提交 | 用户 | 时间
|
8286c6
|
1 |
/** |
懒 |
2 |
* @licstart The following is the entire license notice for the |
|
3 |
* Javascript code in this page |
|
4 |
* |
|
5 |
* Copyright 2018 Mozilla Foundation |
|
6 |
* |
|
7 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 |
* you may not use this file except in compliance with the License. |
|
9 |
* You may obtain a copy of the License at |
|
10 |
* |
|
11 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
12 |
* |
|
13 |
* Unless required by applicable law or agreed to in writing, software |
|
14 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
15 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 |
* See the License for the specific language governing permissions and |
|
17 |
* limitations under the License. |
|
18 |
* |
|
19 |
* @licend The above is the entire license notice for the |
|
20 |
* Javascript code in this page |
|
21 |
*/ |
|
22 |
|
|
23 |
(function webpackUniversalModuleDefinition(root, factory) { |
|
24 |
if(typeof exports === 'object' && typeof module === 'object') |
|
25 |
module.exports = factory(); |
|
26 |
else if(typeof define === 'function' && define.amd) |
|
27 |
define("pdfjs-dist/build/pdf", [], factory); |
|
28 |
else if(typeof exports === 'object') |
|
29 |
exports["pdfjs-dist/build/pdf"] = factory(); |
|
30 |
else |
|
31 |
root["pdfjs-dist/build/pdf"] = root.pdfjsLib = factory(); |
|
32 |
})(this, function() { |
|
33 |
return /******/ (function(modules) { // webpackBootstrap |
|
34 |
/******/ // The module cache |
|
35 |
/******/ var installedModules = {}; |
|
36 |
/******/ |
|
37 |
/******/ // The require function |
|
38 |
/******/ function __w_pdfjs_require__(moduleId) { |
|
39 |
/******/ |
|
40 |
/******/ // Check if module is in cache |
|
41 |
/******/ if(installedModules[moduleId]) { |
|
42 |
/******/ return installedModules[moduleId].exports; |
|
43 |
/******/ } |
|
44 |
/******/ // Create a new module (and put it into the cache) |
|
45 |
/******/ var module = installedModules[moduleId] = { |
|
46 |
/******/ i: moduleId, |
|
47 |
/******/ l: false, |
|
48 |
/******/ exports: {} |
|
49 |
/******/ }; |
|
50 |
/******/ |
|
51 |
/******/ // Execute the module function |
|
52 |
/******/ modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__); |
|
53 |
/******/ |
|
54 |
/******/ // Flag the module as loaded |
|
55 |
/******/ module.l = true; |
|
56 |
/******/ |
|
57 |
/******/ // Return the exports of the module |
|
58 |
/******/ return module.exports; |
|
59 |
/******/ } |
|
60 |
/******/ |
|
61 |
/******/ |
|
62 |
/******/ // expose the modules object (__webpack_modules__) |
|
63 |
/******/ __w_pdfjs_require__.m = modules; |
|
64 |
/******/ |
|
65 |
/******/ // expose the module cache |
|
66 |
/******/ __w_pdfjs_require__.c = installedModules; |
|
67 |
/******/ |
|
68 |
/******/ // define getter function for harmony exports |
|
69 |
/******/ __w_pdfjs_require__.d = function(exports, name, getter) { |
|
70 |
/******/ if(!__w_pdfjs_require__.o(exports, name)) { |
|
71 |
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
|
72 |
/******/ } |
|
73 |
/******/ }; |
|
74 |
/******/ |
|
75 |
/******/ // define __esModule on exports |
|
76 |
/******/ __w_pdfjs_require__.r = function(exports) { |
|
77 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
78 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
79 |
/******/ } |
|
80 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
81 |
/******/ }; |
|
82 |
/******/ |
|
83 |
/******/ // create a fake namespace object |
|
84 |
/******/ // mode & 1: value is a module id, require it |
|
85 |
/******/ // mode & 2: merge all properties of value into the ns |
|
86 |
/******/ // mode & 4: return value when already ns object |
|
87 |
/******/ // mode & 8|1: behave like require |
|
88 |
/******/ __w_pdfjs_require__.t = function(value, mode) { |
|
89 |
/******/ if(mode & 1) value = __w_pdfjs_require__(value); |
|
90 |
/******/ if(mode & 8) return value; |
|
91 |
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
|
92 |
/******/ var ns = Object.create(null); |
|
93 |
/******/ __w_pdfjs_require__.r(ns); |
|
94 |
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
|
95 |
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __w_pdfjs_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
|
96 |
/******/ return ns; |
|
97 |
/******/ }; |
|
98 |
/******/ |
|
99 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
|
100 |
/******/ __w_pdfjs_require__.n = function(module) { |
|
101 |
/******/ var getter = module && module.__esModule ? |
|
102 |
/******/ function getDefault() { return module['default']; } : |
|
103 |
/******/ function getModuleExports() { return module; }; |
|
104 |
/******/ __w_pdfjs_require__.d(getter, 'a', getter); |
|
105 |
/******/ return getter; |
|
106 |
/******/ }; |
|
107 |
/******/ |
|
108 |
/******/ // Object.prototype.hasOwnProperty.call |
|
109 |
/******/ __w_pdfjs_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
110 |
/******/ |
|
111 |
/******/ // __webpack_public_path__ |
|
112 |
/******/ __w_pdfjs_require__.p = ""; |
|
113 |
/******/ |
|
114 |
/******/ |
|
115 |
/******/ // Load entry module and return exports |
|
116 |
/******/ return __w_pdfjs_require__(__w_pdfjs_require__.s = 0); |
|
117 |
/******/ }) |
|
118 |
/************************************************************************/ |
|
119 |
/******/ ([ |
|
120 |
/* 0 */ |
|
121 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
122 |
|
|
123 |
"use strict"; |
|
124 |
|
|
125 |
|
|
126 |
var pdfjsVersion = '2.0.943'; |
|
127 |
var pdfjsBuild = 'dc98bf76'; |
|
128 |
var pdfjsSharedUtil = __w_pdfjs_require__(1); |
|
129 |
var pdfjsDisplayAPI = __w_pdfjs_require__(129); |
|
130 |
var pdfjsDisplayTextLayer = __w_pdfjs_require__(145); |
|
131 |
var pdfjsDisplayAnnotationLayer = __w_pdfjs_require__(146); |
|
132 |
var pdfjsDisplayDOMUtils = __w_pdfjs_require__(130); |
|
133 |
var pdfjsDisplaySVG = __w_pdfjs_require__(147); |
|
134 |
var pdfjsDisplayWorkerOptions = __w_pdfjs_require__(135); |
|
135 |
var pdfjsDisplayAPICompatibility = __w_pdfjs_require__(132); |
|
136 |
{ |
|
137 |
var isNodeJS = __w_pdfjs_require__(4); |
|
138 |
if (isNodeJS()) { |
|
139 |
var PDFNodeStream = __w_pdfjs_require__(148).PDFNodeStream; |
|
140 |
pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) { |
|
141 |
return new PDFNodeStream(params); |
|
142 |
}); |
|
143 |
} else if (typeof Response !== 'undefined' && 'body' in Response.prototype && typeof ReadableStream !== 'undefined') { |
|
144 |
var PDFFetchStream = __w_pdfjs_require__(151).PDFFetchStream; |
|
145 |
pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) { |
|
146 |
return new PDFFetchStream(params); |
|
147 |
}); |
|
148 |
} else { |
|
149 |
var PDFNetworkStream = __w_pdfjs_require__(152).PDFNetworkStream; |
|
150 |
pdfjsDisplayAPI.setPDFNetworkStreamFactory(function (params) { |
|
151 |
return new PDFNetworkStream(params); |
|
152 |
}); |
|
153 |
} |
|
154 |
} |
|
155 |
exports.build = pdfjsDisplayAPI.build; |
|
156 |
exports.version = pdfjsDisplayAPI.version; |
|
157 |
exports.getDocument = pdfjsDisplayAPI.getDocument; |
|
158 |
exports.LoopbackPort = pdfjsDisplayAPI.LoopbackPort; |
|
159 |
exports.PDFDataRangeTransport = pdfjsDisplayAPI.PDFDataRangeTransport; |
|
160 |
exports.PDFWorker = pdfjsDisplayAPI.PDFWorker; |
|
161 |
exports.renderTextLayer = pdfjsDisplayTextLayer.renderTextLayer; |
|
162 |
exports.AnnotationLayer = pdfjsDisplayAnnotationLayer.AnnotationLayer; |
|
163 |
exports.createPromiseCapability = pdfjsSharedUtil.createPromiseCapability; |
|
164 |
exports.PasswordResponses = pdfjsSharedUtil.PasswordResponses; |
|
165 |
exports.InvalidPDFException = pdfjsSharedUtil.InvalidPDFException; |
|
166 |
exports.MissingPDFException = pdfjsSharedUtil.MissingPDFException; |
|
167 |
exports.SVGGraphics = pdfjsDisplaySVG.SVGGraphics; |
|
168 |
exports.NativeImageDecoding = pdfjsSharedUtil.NativeImageDecoding; |
|
169 |
exports.CMapCompressionType = pdfjsSharedUtil.CMapCompressionType; |
|
170 |
exports.PermissionFlag = pdfjsSharedUtil.PermissionFlag; |
|
171 |
exports.UnexpectedResponseException = pdfjsSharedUtil.UnexpectedResponseException; |
|
172 |
exports.OPS = pdfjsSharedUtil.OPS; |
|
173 |
exports.VerbosityLevel = pdfjsSharedUtil.VerbosityLevel; |
|
174 |
exports.UNSUPPORTED_FEATURES = pdfjsSharedUtil.UNSUPPORTED_FEATURES; |
|
175 |
exports.createValidAbsoluteUrl = pdfjsSharedUtil.createValidAbsoluteUrl; |
|
176 |
exports.createObjectURL = pdfjsSharedUtil.createObjectURL; |
|
177 |
exports.removeNullCharacters = pdfjsSharedUtil.removeNullCharacters; |
|
178 |
exports.shadow = pdfjsSharedUtil.shadow; |
|
179 |
exports.Util = pdfjsSharedUtil.Util; |
|
180 |
exports.ReadableStream = pdfjsSharedUtil.ReadableStream; |
|
181 |
exports.URL = pdfjsSharedUtil.URL; |
|
182 |
exports.RenderingCancelledException = pdfjsDisplayDOMUtils.RenderingCancelledException; |
|
183 |
exports.getFilenameFromUrl = pdfjsDisplayDOMUtils.getFilenameFromUrl; |
|
184 |
exports.LinkTarget = pdfjsDisplayDOMUtils.LinkTarget; |
|
185 |
exports.addLinkAttributes = pdfjsDisplayDOMUtils.addLinkAttributes; |
|
186 |
exports.loadScript = pdfjsDisplayDOMUtils.loadScript; |
|
187 |
exports.GlobalWorkerOptions = pdfjsDisplayWorkerOptions.GlobalWorkerOptions; |
|
188 |
exports.apiCompatibilityParams = pdfjsDisplayAPICompatibility.apiCompatibilityParams; |
|
189 |
|
|
190 |
/***/ }), |
|
191 |
/* 1 */ |
|
192 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
193 |
|
|
194 |
"use strict"; |
|
195 |
|
|
196 |
|
|
197 |
Object.defineProperty(exports, "__esModule", { |
|
198 |
value: true |
|
199 |
}); |
|
200 |
exports.unreachable = exports.warn = exports.utf8StringToString = exports.stringToUTF8String = exports.stringToPDFString = exports.stringToBytes = exports.string32 = exports.shadow = exports.setVerbosityLevel = exports.URL = exports.ReadableStream = exports.removeNullCharacters = exports.readUint32 = exports.readUint16 = exports.readInt8 = exports.log2 = exports.isEvalSupported = exports.isLittleEndian = exports.createValidAbsoluteUrl = exports.isSameOrigin = exports.isSpace = exports.isString = exports.isNum = exports.isEmptyObj = exports.isBool = exports.isArrayBuffer = exports.info = exports.getVerbosityLevel = exports.getLookupTableFactory = exports.getInheritableProperty = exports.deprecated = exports.createObjectURL = exports.createPromiseCapability = exports.bytesToString = exports.assert = exports.arraysToBytes = exports.arrayByteLength = exports.FormatError = exports.XRefParseException = exports.toRomanNumerals = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = undefined; |
|
201 |
|
|
202 |
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; }; |
|
203 |
|
|
204 |
__w_pdfjs_require__(2); |
|
205 |
|
|
206 |
var _streams_polyfill = __w_pdfjs_require__(125); |
|
207 |
|
|
208 |
var _url_polyfill = __w_pdfjs_require__(127); |
|
209 |
|
|
210 |
var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0]; |
|
211 |
var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0]; |
|
212 |
var NativeImageDecoding = { |
|
213 |
NONE: 'none', |
|
214 |
DECODE: 'decode', |
|
215 |
DISPLAY: 'display' |
|
216 |
}; |
|
217 |
var PermissionFlag = { |
|
218 |
PRINT: 0x04, |
|
219 |
MODIFY_CONTENTS: 0x08, |
|
220 |
COPY: 0x10, |
|
221 |
MODIFY_ANNOTATIONS: 0x20, |
|
222 |
FILL_INTERACTIVE_FORMS: 0x100, |
|
223 |
COPY_FOR_ACCESSIBILITY: 0x200, |
|
224 |
ASSEMBLE: 0x400, |
|
225 |
PRINT_HIGH_QUALITY: 0x800 |
|
226 |
}; |
|
227 |
var TextRenderingMode = { |
|
228 |
FILL: 0, |
|
229 |
STROKE: 1, |
|
230 |
FILL_STROKE: 2, |
|
231 |
INVISIBLE: 3, |
|
232 |
FILL_ADD_TO_PATH: 4, |
|
233 |
STROKE_ADD_TO_PATH: 5, |
|
234 |
FILL_STROKE_ADD_TO_PATH: 6, |
|
235 |
ADD_TO_PATH: 7, |
|
236 |
FILL_STROKE_MASK: 3, |
|
237 |
ADD_TO_PATH_FLAG: 4 |
|
238 |
}; |
|
239 |
var ImageKind = { |
|
240 |
GRAYSCALE_1BPP: 1, |
|
241 |
RGB_24BPP: 2, |
|
242 |
RGBA_32BPP: 3 |
|
243 |
}; |
|
244 |
var AnnotationType = { |
|
245 |
TEXT: 1, |
|
246 |
LINK: 2, |
|
247 |
FREETEXT: 3, |
|
248 |
LINE: 4, |
|
249 |
SQUARE: 5, |
|
250 |
CIRCLE: 6, |
|
251 |
POLYGON: 7, |
|
252 |
POLYLINE: 8, |
|
253 |
HIGHLIGHT: 9, |
|
254 |
UNDERLINE: 10, |
|
255 |
SQUIGGLY: 11, |
|
256 |
STRIKEOUT: 12, |
|
257 |
STAMP: 13, |
|
258 |
CARET: 14, |
|
259 |
INK: 15, |
|
260 |
POPUP: 16, |
|
261 |
FILEATTACHMENT: 17, |
|
262 |
SOUND: 18, |
|
263 |
MOVIE: 19, |
|
264 |
WIDGET: 20, |
|
265 |
SCREEN: 21, |
|
266 |
PRINTERMARK: 22, |
|
267 |
TRAPNET: 23, |
|
268 |
WATERMARK: 24, |
|
269 |
THREED: 25, |
|
270 |
REDACT: 26 |
|
271 |
}; |
|
272 |
var AnnotationFlag = { |
|
273 |
INVISIBLE: 0x01, |
|
274 |
HIDDEN: 0x02, |
|
275 |
PRINT: 0x04, |
|
276 |
NOZOOM: 0x08, |
|
277 |
NOROTATE: 0x10, |
|
278 |
NOVIEW: 0x20, |
|
279 |
READONLY: 0x40, |
|
280 |
LOCKED: 0x80, |
|
281 |
TOGGLENOVIEW: 0x100, |
|
282 |
LOCKEDCONTENTS: 0x200 |
|
283 |
}; |
|
284 |
var AnnotationFieldFlag = { |
|
285 |
READONLY: 0x0000001, |
|
286 |
REQUIRED: 0x0000002, |
|
287 |
NOEXPORT: 0x0000004, |
|
288 |
MULTILINE: 0x0001000, |
|
289 |
PASSWORD: 0x0002000, |
|
290 |
NOTOGGLETOOFF: 0x0004000, |
|
291 |
RADIO: 0x0008000, |
|
292 |
PUSHBUTTON: 0x0010000, |
|
293 |
COMBO: 0x0020000, |
|
294 |
EDIT: 0x0040000, |
|
295 |
SORT: 0x0080000, |
|
296 |
FILESELECT: 0x0100000, |
|
297 |
MULTISELECT: 0x0200000, |
|
298 |
DONOTSPELLCHECK: 0x0400000, |
|
299 |
DONOTSCROLL: 0x0800000, |
|
300 |
COMB: 0x1000000, |
|
301 |
RICHTEXT: 0x2000000, |
|
302 |
RADIOSINUNISON: 0x2000000, |
|
303 |
COMMITONSELCHANGE: 0x4000000 |
|
304 |
}; |
|
305 |
var AnnotationBorderStyleType = { |
|
306 |
SOLID: 1, |
|
307 |
DASHED: 2, |
|
308 |
BEVELED: 3, |
|
309 |
INSET: 4, |
|
310 |
UNDERLINE: 5 |
|
311 |
}; |
|
312 |
var StreamType = { |
|
313 |
UNKNOWN: 0, |
|
314 |
FLATE: 1, |
|
315 |
LZW: 2, |
|
316 |
DCT: 3, |
|
317 |
JPX: 4, |
|
318 |
JBIG: 5, |
|
319 |
A85: 6, |
|
320 |
AHX: 7, |
|
321 |
CCF: 8, |
|
322 |
RL: 9 |
|
323 |
}; |
|
324 |
var FontType = { |
|
325 |
UNKNOWN: 0, |
|
326 |
TYPE1: 1, |
|
327 |
TYPE1C: 2, |
|
328 |
CIDFONTTYPE0: 3, |
|
329 |
CIDFONTTYPE0C: 4, |
|
330 |
TRUETYPE: 5, |
|
331 |
CIDFONTTYPE2: 6, |
|
332 |
TYPE3: 7, |
|
333 |
OPENTYPE: 8, |
|
334 |
TYPE0: 9, |
|
335 |
MMTYPE1: 10 |
|
336 |
}; |
|
337 |
var VerbosityLevel = { |
|
338 |
ERRORS: 0, |
|
339 |
WARNINGS: 1, |
|
340 |
INFOS: 5 |
|
341 |
}; |
|
342 |
var CMapCompressionType = { |
|
343 |
NONE: 0, |
|
344 |
BINARY: 1, |
|
345 |
STREAM: 2 |
|
346 |
}; |
|
347 |
var OPS = { |
|
348 |
dependency: 1, |
|
349 |
setLineWidth: 2, |
|
350 |
setLineCap: 3, |
|
351 |
setLineJoin: 4, |
|
352 |
setMiterLimit: 5, |
|
353 |
setDash: 6, |
|
354 |
setRenderingIntent: 7, |
|
355 |
setFlatness: 8, |
|
356 |
setGState: 9, |
|
357 |
save: 10, |
|
358 |
restore: 11, |
|
359 |
transform: 12, |
|
360 |
moveTo: 13, |
|
361 |
lineTo: 14, |
|
362 |
curveTo: 15, |
|
363 |
curveTo2: 16, |
|
364 |
curveTo3: 17, |
|
365 |
closePath: 18, |
|
366 |
rectangle: 19, |
|
367 |
stroke: 20, |
|
368 |
closeStroke: 21, |
|
369 |
fill: 22, |
|
370 |
eoFill: 23, |
|
371 |
fillStroke: 24, |
|
372 |
eoFillStroke: 25, |
|
373 |
closeFillStroke: 26, |
|
374 |
closeEOFillStroke: 27, |
|
375 |
endPath: 28, |
|
376 |
clip: 29, |
|
377 |
eoClip: 30, |
|
378 |
beginText: 31, |
|
379 |
endText: 32, |
|
380 |
setCharSpacing: 33, |
|
381 |
setWordSpacing: 34, |
|
382 |
setHScale: 35, |
|
383 |
setLeading: 36, |
|
384 |
setFont: 37, |
|
385 |
setTextRenderingMode: 38, |
|
386 |
setTextRise: 39, |
|
387 |
moveText: 40, |
|
388 |
setLeadingMoveText: 41, |
|
389 |
setTextMatrix: 42, |
|
390 |
nextLine: 43, |
|
391 |
showText: 44, |
|
392 |
showSpacedText: 45, |
|
393 |
nextLineShowText: 46, |
|
394 |
nextLineSetSpacingShowText: 47, |
|
395 |
setCharWidth: 48, |
|
396 |
setCharWidthAndBounds: 49, |
|
397 |
setStrokeColorSpace: 50, |
|
398 |
setFillColorSpace: 51, |
|
399 |
setStrokeColor: 52, |
|
400 |
setStrokeColorN: 53, |
|
401 |
setFillColor: 54, |
|
402 |
setFillColorN: 55, |
|
403 |
setStrokeGray: 56, |
|
404 |
setFillGray: 57, |
|
405 |
setStrokeRGBColor: 58, |
|
406 |
setFillRGBColor: 59, |
|
407 |
setStrokeCMYKColor: 60, |
|
408 |
setFillCMYKColor: 61, |
|
409 |
shadingFill: 62, |
|
410 |
beginInlineImage: 63, |
|
411 |
beginImageData: 64, |
|
412 |
endInlineImage: 65, |
|
413 |
paintXObject: 66, |
|
414 |
markPoint: 67, |
|
415 |
markPointProps: 68, |
|
416 |
beginMarkedContent: 69, |
|
417 |
beginMarkedContentProps: 70, |
|
418 |
endMarkedContent: 71, |
|
419 |
beginCompat: 72, |
|
420 |
endCompat: 73, |
|
421 |
paintFormXObjectBegin: 74, |
|
422 |
paintFormXObjectEnd: 75, |
|
423 |
beginGroup: 76, |
|
424 |
endGroup: 77, |
|
425 |
beginAnnotations: 78, |
|
426 |
endAnnotations: 79, |
|
427 |
beginAnnotation: 80, |
|
428 |
endAnnotation: 81, |
|
429 |
paintJpegXObject: 82, |
|
430 |
paintImageMaskXObject: 83, |
|
431 |
paintImageMaskXObjectGroup: 84, |
|
432 |
paintImageXObject: 85, |
|
433 |
paintInlineImageXObject: 86, |
|
434 |
paintInlineImageXObjectGroup: 87, |
|
435 |
paintImageXObjectRepeat: 88, |
|
436 |
paintImageMaskXObjectRepeat: 89, |
|
437 |
paintSolidColorImageMask: 90, |
|
438 |
constructPath: 91 |
|
439 |
}; |
|
440 |
var UNSUPPORTED_FEATURES = { |
|
441 |
unknown: 'unknown', |
|
442 |
forms: 'forms', |
|
443 |
javaScript: 'javaScript', |
|
444 |
smask: 'smask', |
|
445 |
shadingPattern: 'shadingPattern', |
|
446 |
font: 'font' |
|
447 |
}; |
|
448 |
var PasswordResponses = { |
|
449 |
NEED_PASSWORD: 1, |
|
450 |
INCORRECT_PASSWORD: 2 |
|
451 |
}; |
|
452 |
var verbosity = VerbosityLevel.WARNINGS; |
|
453 |
function setVerbosityLevel(level) { |
|
454 |
if (Number.isInteger(level)) { |
|
455 |
verbosity = level; |
|
456 |
} |
|
457 |
} |
|
458 |
function getVerbosityLevel() { |
|
459 |
return verbosity; |
|
460 |
} |
|
461 |
function info(msg) { |
|
462 |
if (verbosity >= VerbosityLevel.INFOS) { |
|
463 |
console.log('Info: ' + msg); |
|
464 |
} |
|
465 |
} |
|
466 |
function warn(msg) { |
|
467 |
if (verbosity >= VerbosityLevel.WARNINGS) { |
|
468 |
console.log('Warning: ' + msg); |
|
469 |
} |
|
470 |
} |
|
471 |
function deprecated(details) { |
|
472 |
console.log('Deprecated API usage: ' + details); |
|
473 |
} |
|
474 |
function unreachable(msg) { |
|
475 |
throw new Error(msg); |
|
476 |
} |
|
477 |
function assert(cond, msg) { |
|
478 |
if (!cond) { |
|
479 |
unreachable(msg); |
|
480 |
} |
|
481 |
} |
|
482 |
function isSameOrigin(baseUrl, otherUrl) { |
|
483 |
try { |
|
484 |
var base = new _url_polyfill.URL(baseUrl); |
|
485 |
if (!base.origin || base.origin === 'null') { |
|
486 |
return false; |
|
487 |
} |
|
488 |
} catch (e) { |
|
489 |
return false; |
|
490 |
} |
|
491 |
var other = new _url_polyfill.URL(otherUrl, base); |
|
492 |
return base.origin === other.origin; |
|
493 |
} |
|
494 |
function _isValidProtocol(url) { |
|
495 |
if (!url) { |
|
496 |
return false; |
|
497 |
} |
|
498 |
switch (url.protocol) { |
|
499 |
case 'http:': |
|
500 |
case 'https:': |
|
501 |
case 'ftp:': |
|
502 |
case 'mailto:': |
|
503 |
case 'tel:': |
|
504 |
return true; |
|
505 |
default: |
|
506 |
return false; |
|
507 |
} |
|
508 |
} |
|
509 |
function createValidAbsoluteUrl(url, baseUrl) { |
|
510 |
if (!url) { |
|
511 |
return null; |
|
512 |
} |
|
513 |
try { |
|
514 |
var absoluteUrl = baseUrl ? new _url_polyfill.URL(url, baseUrl) : new _url_polyfill.URL(url); |
|
515 |
if (_isValidProtocol(absoluteUrl)) { |
|
516 |
return absoluteUrl; |
|
517 |
} |
|
518 |
} catch (ex) {} |
|
519 |
return null; |
|
520 |
} |
|
521 |
function shadow(obj, prop, value) { |
|
522 |
Object.defineProperty(obj, prop, { |
|
523 |
value: value, |
|
524 |
enumerable: true, |
|
525 |
configurable: true, |
|
526 |
writable: false |
|
527 |
}); |
|
528 |
return value; |
|
529 |
} |
|
530 |
function getLookupTableFactory(initializer) { |
|
531 |
var lookup; |
|
532 |
return function () { |
|
533 |
if (initializer) { |
|
534 |
lookup = Object.create(null); |
|
535 |
initializer(lookup); |
|
536 |
initializer = null; |
|
537 |
} |
|
538 |
return lookup; |
|
539 |
}; |
|
540 |
} |
|
541 |
var PasswordException = function PasswordExceptionClosure() { |
|
542 |
function PasswordException(msg, code) { |
|
543 |
this.name = 'PasswordException'; |
|
544 |
this.message = msg; |
|
545 |
this.code = code; |
|
546 |
} |
|
547 |
PasswordException.prototype = new Error(); |
|
548 |
PasswordException.constructor = PasswordException; |
|
549 |
return PasswordException; |
|
550 |
}(); |
|
551 |
var UnknownErrorException = function UnknownErrorExceptionClosure() { |
|
552 |
function UnknownErrorException(msg, details) { |
|
553 |
this.name = 'UnknownErrorException'; |
|
554 |
this.message = msg; |
|
555 |
this.details = details; |
|
556 |
} |
|
557 |
UnknownErrorException.prototype = new Error(); |
|
558 |
UnknownErrorException.constructor = UnknownErrorException; |
|
559 |
return UnknownErrorException; |
|
560 |
}(); |
|
561 |
var InvalidPDFException = function InvalidPDFExceptionClosure() { |
|
562 |
function InvalidPDFException(msg) { |
|
563 |
this.name = 'InvalidPDFException'; |
|
564 |
this.message = msg; |
|
565 |
} |
|
566 |
InvalidPDFException.prototype = new Error(); |
|
567 |
InvalidPDFException.constructor = InvalidPDFException; |
|
568 |
return InvalidPDFException; |
|
569 |
}(); |
|
570 |
var MissingPDFException = function MissingPDFExceptionClosure() { |
|
571 |
function MissingPDFException(msg) { |
|
572 |
this.name = 'MissingPDFException'; |
|
573 |
this.message = msg; |
|
574 |
} |
|
575 |
MissingPDFException.prototype = new Error(); |
|
576 |
MissingPDFException.constructor = MissingPDFException; |
|
577 |
return MissingPDFException; |
|
578 |
}(); |
|
579 |
var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() { |
|
580 |
function UnexpectedResponseException(msg, status) { |
|
581 |
this.name = 'UnexpectedResponseException'; |
|
582 |
this.message = msg; |
|
583 |
this.status = status; |
|
584 |
} |
|
585 |
UnexpectedResponseException.prototype = new Error(); |
|
586 |
UnexpectedResponseException.constructor = UnexpectedResponseException; |
|
587 |
return UnexpectedResponseException; |
|
588 |
}(); |
|
589 |
var MissingDataException = function MissingDataExceptionClosure() { |
|
590 |
function MissingDataException(begin, end) { |
|
591 |
this.begin = begin; |
|
592 |
this.end = end; |
|
593 |
this.message = 'Missing data [' + begin + ', ' + end + ')'; |
|
594 |
} |
|
595 |
MissingDataException.prototype = new Error(); |
|
596 |
MissingDataException.prototype.name = 'MissingDataException'; |
|
597 |
MissingDataException.constructor = MissingDataException; |
|
598 |
return MissingDataException; |
|
599 |
}(); |
|
600 |
var XRefParseException = function XRefParseExceptionClosure() { |
|
601 |
function XRefParseException(msg) { |
|
602 |
this.message = msg; |
|
603 |
} |
|
604 |
XRefParseException.prototype = new Error(); |
|
605 |
XRefParseException.prototype.name = 'XRefParseException'; |
|
606 |
XRefParseException.constructor = XRefParseException; |
|
607 |
return XRefParseException; |
|
608 |
}(); |
|
609 |
var FormatError = function FormatErrorClosure() { |
|
610 |
function FormatError(msg) { |
|
611 |
this.message = msg; |
|
612 |
} |
|
613 |
FormatError.prototype = new Error(); |
|
614 |
FormatError.prototype.name = 'FormatError'; |
|
615 |
FormatError.constructor = FormatError; |
|
616 |
return FormatError; |
|
617 |
}(); |
|
618 |
var AbortException = function AbortExceptionClosure() { |
|
619 |
function AbortException(msg) { |
|
620 |
this.name = 'AbortException'; |
|
621 |
this.message = msg; |
|
622 |
} |
|
623 |
AbortException.prototype = new Error(); |
|
624 |
AbortException.constructor = AbortException; |
|
625 |
return AbortException; |
|
626 |
}(); |
|
627 |
var NullCharactersRegExp = /\x00/g; |
|
628 |
function removeNullCharacters(str) { |
|
629 |
if (typeof str !== 'string') { |
|
630 |
warn('The argument for removeNullCharacters must be a string.'); |
|
631 |
return str; |
|
632 |
} |
|
633 |
return str.replace(NullCharactersRegExp, ''); |
|
634 |
} |
|
635 |
function bytesToString(bytes) { |
|
636 |
assert(bytes !== null && (typeof bytes === 'undefined' ? 'undefined' : _typeof(bytes)) === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString'); |
|
637 |
var length = bytes.length; |
|
638 |
var MAX_ARGUMENT_COUNT = 8192; |
|
639 |
if (length < MAX_ARGUMENT_COUNT) { |
|
640 |
return String.fromCharCode.apply(null, bytes); |
|
641 |
} |
|
642 |
var strBuf = []; |
|
643 |
for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) { |
|
644 |
var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length); |
|
645 |
var chunk = bytes.subarray(i, chunkEnd); |
|
646 |
strBuf.push(String.fromCharCode.apply(null, chunk)); |
|
647 |
} |
|
648 |
return strBuf.join(''); |
|
649 |
} |
|
650 |
function stringToBytes(str) { |
|
651 |
assert(typeof str === 'string', 'Invalid argument for stringToBytes'); |
|
652 |
var length = str.length; |
|
653 |
var bytes = new Uint8Array(length); |
|
654 |
for (var i = 0; i < length; ++i) { |
|
655 |
bytes[i] = str.charCodeAt(i) & 0xFF; |
|
656 |
} |
|
657 |
return bytes; |
|
658 |
} |
|
659 |
function arrayByteLength(arr) { |
|
660 |
if (arr.length !== undefined) { |
|
661 |
return arr.length; |
|
662 |
} |
|
663 |
assert(arr.byteLength !== undefined); |
|
664 |
return arr.byteLength; |
|
665 |
} |
|
666 |
function arraysToBytes(arr) { |
|
667 |
if (arr.length === 1 && arr[0] instanceof Uint8Array) { |
|
668 |
return arr[0]; |
|
669 |
} |
|
670 |
var resultLength = 0; |
|
671 |
var i, |
|
672 |
ii = arr.length; |
|
673 |
var item, itemLength; |
|
674 |
for (i = 0; i < ii; i++) { |
|
675 |
item = arr[i]; |
|
676 |
itemLength = arrayByteLength(item); |
|
677 |
resultLength += itemLength; |
|
678 |
} |
|
679 |
var pos = 0; |
|
680 |
var data = new Uint8Array(resultLength); |
|
681 |
for (i = 0; i < ii; i++) { |
|
682 |
item = arr[i]; |
|
683 |
if (!(item instanceof Uint8Array)) { |
|
684 |
if (typeof item === 'string') { |
|
685 |
item = stringToBytes(item); |
|
686 |
} else { |
|
687 |
item = new Uint8Array(item); |
|
688 |
} |
|
689 |
} |
|
690 |
itemLength = item.byteLength; |
|
691 |
data.set(item, pos); |
|
692 |
pos += itemLength; |
|
693 |
} |
|
694 |
return data; |
|
695 |
} |
|
696 |
function string32(value) { |
|
697 |
return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff); |
|
698 |
} |
|
699 |
function log2(x) { |
|
700 |
if (x <= 0) { |
|
701 |
return 0; |
|
702 |
} |
|
703 |
return Math.ceil(Math.log2(x)); |
|
704 |
} |
|
705 |
function readInt8(data, start) { |
|
706 |
return data[start] << 24 >> 24; |
|
707 |
} |
|
708 |
function readUint16(data, offset) { |
|
709 |
return data[offset] << 8 | data[offset + 1]; |
|
710 |
} |
|
711 |
function readUint32(data, offset) { |
|
712 |
return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0; |
|
713 |
} |
|
714 |
function isLittleEndian() { |
|
715 |
var buffer8 = new Uint8Array(4); |
|
716 |
buffer8[0] = 1; |
|
717 |
var view32 = new Uint32Array(buffer8.buffer, 0, 1); |
|
718 |
return view32[0] === 1; |
|
719 |
} |
|
720 |
function isEvalSupported() { |
|
721 |
try { |
|
722 |
new Function(''); |
|
723 |
return true; |
|
724 |
} catch (e) { |
|
725 |
return false; |
|
726 |
} |
|
727 |
} |
|
728 |
function getInheritableProperty(_ref) { |
|
729 |
var dict = _ref.dict, |
|
730 |
key = _ref.key, |
|
731 |
_ref$getArray = _ref.getArray, |
|
732 |
getArray = _ref$getArray === undefined ? false : _ref$getArray, |
|
733 |
_ref$stopWhenFound = _ref.stopWhenFound, |
|
734 |
stopWhenFound = _ref$stopWhenFound === undefined ? true : _ref$stopWhenFound; |
|
735 |
|
|
736 |
var LOOP_LIMIT = 100; |
|
737 |
var loopCount = 0; |
|
738 |
var values = void 0; |
|
739 |
while (dict) { |
|
740 |
var value = getArray ? dict.getArray(key) : dict.get(key); |
|
741 |
if (value !== undefined) { |
|
742 |
if (stopWhenFound) { |
|
743 |
return value; |
|
744 |
} |
|
745 |
if (!values) { |
|
746 |
values = []; |
|
747 |
} |
|
748 |
values.push(value); |
|
749 |
} |
|
750 |
if (++loopCount > LOOP_LIMIT) { |
|
751 |
warn('getInheritableProperty: maximum loop count exceeded for "' + key + '"'); |
|
752 |
break; |
|
753 |
} |
|
754 |
dict = dict.get('Parent'); |
|
755 |
} |
|
756 |
return values; |
|
757 |
} |
|
758 |
var Util = function UtilClosure() { |
|
759 |
function Util() {} |
|
760 |
var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')']; |
|
761 |
Util.makeCssRgb = function Util_makeCssRgb(r, g, b) { |
|
762 |
rgbBuf[1] = r; |
|
763 |
rgbBuf[3] = g; |
|
764 |
rgbBuf[5] = b; |
|
765 |
return rgbBuf.join(''); |
|
766 |
}; |
|
767 |
Util.transform = function Util_transform(m1, m2) { |
|
768 |
return [m1[0] * m2[0] + m1[2] * m2[1], m1[1] * m2[0] + m1[3] * m2[1], m1[0] * m2[2] + m1[2] * m2[3], m1[1] * m2[2] + m1[3] * m2[3], m1[0] * m2[4] + m1[2] * m2[5] + m1[4], m1[1] * m2[4] + m1[3] * m2[5] + m1[5]]; |
|
769 |
}; |
|
770 |
Util.applyTransform = function Util_applyTransform(p, m) { |
|
771 |
var xt = p[0] * m[0] + p[1] * m[2] + m[4]; |
|
772 |
var yt = p[0] * m[1] + p[1] * m[3] + m[5]; |
|
773 |
return [xt, yt]; |
|
774 |
}; |
|
775 |
Util.applyInverseTransform = function Util_applyInverseTransform(p, m) { |
|
776 |
var d = m[0] * m[3] - m[1] * m[2]; |
|
777 |
var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d; |
|
778 |
var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d; |
|
779 |
return [xt, yt]; |
|
780 |
}; |
|
781 |
Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) { |
|
782 |
var p1 = Util.applyTransform(r, m); |
|
783 |
var p2 = Util.applyTransform(r.slice(2, 4), m); |
|
784 |
var p3 = Util.applyTransform([r[0], r[3]], m); |
|
785 |
var p4 = Util.applyTransform([r[2], r[1]], m); |
|
786 |
return [Math.min(p1[0], p2[0], p3[0], p4[0]), Math.min(p1[1], p2[1], p3[1], p4[1]), Math.max(p1[0], p2[0], p3[0], p4[0]), Math.max(p1[1], p2[1], p3[1], p4[1])]; |
|
787 |
}; |
|
788 |
Util.inverseTransform = function Util_inverseTransform(m) { |
|
789 |
var d = m[0] * m[3] - m[1] * m[2]; |
|
790 |
return [m[3] / d, -m[1] / d, -m[2] / d, m[0] / d, (m[2] * m[5] - m[4] * m[3]) / d, (m[4] * m[1] - m[5] * m[0]) / d]; |
|
791 |
}; |
|
792 |
Util.apply3dTransform = function Util_apply3dTransform(m, v) { |
|
793 |
return [m[0] * v[0] + m[1] * v[1] + m[2] * v[2], m[3] * v[0] + m[4] * v[1] + m[5] * v[2], m[6] * v[0] + m[7] * v[1] + m[8] * v[2]]; |
|
794 |
}; |
|
795 |
Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) { |
|
796 |
var transpose = [m[0], m[2], m[1], m[3]]; |
|
797 |
var a = m[0] * transpose[0] + m[1] * transpose[2]; |
|
798 |
var b = m[0] * transpose[1] + m[1] * transpose[3]; |
|
799 |
var c = m[2] * transpose[0] + m[3] * transpose[2]; |
|
800 |
var d = m[2] * transpose[1] + m[3] * transpose[3]; |
|
801 |
var first = (a + d) / 2; |
|
802 |
var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2; |
|
803 |
var sx = first + second || 1; |
|
804 |
var sy = first - second || 1; |
|
805 |
return [Math.sqrt(sx), Math.sqrt(sy)]; |
|
806 |
}; |
|
807 |
Util.normalizeRect = function Util_normalizeRect(rect) { |
|
808 |
var r = rect.slice(0); |
|
809 |
if (rect[0] > rect[2]) { |
|
810 |
r[0] = rect[2]; |
|
811 |
r[2] = rect[0]; |
|
812 |
} |
|
813 |
if (rect[1] > rect[3]) { |
|
814 |
r[1] = rect[3]; |
|
815 |
r[3] = rect[1]; |
|
816 |
} |
|
817 |
return r; |
|
818 |
}; |
|
819 |
Util.intersect = function Util_intersect(rect1, rect2) { |
|
820 |
function compare(a, b) { |
|
821 |
return a - b; |
|
822 |
} |
|
823 |
var orderedX = [rect1[0], rect1[2], rect2[0], rect2[2]].sort(compare), |
|
824 |
orderedY = [rect1[1], rect1[3], rect2[1], rect2[3]].sort(compare), |
|
825 |
result = []; |
|
826 |
rect1 = Util.normalizeRect(rect1); |
|
827 |
rect2 = Util.normalizeRect(rect2); |
|
828 |
if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) { |
|
829 |
result[0] = orderedX[1]; |
|
830 |
result[2] = orderedX[2]; |
|
831 |
} else { |
|
832 |
return false; |
|
833 |
} |
|
834 |
if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) { |
|
835 |
result[1] = orderedY[1]; |
|
836 |
result[3] = orderedY[2]; |
|
837 |
} else { |
|
838 |
return false; |
|
839 |
} |
|
840 |
return result; |
|
841 |
}; |
|
842 |
return Util; |
|
843 |
}(); |
|
844 |
var ROMAN_NUMBER_MAP = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM', '', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC', '', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']; |
|
845 |
function toRomanNumerals(number) { |
|
846 |
var lowerCase = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
|
847 |
|
|
848 |
assert(Number.isInteger(number) && number > 0, 'The number should be a positive integer.'); |
|
849 |
var pos = void 0, |
|
850 |
romanBuf = []; |
|
851 |
while (number >= 1000) { |
|
852 |
number -= 1000; |
|
853 |
romanBuf.push('M'); |
|
854 |
} |
|
855 |
pos = number / 100 | 0; |
|
856 |
number %= 100; |
|
857 |
romanBuf.push(ROMAN_NUMBER_MAP[pos]); |
|
858 |
pos = number / 10 | 0; |
|
859 |
number %= 10; |
|
860 |
romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]); |
|
861 |
romanBuf.push(ROMAN_NUMBER_MAP[20 + number]); |
|
862 |
var romanStr = romanBuf.join(''); |
|
863 |
return lowerCase ? romanStr.toLowerCase() : romanStr; |
|
864 |
} |
|
865 |
var PDFStringTranslateTable = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2D8, 0x2C7, 0x2C6, 0x2D9, 0x2DD, 0x2DB, 0x2DA, 0x2DC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192, 0x2044, 0x2039, 0x203A, 0x2212, 0x2030, 0x201E, 0x201C, 0x201D, 0x2018, 0x2019, 0x201A, 0x2122, 0xFB01, 0xFB02, 0x141, 0x152, 0x160, 0x178, 0x17D, 0x131, 0x142, 0x153, 0x161, 0x17E, 0, 0x20AC]; |
|
866 |
function stringToPDFString(str) { |
|
867 |
var i, |
|
868 |
n = str.length, |
|
869 |
strBuf = []; |
|
870 |
if (str[0] === '\xFE' && str[1] === '\xFF') { |
|
871 |
for (i = 2; i < n; i += 2) { |
|
872 |
strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1))); |
|
873 |
} |
|
874 |
} else { |
|
875 |
for (i = 0; i < n; ++i) { |
|
876 |
var code = PDFStringTranslateTable[str.charCodeAt(i)]; |
|
877 |
strBuf.push(code ? String.fromCharCode(code) : str.charAt(i)); |
|
878 |
} |
|
879 |
} |
|
880 |
return strBuf.join(''); |
|
881 |
} |
|
882 |
function stringToUTF8String(str) { |
|
883 |
return decodeURIComponent(escape(str)); |
|
884 |
} |
|
885 |
function utf8StringToString(str) { |
|
886 |
return unescape(encodeURIComponent(str)); |
|
887 |
} |
|
888 |
function isEmptyObj(obj) { |
|
889 |
for (var key in obj) { |
|
890 |
return false; |
|
891 |
} |
|
892 |
return true; |
|
893 |
} |
|
894 |
function isBool(v) { |
|
895 |
return typeof v === 'boolean'; |
|
896 |
} |
|
897 |
function isNum(v) { |
|
898 |
return typeof v === 'number'; |
|
899 |
} |
|
900 |
function isString(v) { |
|
901 |
return typeof v === 'string'; |
|
902 |
} |
|
903 |
function isArrayBuffer(v) { |
|
904 |
return (typeof v === 'undefined' ? 'undefined' : _typeof(v)) === 'object' && v !== null && v.byteLength !== undefined; |
|
905 |
} |
|
906 |
function isSpace(ch) { |
|
907 |
return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A; |
|
908 |
} |
|
909 |
function createPromiseCapability() { |
|
910 |
var capability = {}; |
|
911 |
capability.promise = new Promise(function (resolve, reject) { |
|
912 |
capability.resolve = resolve; |
|
913 |
capability.reject = reject; |
|
914 |
}); |
|
915 |
return capability; |
|
916 |
} |
|
917 |
var createObjectURL = function createObjectURLClosure() { |
|
918 |
var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; |
|
919 |
return function createObjectURL(data, contentType) { |
|
920 |
var forceDataSchema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
|
921 |
|
|
922 |
if (!forceDataSchema && _url_polyfill.URL.createObjectURL) { |
|
923 |
var blob = new Blob([data], { type: contentType }); |
|
924 |
return _url_polyfill.URL.createObjectURL(blob); |
|
925 |
} |
|
926 |
var buffer = 'data:' + contentType + ';base64,'; |
|
927 |
for (var i = 0, ii = data.length; i < ii; i += 3) { |
|
928 |
var b1 = data[i] & 0xFF; |
|
929 |
var b2 = data[i + 1] & 0xFF; |
|
930 |
var b3 = data[i + 2] & 0xFF; |
|
931 |
var d1 = b1 >> 2, |
|
932 |
d2 = (b1 & 3) << 4 | b2 >> 4; |
|
933 |
var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64; |
|
934 |
var d4 = i + 2 < ii ? b3 & 0x3F : 64; |
|
935 |
buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4]; |
|
936 |
} |
|
937 |
return buffer; |
|
938 |
}; |
|
939 |
}(); |
|
940 |
exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX; |
|
941 |
exports.IDENTITY_MATRIX = IDENTITY_MATRIX; |
|
942 |
exports.OPS = OPS; |
|
943 |
exports.VerbosityLevel = VerbosityLevel; |
|
944 |
exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES; |
|
945 |
exports.AnnotationBorderStyleType = AnnotationBorderStyleType; |
|
946 |
exports.AnnotationFieldFlag = AnnotationFieldFlag; |
|
947 |
exports.AnnotationFlag = AnnotationFlag; |
|
948 |
exports.AnnotationType = AnnotationType; |
|
949 |
exports.FontType = FontType; |
|
950 |
exports.ImageKind = ImageKind; |
|
951 |
exports.CMapCompressionType = CMapCompressionType; |
|
952 |
exports.AbortException = AbortException; |
|
953 |
exports.InvalidPDFException = InvalidPDFException; |
|
954 |
exports.MissingDataException = MissingDataException; |
|
955 |
exports.MissingPDFException = MissingPDFException; |
|
956 |
exports.NativeImageDecoding = NativeImageDecoding; |
|
957 |
exports.PasswordException = PasswordException; |
|
958 |
exports.PasswordResponses = PasswordResponses; |
|
959 |
exports.PermissionFlag = PermissionFlag; |
|
960 |
exports.StreamType = StreamType; |
|
961 |
exports.TextRenderingMode = TextRenderingMode; |
|
962 |
exports.UnexpectedResponseException = UnexpectedResponseException; |
|
963 |
exports.UnknownErrorException = UnknownErrorException; |
|
964 |
exports.Util = Util; |
|
965 |
exports.toRomanNumerals = toRomanNumerals; |
|
966 |
exports.XRefParseException = XRefParseException; |
|
967 |
exports.FormatError = FormatError; |
|
968 |
exports.arrayByteLength = arrayByteLength; |
|
969 |
exports.arraysToBytes = arraysToBytes; |
|
970 |
exports.assert = assert; |
|
971 |
exports.bytesToString = bytesToString; |
|
972 |
exports.createPromiseCapability = createPromiseCapability; |
|
973 |
exports.createObjectURL = createObjectURL; |
|
974 |
exports.deprecated = deprecated; |
|
975 |
exports.getInheritableProperty = getInheritableProperty; |
|
976 |
exports.getLookupTableFactory = getLookupTableFactory; |
|
977 |
exports.getVerbosityLevel = getVerbosityLevel; |
|
978 |
exports.info = info; |
|
979 |
exports.isArrayBuffer = isArrayBuffer; |
|
980 |
exports.isBool = isBool; |
|
981 |
exports.isEmptyObj = isEmptyObj; |
|
982 |
exports.isNum = isNum; |
|
983 |
exports.isString = isString; |
|
984 |
exports.isSpace = isSpace; |
|
985 |
exports.isSameOrigin = isSameOrigin; |
|
986 |
exports.createValidAbsoluteUrl = createValidAbsoluteUrl; |
|
987 |
exports.isLittleEndian = isLittleEndian; |
|
988 |
exports.isEvalSupported = isEvalSupported; |
|
989 |
exports.log2 = log2; |
|
990 |
exports.readInt8 = readInt8; |
|
991 |
exports.readUint16 = readUint16; |
|
992 |
exports.readUint32 = readUint32; |
|
993 |
exports.removeNullCharacters = removeNullCharacters; |
|
994 |
exports.ReadableStream = _streams_polyfill.ReadableStream; |
|
995 |
exports.URL = _url_polyfill.URL; |
|
996 |
exports.setVerbosityLevel = setVerbosityLevel; |
|
997 |
exports.shadow = shadow; |
|
998 |
exports.string32 = string32; |
|
999 |
exports.stringToBytes = stringToBytes; |
|
1000 |
exports.stringToPDFString = stringToPDFString; |
|
1001 |
exports.stringToUTF8String = stringToUTF8String; |
|
1002 |
exports.utf8StringToString = utf8StringToString; |
|
1003 |
exports.warn = warn; |
|
1004 |
exports.unreachable = unreachable; |
|
1005 |
|
|
1006 |
/***/ }), |
|
1007 |
/* 2 */ |
|
1008 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1009 |
|
|
1010 |
"use strict"; |
|
1011 |
|
|
1012 |
|
|
1013 |
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; }; |
|
1014 |
|
|
1015 |
var globalScope = __w_pdfjs_require__(3); |
|
1016 |
if (!globalScope._pdfjsCompatibilityChecked) { |
|
1017 |
globalScope._pdfjsCompatibilityChecked = true; |
|
1018 |
var isNodeJS = __w_pdfjs_require__(4); |
|
1019 |
var hasDOM = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) === 'object' && (typeof document === 'undefined' ? 'undefined' : _typeof(document)) === 'object'; |
|
1020 |
(function checkNodeBtoa() { |
|
1021 |
if (globalScope.btoa || !isNodeJS()) { |
|
1022 |
return; |
|
1023 |
} |
|
1024 |
globalScope.btoa = function (chars) { |
|
1025 |
return Buffer.from(chars, 'binary').toString('base64'); |
|
1026 |
}; |
|
1027 |
})(); |
|
1028 |
(function checkNodeAtob() { |
|
1029 |
if (globalScope.atob || !isNodeJS()) { |
|
1030 |
return; |
|
1031 |
} |
|
1032 |
globalScope.atob = function (input) { |
|
1033 |
return Buffer.from(input, 'base64').toString('binary'); |
|
1034 |
}; |
|
1035 |
})(); |
|
1036 |
(function checkCurrentScript() { |
|
1037 |
if (!hasDOM) { |
|
1038 |
return; |
|
1039 |
} |
|
1040 |
if ('currentScript' in document) { |
|
1041 |
return; |
|
1042 |
} |
|
1043 |
Object.defineProperty(document, 'currentScript', { |
|
1044 |
get: function get() { |
|
1045 |
var scripts = document.getElementsByTagName('script'); |
|
1046 |
return scripts[scripts.length - 1]; |
|
1047 |
}, |
|
1048 |
|
|
1049 |
enumerable: true, |
|
1050 |
configurable: true |
|
1051 |
}); |
|
1052 |
})(); |
|
1053 |
(function checkChildNodeRemove() { |
|
1054 |
if (!hasDOM) { |
|
1055 |
return; |
|
1056 |
} |
|
1057 |
if (typeof Element.prototype.remove !== 'undefined') { |
|
1058 |
return; |
|
1059 |
} |
|
1060 |
Element.prototype.remove = function () { |
|
1061 |
if (this.parentNode) { |
|
1062 |
this.parentNode.removeChild(this); |
|
1063 |
} |
|
1064 |
}; |
|
1065 |
})(); |
|
1066 |
(function checkDOMTokenListToggle() { |
|
1067 |
if (!hasDOM || isNodeJS()) { |
|
1068 |
return; |
|
1069 |
} |
|
1070 |
var div = document.createElement('div'); |
|
1071 |
if (div.classList.toggle('test', 0) === false) { |
|
1072 |
return; |
|
1073 |
} |
|
1074 |
var originalDOMTokenListToggle = DOMTokenList.prototype.toggle; |
|
1075 |
DOMTokenList.prototype.toggle = function (token) { |
|
1076 |
if (arguments.length > 1) { |
|
1077 |
var force = !!arguments[1]; |
|
1078 |
return this[force ? 'add' : 'remove'](token), force; |
|
1079 |
} |
|
1080 |
return originalDOMTokenListToggle(token); |
|
1081 |
}; |
|
1082 |
})(); |
|
1083 |
(function checkStringIncludes() { |
|
1084 |
if (String.prototype.includes) { |
|
1085 |
return; |
|
1086 |
} |
|
1087 |
__w_pdfjs_require__(5); |
|
1088 |
})(); |
|
1089 |
(function checkArrayIncludes() { |
|
1090 |
if (Array.prototype.includes) { |
|
1091 |
return; |
|
1092 |
} |
|
1093 |
__w_pdfjs_require__(33); |
|
1094 |
})(); |
|
1095 |
(function checkObjectAssign() { |
|
1096 |
if (Object.assign) { |
|
1097 |
return; |
|
1098 |
} |
|
1099 |
__w_pdfjs_require__(42); |
|
1100 |
})(); |
|
1101 |
(function checkMathLog2() { |
|
1102 |
if (Math.log2) { |
|
1103 |
return; |
|
1104 |
} |
|
1105 |
Math.log2 = __w_pdfjs_require__(52); |
|
1106 |
})(); |
|
1107 |
(function checkNumberIsNaN() { |
|
1108 |
if (Number.isNaN) { |
|
1109 |
return; |
|
1110 |
} |
|
1111 |
Number.isNaN = __w_pdfjs_require__(54); |
|
1112 |
})(); |
|
1113 |
(function checkNumberIsInteger() { |
|
1114 |
if (Number.isInteger) { |
|
1115 |
return; |
|
1116 |
} |
|
1117 |
Number.isInteger = __w_pdfjs_require__(56); |
|
1118 |
})(); |
|
1119 |
(function checkPromise() { |
|
1120 |
if (globalScope.Promise) { |
|
1121 |
return; |
|
1122 |
} |
|
1123 |
globalScope.Promise = __w_pdfjs_require__(59); |
|
1124 |
})(); |
|
1125 |
(function checkWeakMap() { |
|
1126 |
if (globalScope.WeakMap) { |
|
1127 |
return; |
|
1128 |
} |
|
1129 |
globalScope.WeakMap = __w_pdfjs_require__(94); |
|
1130 |
})(); |
|
1131 |
(function checkStringCodePointAt() { |
|
1132 |
if (String.codePointAt) { |
|
1133 |
return; |
|
1134 |
} |
|
1135 |
String.codePointAt = __w_pdfjs_require__(111); |
|
1136 |
})(); |
|
1137 |
(function checkStringFromCodePoint() { |
|
1138 |
if (String.fromCodePoint) { |
|
1139 |
return; |
|
1140 |
} |
|
1141 |
String.fromCodePoint = __w_pdfjs_require__(113); |
|
1142 |
})(); |
|
1143 |
(function checkSymbol() { |
|
1144 |
if (globalScope.Symbol) { |
|
1145 |
return; |
|
1146 |
} |
|
1147 |
__w_pdfjs_require__(115); |
|
1148 |
})(); |
|
1149 |
(function checkObjectValues() { |
|
1150 |
if (Object.values) { |
|
1151 |
return; |
|
1152 |
} |
|
1153 |
Object.values = __w_pdfjs_require__(122); |
|
1154 |
})(); |
|
1155 |
} |
|
1156 |
|
|
1157 |
/***/ }), |
|
1158 |
/* 3 */ |
|
1159 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1160 |
|
|
1161 |
"use strict"; |
|
1162 |
|
|
1163 |
|
|
1164 |
module.exports = typeof window !== 'undefined' && window.Math === Math ? window : typeof global !== 'undefined' && global.Math === Math ? global : typeof self !== 'undefined' && self.Math === Math ? self : {}; |
|
1165 |
|
|
1166 |
/***/ }), |
|
1167 |
/* 4 */ |
|
1168 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1169 |
|
|
1170 |
"use strict"; |
|
1171 |
|
|
1172 |
|
|
1173 |
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; }; |
|
1174 |
|
|
1175 |
module.exports = function isNodeJS() { |
|
1176 |
return (typeof process === 'undefined' ? 'undefined' : _typeof(process)) === 'object' && process + '' === '[object process]'; |
|
1177 |
}; |
|
1178 |
|
|
1179 |
/***/ }), |
|
1180 |
/* 5 */ |
|
1181 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1182 |
|
|
1183 |
"use strict"; |
|
1184 |
|
|
1185 |
|
|
1186 |
__w_pdfjs_require__(6); |
|
1187 |
module.exports = __w_pdfjs_require__(9).String.includes; |
|
1188 |
|
|
1189 |
/***/ }), |
|
1190 |
/* 6 */ |
|
1191 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1192 |
|
|
1193 |
"use strict"; |
|
1194 |
|
|
1195 |
|
|
1196 |
var $export = __w_pdfjs_require__(7); |
|
1197 |
var context = __w_pdfjs_require__(25); |
|
1198 |
var INCLUDES = 'includes'; |
|
1199 |
$export($export.P + $export.F * __w_pdfjs_require__(32)(INCLUDES), 'String', { |
|
1200 |
includes: function includes(searchString) { |
|
1201 |
return !!~context(this, searchString, INCLUDES).indexOf(searchString, arguments.length > 1 ? arguments[1] : undefined); |
|
1202 |
} |
|
1203 |
}); |
|
1204 |
|
|
1205 |
/***/ }), |
|
1206 |
/* 7 */ |
|
1207 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1208 |
|
|
1209 |
"use strict"; |
|
1210 |
|
|
1211 |
|
|
1212 |
var global = __w_pdfjs_require__(8); |
|
1213 |
var core = __w_pdfjs_require__(9); |
|
1214 |
var hide = __w_pdfjs_require__(10); |
|
1215 |
var redefine = __w_pdfjs_require__(20); |
|
1216 |
var ctx = __w_pdfjs_require__(23); |
|
1217 |
var PROTOTYPE = 'prototype'; |
|
1218 |
var $export = function $export(type, name, source) { |
|
1219 |
var IS_FORCED = type & $export.F; |
|
1220 |
var IS_GLOBAL = type & $export.G; |
|
1221 |
var IS_STATIC = type & $export.S; |
|
1222 |
var IS_PROTO = type & $export.P; |
|
1223 |
var IS_BIND = type & $export.B; |
|
1224 |
var target = IS_GLOBAL ? global : IS_STATIC ? global[name] || (global[name] = {}) : (global[name] || {})[PROTOTYPE]; |
|
1225 |
var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); |
|
1226 |
var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {}); |
|
1227 |
var key, own, out, exp; |
|
1228 |
if (IS_GLOBAL) source = name; |
|
1229 |
for (key in source) { |
|
1230 |
own = !IS_FORCED && target && target[key] !== undefined; |
|
1231 |
out = (own ? target : source)[key]; |
|
1232 |
exp = IS_BIND && own ? ctx(out, global) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; |
|
1233 |
if (target) redefine(target, key, out, type & $export.U); |
|
1234 |
if (exports[key] != out) hide(exports, key, exp); |
|
1235 |
if (IS_PROTO && expProto[key] != out) expProto[key] = out; |
|
1236 |
} |
|
1237 |
}; |
|
1238 |
global.core = core; |
|
1239 |
$export.F = 1; |
|
1240 |
$export.G = 2; |
|
1241 |
$export.S = 4; |
|
1242 |
$export.P = 8; |
|
1243 |
$export.B = 16; |
|
1244 |
$export.W = 32; |
|
1245 |
$export.U = 64; |
|
1246 |
$export.R = 128; |
|
1247 |
module.exports = $export; |
|
1248 |
|
|
1249 |
/***/ }), |
|
1250 |
/* 8 */ |
|
1251 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1252 |
|
|
1253 |
"use strict"; |
|
1254 |
|
|
1255 |
|
|
1256 |
var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); |
|
1257 |
if (typeof __g == 'number') __g = global; |
|
1258 |
|
|
1259 |
/***/ }), |
|
1260 |
/* 9 */ |
|
1261 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1262 |
|
|
1263 |
"use strict"; |
|
1264 |
|
|
1265 |
|
|
1266 |
var core = module.exports = { version: '2.5.7' }; |
|
1267 |
if (typeof __e == 'number') __e = core; |
|
1268 |
|
|
1269 |
/***/ }), |
|
1270 |
/* 10 */ |
|
1271 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1272 |
|
|
1273 |
"use strict"; |
|
1274 |
|
|
1275 |
|
|
1276 |
var dP = __w_pdfjs_require__(11); |
|
1277 |
var createDesc = __w_pdfjs_require__(19); |
|
1278 |
module.exports = __w_pdfjs_require__(15) ? function (object, key, value) { |
|
1279 |
return dP.f(object, key, createDesc(1, value)); |
|
1280 |
} : function (object, key, value) { |
|
1281 |
object[key] = value; |
|
1282 |
return object; |
|
1283 |
}; |
|
1284 |
|
|
1285 |
/***/ }), |
|
1286 |
/* 11 */ |
|
1287 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1288 |
|
|
1289 |
"use strict"; |
|
1290 |
|
|
1291 |
|
|
1292 |
var anObject = __w_pdfjs_require__(12); |
|
1293 |
var IE8_DOM_DEFINE = __w_pdfjs_require__(14); |
|
1294 |
var toPrimitive = __w_pdfjs_require__(18); |
|
1295 |
var dP = Object.defineProperty; |
|
1296 |
exports.f = __w_pdfjs_require__(15) ? Object.defineProperty : function defineProperty(O, P, Attributes) { |
|
1297 |
anObject(O); |
|
1298 |
P = toPrimitive(P, true); |
|
1299 |
anObject(Attributes); |
|
1300 |
if (IE8_DOM_DEFINE) try { |
|
1301 |
return dP(O, P, Attributes); |
|
1302 |
} catch (e) {} |
|
1303 |
if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); |
|
1304 |
if ('value' in Attributes) O[P] = Attributes.value; |
|
1305 |
return O; |
|
1306 |
}; |
|
1307 |
|
|
1308 |
/***/ }), |
|
1309 |
/* 12 */ |
|
1310 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1311 |
|
|
1312 |
"use strict"; |
|
1313 |
|
|
1314 |
|
|
1315 |
var isObject = __w_pdfjs_require__(13); |
|
1316 |
module.exports = function (it) { |
|
1317 |
if (!isObject(it)) throw TypeError(it + ' is not an object!'); |
|
1318 |
return it; |
|
1319 |
}; |
|
1320 |
|
|
1321 |
/***/ }), |
|
1322 |
/* 13 */ |
|
1323 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1324 |
|
|
1325 |
"use strict"; |
|
1326 |
|
|
1327 |
|
|
1328 |
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; }; |
|
1329 |
|
|
1330 |
module.exports = function (it) { |
|
1331 |
return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) === 'object' ? it !== null : typeof it === 'function'; |
|
1332 |
}; |
|
1333 |
|
|
1334 |
/***/ }), |
|
1335 |
/* 14 */ |
|
1336 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1337 |
|
|
1338 |
"use strict"; |
|
1339 |
|
|
1340 |
|
|
1341 |
module.exports = !__w_pdfjs_require__(15) && !__w_pdfjs_require__(16)(function () { |
|
1342 |
return Object.defineProperty(__w_pdfjs_require__(17)('div'), 'a', { |
|
1343 |
get: function get() { |
|
1344 |
return 7; |
|
1345 |
} |
|
1346 |
}).a != 7; |
|
1347 |
}); |
|
1348 |
|
|
1349 |
/***/ }), |
|
1350 |
/* 15 */ |
|
1351 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1352 |
|
|
1353 |
"use strict"; |
|
1354 |
|
|
1355 |
|
|
1356 |
module.exports = !__w_pdfjs_require__(16)(function () { |
|
1357 |
return Object.defineProperty({}, 'a', { |
|
1358 |
get: function get() { |
|
1359 |
return 7; |
|
1360 |
} |
|
1361 |
}).a != 7; |
|
1362 |
}); |
|
1363 |
|
|
1364 |
/***/ }), |
|
1365 |
/* 16 */ |
|
1366 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1367 |
|
|
1368 |
"use strict"; |
|
1369 |
|
|
1370 |
|
|
1371 |
module.exports = function (exec) { |
|
1372 |
try { |
|
1373 |
return !!exec(); |
|
1374 |
} catch (e) { |
|
1375 |
return true; |
|
1376 |
} |
|
1377 |
}; |
|
1378 |
|
|
1379 |
/***/ }), |
|
1380 |
/* 17 */ |
|
1381 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1382 |
|
|
1383 |
"use strict"; |
|
1384 |
|
|
1385 |
|
|
1386 |
var isObject = __w_pdfjs_require__(13); |
|
1387 |
var document = __w_pdfjs_require__(8).document; |
|
1388 |
var is = isObject(document) && isObject(document.createElement); |
|
1389 |
module.exports = function (it) { |
|
1390 |
return is ? document.createElement(it) : {}; |
|
1391 |
}; |
|
1392 |
|
|
1393 |
/***/ }), |
|
1394 |
/* 18 */ |
|
1395 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1396 |
|
|
1397 |
"use strict"; |
|
1398 |
|
|
1399 |
|
|
1400 |
var isObject = __w_pdfjs_require__(13); |
|
1401 |
module.exports = function (it, S) { |
|
1402 |
if (!isObject(it)) return it; |
|
1403 |
var fn, val; |
|
1404 |
if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; |
|
1405 |
if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; |
|
1406 |
if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; |
|
1407 |
throw TypeError("Can't convert object to primitive value"); |
|
1408 |
}; |
|
1409 |
|
|
1410 |
/***/ }), |
|
1411 |
/* 19 */ |
|
1412 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1413 |
|
|
1414 |
"use strict"; |
|
1415 |
|
|
1416 |
|
|
1417 |
module.exports = function (bitmap, value) { |
|
1418 |
return { |
|
1419 |
enumerable: !(bitmap & 1), |
|
1420 |
configurable: !(bitmap & 2), |
|
1421 |
writable: !(bitmap & 4), |
|
1422 |
value: value |
|
1423 |
}; |
|
1424 |
}; |
|
1425 |
|
|
1426 |
/***/ }), |
|
1427 |
/* 20 */ |
|
1428 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1429 |
|
|
1430 |
"use strict"; |
|
1431 |
|
|
1432 |
|
|
1433 |
var global = __w_pdfjs_require__(8); |
|
1434 |
var hide = __w_pdfjs_require__(10); |
|
1435 |
var has = __w_pdfjs_require__(21); |
|
1436 |
var SRC = __w_pdfjs_require__(22)('src'); |
|
1437 |
var TO_STRING = 'toString'; |
|
1438 |
var $toString = Function[TO_STRING]; |
|
1439 |
var TPL = ('' + $toString).split(TO_STRING); |
|
1440 |
__w_pdfjs_require__(9).inspectSource = function (it) { |
|
1441 |
return $toString.call(it); |
|
1442 |
}; |
|
1443 |
(module.exports = function (O, key, val, safe) { |
|
1444 |
var isFunction = typeof val == 'function'; |
|
1445 |
if (isFunction) has(val, 'name') || hide(val, 'name', key); |
|
1446 |
if (O[key] === val) return; |
|
1447 |
if (isFunction) has(val, SRC) || hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); |
|
1448 |
if (O === global) { |
|
1449 |
O[key] = val; |
|
1450 |
} else if (!safe) { |
|
1451 |
delete O[key]; |
|
1452 |
hide(O, key, val); |
|
1453 |
} else if (O[key]) { |
|
1454 |
O[key] = val; |
|
1455 |
} else { |
|
1456 |
hide(O, key, val); |
|
1457 |
} |
|
1458 |
})(Function.prototype, TO_STRING, function toString() { |
|
1459 |
return typeof this == 'function' && this[SRC] || $toString.call(this); |
|
1460 |
}); |
|
1461 |
|
|
1462 |
/***/ }), |
|
1463 |
/* 21 */ |
|
1464 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1465 |
|
|
1466 |
"use strict"; |
|
1467 |
|
|
1468 |
|
|
1469 |
var hasOwnProperty = {}.hasOwnProperty; |
|
1470 |
module.exports = function (it, key) { |
|
1471 |
return hasOwnProperty.call(it, key); |
|
1472 |
}; |
|
1473 |
|
|
1474 |
/***/ }), |
|
1475 |
/* 22 */ |
|
1476 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1477 |
|
|
1478 |
"use strict"; |
|
1479 |
|
|
1480 |
|
|
1481 |
var id = 0; |
|
1482 |
var px = Math.random(); |
|
1483 |
module.exports = function (key) { |
|
1484 |
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); |
|
1485 |
}; |
|
1486 |
|
|
1487 |
/***/ }), |
|
1488 |
/* 23 */ |
|
1489 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1490 |
|
|
1491 |
"use strict"; |
|
1492 |
|
|
1493 |
|
|
1494 |
var aFunction = __w_pdfjs_require__(24); |
|
1495 |
module.exports = function (fn, that, length) { |
|
1496 |
aFunction(fn); |
|
1497 |
if (that === undefined) return fn; |
|
1498 |
switch (length) { |
|
1499 |
case 1: |
|
1500 |
return function (a) { |
|
1501 |
return fn.call(that, a); |
|
1502 |
}; |
|
1503 |
case 2: |
|
1504 |
return function (a, b) { |
|
1505 |
return fn.call(that, a, b); |
|
1506 |
}; |
|
1507 |
case 3: |
|
1508 |
return function (a, b, c) { |
|
1509 |
return fn.call(that, a, b, c); |
|
1510 |
}; |
|
1511 |
} |
|
1512 |
return function () { |
|
1513 |
return fn.apply(that, arguments); |
|
1514 |
}; |
|
1515 |
}; |
|
1516 |
|
|
1517 |
/***/ }), |
|
1518 |
/* 24 */ |
|
1519 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1520 |
|
|
1521 |
"use strict"; |
|
1522 |
|
|
1523 |
|
|
1524 |
module.exports = function (it) { |
|
1525 |
if (typeof it != 'function') throw TypeError(it + ' is not a function!'); |
|
1526 |
return it; |
|
1527 |
}; |
|
1528 |
|
|
1529 |
/***/ }), |
|
1530 |
/* 25 */ |
|
1531 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1532 |
|
|
1533 |
"use strict"; |
|
1534 |
|
|
1535 |
|
|
1536 |
var isRegExp = __w_pdfjs_require__(26); |
|
1537 |
var defined = __w_pdfjs_require__(31); |
|
1538 |
module.exports = function (that, searchString, NAME) { |
|
1539 |
if (isRegExp(searchString)) throw TypeError('String#' + NAME + " doesn't accept regex!"); |
|
1540 |
return String(defined(that)); |
|
1541 |
}; |
|
1542 |
|
|
1543 |
/***/ }), |
|
1544 |
/* 26 */ |
|
1545 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1546 |
|
|
1547 |
"use strict"; |
|
1548 |
|
|
1549 |
|
|
1550 |
var isObject = __w_pdfjs_require__(13); |
|
1551 |
var cof = __w_pdfjs_require__(27); |
|
1552 |
var MATCH = __w_pdfjs_require__(28)('match'); |
|
1553 |
module.exports = function (it) { |
|
1554 |
var isRegExp; |
|
1555 |
return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : cof(it) == 'RegExp'); |
|
1556 |
}; |
|
1557 |
|
|
1558 |
/***/ }), |
|
1559 |
/* 27 */ |
|
1560 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1561 |
|
|
1562 |
"use strict"; |
|
1563 |
|
|
1564 |
|
|
1565 |
var toString = {}.toString; |
|
1566 |
module.exports = function (it) { |
|
1567 |
return toString.call(it).slice(8, -1); |
|
1568 |
}; |
|
1569 |
|
|
1570 |
/***/ }), |
|
1571 |
/* 28 */ |
|
1572 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1573 |
|
|
1574 |
"use strict"; |
|
1575 |
|
|
1576 |
|
|
1577 |
var store = __w_pdfjs_require__(29)('wks'); |
|
1578 |
var uid = __w_pdfjs_require__(22); |
|
1579 |
var _Symbol = __w_pdfjs_require__(8).Symbol; |
|
1580 |
var USE_SYMBOL = typeof _Symbol == 'function'; |
|
1581 |
var $exports = module.exports = function (name) { |
|
1582 |
return store[name] || (store[name] = USE_SYMBOL && _Symbol[name] || (USE_SYMBOL ? _Symbol : uid)('Symbol.' + name)); |
|
1583 |
}; |
|
1584 |
$exports.store = store; |
|
1585 |
|
|
1586 |
/***/ }), |
|
1587 |
/* 29 */ |
|
1588 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1589 |
|
|
1590 |
"use strict"; |
|
1591 |
|
|
1592 |
|
|
1593 |
var core = __w_pdfjs_require__(9); |
|
1594 |
var global = __w_pdfjs_require__(8); |
|
1595 |
var SHARED = '__core-js_shared__'; |
|
1596 |
var store = global[SHARED] || (global[SHARED] = {}); |
|
1597 |
(module.exports = function (key, value) { |
|
1598 |
return store[key] || (store[key] = value !== undefined ? value : {}); |
|
1599 |
})('versions', []).push({ |
|
1600 |
version: core.version, |
|
1601 |
mode: __w_pdfjs_require__(30) ? 'pure' : 'global', |
|
1602 |
copyright: '© 2018 Denis Pushkarev (zloirock.ru)' |
|
1603 |
}); |
|
1604 |
|
|
1605 |
/***/ }), |
|
1606 |
/* 30 */ |
|
1607 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1608 |
|
|
1609 |
"use strict"; |
|
1610 |
|
|
1611 |
|
|
1612 |
module.exports = false; |
|
1613 |
|
|
1614 |
/***/ }), |
|
1615 |
/* 31 */ |
|
1616 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1617 |
|
|
1618 |
"use strict"; |
|
1619 |
|
|
1620 |
|
|
1621 |
module.exports = function (it) { |
|
1622 |
if (it == undefined) throw TypeError("Can't call method on " + it); |
|
1623 |
return it; |
|
1624 |
}; |
|
1625 |
|
|
1626 |
/***/ }), |
|
1627 |
/* 32 */ |
|
1628 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1629 |
|
|
1630 |
"use strict"; |
|
1631 |
|
|
1632 |
|
|
1633 |
var MATCH = __w_pdfjs_require__(28)('match'); |
|
1634 |
module.exports = function (KEY) { |
|
1635 |
var re = /./; |
|
1636 |
try { |
|
1637 |
'/./'[KEY](re); |
|
1638 |
} catch (e) { |
|
1639 |
try { |
|
1640 |
re[MATCH] = false; |
|
1641 |
return !'/./'[KEY](re); |
|
1642 |
} catch (f) {} |
|
1643 |
} |
|
1644 |
return true; |
|
1645 |
}; |
|
1646 |
|
|
1647 |
/***/ }), |
|
1648 |
/* 33 */ |
|
1649 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1650 |
|
|
1651 |
"use strict"; |
|
1652 |
|
|
1653 |
|
|
1654 |
__w_pdfjs_require__(34); |
|
1655 |
module.exports = __w_pdfjs_require__(9).Array.includes; |
|
1656 |
|
|
1657 |
/***/ }), |
|
1658 |
/* 34 */ |
|
1659 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1660 |
|
|
1661 |
"use strict"; |
|
1662 |
|
|
1663 |
|
|
1664 |
var $export = __w_pdfjs_require__(7); |
|
1665 |
var $includes = __w_pdfjs_require__(35)(true); |
|
1666 |
$export($export.P, 'Array', { |
|
1667 |
includes: function includes(el) { |
|
1668 |
return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined); |
|
1669 |
} |
|
1670 |
}); |
|
1671 |
__w_pdfjs_require__(41)('includes'); |
|
1672 |
|
|
1673 |
/***/ }), |
|
1674 |
/* 35 */ |
|
1675 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1676 |
|
|
1677 |
"use strict"; |
|
1678 |
|
|
1679 |
|
|
1680 |
var toIObject = __w_pdfjs_require__(36); |
|
1681 |
var toLength = __w_pdfjs_require__(38); |
|
1682 |
var toAbsoluteIndex = __w_pdfjs_require__(40); |
|
1683 |
module.exports = function (IS_INCLUDES) { |
|
1684 |
return function ($this, el, fromIndex) { |
|
1685 |
var O = toIObject($this); |
|
1686 |
var length = toLength(O.length); |
|
1687 |
var index = toAbsoluteIndex(fromIndex, length); |
|
1688 |
var value; |
|
1689 |
if (IS_INCLUDES && el != el) while (length > index) { |
|
1690 |
value = O[index++]; |
|
1691 |
if (value != value) return true; |
|
1692 |
} else for (; length > index; index++) { |
|
1693 |
if (IS_INCLUDES || index in O) { |
|
1694 |
if (O[index] === el) return IS_INCLUDES || index || 0; |
|
1695 |
} |
|
1696 |
}return !IS_INCLUDES && -1; |
|
1697 |
}; |
|
1698 |
}; |
|
1699 |
|
|
1700 |
/***/ }), |
|
1701 |
/* 36 */ |
|
1702 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1703 |
|
|
1704 |
"use strict"; |
|
1705 |
|
|
1706 |
|
|
1707 |
var IObject = __w_pdfjs_require__(37); |
|
1708 |
var defined = __w_pdfjs_require__(31); |
|
1709 |
module.exports = function (it) { |
|
1710 |
return IObject(defined(it)); |
|
1711 |
}; |
|
1712 |
|
|
1713 |
/***/ }), |
|
1714 |
/* 37 */ |
|
1715 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1716 |
|
|
1717 |
"use strict"; |
|
1718 |
|
|
1719 |
|
|
1720 |
var cof = __w_pdfjs_require__(27); |
|
1721 |
module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { |
|
1722 |
return cof(it) == 'String' ? it.split('') : Object(it); |
|
1723 |
}; |
|
1724 |
|
|
1725 |
/***/ }), |
|
1726 |
/* 38 */ |
|
1727 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1728 |
|
|
1729 |
"use strict"; |
|
1730 |
|
|
1731 |
|
|
1732 |
var toInteger = __w_pdfjs_require__(39); |
|
1733 |
var min = Math.min; |
|
1734 |
module.exports = function (it) { |
|
1735 |
return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; |
|
1736 |
}; |
|
1737 |
|
|
1738 |
/***/ }), |
|
1739 |
/* 39 */ |
|
1740 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1741 |
|
|
1742 |
"use strict"; |
|
1743 |
|
|
1744 |
|
|
1745 |
var ceil = Math.ceil; |
|
1746 |
var floor = Math.floor; |
|
1747 |
module.exports = function (it) { |
|
1748 |
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); |
|
1749 |
}; |
|
1750 |
|
|
1751 |
/***/ }), |
|
1752 |
/* 40 */ |
|
1753 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1754 |
|
|
1755 |
"use strict"; |
|
1756 |
|
|
1757 |
|
|
1758 |
var toInteger = __w_pdfjs_require__(39); |
|
1759 |
var max = Math.max; |
|
1760 |
var min = Math.min; |
|
1761 |
module.exports = function (index, length) { |
|
1762 |
index = toInteger(index); |
|
1763 |
return index < 0 ? max(index + length, 0) : min(index, length); |
|
1764 |
}; |
|
1765 |
|
|
1766 |
/***/ }), |
|
1767 |
/* 41 */ |
|
1768 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1769 |
|
|
1770 |
"use strict"; |
|
1771 |
|
|
1772 |
|
|
1773 |
var UNSCOPABLES = __w_pdfjs_require__(28)('unscopables'); |
|
1774 |
var ArrayProto = Array.prototype; |
|
1775 |
if (ArrayProto[UNSCOPABLES] == undefined) __w_pdfjs_require__(10)(ArrayProto, UNSCOPABLES, {}); |
|
1776 |
module.exports = function (key) { |
|
1777 |
ArrayProto[UNSCOPABLES][key] = true; |
|
1778 |
}; |
|
1779 |
|
|
1780 |
/***/ }), |
|
1781 |
/* 42 */ |
|
1782 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1783 |
|
|
1784 |
"use strict"; |
|
1785 |
|
|
1786 |
|
|
1787 |
__w_pdfjs_require__(43); |
|
1788 |
module.exports = __w_pdfjs_require__(9).Object.assign; |
|
1789 |
|
|
1790 |
/***/ }), |
|
1791 |
/* 43 */ |
|
1792 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1793 |
|
|
1794 |
"use strict"; |
|
1795 |
|
|
1796 |
|
|
1797 |
var $export = __w_pdfjs_require__(7); |
|
1798 |
$export($export.S + $export.F, 'Object', { assign: __w_pdfjs_require__(44) }); |
|
1799 |
|
|
1800 |
/***/ }), |
|
1801 |
/* 44 */ |
|
1802 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1803 |
|
|
1804 |
"use strict"; |
|
1805 |
|
|
1806 |
|
|
1807 |
var getKeys = __w_pdfjs_require__(45); |
|
1808 |
var gOPS = __w_pdfjs_require__(49); |
|
1809 |
var pIE = __w_pdfjs_require__(50); |
|
1810 |
var toObject = __w_pdfjs_require__(51); |
|
1811 |
var IObject = __w_pdfjs_require__(37); |
|
1812 |
var $assign = Object.assign; |
|
1813 |
module.exports = !$assign || __w_pdfjs_require__(16)(function () { |
|
1814 |
var A = {}; |
|
1815 |
var B = {}; |
|
1816 |
var S = Symbol(); |
|
1817 |
var K = 'abcdefghijklmnopqrst'; |
|
1818 |
A[S] = 7; |
|
1819 |
K.split('').forEach(function (k) { |
|
1820 |
B[k] = k; |
|
1821 |
}); |
|
1822 |
return $assign({}, A)[S] != 7 || Object.keys($assign({}, B)).join('') != K; |
|
1823 |
}) ? function assign(target, source) { |
|
1824 |
var T = toObject(target); |
|
1825 |
var aLen = arguments.length; |
|
1826 |
var index = 1; |
|
1827 |
var getSymbols = gOPS.f; |
|
1828 |
var isEnum = pIE.f; |
|
1829 |
while (aLen > index) { |
|
1830 |
var S = IObject(arguments[index++]); |
|
1831 |
var keys = getSymbols ? getKeys(S).concat(getSymbols(S)) : getKeys(S); |
|
1832 |
var length = keys.length; |
|
1833 |
var j = 0; |
|
1834 |
var key; |
|
1835 |
while (length > j) { |
|
1836 |
if (isEnum.call(S, key = keys[j++])) T[key] = S[key]; |
|
1837 |
} |
|
1838 |
} |
|
1839 |
return T; |
|
1840 |
} : $assign; |
|
1841 |
|
|
1842 |
/***/ }), |
|
1843 |
/* 45 */ |
|
1844 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1845 |
|
|
1846 |
"use strict"; |
|
1847 |
|
|
1848 |
|
|
1849 |
var $keys = __w_pdfjs_require__(46); |
|
1850 |
var enumBugKeys = __w_pdfjs_require__(48); |
|
1851 |
module.exports = Object.keys || function keys(O) { |
|
1852 |
return $keys(O, enumBugKeys); |
|
1853 |
}; |
|
1854 |
|
|
1855 |
/***/ }), |
|
1856 |
/* 46 */ |
|
1857 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1858 |
|
|
1859 |
"use strict"; |
|
1860 |
|
|
1861 |
|
|
1862 |
var has = __w_pdfjs_require__(21); |
|
1863 |
var toIObject = __w_pdfjs_require__(36); |
|
1864 |
var arrayIndexOf = __w_pdfjs_require__(35)(false); |
|
1865 |
var IE_PROTO = __w_pdfjs_require__(47)('IE_PROTO'); |
|
1866 |
module.exports = function (object, names) { |
|
1867 |
var O = toIObject(object); |
|
1868 |
var i = 0; |
|
1869 |
var result = []; |
|
1870 |
var key; |
|
1871 |
for (key in O) { |
|
1872 |
if (key != IE_PROTO) has(O, key) && result.push(key); |
|
1873 |
}while (names.length > i) { |
|
1874 |
if (has(O, key = names[i++])) { |
|
1875 |
~arrayIndexOf(result, key) || result.push(key); |
|
1876 |
} |
|
1877 |
}return result; |
|
1878 |
}; |
|
1879 |
|
|
1880 |
/***/ }), |
|
1881 |
/* 47 */ |
|
1882 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1883 |
|
|
1884 |
"use strict"; |
|
1885 |
|
|
1886 |
|
|
1887 |
var shared = __w_pdfjs_require__(29)('keys'); |
|
1888 |
var uid = __w_pdfjs_require__(22); |
|
1889 |
module.exports = function (key) { |
|
1890 |
return shared[key] || (shared[key] = uid(key)); |
|
1891 |
}; |
|
1892 |
|
|
1893 |
/***/ }), |
|
1894 |
/* 48 */ |
|
1895 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1896 |
|
|
1897 |
"use strict"; |
|
1898 |
|
|
1899 |
|
|
1900 |
module.exports = 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf'.split(','); |
|
1901 |
|
|
1902 |
/***/ }), |
|
1903 |
/* 49 */ |
|
1904 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1905 |
|
|
1906 |
"use strict"; |
|
1907 |
|
|
1908 |
|
|
1909 |
exports.f = Object.getOwnPropertySymbols; |
|
1910 |
|
|
1911 |
/***/ }), |
|
1912 |
/* 50 */ |
|
1913 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1914 |
|
|
1915 |
"use strict"; |
|
1916 |
|
|
1917 |
|
|
1918 |
exports.f = {}.propertyIsEnumerable; |
|
1919 |
|
|
1920 |
/***/ }), |
|
1921 |
/* 51 */ |
|
1922 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1923 |
|
|
1924 |
"use strict"; |
|
1925 |
|
|
1926 |
|
|
1927 |
var defined = __w_pdfjs_require__(31); |
|
1928 |
module.exports = function (it) { |
|
1929 |
return Object(defined(it)); |
|
1930 |
}; |
|
1931 |
|
|
1932 |
/***/ }), |
|
1933 |
/* 52 */ |
|
1934 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1935 |
|
|
1936 |
"use strict"; |
|
1937 |
|
|
1938 |
|
|
1939 |
__w_pdfjs_require__(53); |
|
1940 |
module.exports = __w_pdfjs_require__(9).Math.log2; |
|
1941 |
|
|
1942 |
/***/ }), |
|
1943 |
/* 53 */ |
|
1944 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1945 |
|
|
1946 |
"use strict"; |
|
1947 |
|
|
1948 |
|
|
1949 |
var $export = __w_pdfjs_require__(7); |
|
1950 |
$export($export.S, 'Math', { |
|
1951 |
log2: function log2(x) { |
|
1952 |
return Math.log(x) / Math.LN2; |
|
1953 |
} |
|
1954 |
}); |
|
1955 |
|
|
1956 |
/***/ }), |
|
1957 |
/* 54 */ |
|
1958 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1959 |
|
|
1960 |
"use strict"; |
|
1961 |
|
|
1962 |
|
|
1963 |
__w_pdfjs_require__(55); |
|
1964 |
module.exports = __w_pdfjs_require__(9).Number.isNaN; |
|
1965 |
|
|
1966 |
/***/ }), |
|
1967 |
/* 55 */ |
|
1968 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1969 |
|
|
1970 |
"use strict"; |
|
1971 |
|
|
1972 |
|
|
1973 |
var $export = __w_pdfjs_require__(7); |
|
1974 |
$export($export.S, 'Number', { |
|
1975 |
isNaN: function isNaN(number) { |
|
1976 |
return number != number; |
|
1977 |
} |
|
1978 |
}); |
|
1979 |
|
|
1980 |
/***/ }), |
|
1981 |
/* 56 */ |
|
1982 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1983 |
|
|
1984 |
"use strict"; |
|
1985 |
|
|
1986 |
|
|
1987 |
__w_pdfjs_require__(57); |
|
1988 |
module.exports = __w_pdfjs_require__(9).Number.isInteger; |
|
1989 |
|
|
1990 |
/***/ }), |
|
1991 |
/* 57 */ |
|
1992 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
1993 |
|
|
1994 |
"use strict"; |
|
1995 |
|
|
1996 |
|
|
1997 |
var $export = __w_pdfjs_require__(7); |
|
1998 |
$export($export.S, 'Number', { isInteger: __w_pdfjs_require__(58) }); |
|
1999 |
|
|
2000 |
/***/ }), |
|
2001 |
/* 58 */ |
|
2002 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2003 |
|
|
2004 |
"use strict"; |
|
2005 |
|
|
2006 |
|
|
2007 |
var isObject = __w_pdfjs_require__(13); |
|
2008 |
var floor = Math.floor; |
|
2009 |
module.exports = function isInteger(it) { |
|
2010 |
return !isObject(it) && isFinite(it) && floor(it) === it; |
|
2011 |
}; |
|
2012 |
|
|
2013 |
/***/ }), |
|
2014 |
/* 59 */ |
|
2015 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2016 |
|
|
2017 |
"use strict"; |
|
2018 |
|
|
2019 |
|
|
2020 |
__w_pdfjs_require__(60); |
|
2021 |
__w_pdfjs_require__(62); |
|
2022 |
__w_pdfjs_require__(72); |
|
2023 |
__w_pdfjs_require__(75); |
|
2024 |
__w_pdfjs_require__(92); |
|
2025 |
__w_pdfjs_require__(93); |
|
2026 |
module.exports = __w_pdfjs_require__(9).Promise; |
|
2027 |
|
|
2028 |
/***/ }), |
|
2029 |
/* 60 */ |
|
2030 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2031 |
|
|
2032 |
"use strict"; |
|
2033 |
|
|
2034 |
|
|
2035 |
var classof = __w_pdfjs_require__(61); |
|
2036 |
var test = {}; |
|
2037 |
test[__w_pdfjs_require__(28)('toStringTag')] = 'z'; |
|
2038 |
if (test + '' != '[object z]') { |
|
2039 |
__w_pdfjs_require__(20)(Object.prototype, 'toString', function toString() { |
|
2040 |
return '[object ' + classof(this) + ']'; |
|
2041 |
}, true); |
|
2042 |
} |
|
2043 |
|
|
2044 |
/***/ }), |
|
2045 |
/* 61 */ |
|
2046 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2047 |
|
|
2048 |
"use strict"; |
|
2049 |
|
|
2050 |
|
|
2051 |
var cof = __w_pdfjs_require__(27); |
|
2052 |
var TAG = __w_pdfjs_require__(28)('toStringTag'); |
|
2053 |
var ARG = cof(function () { |
|
2054 |
return arguments; |
|
2055 |
}()) == 'Arguments'; |
|
2056 |
var tryGet = function tryGet(it, key) { |
|
2057 |
try { |
|
2058 |
return it[key]; |
|
2059 |
} catch (e) {} |
|
2060 |
}; |
|
2061 |
module.exports = function (it) { |
|
2062 |
var O, T, B; |
|
2063 |
return it === undefined ? 'Undefined' : it === null ? 'Null' : typeof (T = tryGet(O = Object(it), TAG)) == 'string' ? T : ARG ? cof(O) : (B = cof(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : B; |
|
2064 |
}; |
|
2065 |
|
|
2066 |
/***/ }), |
|
2067 |
/* 62 */ |
|
2068 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2069 |
|
|
2070 |
"use strict"; |
|
2071 |
|
|
2072 |
|
|
2073 |
var $at = __w_pdfjs_require__(63)(true); |
|
2074 |
__w_pdfjs_require__(64)(String, 'String', function (iterated) { |
|
2075 |
this._t = String(iterated); |
|
2076 |
this._i = 0; |
|
2077 |
}, function () { |
|
2078 |
var O = this._t; |
|
2079 |
var index = this._i; |
|
2080 |
var point; |
|
2081 |
if (index >= O.length) return { |
|
2082 |
value: undefined, |
|
2083 |
done: true |
|
2084 |
}; |
|
2085 |
point = $at(O, index); |
|
2086 |
this._i += point.length; |
|
2087 |
return { |
|
2088 |
value: point, |
|
2089 |
done: false |
|
2090 |
}; |
|
2091 |
}); |
|
2092 |
|
|
2093 |
/***/ }), |
|
2094 |
/* 63 */ |
|
2095 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2096 |
|
|
2097 |
"use strict"; |
|
2098 |
|
|
2099 |
|
|
2100 |
var toInteger = __w_pdfjs_require__(39); |
|
2101 |
var defined = __w_pdfjs_require__(31); |
|
2102 |
module.exports = function (TO_STRING) { |
|
2103 |
return function (that, pos) { |
|
2104 |
var s = String(defined(that)); |
|
2105 |
var i = toInteger(pos); |
|
2106 |
var l = s.length; |
|
2107 |
var a, b; |
|
2108 |
if (i < 0 || i >= l) return TO_STRING ? '' : undefined; |
|
2109 |
a = s.charCodeAt(i); |
|
2110 |
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff ? TO_STRING ? s.charAt(i) : a : TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000; |
|
2111 |
}; |
|
2112 |
}; |
|
2113 |
|
|
2114 |
/***/ }), |
|
2115 |
/* 64 */ |
|
2116 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2117 |
|
|
2118 |
"use strict"; |
|
2119 |
|
|
2120 |
|
|
2121 |
var LIBRARY = __w_pdfjs_require__(30); |
|
2122 |
var $export = __w_pdfjs_require__(7); |
|
2123 |
var redefine = __w_pdfjs_require__(20); |
|
2124 |
var hide = __w_pdfjs_require__(10); |
|
2125 |
var Iterators = __w_pdfjs_require__(65); |
|
2126 |
var $iterCreate = __w_pdfjs_require__(66); |
|
2127 |
var setToStringTag = __w_pdfjs_require__(70); |
|
2128 |
var getPrototypeOf = __w_pdfjs_require__(71); |
|
2129 |
var ITERATOR = __w_pdfjs_require__(28)('iterator'); |
|
2130 |
var BUGGY = !([].keys && 'next' in [].keys()); |
|
2131 |
var FF_ITERATOR = '@@iterator'; |
|
2132 |
var KEYS = 'keys'; |
|
2133 |
var VALUES = 'values'; |
|
2134 |
var returnThis = function returnThis() { |
|
2135 |
return this; |
|
2136 |
}; |
|
2137 |
module.exports = function (Base, NAME, Constructor, next, DEFAULT, IS_SET, FORCED) { |
|
2138 |
$iterCreate(Constructor, NAME, next); |
|
2139 |
var getMethod = function getMethod(kind) { |
|
2140 |
if (!BUGGY && kind in proto) return proto[kind]; |
|
2141 |
switch (kind) { |
|
2142 |
case KEYS: |
|
2143 |
return function keys() { |
|
2144 |
return new Constructor(this, kind); |
|
2145 |
}; |
|
2146 |
case VALUES: |
|
2147 |
return function values() { |
|
2148 |
return new Constructor(this, kind); |
|
2149 |
}; |
|
2150 |
} |
|
2151 |
return function entries() { |
|
2152 |
return new Constructor(this, kind); |
|
2153 |
}; |
|
2154 |
}; |
|
2155 |
var TAG = NAME + ' Iterator'; |
|
2156 |
var DEF_VALUES = DEFAULT == VALUES; |
|
2157 |
var VALUES_BUG = false; |
|
2158 |
var proto = Base.prototype; |
|
2159 |
var $native = proto[ITERATOR] || proto[FF_ITERATOR] || DEFAULT && proto[DEFAULT]; |
|
2160 |
var $default = $native || getMethod(DEFAULT); |
|
2161 |
var $entries = DEFAULT ? !DEF_VALUES ? $default : getMethod('entries') : undefined; |
|
2162 |
var $anyNative = NAME == 'Array' ? proto.entries || $native : $native; |
|
2163 |
var methods, key, IteratorPrototype; |
|
2164 |
if ($anyNative) { |
|
2165 |
IteratorPrototype = getPrototypeOf($anyNative.call(new Base())); |
|
2166 |
if (IteratorPrototype !== Object.prototype && IteratorPrototype.next) { |
|
2167 |
setToStringTag(IteratorPrototype, TAG, true); |
|
2168 |
if (!LIBRARY && typeof IteratorPrototype[ITERATOR] != 'function') hide(IteratorPrototype, ITERATOR, returnThis); |
|
2169 |
} |
|
2170 |
} |
|
2171 |
if (DEF_VALUES && $native && $native.name !== VALUES) { |
|
2172 |
VALUES_BUG = true; |
|
2173 |
$default = function values() { |
|
2174 |
return $native.call(this); |
|
2175 |
}; |
|
2176 |
} |
|
2177 |
if ((!LIBRARY || FORCED) && (BUGGY || VALUES_BUG || !proto[ITERATOR])) { |
|
2178 |
hide(proto, ITERATOR, $default); |
|
2179 |
} |
|
2180 |
Iterators[NAME] = $default; |
|
2181 |
Iterators[TAG] = returnThis; |
|
2182 |
if (DEFAULT) { |
|
2183 |
methods = { |
|
2184 |
values: DEF_VALUES ? $default : getMethod(VALUES), |
|
2185 |
keys: IS_SET ? $default : getMethod(KEYS), |
|
2186 |
entries: $entries |
|
2187 |
}; |
|
2188 |
if (FORCED) for (key in methods) { |
|
2189 |
if (!(key in proto)) redefine(proto, key, methods[key]); |
|
2190 |
} else $export($export.P + $export.F * (BUGGY || VALUES_BUG), NAME, methods); |
|
2191 |
} |
|
2192 |
return methods; |
|
2193 |
}; |
|
2194 |
|
|
2195 |
/***/ }), |
|
2196 |
/* 65 */ |
|
2197 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2198 |
|
|
2199 |
"use strict"; |
|
2200 |
|
|
2201 |
|
|
2202 |
module.exports = {}; |
|
2203 |
|
|
2204 |
/***/ }), |
|
2205 |
/* 66 */ |
|
2206 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2207 |
|
|
2208 |
"use strict"; |
|
2209 |
|
|
2210 |
|
|
2211 |
var create = __w_pdfjs_require__(67); |
|
2212 |
var descriptor = __w_pdfjs_require__(19); |
|
2213 |
var setToStringTag = __w_pdfjs_require__(70); |
|
2214 |
var IteratorPrototype = {}; |
|
2215 |
__w_pdfjs_require__(10)(IteratorPrototype, __w_pdfjs_require__(28)('iterator'), function () { |
|
2216 |
return this; |
|
2217 |
}); |
|
2218 |
module.exports = function (Constructor, NAME, next) { |
|
2219 |
Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) }); |
|
2220 |
setToStringTag(Constructor, NAME + ' Iterator'); |
|
2221 |
}; |
|
2222 |
|
|
2223 |
/***/ }), |
|
2224 |
/* 67 */ |
|
2225 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2226 |
|
|
2227 |
"use strict"; |
|
2228 |
|
|
2229 |
|
|
2230 |
var anObject = __w_pdfjs_require__(12); |
|
2231 |
var dPs = __w_pdfjs_require__(68); |
|
2232 |
var enumBugKeys = __w_pdfjs_require__(48); |
|
2233 |
var IE_PROTO = __w_pdfjs_require__(47)('IE_PROTO'); |
|
2234 |
var Empty = function Empty() {}; |
|
2235 |
var PROTOTYPE = 'prototype'; |
|
2236 |
var _createDict = function createDict() { |
|
2237 |
var iframe = __w_pdfjs_require__(17)('iframe'); |
|
2238 |
var i = enumBugKeys.length; |
|
2239 |
var lt = '<'; |
|
2240 |
var gt = '>'; |
|
2241 |
var iframeDocument; |
|
2242 |
iframe.style.display = 'none'; |
|
2243 |
__w_pdfjs_require__(69).appendChild(iframe); |
|
2244 |
iframe.src = 'javascript:'; |
|
2245 |
iframeDocument = iframe.contentWindow.document; |
|
2246 |
iframeDocument.open(); |
|
2247 |
iframeDocument.write(lt + 'script' + gt + 'document.F=Object' + lt + '/script' + gt); |
|
2248 |
iframeDocument.close(); |
|
2249 |
_createDict = iframeDocument.F; |
|
2250 |
while (i--) { |
|
2251 |
delete _createDict[PROTOTYPE][enumBugKeys[i]]; |
|
2252 |
}return _createDict(); |
|
2253 |
}; |
|
2254 |
module.exports = Object.create || function create(O, Properties) { |
|
2255 |
var result; |
|
2256 |
if (O !== null) { |
|
2257 |
Empty[PROTOTYPE] = anObject(O); |
|
2258 |
result = new Empty(); |
|
2259 |
Empty[PROTOTYPE] = null; |
|
2260 |
result[IE_PROTO] = O; |
|
2261 |
} else result = _createDict(); |
|
2262 |
return Properties === undefined ? result : dPs(result, Properties); |
|
2263 |
}; |
|
2264 |
|
|
2265 |
/***/ }), |
|
2266 |
/* 68 */ |
|
2267 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2268 |
|
|
2269 |
"use strict"; |
|
2270 |
|
|
2271 |
|
|
2272 |
var dP = __w_pdfjs_require__(11); |
|
2273 |
var anObject = __w_pdfjs_require__(12); |
|
2274 |
var getKeys = __w_pdfjs_require__(45); |
|
2275 |
module.exports = __w_pdfjs_require__(15) ? Object.defineProperties : function defineProperties(O, Properties) { |
|
2276 |
anObject(O); |
|
2277 |
var keys = getKeys(Properties); |
|
2278 |
var length = keys.length; |
|
2279 |
var i = 0; |
|
2280 |
var P; |
|
2281 |
while (length > i) { |
|
2282 |
dP.f(O, P = keys[i++], Properties[P]); |
|
2283 |
}return O; |
|
2284 |
}; |
|
2285 |
|
|
2286 |
/***/ }), |
|
2287 |
/* 69 */ |
|
2288 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2289 |
|
|
2290 |
"use strict"; |
|
2291 |
|
|
2292 |
|
|
2293 |
var document = __w_pdfjs_require__(8).document; |
|
2294 |
module.exports = document && document.documentElement; |
|
2295 |
|
|
2296 |
/***/ }), |
|
2297 |
/* 70 */ |
|
2298 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2299 |
|
|
2300 |
"use strict"; |
|
2301 |
|
|
2302 |
|
|
2303 |
var def = __w_pdfjs_require__(11).f; |
|
2304 |
var has = __w_pdfjs_require__(21); |
|
2305 |
var TAG = __w_pdfjs_require__(28)('toStringTag'); |
|
2306 |
module.exports = function (it, tag, stat) { |
|
2307 |
if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { |
|
2308 |
configurable: true, |
|
2309 |
value: tag |
|
2310 |
}); |
|
2311 |
}; |
|
2312 |
|
|
2313 |
/***/ }), |
|
2314 |
/* 71 */ |
|
2315 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2316 |
|
|
2317 |
"use strict"; |
|
2318 |
|
|
2319 |
|
|
2320 |
var has = __w_pdfjs_require__(21); |
|
2321 |
var toObject = __w_pdfjs_require__(51); |
|
2322 |
var IE_PROTO = __w_pdfjs_require__(47)('IE_PROTO'); |
|
2323 |
var ObjectProto = Object.prototype; |
|
2324 |
module.exports = Object.getPrototypeOf || function (O) { |
|
2325 |
O = toObject(O); |
|
2326 |
if (has(O, IE_PROTO)) return O[IE_PROTO]; |
|
2327 |
if (typeof O.constructor == 'function' && O instanceof O.constructor) { |
|
2328 |
return O.constructor.prototype; |
|
2329 |
} |
|
2330 |
return O instanceof Object ? ObjectProto : null; |
|
2331 |
}; |
|
2332 |
|
|
2333 |
/***/ }), |
|
2334 |
/* 72 */ |
|
2335 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2336 |
|
|
2337 |
"use strict"; |
|
2338 |
|
|
2339 |
|
|
2340 |
var $iterators = __w_pdfjs_require__(73); |
|
2341 |
var getKeys = __w_pdfjs_require__(45); |
|
2342 |
var redefine = __w_pdfjs_require__(20); |
|
2343 |
var global = __w_pdfjs_require__(8); |
|
2344 |
var hide = __w_pdfjs_require__(10); |
|
2345 |
var Iterators = __w_pdfjs_require__(65); |
|
2346 |
var wks = __w_pdfjs_require__(28); |
|
2347 |
var ITERATOR = wks('iterator'); |
|
2348 |
var TO_STRING_TAG = wks('toStringTag'); |
|
2349 |
var ArrayValues = Iterators.Array; |
|
2350 |
var DOMIterables = { |
|
2351 |
CSSRuleList: true, |
|
2352 |
CSSStyleDeclaration: false, |
|
2353 |
CSSValueList: false, |
|
2354 |
ClientRectList: false, |
|
2355 |
DOMRectList: false, |
|
2356 |
DOMStringList: false, |
|
2357 |
DOMTokenList: true, |
|
2358 |
DataTransferItemList: false, |
|
2359 |
FileList: false, |
|
2360 |
HTMLAllCollection: false, |
|
2361 |
HTMLCollection: false, |
|
2362 |
HTMLFormElement: false, |
|
2363 |
HTMLSelectElement: false, |
|
2364 |
MediaList: true, |
|
2365 |
MimeTypeArray: false, |
|
2366 |
NamedNodeMap: false, |
|
2367 |
NodeList: true, |
|
2368 |
PaintRequestList: false, |
|
2369 |
Plugin: false, |
|
2370 |
PluginArray: false, |
|
2371 |
SVGLengthList: false, |
|
2372 |
SVGNumberList: false, |
|
2373 |
SVGPathSegList: false, |
|
2374 |
SVGPointList: false, |
|
2375 |
SVGStringList: false, |
|
2376 |
SVGTransformList: false, |
|
2377 |
SourceBufferList: false, |
|
2378 |
StyleSheetList: true, |
|
2379 |
TextTrackCueList: false, |
|
2380 |
TextTrackList: false, |
|
2381 |
TouchList: false |
|
2382 |
}; |
|
2383 |
for (var collections = getKeys(DOMIterables), i = 0; i < collections.length; i++) { |
|
2384 |
var NAME = collections[i]; |
|
2385 |
var explicit = DOMIterables[NAME]; |
|
2386 |
var Collection = global[NAME]; |
|
2387 |
var proto = Collection && Collection.prototype; |
|
2388 |
var key; |
|
2389 |
if (proto) { |
|
2390 |
if (!proto[ITERATOR]) hide(proto, ITERATOR, ArrayValues); |
|
2391 |
if (!proto[TO_STRING_TAG]) hide(proto, TO_STRING_TAG, NAME); |
|
2392 |
Iterators[NAME] = ArrayValues; |
|
2393 |
if (explicit) for (key in $iterators) { |
|
2394 |
if (!proto[key]) redefine(proto, key, $iterators[key], true); |
|
2395 |
} |
|
2396 |
} |
|
2397 |
} |
|
2398 |
|
|
2399 |
/***/ }), |
|
2400 |
/* 73 */ |
|
2401 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2402 |
|
|
2403 |
"use strict"; |
|
2404 |
|
|
2405 |
|
|
2406 |
var addToUnscopables = __w_pdfjs_require__(41); |
|
2407 |
var step = __w_pdfjs_require__(74); |
|
2408 |
var Iterators = __w_pdfjs_require__(65); |
|
2409 |
var toIObject = __w_pdfjs_require__(36); |
|
2410 |
module.exports = __w_pdfjs_require__(64)(Array, 'Array', function (iterated, kind) { |
|
2411 |
this._t = toIObject(iterated); |
|
2412 |
this._i = 0; |
|
2413 |
this._k = kind; |
|
2414 |
}, function () { |
|
2415 |
var O = this._t; |
|
2416 |
var kind = this._k; |
|
2417 |
var index = this._i++; |
|
2418 |
if (!O || index >= O.length) { |
|
2419 |
this._t = undefined; |
|
2420 |
return step(1); |
|
2421 |
} |
|
2422 |
if (kind == 'keys') return step(0, index); |
|
2423 |
if (kind == 'values') return step(0, O[index]); |
|
2424 |
return step(0, [index, O[index]]); |
|
2425 |
}, 'values'); |
|
2426 |
Iterators.Arguments = Iterators.Array; |
|
2427 |
addToUnscopables('keys'); |
|
2428 |
addToUnscopables('values'); |
|
2429 |
addToUnscopables('entries'); |
|
2430 |
|
|
2431 |
/***/ }), |
|
2432 |
/* 74 */ |
|
2433 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2434 |
|
|
2435 |
"use strict"; |
|
2436 |
|
|
2437 |
|
|
2438 |
module.exports = function (done, value) { |
|
2439 |
return { |
|
2440 |
value: value, |
|
2441 |
done: !!done |
|
2442 |
}; |
|
2443 |
}; |
|
2444 |
|
|
2445 |
/***/ }), |
|
2446 |
/* 75 */ |
|
2447 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2448 |
|
|
2449 |
"use strict"; |
|
2450 |
|
|
2451 |
|
|
2452 |
var LIBRARY = __w_pdfjs_require__(30); |
|
2453 |
var global = __w_pdfjs_require__(8); |
|
2454 |
var ctx = __w_pdfjs_require__(23); |
|
2455 |
var classof = __w_pdfjs_require__(61); |
|
2456 |
var $export = __w_pdfjs_require__(7); |
|
2457 |
var isObject = __w_pdfjs_require__(13); |
|
2458 |
var aFunction = __w_pdfjs_require__(24); |
|
2459 |
var anInstance = __w_pdfjs_require__(76); |
|
2460 |
var forOf = __w_pdfjs_require__(77); |
|
2461 |
var speciesConstructor = __w_pdfjs_require__(81); |
|
2462 |
var task = __w_pdfjs_require__(82).set; |
|
2463 |
var microtask = __w_pdfjs_require__(84)(); |
|
2464 |
var newPromiseCapabilityModule = __w_pdfjs_require__(85); |
|
2465 |
var perform = __w_pdfjs_require__(86); |
|
2466 |
var userAgent = __w_pdfjs_require__(87); |
|
2467 |
var promiseResolve = __w_pdfjs_require__(88); |
|
2468 |
var PROMISE = 'Promise'; |
|
2469 |
var TypeError = global.TypeError; |
|
2470 |
var process = global.process; |
|
2471 |
var versions = process && process.versions; |
|
2472 |
var v8 = versions && versions.v8 || ''; |
|
2473 |
var $Promise = global[PROMISE]; |
|
2474 |
var isNode = classof(process) == 'process'; |
|
2475 |
var empty = function empty() {}; |
|
2476 |
var Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper; |
|
2477 |
var newPromiseCapability = newGenericPromiseCapability = newPromiseCapabilityModule.f; |
|
2478 |
var USE_NATIVE = !!function () { |
|
2479 |
try { |
|
2480 |
var promise = $Promise.resolve(1); |
|
2481 |
var FakePromise = (promise.constructor = {})[__w_pdfjs_require__(28)('species')] = function (exec) { |
|
2482 |
exec(empty, empty); |
|
2483 |
}; |
|
2484 |
return (isNode || typeof PromiseRejectionEvent == 'function') && promise.then(empty) instanceof FakePromise && v8.indexOf('6.6') !== 0 && userAgent.indexOf('Chrome/66') === -1; |
|
2485 |
} catch (e) {} |
|
2486 |
}(); |
|
2487 |
var isThenable = function isThenable(it) { |
|
2488 |
var then; |
|
2489 |
return isObject(it) && typeof (then = it.then) == 'function' ? then : false; |
|
2490 |
}; |
|
2491 |
var notify = function notify(promise, isReject) { |
|
2492 |
if (promise._n) return; |
|
2493 |
promise._n = true; |
|
2494 |
var chain = promise._c; |
|
2495 |
microtask(function () { |
|
2496 |
var value = promise._v; |
|
2497 |
var ok = promise._s == 1; |
|
2498 |
var i = 0; |
|
2499 |
var run = function run(reaction) { |
|
2500 |
var handler = ok ? reaction.ok : reaction.fail; |
|
2501 |
var resolve = reaction.resolve; |
|
2502 |
var reject = reaction.reject; |
|
2503 |
var domain = reaction.domain; |
|
2504 |
var result, then, exited; |
|
2505 |
try { |
|
2506 |
if (handler) { |
|
2507 |
if (!ok) { |
|
2508 |
if (promise._h == 2) onHandleUnhandled(promise); |
|
2509 |
promise._h = 1; |
|
2510 |
} |
|
2511 |
if (handler === true) result = value;else { |
|
2512 |
if (domain) domain.enter(); |
|
2513 |
result = handler(value); |
|
2514 |
if (domain) { |
|
2515 |
domain.exit(); |
|
2516 |
exited = true; |
|
2517 |
} |
|
2518 |
} |
|
2519 |
if (result === reaction.promise) { |
|
2520 |
reject(TypeError('Promise-chain cycle')); |
|
2521 |
} else if (then = isThenable(result)) { |
|
2522 |
then.call(result, resolve, reject); |
|
2523 |
} else resolve(result); |
|
2524 |
} else reject(value); |
|
2525 |
} catch (e) { |
|
2526 |
if (domain && !exited) domain.exit(); |
|
2527 |
reject(e); |
|
2528 |
} |
|
2529 |
}; |
|
2530 |
while (chain.length > i) { |
|
2531 |
run(chain[i++]); |
|
2532 |
}promise._c = []; |
|
2533 |
promise._n = false; |
|
2534 |
if (isReject && !promise._h) onUnhandled(promise); |
|
2535 |
}); |
|
2536 |
}; |
|
2537 |
var onUnhandled = function onUnhandled(promise) { |
|
2538 |
task.call(global, function () { |
|
2539 |
var value = promise._v; |
|
2540 |
var unhandled = isUnhandled(promise); |
|
2541 |
var result, handler, console; |
|
2542 |
if (unhandled) { |
|
2543 |
result = perform(function () { |
|
2544 |
if (isNode) { |
|
2545 |
process.emit('unhandledRejection', value, promise); |
|
2546 |
} else if (handler = global.onunhandledrejection) { |
|
2547 |
handler({ |
|
2548 |
promise: promise, |
|
2549 |
reason: value |
|
2550 |
}); |
|
2551 |
} else if ((console = global.console) && console.error) { |
|
2552 |
console.error('Unhandled promise rejection', value); |
|
2553 |
} |
|
2554 |
}); |
|
2555 |
promise._h = isNode || isUnhandled(promise) ? 2 : 1; |
|
2556 |
} |
|
2557 |
promise._a = undefined; |
|
2558 |
if (unhandled && result.e) throw result.v; |
|
2559 |
}); |
|
2560 |
}; |
|
2561 |
var isUnhandled = function isUnhandled(promise) { |
|
2562 |
return promise._h !== 1 && (promise._a || promise._c).length === 0; |
|
2563 |
}; |
|
2564 |
var onHandleUnhandled = function onHandleUnhandled(promise) { |
|
2565 |
task.call(global, function () { |
|
2566 |
var handler; |
|
2567 |
if (isNode) { |
|
2568 |
process.emit('rejectionHandled', promise); |
|
2569 |
} else if (handler = global.onrejectionhandled) { |
|
2570 |
handler({ |
|
2571 |
promise: promise, |
|
2572 |
reason: promise._v |
|
2573 |
}); |
|
2574 |
} |
|
2575 |
}); |
|
2576 |
}; |
|
2577 |
var $reject = function $reject(value) { |
|
2578 |
var promise = this; |
|
2579 |
if (promise._d) return; |
|
2580 |
promise._d = true; |
|
2581 |
promise = promise._w || promise; |
|
2582 |
promise._v = value; |
|
2583 |
promise._s = 2; |
|
2584 |
if (!promise._a) promise._a = promise._c.slice(); |
|
2585 |
notify(promise, true); |
|
2586 |
}; |
|
2587 |
var $resolve = function $resolve(value) { |
|
2588 |
var promise = this; |
|
2589 |
var then; |
|
2590 |
if (promise._d) return; |
|
2591 |
promise._d = true; |
|
2592 |
promise = promise._w || promise; |
|
2593 |
try { |
|
2594 |
if (promise === value) throw TypeError("Promise can't be resolved itself"); |
|
2595 |
if (then = isThenable(value)) { |
|
2596 |
microtask(function () { |
|
2597 |
var wrapper = { |
|
2598 |
_w: promise, |
|
2599 |
_d: false |
|
2600 |
}; |
|
2601 |
try { |
|
2602 |
then.call(value, ctx($resolve, wrapper, 1), ctx($reject, wrapper, 1)); |
|
2603 |
} catch (e) { |
|
2604 |
$reject.call(wrapper, e); |
|
2605 |
} |
|
2606 |
}); |
|
2607 |
} else { |
|
2608 |
promise._v = value; |
|
2609 |
promise._s = 1; |
|
2610 |
notify(promise, false); |
|
2611 |
} |
|
2612 |
} catch (e) { |
|
2613 |
$reject.call({ |
|
2614 |
_w: promise, |
|
2615 |
_d: false |
|
2616 |
}, e); |
|
2617 |
} |
|
2618 |
}; |
|
2619 |
if (!USE_NATIVE) { |
|
2620 |
$Promise = function Promise(executor) { |
|
2621 |
anInstance(this, $Promise, PROMISE, '_h'); |
|
2622 |
aFunction(executor); |
|
2623 |
Internal.call(this); |
|
2624 |
try { |
|
2625 |
executor(ctx($resolve, this, 1), ctx($reject, this, 1)); |
|
2626 |
} catch (err) { |
|
2627 |
$reject.call(this, err); |
|
2628 |
} |
|
2629 |
}; |
|
2630 |
Internal = function Promise(executor) { |
|
2631 |
this._c = []; |
|
2632 |
this._a = undefined; |
|
2633 |
this._s = 0; |
|
2634 |
this._d = false; |
|
2635 |
this._v = undefined; |
|
2636 |
this._h = 0; |
|
2637 |
this._n = false; |
|
2638 |
}; |
|
2639 |
Internal.prototype = __w_pdfjs_require__(89)($Promise.prototype, { |
|
2640 |
then: function then(onFulfilled, onRejected) { |
|
2641 |
var reaction = newPromiseCapability(speciesConstructor(this, $Promise)); |
|
2642 |
reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true; |
|
2643 |
reaction.fail = typeof onRejected == 'function' && onRejected; |
|
2644 |
reaction.domain = isNode ? process.domain : undefined; |
|
2645 |
this._c.push(reaction); |
|
2646 |
if (this._a) this._a.push(reaction); |
|
2647 |
if (this._s) notify(this, false); |
|
2648 |
return reaction.promise; |
|
2649 |
}, |
|
2650 |
'catch': function _catch(onRejected) { |
|
2651 |
return this.then(undefined, onRejected); |
|
2652 |
} |
|
2653 |
}); |
|
2654 |
OwnPromiseCapability = function OwnPromiseCapability() { |
|
2655 |
var promise = new Internal(); |
|
2656 |
this.promise = promise; |
|
2657 |
this.resolve = ctx($resolve, promise, 1); |
|
2658 |
this.reject = ctx($reject, promise, 1); |
|
2659 |
}; |
|
2660 |
newPromiseCapabilityModule.f = newPromiseCapability = function newPromiseCapability(C) { |
|
2661 |
return C === $Promise || C === Wrapper ? new OwnPromiseCapability(C) : newGenericPromiseCapability(C); |
|
2662 |
}; |
|
2663 |
} |
|
2664 |
$export($export.G + $export.W + $export.F * !USE_NATIVE, { Promise: $Promise }); |
|
2665 |
__w_pdfjs_require__(70)($Promise, PROMISE); |
|
2666 |
__w_pdfjs_require__(90)(PROMISE); |
|
2667 |
Wrapper = __w_pdfjs_require__(9)[PROMISE]; |
|
2668 |
$export($export.S + $export.F * !USE_NATIVE, PROMISE, { |
|
2669 |
reject: function reject(r) { |
|
2670 |
var capability = newPromiseCapability(this); |
|
2671 |
var $$reject = capability.reject; |
|
2672 |
$$reject(r); |
|
2673 |
return capability.promise; |
|
2674 |
} |
|
2675 |
}); |
|
2676 |
$export($export.S + $export.F * (LIBRARY || !USE_NATIVE), PROMISE, { |
|
2677 |
resolve: function resolve(x) { |
|
2678 |
return promiseResolve(LIBRARY && this === Wrapper ? $Promise : this, x); |
|
2679 |
} |
|
2680 |
}); |
|
2681 |
$export($export.S + $export.F * !(USE_NATIVE && __w_pdfjs_require__(91)(function (iter) { |
|
2682 |
$Promise.all(iter)['catch'](empty); |
|
2683 |
})), PROMISE, { |
|
2684 |
all: function all(iterable) { |
|
2685 |
var C = this; |
|
2686 |
var capability = newPromiseCapability(C); |
|
2687 |
var resolve = capability.resolve; |
|
2688 |
var reject = capability.reject; |
|
2689 |
var result = perform(function () { |
|
2690 |
var values = []; |
|
2691 |
var index = 0; |
|
2692 |
var remaining = 1; |
|
2693 |
forOf(iterable, false, function (promise) { |
|
2694 |
var $index = index++; |
|
2695 |
var alreadyCalled = false; |
|
2696 |
values.push(undefined); |
|
2697 |
remaining++; |
|
2698 |
C.resolve(promise).then(function (value) { |
|
2699 |
if (alreadyCalled) return; |
|
2700 |
alreadyCalled = true; |
|
2701 |
values[$index] = value; |
|
2702 |
--remaining || resolve(values); |
|
2703 |
}, reject); |
|
2704 |
}); |
|
2705 |
--remaining || resolve(values); |
|
2706 |
}); |
|
2707 |
if (result.e) reject(result.v); |
|
2708 |
return capability.promise; |
|
2709 |
}, |
|
2710 |
race: function race(iterable) { |
|
2711 |
var C = this; |
|
2712 |
var capability = newPromiseCapability(C); |
|
2713 |
var reject = capability.reject; |
|
2714 |
var result = perform(function () { |
|
2715 |
forOf(iterable, false, function (promise) { |
|
2716 |
C.resolve(promise).then(capability.resolve, reject); |
|
2717 |
}); |
|
2718 |
}); |
|
2719 |
if (result.e) reject(result.v); |
|
2720 |
return capability.promise; |
|
2721 |
} |
|
2722 |
}); |
|
2723 |
|
|
2724 |
/***/ }), |
|
2725 |
/* 76 */ |
|
2726 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2727 |
|
|
2728 |
"use strict"; |
|
2729 |
|
|
2730 |
|
|
2731 |
module.exports = function (it, Constructor, name, forbiddenField) { |
|
2732 |
if (!(it instanceof Constructor) || forbiddenField !== undefined && forbiddenField in it) { |
|
2733 |
throw TypeError(name + ': incorrect invocation!'); |
|
2734 |
} |
|
2735 |
return it; |
|
2736 |
}; |
|
2737 |
|
|
2738 |
/***/ }), |
|
2739 |
/* 77 */ |
|
2740 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2741 |
|
|
2742 |
"use strict"; |
|
2743 |
|
|
2744 |
|
|
2745 |
var ctx = __w_pdfjs_require__(23); |
|
2746 |
var call = __w_pdfjs_require__(78); |
|
2747 |
var isArrayIter = __w_pdfjs_require__(79); |
|
2748 |
var anObject = __w_pdfjs_require__(12); |
|
2749 |
var toLength = __w_pdfjs_require__(38); |
|
2750 |
var getIterFn = __w_pdfjs_require__(80); |
|
2751 |
var BREAK = {}; |
|
2752 |
var RETURN = {}; |
|
2753 |
var _exports = module.exports = function (iterable, entries, fn, that, ITERATOR) { |
|
2754 |
var iterFn = ITERATOR ? function () { |
|
2755 |
return iterable; |
|
2756 |
} : getIterFn(iterable); |
|
2757 |
var f = ctx(fn, that, entries ? 2 : 1); |
|
2758 |
var index = 0; |
|
2759 |
var length, step, iterator, result; |
|
2760 |
if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!'); |
|
2761 |
if (isArrayIter(iterFn)) for (length = toLength(iterable.length); length > index; index++) { |
|
2762 |
result = entries ? f(anObject(step = iterable[index])[0], step[1]) : f(iterable[index]); |
|
2763 |
if (result === BREAK || result === RETURN) return result; |
|
2764 |
} else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) { |
|
2765 |
result = call(iterator, f, step.value, entries); |
|
2766 |
if (result === BREAK || result === RETURN) return result; |
|
2767 |
} |
|
2768 |
}; |
|
2769 |
_exports.BREAK = BREAK; |
|
2770 |
_exports.RETURN = RETURN; |
|
2771 |
|
|
2772 |
/***/ }), |
|
2773 |
/* 78 */ |
|
2774 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2775 |
|
|
2776 |
"use strict"; |
|
2777 |
|
|
2778 |
|
|
2779 |
var anObject = __w_pdfjs_require__(12); |
|
2780 |
module.exports = function (iterator, fn, value, entries) { |
|
2781 |
try { |
|
2782 |
return entries ? fn(anObject(value)[0], value[1]) : fn(value); |
|
2783 |
} catch (e) { |
|
2784 |
var ret = iterator['return']; |
|
2785 |
if (ret !== undefined) anObject(ret.call(iterator)); |
|
2786 |
throw e; |
|
2787 |
} |
|
2788 |
}; |
|
2789 |
|
|
2790 |
/***/ }), |
|
2791 |
/* 79 */ |
|
2792 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2793 |
|
|
2794 |
"use strict"; |
|
2795 |
|
|
2796 |
|
|
2797 |
var Iterators = __w_pdfjs_require__(65); |
|
2798 |
var ITERATOR = __w_pdfjs_require__(28)('iterator'); |
|
2799 |
var ArrayProto = Array.prototype; |
|
2800 |
module.exports = function (it) { |
|
2801 |
return it !== undefined && (Iterators.Array === it || ArrayProto[ITERATOR] === it); |
|
2802 |
}; |
|
2803 |
|
|
2804 |
/***/ }), |
|
2805 |
/* 80 */ |
|
2806 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2807 |
|
|
2808 |
"use strict"; |
|
2809 |
|
|
2810 |
|
|
2811 |
var classof = __w_pdfjs_require__(61); |
|
2812 |
var ITERATOR = __w_pdfjs_require__(28)('iterator'); |
|
2813 |
var Iterators = __w_pdfjs_require__(65); |
|
2814 |
module.exports = __w_pdfjs_require__(9).getIteratorMethod = function (it) { |
|
2815 |
if (it != undefined) return it[ITERATOR] || it['@@iterator'] || Iterators[classof(it)]; |
|
2816 |
}; |
|
2817 |
|
|
2818 |
/***/ }), |
|
2819 |
/* 81 */ |
|
2820 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2821 |
|
|
2822 |
"use strict"; |
|
2823 |
|
|
2824 |
|
|
2825 |
var anObject = __w_pdfjs_require__(12); |
|
2826 |
var aFunction = __w_pdfjs_require__(24); |
|
2827 |
var SPECIES = __w_pdfjs_require__(28)('species'); |
|
2828 |
module.exports = function (O, D) { |
|
2829 |
var C = anObject(O).constructor; |
|
2830 |
var S; |
|
2831 |
return C === undefined || (S = anObject(C)[SPECIES]) == undefined ? D : aFunction(S); |
|
2832 |
}; |
|
2833 |
|
|
2834 |
/***/ }), |
|
2835 |
/* 82 */ |
|
2836 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2837 |
|
|
2838 |
"use strict"; |
|
2839 |
|
|
2840 |
|
|
2841 |
var ctx = __w_pdfjs_require__(23); |
|
2842 |
var invoke = __w_pdfjs_require__(83); |
|
2843 |
var html = __w_pdfjs_require__(69); |
|
2844 |
var cel = __w_pdfjs_require__(17); |
|
2845 |
var global = __w_pdfjs_require__(8); |
|
2846 |
var process = global.process; |
|
2847 |
var setTask = global.setImmediate; |
|
2848 |
var clearTask = global.clearImmediate; |
|
2849 |
var MessageChannel = global.MessageChannel; |
|
2850 |
var Dispatch = global.Dispatch; |
|
2851 |
var counter = 0; |
|
2852 |
var queue = {}; |
|
2853 |
var ONREADYSTATECHANGE = 'onreadystatechange'; |
|
2854 |
var defer, channel, port; |
|
2855 |
var run = function run() { |
|
2856 |
var id = +this; |
|
2857 |
if (queue.hasOwnProperty(id)) { |
|
2858 |
var fn = queue[id]; |
|
2859 |
delete queue[id]; |
|
2860 |
fn(); |
|
2861 |
} |
|
2862 |
}; |
|
2863 |
var listener = function listener(event) { |
|
2864 |
run.call(event.data); |
|
2865 |
}; |
|
2866 |
if (!setTask || !clearTask) { |
|
2867 |
setTask = function setImmediate(fn) { |
|
2868 |
var args = []; |
|
2869 |
var i = 1; |
|
2870 |
while (arguments.length > i) { |
|
2871 |
args.push(arguments[i++]); |
|
2872 |
}queue[++counter] = function () { |
|
2873 |
invoke(typeof fn == 'function' ? fn : Function(fn), args); |
|
2874 |
}; |
|
2875 |
defer(counter); |
|
2876 |
return counter; |
|
2877 |
}; |
|
2878 |
clearTask = function clearImmediate(id) { |
|
2879 |
delete queue[id]; |
|
2880 |
}; |
|
2881 |
if (__w_pdfjs_require__(27)(process) == 'process') { |
|
2882 |
defer = function defer(id) { |
|
2883 |
process.nextTick(ctx(run, id, 1)); |
|
2884 |
}; |
|
2885 |
} else if (Dispatch && Dispatch.now) { |
|
2886 |
defer = function defer(id) { |
|
2887 |
Dispatch.now(ctx(run, id, 1)); |
|
2888 |
}; |
|
2889 |
} else if (MessageChannel) { |
|
2890 |
channel = new MessageChannel(); |
|
2891 |
port = channel.port2; |
|
2892 |
channel.port1.onmessage = listener; |
|
2893 |
defer = ctx(port.postMessage, port, 1); |
|
2894 |
} else if (global.addEventListener && typeof postMessage == 'function' && !global.importScripts) { |
|
2895 |
defer = function defer(id) { |
|
2896 |
global.postMessage(id + '', '*'); |
|
2897 |
}; |
|
2898 |
global.addEventListener('message', listener, false); |
|
2899 |
} else if (ONREADYSTATECHANGE in cel('script')) { |
|
2900 |
defer = function defer(id) { |
|
2901 |
html.appendChild(cel('script'))[ONREADYSTATECHANGE] = function () { |
|
2902 |
html.removeChild(this); |
|
2903 |
run.call(id); |
|
2904 |
}; |
|
2905 |
}; |
|
2906 |
} else { |
|
2907 |
defer = function defer(id) { |
|
2908 |
setTimeout(ctx(run, id, 1), 0); |
|
2909 |
}; |
|
2910 |
} |
|
2911 |
} |
|
2912 |
module.exports = { |
|
2913 |
set: setTask, |
|
2914 |
clear: clearTask |
|
2915 |
}; |
|
2916 |
|
|
2917 |
/***/ }), |
|
2918 |
/* 83 */ |
|
2919 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2920 |
|
|
2921 |
"use strict"; |
|
2922 |
|
|
2923 |
|
|
2924 |
module.exports = function (fn, args, that) { |
|
2925 |
var un = that === undefined; |
|
2926 |
switch (args.length) { |
|
2927 |
case 0: |
|
2928 |
return un ? fn() : fn.call(that); |
|
2929 |
case 1: |
|
2930 |
return un ? fn(args[0]) : fn.call(that, args[0]); |
|
2931 |
case 2: |
|
2932 |
return un ? fn(args[0], args[1]) : fn.call(that, args[0], args[1]); |
|
2933 |
case 3: |
|
2934 |
return un ? fn(args[0], args[1], args[2]) : fn.call(that, args[0], args[1], args[2]); |
|
2935 |
case 4: |
|
2936 |
return un ? fn(args[0], args[1], args[2], args[3]) : fn.call(that, args[0], args[1], args[2], args[3]); |
|
2937 |
} |
|
2938 |
return fn.apply(that, args); |
|
2939 |
}; |
|
2940 |
|
|
2941 |
/***/ }), |
|
2942 |
/* 84 */ |
|
2943 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
2944 |
|
|
2945 |
"use strict"; |
|
2946 |
|
|
2947 |
|
|
2948 |
var global = __w_pdfjs_require__(8); |
|
2949 |
var macrotask = __w_pdfjs_require__(82).set; |
|
2950 |
var Observer = global.MutationObserver || global.WebKitMutationObserver; |
|
2951 |
var process = global.process; |
|
2952 |
var Promise = global.Promise; |
|
2953 |
var isNode = __w_pdfjs_require__(27)(process) == 'process'; |
|
2954 |
module.exports = function () { |
|
2955 |
var head, last, notify; |
|
2956 |
var flush = function flush() { |
|
2957 |
var parent, fn; |
|
2958 |
if (isNode && (parent = process.domain)) parent.exit(); |
|
2959 |
while (head) { |
|
2960 |
fn = head.fn; |
|
2961 |
head = head.next; |
|
2962 |
try { |
|
2963 |
fn(); |
|
2964 |
} catch (e) { |
|
2965 |
if (head) notify();else last = undefined; |
|
2966 |
throw e; |
|
2967 |
} |
|
2968 |
} |
|
2969 |
last = undefined; |
|
2970 |
if (parent) parent.enter(); |
|
2971 |
}; |
|
2972 |
if (isNode) { |
|
2973 |
notify = function notify() { |
|
2974 |
process.nextTick(flush); |
|
2975 |
}; |
|
2976 |
} else if (Observer && !(global.navigator && global.navigator.standalone)) { |
|
2977 |
var toggle = true; |
|
2978 |
var node = document.createTextNode(''); |
|
2979 |
new Observer(flush).observe(node, { characterData: true }); |
|
2980 |
notify = function notify() { |
|
2981 |
node.data = toggle = !toggle; |
|
2982 |
}; |
|
2983 |
} else if (Promise && Promise.resolve) { |
|
2984 |
var promise = Promise.resolve(undefined); |
|
2985 |
notify = function notify() { |
|
2986 |
promise.then(flush); |
|
2987 |
}; |
|
2988 |
} else { |
|
2989 |
notify = function notify() { |
|
2990 |
macrotask.call(global, flush); |
|
2991 |
}; |
|
2992 |
} |
|
2993 |
return function (fn) { |
|
2994 |
var task = { |
|
2995 |
fn: fn, |
|
2996 |
next: undefined |
|
2997 |
}; |
|
2998 |
if (last) last.next = task; |
|
2999 |
if (!head) { |
|
3000 |
head = task; |
|
3001 |
notify(); |
|
3002 |
} |
|
3003 |
last = task; |
|
3004 |
}; |
|
3005 |
}; |
|
3006 |
|
|
3007 |
/***/ }), |
|
3008 |
/* 85 */ |
|
3009 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3010 |
|
|
3011 |
"use strict"; |
|
3012 |
|
|
3013 |
|
|
3014 |
var aFunction = __w_pdfjs_require__(24); |
|
3015 |
function PromiseCapability(C) { |
|
3016 |
var resolve, reject; |
|
3017 |
this.promise = new C(function ($$resolve, $$reject) { |
|
3018 |
if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor'); |
|
3019 |
resolve = $$resolve; |
|
3020 |
reject = $$reject; |
|
3021 |
}); |
|
3022 |
this.resolve = aFunction(resolve); |
|
3023 |
this.reject = aFunction(reject); |
|
3024 |
} |
|
3025 |
module.exports.f = function (C) { |
|
3026 |
return new PromiseCapability(C); |
|
3027 |
}; |
|
3028 |
|
|
3029 |
/***/ }), |
|
3030 |
/* 86 */ |
|
3031 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3032 |
|
|
3033 |
"use strict"; |
|
3034 |
|
|
3035 |
|
|
3036 |
module.exports = function (exec) { |
|
3037 |
try { |
|
3038 |
return { |
|
3039 |
e: false, |
|
3040 |
v: exec() |
|
3041 |
}; |
|
3042 |
} catch (e) { |
|
3043 |
return { |
|
3044 |
e: true, |
|
3045 |
v: e |
|
3046 |
}; |
|
3047 |
} |
|
3048 |
}; |
|
3049 |
|
|
3050 |
/***/ }), |
|
3051 |
/* 87 */ |
|
3052 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3053 |
|
|
3054 |
"use strict"; |
|
3055 |
|
|
3056 |
|
|
3057 |
var global = __w_pdfjs_require__(8); |
|
3058 |
var navigator = global.navigator; |
|
3059 |
module.exports = navigator && navigator.userAgent || ''; |
|
3060 |
|
|
3061 |
/***/ }), |
|
3062 |
/* 88 */ |
|
3063 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3064 |
|
|
3065 |
"use strict"; |
|
3066 |
|
|
3067 |
|
|
3068 |
var anObject = __w_pdfjs_require__(12); |
|
3069 |
var isObject = __w_pdfjs_require__(13); |
|
3070 |
var newPromiseCapability = __w_pdfjs_require__(85); |
|
3071 |
module.exports = function (C, x) { |
|
3072 |
anObject(C); |
|
3073 |
if (isObject(x) && x.constructor === C) return x; |
|
3074 |
var promiseCapability = newPromiseCapability.f(C); |
|
3075 |
var resolve = promiseCapability.resolve; |
|
3076 |
resolve(x); |
|
3077 |
return promiseCapability.promise; |
|
3078 |
}; |
|
3079 |
|
|
3080 |
/***/ }), |
|
3081 |
/* 89 */ |
|
3082 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3083 |
|
|
3084 |
"use strict"; |
|
3085 |
|
|
3086 |
|
|
3087 |
var redefine = __w_pdfjs_require__(20); |
|
3088 |
module.exports = function (target, src, safe) { |
|
3089 |
for (var key in src) { |
|
3090 |
redefine(target, key, src[key], safe); |
|
3091 |
}return target; |
|
3092 |
}; |
|
3093 |
|
|
3094 |
/***/ }), |
|
3095 |
/* 90 */ |
|
3096 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3097 |
|
|
3098 |
"use strict"; |
|
3099 |
|
|
3100 |
|
|
3101 |
var global = __w_pdfjs_require__(8); |
|
3102 |
var dP = __w_pdfjs_require__(11); |
|
3103 |
var DESCRIPTORS = __w_pdfjs_require__(15); |
|
3104 |
var SPECIES = __w_pdfjs_require__(28)('species'); |
|
3105 |
module.exports = function (KEY) { |
|
3106 |
var C = global[KEY]; |
|
3107 |
if (DESCRIPTORS && C && !C[SPECIES]) dP.f(C, SPECIES, { |
|
3108 |
configurable: true, |
|
3109 |
get: function get() { |
|
3110 |
return this; |
|
3111 |
} |
|
3112 |
}); |
|
3113 |
}; |
|
3114 |
|
|
3115 |
/***/ }), |
|
3116 |
/* 91 */ |
|
3117 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3118 |
|
|
3119 |
"use strict"; |
|
3120 |
|
|
3121 |
|
|
3122 |
var ITERATOR = __w_pdfjs_require__(28)('iterator'); |
|
3123 |
var SAFE_CLOSING = false; |
|
3124 |
try { |
|
3125 |
var riter = [7][ITERATOR](); |
|
3126 |
riter['return'] = function () { |
|
3127 |
SAFE_CLOSING = true; |
|
3128 |
}; |
|
3129 |
Array.from(riter, function () { |
|
3130 |
throw 2; |
|
3131 |
}); |
|
3132 |
} catch (e) {} |
|
3133 |
module.exports = function (exec, skipClosing) { |
|
3134 |
if (!skipClosing && !SAFE_CLOSING) return false; |
|
3135 |
var safe = false; |
|
3136 |
try { |
|
3137 |
var arr = [7]; |
|
3138 |
var iter = arr[ITERATOR](); |
|
3139 |
iter.next = function () { |
|
3140 |
return { done: safe = true }; |
|
3141 |
}; |
|
3142 |
arr[ITERATOR] = function () { |
|
3143 |
return iter; |
|
3144 |
}; |
|
3145 |
exec(arr); |
|
3146 |
} catch (e) {} |
|
3147 |
return safe; |
|
3148 |
}; |
|
3149 |
|
|
3150 |
/***/ }), |
|
3151 |
/* 92 */ |
|
3152 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3153 |
|
|
3154 |
"use strict"; |
|
3155 |
|
|
3156 |
|
|
3157 |
var $export = __w_pdfjs_require__(7); |
|
3158 |
var core = __w_pdfjs_require__(9); |
|
3159 |
var global = __w_pdfjs_require__(8); |
|
3160 |
var speciesConstructor = __w_pdfjs_require__(81); |
|
3161 |
var promiseResolve = __w_pdfjs_require__(88); |
|
3162 |
$export($export.P + $export.R, 'Promise', { |
|
3163 |
'finally': function _finally(onFinally) { |
|
3164 |
var C = speciesConstructor(this, core.Promise || global.Promise); |
|
3165 |
var isFunction = typeof onFinally == 'function'; |
|
3166 |
return this.then(isFunction ? function (x) { |
|
3167 |
return promiseResolve(C, onFinally()).then(function () { |
|
3168 |
return x; |
|
3169 |
}); |
|
3170 |
} : onFinally, isFunction ? function (e) { |
|
3171 |
return promiseResolve(C, onFinally()).then(function () { |
|
3172 |
throw e; |
|
3173 |
}); |
|
3174 |
} : onFinally); |
|
3175 |
} |
|
3176 |
}); |
|
3177 |
|
|
3178 |
/***/ }), |
|
3179 |
/* 93 */ |
|
3180 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3181 |
|
|
3182 |
"use strict"; |
|
3183 |
|
|
3184 |
|
|
3185 |
var $export = __w_pdfjs_require__(7); |
|
3186 |
var newPromiseCapability = __w_pdfjs_require__(85); |
|
3187 |
var perform = __w_pdfjs_require__(86); |
|
3188 |
$export($export.S, 'Promise', { |
|
3189 |
'try': function _try(callbackfn) { |
|
3190 |
var promiseCapability = newPromiseCapability.f(this); |
|
3191 |
var result = perform(callbackfn); |
|
3192 |
(result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v); |
|
3193 |
return promiseCapability.promise; |
|
3194 |
} |
|
3195 |
}); |
|
3196 |
|
|
3197 |
/***/ }), |
|
3198 |
/* 94 */ |
|
3199 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3200 |
|
|
3201 |
"use strict"; |
|
3202 |
|
|
3203 |
|
|
3204 |
__w_pdfjs_require__(60); |
|
3205 |
__w_pdfjs_require__(72); |
|
3206 |
__w_pdfjs_require__(95); |
|
3207 |
__w_pdfjs_require__(107); |
|
3208 |
__w_pdfjs_require__(109); |
|
3209 |
module.exports = __w_pdfjs_require__(9).WeakMap; |
|
3210 |
|
|
3211 |
/***/ }), |
|
3212 |
/* 95 */ |
|
3213 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3214 |
|
|
3215 |
"use strict"; |
|
3216 |
|
|
3217 |
|
|
3218 |
var each = __w_pdfjs_require__(96)(0); |
|
3219 |
var redefine = __w_pdfjs_require__(20); |
|
3220 |
var meta = __w_pdfjs_require__(100); |
|
3221 |
var assign = __w_pdfjs_require__(44); |
|
3222 |
var weak = __w_pdfjs_require__(101); |
|
3223 |
var isObject = __w_pdfjs_require__(13); |
|
3224 |
var fails = __w_pdfjs_require__(16); |
|
3225 |
var validate = __w_pdfjs_require__(102); |
|
3226 |
var WEAK_MAP = 'WeakMap'; |
|
3227 |
var getWeak = meta.getWeak; |
|
3228 |
var isExtensible = Object.isExtensible; |
|
3229 |
var uncaughtFrozenStore = weak.ufstore; |
|
3230 |
var tmp = {}; |
|
3231 |
var InternalMap; |
|
3232 |
var wrapper = function wrapper(get) { |
|
3233 |
return function WeakMap() { |
|
3234 |
return get(this, arguments.length > 0 ? arguments[0] : undefined); |
|
3235 |
}; |
|
3236 |
}; |
|
3237 |
var methods = { |
|
3238 |
get: function get(key) { |
|
3239 |
if (isObject(key)) { |
|
3240 |
var data = getWeak(key); |
|
3241 |
if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key); |
|
3242 |
return data ? data[this._i] : undefined; |
|
3243 |
} |
|
3244 |
}, |
|
3245 |
set: function set(key, value) { |
|
3246 |
return weak.def(validate(this, WEAK_MAP), key, value); |
|
3247 |
} |
|
3248 |
}; |
|
3249 |
var $WeakMap = module.exports = __w_pdfjs_require__(103)(WEAK_MAP, wrapper, methods, weak, true, true); |
|
3250 |
if (fails(function () { |
|
3251 |
return new $WeakMap().set((Object.freeze || Object)(tmp), 7).get(tmp) != 7; |
|
3252 |
})) { |
|
3253 |
InternalMap = weak.getConstructor(wrapper, WEAK_MAP); |
|
3254 |
assign(InternalMap.prototype, methods); |
|
3255 |
meta.NEED = true; |
|
3256 |
each(['delete', 'has', 'get', 'set'], function (key) { |
|
3257 |
var proto = $WeakMap.prototype; |
|
3258 |
var method = proto[key]; |
|
3259 |
redefine(proto, key, function (a, b) { |
|
3260 |
if (isObject(a) && !isExtensible(a)) { |
|
3261 |
if (!this._f) this._f = new InternalMap(); |
|
3262 |
var result = this._f[key](a, b); |
|
3263 |
return key == 'set' ? this : result; |
|
3264 |
} |
|
3265 |
return method.call(this, a, b); |
|
3266 |
}); |
|
3267 |
}); |
|
3268 |
} |
|
3269 |
|
|
3270 |
/***/ }), |
|
3271 |
/* 96 */ |
|
3272 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3273 |
|
|
3274 |
"use strict"; |
|
3275 |
|
|
3276 |
|
|
3277 |
var ctx = __w_pdfjs_require__(23); |
|
3278 |
var IObject = __w_pdfjs_require__(37); |
|
3279 |
var toObject = __w_pdfjs_require__(51); |
|
3280 |
var toLength = __w_pdfjs_require__(38); |
|
3281 |
var asc = __w_pdfjs_require__(97); |
|
3282 |
module.exports = function (TYPE, $create) { |
|
3283 |
var IS_MAP = TYPE == 1; |
|
3284 |
var IS_FILTER = TYPE == 2; |
|
3285 |
var IS_SOME = TYPE == 3; |
|
3286 |
var IS_EVERY = TYPE == 4; |
|
3287 |
var IS_FIND_INDEX = TYPE == 6; |
|
3288 |
var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; |
|
3289 |
var create = $create || asc; |
|
3290 |
return function ($this, callbackfn, that) { |
|
3291 |
var O = toObject($this); |
|
3292 |
var self = IObject(O); |
|
3293 |
var f = ctx(callbackfn, that, 3); |
|
3294 |
var length = toLength(self.length); |
|
3295 |
var index = 0; |
|
3296 |
var result = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined; |
|
3297 |
var val, res; |
|
3298 |
for (; length > index; index++) { |
|
3299 |
if (NO_HOLES || index in self) { |
|
3300 |
val = self[index]; |
|
3301 |
res = f(val, index, O); |
|
3302 |
if (TYPE) { |
|
3303 |
if (IS_MAP) result[index] = res;else if (res) switch (TYPE) { |
|
3304 |
case 3: |
|
3305 |
return true; |
|
3306 |
case 5: |
|
3307 |
return val; |
|
3308 |
case 6: |
|
3309 |
return index; |
|
3310 |
case 2: |
|
3311 |
result.push(val); |
|
3312 |
} else if (IS_EVERY) return false; |
|
3313 |
} |
|
3314 |
} |
|
3315 |
}return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : result; |
|
3316 |
}; |
|
3317 |
}; |
|
3318 |
|
|
3319 |
/***/ }), |
|
3320 |
/* 97 */ |
|
3321 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3322 |
|
|
3323 |
"use strict"; |
|
3324 |
|
|
3325 |
|
|
3326 |
var speciesConstructor = __w_pdfjs_require__(98); |
|
3327 |
module.exports = function (original, length) { |
|
3328 |
return new (speciesConstructor(original))(length); |
|
3329 |
}; |
|
3330 |
|
|
3331 |
/***/ }), |
|
3332 |
/* 98 */ |
|
3333 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3334 |
|
|
3335 |
"use strict"; |
|
3336 |
|
|
3337 |
|
|
3338 |
var isObject = __w_pdfjs_require__(13); |
|
3339 |
var isArray = __w_pdfjs_require__(99); |
|
3340 |
var SPECIES = __w_pdfjs_require__(28)('species'); |
|
3341 |
module.exports = function (original) { |
|
3342 |
var C; |
|
3343 |
if (isArray(original)) { |
|
3344 |
C = original.constructor; |
|
3345 |
if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined; |
|
3346 |
if (isObject(C)) { |
|
3347 |
C = C[SPECIES]; |
|
3348 |
if (C === null) C = undefined; |
|
3349 |
} |
|
3350 |
} |
|
3351 |
return C === undefined ? Array : C; |
|
3352 |
}; |
|
3353 |
|
|
3354 |
/***/ }), |
|
3355 |
/* 99 */ |
|
3356 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3357 |
|
|
3358 |
"use strict"; |
|
3359 |
|
|
3360 |
|
|
3361 |
var cof = __w_pdfjs_require__(27); |
|
3362 |
module.exports = Array.isArray || function isArray(arg) { |
|
3363 |
return cof(arg) == 'Array'; |
|
3364 |
}; |
|
3365 |
|
|
3366 |
/***/ }), |
|
3367 |
/* 100 */ |
|
3368 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3369 |
|
|
3370 |
"use strict"; |
|
3371 |
|
|
3372 |
|
|
3373 |
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; }; |
|
3374 |
|
|
3375 |
var META = __w_pdfjs_require__(22)('meta'); |
|
3376 |
var isObject = __w_pdfjs_require__(13); |
|
3377 |
var has = __w_pdfjs_require__(21); |
|
3378 |
var setDesc = __w_pdfjs_require__(11).f; |
|
3379 |
var id = 0; |
|
3380 |
var isExtensible = Object.isExtensible || function () { |
|
3381 |
return true; |
|
3382 |
}; |
|
3383 |
var FREEZE = !__w_pdfjs_require__(16)(function () { |
|
3384 |
return isExtensible(Object.preventExtensions({})); |
|
3385 |
}); |
|
3386 |
var setMeta = function setMeta(it) { |
|
3387 |
setDesc(it, META, { |
|
3388 |
value: { |
|
3389 |
i: 'O' + ++id, |
|
3390 |
w: {} |
|
3391 |
} |
|
3392 |
}); |
|
3393 |
}; |
|
3394 |
var fastKey = function fastKey(it, create) { |
|
3395 |
if (!isObject(it)) return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it; |
|
3396 |
if (!has(it, META)) { |
|
3397 |
if (!isExtensible(it)) return 'F'; |
|
3398 |
if (!create) return 'E'; |
|
3399 |
setMeta(it); |
|
3400 |
} |
|
3401 |
return it[META].i; |
|
3402 |
}; |
|
3403 |
var getWeak = function getWeak(it, create) { |
|
3404 |
if (!has(it, META)) { |
|
3405 |
if (!isExtensible(it)) return true; |
|
3406 |
if (!create) return false; |
|
3407 |
setMeta(it); |
|
3408 |
} |
|
3409 |
return it[META].w; |
|
3410 |
}; |
|
3411 |
var onFreeze = function onFreeze(it) { |
|
3412 |
if (FREEZE && meta.NEED && isExtensible(it) && !has(it, META)) setMeta(it); |
|
3413 |
return it; |
|
3414 |
}; |
|
3415 |
var meta = module.exports = { |
|
3416 |
KEY: META, |
|
3417 |
NEED: false, |
|
3418 |
fastKey: fastKey, |
|
3419 |
getWeak: getWeak, |
|
3420 |
onFreeze: onFreeze |
|
3421 |
}; |
|
3422 |
|
|
3423 |
/***/ }), |
|
3424 |
/* 101 */ |
|
3425 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3426 |
|
|
3427 |
"use strict"; |
|
3428 |
|
|
3429 |
|
|
3430 |
var redefineAll = __w_pdfjs_require__(89); |
|
3431 |
var getWeak = __w_pdfjs_require__(100).getWeak; |
|
3432 |
var anObject = __w_pdfjs_require__(12); |
|
3433 |
var isObject = __w_pdfjs_require__(13); |
|
3434 |
var anInstance = __w_pdfjs_require__(76); |
|
3435 |
var forOf = __w_pdfjs_require__(77); |
|
3436 |
var createArrayMethod = __w_pdfjs_require__(96); |
|
3437 |
var $has = __w_pdfjs_require__(21); |
|
3438 |
var validate = __w_pdfjs_require__(102); |
|
3439 |
var arrayFind = createArrayMethod(5); |
|
3440 |
var arrayFindIndex = createArrayMethod(6); |
|
3441 |
var id = 0; |
|
3442 |
var uncaughtFrozenStore = function uncaughtFrozenStore(that) { |
|
3443 |
return that._l || (that._l = new UncaughtFrozenStore()); |
|
3444 |
}; |
|
3445 |
var UncaughtFrozenStore = function UncaughtFrozenStore() { |
|
3446 |
this.a = []; |
|
3447 |
}; |
|
3448 |
var findUncaughtFrozen = function findUncaughtFrozen(store, key) { |
|
3449 |
return arrayFind(store.a, function (it) { |
|
3450 |
return it[0] === key; |
|
3451 |
}); |
|
3452 |
}; |
|
3453 |
UncaughtFrozenStore.prototype = { |
|
3454 |
get: function get(key) { |
|
3455 |
var entry = findUncaughtFrozen(this, key); |
|
3456 |
if (entry) return entry[1]; |
|
3457 |
}, |
|
3458 |
has: function has(key) { |
|
3459 |
return !!findUncaughtFrozen(this, key); |
|
3460 |
}, |
|
3461 |
set: function set(key, value) { |
|
3462 |
var entry = findUncaughtFrozen(this, key); |
|
3463 |
if (entry) entry[1] = value;else this.a.push([key, value]); |
|
3464 |
}, |
|
3465 |
'delete': function _delete(key) { |
|
3466 |
var index = arrayFindIndex(this.a, function (it) { |
|
3467 |
return it[0] === key; |
|
3468 |
}); |
|
3469 |
if (~index) this.a.splice(index, 1); |
|
3470 |
return !!~index; |
|
3471 |
} |
|
3472 |
}; |
|
3473 |
module.exports = { |
|
3474 |
getConstructor: function getConstructor(wrapper, NAME, IS_MAP, ADDER) { |
|
3475 |
var C = wrapper(function (that, iterable) { |
|
3476 |
anInstance(that, C, NAME, '_i'); |
|
3477 |
that._t = NAME; |
|
3478 |
that._i = id++; |
|
3479 |
that._l = undefined; |
|
3480 |
if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that); |
|
3481 |
}); |
|
3482 |
redefineAll(C.prototype, { |
|
3483 |
'delete': function _delete(key) { |
|
3484 |
if (!isObject(key)) return false; |
|
3485 |
var data = getWeak(key); |
|
3486 |
if (data === true) return uncaughtFrozenStore(validate(this, NAME))['delete'](key); |
|
3487 |
return data && $has(data, this._i) && delete data[this._i]; |
|
3488 |
}, |
|
3489 |
has: function has(key) { |
|
3490 |
if (!isObject(key)) return false; |
|
3491 |
var data = getWeak(key); |
|
3492 |
if (data === true) return uncaughtFrozenStore(validate(this, NAME)).has(key); |
|
3493 |
return data && $has(data, this._i); |
|
3494 |
} |
|
3495 |
}); |
|
3496 |
return C; |
|
3497 |
}, |
|
3498 |
def: function def(that, key, value) { |
|
3499 |
var data = getWeak(anObject(key), true); |
|
3500 |
if (data === true) uncaughtFrozenStore(that).set(key, value);else data[that._i] = value; |
|
3501 |
return that; |
|
3502 |
}, |
|
3503 |
ufstore: uncaughtFrozenStore |
|
3504 |
}; |
|
3505 |
|
|
3506 |
/***/ }), |
|
3507 |
/* 102 */ |
|
3508 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3509 |
|
|
3510 |
"use strict"; |
|
3511 |
|
|
3512 |
|
|
3513 |
var isObject = __w_pdfjs_require__(13); |
|
3514 |
module.exports = function (it, TYPE) { |
|
3515 |
if (!isObject(it) || it._t !== TYPE) throw TypeError('Incompatible receiver, ' + TYPE + ' required!'); |
|
3516 |
return it; |
|
3517 |
}; |
|
3518 |
|
|
3519 |
/***/ }), |
|
3520 |
/* 103 */ |
|
3521 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3522 |
|
|
3523 |
"use strict"; |
|
3524 |
|
|
3525 |
|
|
3526 |
var global = __w_pdfjs_require__(8); |
|
3527 |
var $export = __w_pdfjs_require__(7); |
|
3528 |
var redefine = __w_pdfjs_require__(20); |
|
3529 |
var redefineAll = __w_pdfjs_require__(89); |
|
3530 |
var meta = __w_pdfjs_require__(100); |
|
3531 |
var forOf = __w_pdfjs_require__(77); |
|
3532 |
var anInstance = __w_pdfjs_require__(76); |
|
3533 |
var isObject = __w_pdfjs_require__(13); |
|
3534 |
var fails = __w_pdfjs_require__(16); |
|
3535 |
var $iterDetect = __w_pdfjs_require__(91); |
|
3536 |
var setToStringTag = __w_pdfjs_require__(70); |
|
3537 |
var inheritIfRequired = __w_pdfjs_require__(104); |
|
3538 |
module.exports = function (NAME, wrapper, methods, common, IS_MAP, IS_WEAK) { |
|
3539 |
var Base = global[NAME]; |
|
3540 |
var C = Base; |
|
3541 |
var ADDER = IS_MAP ? 'set' : 'add'; |
|
3542 |
var proto = C && C.prototype; |
|
3543 |
var O = {}; |
|
3544 |
var fixMethod = function fixMethod(KEY) { |
|
3545 |
var fn = proto[KEY]; |
|
3546 |
redefine(proto, KEY, KEY == 'delete' ? function (a) { |
|
3547 |
return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); |
|
3548 |
} : KEY == 'has' ? function has(a) { |
|
3549 |
return IS_WEAK && !isObject(a) ? false : fn.call(this, a === 0 ? 0 : a); |
|
3550 |
} : KEY == 'get' ? function get(a) { |
|
3551 |
return IS_WEAK && !isObject(a) ? undefined : fn.call(this, a === 0 ? 0 : a); |
|
3552 |
} : KEY == 'add' ? function add(a) { |
|
3553 |
fn.call(this, a === 0 ? 0 : a); |
|
3554 |
return this; |
|
3555 |
} : function set(a, b) { |
|
3556 |
fn.call(this, a === 0 ? 0 : a, b); |
|
3557 |
return this; |
|
3558 |
}); |
|
3559 |
}; |
|
3560 |
if (typeof C != 'function' || !(IS_WEAK || proto.forEach && !fails(function () { |
|
3561 |
new C().entries().next(); |
|
3562 |
}))) { |
|
3563 |
C = common.getConstructor(wrapper, NAME, IS_MAP, ADDER); |
|
3564 |
redefineAll(C.prototype, methods); |
|
3565 |
meta.NEED = true; |
|
3566 |
} else { |
|
3567 |
var instance = new C(); |
|
3568 |
var HASNT_CHAINING = instance[ADDER](IS_WEAK ? {} : -0, 1) != instance; |
|
3569 |
var THROWS_ON_PRIMITIVES = fails(function () { |
|
3570 |
instance.has(1); |
|
3571 |
}); |
|
3572 |
var ACCEPT_ITERABLES = $iterDetect(function (iter) { |
|
3573 |
new C(iter); |
|
3574 |
}); |
|
3575 |
var BUGGY_ZERO = !IS_WEAK && fails(function () { |
|
3576 |
var $instance = new C(); |
|
3577 |
var index = 5; |
|
3578 |
while (index--) { |
|
3579 |
$instance[ADDER](index, index); |
|
3580 |
}return !$instance.has(-0); |
|
3581 |
}); |
|
3582 |
if (!ACCEPT_ITERABLES) { |
|
3583 |
C = wrapper(function (target, iterable) { |
|
3584 |
anInstance(target, C, NAME); |
|
3585 |
var that = inheritIfRequired(new Base(), target, C); |
|
3586 |
if (iterable != undefined) forOf(iterable, IS_MAP, that[ADDER], that); |
|
3587 |
return that; |
|
3588 |
}); |
|
3589 |
C.prototype = proto; |
|
3590 |
proto.constructor = C; |
|
3591 |
} |
|
3592 |
if (THROWS_ON_PRIMITIVES || BUGGY_ZERO) { |
|
3593 |
fixMethod('delete'); |
|
3594 |
fixMethod('has'); |
|
3595 |
IS_MAP && fixMethod('get'); |
|
3596 |
} |
|
3597 |
if (BUGGY_ZERO || HASNT_CHAINING) fixMethod(ADDER); |
|
3598 |
if (IS_WEAK && proto.clear) delete proto.clear; |
|
3599 |
} |
|
3600 |
setToStringTag(C, NAME); |
|
3601 |
O[NAME] = C; |
|
3602 |
$export($export.G + $export.W + $export.F * (C != Base), O); |
|
3603 |
if (!IS_WEAK) common.setStrong(C, NAME, IS_MAP); |
|
3604 |
return C; |
|
3605 |
}; |
|
3606 |
|
|
3607 |
/***/ }), |
|
3608 |
/* 104 */ |
|
3609 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3610 |
|
|
3611 |
"use strict"; |
|
3612 |
|
|
3613 |
|
|
3614 |
var isObject = __w_pdfjs_require__(13); |
|
3615 |
var setPrototypeOf = __w_pdfjs_require__(105).set; |
|
3616 |
module.exports = function (that, target, C) { |
|
3617 |
var S = target.constructor; |
|
3618 |
var P; |
|
3619 |
if (S !== C && typeof S == 'function' && (P = S.prototype) !== C.prototype && isObject(P) && setPrototypeOf) { |
|
3620 |
setPrototypeOf(that, P); |
|
3621 |
} |
|
3622 |
return that; |
|
3623 |
}; |
|
3624 |
|
|
3625 |
/***/ }), |
|
3626 |
/* 105 */ |
|
3627 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3628 |
|
|
3629 |
"use strict"; |
|
3630 |
|
|
3631 |
|
|
3632 |
var isObject = __w_pdfjs_require__(13); |
|
3633 |
var anObject = __w_pdfjs_require__(12); |
|
3634 |
var check = function check(O, proto) { |
|
3635 |
anObject(O); |
|
3636 |
if (!isObject(proto) && proto !== null) throw TypeError(proto + ": can't set as prototype!"); |
|
3637 |
}; |
|
3638 |
module.exports = { |
|
3639 |
set: Object.setPrototypeOf || ('__proto__' in {} ? function (test, buggy, set) { |
|
3640 |
try { |
|
3641 |
set = __w_pdfjs_require__(23)(Function.call, __w_pdfjs_require__(106).f(Object.prototype, '__proto__').set, 2); |
|
3642 |
set(test, []); |
|
3643 |
buggy = !(test instanceof Array); |
|
3644 |
} catch (e) { |
|
3645 |
buggy = true; |
|
3646 |
} |
|
3647 |
return function setPrototypeOf(O, proto) { |
|
3648 |
check(O, proto); |
|
3649 |
if (buggy) O.__proto__ = proto;else set(O, proto); |
|
3650 |
return O; |
|
3651 |
}; |
|
3652 |
}({}, false) : undefined), |
|
3653 |
check: check |
|
3654 |
}; |
|
3655 |
|
|
3656 |
/***/ }), |
|
3657 |
/* 106 */ |
|
3658 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3659 |
|
|
3660 |
"use strict"; |
|
3661 |
|
|
3662 |
|
|
3663 |
var pIE = __w_pdfjs_require__(50); |
|
3664 |
var createDesc = __w_pdfjs_require__(19); |
|
3665 |
var toIObject = __w_pdfjs_require__(36); |
|
3666 |
var toPrimitive = __w_pdfjs_require__(18); |
|
3667 |
var has = __w_pdfjs_require__(21); |
|
3668 |
var IE8_DOM_DEFINE = __w_pdfjs_require__(14); |
|
3669 |
var gOPD = Object.getOwnPropertyDescriptor; |
|
3670 |
exports.f = __w_pdfjs_require__(15) ? gOPD : function getOwnPropertyDescriptor(O, P) { |
|
3671 |
O = toIObject(O); |
|
3672 |
P = toPrimitive(P, true); |
|
3673 |
if (IE8_DOM_DEFINE) try { |
|
3674 |
return gOPD(O, P); |
|
3675 |
} catch (e) {} |
|
3676 |
if (has(O, P)) return createDesc(!pIE.f.call(O, P), O[P]); |
|
3677 |
}; |
|
3678 |
|
|
3679 |
/***/ }), |
|
3680 |
/* 107 */ |
|
3681 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3682 |
|
|
3683 |
"use strict"; |
|
3684 |
|
|
3685 |
|
|
3686 |
__w_pdfjs_require__(108)('WeakMap'); |
|
3687 |
|
|
3688 |
/***/ }), |
|
3689 |
/* 108 */ |
|
3690 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3691 |
|
|
3692 |
"use strict"; |
|
3693 |
|
|
3694 |
|
|
3695 |
var $export = __w_pdfjs_require__(7); |
|
3696 |
module.exports = function (COLLECTION) { |
|
3697 |
$export($export.S, COLLECTION, { |
|
3698 |
of: function of() { |
|
3699 |
var length = arguments.length; |
|
3700 |
var A = new Array(length); |
|
3701 |
while (length--) { |
|
3702 |
A[length] = arguments[length]; |
|
3703 |
}return new this(A); |
|
3704 |
} |
|
3705 |
}); |
|
3706 |
}; |
|
3707 |
|
|
3708 |
/***/ }), |
|
3709 |
/* 109 */ |
|
3710 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3711 |
|
|
3712 |
"use strict"; |
|
3713 |
|
|
3714 |
|
|
3715 |
__w_pdfjs_require__(110)('WeakMap'); |
|
3716 |
|
|
3717 |
/***/ }), |
|
3718 |
/* 110 */ |
|
3719 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3720 |
|
|
3721 |
"use strict"; |
|
3722 |
|
|
3723 |
|
|
3724 |
var $export = __w_pdfjs_require__(7); |
|
3725 |
var aFunction = __w_pdfjs_require__(24); |
|
3726 |
var ctx = __w_pdfjs_require__(23); |
|
3727 |
var forOf = __w_pdfjs_require__(77); |
|
3728 |
module.exports = function (COLLECTION) { |
|
3729 |
$export($export.S, COLLECTION, { |
|
3730 |
from: function from(source) { |
|
3731 |
var mapFn = arguments[1]; |
|
3732 |
var mapping, A, n, cb; |
|
3733 |
aFunction(this); |
|
3734 |
mapping = mapFn !== undefined; |
|
3735 |
if (mapping) aFunction(mapFn); |
|
3736 |
if (source == undefined) return new this(); |
|
3737 |
A = []; |
|
3738 |
if (mapping) { |
|
3739 |
n = 0; |
|
3740 |
cb = ctx(mapFn, arguments[2], 2); |
|
3741 |
forOf(source, false, function (nextItem) { |
|
3742 |
A.push(cb(nextItem, n++)); |
|
3743 |
}); |
|
3744 |
} else { |
|
3745 |
forOf(source, false, A.push, A); |
|
3746 |
} |
|
3747 |
return new this(A); |
|
3748 |
} |
|
3749 |
}); |
|
3750 |
}; |
|
3751 |
|
|
3752 |
/***/ }), |
|
3753 |
/* 111 */ |
|
3754 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3755 |
|
|
3756 |
"use strict"; |
|
3757 |
|
|
3758 |
|
|
3759 |
__w_pdfjs_require__(112); |
|
3760 |
module.exports = __w_pdfjs_require__(9).String.codePointAt; |
|
3761 |
|
|
3762 |
/***/ }), |
|
3763 |
/* 112 */ |
|
3764 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3765 |
|
|
3766 |
"use strict"; |
|
3767 |
|
|
3768 |
|
|
3769 |
var $export = __w_pdfjs_require__(7); |
|
3770 |
var $at = __w_pdfjs_require__(63)(false); |
|
3771 |
$export($export.P, 'String', { |
|
3772 |
codePointAt: function codePointAt(pos) { |
|
3773 |
return $at(this, pos); |
|
3774 |
} |
|
3775 |
}); |
|
3776 |
|
|
3777 |
/***/ }), |
|
3778 |
/* 113 */ |
|
3779 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3780 |
|
|
3781 |
"use strict"; |
|
3782 |
|
|
3783 |
|
|
3784 |
__w_pdfjs_require__(114); |
|
3785 |
module.exports = __w_pdfjs_require__(9).String.fromCodePoint; |
|
3786 |
|
|
3787 |
/***/ }), |
|
3788 |
/* 114 */ |
|
3789 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3790 |
|
|
3791 |
"use strict"; |
|
3792 |
|
|
3793 |
|
|
3794 |
var $export = __w_pdfjs_require__(7); |
|
3795 |
var toAbsoluteIndex = __w_pdfjs_require__(40); |
|
3796 |
var fromCharCode = String.fromCharCode; |
|
3797 |
var $fromCodePoint = String.fromCodePoint; |
|
3798 |
$export($export.S + $export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', { |
|
3799 |
fromCodePoint: function fromCodePoint(x) { |
|
3800 |
var res = []; |
|
3801 |
var aLen = arguments.length; |
|
3802 |
var i = 0; |
|
3803 |
var code; |
|
3804 |
while (aLen > i) { |
|
3805 |
code = +arguments[i++]; |
|
3806 |
if (toAbsoluteIndex(code, 0x10ffff) !== code) throw RangeError(code + ' is not a valid code point'); |
|
3807 |
res.push(code < 0x10000 ? fromCharCode(code) : fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)); |
|
3808 |
} |
|
3809 |
return res.join(''); |
|
3810 |
} |
|
3811 |
}); |
|
3812 |
|
|
3813 |
/***/ }), |
|
3814 |
/* 115 */ |
|
3815 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3816 |
|
|
3817 |
"use strict"; |
|
3818 |
|
|
3819 |
|
|
3820 |
__w_pdfjs_require__(116); |
|
3821 |
__w_pdfjs_require__(60); |
|
3822 |
module.exports = __w_pdfjs_require__(9).Symbol; |
|
3823 |
|
|
3824 |
/***/ }), |
|
3825 |
/* 116 */ |
|
3826 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
3827 |
|
|
3828 |
"use strict"; |
|
3829 |
|
|
3830 |
|
|
3831 |
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; }; |
|
3832 |
|
|
3833 |
var global = __w_pdfjs_require__(8); |
|
3834 |
var has = __w_pdfjs_require__(21); |
|
3835 |
var DESCRIPTORS = __w_pdfjs_require__(15); |
|
3836 |
var $export = __w_pdfjs_require__(7); |
|
3837 |
var redefine = __w_pdfjs_require__(20); |
|
3838 |
var META = __w_pdfjs_require__(100).KEY; |
|
3839 |
var $fails = __w_pdfjs_require__(16); |
|
3840 |
var shared = __w_pdfjs_require__(29); |
|
3841 |
var setToStringTag = __w_pdfjs_require__(70); |
|
3842 |
var uid = __w_pdfjs_require__(22); |
|
3843 |
var wks = __w_pdfjs_require__(28); |
|
3844 |
var wksExt = __w_pdfjs_require__(117); |
|
3845 |
var wksDefine = __w_pdfjs_require__(118); |
|
3846 |
var enumKeys = __w_pdfjs_require__(119); |
|
3847 |
var isArray = __w_pdfjs_require__(99); |
|
3848 |
var anObject = __w_pdfjs_require__(12); |
|
3849 |
var isObject = __w_pdfjs_require__(13); |
|
3850 |
var toIObject = __w_pdfjs_require__(36); |
|
3851 |
var toPrimitive = __w_pdfjs_require__(18); |
|
3852 |
var createDesc = __w_pdfjs_require__(19); |
|
3853 |
var _create = __w_pdfjs_require__(67); |
|
3854 |
var gOPNExt = __w_pdfjs_require__(120); |
|
3855 |
var $GOPD = __w_pdfjs_require__(106); |
|
3856 |
var $DP = __w_pdfjs_require__(11); |
|
3857 |
var $keys = __w_pdfjs_require__(45); |
|
3858 |
var gOPD = $GOPD.f; |
|
3859 |
var dP = $DP.f; |
|
3860 |
var gOPN = gOPNExt.f; |
|
3861 |
var $Symbol = global.Symbol; |
|
3862 |
var $JSON = global.JSON; |
|
3863 |
var _stringify = $JSON && $JSON.stringify; |
|
3864 |
var PROTOTYPE = 'prototype'; |
|
3865 |
var HIDDEN = wks('_hidden'); |
|
3866 |
var TO_PRIMITIVE = wks('toPrimitive'); |
|
3867 |
var isEnum = {}.propertyIsEnumerable; |
|
3868 |
var SymbolRegistry = shared('symbol-registry'); |
|
3869 |
var AllSymbols = shared('symbols'); |
|
3870 |
var OPSymbols = shared('op-symbols'); |
|
3871 |
var ObjectProto = Object[PROTOTYPE]; |
|
3872 |
var USE_NATIVE = typeof $Symbol == 'function'; |
|
3873 |
var QObject = global.QObject; |
|
3874 |
var setter = !QObject || !QObject[PROTOTYPE] || !QObject[PROTOTYPE].findChild; |
|
3875 |
var setSymbolDesc = DESCRIPTORS && $fails(function () { |
|
3876 |
return _create(dP({}, 'a', { |
|
3877 |
get: function get() { |
|
3878 |
return dP(this, 'a', { value: 7 }).a; |
|
3879 |
} |
|
3880 |
})).a != 7; |
|
3881 |
}) ? function (it, key, D) { |
|
3882 |
var protoDesc = gOPD(ObjectProto, key); |
|
3883 |
if (protoDesc) delete ObjectProto[key]; |
|
3884 |
dP(it, key, D); |
|
3885 |
if (protoDesc && it !== ObjectProto) dP(ObjectProto, key, protoDesc); |
|
3886 |
} : dP; |
|
3887 |
var wrap = function wrap(tag) { |
|
3888 |
var sym = AllSymbols[tag] = _create($Symbol[PROTOTYPE]); |
|
3889 |
sym._k = tag; |
|
3890 |
return sym; |
|
3891 |
}; |
|
3892 |
var isSymbol = USE_NATIVE && _typeof($Symbol.iterator) == 'symbol' ? function (it) { |
|
3893 |
return (typeof it === 'undefined' ? 'undefined' : _typeof(it)) == 'symbol'; |
|
3894 |
} : function (it) { |
|
3895 |
return it instanceof $Symbol; |
|
3896 |
}; |
|
3897 |
var $defineProperty = function defineProperty(it, key, D) { |
|
3898 |
if (it === ObjectProto) $defineProperty(OPSymbols, key, D); |
|
3899 |
anObject(it); |
|
3900 |
key = toPrimitive(key, true); |
|
3901 |
anObject(D); |
|
3902 |
if (has(AllSymbols, key)) { |
|
3903 |
if (!D.enumerable) { |
|
3904 |
if (!has(it, HIDDEN)) dP(it, HIDDEN, createDesc(1, {})); |
|
3905 |
it[HIDDEN][key] = true; |
|
3906 |
} else { |
|
3907 |
if (has(it, HIDDEN) && it[HIDDEN][key]) it[HIDDEN][key] = false; |
|
3908 |
D = _create(D, { enumerable: createDesc(0, false) }); |
|
3909 |
} |
|
3910 |
return setSymbolDesc(it, key, D); |
|
3911 |
} |
|
3912 |
return dP(it, key, D); |
|
3913 |
}; |
|
3914 |
var $defineProperties = function defineProperties(it, P) { |
|
3915 |
anObject(it); |
|
3916 |
var keys = enumKeys(P = toIObject(P)); |
|
3917 |
var i = 0; |
|
3918 |
var l = keys.length; |
|
3919 |
var key; |
|
3920 |
while (l > i) { |
|
3921 |
$defineProperty(it, key = keys[i++], P[key]); |
|
3922 |
}return it; |
|
3923 |
}; |
|
3924 |
var $create = function create(it, P) { |
|
3925 |
return P === undefined ? _create(it) : $defineProperties(_create(it), P); |
|
3926 |
}; |
|
3927 |
var $propertyIsEnumerable = function propertyIsEnumerable(key) { |
|
3928 |
var E = isEnum.call(this, key = toPrimitive(key, true)); |
|
3929 |
if (this === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return false; |
|
3930 |
return E || !has(this, key) || !has(AllSymbols, key) || has(this, HIDDEN) && this[HIDDEN][key] ? E : true; |
|
3931 |
}; |
|
3932 |
var $getOwnPropertyDescriptor = function getOwnPropertyDescriptor(it, key) { |
|
3933 |
it = toIObject(it); |
|
3934 |
key = toPrimitive(key, true); |
|
3935 |
if (it === ObjectProto && has(AllSymbols, key) && !has(OPSymbols, key)) return; |
|
3936 |
var D = gOPD(it, key); |
|
3937 |
if (D && has(AllSymbols, key) && !(has(it, HIDDEN) && it[HIDDEN][key])) D.enumerable = true; |
|
3938 |
return D; |
|
3939 |
}; |
|
3940 |
var $getOwnPropertyNames = function getOwnPropertyNames(it) { |
|
3941 |
var names = gOPN(toIObject(it)); |
|
3942 |
var result = []; |
|
3943 |
var i = 0; |
|
3944 |
var key; |
|
3945 |
while (names.length > i) { |
|
3946 |
if (!has(AllSymbols, key = names[i++]) && key != HIDDEN && key != META) result.push(key); |
|
3947 |
} |
|
3948 |
return result; |
|
3949 |
}; |
|
3950 |
var $getOwnPropertySymbols = function getOwnPropertySymbols(it) { |
|
3951 |
var IS_OP = it === ObjectProto; |
|
3952 |
var names = gOPN(IS_OP ? OPSymbols : toIObject(it)); |
|
3953 |
var result = []; |
|
3954 |
var i = 0; |
|
3955 |
var key; |
|
3956 |
while (names.length > i) { |
|
3957 |
if (has(AllSymbols, key = names[i++]) && (IS_OP ? has(ObjectProto, key) : true)) result.push(AllSymbols[key]); |
|
3958 |
} |
|
3959 |
return result; |
|
3960 |
}; |
|
3961 |
if (!USE_NATIVE) { |
|
3962 |
$Symbol = function _Symbol() { |
|
3963 |
if (this instanceof $Symbol) throw TypeError('Symbol is not a constructor!'); |
|
3964 |
var tag = uid(arguments.length > 0 ? arguments[0] : undefined); |
|
3965 |
var $set = function $set(value) { |
|
3966 |
if (this === ObjectProto) $set.call(OPSymbols, value); |
|
3967 |
if (has(this, HIDDEN) && has(this[HIDDEN], tag)) this[HIDDEN][tag] = false; |
|
3968 |
setSymbolDesc(this, tag, createDesc(1, value)); |
|
3969 |
}; |
|
3970 |
if (DESCRIPTORS && setter) setSymbolDesc(ObjectProto, tag, { |
|
3971 |
configurable: true, |
|
3972 |
set: $set |
|
3973 |
}); |
|
3974 |
return wrap(tag); |
|
3975 |
}; |
|
3976 |
redefine($Symbol[PROTOTYPE], 'toString', function toString() { |
|
3977 |
return this._k; |
|
3978 |
}); |
|
3979 |
$GOPD.f = $getOwnPropertyDescriptor; |
|
3980 |
$DP.f = $defineProperty; |
|
3981 |
__w_pdfjs_require__(121).f = gOPNExt.f = $getOwnPropertyNames; |
|
3982 |
__w_pdfjs_require__(50).f = $propertyIsEnumerable; |
|
3983 |
__w_pdfjs_require__(49).f = $getOwnPropertySymbols; |
|
3984 |
if (DESCRIPTORS && !__w_pdfjs_require__(30)) { |
|
3985 |
redefine(ObjectProto, 'propertyIsEnumerable', $propertyIsEnumerable, true); |
|
3986 |
} |
|
3987 |
wksExt.f = function (name) { |
|
3988 |
return wrap(wks(name)); |
|
3989 |
}; |
|
3990 |
} |
|
3991 |
$export($export.G + $export.W + $export.F * !USE_NATIVE, { Symbol: $Symbol }); |
|
3992 |
for (var es6Symbols = 'hasInstance,isConcatSpreadable,iterator,match,replace,search,species,split,toPrimitive,toStringTag,unscopables'.split(','), j = 0; es6Symbols.length > j;) { |
|
3993 |
wks(es6Symbols[j++]); |
|
3994 |
}for (var wellKnownSymbols = $keys(wks.store), k = 0; wellKnownSymbols.length > k;) { |
|
3995 |
wksDefine(wellKnownSymbols[k++]); |
|
3996 |
}$export($export.S + $export.F * !USE_NATIVE, 'Symbol', { |
|
3997 |
'for': function _for(key) { |
|
3998 |
return has(SymbolRegistry, key += '') ? SymbolRegistry[key] : SymbolRegistry[key] = $Symbol(key); |
|
3999 |
}, |
|
4000 |
keyFor: function keyFor(sym) { |
|
4001 |
if (!isSymbol(sym)) throw TypeError(sym + ' is not a symbol!'); |
|
4002 |
for (var key in SymbolRegistry) { |
|
4003 |
if (SymbolRegistry[key] === sym) return key; |
|
4004 |
} |
|
4005 |
}, |
|
4006 |
useSetter: function useSetter() { |
|
4007 |
setter = true; |
|
4008 |
}, |
|
4009 |
useSimple: function useSimple() { |
|
4010 |
setter = false; |
|
4011 |
} |
|
4012 |
}); |
|
4013 |
$export($export.S + $export.F * !USE_NATIVE, 'Object', { |
|
4014 |
create: $create, |
|
4015 |
defineProperty: $defineProperty, |
|
4016 |
defineProperties: $defineProperties, |
|
4017 |
getOwnPropertyDescriptor: $getOwnPropertyDescriptor, |
|
4018 |
getOwnPropertyNames: $getOwnPropertyNames, |
|
4019 |
getOwnPropertySymbols: $getOwnPropertySymbols |
|
4020 |
}); |
|
4021 |
$JSON && $export($export.S + $export.F * (!USE_NATIVE || $fails(function () { |
|
4022 |
var S = $Symbol(); |
|
4023 |
return _stringify([S]) != '[null]' || _stringify({ a: S }) != '{}' || _stringify(Object(S)) != '{}'; |
|
4024 |
})), 'JSON', { |
|
4025 |
stringify: function stringify(it) { |
|
4026 |
var args = [it]; |
|
4027 |
var i = 1; |
|
4028 |
var replacer, $replacer; |
|
4029 |
while (arguments.length > i) { |
|
4030 |
args.push(arguments[i++]); |
|
4031 |
}$replacer = replacer = args[1]; |
|
4032 |
if (!isObject(replacer) && it === undefined || isSymbol(it)) return; |
|
4033 |
if (!isArray(replacer)) replacer = function replacer(key, value) { |
|
4034 |
if (typeof $replacer == 'function') value = $replacer.call(this, key, value); |
|
4035 |
if (!isSymbol(value)) return value; |
|
4036 |
}; |
|
4037 |
args[1] = replacer; |
|
4038 |
return _stringify.apply($JSON, args); |
|
4039 |
} |
|
4040 |
}); |
|
4041 |
$Symbol[PROTOTYPE][TO_PRIMITIVE] || __w_pdfjs_require__(10)($Symbol[PROTOTYPE], TO_PRIMITIVE, $Symbol[PROTOTYPE].valueOf); |
|
4042 |
setToStringTag($Symbol, 'Symbol'); |
|
4043 |
setToStringTag(Math, 'Math', true); |
|
4044 |
setToStringTag(global.JSON, 'JSON', true); |
|
4045 |
|
|
4046 |
/***/ }), |
|
4047 |
/* 117 */ |
|
4048 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
4049 |
|
|
4050 |
"use strict"; |
|
4051 |
|
|
4052 |
|
|
4053 |
exports.f = __w_pdfjs_require__(28); |
|
4054 |
|
|
4055 |
/***/ }), |
|
4056 |
/* 118 */ |
|
4057 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
4058 |
|
|
4059 |
"use strict"; |
|
4060 |
|
|
4061 |
|
|
4062 |
var global = __w_pdfjs_require__(8); |
|
4063 |
var core = __w_pdfjs_require__(9); |
|
4064 |
var LIBRARY = __w_pdfjs_require__(30); |
|
4065 |
var wksExt = __w_pdfjs_require__(117); |
|
4066 |
var defineProperty = __w_pdfjs_require__(11).f; |
|
4067 |
module.exports = function (name) { |
|
4068 |
var $Symbol = core.Symbol || (core.Symbol = LIBRARY ? {} : global.Symbol || {}); |
|
4069 |
if (name.charAt(0) != '_' && !(name in $Symbol)) defineProperty($Symbol, name, { value: wksExt.f(name) }); |
|
4070 |
}; |
|
4071 |
|
|
4072 |
/***/ }), |
|
4073 |
/* 119 */ |
|
4074 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
4075 |
|
|
4076 |
"use strict"; |
|
4077 |
|
|
4078 |
|
|
4079 |
var getKeys = __w_pdfjs_require__(45); |
|
4080 |
var gOPS = __w_pdfjs_require__(49); |
|
4081 |
var pIE = __w_pdfjs_require__(50); |
|
4082 |
module.exports = function (it) { |
|
4083 |
var result = getKeys(it); |
|
4084 |
var getSymbols = gOPS.f; |
|
4085 |
if (getSymbols) { |
|
4086 |
var symbols = getSymbols(it); |
|
4087 |
var isEnum = pIE.f; |
|
4088 |
var i = 0; |
|
4089 |
var key; |
|
4090 |
while (symbols.length > i) { |
|
4091 |
if (isEnum.call(it, key = symbols[i++])) result.push(key); |
|
4092 |
} |
|
4093 |
} |
|
4094 |
return result; |
|
4095 |
}; |
|
4096 |
|
|
4097 |
/***/ }), |
|
4098 |
/* 120 */ |
|
4099 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
4100 |
|
|
4101 |
"use strict"; |
|
4102 |
|
|
4103 |
|
|
4104 |
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; }; |
|
4105 |
|
|
4106 |
var toIObject = __w_pdfjs_require__(36); |
|
4107 |
var gOPN = __w_pdfjs_require__(121).f; |
|
4108 |
var toString = {}.toString; |
|
4109 |
var windowNames = (typeof window === 'undefined' ? 'undefined' : _typeof(window)) == 'object' && window && Object.getOwnPropertyNames ? Object.getOwnPropertyNames(window) : []; |
|
4110 |
var getWindowNames = function getWindowNames(it) { |
|
4111 |
try { |
|
4112 |
return gOPN(it); |
|
4113 |
} catch (e) { |
|
4114 |
return windowNames.slice(); |
|
4115 |
} |
|
4116 |
}; |
|
4117 |
module.exports.f = function getOwnPropertyNames(it) { |
|
4118 |
return windowNames && toString.call(it) == '[object Window]' ? getWindowNames(it) : gOPN(toIObject(it)); |
|
4119 |
}; |
|
4120 |
|
|
4121 |
/***/ }), |
|
4122 |
/* 121 */ |
|
4123 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
4124 |
|
|
4125 |
"use strict"; |
|
4126 |
|
|
4127 |
|
|
4128 |
var $keys = __w_pdfjs_require__(46); |
|
4129 |
var hiddenKeys = __w_pdfjs_require__(48).concat('length', 'prototype'); |
|
4130 |
exports.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { |
|
4131 |
return $keys(O, hiddenKeys); |
|
4132 |
}; |
|
4133 |
|
|
4134 |
/***/ }), |
|
4135 |
/* 122 */ |
|
4136 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
4137 |
|
|
4138 |
"use strict"; |
|
4139 |
|
|
4140 |
|
|
4141 |
__w_pdfjs_require__(123); |
|
4142 |
module.exports = __w_pdfjs_require__(9).Object.values; |
|
4143 |
|
|
4144 |
/***/ }), |
|
4145 |
/* 123 */ |
|
4146 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
4147 |
|
|
4148 |
"use strict"; |
|
4149 |
|
|
4150 |
|
|
4151 |
var $export = __w_pdfjs_require__(7); |
|
4152 |
var $values = __w_pdfjs_require__(124)(false); |
|
4153 |
$export($export.S, 'Object', { |
|
4154 |
values: function values(it) { |
|
4155 |
return $values(it); |
|
4156 |
} |
|
4157 |
}); |
|
4158 |
|
|
4159 |
/***/ }), |
|
4160 |
/* 124 */ |
|
4161 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
4162 |
|
|
4163 |
"use strict"; |
|
4164 |
|
|
4165 |
|
|
4166 |
var getKeys = __w_pdfjs_require__(45); |
|
4167 |
var toIObject = __w_pdfjs_require__(36); |
|
4168 |
var isEnum = __w_pdfjs_require__(50).f; |
|
4169 |
module.exports = function (isEntries) { |
|
4170 |
return function (it) { |
|
4171 |
var O = toIObject(it); |
|
4172 |
var keys = getKeys(O); |
|
4173 |
var length = keys.length; |
|
4174 |
var i = 0; |
|
4175 |
var result = []; |
|
4176 |
var key; |
|
4177 |
while (length > i) { |
|
4178 |
if (isEnum.call(O, key = keys[i++])) { |
|
4179 |
result.push(isEntries ? [key, O[key]] : O[key]); |
|
4180 |
} |
|
4181 |
}return result; |
|
4182 |
}; |
|
4183 |
}; |
|
4184 |
|
|
4185 |
/***/ }), |
|
4186 |
/* 125 */ |
|
4187 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
4188 |
|
|
4189 |
"use strict"; |
|
4190 |
|
|
4191 |
|
|
4192 |
var isReadableStreamSupported = false; |
|
4193 |
if (typeof ReadableStream !== 'undefined') { |
|
4194 |
try { |
|
4195 |
new ReadableStream({ |
|
4196 |
start: function start(controller) { |
|
4197 |
controller.close(); |
|
4198 |
} |
|
4199 |
}); |
|
4200 |
isReadableStreamSupported = true; |
|
4201 |
} catch (e) {} |
|
4202 |
} |
|
4203 |
if (isReadableStreamSupported) { |
|
4204 |
exports.ReadableStream = ReadableStream; |
|
4205 |
} else { |
|
4206 |
exports.ReadableStream = __w_pdfjs_require__(126).ReadableStream; |
|
4207 |
} |
|
4208 |
|
|
4209 |
/***/ }), |
|
4210 |
/* 126 */ |
|
4211 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
4212 |
|
|
4213 |
"use strict"; |
|
4214 |
|
|
4215 |
|
|
4216 |
var _typeof2 = 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; }; |
|
4217 |
|
|
4218 |
(function (e, a) { |
|
4219 |
for (var i in a) { |
|
4220 |
e[i] = a[i]; |
|
4221 |
} |
|
4222 |
})(exports, function (modules) { |
|
4223 |
var installedModules = {}; |
|
4224 |
function __w_pdfjs_require__(moduleId) { |
|
4225 |
if (installedModules[moduleId]) return installedModules[moduleId].exports; |
|
4226 |
var module = installedModules[moduleId] = { |
|
4227 |
i: moduleId, |
|
4228 |
l: false, |
|
4229 |
exports: {} |
|
4230 |
}; |
|
4231 |
modules[moduleId].call(module.exports, module, module.exports, __w_pdfjs_require__); |
|
4232 |
module.l = true; |
|
4233 |
return module.exports; |
|
4234 |
} |
|
4235 |
__w_pdfjs_require__.m = modules; |
|
4236 |
__w_pdfjs_require__.c = installedModules; |
|
4237 |
__w_pdfjs_require__.i = function (value) { |
|
4238 |
return value; |
|
4239 |
}; |
|
4240 |
__w_pdfjs_require__.d = function (exports, name, getter) { |
|
4241 |
if (!__w_pdfjs_require__.o(exports, name)) { |
|
4242 |
Object.defineProperty(exports, name, { |
|
4243 |
configurable: false, |
|
4244 |
enumerable: true, |
|
4245 |
get: getter |
|
4246 |
}); |
|
4247 |
} |
|
4248 |
}; |
|
4249 |
__w_pdfjs_require__.n = function (module) { |
|
4250 |
var getter = module && module.__esModule ? function getDefault() { |
|
4251 |
return module['default']; |
|
4252 |
} : function getModuleExports() { |
|
4253 |
return module; |
|
4254 |
}; |
|
4255 |
__w_pdfjs_require__.d(getter, 'a', getter); |
|
4256 |
return getter; |
|
4257 |
}; |
|
4258 |
__w_pdfjs_require__.o = function (object, property) { |
|
4259 |
return Object.prototype.hasOwnProperty.call(object, property); |
|
4260 |
}; |
|
4261 |
__w_pdfjs_require__.p = ""; |
|
4262 |
return __w_pdfjs_require__(__w_pdfjs_require__.s = 7); |
|
4263 |
}([function (module, exports, __w_pdfjs_require__) { |
|
4264 |
"use strict"; |
|
4265 |
|
|
4266 |
var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) { |
|
4267 |
return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); |
|
4268 |
} : function (obj) { |
|
4269 |
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj); |
|
4270 |
}; |
|
4271 |
var _require = __w_pdfjs_require__(1), |
|
4272 |
assert = _require.assert; |
|
4273 |
function IsPropertyKey(argument) { |
|
4274 |
return typeof argument === 'string' || (typeof argument === 'undefined' ? 'undefined' : _typeof(argument)) === 'symbol'; |
|
4275 |
} |
|
4276 |
exports.typeIsObject = function (x) { |
|
4277 |
return (typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && x !== null || typeof x === 'function'; |
|
4278 |
}; |
|
4279 |
exports.createDataProperty = function (o, p, v) { |
|
4280 |
assert(exports.typeIsObject(o)); |
|
4281 |
Object.defineProperty(o, p, { |
|
4282 |
value: v, |
|
4283 |
writable: true, |
|
4284 |
enumerable: true, |
|
4285 |
configurable: true |
|
4286 |
}); |
|
4287 |
}; |
|
4288 |
exports.createArrayFromList = function (elements) { |
|
4289 |
return elements.slice(); |
|
4290 |
}; |
|
4291 |
exports.ArrayBufferCopy = function (dest, destOffset, src, srcOffset, n) { |
|
4292 |
new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset); |
|
4293 |
}; |
|
4294 |
exports.CreateIterResultObject = function (value, done) { |
|
4295 |
assert(typeof done === 'boolean'); |
|
4296 |
var obj = {}; |
|
4297 |
Object.defineProperty(obj, 'value', { |
|
4298 |
value: value, |
|
4299 |
enumerable: true, |
|
4300 |
writable: true, |
|
4301 |
configurable: true |
|
4302 |
}); |
|
4303 |
Object.defineProperty(obj, 'done', { |
|
4304 |
value: done, |
|
4305 |
enumerable: true, |
|
4306 |
writable: true, |
|
4307 |
configurable: true |
|
4308 |
}); |
|
4309 |
return obj; |
|
4310 |
}; |
|
4311 |
exports.IsFiniteNonNegativeNumber = function (v) { |
|
4312 |
if (Number.isNaN(v)) { |
|
4313 |
return false; |
|
4314 |
} |
|
4315 |
if (v === Infinity) { |
|
4316 |
return false; |
|
4317 |
} |
|
4318 |
if (v < 0) { |
|
4319 |
return false; |
|
4320 |
} |
|
4321 |
return true; |
|
4322 |
}; |
|
4323 |
function Call(F, V, args) { |
|
4324 |
if (typeof F !== 'function') { |
|
4325 |
throw new TypeError('Argument is not a function'); |
|
4326 |
} |
|
4327 |
return Function.prototype.apply.call(F, V, args); |
|
4328 |
} |
|
4329 |
exports.InvokeOrNoop = function (O, P, args) { |
|
4330 |
assert(O !== undefined); |
|
4331 |
assert(IsPropertyKey(P)); |
|
4332 |
assert(Array.isArray(args)); |
|
4333 |
var method = O[P]; |
|
4334 |
if (method === undefined) { |
|
4335 |
return undefined; |
|
4336 |
} |
|
4337 |
return Call(method, O, args); |
|
4338 |
}; |
|
4339 |
exports.PromiseInvokeOrNoop = function (O, P, args) { |
|
4340 |
assert(O !== undefined); |
|
4341 |
assert(IsPropertyKey(P)); |
|
4342 |
assert(Array.isArray(args)); |
|
4343 |
try { |
|
4344 |
return Promise.resolve(exports.InvokeOrNoop(O, P, args)); |
|
4345 |
} catch (returnValueE) { |
|
4346 |
return Promise.reject(returnValueE); |
|
4347 |
} |
|
4348 |
}; |
|
4349 |
exports.PromiseInvokeOrPerformFallback = function (O, P, args, F, argsF) { |
|
4350 |
assert(O !== undefined); |
|
4351 |
assert(IsPropertyKey(P)); |
|
4352 |
assert(Array.isArray(args)); |
|
4353 |
assert(Array.isArray(argsF)); |
|
4354 |
var method = void 0; |
|
4355 |
try { |
|
4356 |
method = O[P]; |
|
4357 |
} catch (methodE) { |
|
4358 |
return Promise.reject(methodE); |
|
4359 |
} |
|
4360 |
if (method === undefined) { |
|
4361 |
return F.apply(null, argsF); |
|
4362 |
} |
|
4363 |
try { |
|
4364 |
return Promise.resolve(Call(method, O, args)); |
|
4365 |
} catch (e) { |
|
4366 |
return Promise.reject(e); |
|
4367 |
} |
|
4368 |
}; |
|
4369 |
exports.TransferArrayBuffer = function (O) { |
|
4370 |
return O.slice(); |
|
4371 |
}; |
|
4372 |
exports.ValidateAndNormalizeHighWaterMark = function (highWaterMark) { |
|
4373 |
highWaterMark = Number(highWaterMark); |
|
4374 |
if (Number.isNaN(highWaterMark) || highWaterMark < 0) { |
|
4375 |
throw new RangeError('highWaterMark property of a queuing strategy must be non-negative and non-NaN'); |
|
4376 |
} |
|
4377 |
return highWaterMark; |
|
4378 |
}; |
|
4379 |
exports.ValidateAndNormalizeQueuingStrategy = function (size, highWaterMark) { |
|
4380 |
if (size !== undefined && typeof size !== 'function') { |
|
4381 |
throw new TypeError('size property of a queuing strategy must be a function'); |
|
4382 |
} |
|
4383 |
highWaterMark = exports.ValidateAndNormalizeHighWaterMark(highWaterMark); |
|
4384 |
return { |
|
4385 |
size: size, |
|
4386 |
highWaterMark: highWaterMark |
|
4387 |
}; |
|
4388 |
}; |
|
4389 |
}, function (module, exports, __w_pdfjs_require__) { |
|
4390 |
"use strict"; |
|
4391 |
|
|
4392 |
function rethrowAssertionErrorRejection(e) { |
|
4393 |
if (e && e.constructor === AssertionError) { |
|
4394 |
setTimeout(function () { |
|
4395 |
throw e; |
|
4396 |
}, 0); |
|
4397 |
} |
|
4398 |
} |
|
4399 |
function AssertionError(message) { |
|
4400 |
this.name = 'AssertionError'; |
|
4401 |
this.message = message || ''; |
|
4402 |
this.stack = new Error().stack; |
|
4403 |
} |
|
4404 |
AssertionError.prototype = Object.create(Error.prototype); |
|
4405 |
AssertionError.prototype.constructor = AssertionError; |
|
4406 |
function assert(value, message) { |
|
4407 |
if (!value) { |
|
4408 |
throw new AssertionError(message); |
|
4409 |
} |
|
4410 |
} |
|
4411 |
module.exports = { |
|
4412 |
rethrowAssertionErrorRejection: rethrowAssertionErrorRejection, |
|
4413 |
AssertionError: AssertionError, |
|
4414 |
assert: assert |
|
4415 |
}; |
|
4416 |
}, function (module, exports, __w_pdfjs_require__) { |
|
4417 |
"use strict"; |
|
4418 |
|
|
4419 |
var _createClass = function () { |
|
4420 |
function defineProperties(target, props) { |
|
4421 |
for (var i = 0; i < props.length; i++) { |
|
4422 |
var descriptor = props[i]; |
|
4423 |
descriptor.enumerable = descriptor.enumerable || false; |
|
4424 |
descriptor.configurable = true; |
|
4425 |
if ("value" in descriptor) descriptor.writable = true; |
|
4426 |
Object.defineProperty(target, descriptor.key, descriptor); |
|
4427 |
} |
|
4428 |
} |
|
4429 |
return function (Constructor, protoProps, staticProps) { |
|
4430 |
if (protoProps) defineProperties(Constructor.prototype, protoProps); |
|
4431 |
if (staticProps) defineProperties(Constructor, staticProps); |
|
4432 |
return Constructor; |
|
4433 |
}; |
|
4434 |
}(); |
|
4435 |
function _classCallCheck(instance, Constructor) { |
|
4436 |
if (!(instance instanceof Constructor)) { |
|
4437 |
throw new TypeError("Cannot call a class as a function"); |
|
4438 |
} |
|
4439 |
} |
|
4440 |
var _require = __w_pdfjs_require__(0), |
|
4441 |
InvokeOrNoop = _require.InvokeOrNoop, |
|
4442 |
PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop, |
|
4443 |
ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy, |
|
4444 |
typeIsObject = _require.typeIsObject; |
|
4445 |
var _require2 = __w_pdfjs_require__(1), |
|
4446 |
assert = _require2.assert, |
|
4447 |
rethrowAssertionErrorRejection = _require2.rethrowAssertionErrorRejection; |
|
4448 |
var _require3 = __w_pdfjs_require__(3), |
|
4449 |
DequeueValue = _require3.DequeueValue, |
|
4450 |
EnqueueValueWithSize = _require3.EnqueueValueWithSize, |
|
4451 |
PeekQueueValue = _require3.PeekQueueValue, |
|
4452 |
ResetQueue = _require3.ResetQueue; |
|
4453 |
var WritableStream = function () { |
|
4454 |
function WritableStream() { |
|
4455 |
var underlyingSink = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
4456 |
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, |
|
4457 |
size = _ref.size, |
|
4458 |
_ref$highWaterMark = _ref.highWaterMark, |
|
4459 |
highWaterMark = _ref$highWaterMark === undefined ? 1 : _ref$highWaterMark; |
|
4460 |
_classCallCheck(this, WritableStream); |
|
4461 |
this._state = 'writable'; |
|
4462 |
this._storedError = undefined; |
|
4463 |
this._writer = undefined; |
|
4464 |
this._writableStreamController = undefined; |
|
4465 |
this._writeRequests = []; |
|
4466 |
this._inFlightWriteRequest = undefined; |
|
4467 |
this._closeRequest = undefined; |
|
4468 |
this._inFlightCloseRequest = undefined; |
|
4469 |
this._pendingAbortRequest = undefined; |
|
4470 |
this._backpressure = false; |
|
4471 |
var type = underlyingSink.type; |
|
4472 |
if (type !== undefined) { |
|
4473 |
throw new RangeError('Invalid type is specified'); |
|
4474 |
} |
|
4475 |
this._writableStreamController = new WritableStreamDefaultController(this, underlyingSink, size, highWaterMark); |
|
4476 |
this._writableStreamController.__startSteps(); |
|
4477 |
} |
|
4478 |
_createClass(WritableStream, [{ |
|
4479 |
key: 'abort', |
|
4480 |
value: function abort(reason) { |
|
4481 |
if (IsWritableStream(this) === false) { |
|
4482 |
return Promise.reject(streamBrandCheckException('abort')); |
|
4483 |
} |
|
4484 |
if (IsWritableStreamLocked(this) === true) { |
|
4485 |
return Promise.reject(new TypeError('Cannot abort a stream that already has a writer')); |
|
4486 |
} |
|
4487 |
return WritableStreamAbort(this, reason); |
|
4488 |
} |
|
4489 |
}, { |
|
4490 |
key: 'getWriter', |
|
4491 |
value: function getWriter() { |
|
4492 |
if (IsWritableStream(this) === false) { |
|
4493 |
throw streamBrandCheckException('getWriter'); |
|
4494 |
} |
|
4495 |
return AcquireWritableStreamDefaultWriter(this); |
|
4496 |
} |
|
4497 |
}, { |
|
4498 |
key: 'locked', |
|
4499 |
get: function get() { |
|
4500 |
if (IsWritableStream(this) === false) { |
|
4501 |
throw streamBrandCheckException('locked'); |
|
4502 |
} |
|
4503 |
return IsWritableStreamLocked(this); |
|
4504 |
} |
|
4505 |
}]); |
|
4506 |
return WritableStream; |
|
4507 |
}(); |
|
4508 |
module.exports = { |
|
4509 |
AcquireWritableStreamDefaultWriter: AcquireWritableStreamDefaultWriter, |
|
4510 |
IsWritableStream: IsWritableStream, |
|
4511 |
IsWritableStreamLocked: IsWritableStreamLocked, |
|
4512 |
WritableStream: WritableStream, |
|
4513 |
WritableStreamAbort: WritableStreamAbort, |
|
4514 |
WritableStreamDefaultControllerError: WritableStreamDefaultControllerError, |
|
4515 |
WritableStreamDefaultWriterCloseWithErrorPropagation: WritableStreamDefaultWriterCloseWithErrorPropagation, |
|
4516 |
WritableStreamDefaultWriterRelease: WritableStreamDefaultWriterRelease, |
|
4517 |
WritableStreamDefaultWriterWrite: WritableStreamDefaultWriterWrite, |
|
4518 |
WritableStreamCloseQueuedOrInFlight: WritableStreamCloseQueuedOrInFlight |
|
4519 |
}; |
|
4520 |
function AcquireWritableStreamDefaultWriter(stream) { |
|
4521 |
return new WritableStreamDefaultWriter(stream); |
|
4522 |
} |
|
4523 |
function IsWritableStream(x) { |
|
4524 |
if (!typeIsObject(x)) { |
|
4525 |
return false; |
|
4526 |
} |
|
4527 |
if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) { |
|
4528 |
return false; |
|
4529 |
} |
|
4530 |
return true; |
|
4531 |
} |
|
4532 |
function IsWritableStreamLocked(stream) { |
|
4533 |
assert(IsWritableStream(stream) === true, 'IsWritableStreamLocked should only be used on known writable streams'); |
|
4534 |
if (stream._writer === undefined) { |
|
4535 |
return false; |
|
4536 |
} |
|
4537 |
return true; |
|
4538 |
} |
|
4539 |
function WritableStreamAbort(stream, reason) { |
|
4540 |
var state = stream._state; |
|
4541 |
if (state === 'closed') { |
|
4542 |
return Promise.resolve(undefined); |
|
4543 |
} |
|
4544 |
if (state === 'errored') { |
|
4545 |
return Promise.reject(stream._storedError); |
|
4546 |
} |
|
4547 |
var error = new TypeError('Requested to abort'); |
|
4548 |
if (stream._pendingAbortRequest !== undefined) { |
|
4549 |
return Promise.reject(error); |
|
4550 |
} |
|
4551 |
assert(state === 'writable' || state === 'erroring', 'state must be writable or erroring'); |
|
4552 |
var wasAlreadyErroring = false; |
|
4553 |
if (state === 'erroring') { |
|
4554 |
wasAlreadyErroring = true; |
|
4555 |
reason = undefined; |
|
4556 |
} |
|
4557 |
var promise = new Promise(function (resolve, reject) { |
|
4558 |
stream._pendingAbortRequest = { |
|
4559 |
_resolve: resolve, |
|
4560 |
_reject: reject, |
|
4561 |
_reason: reason, |
|
4562 |
_wasAlreadyErroring: wasAlreadyErroring |
|
4563 |
}; |
|
4564 |
}); |
|
4565 |
if (wasAlreadyErroring === false) { |
|
4566 |
WritableStreamStartErroring(stream, error); |
|
4567 |
} |
|
4568 |
return promise; |
|
4569 |
} |
|
4570 |
function WritableStreamAddWriteRequest(stream) { |
|
4571 |
assert(IsWritableStreamLocked(stream) === true); |
|
4572 |
assert(stream._state === 'writable'); |
|
4573 |
var promise = new Promise(function (resolve, reject) { |
|
4574 |
var writeRequest = { |
|
4575 |
_resolve: resolve, |
|
4576 |
_reject: reject |
|
4577 |
}; |
|
4578 |
stream._writeRequests.push(writeRequest); |
|
4579 |
}); |
|
4580 |
return promise; |
|
4581 |
} |
|
4582 |
function WritableStreamDealWithRejection(stream, error) { |
|
4583 |
var state = stream._state; |
|
4584 |
if (state === 'writable') { |
|
4585 |
WritableStreamStartErroring(stream, error); |
|
4586 |
return; |
|
4587 |
} |
|
4588 |
assert(state === 'erroring'); |
|
4589 |
WritableStreamFinishErroring(stream); |
|
4590 |
} |
|
4591 |
function WritableStreamStartErroring(stream, reason) { |
|
4592 |
assert(stream._storedError === undefined, 'stream._storedError === undefined'); |
|
4593 |
assert(stream._state === 'writable', 'state must be writable'); |
|
4594 |
var controller = stream._writableStreamController; |
|
4595 |
assert(controller !== undefined, 'controller must not be undefined'); |
|
4596 |
stream._state = 'erroring'; |
|
4597 |
stream._storedError = reason; |
|
4598 |
var writer = stream._writer; |
|
4599 |
if (writer !== undefined) { |
|
4600 |
WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason); |
|
4601 |
} |
|
4602 |
if (WritableStreamHasOperationMarkedInFlight(stream) === false && controller._started === true) { |
|
4603 |
WritableStreamFinishErroring(stream); |
|
4604 |
} |
|
4605 |
} |
|
4606 |
function WritableStreamFinishErroring(stream) { |
|
4607 |
assert(stream._state === 'erroring', 'stream._state === erroring'); |
|
4608 |
assert(WritableStreamHasOperationMarkedInFlight(stream) === false, 'WritableStreamHasOperationMarkedInFlight(stream) === false'); |
|
4609 |
stream._state = 'errored'; |
|
4610 |
stream._writableStreamController.__errorSteps(); |
|
4611 |
var storedError = stream._storedError; |
|
4612 |
for (var i = 0; i < stream._writeRequests.length; i++) { |
|
4613 |
var writeRequest = stream._writeRequests[i]; |
|
4614 |
writeRequest._reject(storedError); |
|
4615 |
} |
|
4616 |
stream._writeRequests = []; |
|
4617 |
if (stream._pendingAbortRequest === undefined) { |
|
4618 |
WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); |
|
4619 |
return; |
|
4620 |
} |
|
4621 |
var abortRequest = stream._pendingAbortRequest; |
|
4622 |
stream._pendingAbortRequest = undefined; |
|
4623 |
if (abortRequest._wasAlreadyErroring === true) { |
|
4624 |
abortRequest._reject(storedError); |
|
4625 |
WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); |
|
4626 |
return; |
|
4627 |
} |
|
4628 |
var promise = stream._writableStreamController.__abortSteps(abortRequest._reason); |
|
4629 |
promise.then(function () { |
|
4630 |
abortRequest._resolve(); |
|
4631 |
WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); |
|
4632 |
}, function (reason) { |
|
4633 |
abortRequest._reject(reason); |
|
4634 |
WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); |
|
4635 |
}); |
|
4636 |
} |
|
4637 |
function WritableStreamFinishInFlightWrite(stream) { |
|
4638 |
assert(stream._inFlightWriteRequest !== undefined); |
|
4639 |
stream._inFlightWriteRequest._resolve(undefined); |
|
4640 |
stream._inFlightWriteRequest = undefined; |
|
4641 |
} |
|
4642 |
function WritableStreamFinishInFlightWriteWithError(stream, error) { |
|
4643 |
assert(stream._inFlightWriteRequest !== undefined); |
|
4644 |
stream._inFlightWriteRequest._reject(error); |
|
4645 |
stream._inFlightWriteRequest = undefined; |
|
4646 |
assert(stream._state === 'writable' || stream._state === 'erroring'); |
|
4647 |
WritableStreamDealWithRejection(stream, error); |
|
4648 |
} |
|
4649 |
function WritableStreamFinishInFlightClose(stream) { |
|
4650 |
assert(stream._inFlightCloseRequest !== undefined); |
|
4651 |
stream._inFlightCloseRequest._resolve(undefined); |
|
4652 |
stream._inFlightCloseRequest = undefined; |
|
4653 |
var state = stream._state; |
|
4654 |
assert(state === 'writable' || state === 'erroring'); |
|
4655 |
if (state === 'erroring') { |
|
4656 |
stream._storedError = undefined; |
|
4657 |
if (stream._pendingAbortRequest !== undefined) { |
|
4658 |
stream._pendingAbortRequest._resolve(); |
|
4659 |
stream._pendingAbortRequest = undefined; |
|
4660 |
} |
|
4661 |
} |
|
4662 |
stream._state = 'closed'; |
|
4663 |
var writer = stream._writer; |
|
4664 |
if (writer !== undefined) { |
|
4665 |
defaultWriterClosedPromiseResolve(writer); |
|
4666 |
} |
|
4667 |
assert(stream._pendingAbortRequest === undefined, 'stream._pendingAbortRequest === undefined'); |
|
4668 |
assert(stream._storedError === undefined, 'stream._storedError === undefined'); |
|
4669 |
} |
|
4670 |
function WritableStreamFinishInFlightCloseWithError(stream, error) { |
|
4671 |
assert(stream._inFlightCloseRequest !== undefined); |
|
4672 |
stream._inFlightCloseRequest._reject(error); |
|
4673 |
stream._inFlightCloseRequest = undefined; |
|
4674 |
assert(stream._state === 'writable' || stream._state === 'erroring'); |
|
4675 |
if (stream._pendingAbortRequest !== undefined) { |
|
4676 |
stream._pendingAbortRequest._reject(error); |
|
4677 |
stream._pendingAbortRequest = undefined; |
|
4678 |
} |
|
4679 |
WritableStreamDealWithRejection(stream, error); |
|
4680 |
} |
|
4681 |
function WritableStreamCloseQueuedOrInFlight(stream) { |
|
4682 |
if (stream._closeRequest === undefined && stream._inFlightCloseRequest === undefined) { |
|
4683 |
return false; |
|
4684 |
} |
|
4685 |
return true; |
|
4686 |
} |
|
4687 |
function WritableStreamHasOperationMarkedInFlight(stream) { |
|
4688 |
if (stream._inFlightWriteRequest === undefined && stream._inFlightCloseRequest === undefined) { |
|
4689 |
return false; |
|
4690 |
} |
|
4691 |
return true; |
|
4692 |
} |
|
4693 |
function WritableStreamMarkCloseRequestInFlight(stream) { |
|
4694 |
assert(stream._inFlightCloseRequest === undefined); |
|
4695 |
assert(stream._closeRequest !== undefined); |
|
4696 |
stream._inFlightCloseRequest = stream._closeRequest; |
|
4697 |
stream._closeRequest = undefined; |
|
4698 |
} |
|
4699 |
function WritableStreamMarkFirstWriteRequestInFlight(stream) { |
|
4700 |
assert(stream._inFlightWriteRequest === undefined, 'there must be no pending write request'); |
|
4701 |
assert(stream._writeRequests.length !== 0, 'writeRequests must not be empty'); |
|
4702 |
stream._inFlightWriteRequest = stream._writeRequests.shift(); |
|
4703 |
} |
|
4704 |
function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream) { |
|
4705 |
assert(stream._state === 'errored', '_stream_.[[state]] is `"errored"`'); |
|
4706 |
if (stream._closeRequest !== undefined) { |
|
4707 |
assert(stream._inFlightCloseRequest === undefined); |
|
4708 |
stream._closeRequest._reject(stream._storedError); |
|
4709 |
stream._closeRequest = undefined; |
|
4710 |
} |
|
4711 |
var writer = stream._writer; |
|
4712 |
if (writer !== undefined) { |
|
4713 |
defaultWriterClosedPromiseReject(writer, stream._storedError); |
|
4714 |
writer._closedPromise.catch(function () {}); |
|
4715 |
} |
|
4716 |
} |
|
4717 |
function WritableStreamUpdateBackpressure(stream, backpressure) { |
|
4718 |
assert(stream._state === 'writable'); |
|
4719 |
assert(WritableStreamCloseQueuedOrInFlight(stream) === false); |
|
4720 |
var writer = stream._writer; |
|
4721 |
if (writer !== undefined && backpressure !== stream._backpressure) { |
|
4722 |
if (backpressure === true) { |
|
4723 |
defaultWriterReadyPromiseReset(writer); |
|
4724 |
} else { |
|
4725 |
assert(backpressure === false); |
|
4726 |
defaultWriterReadyPromiseResolve(writer); |
|
4727 |
} |
|
4728 |
} |
|
4729 |
stream._backpressure = backpressure; |
|
4730 |
} |
|
4731 |
var WritableStreamDefaultWriter = function () { |
|
4732 |
function WritableStreamDefaultWriter(stream) { |
|
4733 |
_classCallCheck(this, WritableStreamDefaultWriter); |
|
4734 |
if (IsWritableStream(stream) === false) { |
|
4735 |
throw new TypeError('WritableStreamDefaultWriter can only be constructed with a WritableStream instance'); |
|
4736 |
} |
|
4737 |
if (IsWritableStreamLocked(stream) === true) { |
|
4738 |
throw new TypeError('This stream has already been locked for exclusive writing by another writer'); |
|
4739 |
} |
|
4740 |
this._ownerWritableStream = stream; |
|
4741 |
stream._writer = this; |
|
4742 |
var state = stream._state; |
|
4743 |
if (state === 'writable') { |
|
4744 |
if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._backpressure === true) { |
|
4745 |
defaultWriterReadyPromiseInitialize(this); |
|
4746 |
} else { |
|
4747 |
defaultWriterReadyPromiseInitializeAsResolved(this); |
|
4748 |
} |
|
4749 |
defaultWriterClosedPromiseInitialize(this); |
|
4750 |
} else if (state === 'erroring') { |
|
4751 |
defaultWriterReadyPromiseInitializeAsRejected(this, stream._storedError); |
|
4752 |
this._readyPromise.catch(function () {}); |
|
4753 |
defaultWriterClosedPromiseInitialize(this); |
|
4754 |
} else if (state === 'closed') { |
|
4755 |
defaultWriterReadyPromiseInitializeAsResolved(this); |
|
4756 |
defaultWriterClosedPromiseInitializeAsResolved(this); |
|
4757 |
} else { |
|
4758 |
assert(state === 'errored', 'state must be errored'); |
|
4759 |
var storedError = stream._storedError; |
|
4760 |
defaultWriterReadyPromiseInitializeAsRejected(this, storedError); |
|
4761 |
this._readyPromise.catch(function () {}); |
|
4762 |
defaultWriterClosedPromiseInitializeAsRejected(this, storedError); |
|
4763 |
this._closedPromise.catch(function () {}); |
|
4764 |
} |
|
4765 |
} |
|
4766 |
_createClass(WritableStreamDefaultWriter, [{ |
|
4767 |
key: 'abort', |
|
4768 |
value: function abort(reason) { |
|
4769 |
if (IsWritableStreamDefaultWriter(this) === false) { |
|
4770 |
return Promise.reject(defaultWriterBrandCheckException('abort')); |
|
4771 |
} |
|
4772 |
if (this._ownerWritableStream === undefined) { |
|
4773 |
return Promise.reject(defaultWriterLockException('abort')); |
|
4774 |
} |
|
4775 |
return WritableStreamDefaultWriterAbort(this, reason); |
|
4776 |
} |
|
4777 |
}, { |
|
4778 |
key: 'close', |
|
4779 |
value: function close() { |
|
4780 |
if (IsWritableStreamDefaultWriter(this) === false) { |
|
4781 |
return Promise.reject(defaultWriterBrandCheckException('close')); |
|
4782 |
} |
|
4783 |
var stream = this._ownerWritableStream; |
|
4784 |
if (stream === undefined) { |
|
4785 |
return Promise.reject(defaultWriterLockException('close')); |
|
4786 |
} |
|
4787 |
if (WritableStreamCloseQueuedOrInFlight(stream) === true) { |
|
4788 |
return Promise.reject(new TypeError('cannot close an already-closing stream')); |
|
4789 |
} |
|
4790 |
return WritableStreamDefaultWriterClose(this); |
|
4791 |
} |
|
4792 |
}, { |
|
4793 |
key: 'releaseLock', |
|
4794 |
value: function releaseLock() { |
|
4795 |
if (IsWritableStreamDefaultWriter(this) === false) { |
|
4796 |
throw defaultWriterBrandCheckException('releaseLock'); |
|
4797 |
} |
|
4798 |
var stream = this._ownerWritableStream; |
|
4799 |
if (stream === undefined) { |
|
4800 |
return; |
|
4801 |
} |
|
4802 |
assert(stream._writer !== undefined); |
|
4803 |
WritableStreamDefaultWriterRelease(this); |
|
4804 |
} |
|
4805 |
}, { |
|
4806 |
key: 'write', |
|
4807 |
value: function write(chunk) { |
|
4808 |
if (IsWritableStreamDefaultWriter(this) === false) { |
|
4809 |
return Promise.reject(defaultWriterBrandCheckException('write')); |
|
4810 |
} |
|
4811 |
if (this._ownerWritableStream === undefined) { |
|
4812 |
return Promise.reject(defaultWriterLockException('write to')); |
|
4813 |
} |
|
4814 |
return WritableStreamDefaultWriterWrite(this, chunk); |
|
4815 |
} |
|
4816 |
}, { |
|
4817 |
key: 'closed', |
|
4818 |
get: function get() { |
|
4819 |
if (IsWritableStreamDefaultWriter(this) === false) { |
|
4820 |
return Promise.reject(defaultWriterBrandCheckException('closed')); |
|
4821 |
} |
|
4822 |
return this._closedPromise; |
|
4823 |
} |
|
4824 |
}, { |
|
4825 |
key: 'desiredSize', |
|
4826 |
get: function get() { |
|
4827 |
if (IsWritableStreamDefaultWriter(this) === false) { |
|
4828 |
throw defaultWriterBrandCheckException('desiredSize'); |
|
4829 |
} |
|
4830 |
if (this._ownerWritableStream === undefined) { |
|
4831 |
throw defaultWriterLockException('desiredSize'); |
|
4832 |
} |
|
4833 |
return WritableStreamDefaultWriterGetDesiredSize(this); |
|
4834 |
} |
|
4835 |
}, { |
|
4836 |
key: 'ready', |
|
4837 |
get: function get() { |
|
4838 |
if (IsWritableStreamDefaultWriter(this) === false) { |
|
4839 |
return Promise.reject(defaultWriterBrandCheckException('ready')); |
|
4840 |
} |
|
4841 |
return this._readyPromise; |
|
4842 |
} |
|
4843 |
}]); |
|
4844 |
return WritableStreamDefaultWriter; |
|
4845 |
}(); |
|
4846 |
function IsWritableStreamDefaultWriter(x) { |
|
4847 |
if (!typeIsObject(x)) { |
|
4848 |
return false; |
|
4849 |
} |
|
4850 |
if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) { |
|
4851 |
return false; |
|
4852 |
} |
|
4853 |
return true; |
|
4854 |
} |
|
4855 |
function WritableStreamDefaultWriterAbort(writer, reason) { |
|
4856 |
var stream = writer._ownerWritableStream; |
|
4857 |
assert(stream !== undefined); |
|
4858 |
return WritableStreamAbort(stream, reason); |
|
4859 |
} |
|
4860 |
function WritableStreamDefaultWriterClose(writer) { |
|
4861 |
var stream = writer._ownerWritableStream; |
|
4862 |
assert(stream !== undefined); |
|
4863 |
var state = stream._state; |
|
4864 |
if (state === 'closed' || state === 'errored') { |
|
4865 |
return Promise.reject(new TypeError('The stream (in ' + state + ' state) is not in the writable state and cannot be closed')); |
|
4866 |
} |
|
4867 |
assert(state === 'writable' || state === 'erroring'); |
|
4868 |
assert(WritableStreamCloseQueuedOrInFlight(stream) === false); |
|
4869 |
var promise = new Promise(function (resolve, reject) { |
|
4870 |
var closeRequest = { |
|
4871 |
_resolve: resolve, |
|
4872 |
_reject: reject |
|
4873 |
}; |
|
4874 |
stream._closeRequest = closeRequest; |
|
4875 |
}); |
|
4876 |
if (stream._backpressure === true && state === 'writable') { |
|
4877 |
defaultWriterReadyPromiseResolve(writer); |
|
4878 |
} |
|
4879 |
WritableStreamDefaultControllerClose(stream._writableStreamController); |
|
4880 |
return promise; |
|
4881 |
} |
|
4882 |
function WritableStreamDefaultWriterCloseWithErrorPropagation(writer) { |
|
4883 |
var stream = writer._ownerWritableStream; |
|
4884 |
assert(stream !== undefined); |
|
4885 |
var state = stream._state; |
|
4886 |
if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') { |
|
4887 |
return Promise.resolve(); |
|
4888 |
} |
|
4889 |
if (state === 'errored') { |
|
4890 |
return Promise.reject(stream._storedError); |
|
4891 |
} |
|
4892 |
assert(state === 'writable' || state === 'erroring'); |
|
4893 |
return WritableStreamDefaultWriterClose(writer); |
|
4894 |
} |
|
4895 |
function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error) { |
|
4896 |
if (writer._closedPromiseState === 'pending') { |
|
4897 |
defaultWriterClosedPromiseReject(writer, error); |
|
4898 |
} else { |
|
4899 |
defaultWriterClosedPromiseResetToRejected(writer, error); |
|
4900 |
} |
|
4901 |
writer._closedPromise.catch(function () {}); |
|
4902 |
} |
|
4903 |
function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error) { |
|
4904 |
if (writer._readyPromiseState === 'pending') { |
|
4905 |
defaultWriterReadyPromiseReject(writer, error); |
|
4906 |
} else { |
|
4907 |
defaultWriterReadyPromiseResetToRejected(writer, error); |
|
4908 |
} |
|
4909 |
writer._readyPromise.catch(function () {}); |
|
4910 |
} |
|
4911 |
function WritableStreamDefaultWriterGetDesiredSize(writer) { |
|
4912 |
var stream = writer._ownerWritableStream; |
|
4913 |
var state = stream._state; |
|
4914 |
if (state === 'errored' || state === 'erroring') { |
|
4915 |
return null; |
|
4916 |
} |
|
4917 |
if (state === 'closed') { |
|
4918 |
return 0; |
|
4919 |
} |
|
4920 |
return WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController); |
|
4921 |
} |
|
4922 |
function WritableStreamDefaultWriterRelease(writer) { |
|
4923 |
var stream = writer._ownerWritableStream; |
|
4924 |
assert(stream !== undefined); |
|
4925 |
assert(stream._writer === writer); |
|
4926 |
var releasedError = new TypeError('Writer was released and can no longer be used to monitor the stream\'s closedness'); |
|
4927 |
WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError); |
|
4928 |
WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError); |
|
4929 |
stream._writer = undefined; |
|
4930 |
writer._ownerWritableStream = undefined; |
|
4931 |
} |
|
4932 |
function WritableStreamDefaultWriterWrite(writer, chunk) { |
|
4933 |
var stream = writer._ownerWritableStream; |
|
4934 |
assert(stream !== undefined); |
|
4935 |
var controller = stream._writableStreamController; |
|
4936 |
var chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk); |
|
4937 |
if (stream !== writer._ownerWritableStream) { |
|
4938 |
return Promise.reject(defaultWriterLockException('write to')); |
|
4939 |
} |
|
4940 |
var state = stream._state; |
|
4941 |
if (state === 'errored') { |
|
4942 |
return Promise.reject(stream._storedError); |
|
4943 |
} |
|
4944 |
if (WritableStreamCloseQueuedOrInFlight(stream) === true || state === 'closed') { |
|
4945 |
return Promise.reject(new TypeError('The stream is closing or closed and cannot be written to')); |
|
4946 |
} |
|
4947 |
if (state === 'erroring') { |
|
4948 |
return Promise.reject(stream._storedError); |
|
4949 |
} |
|
4950 |
assert(state === 'writable'); |
|
4951 |
var promise = WritableStreamAddWriteRequest(stream); |
|
4952 |
WritableStreamDefaultControllerWrite(controller, chunk, chunkSize); |
|
4953 |
return promise; |
|
4954 |
} |
|
4955 |
var WritableStreamDefaultController = function () { |
|
4956 |
function WritableStreamDefaultController(stream, underlyingSink, size, highWaterMark) { |
|
4957 |
_classCallCheck(this, WritableStreamDefaultController); |
|
4958 |
if (IsWritableStream(stream) === false) { |
|
4959 |
throw new TypeError('WritableStreamDefaultController can only be constructed with a WritableStream instance'); |
|
4960 |
} |
|
4961 |
if (stream._writableStreamController !== undefined) { |
|
4962 |
throw new TypeError('WritableStreamDefaultController instances can only be created by the WritableStream constructor'); |
|
4963 |
} |
|
4964 |
this._controlledWritableStream = stream; |
|
4965 |
this._underlyingSink = underlyingSink; |
|
4966 |
this._queue = undefined; |
|
4967 |
this._queueTotalSize = undefined; |
|
4968 |
ResetQueue(this); |
|
4969 |
this._started = false; |
|
4970 |
var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark); |
|
4971 |
this._strategySize = normalizedStrategy.size; |
|
4972 |
this._strategyHWM = normalizedStrategy.highWaterMark; |
|
4973 |
var backpressure = WritableStreamDefaultControllerGetBackpressure(this); |
|
4974 |
WritableStreamUpdateBackpressure(stream, backpressure); |
|
4975 |
} |
|
4976 |
_createClass(WritableStreamDefaultController, [{ |
|
4977 |
key: 'error', |
|
4978 |
value: function error(e) { |
|
4979 |
if (IsWritableStreamDefaultController(this) === false) { |
|
4980 |
throw new TypeError('WritableStreamDefaultController.prototype.error can only be used on a WritableStreamDefaultController'); |
|
4981 |
} |
|
4982 |
var state = this._controlledWritableStream._state; |
|
4983 |
if (state !== 'writable') { |
|
4984 |
return; |
|
4985 |
} |
|
4986 |
WritableStreamDefaultControllerError(this, e); |
|
4987 |
} |
|
4988 |
}, { |
|
4989 |
key: '__abortSteps', |
|
4990 |
value: function __abortSteps(reason) { |
|
4991 |
return PromiseInvokeOrNoop(this._underlyingSink, 'abort', [reason]); |
|
4992 |
} |
|
4993 |
}, { |
|
4994 |
key: '__errorSteps', |
|
4995 |
value: function __errorSteps() { |
|
4996 |
ResetQueue(this); |
|
4997 |
} |
|
4998 |
}, { |
|
4999 |
key: '__startSteps', |
|
5000 |
value: function __startSteps() { |
|
5001 |
var _this = this; |
|
5002 |
var startResult = InvokeOrNoop(this._underlyingSink, 'start', [this]); |
|
5003 |
var stream = this._controlledWritableStream; |
|
5004 |
Promise.resolve(startResult).then(function () { |
|
5005 |
assert(stream._state === 'writable' || stream._state === 'erroring'); |
|
5006 |
_this._started = true; |
|
5007 |
WritableStreamDefaultControllerAdvanceQueueIfNeeded(_this); |
|
5008 |
}, function (r) { |
|
5009 |
assert(stream._state === 'writable' || stream._state === 'erroring'); |
|
5010 |
_this._started = true; |
|
5011 |
WritableStreamDealWithRejection(stream, r); |
|
5012 |
}).catch(rethrowAssertionErrorRejection); |
|
5013 |
} |
|
5014 |
}]); |
|
5015 |
return WritableStreamDefaultController; |
|
5016 |
}(); |
|
5017 |
function WritableStreamDefaultControllerClose(controller) { |
|
5018 |
EnqueueValueWithSize(controller, 'close', 0); |
|
5019 |
WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller); |
|
5020 |
} |
|
5021 |
function WritableStreamDefaultControllerGetChunkSize(controller, chunk) { |
|
5022 |
var strategySize = controller._strategySize; |
|
5023 |
if (strategySize === undefined) { |
|
5024 |
return 1; |
|
5025 |
} |
|
5026 |
try { |
|
5027 |
return strategySize(chunk); |
|
5028 |
} catch (chunkSizeE) { |
|
5029 |
WritableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE); |
|
5030 |
return 1; |
|
5031 |
} |
|
5032 |
} |
|
5033 |
function WritableStreamDefaultControllerGetDesiredSize(controller) { |
|
5034 |
return controller._strategyHWM - controller._queueTotalSize; |
|
5035 |
} |
|
5036 |
function WritableStreamDefaultControllerWrite(controller, chunk, chunkSize) { |
|
5037 |
var writeRecord = { chunk: chunk }; |
|
5038 |
try { |
|
5039 |
EnqueueValueWithSize(controller, writeRecord, chunkSize); |
|
5040 |
} catch (enqueueE) { |
|
5041 |
WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueE); |
|
5042 |
return; |
|
5043 |
} |
|
5044 |
var stream = controller._controlledWritableStream; |
|
5045 |
if (WritableStreamCloseQueuedOrInFlight(stream) === false && stream._state === 'writable') { |
|
5046 |
var backpressure = WritableStreamDefaultControllerGetBackpressure(controller); |
|
5047 |
WritableStreamUpdateBackpressure(stream, backpressure); |
|
5048 |
} |
|
5049 |
WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller); |
|
5050 |
} |
|
5051 |
function IsWritableStreamDefaultController(x) { |
|
5052 |
if (!typeIsObject(x)) { |
|
5053 |
return false; |
|
5054 |
} |
|
5055 |
if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSink')) { |
|
5056 |
return false; |
|
5057 |
} |
|
5058 |
return true; |
|
5059 |
} |
|
5060 |
function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller) { |
|
5061 |
var stream = controller._controlledWritableStream; |
|
5062 |
if (controller._started === false) { |
|
5063 |
return; |
|
5064 |
} |
|
5065 |
if (stream._inFlightWriteRequest !== undefined) { |
|
5066 |
return; |
|
5067 |
} |
|
5068 |
var state = stream._state; |
|
5069 |
if (state === 'closed' || state === 'errored') { |
|
5070 |
return; |
|
5071 |
} |
|
5072 |
if (state === 'erroring') { |
|
5073 |
WritableStreamFinishErroring(stream); |
|
5074 |
return; |
|
5075 |
} |
|
5076 |
if (controller._queue.length === 0) { |
|
5077 |
return; |
|
5078 |
} |
|
5079 |
var writeRecord = PeekQueueValue(controller); |
|
5080 |
if (writeRecord === 'close') { |
|
5081 |
WritableStreamDefaultControllerProcessClose(controller); |
|
5082 |
} else { |
|
5083 |
WritableStreamDefaultControllerProcessWrite(controller, writeRecord.chunk); |
|
5084 |
} |
|
5085 |
} |
|
5086 |
function WritableStreamDefaultControllerErrorIfNeeded(controller, error) { |
|
5087 |
if (controller._controlledWritableStream._state === 'writable') { |
|
5088 |
WritableStreamDefaultControllerError(controller, error); |
|
5089 |
} |
|
5090 |
} |
|
5091 |
function WritableStreamDefaultControllerProcessClose(controller) { |
|
5092 |
var stream = controller._controlledWritableStream; |
|
5093 |
WritableStreamMarkCloseRequestInFlight(stream); |
|
5094 |
DequeueValue(controller); |
|
5095 |
assert(controller._queue.length === 0, 'queue must be empty once the final write record is dequeued'); |
|
5096 |
var sinkClosePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'close', []); |
|
5097 |
sinkClosePromise.then(function () { |
|
5098 |
WritableStreamFinishInFlightClose(stream); |
|
5099 |
}, function (reason) { |
|
5100 |
WritableStreamFinishInFlightCloseWithError(stream, reason); |
|
5101 |
}).catch(rethrowAssertionErrorRejection); |
|
5102 |
} |
|
5103 |
function WritableStreamDefaultControllerProcessWrite(controller, chunk) { |
|
5104 |
var stream = controller._controlledWritableStream; |
|
5105 |
WritableStreamMarkFirstWriteRequestInFlight(stream); |
|
5106 |
var sinkWritePromise = PromiseInvokeOrNoop(controller._underlyingSink, 'write', [chunk, controller]); |
|
5107 |
sinkWritePromise.then(function () { |
|
5108 |
WritableStreamFinishInFlightWrite(stream); |
|
5109 |
var state = stream._state; |
|
5110 |
assert(state === 'writable' || state === 'erroring'); |
|
5111 |
DequeueValue(controller); |
|
5112 |
if (WritableStreamCloseQueuedOrInFlight(stream) === false && state === 'writable') { |
|
5113 |
var backpressure = WritableStreamDefaultControllerGetBackpressure(controller); |
|
5114 |
WritableStreamUpdateBackpressure(stream, backpressure); |
|
5115 |
} |
|
5116 |
WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller); |
|
5117 |
}, function (reason) { |
|
5118 |
WritableStreamFinishInFlightWriteWithError(stream, reason); |
|
5119 |
}).catch(rethrowAssertionErrorRejection); |
|
5120 |
} |
|
5121 |
function WritableStreamDefaultControllerGetBackpressure(controller) { |
|
5122 |
var desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller); |
|
5123 |
return desiredSize <= 0; |
|
5124 |
} |
|
5125 |
function WritableStreamDefaultControllerError(controller, error) { |
|
5126 |
var stream = controller._controlledWritableStream; |
|
5127 |
assert(stream._state === 'writable'); |
|
5128 |
WritableStreamStartErroring(stream, error); |
|
5129 |
} |
|
5130 |
function streamBrandCheckException(name) { |
|
5131 |
return new TypeError('WritableStream.prototype.' + name + ' can only be used on a WritableStream'); |
|
5132 |
} |
|
5133 |
function defaultWriterBrandCheckException(name) { |
|
5134 |
return new TypeError('WritableStreamDefaultWriter.prototype.' + name + ' can only be used on a WritableStreamDefaultWriter'); |
|
5135 |
} |
|
5136 |
function defaultWriterLockException(name) { |
|
5137 |
return new TypeError('Cannot ' + name + ' a stream using a released writer'); |
|
5138 |
} |
|
5139 |
function defaultWriterClosedPromiseInitialize(writer) { |
|
5140 |
writer._closedPromise = new Promise(function (resolve, reject) { |
|
5141 |
writer._closedPromise_resolve = resolve; |
|
5142 |
writer._closedPromise_reject = reject; |
|
5143 |
writer._closedPromiseState = 'pending'; |
|
5144 |
}); |
|
5145 |
} |
|
5146 |
function defaultWriterClosedPromiseInitializeAsRejected(writer, reason) { |
|
5147 |
writer._closedPromise = Promise.reject(reason); |
|
5148 |
writer._closedPromise_resolve = undefined; |
|
5149 |
writer._closedPromise_reject = undefined; |
|
5150 |
writer._closedPromiseState = 'rejected'; |
|
5151 |
} |
|
5152 |
function defaultWriterClosedPromiseInitializeAsResolved(writer) { |
|
5153 |
writer._closedPromise = Promise.resolve(undefined); |
|
5154 |
writer._closedPromise_resolve = undefined; |
|
5155 |
writer._closedPromise_reject = undefined; |
|
5156 |
writer._closedPromiseState = 'resolved'; |
|
5157 |
} |
|
5158 |
function defaultWriterClosedPromiseReject(writer, reason) { |
|
5159 |
assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined'); |
|
5160 |
assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined'); |
|
5161 |
assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending'); |
|
5162 |
writer._closedPromise_reject(reason); |
|
5163 |
writer._closedPromise_resolve = undefined; |
|
5164 |
writer._closedPromise_reject = undefined; |
|
5165 |
writer._closedPromiseState = 'rejected'; |
|
5166 |
} |
|
5167 |
function defaultWriterClosedPromiseResetToRejected(writer, reason) { |
|
5168 |
assert(writer._closedPromise_resolve === undefined, 'writer._closedPromise_resolve === undefined'); |
|
5169 |
assert(writer._closedPromise_reject === undefined, 'writer._closedPromise_reject === undefined'); |
|
5170 |
assert(writer._closedPromiseState !== 'pending', 'writer._closedPromiseState is not pending'); |
|
5171 |
writer._closedPromise = Promise.reject(reason); |
|
5172 |
writer._closedPromiseState = 'rejected'; |
|
5173 |
} |
|
5174 |
function defaultWriterClosedPromiseResolve(writer) { |
|
5175 |
assert(writer._closedPromise_resolve !== undefined, 'writer._closedPromise_resolve !== undefined'); |
|
5176 |
assert(writer._closedPromise_reject !== undefined, 'writer._closedPromise_reject !== undefined'); |
|
5177 |
assert(writer._closedPromiseState === 'pending', 'writer._closedPromiseState is pending'); |
|
5178 |
writer._closedPromise_resolve(undefined); |
|
5179 |
writer._closedPromise_resolve = undefined; |
|
5180 |
writer._closedPromise_reject = undefined; |
|
5181 |
writer._closedPromiseState = 'resolved'; |
|
5182 |
} |
|
5183 |
function defaultWriterReadyPromiseInitialize(writer) { |
|
5184 |
writer._readyPromise = new Promise(function (resolve, reject) { |
|
5185 |
writer._readyPromise_resolve = resolve; |
|
5186 |
writer._readyPromise_reject = reject; |
|
5187 |
}); |
|
5188 |
writer._readyPromiseState = 'pending'; |
|
5189 |
} |
|
5190 |
function defaultWriterReadyPromiseInitializeAsRejected(writer, reason) { |
|
5191 |
writer._readyPromise = Promise.reject(reason); |
|
5192 |
writer._readyPromise_resolve = undefined; |
|
5193 |
writer._readyPromise_reject = undefined; |
|
5194 |
writer._readyPromiseState = 'rejected'; |
|
5195 |
} |
|
5196 |
function defaultWriterReadyPromiseInitializeAsResolved(writer) { |
|
5197 |
writer._readyPromise = Promise.resolve(undefined); |
|
5198 |
writer._readyPromise_resolve = undefined; |
|
5199 |
writer._readyPromise_reject = undefined; |
|
5200 |
writer._readyPromiseState = 'fulfilled'; |
|
5201 |
} |
|
5202 |
function defaultWriterReadyPromiseReject(writer, reason) { |
|
5203 |
assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined'); |
|
5204 |
assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined'); |
|
5205 |
writer._readyPromise_reject(reason); |
|
5206 |
writer._readyPromise_resolve = undefined; |
|
5207 |
writer._readyPromise_reject = undefined; |
|
5208 |
writer._readyPromiseState = 'rejected'; |
|
5209 |
} |
|
5210 |
function defaultWriterReadyPromiseReset(writer) { |
|
5211 |
assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined'); |
|
5212 |
assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined'); |
|
5213 |
writer._readyPromise = new Promise(function (resolve, reject) { |
|
5214 |
writer._readyPromise_resolve = resolve; |
|
5215 |
writer._readyPromise_reject = reject; |
|
5216 |
}); |
|
5217 |
writer._readyPromiseState = 'pending'; |
|
5218 |
} |
|
5219 |
function defaultWriterReadyPromiseResetToRejected(writer, reason) { |
|
5220 |
assert(writer._readyPromise_resolve === undefined, 'writer._readyPromise_resolve === undefined'); |
|
5221 |
assert(writer._readyPromise_reject === undefined, 'writer._readyPromise_reject === undefined'); |
|
5222 |
writer._readyPromise = Promise.reject(reason); |
|
5223 |
writer._readyPromiseState = 'rejected'; |
|
5224 |
} |
|
5225 |
function defaultWriterReadyPromiseResolve(writer) { |
|
5226 |
assert(writer._readyPromise_resolve !== undefined, 'writer._readyPromise_resolve !== undefined'); |
|
5227 |
assert(writer._readyPromise_reject !== undefined, 'writer._readyPromise_reject !== undefined'); |
|
5228 |
writer._readyPromise_resolve(undefined); |
|
5229 |
writer._readyPromise_resolve = undefined; |
|
5230 |
writer._readyPromise_reject = undefined; |
|
5231 |
writer._readyPromiseState = 'fulfilled'; |
|
5232 |
} |
|
5233 |
}, function (module, exports, __w_pdfjs_require__) { |
|
5234 |
"use strict"; |
|
5235 |
|
|
5236 |
var _require = __w_pdfjs_require__(0), |
|
5237 |
IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber; |
|
5238 |
var _require2 = __w_pdfjs_require__(1), |
|
5239 |
assert = _require2.assert; |
|
5240 |
exports.DequeueValue = function (container) { |
|
5241 |
assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: DequeueValue should only be used on containers with [[queue]] and [[queueTotalSize]].'); |
|
5242 |
assert(container._queue.length > 0, 'Spec-level failure: should never dequeue from an empty queue.'); |
|
5243 |
var pair = container._queue.shift(); |
|
5244 |
container._queueTotalSize -= pair.size; |
|
5245 |
if (container._queueTotalSize < 0) { |
|
5246 |
container._queueTotalSize = 0; |
|
5247 |
} |
|
5248 |
return pair.value; |
|
5249 |
}; |
|
5250 |
exports.EnqueueValueWithSize = function (container, value, size) { |
|
5251 |
assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: EnqueueValueWithSize should only be used on containers with [[queue]] and ' + '[[queueTotalSize]].'); |
|
5252 |
size = Number(size); |
|
5253 |
if (!IsFiniteNonNegativeNumber(size)) { |
|
5254 |
throw new RangeError('Size must be a finite, non-NaN, non-negative number.'); |
|
5255 |
} |
|
5256 |
container._queue.push({ |
|
5257 |
value: value, |
|
5258 |
size: size |
|
5259 |
}); |
|
5260 |
container._queueTotalSize += size; |
|
5261 |
}; |
|
5262 |
exports.PeekQueueValue = function (container) { |
|
5263 |
assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: PeekQueueValue should only be used on containers with [[queue]] and [[queueTotalSize]].'); |
|
5264 |
assert(container._queue.length > 0, 'Spec-level failure: should never peek at an empty queue.'); |
|
5265 |
var pair = container._queue[0]; |
|
5266 |
return pair.value; |
|
5267 |
}; |
|
5268 |
exports.ResetQueue = function (container) { |
|
5269 |
assert('_queue' in container && '_queueTotalSize' in container, 'Spec-level failure: ResetQueue should only be used on containers with [[queue]] and [[queueTotalSize]].'); |
|
5270 |
container._queue = []; |
|
5271 |
container._queueTotalSize = 0; |
|
5272 |
}; |
|
5273 |
}, function (module, exports, __w_pdfjs_require__) { |
|
5274 |
"use strict"; |
|
5275 |
|
|
5276 |
var _createClass = function () { |
|
5277 |
function defineProperties(target, props) { |
|
5278 |
for (var i = 0; i < props.length; i++) { |
|
5279 |
var descriptor = props[i]; |
|
5280 |
descriptor.enumerable = descriptor.enumerable || false; |
|
5281 |
descriptor.configurable = true; |
|
5282 |
if ("value" in descriptor) descriptor.writable = true; |
|
5283 |
Object.defineProperty(target, descriptor.key, descriptor); |
|
5284 |
} |
|
5285 |
} |
|
5286 |
return function (Constructor, protoProps, staticProps) { |
|
5287 |
if (protoProps) defineProperties(Constructor.prototype, protoProps); |
|
5288 |
if (staticProps) defineProperties(Constructor, staticProps); |
|
5289 |
return Constructor; |
|
5290 |
}; |
|
5291 |
}(); |
|
5292 |
function _classCallCheck(instance, Constructor) { |
|
5293 |
if (!(instance instanceof Constructor)) { |
|
5294 |
throw new TypeError("Cannot call a class as a function"); |
|
5295 |
} |
|
5296 |
} |
|
5297 |
var _require = __w_pdfjs_require__(0), |
|
5298 |
ArrayBufferCopy = _require.ArrayBufferCopy, |
|
5299 |
CreateIterResultObject = _require.CreateIterResultObject, |
|
5300 |
IsFiniteNonNegativeNumber = _require.IsFiniteNonNegativeNumber, |
|
5301 |
InvokeOrNoop = _require.InvokeOrNoop, |
|
5302 |
PromiseInvokeOrNoop = _require.PromiseInvokeOrNoop, |
|
5303 |
TransferArrayBuffer = _require.TransferArrayBuffer, |
|
5304 |
ValidateAndNormalizeQueuingStrategy = _require.ValidateAndNormalizeQueuingStrategy, |
|
5305 |
ValidateAndNormalizeHighWaterMark = _require.ValidateAndNormalizeHighWaterMark; |
|
5306 |
var _require2 = __w_pdfjs_require__(0), |
|
5307 |
createArrayFromList = _require2.createArrayFromList, |
|
5308 |
createDataProperty = _require2.createDataProperty, |
|
5309 |
typeIsObject = _require2.typeIsObject; |
|
5310 |
var _require3 = __w_pdfjs_require__(1), |
|
5311 |
assert = _require3.assert, |
|
5312 |
rethrowAssertionErrorRejection = _require3.rethrowAssertionErrorRejection; |
|
5313 |
var _require4 = __w_pdfjs_require__(3), |
|
5314 |
DequeueValue = _require4.DequeueValue, |
|
5315 |
EnqueueValueWithSize = _require4.EnqueueValueWithSize, |
|
5316 |
ResetQueue = _require4.ResetQueue; |
|
5317 |
var _require5 = __w_pdfjs_require__(2), |
|
5318 |
AcquireWritableStreamDefaultWriter = _require5.AcquireWritableStreamDefaultWriter, |
|
5319 |
IsWritableStream = _require5.IsWritableStream, |
|
5320 |
IsWritableStreamLocked = _require5.IsWritableStreamLocked, |
|
5321 |
WritableStreamAbort = _require5.WritableStreamAbort, |
|
5322 |
WritableStreamDefaultWriterCloseWithErrorPropagation = _require5.WritableStreamDefaultWriterCloseWithErrorPropagation, |
|
5323 |
WritableStreamDefaultWriterRelease = _require5.WritableStreamDefaultWriterRelease, |
|
5324 |
WritableStreamDefaultWriterWrite = _require5.WritableStreamDefaultWriterWrite, |
|
5325 |
WritableStreamCloseQueuedOrInFlight = _require5.WritableStreamCloseQueuedOrInFlight; |
|
5326 |
var ReadableStream = function () { |
|
5327 |
function ReadableStream() { |
|
5328 |
var underlyingSource = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
5329 |
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, |
|
5330 |
size = _ref.size, |
|
5331 |
highWaterMark = _ref.highWaterMark; |
|
5332 |
_classCallCheck(this, ReadableStream); |
|
5333 |
this._state = 'readable'; |
|
5334 |
this._reader = undefined; |
|
5335 |
this._storedError = undefined; |
|
5336 |
this._disturbed = false; |
|
5337 |
this._readableStreamController = undefined; |
|
5338 |
var type = underlyingSource.type; |
|
5339 |
var typeString = String(type); |
|
5340 |
if (typeString === 'bytes') { |
|
5341 |
if (highWaterMark === undefined) { |
|
5342 |
highWaterMark = 0; |
|
5343 |
} |
|
5344 |
this._readableStreamController = new ReadableByteStreamController(this, underlyingSource, highWaterMark); |
|
5345 |
} else if (type === undefined) { |
|
5346 |
if (highWaterMark === undefined) { |
|
5347 |
highWaterMark = 1; |
|
5348 |
} |
|
5349 |
this._readableStreamController = new ReadableStreamDefaultController(this, underlyingSource, size, highWaterMark); |
|
5350 |
} else { |
|
5351 |
throw new RangeError('Invalid type is specified'); |
|
5352 |
} |
|
5353 |
} |
|
5354 |
_createClass(ReadableStream, [{ |
|
5355 |
key: 'cancel', |
|
5356 |
value: function cancel(reason) { |
|
5357 |
if (IsReadableStream(this) === false) { |
|
5358 |
return Promise.reject(streamBrandCheckException('cancel')); |
|
5359 |
} |
|
5360 |
if (IsReadableStreamLocked(this) === true) { |
|
5361 |
return Promise.reject(new TypeError('Cannot cancel a stream that already has a reader')); |
|
5362 |
} |
|
5363 |
return ReadableStreamCancel(this, reason); |
|
5364 |
} |
|
5365 |
}, { |
|
5366 |
key: 'getReader', |
|
5367 |
value: function getReader() { |
|
5368 |
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
|
5369 |
mode = _ref2.mode; |
|
5370 |
if (IsReadableStream(this) === false) { |
|
5371 |
throw streamBrandCheckException('getReader'); |
|
5372 |
} |
|
5373 |
if (mode === undefined) { |
|
5374 |
return AcquireReadableStreamDefaultReader(this); |
|
5375 |
} |
|
5376 |
mode = String(mode); |
|
5377 |
if (mode === 'byob') { |
|
5378 |
return AcquireReadableStreamBYOBReader(this); |
|
5379 |
} |
|
5380 |
throw new RangeError('Invalid mode is specified'); |
|
5381 |
} |
|
5382 |
}, { |
|
5383 |
key: 'pipeThrough', |
|
5384 |
value: function pipeThrough(_ref3, options) { |
|
5385 |
var writable = _ref3.writable, |
|
5386 |
readable = _ref3.readable; |
|
5387 |
var promise = this.pipeTo(writable, options); |
|
5388 |
ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise); |
|
5389 |
return readable; |
|
5390 |
} |
|
5391 |
}, { |
|
5392 |
key: 'pipeTo', |
|
5393 |
value: function pipeTo(dest) { |
|
5394 |
var _this = this; |
|
5395 |
var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, |
|
5396 |
preventClose = _ref4.preventClose, |
|
5397 |
preventAbort = _ref4.preventAbort, |
|
5398 |
preventCancel = _ref4.preventCancel; |
|
5399 |
if (IsReadableStream(this) === false) { |
|
5400 |
return Promise.reject(streamBrandCheckException('pipeTo')); |
|
5401 |
} |
|
5402 |
if (IsWritableStream(dest) === false) { |
|
5403 |
return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo\'s first argument must be a WritableStream')); |
|
5404 |
} |
|
5405 |
preventClose = Boolean(preventClose); |
|
5406 |
preventAbort = Boolean(preventAbort); |
|
5407 |
preventCancel = Boolean(preventCancel); |
|
5408 |
if (IsReadableStreamLocked(this) === true) { |
|
5409 |
return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream')); |
|
5410 |
} |
|
5411 |
if (IsWritableStreamLocked(dest) === true) { |
|
5412 |
return Promise.reject(new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream')); |
|
5413 |
} |
|
5414 |
var reader = AcquireReadableStreamDefaultReader(this); |
|
5415 |
var writer = AcquireWritableStreamDefaultWriter(dest); |
|
5416 |
var shuttingDown = false; |
|
5417 |
var currentWrite = Promise.resolve(); |
|
5418 |
return new Promise(function (resolve, reject) { |
|
5419 |
function pipeLoop() { |
|
5420 |
currentWrite = Promise.resolve(); |
|
5421 |
if (shuttingDown === true) { |
|
5422 |
return Promise.resolve(); |
|
5423 |
} |
|
5424 |
return writer._readyPromise.then(function () { |
|
5425 |
return ReadableStreamDefaultReaderRead(reader).then(function (_ref5) { |
|
5426 |
var value = _ref5.value, |
|
5427 |
done = _ref5.done; |
|
5428 |
if (done === true) { |
|
5429 |
return; |
|
5430 |
} |
|
5431 |
currentWrite = WritableStreamDefaultWriterWrite(writer, value).catch(function () {}); |
|
5432 |
}); |
|
5433 |
}).then(pipeLoop); |
|
5434 |
} |
|
5435 |
isOrBecomesErrored(_this, reader._closedPromise, function (storedError) { |
|
5436 |
if (preventAbort === false) { |
|
5437 |
shutdownWithAction(function () { |
|
5438 |
return WritableStreamAbort(dest, storedError); |
|
5439 |
}, true, storedError); |
|
5440 |
} else { |
|
5441 |
shutdown(true, storedError); |
|
5442 |
} |
|
5443 |
}); |
|
5444 |
isOrBecomesErrored(dest, writer._closedPromise, function (storedError) { |
|
5445 |
if (preventCancel === false) { |
|
5446 |
shutdownWithAction(function () { |
|
5447 |
return ReadableStreamCancel(_this, storedError); |
|
5448 |
}, true, storedError); |
|
5449 |
} else { |
|
5450 |
shutdown(true, storedError); |
|
5451 |
} |
|
5452 |
}); |
|
5453 |
isOrBecomesClosed(_this, reader._closedPromise, function () { |
|
5454 |
if (preventClose === false) { |
|
5455 |
shutdownWithAction(function () { |
|
5456 |
return WritableStreamDefaultWriterCloseWithErrorPropagation(writer); |
|
5457 |
}); |
|
5458 |
} else { |
|
5459 |
shutdown(); |
|
5460 |
} |
|
5461 |
}); |
|
5462 |
if (WritableStreamCloseQueuedOrInFlight(dest) === true || dest._state === 'closed') { |
|
5463 |
var destClosed = new TypeError('the destination writable stream closed before all data could be piped to it'); |
|
5464 |
if (preventCancel === false) { |
|
5465 |
shutdownWithAction(function () { |
|
5466 |
return ReadableStreamCancel(_this, destClosed); |
|
5467 |
}, true, destClosed); |
|
5468 |
} else { |
|
5469 |
shutdown(true, destClosed); |
|
5470 |
} |
|
5471 |
} |
|
5472 |
pipeLoop().catch(function (err) { |
|
5473 |
currentWrite = Promise.resolve(); |
|
5474 |
rethrowAssertionErrorRejection(err); |
|
5475 |
}); |
|
5476 |
function waitForWritesToFinish() { |
|
5477 |
var oldCurrentWrite = currentWrite; |
|
5478 |
return currentWrite.then(function () { |
|
5479 |
return oldCurrentWrite !== currentWrite ? waitForWritesToFinish() : undefined; |
|
5480 |
}); |
|
5481 |
} |
|
5482 |
function isOrBecomesErrored(stream, promise, action) { |
|
5483 |
if (stream._state === 'errored') { |
|
5484 |
action(stream._storedError); |
|
5485 |
} else { |
|
5486 |
promise.catch(action).catch(rethrowAssertionErrorRejection); |
|
5487 |
} |
|
5488 |
} |
|
5489 |
function isOrBecomesClosed(stream, promise, action) { |
|
5490 |
if (stream._state === 'closed') { |
|
5491 |
action(); |
|
5492 |
} else { |
|
5493 |
promise.then(action).catch(rethrowAssertionErrorRejection); |
|
5494 |
} |
|
5495 |
} |
|
5496 |
function shutdownWithAction(action, originalIsError, originalError) { |
|
5497 |
if (shuttingDown === true) { |
|
5498 |
return; |
|
5499 |
} |
|
5500 |
shuttingDown = true; |
|
5501 |
if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) { |
|
5502 |
waitForWritesToFinish().then(doTheRest); |
|
5503 |
} else { |
|
5504 |
doTheRest(); |
|
5505 |
} |
|
5506 |
function doTheRest() { |
|
5507 |
action().then(function () { |
|
5508 |
return finalize(originalIsError, originalError); |
|
5509 |
}, function (newError) { |
|
5510 |
return finalize(true, newError); |
|
5511 |
}).catch(rethrowAssertionErrorRejection); |
|
5512 |
} |
|
5513 |
} |
|
5514 |
function shutdown(isError, error) { |
|
5515 |
if (shuttingDown === true) { |
|
5516 |
return; |
|
5517 |
} |
|
5518 |
shuttingDown = true; |
|
5519 |
if (dest._state === 'writable' && WritableStreamCloseQueuedOrInFlight(dest) === false) { |
|
5520 |
waitForWritesToFinish().then(function () { |
|
5521 |
return finalize(isError, error); |
|
5522 |
}).catch(rethrowAssertionErrorRejection); |
|
5523 |
} else { |
|
5524 |
finalize(isError, error); |
|
5525 |
} |
|
5526 |
} |
|
5527 |
function finalize(isError, error) { |
|
5528 |
WritableStreamDefaultWriterRelease(writer); |
|
5529 |
ReadableStreamReaderGenericRelease(reader); |
|
5530 |
if (isError) { |
|
5531 |
reject(error); |
|
5532 |
} else { |
|
5533 |
resolve(undefined); |
|
5534 |
} |
|
5535 |
} |
|
5536 |
}); |
|
5537 |
} |
|
5538 |
}, { |
|
5539 |
key: 'tee', |
|
5540 |
value: function tee() { |
|
5541 |
if (IsReadableStream(this) === false) { |
|
5542 |
throw streamBrandCheckException('tee'); |
|
5543 |
} |
|
5544 |
var branches = ReadableStreamTee(this, false); |
|
5545 |
return createArrayFromList(branches); |
|
5546 |
} |
|
5547 |
}, { |
|
5548 |
key: 'locked', |
|
5549 |
get: function get() { |
|
5550 |
if (IsReadableStream(this) === false) { |
|
5551 |
throw streamBrandCheckException('locked'); |
|
5552 |
} |
|
5553 |
return IsReadableStreamLocked(this); |
|
5554 |
} |
|
5555 |
}]); |
|
5556 |
return ReadableStream; |
|
5557 |
}(); |
|
5558 |
module.exports = { |
|
5559 |
ReadableStream: ReadableStream, |
|
5560 |
IsReadableStreamDisturbed: IsReadableStreamDisturbed, |
|
5561 |
ReadableStreamDefaultControllerClose: ReadableStreamDefaultControllerClose, |
|
5562 |
ReadableStreamDefaultControllerEnqueue: ReadableStreamDefaultControllerEnqueue, |
|
5563 |
ReadableStreamDefaultControllerError: ReadableStreamDefaultControllerError, |
|
5564 |
ReadableStreamDefaultControllerGetDesiredSize: ReadableStreamDefaultControllerGetDesiredSize |
|
5565 |
}; |
|
5566 |
function AcquireReadableStreamBYOBReader(stream) { |
|
5567 |
return new ReadableStreamBYOBReader(stream); |
|
5568 |
} |
|
5569 |
function AcquireReadableStreamDefaultReader(stream) { |
|
5570 |
return new ReadableStreamDefaultReader(stream); |
|
5571 |
} |
|
5572 |
function IsReadableStream(x) { |
|
5573 |
if (!typeIsObject(x)) { |
|
5574 |
return false; |
|
5575 |
} |
|
5576 |
if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) { |
|
5577 |
return false; |
|
5578 |
} |
|
5579 |
return true; |
|
5580 |
} |
|
5581 |
function IsReadableStreamDisturbed(stream) { |
|
5582 |
assert(IsReadableStream(stream) === true, 'IsReadableStreamDisturbed should only be used on known readable streams'); |
|
5583 |
return stream._disturbed; |
|
5584 |
} |
|
5585 |
function IsReadableStreamLocked(stream) { |
|
5586 |
assert(IsReadableStream(stream) === true, 'IsReadableStreamLocked should only be used on known readable streams'); |
|
5587 |
if (stream._reader === undefined) { |
|
5588 |
return false; |
|
5589 |
} |
|
5590 |
return true; |
|
5591 |
} |
|
5592 |
function ReadableStreamTee(stream, cloneForBranch2) { |
|
5593 |
assert(IsReadableStream(stream) === true); |
|
5594 |
assert(typeof cloneForBranch2 === 'boolean'); |
|
5595 |
var reader = AcquireReadableStreamDefaultReader(stream); |
|
5596 |
var teeState = { |
|
5597 |
closedOrErrored: false, |
|
5598 |
canceled1: false, |
|
5599 |
canceled2: false, |
|
5600 |
reason1: undefined, |
|
5601 |
reason2: undefined |
|
5602 |
}; |
|
5603 |
teeState.promise = new Promise(function (resolve) { |
|
5604 |
teeState._resolve = resolve; |
|
5605 |
}); |
|
5606 |
var pull = create_ReadableStreamTeePullFunction(); |
|
5607 |
pull._reader = reader; |
|
5608 |
pull._teeState = teeState; |
|
5609 |
pull._cloneForBranch2 = cloneForBranch2; |
|
5610 |
var cancel1 = create_ReadableStreamTeeBranch1CancelFunction(); |
|
5611 |
cancel1._stream = stream; |
|
5612 |
cancel1._teeState = teeState; |
|
5613 |
var cancel2 = create_ReadableStreamTeeBranch2CancelFunction(); |
|
5614 |
cancel2._stream = stream; |
|
5615 |
cancel2._teeState = teeState; |
|
5616 |
var underlyingSource1 = Object.create(Object.prototype); |
|
5617 |
createDataProperty(underlyingSource1, 'pull', pull); |
|
5618 |
createDataProperty(underlyingSource1, 'cancel', cancel1); |
|
5619 |
var branch1Stream = new ReadableStream(underlyingSource1); |
|
5620 |
var underlyingSource2 = Object.create(Object.prototype); |
|
5621 |
createDataProperty(underlyingSource2, 'pull', pull); |
|
5622 |
createDataProperty(underlyingSource2, 'cancel', cancel2); |
|
5623 |
var branch2Stream = new ReadableStream(underlyingSource2); |
|
5624 |
pull._branch1 = branch1Stream._readableStreamController; |
|
5625 |
pull._branch2 = branch2Stream._readableStreamController; |
|
5626 |
reader._closedPromise.catch(function (r) { |
|
5627 |
if (teeState.closedOrErrored === true) { |
|
5628 |
return; |
|
5629 |
} |
|
5630 |
ReadableStreamDefaultControllerError(pull._branch1, r); |
|
5631 |
ReadableStreamDefaultControllerError(pull._branch2, r); |
|
5632 |
teeState.closedOrErrored = true; |
|
5633 |
}); |
|
5634 |
return [branch1Stream, branch2Stream]; |
|
5635 |
} |
|
5636 |
function create_ReadableStreamTeePullFunction() { |
|
5637 |
function f() { |
|
5638 |
var reader = f._reader, |
|
5639 |
branch1 = f._branch1, |
|
5640 |
branch2 = f._branch2, |
|
5641 |
teeState = f._teeState; |
|
5642 |
return ReadableStreamDefaultReaderRead(reader).then(function (result) { |
|
5643 |
assert(typeIsObject(result)); |
|
5644 |
var value = result.value; |
|
5645 |
var done = result.done; |
|
5646 |
assert(typeof done === 'boolean'); |
|
5647 |
if (done === true && teeState.closedOrErrored === false) { |
|
5648 |
if (teeState.canceled1 === false) { |
|
5649 |
ReadableStreamDefaultControllerClose(branch1); |
|
5650 |
} |
|
5651 |
if (teeState.canceled2 === false) { |
|
5652 |
ReadableStreamDefaultControllerClose(branch2); |
|
5653 |
} |
|
5654 |
teeState.closedOrErrored = true; |
|
5655 |
} |
|
5656 |
if (teeState.closedOrErrored === true) { |
|
5657 |
return; |
|
5658 |
} |
|
5659 |
var value1 = value; |
|
5660 |
var value2 = value; |
|
5661 |
if (teeState.canceled1 === false) { |
|
5662 |
ReadableStreamDefaultControllerEnqueue(branch1, value1); |
|
5663 |
} |
|
5664 |
if (teeState.canceled2 === false) { |
|
5665 |
ReadableStreamDefaultControllerEnqueue(branch2, value2); |
|
5666 |
} |
|
5667 |
}); |
|
5668 |
} |
|
5669 |
return f; |
|
5670 |
} |
|
5671 |
function create_ReadableStreamTeeBranch1CancelFunction() { |
|
5672 |
function f(reason) { |
|
5673 |
var stream = f._stream, |
|
5674 |
teeState = f._teeState; |
|
5675 |
teeState.canceled1 = true; |
|
5676 |
teeState.reason1 = reason; |
|
5677 |
if (teeState.canceled2 === true) { |
|
5678 |
var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]); |
|
5679 |
var cancelResult = ReadableStreamCancel(stream, compositeReason); |
|
5680 |
teeState._resolve(cancelResult); |
|
5681 |
} |
|
5682 |
return teeState.promise; |
|
5683 |
} |
|
5684 |
return f; |
|
5685 |
} |
|
5686 |
function create_ReadableStreamTeeBranch2CancelFunction() { |
|
5687 |
function f(reason) { |
|
5688 |
var stream = f._stream, |
|
5689 |
teeState = f._teeState; |
|
5690 |
teeState.canceled2 = true; |
|
5691 |
teeState.reason2 = reason; |
|
5692 |
if (teeState.canceled1 === true) { |
|
5693 |
var compositeReason = createArrayFromList([teeState.reason1, teeState.reason2]); |
|
5694 |
var cancelResult = ReadableStreamCancel(stream, compositeReason); |
|
5695 |
teeState._resolve(cancelResult); |
|
5696 |
} |
|
5697 |
return teeState.promise; |
|
5698 |
} |
|
5699 |
return f; |
|
5700 |
} |
|
5701 |
function ReadableStreamAddReadIntoRequest(stream) { |
|
5702 |
assert(IsReadableStreamBYOBReader(stream._reader) === true); |
|
5703 |
assert(stream._state === 'readable' || stream._state === 'closed'); |
|
5704 |
var promise = new Promise(function (resolve, reject) { |
|
5705 |
var readIntoRequest = { |
|
5706 |
_resolve: resolve, |
|
5707 |
_reject: reject |
|
5708 |
}; |
|
5709 |
stream._reader._readIntoRequests.push(readIntoRequest); |
|
5710 |
}); |
|
5711 |
return promise; |
|
5712 |
} |
|
5713 |
function ReadableStreamAddReadRequest(stream) { |
|
5714 |
assert(IsReadableStreamDefaultReader(stream._reader) === true); |
|
5715 |
assert(stream._state === 'readable'); |
|
5716 |
var promise = new Promise(function (resolve, reject) { |
|
5717 |
var readRequest = { |
|
5718 |
_resolve: resolve, |
|
5719 |
_reject: reject |
|
5720 |
}; |
|
5721 |
stream._reader._readRequests.push(readRequest); |
|
5722 |
}); |
|
5723 |
return promise; |
|
5724 |
} |
|
5725 |
function ReadableStreamCancel(stream, reason) { |
|
5726 |
stream._disturbed = true; |
|
5727 |
if (stream._state === 'closed') { |
|
5728 |
return Promise.resolve(undefined); |
|
5729 |
} |
|
5730 |
if (stream._state === 'errored') { |
|
5731 |
return Promise.reject(stream._storedError); |
|
5732 |
} |
|
5733 |
ReadableStreamClose(stream); |
|
5734 |
var sourceCancelPromise = stream._readableStreamController.__cancelSteps(reason); |
|
5735 |
return sourceCancelPromise.then(function () { |
|
5736 |
return undefined; |
|
5737 |
}); |
|
5738 |
} |
|
5739 |
function ReadableStreamClose(stream) { |
|
5740 |
assert(stream._state === 'readable'); |
|
5741 |
stream._state = 'closed'; |
|
5742 |
var reader = stream._reader; |
|
5743 |
if (reader === undefined) { |
|
5744 |
return undefined; |
|
5745 |
} |
|
5746 |
if (IsReadableStreamDefaultReader(reader) === true) { |
|
5747 |
for (var i = 0; i < reader._readRequests.length; i++) { |
|
5748 |
var _resolve = reader._readRequests[i]._resolve; |
|
5749 |
_resolve(CreateIterResultObject(undefined, true)); |
|
5750 |
} |
|
5751 |
reader._readRequests = []; |
|
5752 |
} |
|
5753 |
defaultReaderClosedPromiseResolve(reader); |
|
5754 |
return undefined; |
|
5755 |
} |
|
5756 |
function ReadableStreamError(stream, e) { |
|
5757 |
assert(IsReadableStream(stream) === true, 'stream must be ReadableStream'); |
|
5758 |
assert(stream._state === 'readable', 'state must be readable'); |
|
5759 |
stream._state = 'errored'; |
|
5760 |
stream._storedError = e; |
|
5761 |
var reader = stream._reader; |
|
5762 |
if (reader === undefined) { |
|
5763 |
return undefined; |
|
5764 |
} |
|
5765 |
if (IsReadableStreamDefaultReader(reader) === true) { |
|
5766 |
for (var i = 0; i < reader._readRequests.length; i++) { |
|
5767 |
var readRequest = reader._readRequests[i]; |
|
5768 |
readRequest._reject(e); |
|
5769 |
} |
|
5770 |
reader._readRequests = []; |
|
5771 |
} else { |
|
5772 |
assert(IsReadableStreamBYOBReader(reader), 'reader must be ReadableStreamBYOBReader'); |
|
5773 |
for (var _i = 0; _i < reader._readIntoRequests.length; _i++) { |
|
5774 |
var readIntoRequest = reader._readIntoRequests[_i]; |
|
5775 |
readIntoRequest._reject(e); |
|
5776 |
} |
|
5777 |
reader._readIntoRequests = []; |
|
5778 |
} |
|
5779 |
defaultReaderClosedPromiseReject(reader, e); |
|
5780 |
reader._closedPromise.catch(function () {}); |
|
5781 |
} |
|
5782 |
function ReadableStreamFulfillReadIntoRequest(stream, chunk, done) { |
|
5783 |
var reader = stream._reader; |
|
5784 |
assert(reader._readIntoRequests.length > 0); |
|
5785 |
var readIntoRequest = reader._readIntoRequests.shift(); |
|
5786 |
readIntoRequest._resolve(CreateIterResultObject(chunk, done)); |
|
5787 |
} |
|
5788 |
function ReadableStreamFulfillReadRequest(stream, chunk, done) { |
|
5789 |
var reader = stream._reader; |
|
5790 |
assert(reader._readRequests.length > 0); |
|
5791 |
var readRequest = reader._readRequests.shift(); |
|
5792 |
readRequest._resolve(CreateIterResultObject(chunk, done)); |
|
5793 |
} |
|
5794 |
function ReadableStreamGetNumReadIntoRequests(stream) { |
|
5795 |
return stream._reader._readIntoRequests.length; |
|
5796 |
} |
|
5797 |
function ReadableStreamGetNumReadRequests(stream) { |
|
5798 |
return stream._reader._readRequests.length; |
|
5799 |
} |
|
5800 |
function ReadableStreamHasBYOBReader(stream) { |
|
5801 |
var reader = stream._reader; |
|
5802 |
if (reader === undefined) { |
|
5803 |
return false; |
|
5804 |
} |
|
5805 |
if (IsReadableStreamBYOBReader(reader) === false) { |
|
5806 |
return false; |
|
5807 |
} |
|
5808 |
return true; |
|
5809 |
} |
|
5810 |
function ReadableStreamHasDefaultReader(stream) { |
|
5811 |
var reader = stream._reader; |
|
5812 |
if (reader === undefined) { |
|
5813 |
return false; |
|
5814 |
} |
|
5815 |
if (IsReadableStreamDefaultReader(reader) === false) { |
|
5816 |
return false; |
|
5817 |
} |
|
5818 |
return true; |
|
5819 |
} |
|
5820 |
var ReadableStreamDefaultReader = function () { |
|
5821 |
function ReadableStreamDefaultReader(stream) { |
|
5822 |
_classCallCheck(this, ReadableStreamDefaultReader); |
|
5823 |
if (IsReadableStream(stream) === false) { |
|
5824 |
throw new TypeError('ReadableStreamDefaultReader can only be constructed with a ReadableStream instance'); |
|
5825 |
} |
|
5826 |
if (IsReadableStreamLocked(stream) === true) { |
|
5827 |
throw new TypeError('This stream has already been locked for exclusive reading by another reader'); |
|
5828 |
} |
|
5829 |
ReadableStreamReaderGenericInitialize(this, stream); |
|
5830 |
this._readRequests = []; |
|
5831 |
} |
|
5832 |
_createClass(ReadableStreamDefaultReader, [{ |
|
5833 |
key: 'cancel', |
|
5834 |
value: function cancel(reason) { |
|
5835 |
if (IsReadableStreamDefaultReader(this) === false) { |
|
5836 |
return Promise.reject(defaultReaderBrandCheckException('cancel')); |
|
5837 |
} |
|
5838 |
if (this._ownerReadableStream === undefined) { |
|
5839 |
return Promise.reject(readerLockException('cancel')); |
|
5840 |
} |
|
5841 |
return ReadableStreamReaderGenericCancel(this, reason); |
|
5842 |
} |
|
5843 |
}, { |
|
5844 |
key: 'read', |
|
5845 |
value: function read() { |
|
5846 |
if (IsReadableStreamDefaultReader(this) === false) { |
|
5847 |
return Promise.reject(defaultReaderBrandCheckException('read')); |
|
5848 |
} |
|
5849 |
if (this._ownerReadableStream === undefined) { |
|
5850 |
return Promise.reject(readerLockException('read from')); |
|
5851 |
} |
|
5852 |
return ReadableStreamDefaultReaderRead(this); |
|
5853 |
} |
|
5854 |
}, { |
|
5855 |
key: 'releaseLock', |
|
5856 |
value: function releaseLock() { |
|
5857 |
if (IsReadableStreamDefaultReader(this) === false) { |
|
5858 |
throw defaultReaderBrandCheckException('releaseLock'); |
|
5859 |
} |
|
5860 |
if (this._ownerReadableStream === undefined) { |
|
5861 |
return; |
|
5862 |
} |
|
5863 |
if (this._readRequests.length > 0) { |
|
5864 |
throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled'); |
|
5865 |
} |
|
5866 |
ReadableStreamReaderGenericRelease(this); |
|
5867 |
} |
|
5868 |
}, { |
|
5869 |
key: 'closed', |
|
5870 |
get: function get() { |
|
5871 |
if (IsReadableStreamDefaultReader(this) === false) { |
|
5872 |
return Promise.reject(defaultReaderBrandCheckException('closed')); |
|
5873 |
} |
|
5874 |
return this._closedPromise; |
|
5875 |
} |
|
5876 |
}]); |
|
5877 |
return ReadableStreamDefaultReader; |
|
5878 |
}(); |
|
5879 |
var ReadableStreamBYOBReader = function () { |
|
5880 |
function ReadableStreamBYOBReader(stream) { |
|
5881 |
_classCallCheck(this, ReadableStreamBYOBReader); |
|
5882 |
if (!IsReadableStream(stream)) { |
|
5883 |
throw new TypeError('ReadableStreamBYOBReader can only be constructed with a ReadableStream instance given a ' + 'byte source'); |
|
5884 |
} |
|
5885 |
if (IsReadableByteStreamController(stream._readableStreamController) === false) { |
|
5886 |
throw new TypeError('Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte ' + 'source'); |
|
5887 |
} |
|
5888 |
if (IsReadableStreamLocked(stream)) { |
|
5889 |
throw new TypeError('This stream has already been locked for exclusive reading by another reader'); |
|
5890 |
} |
|
5891 |
ReadableStreamReaderGenericInitialize(this, stream); |
|
5892 |
this._readIntoRequests = []; |
|
5893 |
} |
|
5894 |
_createClass(ReadableStreamBYOBReader, [{ |
|
5895 |
key: 'cancel', |
|
5896 |
value: function cancel(reason) { |
|
5897 |
if (!IsReadableStreamBYOBReader(this)) { |
|
5898 |
return Promise.reject(byobReaderBrandCheckException('cancel')); |
|
5899 |
} |
|
5900 |
if (this._ownerReadableStream === undefined) { |
|
5901 |
return Promise.reject(readerLockException('cancel')); |
|
5902 |
} |
|
5903 |
return ReadableStreamReaderGenericCancel(this, reason); |
|
5904 |
} |
|
5905 |
}, { |
|
5906 |
key: 'read', |
|
5907 |
value: function read(view) { |
|
5908 |
if (!IsReadableStreamBYOBReader(this)) { |
|
5909 |
return Promise.reject(byobReaderBrandCheckException('read')); |
|
5910 |
} |
|
5911 |
if (this._ownerReadableStream === undefined) { |
|
5912 |
return Promise.reject(readerLockException('read from')); |
|
5913 |
} |
|
5914 |
if (!ArrayBuffer.isView(view)) { |
|
5915 |
return Promise.reject(new TypeError('view must be an array buffer view')); |
|
5916 |
} |
|
5917 |
if (view.byteLength === 0) { |
|
5918 |
return Promise.reject(new TypeError('view must have non-zero byteLength')); |
|
5919 |
} |
|
5920 |
return ReadableStreamBYOBReaderRead(this, view); |
|
5921 |
} |
|
5922 |
}, { |
|
5923 |
key: 'releaseLock', |
|
5924 |
value: function releaseLock() { |
|
5925 |
if (!IsReadableStreamBYOBReader(this)) { |
|
5926 |
throw byobReaderBrandCheckException('releaseLock'); |
|
5927 |
} |
|
5928 |
if (this._ownerReadableStream === undefined) { |
|
5929 |
return; |
|
5930 |
} |
|
5931 |
if (this._readIntoRequests.length > 0) { |
|
5932 |
throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled'); |
|
5933 |
} |
|
5934 |
ReadableStreamReaderGenericRelease(this); |
|
5935 |
} |
|
5936 |
}, { |
|
5937 |
key: 'closed', |
|
5938 |
get: function get() { |
|
5939 |
if (!IsReadableStreamBYOBReader(this)) { |
|
5940 |
return Promise.reject(byobReaderBrandCheckException('closed')); |
|
5941 |
} |
|
5942 |
return this._closedPromise; |
|
5943 |
} |
|
5944 |
}]); |
|
5945 |
return ReadableStreamBYOBReader; |
|
5946 |
}(); |
|
5947 |
function IsReadableStreamBYOBReader(x) { |
|
5948 |
if (!typeIsObject(x)) { |
|
5949 |
return false; |
|
5950 |
} |
|
5951 |
if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) { |
|
5952 |
return false; |
|
5953 |
} |
|
5954 |
return true; |
|
5955 |
} |
|
5956 |
function IsReadableStreamDefaultReader(x) { |
|
5957 |
if (!typeIsObject(x)) { |
|
5958 |
return false; |
|
5959 |
} |
|
5960 |
if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) { |
|
5961 |
return false; |
|
5962 |
} |
|
5963 |
return true; |
|
5964 |
} |
|
5965 |
function ReadableStreamReaderGenericInitialize(reader, stream) { |
|
5966 |
reader._ownerReadableStream = stream; |
|
5967 |
stream._reader = reader; |
|
5968 |
if (stream._state === 'readable') { |
|
5969 |
defaultReaderClosedPromiseInitialize(reader); |
|
5970 |
} else if (stream._state === 'closed') { |
|
5971 |
defaultReaderClosedPromiseInitializeAsResolved(reader); |
|
5972 |
} else { |
|
5973 |
assert(stream._state === 'errored', 'state must be errored'); |
|
5974 |
defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError); |
|
5975 |
reader._closedPromise.catch(function () {}); |
|
5976 |
} |
|
5977 |
} |
|
5978 |
function ReadableStreamReaderGenericCancel(reader, reason) { |
|
5979 |
var stream = reader._ownerReadableStream; |
|
5980 |
assert(stream !== undefined); |
|
5981 |
return ReadableStreamCancel(stream, reason); |
|
5982 |
} |
|
5983 |
function ReadableStreamReaderGenericRelease(reader) { |
|
5984 |
assert(reader._ownerReadableStream !== undefined); |
|
5985 |
assert(reader._ownerReadableStream._reader === reader); |
|
5986 |
if (reader._ownerReadableStream._state === 'readable') { |
|
5987 |
defaultReaderClosedPromiseReject(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness')); |
|
5988 |
} else { |
|
5989 |
defaultReaderClosedPromiseResetToRejected(reader, new TypeError('Reader was released and can no longer be used to monitor the stream\'s closedness')); |
|
5990 |
} |
|
5991 |
reader._closedPromise.catch(function () {}); |
|
5992 |
reader._ownerReadableStream._reader = undefined; |
|
5993 |
reader._ownerReadableStream = undefined; |
|
5994 |
} |
|
5995 |
function ReadableStreamBYOBReaderRead(reader, view) { |
|
5996 |
var stream = reader._ownerReadableStream; |
|
5997 |
assert(stream !== undefined); |
|
5998 |
stream._disturbed = true; |
|
5999 |
if (stream._state === 'errored') { |
|
6000 |
return Promise.reject(stream._storedError); |
|
6001 |
} |
|
6002 |
return ReadableByteStreamControllerPullInto(stream._readableStreamController, view); |
|
6003 |
} |
|
6004 |
function ReadableStreamDefaultReaderRead(reader) { |
|
6005 |
var stream = reader._ownerReadableStream; |
|
6006 |
assert(stream !== undefined); |
|
6007 |
stream._disturbed = true; |
|
6008 |
if (stream._state === 'closed') { |
|
6009 |
return Promise.resolve(CreateIterResultObject(undefined, true)); |
|
6010 |
} |
|
6011 |
if (stream._state === 'errored') { |
|
6012 |
return Promise.reject(stream._storedError); |
|
6013 |
} |
|
6014 |
assert(stream._state === 'readable'); |
|
6015 |
return stream._readableStreamController.__pullSteps(); |
|
6016 |
} |
|
6017 |
var ReadableStreamDefaultController = function () { |
|
6018 |
function ReadableStreamDefaultController(stream, underlyingSource, size, highWaterMark) { |
|
6019 |
_classCallCheck(this, ReadableStreamDefaultController); |
|
6020 |
if (IsReadableStream(stream) === false) { |
|
6021 |
throw new TypeError('ReadableStreamDefaultController can only be constructed with a ReadableStream instance'); |
|
6022 |
} |
|
6023 |
if (stream._readableStreamController !== undefined) { |
|
6024 |
throw new TypeError('ReadableStreamDefaultController instances can only be created by the ReadableStream constructor'); |
|
6025 |
} |
|
6026 |
this._controlledReadableStream = stream; |
|
6027 |
this._underlyingSource = underlyingSource; |
|
6028 |
this._queue = undefined; |
|
6029 |
this._queueTotalSize = undefined; |
|
6030 |
ResetQueue(this); |
|
6031 |
this._started = false; |
|
6032 |
this._closeRequested = false; |
|
6033 |
this._pullAgain = false; |
|
6034 |
this._pulling = false; |
|
6035 |
var normalizedStrategy = ValidateAndNormalizeQueuingStrategy(size, highWaterMark); |
|
6036 |
this._strategySize = normalizedStrategy.size; |
|
6037 |
this._strategyHWM = normalizedStrategy.highWaterMark; |
|
6038 |
var controller = this; |
|
6039 |
var startResult = InvokeOrNoop(underlyingSource, 'start', [this]); |
|
6040 |
Promise.resolve(startResult).then(function () { |
|
6041 |
controller._started = true; |
|
6042 |
assert(controller._pulling === false); |
|
6043 |
assert(controller._pullAgain === false); |
|
6044 |
ReadableStreamDefaultControllerCallPullIfNeeded(controller); |
|
6045 |
}, function (r) { |
|
6046 |
ReadableStreamDefaultControllerErrorIfNeeded(controller, r); |
|
6047 |
}).catch(rethrowAssertionErrorRejection); |
|
6048 |
} |
|
6049 |
_createClass(ReadableStreamDefaultController, [{ |
|
6050 |
key: 'close', |
|
6051 |
value: function close() { |
|
6052 |
if (IsReadableStreamDefaultController(this) === false) { |
|
6053 |
throw defaultControllerBrandCheckException('close'); |
|
6054 |
} |
|
6055 |
if (this._closeRequested === true) { |
|
6056 |
throw new TypeError('The stream has already been closed; do not close it again!'); |
|
6057 |
} |
|
6058 |
var state = this._controlledReadableStream._state; |
|
6059 |
if (state !== 'readable') { |
|
6060 |
throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed'); |
|
6061 |
} |
|
6062 |
ReadableStreamDefaultControllerClose(this); |
|
6063 |
} |
|
6064 |
}, { |
|
6065 |
key: 'enqueue', |
|
6066 |
value: function enqueue(chunk) { |
|
6067 |
if (IsReadableStreamDefaultController(this) === false) { |
|
6068 |
throw defaultControllerBrandCheckException('enqueue'); |
|
6069 |
} |
|
6070 |
if (this._closeRequested === true) { |
|
6071 |
throw new TypeError('stream is closed or draining'); |
|
6072 |
} |
|
6073 |
var state = this._controlledReadableStream._state; |
|
6074 |
if (state !== 'readable') { |
|
6075 |
throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to'); |
|
6076 |
} |
|
6077 |
return ReadableStreamDefaultControllerEnqueue(this, chunk); |
|
6078 |
} |
|
6079 |
}, { |
|
6080 |
key: 'error', |
|
6081 |
value: function error(e) { |
|
6082 |
if (IsReadableStreamDefaultController(this) === false) { |
|
6083 |
throw defaultControllerBrandCheckException('error'); |
|
6084 |
} |
|
6085 |
var stream = this._controlledReadableStream; |
|
6086 |
if (stream._state !== 'readable') { |
|
6087 |
throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored'); |
|
6088 |
} |
|
6089 |
ReadableStreamDefaultControllerError(this, e); |
|
6090 |
} |
|
6091 |
}, { |
|
6092 |
key: '__cancelSteps', |
|
6093 |
value: function __cancelSteps(reason) { |
|
6094 |
ResetQueue(this); |
|
6095 |
return PromiseInvokeOrNoop(this._underlyingSource, 'cancel', [reason]); |
|
6096 |
} |
|
6097 |
}, { |
|
6098 |
key: '__pullSteps', |
|
6099 |
value: function __pullSteps() { |
|
6100 |
var stream = this._controlledReadableStream; |
|
6101 |
if (this._queue.length > 0) { |
|
6102 |
var chunk = DequeueValue(this); |
|
6103 |
if (this._closeRequested === true && this._queue.length === 0) { |
|
6104 |
ReadableStreamClose(stream); |
|
6105 |
} else { |
|
6106 |
ReadableStreamDefaultControllerCallPullIfNeeded(this); |
|
6107 |
} |
|
6108 |
return Promise.resolve(CreateIterResultObject(chunk, false)); |
|
6109 |
} |
|
6110 |
var pendingPromise = ReadableStreamAddReadRequest(stream); |
|
6111 |
ReadableStreamDefaultControllerCallPullIfNeeded(this); |
|
6112 |
return pendingPromise; |
|
6113 |
} |
|
6114 |
}, { |
|
6115 |
key: 'desiredSize', |
|
6116 |
get: function get() { |
|
6117 |
if (IsReadableStreamDefaultController(this) === false) { |
|
6118 |
throw defaultControllerBrandCheckException('desiredSize'); |
|
6119 |
} |
|
6120 |
return ReadableStreamDefaultControllerGetDesiredSize(this); |
|
6121 |
} |
|
6122 |
}]); |
|
6123 |
return ReadableStreamDefaultController; |
|
6124 |
}(); |
|
6125 |
function IsReadableStreamDefaultController(x) { |
|
6126 |
if (!typeIsObject(x)) { |
|
6127 |
return false; |
|
6128 |
} |
|
6129 |
if (!Object.prototype.hasOwnProperty.call(x, '_underlyingSource')) { |
|
6130 |
return false; |
|
6131 |
} |
|
6132 |
return true; |
|
6133 |
} |
|
6134 |
function ReadableStreamDefaultControllerCallPullIfNeeded(controller) { |
|
6135 |
var shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller); |
|
6136 |
if (shouldPull === false) { |
|
6137 |
return undefined; |
|
6138 |
} |
|
6139 |
if (controller._pulling === true) { |
|
6140 |
controller._pullAgain = true; |
|
6141 |
return undefined; |
|
6142 |
} |
|
6143 |
assert(controller._pullAgain === false); |
|
6144 |
controller._pulling = true; |
|
6145 |
var pullPromise = PromiseInvokeOrNoop(controller._underlyingSource, 'pull', [controller]); |
|
6146 |
pullPromise.then(function () { |
|
6147 |
controller._pulling = false; |
|
6148 |
if (controller._pullAgain === true) { |
|
6149 |
controller._pullAgain = false; |
|
6150 |
return ReadableStreamDefaultControllerCallPullIfNeeded(controller); |
|
6151 |
} |
|
6152 |
return undefined; |
|
6153 |
}, function (e) { |
|
6154 |
ReadableStreamDefaultControllerErrorIfNeeded(controller, e); |
|
6155 |
}).catch(rethrowAssertionErrorRejection); |
|
6156 |
return undefined; |
|
6157 |
} |
|
6158 |
function ReadableStreamDefaultControllerShouldCallPull(controller) { |
|
6159 |
var stream = controller._controlledReadableStream; |
|
6160 |
if (stream._state === 'closed' || stream._state === 'errored') { |
|
6161 |
return false; |
|
6162 |
} |
|
6163 |
if (controller._closeRequested === true) { |
|
6164 |
return false; |
|
6165 |
} |
|
6166 |
if (controller._started === false) { |
|
6167 |
return false; |
|
6168 |
} |
|
6169 |
if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) { |
|
6170 |
return true; |
|
6171 |
} |
|
6172 |
var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller); |
|
6173 |
if (desiredSize > 0) { |
|
6174 |
return true; |
|
6175 |
} |
|
6176 |
return false; |
|
6177 |
} |
|
6178 |
function ReadableStreamDefaultControllerClose(controller) { |
|
6179 |
var stream = controller._controlledReadableStream; |
|
6180 |
assert(controller._closeRequested === false); |
|
6181 |
assert(stream._state === 'readable'); |
|
6182 |
controller._closeRequested = true; |
|
6183 |
if (controller._queue.length === 0) { |
|
6184 |
ReadableStreamClose(stream); |
|
6185 |
} |
|
6186 |
} |
|
6187 |
function ReadableStreamDefaultControllerEnqueue(controller, chunk) { |
|
6188 |
var stream = controller._controlledReadableStream; |
|
6189 |
assert(controller._closeRequested === false); |
|
6190 |
assert(stream._state === 'readable'); |
|
6191 |
if (IsReadableStreamLocked(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) { |
|
6192 |
ReadableStreamFulfillReadRequest(stream, chunk, false); |
|
6193 |
} else { |
|
6194 |
var chunkSize = 1; |
|
6195 |
if (controller._strategySize !== undefined) { |
|
6196 |
var strategySize = controller._strategySize; |
|
6197 |
try { |
|
6198 |
chunkSize = strategySize(chunk); |
|
6199 |
} catch (chunkSizeE) { |
|
6200 |
ReadableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE); |
|
6201 |
throw chunkSizeE; |
|
6202 |
} |
|
6203 |
} |
|
6204 |
try { |
|
6205 |
EnqueueValueWithSize(controller, chunk, chunkSize); |
|
6206 |
} catch (enqueueE) { |
|
6207 |
ReadableStreamDefaultControllerErrorIfNeeded(controller, enqueueE); |
|
6208 |
throw enqueueE; |
|
6209 |
} |
|
6210 |
} |
|
6211 |
ReadableStreamDefaultControllerCallPullIfNeeded(controller); |
|
6212 |
return undefined; |
|
6213 |
} |
|
6214 |
function ReadableStreamDefaultControllerError(controller, e) { |
|
6215 |
var stream = controller._controlledReadableStream; |
|
6216 |
assert(stream._state === 'readable'); |
|
6217 |
ResetQueue(controller); |
|
6218 |
ReadableStreamError(stream, e); |
|
6219 |
} |
|
6220 |
function ReadableStreamDefaultControllerErrorIfNeeded(controller, e) { |
|
6221 |
if (controller._controlledReadableStream._state === 'readable') { |
|
6222 |
ReadableStreamDefaultControllerError(controller, e); |
|
6223 |
} |
|
6224 |
} |
|
6225 |
function ReadableStreamDefaultControllerGetDesiredSize(controller) { |
|
6226 |
var stream = controller._controlledReadableStream; |
|
6227 |
var state = stream._state; |
|
6228 |
if (state === 'errored') { |
|
6229 |
return null; |
|
6230 |
} |
|
6231 |
if (state === 'closed') { |
|
6232 |
return 0; |
|
6233 |
} |
|
6234 |
return controller._strategyHWM - controller._queueTotalSize; |
|
6235 |
} |
|
6236 |
var ReadableStreamBYOBRequest = function () { |
|
6237 |
function ReadableStreamBYOBRequest(controller, view) { |
|
6238 |
_classCallCheck(this, ReadableStreamBYOBRequest); |
|
6239 |
this._associatedReadableByteStreamController = controller; |
|
6240 |
this._view = view; |
|
6241 |
} |
|
6242 |
_createClass(ReadableStreamBYOBRequest, [{ |
|
6243 |
key: 'respond', |
|
6244 |
value: function respond(bytesWritten) { |
|
6245 |
if (IsReadableStreamBYOBRequest(this) === false) { |
|
6246 |
throw byobRequestBrandCheckException('respond'); |
|
6247 |
} |
|
6248 |
if (this._associatedReadableByteStreamController === undefined) { |
|
6249 |
throw new TypeError('This BYOB request has been invalidated'); |
|
6250 |
} |
|
6251 |
ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten); |
|
6252 |
} |
|
6253 |
}, { |
|
6254 |
key: 'respondWithNewView', |
|
6255 |
value: function respondWithNewView(view) { |
|
6256 |
if (IsReadableStreamBYOBRequest(this) === false) { |
|
6257 |
throw byobRequestBrandCheckException('respond'); |
|
6258 |
} |
|
6259 |
if (this._associatedReadableByteStreamController === undefined) { |
|
6260 |
throw new TypeError('This BYOB request has been invalidated'); |
|
6261 |
} |
|
6262 |
if (!ArrayBuffer.isView(view)) { |
|
6263 |
throw new TypeError('You can only respond with array buffer views'); |
|
6264 |
} |
|
6265 |
ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view); |
|
6266 |
} |
|
6267 |
}, { |
|
6268 |
key: 'view', |
|
6269 |
get: function get() { |
|
6270 |
return this._view; |
|
6271 |
} |
|
6272 |
}]); |
|
6273 |
return ReadableStreamBYOBRequest; |
|
6274 |
}(); |
|
6275 |
var ReadableByteStreamController = function () { |
|
6276 |
function ReadableByteStreamController(stream, underlyingByteSource, highWaterMark) { |
|
6277 |
_classCallCheck(this, ReadableByteStreamController); |
|
6278 |
if (IsReadableStream(stream) === false) { |
|
6279 |
throw new TypeError('ReadableByteStreamController can only be constructed with a ReadableStream instance given ' + 'a byte source'); |
|
6280 |
} |
|
6281 |
if (stream._readableStreamController !== undefined) { |
|
6282 |
throw new TypeError('ReadableByteStreamController instances can only be created by the ReadableStream constructor given a byte ' + 'source'); |
|
6283 |
} |
|
6284 |
this._controlledReadableStream = stream; |
|
6285 |
this._underlyingByteSource = underlyingByteSource; |
|
6286 |
this._pullAgain = false; |
|
6287 |
this._pulling = false; |
|
6288 |
ReadableByteStreamControllerClearPendingPullIntos(this); |
|
6289 |
this._queue = this._queueTotalSize = undefined; |
|
6290 |
ResetQueue(this); |
|
6291 |
this._closeRequested = false; |
|
6292 |
this._started = false; |
|
6293 |
this._strategyHWM = ValidateAndNormalizeHighWaterMark(highWaterMark); |
|
6294 |
var autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize; |
|
6295 |
if (autoAllocateChunkSize !== undefined) { |
|
6296 |
if (Number.isInteger(autoAllocateChunkSize) === false || autoAllocateChunkSize <= 0) { |
|
6297 |
throw new RangeError('autoAllocateChunkSize must be a positive integer'); |
|
6298 |
} |
|
6299 |
} |
|
6300 |
this._autoAllocateChunkSize = autoAllocateChunkSize; |
|
6301 |
this._pendingPullIntos = []; |
|
6302 |
var controller = this; |
|
6303 |
var startResult = InvokeOrNoop(underlyingByteSource, 'start', [this]); |
|
6304 |
Promise.resolve(startResult).then(function () { |
|
6305 |
controller._started = true; |
|
6306 |
assert(controller._pulling === false); |
|
6307 |
assert(controller._pullAgain === false); |
|
6308 |
ReadableByteStreamControllerCallPullIfNeeded(controller); |
|
6309 |
}, function (r) { |
|
6310 |
if (stream._state === 'readable') { |
|
6311 |
ReadableByteStreamControllerError(controller, r); |
|
6312 |
} |
|
6313 |
}).catch(rethrowAssertionErrorRejection); |
|
6314 |
} |
|
6315 |
_createClass(ReadableByteStreamController, [{ |
|
6316 |
key: 'close', |
|
6317 |
value: function close() { |
|
6318 |
if (IsReadableByteStreamController(this) === false) { |
|
6319 |
throw byteStreamControllerBrandCheckException('close'); |
|
6320 |
} |
|
6321 |
if (this._closeRequested === true) { |
|
6322 |
throw new TypeError('The stream has already been closed; do not close it again!'); |
|
6323 |
} |
|
6324 |
var state = this._controlledReadableStream._state; |
|
6325 |
if (state !== 'readable') { |
|
6326 |
throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be closed'); |
|
6327 |
} |
|
6328 |
ReadableByteStreamControllerClose(this); |
|
6329 |
} |
|
6330 |
}, { |
|
6331 |
key: 'enqueue', |
|
6332 |
value: function enqueue(chunk) { |
|
6333 |
if (IsReadableByteStreamController(this) === false) { |
|
6334 |
throw byteStreamControllerBrandCheckException('enqueue'); |
|
6335 |
} |
|
6336 |
if (this._closeRequested === true) { |
|
6337 |
throw new TypeError('stream is closed or draining'); |
|
6338 |
} |
|
6339 |
var state = this._controlledReadableStream._state; |
|
6340 |
if (state !== 'readable') { |
|
6341 |
throw new TypeError('The stream (in ' + state + ' state) is not in the readable state and cannot be enqueued to'); |
|
6342 |
} |
|
6343 |
if (!ArrayBuffer.isView(chunk)) { |
|
6344 |
throw new TypeError('You can only enqueue array buffer views when using a ReadableByteStreamController'); |
|
6345 |
} |
|
6346 |
ReadableByteStreamControllerEnqueue(this, chunk); |
|
6347 |
} |
|
6348 |
}, { |
|
6349 |
key: 'error', |
|
6350 |
value: function error(e) { |
|
6351 |
if (IsReadableByteStreamController(this) === false) { |
|
6352 |
throw byteStreamControllerBrandCheckException('error'); |
|
6353 |
} |
|
6354 |
var stream = this._controlledReadableStream; |
|
6355 |
if (stream._state !== 'readable') { |
|
6356 |
throw new TypeError('The stream is ' + stream._state + ' and so cannot be errored'); |
|
6357 |
} |
|
6358 |
ReadableByteStreamControllerError(this, e); |
|
6359 |
} |
|
6360 |
}, { |
|
6361 |
key: '__cancelSteps', |
|
6362 |
value: function __cancelSteps(reason) { |
|
6363 |
if (this._pendingPullIntos.length > 0) { |
|
6364 |
var firstDescriptor = this._pendingPullIntos[0]; |
|
6365 |
firstDescriptor.bytesFilled = 0; |
|
6366 |
} |
|
6367 |
ResetQueue(this); |
|
6368 |
return PromiseInvokeOrNoop(this._underlyingByteSource, 'cancel', [reason]); |
|
6369 |
} |
|
6370 |
}, { |
|
6371 |
key: '__pullSteps', |
|
6372 |
value: function __pullSteps() { |
|
6373 |
var stream = this._controlledReadableStream; |
|
6374 |
assert(ReadableStreamHasDefaultReader(stream) === true); |
|
6375 |
if (this._queueTotalSize > 0) { |
|
6376 |
assert(ReadableStreamGetNumReadRequests(stream) === 0); |
|
6377 |
var entry = this._queue.shift(); |
|
6378 |
this._queueTotalSize -= entry.byteLength; |
|
6379 |
ReadableByteStreamControllerHandleQueueDrain(this); |
|
6380 |
var view = void 0; |
|
6381 |
try { |
|
6382 |
view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength); |
|
6383 |
} catch (viewE) { |
|
6384 |
return Promise.reject(viewE); |
|
6385 |
} |
|
6386 |
return Promise.resolve(CreateIterResultObject(view, false)); |
|
6387 |
} |
|
6388 |
var autoAllocateChunkSize = this._autoAllocateChunkSize; |
|
6389 |
if (autoAllocateChunkSize !== undefined) { |
|
6390 |
var buffer = void 0; |
|
6391 |
try { |
|
6392 |
buffer = new ArrayBuffer(autoAllocateChunkSize); |
|
6393 |
} catch (bufferE) { |
|
6394 |
return Promise.reject(bufferE); |
|
6395 |
} |
|
6396 |
var pullIntoDescriptor = { |
|
6397 |
buffer: buffer, |
|
6398 |
byteOffset: 0, |
|
6399 |
byteLength: autoAllocateChunkSize, |
|
6400 |
bytesFilled: 0, |
|
6401 |
elementSize: 1, |
|
6402 |
ctor: Uint8Array, |
|
6403 |
readerType: 'default' |
|
6404 |
}; |
|
6405 |
this._pendingPullIntos.push(pullIntoDescriptor); |
|
6406 |
} |
|
6407 |
var promise = ReadableStreamAddReadRequest(stream); |
|
6408 |
ReadableByteStreamControllerCallPullIfNeeded(this); |
|
6409 |
return promise; |
|
6410 |
} |
|
6411 |
}, { |
|
6412 |
key: 'byobRequest', |
|
6413 |
get: function get() { |
|
6414 |
if (IsReadableByteStreamController(this) === false) { |
|
6415 |
throw byteStreamControllerBrandCheckException('byobRequest'); |
|
6416 |
} |
|
6417 |
if (this._byobRequest === undefined && this._pendingPullIntos.length > 0) { |
|
6418 |
var firstDescriptor = this._pendingPullIntos[0]; |
|
6419 |
var view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled); |
|
6420 |
this._byobRequest = new ReadableStreamBYOBRequest(this, view); |
|
6421 |
} |
|
6422 |
return this._byobRequest; |
|
6423 |
} |
|
6424 |
}, { |
|
6425 |
key: 'desiredSize', |
|
6426 |
get: function get() { |
|
6427 |
if (IsReadableByteStreamController(this) === false) { |
|
6428 |
throw byteStreamControllerBrandCheckException('desiredSize'); |
|
6429 |
} |
|
6430 |
return ReadableByteStreamControllerGetDesiredSize(this); |
|
6431 |
} |
|
6432 |
}]); |
|
6433 |
return ReadableByteStreamController; |
|
6434 |
}(); |
|
6435 |
function IsReadableByteStreamController(x) { |
|
6436 |
if (!typeIsObject(x)) { |
|
6437 |
return false; |
|
6438 |
} |
|
6439 |
if (!Object.prototype.hasOwnProperty.call(x, '_underlyingByteSource')) { |
|
6440 |
return false; |
|
6441 |
} |
|
6442 |
return true; |
|
6443 |
} |
|
6444 |
function IsReadableStreamBYOBRequest(x) { |
|
6445 |
if (!typeIsObject(x)) { |
|
6446 |
return false; |
|
6447 |
} |
|
6448 |
if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) { |
|
6449 |
return false; |
|
6450 |
} |
|
6451 |
return true; |
|
6452 |
} |
|
6453 |
function ReadableByteStreamControllerCallPullIfNeeded(controller) { |
|
6454 |
var shouldPull = ReadableByteStreamControllerShouldCallPull(controller); |
|
6455 |
if (shouldPull === false) { |
|
6456 |
return undefined; |
|
6457 |
} |
|
6458 |
if (controller._pulling === true) { |
|
6459 |
controller._pullAgain = true; |
|
6460 |
return undefined; |
|
6461 |
} |
|
6462 |
assert(controller._pullAgain === false); |
|
6463 |
controller._pulling = true; |
|
6464 |
var pullPromise = PromiseInvokeOrNoop(controller._underlyingByteSource, 'pull', [controller]); |
|
6465 |
pullPromise.then(function () { |
|
6466 |
controller._pulling = false; |
|
6467 |
if (controller._pullAgain === true) { |
|
6468 |
controller._pullAgain = false; |
|
6469 |
ReadableByteStreamControllerCallPullIfNeeded(controller); |
|
6470 |
} |
|
6471 |
}, function (e) { |
|
6472 |
if (controller._controlledReadableStream._state === 'readable') { |
|
6473 |
ReadableByteStreamControllerError(controller, e); |
|
6474 |
} |
|
6475 |
}).catch(rethrowAssertionErrorRejection); |
|
6476 |
return undefined; |
|
6477 |
} |
|
6478 |
function ReadableByteStreamControllerClearPendingPullIntos(controller) { |
|
6479 |
ReadableByteStreamControllerInvalidateBYOBRequest(controller); |
|
6480 |
controller._pendingPullIntos = []; |
|
6481 |
} |
|
6482 |
function ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor) { |
|
6483 |
assert(stream._state !== 'errored', 'state must not be errored'); |
|
6484 |
var done = false; |
|
6485 |
if (stream._state === 'closed') { |
|
6486 |
assert(pullIntoDescriptor.bytesFilled === 0); |
|
6487 |
done = true; |
|
6488 |
} |
|
6489 |
var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor); |
|
6490 |
if (pullIntoDescriptor.readerType === 'default') { |
|
6491 |
ReadableStreamFulfillReadRequest(stream, filledView, done); |
|
6492 |
} else { |
|
6493 |
assert(pullIntoDescriptor.readerType === 'byob'); |
|
6494 |
ReadableStreamFulfillReadIntoRequest(stream, filledView, done); |
|
6495 |
} |
|
6496 |
} |
|
6497 |
function ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor) { |
|
6498 |
var bytesFilled = pullIntoDescriptor.bytesFilled; |
|
6499 |
var elementSize = pullIntoDescriptor.elementSize; |
|
6500 |
assert(bytesFilled <= pullIntoDescriptor.byteLength); |
|
6501 |
assert(bytesFilled % elementSize === 0); |
|
6502 |
return new pullIntoDescriptor.ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize); |
|
6503 |
} |
|
6504 |
function ReadableByteStreamControllerEnqueueChunkToQueue(controller, buffer, byteOffset, byteLength) { |
|
6505 |
controller._queue.push({ |
|
6506 |
buffer: buffer, |
|
6507 |
byteOffset: byteOffset, |
|
6508 |
byteLength: byteLength |
|
6509 |
}); |
|
6510 |
controller._queueTotalSize += byteLength; |
|
6511 |
} |
|
6512 |
function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) { |
|
6513 |
var elementSize = pullIntoDescriptor.elementSize; |
|
6514 |
var currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize; |
|
6515 |
var maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled); |
|
6516 |
var maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy; |
|
6517 |
var maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize; |
|
6518 |
var totalBytesToCopyRemaining = maxBytesToCopy; |
|
6519 |
var ready = false; |
|
6520 |
if (maxAlignedBytes > currentAlignedBytes) { |
|
6521 |
totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled; |
|
6522 |
ready = true; |
|
6523 |
} |
|
6524 |
var queue = controller._queue; |
|
6525 |
while (totalBytesToCopyRemaining > 0) { |
|
6526 |
var headOfQueue = queue[0]; |
|
6527 |
var bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength); |
|
6528 |
var destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled; |
|
6529 |
ArrayBufferCopy(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy); |
|
6530 |
if (headOfQueue.byteLength === bytesToCopy) { |
|
6531 |
queue.shift(); |
|
6532 |
} else { |
|
6533 |
headOfQueue.byteOffset += bytesToCopy; |
|
6534 |
headOfQueue.byteLength -= bytesToCopy; |
|
6535 |
} |
|
6536 |
controller._queueTotalSize -= bytesToCopy; |
|
6537 |
ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor); |
|
6538 |
totalBytesToCopyRemaining -= bytesToCopy; |
|
6539 |
} |
|
6540 |
if (ready === false) { |
|
6541 |
assert(controller._queueTotalSize === 0, 'queue must be empty'); |
|
6542 |
assert(pullIntoDescriptor.bytesFilled > 0); |
|
6543 |
assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize); |
|
6544 |
} |
|
6545 |
return ready; |
|
6546 |
} |
|
6547 |
function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, size, pullIntoDescriptor) { |
|
6548 |
assert(controller._pendingPullIntos.length === 0 || controller._pendingPullIntos[0] === pullIntoDescriptor); |
|
6549 |
ReadableByteStreamControllerInvalidateBYOBRequest(controller); |
|
6550 |
pullIntoDescriptor.bytesFilled += size; |
|
6551 |
} |
|
6552 |
function ReadableByteStreamControllerHandleQueueDrain(controller) { |
|
6553 |
assert(controller._controlledReadableStream._state === 'readable'); |
|
6554 |
if (controller._queueTotalSize === 0 && controller._closeRequested === true) { |
|
6555 |
ReadableStreamClose(controller._controlledReadableStream); |
|
6556 |
} else { |
|
6557 |
ReadableByteStreamControllerCallPullIfNeeded(controller); |
|
6558 |
} |
|
6559 |
} |
|
6560 |
function ReadableByteStreamControllerInvalidateBYOBRequest(controller) { |
|
6561 |
if (controller._byobRequest === undefined) { |
|
6562 |
return; |
|
6563 |
} |
|
6564 |
controller._byobRequest._associatedReadableByteStreamController = undefined; |
|
6565 |
controller._byobRequest._view = undefined; |
|
6566 |
controller._byobRequest = undefined; |
|
6567 |
} |
|
6568 |
function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller) { |
|
6569 |
assert(controller._closeRequested === false); |
|
6570 |
while (controller._pendingPullIntos.length > 0) { |
|
6571 |
if (controller._queueTotalSize === 0) { |
|
6572 |
return; |
|
6573 |
} |
|
6574 |
var pullIntoDescriptor = controller._pendingPullIntos[0]; |
|
6575 |
if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) { |
|
6576 |
ReadableByteStreamControllerShiftPendingPullInto(controller); |
|
6577 |
ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor); |
|
6578 |
} |
|
6579 |
} |
|
6580 |
} |
|
6581 |
function ReadableByteStreamControllerPullInto(controller, view) { |
|
6582 |
var stream = controller._controlledReadableStream; |
|
6583 |
var elementSize = 1; |
|
6584 |
if (view.constructor !== DataView) { |
|
6585 |
elementSize = view.constructor.BYTES_PER_ELEMENT; |
|
6586 |
} |
|
6587 |
var ctor = view.constructor; |
|
6588 |
var pullIntoDescriptor = { |
|
6589 |
buffer: view.buffer, |
|
6590 |
byteOffset: view.byteOffset, |
|
6591 |
byteLength: view.byteLength, |
|
6592 |
bytesFilled: 0, |
|
6593 |
elementSize: elementSize, |
|
6594 |
ctor: ctor, |
|
6595 |
readerType: 'byob' |
|
6596 |
}; |
|
6597 |
if (controller._pendingPullIntos.length > 0) { |
|
6598 |
pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer); |
|
6599 |
controller._pendingPullIntos.push(pullIntoDescriptor); |
|
6600 |
return ReadableStreamAddReadIntoRequest(stream); |
|
6601 |
} |
|
6602 |
if (stream._state === 'closed') { |
|
6603 |
var emptyView = new view.constructor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0); |
|
6604 |
return Promise.resolve(CreateIterResultObject(emptyView, true)); |
|
6605 |
} |
|
6606 |
if (controller._queueTotalSize > 0) { |
|
6607 |
if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor) === true) { |
|
6608 |
var filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor); |
|
6609 |
ReadableByteStreamControllerHandleQueueDrain(controller); |
|
6610 |
return Promise.resolve(CreateIterResultObject(filledView, false)); |
|
6611 |
} |
|
6612 |
if (controller._closeRequested === true) { |
|
6613 |
var e = new TypeError('Insufficient bytes to fill elements in the given buffer'); |
|
6614 |
ReadableByteStreamControllerError(controller, e); |
|
6615 |
return Promise.reject(e); |
|
6616 |
} |
|
6617 |
} |
|
6618 |
pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer); |
|
6619 |
controller._pendingPullIntos.push(pullIntoDescriptor); |
|
6620 |
var promise = ReadableStreamAddReadIntoRequest(stream); |
|
6621 |
ReadableByteStreamControllerCallPullIfNeeded(controller); |
|
6622 |
return promise; |
|
6623 |
} |
|
6624 |
function ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor) { |
|
6625 |
firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer); |
|
6626 |
assert(firstDescriptor.bytesFilled === 0, 'bytesFilled must be 0'); |
|
6627 |
var stream = controller._controlledReadableStream; |
|
6628 |
if (ReadableStreamHasBYOBReader(stream) === true) { |
|
6629 |
while (ReadableStreamGetNumReadIntoRequests(stream) > 0) { |
|
6630 |
var pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller); |
|
6631 |
ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor); |
|
6632 |
} |
|
6633 |
} |
|
6634 |
} |
|
6635 |
function ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, pullIntoDescriptor) { |
|
6636 |
if (pullIntoDescriptor.bytesFilled + bytesWritten > pullIntoDescriptor.byteLength) { |
|
6637 |
throw new RangeError('bytesWritten out of range'); |
|
6638 |
} |
|
6639 |
ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor); |
|
6640 |
if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) { |
|
6641 |
return; |
|
6642 |
} |
|
6643 |
ReadableByteStreamControllerShiftPendingPullInto(controller); |
|
6644 |
var remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize; |
|
6645 |
if (remainderSize > 0) { |
|
6646 |
var end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled; |
|
6647 |
var remainder = pullIntoDescriptor.buffer.slice(end - remainderSize, end); |
|
6648 |
ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength); |
|
6649 |
} |
|
6650 |
pullIntoDescriptor.buffer = TransferArrayBuffer(pullIntoDescriptor.buffer); |
|
6651 |
pullIntoDescriptor.bytesFilled -= remainderSize; |
|
6652 |
ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableStream, pullIntoDescriptor); |
|
6653 |
ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller); |
|
6654 |
} |
|
6655 |
function ReadableByteStreamControllerRespondInternal(controller, bytesWritten) { |
|
6656 |
var firstDescriptor = controller._pendingPullIntos[0]; |
|
6657 |
var stream = controller._controlledReadableStream; |
|
6658 |
if (stream._state === 'closed') { |
|
6659 |
if (bytesWritten !== 0) { |
|
6660 |
throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream'); |
|
6661 |
} |
|
6662 |
ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor); |
|
6663 |
} else { |
|
6664 |
assert(stream._state === 'readable'); |
|
6665 |
ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor); |
|
6666 |
} |
|
6667 |
} |
|
6668 |
function ReadableByteStreamControllerShiftPendingPullInto(controller) { |
|
6669 |
var descriptor = controller._pendingPullIntos.shift(); |
|
6670 |
ReadableByteStreamControllerInvalidateBYOBRequest(controller); |
|
6671 |
return descriptor; |
|
6672 |
} |
|
6673 |
function ReadableByteStreamControllerShouldCallPull(controller) { |
|
6674 |
var stream = controller._controlledReadableStream; |
|
6675 |
if (stream._state !== 'readable') { |
|
6676 |
return false; |
|
6677 |
} |
|
6678 |
if (controller._closeRequested === true) { |
|
6679 |
return false; |
|
6680 |
} |
|
6681 |
if (controller._started === false) { |
|
6682 |
return false; |
|
6683 |
} |
|
6684 |
if (ReadableStreamHasDefaultReader(stream) === true && ReadableStreamGetNumReadRequests(stream) > 0) { |
|
6685 |
return true; |
|
6686 |
} |
|
6687 |
if (ReadableStreamHasBYOBReader(stream) === true && ReadableStreamGetNumReadIntoRequests(stream) > 0) { |
|
6688 |
return true; |
|
6689 |
} |
|
6690 |
if (ReadableByteStreamControllerGetDesiredSize(controller) > 0) { |
|
6691 |
return true; |
|
6692 |
} |
|
6693 |
return false; |
|
6694 |
} |
|
6695 |
function ReadableByteStreamControllerClose(controller) { |
|
6696 |
var stream = controller._controlledReadableStream; |
|
6697 |
assert(controller._closeRequested === false); |
|
6698 |
assert(stream._state === 'readable'); |
|
6699 |
if (controller._queueTotalSize > 0) { |
|
6700 |
controller._closeRequested = true; |
|
6701 |
return; |
|
6702 |
} |
|
6703 |
if (controller._pendingPullIntos.length > 0) { |
|
6704 |
var firstPendingPullInto = controller._pendingPullIntos[0]; |
|
6705 |
if (firstPendingPullInto.bytesFilled > 0) { |
|
6706 |
var e = new TypeError('Insufficient bytes to fill elements in the given buffer'); |
|
6707 |
ReadableByteStreamControllerError(controller, e); |
|
6708 |
throw e; |
|
6709 |
} |
|
6710 |
} |
|
6711 |
ReadableStreamClose(stream); |
|
6712 |
} |
|
6713 |
function ReadableByteStreamControllerEnqueue(controller, chunk) { |
|
6714 |
var stream = controller._controlledReadableStream; |
|
6715 |
assert(controller._closeRequested === false); |
|
6716 |
assert(stream._state === 'readable'); |
|
6717 |
var buffer = chunk.buffer; |
|
6718 |
var byteOffset = chunk.byteOffset; |
|
6719 |
var byteLength = chunk.byteLength; |
|
6720 |
var transferredBuffer = TransferArrayBuffer(buffer); |
|
6721 |
if (ReadableStreamHasDefaultReader(stream) === true) { |
|
6722 |
if (ReadableStreamGetNumReadRequests(stream) === 0) { |
|
6723 |
ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength); |
|
6724 |
} else { |
|
6725 |
assert(controller._queue.length === 0); |
|
6726 |
var transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength); |
|
6727 |
ReadableStreamFulfillReadRequest(stream, transferredView, false); |
|
6728 |
} |
|
6729 |
} else if (ReadableStreamHasBYOBReader(stream) === true) { |
|
6730 |
ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength); |
|
6731 |
ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller); |
|
6732 |
} else { |
|
6733 |
assert(IsReadableStreamLocked(stream) === false, 'stream must not be locked'); |
|
6734 |
ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength); |
|
6735 |
} |
|
6736 |
} |
|
6737 |
function ReadableByteStreamControllerError(controller, e) { |
|
6738 |
var stream = controller._controlledReadableStream; |
|
6739 |
assert(stream._state === 'readable'); |
|
6740 |
ReadableByteStreamControllerClearPendingPullIntos(controller); |
|
6741 |
ResetQueue(controller); |
|
6742 |
ReadableStreamError(stream, e); |
|
6743 |
} |
|
6744 |
function ReadableByteStreamControllerGetDesiredSize(controller) { |
|
6745 |
var stream = controller._controlledReadableStream; |
|
6746 |
var state = stream._state; |
|
6747 |
if (state === 'errored') { |
|
6748 |
return null; |
|
6749 |
} |
|
6750 |
if (state === 'closed') { |
|
6751 |
return 0; |
|
6752 |
} |
|
6753 |
return controller._strategyHWM - controller._queueTotalSize; |
|
6754 |
} |
|
6755 |
function ReadableByteStreamControllerRespond(controller, bytesWritten) { |
|
6756 |
bytesWritten = Number(bytesWritten); |
|
6757 |
if (IsFiniteNonNegativeNumber(bytesWritten) === false) { |
|
6758 |
throw new RangeError('bytesWritten must be a finite'); |
|
6759 |
} |
|
6760 |
assert(controller._pendingPullIntos.length > 0); |
|
6761 |
ReadableByteStreamControllerRespondInternal(controller, bytesWritten); |
|
6762 |
} |
|
6763 |
function ReadableByteStreamControllerRespondWithNewView(controller, view) { |
|
6764 |
assert(controller._pendingPullIntos.length > 0); |
|
6765 |
var firstDescriptor = controller._pendingPullIntos[0]; |
|
6766 |
if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) { |
|
6767 |
throw new RangeError('The region specified by view does not match byobRequest'); |
|
6768 |
} |
|
6769 |
if (firstDescriptor.byteLength !== view.byteLength) { |
|
6770 |
throw new RangeError('The buffer of view has different capacity than byobRequest'); |
|
6771 |
} |
|
6772 |
firstDescriptor.buffer = view.buffer; |
|
6773 |
ReadableByteStreamControllerRespondInternal(controller, view.byteLength); |
|
6774 |
} |
|
6775 |
function streamBrandCheckException(name) { |
|
6776 |
return new TypeError('ReadableStream.prototype.' + name + ' can only be used on a ReadableStream'); |
|
6777 |
} |
|
6778 |
function readerLockException(name) { |
|
6779 |
return new TypeError('Cannot ' + name + ' a stream using a released reader'); |
|
6780 |
} |
|
6781 |
function defaultReaderBrandCheckException(name) { |
|
6782 |
return new TypeError('ReadableStreamDefaultReader.prototype.' + name + ' can only be used on a ReadableStreamDefaultReader'); |
|
6783 |
} |
|
6784 |
function defaultReaderClosedPromiseInitialize(reader) { |
|
6785 |
reader._closedPromise = new Promise(function (resolve, reject) { |
|
6786 |
reader._closedPromise_resolve = resolve; |
|
6787 |
reader._closedPromise_reject = reject; |
|
6788 |
}); |
|
6789 |
} |
|
6790 |
function defaultReaderClosedPromiseInitializeAsRejected(reader, reason) { |
|
6791 |
reader._closedPromise = Promise.reject(reason); |
|
6792 |
reader._closedPromise_resolve = undefined; |
|
6793 |
reader._closedPromise_reject = undefined; |
|
6794 |
} |
|
6795 |
function defaultReaderClosedPromiseInitializeAsResolved(reader) { |
|
6796 |
reader._closedPromise = Promise.resolve(undefined); |
|
6797 |
reader._closedPromise_resolve = undefined; |
|
6798 |
reader._closedPromise_reject = undefined; |
|
6799 |
} |
|
6800 |
function defaultReaderClosedPromiseReject(reader, reason) { |
|
6801 |
assert(reader._closedPromise_resolve !== undefined); |
|
6802 |
assert(reader._closedPromise_reject !== undefined); |
|
6803 |
reader._closedPromise_reject(reason); |
|
6804 |
reader._closedPromise_resolve = undefined; |
|
6805 |
reader._closedPromise_reject = undefined; |
|
6806 |
} |
|
6807 |
function defaultReaderClosedPromiseResetToRejected(reader, reason) { |
|
6808 |
assert(reader._closedPromise_resolve === undefined); |
|
6809 |
assert(reader._closedPromise_reject === undefined); |
|
6810 |
reader._closedPromise = Promise.reject(reason); |
|
6811 |
} |
|
6812 |
function defaultReaderClosedPromiseResolve(reader) { |
|
6813 |
assert(reader._closedPromise_resolve !== undefined); |
|
6814 |
assert(reader._closedPromise_reject !== undefined); |
|
6815 |
reader._closedPromise_resolve(undefined); |
|
6816 |
reader._closedPromise_resolve = undefined; |
|
6817 |
reader._closedPromise_reject = undefined; |
|
6818 |
} |
|
6819 |
function byobReaderBrandCheckException(name) { |
|
6820 |
return new TypeError('ReadableStreamBYOBReader.prototype.' + name + ' can only be used on a ReadableStreamBYOBReader'); |
|
6821 |
} |
|
6822 |
function defaultControllerBrandCheckException(name) { |
|
6823 |
return new TypeError('ReadableStreamDefaultController.prototype.' + name + ' can only be used on a ReadableStreamDefaultController'); |
|
6824 |
} |
|
6825 |
function byobRequestBrandCheckException(name) { |
|
6826 |
return new TypeError('ReadableStreamBYOBRequest.prototype.' + name + ' can only be used on a ReadableStreamBYOBRequest'); |
|
6827 |
} |
|
6828 |
function byteStreamControllerBrandCheckException(name) { |
|
6829 |
return new TypeError('ReadableByteStreamController.prototype.' + name + ' can only be used on a ReadableByteStreamController'); |
|
6830 |
} |
|
6831 |
function ifIsObjectAndHasAPromiseIsHandledInternalSlotSetPromiseIsHandledToTrue(promise) { |
|
6832 |
try { |
|
6833 |
Promise.prototype.then.call(promise, undefined, function () {}); |
|
6834 |
} catch (e) {} |
|
6835 |
} |
|
6836 |
}, function (module, exports, __w_pdfjs_require__) { |
|
6837 |
"use strict"; |
|
6838 |
|
|
6839 |
var transformStream = __w_pdfjs_require__(6); |
|
6840 |
var readableStream = __w_pdfjs_require__(4); |
|
6841 |
var writableStream = __w_pdfjs_require__(2); |
|
6842 |
exports.TransformStream = transformStream.TransformStream; |
|
6843 |
exports.ReadableStream = readableStream.ReadableStream; |
|
6844 |
exports.IsReadableStreamDisturbed = readableStream.IsReadableStreamDisturbed; |
|
6845 |
exports.ReadableStreamDefaultControllerClose = readableStream.ReadableStreamDefaultControllerClose; |
|
6846 |
exports.ReadableStreamDefaultControllerEnqueue = readableStream.ReadableStreamDefaultControllerEnqueue; |
|
6847 |
exports.ReadableStreamDefaultControllerError = readableStream.ReadableStreamDefaultControllerError; |
|
6848 |
exports.ReadableStreamDefaultControllerGetDesiredSize = readableStream.ReadableStreamDefaultControllerGetDesiredSize; |
|
6849 |
exports.AcquireWritableStreamDefaultWriter = writableStream.AcquireWritableStreamDefaultWriter; |
|
6850 |
exports.IsWritableStream = writableStream.IsWritableStream; |
|
6851 |
exports.IsWritableStreamLocked = writableStream.IsWritableStreamLocked; |
|
6852 |
exports.WritableStream = writableStream.WritableStream; |
|
6853 |
exports.WritableStreamAbort = writableStream.WritableStreamAbort; |
|
6854 |
exports.WritableStreamDefaultControllerError = writableStream.WritableStreamDefaultControllerError; |
|
6855 |
exports.WritableStreamDefaultWriterCloseWithErrorPropagation = writableStream.WritableStreamDefaultWriterCloseWithErrorPropagation; |
|
6856 |
exports.WritableStreamDefaultWriterRelease = writableStream.WritableStreamDefaultWriterRelease; |
|
6857 |
exports.WritableStreamDefaultWriterWrite = writableStream.WritableStreamDefaultWriterWrite; |
|
6858 |
}, function (module, exports, __w_pdfjs_require__) { |
|
6859 |
"use strict"; |
|
6860 |
|
|
6861 |
var _createClass = function () { |
|
6862 |
function defineProperties(target, props) { |
|
6863 |
for (var i = 0; i < props.length; i++) { |
|
6864 |
var descriptor = props[i]; |
|
6865 |
descriptor.enumerable = descriptor.enumerable || false; |
|
6866 |
descriptor.configurable = true; |
|
6867 |
if ("value" in descriptor) descriptor.writable = true; |
|
6868 |
Object.defineProperty(target, descriptor.key, descriptor); |
|
6869 |
} |
|
6870 |
} |
|
6871 |
return function (Constructor, protoProps, staticProps) { |
|
6872 |
if (protoProps) defineProperties(Constructor.prototype, protoProps); |
|
6873 |
if (staticProps) defineProperties(Constructor, staticProps); |
|
6874 |
return Constructor; |
|
6875 |
}; |
|
6876 |
}(); |
|
6877 |
function _classCallCheck(instance, Constructor) { |
|
6878 |
if (!(instance instanceof Constructor)) { |
|
6879 |
throw new TypeError("Cannot call a class as a function"); |
|
6880 |
} |
|
6881 |
} |
|
6882 |
var _require = __w_pdfjs_require__(1), |
|
6883 |
assert = _require.assert; |
|
6884 |
var _require2 = __w_pdfjs_require__(0), |
|
6885 |
InvokeOrNoop = _require2.InvokeOrNoop, |
|
6886 |
PromiseInvokeOrPerformFallback = _require2.PromiseInvokeOrPerformFallback, |
|
6887 |
PromiseInvokeOrNoop = _require2.PromiseInvokeOrNoop, |
|
6888 |
typeIsObject = _require2.typeIsObject; |
|
6889 |
var _require3 = __w_pdfjs_require__(4), |
|
6890 |
ReadableStream = _require3.ReadableStream, |
|
6891 |
ReadableStreamDefaultControllerClose = _require3.ReadableStreamDefaultControllerClose, |
|
6892 |
ReadableStreamDefaultControllerEnqueue = _require3.ReadableStreamDefaultControllerEnqueue, |
|
6893 |
ReadableStreamDefaultControllerError = _require3.ReadableStreamDefaultControllerError, |
|
6894 |
ReadableStreamDefaultControllerGetDesiredSize = _require3.ReadableStreamDefaultControllerGetDesiredSize; |
|
6895 |
var _require4 = __w_pdfjs_require__(2), |
|
6896 |
WritableStream = _require4.WritableStream, |
|
6897 |
WritableStreamDefaultControllerError = _require4.WritableStreamDefaultControllerError; |
|
6898 |
function TransformStreamCloseReadable(transformStream) { |
|
6899 |
if (transformStream._errored === true) { |
|
6900 |
throw new TypeError('TransformStream is already errored'); |
|
6901 |
} |
|
6902 |
if (transformStream._readableClosed === true) { |
|
6903 |
throw new TypeError('Readable side is already closed'); |
|
6904 |
} |
|
6905 |
TransformStreamCloseReadableInternal(transformStream); |
|
6906 |
} |
|
6907 |
function TransformStreamEnqueueToReadable(transformStream, chunk) { |
|
6908 |
if (transformStream._errored === true) { |
|
6909 |
throw new TypeError('TransformStream is already errored'); |
|
6910 |
} |
|
6911 |
if (transformStream._readableClosed === true) { |
|
6912 |
throw new TypeError('Readable side is already closed'); |
|
6913 |
} |
|
6914 |
var controller = transformStream._readableController; |
|
6915 |
try { |
|
6916 |
ReadableStreamDefaultControllerEnqueue(controller, chunk); |
|
6917 |
} catch (e) { |
|
6918 |
transformStream._readableClosed = true; |
|
6919 |
TransformStreamErrorIfNeeded(transformStream, e); |
|
6920 |
throw transformStream._storedError; |
|
6921 |
} |
|
6922 |
var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller); |
|
6923 |
var maybeBackpressure = desiredSize <= 0; |
|
6924 |
if (maybeBackpressure === true && transformStream._backpressure === false) { |
|
6925 |
TransformStreamSetBackpressure(transformStream, true); |
|
6926 |
} |
|
6927 |
} |
|
6928 |
function TransformStreamError(transformStream, e) { |
|
6929 |
if (transformStream._errored === true) { |
|
6930 |
throw new TypeError('TransformStream is already errored'); |
|
6931 |
} |
|
6932 |
TransformStreamErrorInternal(transformStream, e); |
|
6933 |
} |
|
6934 |
function TransformStreamCloseReadableInternal(transformStream) { |
|
6935 |
assert(transformStream._errored === false); |
|
6936 |
assert(transformStream._readableClosed === false); |
|
6937 |
try { |
|
6938 |
ReadableStreamDefaultControllerClose(transformStream._readableController); |
|
6939 |
} catch (e) { |
|
6940 |
assert(false); |
|
6941 |
} |
|
6942 |
transformStream._readableClosed = true; |
|
6943 |
} |
|
6944 |
function TransformStreamErrorIfNeeded(transformStream, e) { |
|
6945 |
if (transformStream._errored === false) { |
|
6946 |
TransformStreamErrorInternal(transformStream, e); |
|
6947 |
} |
|
6948 |
} |
|
6949 |
function TransformStreamErrorInternal(transformStream, e) { |
|
6950 |
assert(transformStream._errored === false); |
|
6951 |
transformStream._errored = true; |
|
6952 |
transformStream._storedError = e; |
|
6953 |
if (transformStream._writableDone === false) { |
|
6954 |
WritableStreamDefaultControllerError(transformStream._writableController, e); |
|
6955 |
} |
|
6956 |
if (transformStream._readableClosed === false) { |
|
6957 |
ReadableStreamDefaultControllerError(transformStream._readableController, e); |
|
6958 |
} |
|
6959 |
} |
|
6960 |
function TransformStreamReadableReadyPromise(transformStream) { |
|
6961 |
assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized'); |
|
6962 |
if (transformStream._backpressure === false) { |
|
6963 |
return Promise.resolve(); |
|
6964 |
} |
|
6965 |
assert(transformStream._backpressure === true, '_backpressure should have been initialized'); |
|
6966 |
return transformStream._backpressureChangePromise; |
|
6967 |
} |
|
6968 |
function TransformStreamSetBackpressure(transformStream, backpressure) { |
|
6969 |
assert(transformStream._backpressure !== backpressure, 'TransformStreamSetBackpressure() should be called only when backpressure is changed'); |
|
6970 |
if (transformStream._backpressureChangePromise !== undefined) { |
|
6971 |
transformStream._backpressureChangePromise_resolve(backpressure); |
|
6972 |
} |
|
6973 |
transformStream._backpressureChangePromise = new Promise(function (resolve) { |
|
6974 |
transformStream._backpressureChangePromise_resolve = resolve; |
|
6975 |
}); |
|
6976 |
transformStream._backpressureChangePromise.then(function (resolution) { |
|
6977 |
assert(resolution !== backpressure, '_backpressureChangePromise should be fulfilled only when backpressure is changed'); |
|
6978 |
}); |
|
6979 |
transformStream._backpressure = backpressure; |
|
6980 |
} |
|
6981 |
function TransformStreamDefaultTransform(chunk, transformStreamController) { |
|
6982 |
var transformStream = transformStreamController._controlledTransformStream; |
|
6983 |
TransformStreamEnqueueToReadable(transformStream, chunk); |
|
6984 |
return Promise.resolve(); |
|
6985 |
} |
|
6986 |
function TransformStreamTransform(transformStream, chunk) { |
|
6987 |
assert(transformStream._errored === false); |
|
6988 |
assert(transformStream._transforming === false); |
|
6989 |
assert(transformStream._backpressure === false); |
|
6990 |
transformStream._transforming = true; |
|
6991 |
var transformer = transformStream._transformer; |
|
6992 |
var controller = transformStream._transformStreamController; |
|
6993 |
var transformPromise = PromiseInvokeOrPerformFallback(transformer, 'transform', [chunk, controller], TransformStreamDefaultTransform, [chunk, controller]); |
|
6994 |
return transformPromise.then(function () { |
|
6995 |
transformStream._transforming = false; |
|
6996 |
return TransformStreamReadableReadyPromise(transformStream); |
|
6997 |
}, function (e) { |
|
6998 |
TransformStreamErrorIfNeeded(transformStream, e); |
|
6999 |
return Promise.reject(e); |
|
7000 |
}); |
|
7001 |
} |
|
7002 |
function IsTransformStreamDefaultController(x) { |
|
7003 |
if (!typeIsObject(x)) { |
|
7004 |
return false; |
|
7005 |
} |
|
7006 |
if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) { |
|
7007 |
return false; |
|
7008 |
} |
|
7009 |
return true; |
|
7010 |
} |
|
7011 |
function IsTransformStream(x) { |
|
7012 |
if (!typeIsObject(x)) { |
|
7013 |
return false; |
|
7014 |
} |
|
7015 |
if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) { |
|
7016 |
return false; |
|
7017 |
} |
|
7018 |
return true; |
|
7019 |
} |
|
7020 |
var TransformStreamSink = function () { |
|
7021 |
function TransformStreamSink(transformStream, startPromise) { |
|
7022 |
_classCallCheck(this, TransformStreamSink); |
|
7023 |
this._transformStream = transformStream; |
|
7024 |
this._startPromise = startPromise; |
|
7025 |
} |
|
7026 |
_createClass(TransformStreamSink, [{ |
|
7027 |
key: 'start', |
|
7028 |
value: function start(c) { |
|
7029 |
var transformStream = this._transformStream; |
|
7030 |
transformStream._writableController = c; |
|
7031 |
return this._startPromise.then(function () { |
|
7032 |
return TransformStreamReadableReadyPromise(transformStream); |
|
7033 |
}); |
|
7034 |
} |
|
7035 |
}, { |
|
7036 |
key: 'write', |
|
7037 |
value: function write(chunk) { |
|
7038 |
var transformStream = this._transformStream; |
|
7039 |
return TransformStreamTransform(transformStream, chunk); |
|
7040 |
} |
|
7041 |
}, { |
|
7042 |
key: 'abort', |
|
7043 |
value: function abort() { |
|
7044 |
var transformStream = this._transformStream; |
|
7045 |
transformStream._writableDone = true; |
|
7046 |
TransformStreamErrorInternal(transformStream, new TypeError('Writable side aborted')); |
|
7047 |
} |
|
7048 |
}, { |
|
7049 |
key: 'close', |
|
7050 |
value: function close() { |
|
7051 |
var transformStream = this._transformStream; |
|
7052 |
assert(transformStream._transforming === false); |
|
7053 |
transformStream._writableDone = true; |
|
7054 |
var flushPromise = PromiseInvokeOrNoop(transformStream._transformer, 'flush', [transformStream._transformStreamController]); |
|
7055 |
return flushPromise.then(function () { |
|
7056 |
if (transformStream._errored === true) { |
|
7057 |
return Promise.reject(transformStream._storedError); |
|
7058 |
} |
|
7059 |
if (transformStream._readableClosed === false) { |
|
7060 |
TransformStreamCloseReadableInternal(transformStream); |
|
7061 |
} |
|
7062 |
return Promise.resolve(); |
|
7063 |
}).catch(function (r) { |
|
7064 |
TransformStreamErrorIfNeeded(transformStream, r); |
|
7065 |
return Promise.reject(transformStream._storedError); |
|
7066 |
}); |
|
7067 |
} |
|
7068 |
}]); |
|
7069 |
return TransformStreamSink; |
|
7070 |
}(); |
|
7071 |
var TransformStreamSource = function () { |
|
7072 |
function TransformStreamSource(transformStream, startPromise) { |
|
7073 |
_classCallCheck(this, TransformStreamSource); |
|
7074 |
this._transformStream = transformStream; |
|
7075 |
this._startPromise = startPromise; |
|
7076 |
} |
|
7077 |
_createClass(TransformStreamSource, [{ |
|
7078 |
key: 'start', |
|
7079 |
value: function start(c) { |
|
7080 |
var transformStream = this._transformStream; |
|
7081 |
transformStream._readableController = c; |
|
7082 |
return this._startPromise.then(function () { |
|
7083 |
assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized'); |
|
7084 |
if (transformStream._backpressure === true) { |
|
7085 |
return Promise.resolve(); |
|
7086 |
} |
|
7087 |
assert(transformStream._backpressure === false, '_backpressure should have been initialized'); |
|
7088 |
return transformStream._backpressureChangePromise; |
|
7089 |
}); |
|
7090 |
} |
|
7091 |
}, { |
|
7092 |
key: 'pull', |
|
7093 |
value: function pull() { |
|
7094 |
var transformStream = this._transformStream; |
|
7095 |
assert(transformStream._backpressure === true, 'pull() should be never called while _backpressure is false'); |
|
7096 |
assert(transformStream._backpressureChangePromise !== undefined, '_backpressureChangePromise should have been initialized'); |
|
7097 |
TransformStreamSetBackpressure(transformStream, false); |
|
7098 |
return transformStream._backpressureChangePromise; |
|
7099 |
} |
|
7100 |
}, { |
|
7101 |
key: 'cancel', |
|
7102 |
value: function cancel() { |
|
7103 |
var transformStream = this._transformStream; |
|
7104 |
transformStream._readableClosed = true; |
|
7105 |
TransformStreamErrorInternal(transformStream, new TypeError('Readable side canceled')); |
|
7106 |
} |
|
7107 |
}]); |
|
7108 |
return TransformStreamSource; |
|
7109 |
}(); |
|
7110 |
var TransformStreamDefaultController = function () { |
|
7111 |
function TransformStreamDefaultController(transformStream) { |
|
7112 |
_classCallCheck(this, TransformStreamDefaultController); |
|
7113 |
if (IsTransformStream(transformStream) === false) { |
|
7114 |
throw new TypeError('TransformStreamDefaultController can only be ' + 'constructed with a TransformStream instance'); |
|
7115 |
} |
|
7116 |
if (transformStream._transformStreamController !== undefined) { |
|
7117 |
throw new TypeError('TransformStreamDefaultController instances can ' + 'only be created by the TransformStream constructor'); |
|
7118 |
} |
|
7119 |
this._controlledTransformStream = transformStream; |
|
7120 |
} |
|
7121 |
_createClass(TransformStreamDefaultController, [{ |
|
7122 |
key: 'enqueue', |
|
7123 |
value: function enqueue(chunk) { |
|
7124 |
if (IsTransformStreamDefaultController(this) === false) { |
|
7125 |
throw defaultControllerBrandCheckException('enqueue'); |
|
7126 |
} |
|
7127 |
TransformStreamEnqueueToReadable(this._controlledTransformStream, chunk); |
|
7128 |
} |
|
7129 |
}, { |
|
7130 |
key: 'close', |
|
7131 |
value: function close() { |
|
7132 |
if (IsTransformStreamDefaultController(this) === false) { |
|
7133 |
throw defaultControllerBrandCheckException('close'); |
|
7134 |
} |
|
7135 |
TransformStreamCloseReadable(this._controlledTransformStream); |
|
7136 |
} |
|
7137 |
}, { |
|
7138 |
key: 'error', |
|
7139 |
value: function error(reason) { |
|
7140 |
if (IsTransformStreamDefaultController(this) === false) { |
|
7141 |
throw defaultControllerBrandCheckException('error'); |
|
7142 |
} |
|
7143 |
TransformStreamError(this._controlledTransformStream, reason); |
|
7144 |
} |
|
7145 |
}, { |
|
7146 |
key: 'desiredSize', |
|
7147 |
get: function get() { |
|
7148 |
if (IsTransformStreamDefaultController(this) === false) { |
|
7149 |
throw defaultControllerBrandCheckException('desiredSize'); |
|
7150 |
} |
|
7151 |
var transformStream = this._controlledTransformStream; |
|
7152 |
var readableController = transformStream._readableController; |
|
7153 |
return ReadableStreamDefaultControllerGetDesiredSize(readableController); |
|
7154 |
} |
|
7155 |
}]); |
|
7156 |
return TransformStreamDefaultController; |
|
7157 |
}(); |
|
7158 |
var TransformStream = function () { |
|
7159 |
function TransformStream() { |
|
7160 |
var transformer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
7161 |
_classCallCheck(this, TransformStream); |
|
7162 |
this._transformer = transformer; |
|
7163 |
var readableStrategy = transformer.readableStrategy, |
|
7164 |
writableStrategy = transformer.writableStrategy; |
|
7165 |
this._transforming = false; |
|
7166 |
this._errored = false; |
|
7167 |
this._storedError = undefined; |
|
7168 |
this._writableController = undefined; |
|
7169 |
this._readableController = undefined; |
|
7170 |
this._transformStreamController = undefined; |
|
7171 |
this._writableDone = false; |
|
7172 |
this._readableClosed = false; |
|
7173 |
this._backpressure = undefined; |
|
7174 |
this._backpressureChangePromise = undefined; |
|
7175 |
this._backpressureChangePromise_resolve = undefined; |
|
7176 |
this._transformStreamController = new TransformStreamDefaultController(this); |
|
7177 |
var startPromise_resolve = void 0; |
|
7178 |
var startPromise = new Promise(function (resolve) { |
|
7179 |
startPromise_resolve = resolve; |
|
7180 |
}); |
|
7181 |
var source = new TransformStreamSource(this, startPromise); |
|
7182 |
this._readable = new ReadableStream(source, readableStrategy); |
|
7183 |
var sink = new TransformStreamSink(this, startPromise); |
|
7184 |
this._writable = new WritableStream(sink, writableStrategy); |
|
7185 |
assert(this._writableController !== undefined); |
|
7186 |
assert(this._readableController !== undefined); |
|
7187 |
var desiredSize = ReadableStreamDefaultControllerGetDesiredSize(this._readableController); |
|
7188 |
TransformStreamSetBackpressure(this, desiredSize <= 0); |
|
7189 |
var transformStream = this; |
|
7190 |
var startResult = InvokeOrNoop(transformer, 'start', [transformStream._transformStreamController]); |
|
7191 |
startPromise_resolve(startResult); |
|
7192 |
startPromise.catch(function (e) { |
|
7193 |
if (transformStream._errored === false) { |
|
7194 |
transformStream._errored = true; |
|
7195 |
transformStream._storedError = e; |
|
7196 |
} |
|
7197 |
}); |
|
7198 |
} |
|
7199 |
_createClass(TransformStream, [{ |
|
7200 |
key: 'readable', |
|
7201 |
get: function get() { |
|
7202 |
if (IsTransformStream(this) === false) { |
|
7203 |
throw streamBrandCheckException('readable'); |
|
7204 |
} |
|
7205 |
return this._readable; |
|
7206 |
} |
|
7207 |
}, { |
|
7208 |
key: 'writable', |
|
7209 |
get: function get() { |
|
7210 |
if (IsTransformStream(this) === false) { |
|
7211 |
throw streamBrandCheckException('writable'); |
|
7212 |
} |
|
7213 |
return this._writable; |
|
7214 |
} |
|
7215 |
}]); |
|
7216 |
return TransformStream; |
|
7217 |
}(); |
|
7218 |
module.exports = { TransformStream: TransformStream }; |
|
7219 |
function defaultControllerBrandCheckException(name) { |
|
7220 |
return new TypeError('TransformStreamDefaultController.prototype.' + name + ' can only be used on a TransformStreamDefaultController'); |
|
7221 |
} |
|
7222 |
function streamBrandCheckException(name) { |
|
7223 |
return new TypeError('TransformStream.prototype.' + name + ' can only be used on a TransformStream'); |
|
7224 |
} |
|
7225 |
}, function (module, exports, __w_pdfjs_require__) { |
|
7226 |
module.exports = __w_pdfjs_require__(5); |
|
7227 |
}])); |
|
7228 |
|
|
7229 |
/***/ }), |
|
7230 |
/* 127 */ |
|
7231 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
7232 |
|
|
7233 |
"use strict"; |
|
7234 |
|
|
7235 |
|
|
7236 |
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; }; |
|
7237 |
|
|
7238 |
{ |
|
7239 |
var isURLSupported = false; |
|
7240 |
try { |
|
7241 |
if (typeof URL === 'function' && _typeof(URL.prototype) === 'object' && 'origin' in URL.prototype) { |
|
7242 |
var u = new URL('b', 'http://a'); |
|
7243 |
u.pathname = 'c%20d'; |
|
7244 |
isURLSupported = u.href === 'http://a/c%20d'; |
|
7245 |
} |
|
7246 |
} catch (ex) {} |
|
7247 |
if (isURLSupported) { |
|
7248 |
exports.URL = URL; |
|
7249 |
} else { |
|
7250 |
var PolyfillURL = __w_pdfjs_require__(128).URL; |
|
7251 |
var OriginalURL = __w_pdfjs_require__(3).URL; |
|
7252 |
if (OriginalURL) { |
|
7253 |
PolyfillURL.createObjectURL = function (blob) { |
|
7254 |
return OriginalURL.createObjectURL.apply(OriginalURL, arguments); |
|
7255 |
}; |
|
7256 |
PolyfillURL.revokeObjectURL = function (url) { |
|
7257 |
OriginalURL.revokeObjectURL(url); |
|
7258 |
}; |
|
7259 |
} |
|
7260 |
exports.URL = PolyfillURL; |
|
7261 |
} |
|
7262 |
} |
|
7263 |
|
|
7264 |
/***/ }), |
|
7265 |
/* 128 */ |
|
7266 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
7267 |
|
|
7268 |
"use strict"; |
|
7269 |
|
|
7270 |
|
|
7271 |
(function URLConstructorClosure() { |
|
7272 |
'use strict'; |
|
7273 |
|
|
7274 |
var relative = Object.create(null); |
|
7275 |
relative['ftp'] = 21; |
|
7276 |
relative['file'] = 0; |
|
7277 |
relative['gopher'] = 70; |
|
7278 |
relative['http'] = 80; |
|
7279 |
relative['https'] = 443; |
|
7280 |
relative['ws'] = 80; |
|
7281 |
relative['wss'] = 443; |
|
7282 |
var relativePathDotMapping = Object.create(null); |
|
7283 |
relativePathDotMapping['%2e'] = '.'; |
|
7284 |
relativePathDotMapping['.%2e'] = '..'; |
|
7285 |
relativePathDotMapping['%2e.'] = '..'; |
|
7286 |
relativePathDotMapping['%2e%2e'] = '..'; |
|
7287 |
function isRelativeScheme(scheme) { |
|
7288 |
return relative[scheme] !== undefined; |
|
7289 |
} |
|
7290 |
function invalid() { |
|
7291 |
clear.call(this); |
|
7292 |
this._isInvalid = true; |
|
7293 |
} |
|
7294 |
function IDNAToASCII(h) { |
|
7295 |
if (h === '') { |
|
7296 |
invalid.call(this); |
|
7297 |
} |
|
7298 |
return h.toLowerCase(); |
|
7299 |
} |
|
7300 |
function percentEscape(c) { |
|
7301 |
var unicode = c.charCodeAt(0); |
|
7302 |
if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x3F, 0x60].indexOf(unicode) === -1) { |
|
7303 |
return c; |
|
7304 |
} |
|
7305 |
return encodeURIComponent(c); |
|
7306 |
} |
|
7307 |
function percentEscapeQuery(c) { |
|
7308 |
var unicode = c.charCodeAt(0); |
|
7309 |
if (unicode > 0x20 && unicode < 0x7F && [0x22, 0x23, 0x3C, 0x3E, 0x60].indexOf(unicode) === -1) { |
|
7310 |
return c; |
|
7311 |
} |
|
7312 |
return encodeURIComponent(c); |
|
7313 |
} |
|
7314 |
var EOF, |
|
7315 |
ALPHA = /[a-zA-Z]/, |
|
7316 |
ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/; |
|
7317 |
function parse(input, stateOverride, base) { |
|
7318 |
function err(message) { |
|
7319 |
errors.push(message); |
|
7320 |
} |
|
7321 |
var state = stateOverride || 'scheme start', |
|
7322 |
cursor = 0, |
|
7323 |
buffer = '', |
|
7324 |
seenAt = false, |
|
7325 |
seenBracket = false, |
|
7326 |
errors = []; |
|
7327 |
loop: while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) { |
|
7328 |
var c = input[cursor]; |
|
7329 |
switch (state) { |
|
7330 |
case 'scheme start': |
|
7331 |
if (c && ALPHA.test(c)) { |
|
7332 |
buffer += c.toLowerCase(); |
|
7333 |
state = 'scheme'; |
|
7334 |
} else if (!stateOverride) { |
|
7335 |
buffer = ''; |
|
7336 |
state = 'no scheme'; |
|
7337 |
continue; |
|
7338 |
} else { |
|
7339 |
err('Invalid scheme.'); |
|
7340 |
break loop; |
|
7341 |
} |
|
7342 |
break; |
|
7343 |
case 'scheme': |
|
7344 |
if (c && ALPHANUMERIC.test(c)) { |
|
7345 |
buffer += c.toLowerCase(); |
|
7346 |
} else if (c === ':') { |
|
7347 |
this._scheme = buffer; |
|
7348 |
buffer = ''; |
|
7349 |
if (stateOverride) { |
|
7350 |
break loop; |
|
7351 |
} |
|
7352 |
if (isRelativeScheme(this._scheme)) { |
|
7353 |
this._isRelative = true; |
|
7354 |
} |
|
7355 |
if (this._scheme === 'file') { |
|
7356 |
state = 'relative'; |
|
7357 |
} else if (this._isRelative && base && base._scheme === this._scheme) { |
|
7358 |
state = 'relative or authority'; |
|
7359 |
} else if (this._isRelative) { |
|
7360 |
state = 'authority first slash'; |
|
7361 |
} else { |
|
7362 |
state = 'scheme data'; |
|
7363 |
} |
|
7364 |
} else if (!stateOverride) { |
|
7365 |
buffer = ''; |
|
7366 |
cursor = 0; |
|
7367 |
state = 'no scheme'; |
|
7368 |
continue; |
|
7369 |
} else if (c === EOF) { |
|
7370 |
break loop; |
|
7371 |
} else { |
|
7372 |
err('Code point not allowed in scheme: ' + c); |
|
7373 |
break loop; |
|
7374 |
} |
|
7375 |
break; |
|
7376 |
case 'scheme data': |
|
7377 |
if (c === '?') { |
|
7378 |
this._query = '?'; |
|
7379 |
state = 'query'; |
|
7380 |
} else if (c === '#') { |
|
7381 |
this._fragment = '#'; |
|
7382 |
state = 'fragment'; |
|
7383 |
} else { |
|
7384 |
if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') { |
|
7385 |
this._schemeData += percentEscape(c); |
|
7386 |
} |
|
7387 |
} |
|
7388 |
break; |
|
7389 |
case 'no scheme': |
|
7390 |
if (!base || !isRelativeScheme(base._scheme)) { |
|
7391 |
err('Missing scheme.'); |
|
7392 |
invalid.call(this); |
|
7393 |
} else { |
|
7394 |
state = 'relative'; |
|
7395 |
continue; |
|
7396 |
} |
|
7397 |
break; |
|
7398 |
case 'relative or authority': |
|
7399 |
if (c === '/' && input[cursor + 1] === '/') { |
|
7400 |
state = 'authority ignore slashes'; |
|
7401 |
} else { |
|
7402 |
err('Expected /, got: ' + c); |
|
7403 |
state = 'relative'; |
|
7404 |
continue; |
|
7405 |
} |
|
7406 |
break; |
|
7407 |
case 'relative': |
|
7408 |
this._isRelative = true; |
|
7409 |
if (this._scheme !== 'file') { |
|
7410 |
this._scheme = base._scheme; |
|
7411 |
} |
|
7412 |
if (c === EOF) { |
|
7413 |
this._host = base._host; |
|
7414 |
this._port = base._port; |
|
7415 |
this._path = base._path.slice(); |
|
7416 |
this._query = base._query; |
|
7417 |
this._username = base._username; |
|
7418 |
this._password = base._password; |
|
7419 |
break loop; |
|
7420 |
} else if (c === '/' || c === '\\') { |
|
7421 |
if (c === '\\') { |
|
7422 |
err('\\ is an invalid code point.'); |
|
7423 |
} |
|
7424 |
state = 'relative slash'; |
|
7425 |
} else if (c === '?') { |
|
7426 |
this._host = base._host; |
|
7427 |
this._port = base._port; |
|
7428 |
this._path = base._path.slice(); |
|
7429 |
this._query = '?'; |
|
7430 |
this._username = base._username; |
|
7431 |
this._password = base._password; |
|
7432 |
state = 'query'; |
|
7433 |
} else if (c === '#') { |
|
7434 |
this._host = base._host; |
|
7435 |
this._port = base._port; |
|
7436 |
this._path = base._path.slice(); |
|
7437 |
this._query = base._query; |
|
7438 |
this._fragment = '#'; |
|
7439 |
this._username = base._username; |
|
7440 |
this._password = base._password; |
|
7441 |
state = 'fragment'; |
|
7442 |
} else { |
|
7443 |
var nextC = input[cursor + 1]; |
|
7444 |
var nextNextC = input[cursor + 2]; |
|
7445 |
if (this._scheme !== 'file' || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || nextNextC !== EOF && nextNextC !== '/' && nextNextC !== '\\' && nextNextC !== '?' && nextNextC !== '#') { |
|
7446 |
this._host = base._host; |
|
7447 |
this._port = base._port; |
|
7448 |
this._username = base._username; |
|
7449 |
this._password = base._password; |
|
7450 |
this._path = base._path.slice(); |
|
7451 |
this._path.pop(); |
|
7452 |
} |
|
7453 |
state = 'relative path'; |
|
7454 |
continue; |
|
7455 |
} |
|
7456 |
break; |
|
7457 |
case 'relative slash': |
|
7458 |
if (c === '/' || c === '\\') { |
|
7459 |
if (c === '\\') { |
|
7460 |
err('\\ is an invalid code point.'); |
|
7461 |
} |
|
7462 |
if (this._scheme === 'file') { |
|
7463 |
state = 'file host'; |
|
7464 |
} else { |
|
7465 |
state = 'authority ignore slashes'; |
|
7466 |
} |
|
7467 |
} else { |
|
7468 |
if (this._scheme !== 'file') { |
|
7469 |
this._host = base._host; |
|
7470 |
this._port = base._port; |
|
7471 |
this._username = base._username; |
|
7472 |
this._password = base._password; |
|
7473 |
} |
|
7474 |
state = 'relative path'; |
|
7475 |
continue; |
|
7476 |
} |
|
7477 |
break; |
|
7478 |
case 'authority first slash': |
|
7479 |
if (c === '/') { |
|
7480 |
state = 'authority second slash'; |
|
7481 |
} else { |
|
7482 |
err('Expected \'/\', got: ' + c); |
|
7483 |
state = 'authority ignore slashes'; |
|
7484 |
continue; |
|
7485 |
} |
|
7486 |
break; |
|
7487 |
case 'authority second slash': |
|
7488 |
state = 'authority ignore slashes'; |
|
7489 |
if (c !== '/') { |
|
7490 |
err('Expected \'/\', got: ' + c); |
|
7491 |
continue; |
|
7492 |
} |
|
7493 |
break; |
|
7494 |
case 'authority ignore slashes': |
|
7495 |
if (c !== '/' && c !== '\\') { |
|
7496 |
state = 'authority'; |
|
7497 |
continue; |
|
7498 |
} else { |
|
7499 |
err('Expected authority, got: ' + c); |
|
7500 |
} |
|
7501 |
break; |
|
7502 |
case 'authority': |
|
7503 |
if (c === '@') { |
|
7504 |
if (seenAt) { |
|
7505 |
err('@ already seen.'); |
|
7506 |
buffer += '%40'; |
|
7507 |
} |
|
7508 |
seenAt = true; |
|
7509 |
for (var i = 0; i < buffer.length; i++) { |
|
7510 |
var cp = buffer[i]; |
|
7511 |
if (cp === '\t' || cp === '\n' || cp === '\r') { |
|
7512 |
err('Invalid whitespace in authority.'); |
|
7513 |
continue; |
|
7514 |
} |
|
7515 |
if (cp === ':' && this._password === null) { |
|
7516 |
this._password = ''; |
|
7517 |
continue; |
|
7518 |
} |
|
7519 |
var tempC = percentEscape(cp); |
|
7520 |
if (this._password !== null) { |
|
7521 |
this._password += tempC; |
|
7522 |
} else { |
|
7523 |
this._username += tempC; |
|
7524 |
} |
|
7525 |
} |
|
7526 |
buffer = ''; |
|
7527 |
} else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') { |
|
7528 |
cursor -= buffer.length; |
|
7529 |
buffer = ''; |
|
7530 |
state = 'host'; |
|
7531 |
continue; |
|
7532 |
} else { |
|
7533 |
buffer += c; |
|
7534 |
} |
|
7535 |
break; |
|
7536 |
case 'file host': |
|
7537 |
if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') { |
|
7538 |
if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) { |
|
7539 |
state = 'relative path'; |
|
7540 |
} else if (buffer.length === 0) { |
|
7541 |
state = 'relative path start'; |
|
7542 |
} else { |
|
7543 |
this._host = IDNAToASCII.call(this, buffer); |
|
7544 |
buffer = ''; |
|
7545 |
state = 'relative path start'; |
|
7546 |
} |
|
7547 |
continue; |
|
7548 |
} else if (c === '\t' || c === '\n' || c === '\r') { |
|
7549 |
err('Invalid whitespace in file host.'); |
|
7550 |
} else { |
|
7551 |
buffer += c; |
|
7552 |
} |
|
7553 |
break; |
|
7554 |
case 'host': |
|
7555 |
case 'hostname': |
|
7556 |
if (c === ':' && !seenBracket) { |
|
7557 |
this._host = IDNAToASCII.call(this, buffer); |
|
7558 |
buffer = ''; |
|
7559 |
state = 'port'; |
|
7560 |
if (stateOverride === 'hostname') { |
|
7561 |
break loop; |
|
7562 |
} |
|
7563 |
} else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#') { |
|
7564 |
this._host = IDNAToASCII.call(this, buffer); |
|
7565 |
buffer = ''; |
|
7566 |
state = 'relative path start'; |
|
7567 |
if (stateOverride) { |
|
7568 |
break loop; |
|
7569 |
} |
|
7570 |
continue; |
|
7571 |
} else if (c !== '\t' && c !== '\n' && c !== '\r') { |
|
7572 |
if (c === '[') { |
|
7573 |
seenBracket = true; |
|
7574 |
} else if (c === ']') { |
|
7575 |
seenBracket = false; |
|
7576 |
} |
|
7577 |
buffer += c; |
|
7578 |
} else { |
|
7579 |
err('Invalid code point in host/hostname: ' + c); |
|
7580 |
} |
|
7581 |
break; |
|
7582 |
case 'port': |
|
7583 |
if (/[0-9]/.test(c)) { |
|
7584 |
buffer += c; |
|
7585 |
} else if (c === EOF || c === '/' || c === '\\' || c === '?' || c === '#' || stateOverride) { |
|
7586 |
if (buffer !== '') { |
|
7587 |
var temp = parseInt(buffer, 10); |
|
7588 |
if (temp !== relative[this._scheme]) { |
|
7589 |
this._port = temp + ''; |
|
7590 |
} |
|
7591 |
buffer = ''; |
|
7592 |
} |
|
7593 |
if (stateOverride) { |
|
7594 |
break loop; |
|
7595 |
} |
|
7596 |
state = 'relative path start'; |
|
7597 |
continue; |
|
7598 |
} else if (c === '\t' || c === '\n' || c === '\r') { |
|
7599 |
err('Invalid code point in port: ' + c); |
|
7600 |
} else { |
|
7601 |
invalid.call(this); |
|
7602 |
} |
|
7603 |
break; |
|
7604 |
case 'relative path start': |
|
7605 |
if (c === '\\') { |
|
7606 |
err('\'\\\' not allowed in path.'); |
|
7607 |
} |
|
7608 |
state = 'relative path'; |
|
7609 |
if (c !== '/' && c !== '\\') { |
|
7610 |
continue; |
|
7611 |
} |
|
7612 |
break; |
|
7613 |
case 'relative path': |
|
7614 |
if (c === EOF || c === '/' || c === '\\' || !stateOverride && (c === '?' || c === '#')) { |
|
7615 |
if (c === '\\') { |
|
7616 |
err('\\ not allowed in relative path.'); |
|
7617 |
} |
|
7618 |
var tmp; |
|
7619 |
if (tmp = relativePathDotMapping[buffer.toLowerCase()]) { |
|
7620 |
buffer = tmp; |
|
7621 |
} |
|
7622 |
if (buffer === '..') { |
|
7623 |
this._path.pop(); |
|
7624 |
if (c !== '/' && c !== '\\') { |
|
7625 |
this._path.push(''); |
|
7626 |
} |
|
7627 |
} else if (buffer === '.' && c !== '/' && c !== '\\') { |
|
7628 |
this._path.push(''); |
|
7629 |
} else if (buffer !== '.') { |
|
7630 |
if (this._scheme === 'file' && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') { |
|
7631 |
buffer = buffer[0] + ':'; |
|
7632 |
} |
|
7633 |
this._path.push(buffer); |
|
7634 |
} |
|
7635 |
buffer = ''; |
|
7636 |
if (c === '?') { |
|
7637 |
this._query = '?'; |
|
7638 |
state = 'query'; |
|
7639 |
} else if (c === '#') { |
|
7640 |
this._fragment = '#'; |
|
7641 |
state = 'fragment'; |
|
7642 |
} |
|
7643 |
} else if (c !== '\t' && c !== '\n' && c !== '\r') { |
|
7644 |
buffer += percentEscape(c); |
|
7645 |
} |
|
7646 |
break; |
|
7647 |
case 'query': |
|
7648 |
if (!stateOverride && c === '#') { |
|
7649 |
this._fragment = '#'; |
|
7650 |
state = 'fragment'; |
|
7651 |
} else if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') { |
|
7652 |
this._query += percentEscapeQuery(c); |
|
7653 |
} |
|
7654 |
break; |
|
7655 |
case 'fragment': |
|
7656 |
if (c !== EOF && c !== '\t' && c !== '\n' && c !== '\r') { |
|
7657 |
this._fragment += c; |
|
7658 |
} |
|
7659 |
break; |
|
7660 |
} |
|
7661 |
cursor++; |
|
7662 |
} |
|
7663 |
} |
|
7664 |
function clear() { |
|
7665 |
this._scheme = ''; |
|
7666 |
this._schemeData = ''; |
|
7667 |
this._username = ''; |
|
7668 |
this._password = null; |
|
7669 |
this._host = ''; |
|
7670 |
this._port = ''; |
|
7671 |
this._path = []; |
|
7672 |
this._query = ''; |
|
7673 |
this._fragment = ''; |
|
7674 |
this._isInvalid = false; |
|
7675 |
this._isRelative = false; |
|
7676 |
} |
|
7677 |
function JURL(url, base) { |
|
7678 |
if (base !== undefined && !(base instanceof JURL)) { |
|
7679 |
base = new JURL(String(base)); |
|
7680 |
} |
|
7681 |
this._url = url; |
|
7682 |
clear.call(this); |
|
7683 |
var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, ''); |
|
7684 |
parse.call(this, input, null, base); |
|
7685 |
} |
|
7686 |
JURL.prototype = { |
|
7687 |
toString: function toString() { |
|
7688 |
return this.href; |
|
7689 |
}, |
|
7690 |
|
|
7691 |
get href() { |
|
7692 |
if (this._isInvalid) { |
|
7693 |
return this._url; |
|
7694 |
} |
|
7695 |
var authority = ''; |
|
7696 |
if (this._username !== '' || this._password !== null) { |
|
7697 |
authority = this._username + (this._password !== null ? ':' + this._password : '') + '@'; |
|
7698 |
} |
|
7699 |
return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment; |
|
7700 |
}, |
|
7701 |
set href(value) { |
|
7702 |
clear.call(this); |
|
7703 |
parse.call(this, value); |
|
7704 |
}, |
|
7705 |
get protocol() { |
|
7706 |
return this._scheme + ':'; |
|
7707 |
}, |
|
7708 |
set protocol(value) { |
|
7709 |
if (this._isInvalid) { |
|
7710 |
return; |
|
7711 |
} |
|
7712 |
parse.call(this, value + ':', 'scheme start'); |
|
7713 |
}, |
|
7714 |
get host() { |
|
7715 |
return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host; |
|
7716 |
}, |
|
7717 |
set host(value) { |
|
7718 |
if (this._isInvalid || !this._isRelative) { |
|
7719 |
return; |
|
7720 |
} |
|
7721 |
parse.call(this, value, 'host'); |
|
7722 |
}, |
|
7723 |
get hostname() { |
|
7724 |
return this._host; |
|
7725 |
}, |
|
7726 |
set hostname(value) { |
|
7727 |
if (this._isInvalid || !this._isRelative) { |
|
7728 |
return; |
|
7729 |
} |
|
7730 |
parse.call(this, value, 'hostname'); |
|
7731 |
}, |
|
7732 |
get port() { |
|
7733 |
return this._port; |
|
7734 |
}, |
|
7735 |
set port(value) { |
|
7736 |
if (this._isInvalid || !this._isRelative) { |
|
7737 |
return; |
|
7738 |
} |
|
7739 |
parse.call(this, value, 'port'); |
|
7740 |
}, |
|
7741 |
get pathname() { |
|
7742 |
return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData; |
|
7743 |
}, |
|
7744 |
set pathname(value) { |
|
7745 |
if (this._isInvalid || !this._isRelative) { |
|
7746 |
return; |
|
7747 |
} |
|
7748 |
this._path = []; |
|
7749 |
parse.call(this, value, 'relative path start'); |
|
7750 |
}, |
|
7751 |
get search() { |
|
7752 |
return this._isInvalid || !this._query || this._query === '?' ? '' : this._query; |
|
7753 |
}, |
|
7754 |
set search(value) { |
|
7755 |
if (this._isInvalid || !this._isRelative) { |
|
7756 |
return; |
|
7757 |
} |
|
7758 |
this._query = '?'; |
|
7759 |
if (value[0] === '?') { |
|
7760 |
value = value.slice(1); |
|
7761 |
} |
|
7762 |
parse.call(this, value, 'query'); |
|
7763 |
}, |
|
7764 |
get hash() { |
|
7765 |
return this._isInvalid || !this._fragment || this._fragment === '#' ? '' : this._fragment; |
|
7766 |
}, |
|
7767 |
set hash(value) { |
|
7768 |
if (this._isInvalid) { |
|
7769 |
return; |
|
7770 |
} |
|
7771 |
this._fragment = '#'; |
|
7772 |
if (value[0] === '#') { |
|
7773 |
value = value.slice(1); |
|
7774 |
} |
|
7775 |
parse.call(this, value, 'fragment'); |
|
7776 |
}, |
|
7777 |
get origin() { |
|
7778 |
var host; |
|
7779 |
if (this._isInvalid || !this._scheme) { |
|
7780 |
return ''; |
|
7781 |
} |
|
7782 |
switch (this._scheme) { |
|
7783 |
case 'data': |
|
7784 |
case 'file': |
|
7785 |
case 'javascript': |
|
7786 |
case 'mailto': |
|
7787 |
return 'null'; |
|
7788 |
case 'blob': |
|
7789 |
try { |
|
7790 |
return new JURL(this._schemeData).origin || 'null'; |
|
7791 |
} catch (_) {} |
|
7792 |
return 'null'; |
|
7793 |
} |
|
7794 |
host = this.host; |
|
7795 |
if (!host) { |
|
7796 |
return ''; |
|
7797 |
} |
|
7798 |
return this._scheme + '://' + host; |
|
7799 |
} |
|
7800 |
}; |
|
7801 |
exports.URL = JURL; |
|
7802 |
})(); |
|
7803 |
|
|
7804 |
/***/ }), |
|
7805 |
/* 129 */ |
|
7806 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
7807 |
|
|
7808 |
"use strict"; |
|
7809 |
|
|
7810 |
|
|
7811 |
Object.defineProperty(exports, "__esModule", { |
|
7812 |
value: true |
|
7813 |
}); |
|
7814 |
exports.build = exports.version = exports.setPDFNetworkStreamFactory = exports.PDFPageProxy = exports.PDFDocumentProxy = exports.PDFWorker = exports.PDFDataRangeTransport = exports.LoopbackPort = exports.getDocument = undefined; |
|
7815 |
|
|
7816 |
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); |
|
7817 |
|
|
7818 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
|
7819 |
|
|
7820 |
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; }; |
|
7821 |
|
|
7822 |
var _util = __w_pdfjs_require__(1); |
|
7823 |
|
|
7824 |
var _dom_utils = __w_pdfjs_require__(130); |
|
7825 |
|
|
7826 |
var _font_loader = __w_pdfjs_require__(131); |
|
7827 |
|
|
7828 |
var _api_compatibility = __w_pdfjs_require__(132); |
|
7829 |
|
|
7830 |
var _canvas = __w_pdfjs_require__(133); |
|
7831 |
|
|
7832 |
var _global_scope = __w_pdfjs_require__(3); |
|
7833 |
|
|
7834 |
var _global_scope2 = _interopRequireDefault(_global_scope); |
|
7835 |
|
|
7836 |
var _worker_options = __w_pdfjs_require__(135); |
|
7837 |
|
|
7838 |
var _message_handler = __w_pdfjs_require__(136); |
|
7839 |
|
|
7840 |
var _metadata = __w_pdfjs_require__(141); |
|
7841 |
|
|
7842 |
var _transport_stream = __w_pdfjs_require__(143); |
|
7843 |
|
|
7844 |
var _webgl = __w_pdfjs_require__(144); |
|
7845 |
|
|
7846 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
7847 |
|
|
7848 |
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } |
|
7849 |
|
|
7850 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
7851 |
|
|
7852 |
var DEFAULT_RANGE_CHUNK_SIZE = 65536; |
|
7853 |
var isWorkerDisabled = false; |
|
7854 |
var fallbackWorkerSrc = void 0; |
|
7855 |
var fakeWorkerFilesLoader = null; |
|
7856 |
{ |
|
7857 |
var useRequireEnsure = false; |
|
7858 |
if (typeof window === 'undefined') { |
|
7859 |
isWorkerDisabled = true; |
|
7860 |
if (typeof require.ensure === 'undefined') { |
|
7861 |
require.ensure = require('node-ensure'); |
|
7862 |
} |
|
7863 |
useRequireEnsure = true; |
|
7864 |
} else if (typeof require !== 'undefined' && typeof require.ensure === 'function') { |
|
7865 |
useRequireEnsure = true; |
|
7866 |
} |
|
7867 |
if (typeof requirejs !== 'undefined' && requirejs.toUrl) { |
|
7868 |
fallbackWorkerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js'); |
|
7869 |
} |
|
7870 |
var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load; |
|
7871 |
fakeWorkerFilesLoader = useRequireEnsure ? function () { |
|
7872 |
return new Promise(function (resolve, reject) { |
|
7873 |
require.ensure([], function () { |
|
7874 |
try { |
|
7875 |
var worker = void 0; |
|
7876 |
worker = require('./pdf.worker.js'); |
|
7877 |
resolve(worker.WorkerMessageHandler); |
|
7878 |
} catch (ex) { |
|
7879 |
reject(ex); |
|
7880 |
} |
|
7881 |
}, reject, 'pdfjsWorker'); |
|
7882 |
}); |
|
7883 |
} : dynamicLoaderSupported ? function () { |
|
7884 |
return new Promise(function (resolve, reject) { |
|
7885 |
requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) { |
|
7886 |
try { |
|
7887 |
resolve(worker.WorkerMessageHandler); |
|
7888 |
} catch (ex) { |
|
7889 |
reject(ex); |
|
7890 |
} |
|
7891 |
}, reject); |
|
7892 |
}); |
|
7893 |
} : null; |
|
7894 |
if (!fallbackWorkerSrc && typeof document !== 'undefined') { |
|
7895 |
var pdfjsFilePath = document.currentScript && document.currentScript.src; |
|
7896 |
if (pdfjsFilePath) { |
|
7897 |
fallbackWorkerSrc = pdfjsFilePath.replace(/(\.(?:min\.)?js)(\?.*)?$/i, '.worker$1$2'); |
|
7898 |
} |
|
7899 |
} |
|
7900 |
} |
|
7901 |
var createPDFNetworkStream; |
|
7902 |
function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) { |
|
7903 |
createPDFNetworkStream = pdfNetworkStreamFactory; |
|
7904 |
} |
|
7905 |
function getDocument(src) { |
|
7906 |
var task = new PDFDocumentLoadingTask(); |
|
7907 |
var source; |
|
7908 |
if (typeof src === 'string') { |
|
7909 |
source = { url: src }; |
|
7910 |
} else if ((0, _util.isArrayBuffer)(src)) { |
|
7911 |
source = { data: src }; |
|
7912 |
} else if (src instanceof PDFDataRangeTransport) { |
|
7913 |
source = { range: src }; |
|
7914 |
} else { |
|
7915 |
if ((typeof src === 'undefined' ? 'undefined' : _typeof(src)) !== 'object') { |
|
7916 |
throw new Error('Invalid parameter in getDocument, ' + 'need either Uint8Array, string or a parameter object'); |
|
7917 |
} |
|
7918 |
if (!src.url && !src.data && !src.range) { |
|
7919 |
throw new Error('Invalid parameter object: need either .data, .range or .url'); |
|
7920 |
} |
|
7921 |
source = src; |
|
7922 |
} |
|
7923 |
var params = Object.create(null); |
|
7924 |
var rangeTransport = null; |
|
7925 |
var worker = null; |
|
7926 |
for (var key in source) { |
|
7927 |
if (key === 'url' && typeof window !== 'undefined') { |
|
7928 |
params[key] = new _util.URL(source[key], window.location).href; |
|
7929 |
continue; |
|
7930 |
} else if (key === 'range') { |
|
7931 |
rangeTransport = source[key]; |
|
7932 |
continue; |
|
7933 |
} else if (key === 'worker') { |
|
7934 |
worker = source[key]; |
|
7935 |
continue; |
|
7936 |
} else if (key === 'data' && !(source[key] instanceof Uint8Array)) { |
|
7937 |
var pdfBytes = source[key]; |
|
7938 |
if (typeof pdfBytes === 'string') { |
|
7939 |
params[key] = (0, _util.stringToBytes)(pdfBytes); |
|
7940 |
} else if ((typeof pdfBytes === 'undefined' ? 'undefined' : _typeof(pdfBytes)) === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) { |
|
7941 |
params[key] = new Uint8Array(pdfBytes); |
|
7942 |
} else if ((0, _util.isArrayBuffer)(pdfBytes)) { |
|
7943 |
params[key] = new Uint8Array(pdfBytes); |
|
7944 |
} else { |
|
7945 |
throw new Error('Invalid PDF binary data: either typed array, ' + 'string or array-like object is expected in the ' + 'data property.'); |
|
7946 |
} |
|
7947 |
continue; |
|
7948 |
} |
|
7949 |
params[key] = source[key]; |
|
7950 |
} |
|
7951 |
params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE; |
|
7952 |
params.CMapReaderFactory = params.CMapReaderFactory || _dom_utils.DOMCMapReaderFactory; |
|
7953 |
params.ignoreErrors = params.stopAtErrors !== true; |
|
7954 |
params.pdfBug = params.pdfBug === true; |
|
7955 |
var NativeImageDecoderValues = Object.values(_util.NativeImageDecoding); |
|
7956 |
if (params.nativeImageDecoderSupport === undefined || !NativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) { |
|
7957 |
params.nativeImageDecoderSupport = _api_compatibility.apiCompatibilityParams.nativeImageDecoderSupport || _util.NativeImageDecoding.DECODE; |
|
7958 |
} |
|
7959 |
if (!Number.isInteger(params.maxImageSize)) { |
|
7960 |
params.maxImageSize = -1; |
|
7961 |
} |
|
7962 |
if (typeof params.isEvalSupported !== 'boolean') { |
|
7963 |
params.isEvalSupported = true; |
|
7964 |
} |
|
7965 |
if (typeof params.disableFontFace !== 'boolean') { |
|
7966 |
params.disableFontFace = _api_compatibility.apiCompatibilityParams.disableFontFace || false; |
|
7967 |
} |
|
7968 |
if (typeof params.disableRange !== 'boolean') { |
|
7969 |
params.disableRange = false; |
|
7970 |
} |
|
7971 |
if (typeof params.disableStream !== 'boolean') { |
|
7972 |
params.disableStream = false; |
|
7973 |
} |
|
7974 |
if (typeof params.disableAutoFetch !== 'boolean') { |
|
7975 |
params.disableAutoFetch = false; |
|
7976 |
} |
|
7977 |
if (typeof params.disableCreateObjectURL !== 'boolean') { |
|
7978 |
params.disableCreateObjectURL = _api_compatibility.apiCompatibilityParams.disableCreateObjectURL || false; |
|
7979 |
} |
|
7980 |
(0, _util.setVerbosityLevel)(params.verbosity); |
|
7981 |
if (!worker) { |
|
7982 |
var workerParams = { |
|
7983 |
postMessageTransfers: params.postMessageTransfers, |
|
7984 |
verbosity: params.verbosity |
|
7985 |
}; |
|
7986 |
var workerPort = _worker_options.GlobalWorkerOptions.workerPort; |
|
7987 |
if (workerPort) { |
|
7988 |
workerParams.port = workerPort; |
|
7989 |
worker = PDFWorker.fromPort(workerParams); |
|
7990 |
} else { |
|
7991 |
worker = new PDFWorker(workerParams); |
|
7992 |
} |
|
7993 |
task._worker = worker; |
|
7994 |
} |
|
7995 |
var docId = task.docId; |
|
7996 |
worker.promise.then(function () { |
|
7997 |
if (task.destroyed) { |
|
7998 |
throw new Error('Loading aborted'); |
|
7999 |
} |
|
8000 |
return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) { |
|
8001 |
if (task.destroyed) { |
|
8002 |
throw new Error('Loading aborted'); |
|
8003 |
} |
|
8004 |
var networkStream = void 0; |
|
8005 |
if (rangeTransport) { |
|
8006 |
networkStream = new _transport_stream.PDFDataTransportStream({ |
|
8007 |
length: params.length, |
|
8008 |
initialData: params.initialData, |
|
8009 |
disableRange: params.disableRange, |
|
8010 |
disableStream: params.disableStream |
|
8011 |
}, rangeTransport); |
|
8012 |
} else if (!params.data) { |
|
8013 |
networkStream = createPDFNetworkStream({ |
|
8014 |
url: params.url, |
|
8015 |
length: params.length, |
|
8016 |
httpHeaders: params.httpHeaders, |
|
8017 |
withCredentials: params.withCredentials, |
|
8018 |
rangeChunkSize: params.rangeChunkSize, |
|
8019 |
disableRange: params.disableRange, |
|
8020 |
disableStream: params.disableStream |
|
8021 |
}); |
|
8022 |
} |
|
8023 |
var messageHandler = new _message_handler.MessageHandler(docId, workerId, worker.port); |
|
8024 |
messageHandler.postMessageTransfers = worker.postMessageTransfers; |
|
8025 |
var transport = new WorkerTransport(messageHandler, task, networkStream, params); |
|
8026 |
task._transport = transport; |
|
8027 |
messageHandler.send('Ready', null); |
|
8028 |
}); |
|
8029 |
}).catch(task._capability.reject); |
|
8030 |
return task; |
|
8031 |
} |
|
8032 |
function _fetchDocument(worker, source, pdfDataRangeTransport, docId) { |
|
8033 |
if (worker.destroyed) { |
|
8034 |
return Promise.reject(new Error('Worker was destroyed')); |
|
8035 |
} |
|
8036 |
if (pdfDataRangeTransport) { |
|
8037 |
source.length = pdfDataRangeTransport.length; |
|
8038 |
source.initialData = pdfDataRangeTransport.initialData; |
|
8039 |
} |
|
8040 |
return worker.messageHandler.sendWithPromise('GetDocRequest', { |
|
8041 |
docId: docId, |
|
8042 |
apiVersion: '2.0.943', |
|
8043 |
source: { |
|
8044 |
data: source.data, |
|
8045 |
url: source.url, |
|
8046 |
password: source.password, |
|
8047 |
disableAutoFetch: source.disableAutoFetch, |
|
8048 |
rangeChunkSize: source.rangeChunkSize, |
|
8049 |
length: source.length |
|
8050 |
}, |
|
8051 |
maxImageSize: source.maxImageSize, |
|
8052 |
disableFontFace: source.disableFontFace, |
|
8053 |
disableCreateObjectURL: source.disableCreateObjectURL, |
|
8054 |
postMessageTransfers: worker.postMessageTransfers, |
|
8055 |
docBaseUrl: source.docBaseUrl, |
|
8056 |
nativeImageDecoderSupport: source.nativeImageDecoderSupport, |
|
8057 |
ignoreErrors: source.ignoreErrors, |
|
8058 |
isEvalSupported: source.isEvalSupported |
|
8059 |
}).then(function (workerId) { |
|
8060 |
if (worker.destroyed) { |
|
8061 |
throw new Error('Worker was destroyed'); |
|
8062 |
} |
|
8063 |
return workerId; |
|
8064 |
}); |
|
8065 |
} |
|
8066 |
var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() { |
|
8067 |
var nextDocumentId = 0; |
|
8068 |
function PDFDocumentLoadingTask() { |
|
8069 |
this._capability = (0, _util.createPromiseCapability)(); |
|
8070 |
this._transport = null; |
|
8071 |
this._worker = null; |
|
8072 |
this.docId = 'd' + nextDocumentId++; |
|
8073 |
this.destroyed = false; |
|
8074 |
this.onPassword = null; |
|
8075 |
this.onProgress = null; |
|
8076 |
this.onUnsupportedFeature = null; |
|
8077 |
} |
|
8078 |
PDFDocumentLoadingTask.prototype = { |
|
8079 |
get promise() { |
|
8080 |
return this._capability.promise; |
|
8081 |
}, |
|
8082 |
destroy: function destroy() { |
|
8083 |
var _this = this; |
|
8084 |
|
|
8085 |
this.destroyed = true; |
|
8086 |
var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy(); |
|
8087 |
return transportDestroyed.then(function () { |
|
8088 |
_this._transport = null; |
|
8089 |
if (_this._worker) { |
|
8090 |
_this._worker.destroy(); |
|
8091 |
_this._worker = null; |
|
8092 |
} |
|
8093 |
}); |
|
8094 |
}, |
|
8095 |
|
|
8096 |
then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) { |
|
8097 |
return this.promise.then.apply(this.promise, arguments); |
|
8098 |
} |
|
8099 |
}; |
|
8100 |
return PDFDocumentLoadingTask; |
|
8101 |
}(); |
|
8102 |
|
|
8103 |
var PDFDataRangeTransport = function () { |
|
8104 |
function PDFDataRangeTransport(length, initialData) { |
|
8105 |
_classCallCheck(this, PDFDataRangeTransport); |
|
8106 |
|
|
8107 |
this.length = length; |
|
8108 |
this.initialData = initialData; |
|
8109 |
this._rangeListeners = []; |
|
8110 |
this._progressListeners = []; |
|
8111 |
this._progressiveReadListeners = []; |
|
8112 |
this._readyCapability = (0, _util.createPromiseCapability)(); |
|
8113 |
} |
|
8114 |
|
|
8115 |
_createClass(PDFDataRangeTransport, [{ |
|
8116 |
key: 'addRangeListener', |
|
8117 |
value: function addRangeListener(listener) { |
|
8118 |
this._rangeListeners.push(listener); |
|
8119 |
} |
|
8120 |
}, { |
|
8121 |
key: 'addProgressListener', |
|
8122 |
value: function addProgressListener(listener) { |
|
8123 |
this._progressListeners.push(listener); |
|
8124 |
} |
|
8125 |
}, { |
|
8126 |
key: 'addProgressiveReadListener', |
|
8127 |
value: function addProgressiveReadListener(listener) { |
|
8128 |
this._progressiveReadListeners.push(listener); |
|
8129 |
} |
|
8130 |
}, { |
|
8131 |
key: 'onDataRange', |
|
8132 |
value: function onDataRange(begin, chunk) { |
|
8133 |
var _iteratorNormalCompletion = true; |
|
8134 |
var _didIteratorError = false; |
|
8135 |
var _iteratorError = undefined; |
|
8136 |
|
|
8137 |
try { |
|
8138 |
for (var _iterator = this._rangeListeners[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
|
8139 |
var listener = _step.value; |
|
8140 |
|
|
8141 |
listener(begin, chunk); |
|
8142 |
} |
|
8143 |
} catch (err) { |
|
8144 |
_didIteratorError = true; |
|
8145 |
_iteratorError = err; |
|
8146 |
} finally { |
|
8147 |
try { |
|
8148 |
if (!_iteratorNormalCompletion && _iterator.return) { |
|
8149 |
_iterator.return(); |
|
8150 |
} |
|
8151 |
} finally { |
|
8152 |
if (_didIteratorError) { |
|
8153 |
throw _iteratorError; |
|
8154 |
} |
|
8155 |
} |
|
8156 |
} |
|
8157 |
} |
|
8158 |
}, { |
|
8159 |
key: 'onDataProgress', |
|
8160 |
value: function onDataProgress(loaded) { |
|
8161 |
var _this2 = this; |
|
8162 |
|
|
8163 |
this._readyCapability.promise.then(function () { |
|
8164 |
var _iteratorNormalCompletion2 = true; |
|
8165 |
var _didIteratorError2 = false; |
|
8166 |
var _iteratorError2 = undefined; |
|
8167 |
|
|
8168 |
try { |
|
8169 |
for (var _iterator2 = _this2._progressListeners[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { |
|
8170 |
var listener = _step2.value; |
|
8171 |
|
|
8172 |
listener(loaded); |
|
8173 |
} |
|
8174 |
} catch (err) { |
|
8175 |
_didIteratorError2 = true; |
|
8176 |
_iteratorError2 = err; |
|
8177 |
} finally { |
|
8178 |
try { |
|
8179 |
if (!_iteratorNormalCompletion2 && _iterator2.return) { |
|
8180 |
_iterator2.return(); |
|
8181 |
} |
|
8182 |
} finally { |
|
8183 |
if (_didIteratorError2) { |
|
8184 |
throw _iteratorError2; |
|
8185 |
} |
|
8186 |
} |
|
8187 |
} |
|
8188 |
}); |
|
8189 |
} |
|
8190 |
}, { |
|
8191 |
key: 'onDataProgressiveRead', |
|
8192 |
value: function onDataProgressiveRead(chunk) { |
|
8193 |
var _this3 = this; |
|
8194 |
|
|
8195 |
this._readyCapability.promise.then(function () { |
|
8196 |
var _iteratorNormalCompletion3 = true; |
|
8197 |
var _didIteratorError3 = false; |
|
8198 |
var _iteratorError3 = undefined; |
|
8199 |
|
|
8200 |
try { |
|
8201 |
for (var _iterator3 = _this3._progressiveReadListeners[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { |
|
8202 |
var listener = _step3.value; |
|
8203 |
|
|
8204 |
listener(chunk); |
|
8205 |
} |
|
8206 |
} catch (err) { |
|
8207 |
_didIteratorError3 = true; |
|
8208 |
_iteratorError3 = err; |
|
8209 |
} finally { |
|
8210 |
try { |
|
8211 |
if (!_iteratorNormalCompletion3 && _iterator3.return) { |
|
8212 |
_iterator3.return(); |
|
8213 |
} |
|
8214 |
} finally { |
|
8215 |
if (_didIteratorError3) { |
|
8216 |
throw _iteratorError3; |
|
8217 |
} |
|
8218 |
} |
|
8219 |
} |
|
8220 |
}); |
|
8221 |
} |
|
8222 |
}, { |
|
8223 |
key: 'transportReady', |
|
8224 |
value: function transportReady() { |
|
8225 |
this._readyCapability.resolve(); |
|
8226 |
} |
|
8227 |
}, { |
|
8228 |
key: 'requestDataRange', |
|
8229 |
value: function requestDataRange(begin, end) { |
|
8230 |
(0, _util.unreachable)('Abstract method PDFDataRangeTransport.requestDataRange'); |
|
8231 |
} |
|
8232 |
}, { |
|
8233 |
key: 'abort', |
|
8234 |
value: function abort() {} |
|
8235 |
}]); |
|
8236 |
|
|
8237 |
return PDFDataRangeTransport; |
|
8238 |
}(); |
|
8239 |
|
|
8240 |
var PDFDocumentProxy = function () { |
|
8241 |
function PDFDocumentProxy(pdfInfo, transport, loadingTask) { |
|
8242 |
_classCallCheck(this, PDFDocumentProxy); |
|
8243 |
|
|
8244 |
this.loadingTask = loadingTask; |
|
8245 |
this._pdfInfo = pdfInfo; |
|
8246 |
this._transport = transport; |
|
8247 |
} |
|
8248 |
|
|
8249 |
_createClass(PDFDocumentProxy, [{ |
|
8250 |
key: 'getPage', |
|
8251 |
value: function getPage(pageNumber) { |
|
8252 |
return this._transport.getPage(pageNumber); |
|
8253 |
} |
|
8254 |
}, { |
|
8255 |
key: 'getPageIndex', |
|
8256 |
value: function getPageIndex(ref) { |
|
8257 |
return this._transport.getPageIndex(ref); |
|
8258 |
} |
|
8259 |
}, { |
|
8260 |
key: 'getDestinations', |
|
8261 |
value: function getDestinations() { |
|
8262 |
return this._transport.getDestinations(); |
|
8263 |
} |
|
8264 |
}, { |
|
8265 |
key: 'getDestination', |
|
8266 |
value: function getDestination(id) { |
|
8267 |
return this._transport.getDestination(id); |
|
8268 |
} |
|
8269 |
}, { |
|
8270 |
key: 'getPageLabels', |
|
8271 |
value: function getPageLabels() { |
|
8272 |
return this._transport.getPageLabels(); |
|
8273 |
} |
|
8274 |
}, { |
|
8275 |
key: 'getPageMode', |
|
8276 |
value: function getPageMode() { |
|
8277 |
return this._transport.getPageMode(); |
|
8278 |
} |
|
8279 |
}, { |
|
8280 |
key: 'getAttachments', |
|
8281 |
value: function getAttachments() { |
|
8282 |
return this._transport.getAttachments(); |
|
8283 |
} |
|
8284 |
}, { |
|
8285 |
key: 'getJavaScript', |
|
8286 |
value: function getJavaScript() { |
|
8287 |
return this._transport.getJavaScript(); |
|
8288 |
} |
|
8289 |
}, { |
|
8290 |
key: 'getOutline', |
|
8291 |
value: function getOutline() { |
|
8292 |
return this._transport.getOutline(); |
|
8293 |
} |
|
8294 |
}, { |
|
8295 |
key: 'getPermissions', |
|
8296 |
value: function getPermissions() { |
|
8297 |
return this._transport.getPermissions(); |
|
8298 |
} |
|
8299 |
}, { |
|
8300 |
key: 'getMetadata', |
|
8301 |
value: function getMetadata() { |
|
8302 |
return this._transport.getMetadata(); |
|
8303 |
} |
|
8304 |
}, { |
|
8305 |
key: 'getData', |
|
8306 |
value: function getData() { |
|
8307 |
return this._transport.getData(); |
|
8308 |
} |
|
8309 |
}, { |
|
8310 |
key: 'getDownloadInfo', |
|
8311 |
value: function getDownloadInfo() { |
|
8312 |
return this._transport.downloadInfoCapability.promise; |
|
8313 |
} |
|
8314 |
}, { |
|
8315 |
key: 'getStats', |
|
8316 |
value: function getStats() { |
|
8317 |
return this._transport.getStats(); |
|
8318 |
} |
|
8319 |
}, { |
|
8320 |
key: 'cleanup', |
|
8321 |
value: function cleanup() { |
|
8322 |
this._transport.startCleanup(); |
|
8323 |
} |
|
8324 |
}, { |
|
8325 |
key: 'destroy', |
|
8326 |
value: function destroy() { |
|
8327 |
return this.loadingTask.destroy(); |
|
8328 |
} |
|
8329 |
}, { |
|
8330 |
key: 'numPages', |
|
8331 |
get: function get() { |
|
8332 |
return this._pdfInfo.numPages; |
|
8333 |
} |
|
8334 |
}, { |
|
8335 |
key: 'fingerprint', |
|
8336 |
get: function get() { |
|
8337 |
return this._pdfInfo.fingerprint; |
|
8338 |
} |
|
8339 |
}, { |
|
8340 |
key: 'loadingParams', |
|
8341 |
get: function get() { |
|
8342 |
return this._transport.loadingParams; |
|
8343 |
} |
|
8344 |
}]); |
|
8345 |
|
|
8346 |
return PDFDocumentProxy; |
|
8347 |
}(); |
|
8348 |
|
|
8349 |
var PDFPageProxy = function PDFPageProxyClosure() { |
|
8350 |
function PDFPageProxy(pageIndex, pageInfo, transport) { |
|
8351 |
var pdfBug = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; |
|
8352 |
|
|
8353 |
this.pageIndex = pageIndex; |
|
8354 |
this._pageInfo = pageInfo; |
|
8355 |
this.transport = transport; |
|
8356 |
this._stats = pdfBug ? new _dom_utils.StatTimer() : _dom_utils.DummyStatTimer; |
|
8357 |
this._pdfBug = pdfBug; |
|
8358 |
this.commonObjs = transport.commonObjs; |
|
8359 |
this.objs = new PDFObjects(); |
|
8360 |
this.cleanupAfterRender = false; |
|
8361 |
this.pendingCleanup = false; |
|
8362 |
this.intentStates = Object.create(null); |
|
8363 |
this.destroyed = false; |
|
8364 |
} |
|
8365 |
PDFPageProxy.prototype = { |
|
8366 |
get pageNumber() { |
|
8367 |
return this.pageIndex + 1; |
|
8368 |
}, |
|
8369 |
get rotate() { |
|
8370 |
return this._pageInfo.rotate; |
|
8371 |
}, |
|
8372 |
get ref() { |
|
8373 |
return this._pageInfo.ref; |
|
8374 |
}, |
|
8375 |
get userUnit() { |
|
8376 |
return this._pageInfo.userUnit; |
|
8377 |
}, |
|
8378 |
get view() { |
|
8379 |
return this._pageInfo.view; |
|
8380 |
}, |
|
8381 |
getViewport: function getViewport(scale) { |
|
8382 |
var rotate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.rotate; |
|
8383 |
var dontFlip = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
|
8384 |
|
|
8385 |
return new _dom_utils.PageViewport({ |
|
8386 |
viewBox: this.view, |
|
8387 |
scale: scale, |
|
8388 |
rotation: rotate, |
|
8389 |
dontFlip: dontFlip |
|
8390 |
}); |
|
8391 |
}, |
|
8392 |
|
|
8393 |
getAnnotations: function PDFPageProxy_getAnnotations(params) { |
|
8394 |
var intent = params && params.intent || null; |
|
8395 |
if (!this.annotationsPromise || this.annotationsIntent !== intent) { |
|
8396 |
this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent); |
|
8397 |
this.annotationsIntent = intent; |
|
8398 |
} |
|
8399 |
return this.annotationsPromise; |
|
8400 |
}, |
|
8401 |
render: function PDFPageProxy_render(params) { |
|
8402 |
var _this4 = this; |
|
8403 |
|
|
8404 |
var stats = this._stats; |
|
8405 |
stats.time('Overall'); |
|
8406 |
this.pendingCleanup = false; |
|
8407 |
var renderingIntent = params.intent === 'print' ? 'print' : 'display'; |
|
8408 |
var canvasFactory = params.canvasFactory || new _dom_utils.DOMCanvasFactory(); |
|
8409 |
var webGLContext = new _webgl.WebGLContext({ enable: params.enableWebGL }); |
|
8410 |
if (!this.intentStates[renderingIntent]) { |
|
8411 |
this.intentStates[renderingIntent] = Object.create(null); |
|
8412 |
} |
|
8413 |
var intentState = this.intentStates[renderingIntent]; |
|
8414 |
if (!intentState.displayReadyCapability) { |
|
8415 |
intentState.receivingOperatorList = true; |
|
8416 |
intentState.displayReadyCapability = (0, _util.createPromiseCapability)(); |
|
8417 |
intentState.operatorList = { |
|
8418 |
fnArray: [], |
|
8419 |
argsArray: [], |
|
8420 |
lastChunk: false |
|
8421 |
}; |
|
8422 |
stats.time('Page Request'); |
|
8423 |
this.transport.messageHandler.send('RenderPageRequest', { |
|
8424 |
pageIndex: this.pageNumber - 1, |
|
8425 |
intent: renderingIntent, |
|
8426 |
renderInteractiveForms: params.renderInteractiveForms === true |
|
8427 |
}); |
|
8428 |
} |
|
8429 |
var complete = function complete(error) { |
|
8430 |
var i = intentState.renderTasks.indexOf(internalRenderTask); |
|
8431 |
if (i >= 0) { |
|
8432 |
intentState.renderTasks.splice(i, 1); |
|
8433 |
} |
|
8434 |
if (_this4.cleanupAfterRender) { |
|
8435 |
_this4.pendingCleanup = true; |
|
8436 |
} |
|
8437 |
_this4._tryCleanup(); |
|
8438 |
if (error) { |
|
8439 |
internalRenderTask.capability.reject(error); |
|
8440 |
} else { |
|
8441 |
internalRenderTask.capability.resolve(); |
|
8442 |
} |
|
8443 |
stats.timeEnd('Rendering'); |
|
8444 |
stats.timeEnd('Overall'); |
|
8445 |
}; |
|
8446 |
var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber, canvasFactory, webGLContext, this._pdfBug); |
|
8447 |
internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print'; |
|
8448 |
if (!intentState.renderTasks) { |
|
8449 |
intentState.renderTasks = []; |
|
8450 |
} |
|
8451 |
intentState.renderTasks.push(internalRenderTask); |
|
8452 |
var renderTask = internalRenderTask.task; |
|
8453 |
intentState.displayReadyCapability.promise.then(function (transparency) { |
|
8454 |
if (_this4.pendingCleanup) { |
|
8455 |
complete(); |
|
8456 |
return; |
|
8457 |
} |
|
8458 |
stats.time('Rendering'); |
|
8459 |
internalRenderTask.initializeGraphics(transparency); |
|
8460 |
internalRenderTask.operatorListChanged(); |
|
8461 |
}).catch(complete); |
|
8462 |
return renderTask; |
|
8463 |
}, |
|
8464 |
getOperatorList: function PDFPageProxy_getOperatorList() { |
|
8465 |
function operatorListChanged() { |
|
8466 |
if (intentState.operatorList.lastChunk) { |
|
8467 |
intentState.opListReadCapability.resolve(intentState.operatorList); |
|
8468 |
var i = intentState.renderTasks.indexOf(opListTask); |
|
8469 |
if (i >= 0) { |
|
8470 |
intentState.renderTasks.splice(i, 1); |
|
8471 |
} |
|
8472 |
} |
|
8473 |
} |
|
8474 |
var renderingIntent = 'oplist'; |
|
8475 |
if (!this.intentStates[renderingIntent]) { |
|
8476 |
this.intentStates[renderingIntent] = Object.create(null); |
|
8477 |
} |
|
8478 |
var intentState = this.intentStates[renderingIntent]; |
|
8479 |
var opListTask; |
|
8480 |
if (!intentState.opListReadCapability) { |
|
8481 |
opListTask = {}; |
|
8482 |
opListTask.operatorListChanged = operatorListChanged; |
|
8483 |
intentState.receivingOperatorList = true; |
|
8484 |
intentState.opListReadCapability = (0, _util.createPromiseCapability)(); |
|
8485 |
intentState.renderTasks = []; |
|
8486 |
intentState.renderTasks.push(opListTask); |
|
8487 |
intentState.operatorList = { |
|
8488 |
fnArray: [], |
|
8489 |
argsArray: [], |
|
8490 |
lastChunk: false |
|
8491 |
}; |
|
8492 |
this._stats.time('Page Request'); |
|
8493 |
this.transport.messageHandler.send('RenderPageRequest', { |
|
8494 |
pageIndex: this.pageIndex, |
|
8495 |
intent: renderingIntent |
|
8496 |
}); |
|
8497 |
} |
|
8498 |
return intentState.opListReadCapability.promise; |
|
8499 |
}, |
|
8500 |
streamTextContent: function streamTextContent() { |
|
8501 |
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
8502 |
|
|
8503 |
var TEXT_CONTENT_CHUNK_SIZE = 100; |
|
8504 |
return this.transport.messageHandler.sendWithStream('GetTextContent', { |
|
8505 |
pageIndex: this.pageNumber - 1, |
|
8506 |
normalizeWhitespace: params.normalizeWhitespace === true, |
|
8507 |
combineTextItems: params.disableCombineTextItems !== true |
|
8508 |
}, { |
|
8509 |
highWaterMark: TEXT_CONTENT_CHUNK_SIZE, |
|
8510 |
size: function size(textContent) { |
|
8511 |
return textContent.items.length; |
|
8512 |
} |
|
8513 |
}); |
|
8514 |
}, |
|
8515 |
|
|
8516 |
getTextContent: function PDFPageProxy_getTextContent(params) { |
|
8517 |
params = params || {}; |
|
8518 |
var readableStream = this.streamTextContent(params); |
|
8519 |
return new Promise(function (resolve, reject) { |
|
8520 |
function pump() { |
|
8521 |
reader.read().then(function (_ref) { |
|
8522 |
var _textContent$items; |
|
8523 |
|
|
8524 |
var value = _ref.value, |
|
8525 |
done = _ref.done; |
|
8526 |
|
|
8527 |
if (done) { |
|
8528 |
resolve(textContent); |
|
8529 |
return; |
|
8530 |
} |
|
8531 |
Object.assign(textContent.styles, value.styles); |
|
8532 |
(_textContent$items = textContent.items).push.apply(_textContent$items, _toConsumableArray(value.items)); |
|
8533 |
pump(); |
|
8534 |
}, reject); |
|
8535 |
} |
|
8536 |
var reader = readableStream.getReader(); |
|
8537 |
var textContent = { |
|
8538 |
items: [], |
|
8539 |
styles: Object.create(null) |
|
8540 |
}; |
|
8541 |
pump(); |
|
8542 |
}); |
|
8543 |
}, |
|
8544 |
_destroy: function PDFPageProxy_destroy() { |
|
8545 |
this.destroyed = true; |
|
8546 |
this.transport.pageCache[this.pageIndex] = null; |
|
8547 |
var waitOn = []; |
|
8548 |
Object.keys(this.intentStates).forEach(function (intent) { |
|
8549 |
if (intent === 'oplist') { |
|
8550 |
return; |
|
8551 |
} |
|
8552 |
var intentState = this.intentStates[intent]; |
|
8553 |
intentState.renderTasks.forEach(function (renderTask) { |
|
8554 |
var renderCompleted = renderTask.capability.promise.catch(function () {}); |
|
8555 |
waitOn.push(renderCompleted); |
|
8556 |
renderTask.cancel(); |
|
8557 |
}); |
|
8558 |
}, this); |
|
8559 |
this.objs.clear(); |
|
8560 |
this.annotationsPromise = null; |
|
8561 |
this.pendingCleanup = false; |
|
8562 |
return Promise.all(waitOn); |
|
8563 |
}, |
|
8564 |
cleanup: function cleanup() { |
|
8565 |
var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
|
8566 |
|
|
8567 |
this.pendingCleanup = true; |
|
8568 |
this._tryCleanup(resetStats); |
|
8569 |
}, |
|
8570 |
_tryCleanup: function _tryCleanup() { |
|
8571 |
var resetStats = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
|
8572 |
|
|
8573 |
if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) { |
|
8574 |
var intentState = this.intentStates[intent]; |
|
8575 |
return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList; |
|
8576 |
}, this)) { |
|
8577 |
return; |
|
8578 |
} |
|
8579 |
Object.keys(this.intentStates).forEach(function (intent) { |
|
8580 |
delete this.intentStates[intent]; |
|
8581 |
}, this); |
|
8582 |
this.objs.clear(); |
|
8583 |
this.annotationsPromise = null; |
|
8584 |
if (resetStats && this._stats instanceof _dom_utils.StatTimer) { |
|
8585 |
this._stats = new _dom_utils.StatTimer(); |
|
8586 |
} |
|
8587 |
this.pendingCleanup = false; |
|
8588 |
}, |
|
8589 |
|
|
8590 |
_startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) { |
|
8591 |
var intentState = this.intentStates[intent]; |
|
8592 |
if (intentState.displayReadyCapability) { |
|
8593 |
intentState.displayReadyCapability.resolve(transparency); |
|
8594 |
} |
|
8595 |
}, |
|
8596 |
_renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) { |
|
8597 |
var intentState = this.intentStates[intent]; |
|
8598 |
var i, ii; |
|
8599 |
for (i = 0, ii = operatorListChunk.length; i < ii; i++) { |
|
8600 |
intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]); |
|
8601 |
intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]); |
|
8602 |
} |
|
8603 |
intentState.operatorList.lastChunk = operatorListChunk.lastChunk; |
|
8604 |
for (i = 0; i < intentState.renderTasks.length; i++) { |
|
8605 |
intentState.renderTasks[i].operatorListChanged(); |
|
8606 |
} |
|
8607 |
if (operatorListChunk.lastChunk) { |
|
8608 |
intentState.receivingOperatorList = false; |
|
8609 |
this._tryCleanup(); |
|
8610 |
} |
|
8611 |
}, |
|
8612 |
get stats() { |
|
8613 |
return this._stats instanceof _dom_utils.StatTimer ? this._stats : null; |
|
8614 |
} |
|
8615 |
}; |
|
8616 |
return PDFPageProxy; |
|
8617 |
}(); |
|
8618 |
|
|
8619 |
var LoopbackPort = function () { |
|
8620 |
function LoopbackPort() { |
|
8621 |
var defer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; |
|
8622 |
|
|
8623 |
_classCallCheck(this, LoopbackPort); |
|
8624 |
|
|
8625 |
this._listeners = []; |
|
8626 |
this._defer = defer; |
|
8627 |
this._deferred = Promise.resolve(undefined); |
|
8628 |
} |
|
8629 |
|
|
8630 |
_createClass(LoopbackPort, [{ |
|
8631 |
key: 'postMessage', |
|
8632 |
value: function postMessage(obj, transfers) { |
|
8633 |
var _this5 = this; |
|
8634 |
|
|
8635 |
function cloneValue(value) { |
|
8636 |
if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) !== 'object' || value === null) { |
|
8637 |
return value; |
|
8638 |
} |
|
8639 |
if (cloned.has(value)) { |
|
8640 |
return cloned.get(value); |
|
8641 |
} |
|
8642 |
var result; |
|
8643 |
var buffer; |
|
8644 |
if ((buffer = value.buffer) && (0, _util.isArrayBuffer)(buffer)) { |
|
8645 |
var transferable = transfers && transfers.includes(buffer); |
|
8646 |
if (value === buffer) { |
|
8647 |
result = value; |
|
8648 |
} else if (transferable) { |
|
8649 |
result = new value.constructor(buffer, value.byteOffset, value.byteLength); |
|
8650 |
} else { |
|
8651 |
result = new value.constructor(value); |
|
8652 |
} |
|
8653 |
cloned.set(value, result); |
|
8654 |
return result; |
|
8655 |
} |
|
8656 |
result = Array.isArray(value) ? [] : {}; |
|
8657 |
cloned.set(value, result); |
|
8658 |
for (var i in value) { |
|
8659 |
var desc, |
|
8660 |
p = value; |
|
8661 |
while (!(desc = Object.getOwnPropertyDescriptor(p, i))) { |
|
8662 |
p = Object.getPrototypeOf(p); |
|
8663 |
} |
|
8664 |
if (typeof desc.value === 'undefined' || typeof desc.value === 'function') { |
|
8665 |
continue; |
|
8666 |
} |
|
8667 |
result[i] = cloneValue(desc.value); |
|
8668 |
} |
|
8669 |
return result; |
|
8670 |
} |
|
8671 |
if (!this._defer) { |
|
8672 |
this._listeners.forEach(function (listener) { |
|
8673 |
listener.call(this, { data: obj }); |
|
8674 |
}, this); |
|
8675 |
return; |
|
8676 |
} |
|
8677 |
var cloned = new WeakMap(); |
|
8678 |
var e = { data: cloneValue(obj) }; |
|
8679 |
this._deferred.then(function () { |
|
8680 |
_this5._listeners.forEach(function (listener) { |
|
8681 |
listener.call(this, e); |
|
8682 |
}, _this5); |
|
8683 |
}); |
|
8684 |
} |
|
8685 |
}, { |
|
8686 |
key: 'addEventListener', |
|
8687 |
value: function addEventListener(name, listener) { |
|
8688 |
this._listeners.push(listener); |
|
8689 |
} |
|
8690 |
}, { |
|
8691 |
key: 'removeEventListener', |
|
8692 |
value: function removeEventListener(name, listener) { |
|
8693 |
var i = this._listeners.indexOf(listener); |
|
8694 |
this._listeners.splice(i, 1); |
|
8695 |
} |
|
8696 |
}, { |
|
8697 |
key: 'terminate', |
|
8698 |
value: function terminate() { |
|
8699 |
this._listeners = []; |
|
8700 |
} |
|
8701 |
}]); |
|
8702 |
|
|
8703 |
return LoopbackPort; |
|
8704 |
}(); |
|
8705 |
|
|
8706 |
var PDFWorker = function PDFWorkerClosure() { |
|
8707 |
var nextFakeWorkerId = 0; |
|
8708 |
function getWorkerSrc() { |
|
8709 |
if (_worker_options.GlobalWorkerOptions.workerSrc) { |
|
8710 |
return _worker_options.GlobalWorkerOptions.workerSrc; |
|
8711 |
} |
|
8712 |
if (typeof fallbackWorkerSrc !== 'undefined') { |
|
8713 |
return fallbackWorkerSrc; |
|
8714 |
} |
|
8715 |
throw new Error('No "GlobalWorkerOptions.workerSrc" specified.'); |
|
8716 |
} |
|
8717 |
function getMainThreadWorkerMessageHandler() { |
|
8718 |
try { |
|
8719 |
if (typeof window !== 'undefined') { |
|
8720 |
return window.pdfjsWorker && window.pdfjsWorker.WorkerMessageHandler; |
|
8721 |
} |
|
8722 |
} catch (ex) {} |
|
8723 |
return null; |
|
8724 |
} |
|
8725 |
var fakeWorkerFilesLoadedCapability = void 0; |
|
8726 |
function setupFakeWorkerGlobal() { |
|
8727 |
if (fakeWorkerFilesLoadedCapability) { |
|
8728 |
return fakeWorkerFilesLoadedCapability.promise; |
|
8729 |
} |
|
8730 |
fakeWorkerFilesLoadedCapability = (0, _util.createPromiseCapability)(); |
|
8731 |
var mainWorkerMessageHandler = getMainThreadWorkerMessageHandler(); |
|
8732 |
if (mainWorkerMessageHandler) { |
|
8733 |
fakeWorkerFilesLoadedCapability.resolve(mainWorkerMessageHandler); |
|
8734 |
return fakeWorkerFilesLoadedCapability.promise; |
|
8735 |
} |
|
8736 |
var loader = fakeWorkerFilesLoader || function () { |
|
8737 |
return (0, _dom_utils.loadScript)(getWorkerSrc()).then(function () { |
|
8738 |
return window.pdfjsWorker.WorkerMessageHandler; |
|
8739 |
}); |
|
8740 |
}; |
|
8741 |
loader().then(fakeWorkerFilesLoadedCapability.resolve, fakeWorkerFilesLoadedCapability.reject); |
|
8742 |
return fakeWorkerFilesLoadedCapability.promise; |
|
8743 |
} |
|
8744 |
function createCDNWrapper(url) { |
|
8745 |
var wrapper = 'importScripts(\'' + url + '\');'; |
|
8746 |
return _util.URL.createObjectURL(new Blob([wrapper])); |
|
8747 |
} |
|
8748 |
var pdfWorkerPorts = new WeakMap(); |
|
8749 |
function PDFWorker() { |
|
8750 |
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
|
8751 |
_ref2$name = _ref2.name, |
|
8752 |
name = _ref2$name === undefined ? null : _ref2$name, |
|
8753 |
_ref2$port = _ref2.port, |
|
8754 |
port = _ref2$port === undefined ? null : _ref2$port, |
|
8755 |
_ref2$postMessageTran = _ref2.postMessageTransfers, |
|
8756 |
postMessageTransfers = _ref2$postMessageTran === undefined ? true : _ref2$postMessageTran, |
|
8757 |
_ref2$verbosity = _ref2.verbosity, |
|
8758 |
verbosity = _ref2$verbosity === undefined ? (0, _util.getVerbosityLevel)() : _ref2$verbosity; |
|
8759 |
|
|
8760 |
if (port && pdfWorkerPorts.has(port)) { |
|
8761 |
throw new Error('Cannot use more than one PDFWorker per port'); |
|
8762 |
} |
|
8763 |
this.name = name; |
|
8764 |
this.destroyed = false; |
|
8765 |
this.postMessageTransfers = postMessageTransfers !== false; |
|
8766 |
this.verbosity = verbosity; |
|
8767 |
this._readyCapability = (0, _util.createPromiseCapability)(); |
|
8768 |
this._port = null; |
|
8769 |
this._webWorker = null; |
|
8770 |
this._messageHandler = null; |
|
8771 |
if (port) { |
|
8772 |
pdfWorkerPorts.set(port, this); |
|
8773 |
this._initializeFromPort(port); |
|
8774 |
return; |
|
8775 |
} |
|
8776 |
this._initialize(); |
|
8777 |
} |
|
8778 |
PDFWorker.prototype = { |
|
8779 |
get promise() { |
|
8780 |
return this._readyCapability.promise; |
|
8781 |
}, |
|
8782 |
get port() { |
|
8783 |
return this._port; |
|
8784 |
}, |
|
8785 |
get messageHandler() { |
|
8786 |
return this._messageHandler; |
|
8787 |
}, |
|
8788 |
_initializeFromPort: function PDFWorker_initializeFromPort(port) { |
|
8789 |
this._port = port; |
|
8790 |
this._messageHandler = new _message_handler.MessageHandler('main', 'worker', port); |
|
8791 |
this._messageHandler.on('ready', function () {}); |
|
8792 |
this._readyCapability.resolve(); |
|
8793 |
}, |
|
8794 |
_initialize: function PDFWorker_initialize() { |
|
8795 |
var _this6 = this; |
|
8796 |
|
|
8797 |
if (typeof Worker !== 'undefined' && !isWorkerDisabled && !getMainThreadWorkerMessageHandler()) { |
|
8798 |
var workerSrc = getWorkerSrc(); |
|
8799 |
try { |
|
8800 |
if (!(0, _util.isSameOrigin)(window.location.href, workerSrc)) { |
|
8801 |
workerSrc = createCDNWrapper(new _util.URL(workerSrc, window.location).href); |
|
8802 |
} |
|
8803 |
var worker = new Worker(workerSrc); |
|
8804 |
var messageHandler = new _message_handler.MessageHandler('main', 'worker', worker); |
|
8805 |
var terminateEarly = function terminateEarly() { |
|
8806 |
worker.removeEventListener('error', onWorkerError); |
|
8807 |
messageHandler.destroy(); |
|
8808 |
worker.terminate(); |
|
8809 |
if (_this6.destroyed) { |
|
8810 |
_this6._readyCapability.reject(new Error('Worker was destroyed')); |
|
8811 |
} else { |
|
8812 |
_this6._setupFakeWorker(); |
|
8813 |
} |
|
8814 |
}; |
|
8815 |
var onWorkerError = function onWorkerError() { |
|
8816 |
if (!_this6._webWorker) { |
|
8817 |
terminateEarly(); |
|
8818 |
} |
|
8819 |
}; |
|
8820 |
worker.addEventListener('error', onWorkerError); |
|
8821 |
messageHandler.on('test', function (data) { |
|
8822 |
worker.removeEventListener('error', onWorkerError); |
|
8823 |
if (_this6.destroyed) { |
|
8824 |
terminateEarly(); |
|
8825 |
return; |
|
8826 |
} |
|
8827 |
if (data && data.supportTypedArray) { |
|
8828 |
_this6._messageHandler = messageHandler; |
|
8829 |
_this6._port = worker; |
|
8830 |
_this6._webWorker = worker; |
|
8831 |
if (!data.supportTransfers) { |
|
8832 |
_this6.postMessageTransfers = false; |
|
8833 |
} |
|
8834 |
_this6._readyCapability.resolve(); |
|
8835 |
messageHandler.send('configure', { verbosity: _this6.verbosity }); |
|
8836 |
} else { |
|
8837 |
_this6._setupFakeWorker(); |
|
8838 |
messageHandler.destroy(); |
|
8839 |
worker.terminate(); |
|
8840 |
} |
|
8841 |
}); |
|
8842 |
messageHandler.on('ready', function (data) { |
|
8843 |
worker.removeEventListener('error', onWorkerError); |
|
8844 |
if (_this6.destroyed) { |
|
8845 |
terminateEarly(); |
|
8846 |
return; |
|
8847 |
} |
|
8848 |
try { |
|
8849 |
sendTest(); |
|
8850 |
} catch (e) { |
|
8851 |
_this6._setupFakeWorker(); |
|
8852 |
} |
|
8853 |
}); |
|
8854 |
var sendTest = function sendTest() { |
|
8855 |
var testObj = new Uint8Array([_this6.postMessageTransfers ? 255 : 0]); |
|
8856 |
try { |
|
8857 |
messageHandler.send('test', testObj, [testObj.buffer]); |
|
8858 |
} catch (ex) { |
|
8859 |
(0, _util.info)('Cannot use postMessage transfers'); |
|
8860 |
testObj[0] = 0; |
|
8861 |
messageHandler.send('test', testObj); |
|
8862 |
} |
|
8863 |
}; |
|
8864 |
sendTest(); |
|
8865 |
return; |
|
8866 |
} catch (e) { |
|
8867 |
(0, _util.info)('The worker has been disabled.'); |
|
8868 |
} |
|
8869 |
} |
|
8870 |
this._setupFakeWorker(); |
|
8871 |
}, |
|
8872 |
_setupFakeWorker: function PDFWorker_setupFakeWorker() { |
|
8873 |
var _this7 = this; |
|
8874 |
|
|
8875 |
if (!isWorkerDisabled) { |
|
8876 |
(0, _util.warn)('Setting up fake worker.'); |
|
8877 |
isWorkerDisabled = true; |
|
8878 |
} |
|
8879 |
setupFakeWorkerGlobal().then(function (WorkerMessageHandler) { |
|
8880 |
if (_this7.destroyed) { |
|
8881 |
_this7._readyCapability.reject(new Error('Worker was destroyed')); |
|
8882 |
return; |
|
8883 |
} |
|
8884 |
var port = new LoopbackPort(); |
|
8885 |
_this7._port = port; |
|
8886 |
var id = 'fake' + nextFakeWorkerId++; |
|
8887 |
var workerHandler = new _message_handler.MessageHandler(id + '_worker', id, port); |
|
8888 |
WorkerMessageHandler.setup(workerHandler, port); |
|
8889 |
var messageHandler = new _message_handler.MessageHandler(id, id + '_worker', port); |
|
8890 |
_this7._messageHandler = messageHandler; |
|
8891 |
_this7._readyCapability.resolve(); |
|
8892 |
}).catch(function (reason) { |
|
8893 |
_this7._readyCapability.reject(new Error('Setting up fake worker failed: "' + reason.message + '".')); |
|
8894 |
}); |
|
8895 |
}, |
|
8896 |
destroy: function PDFWorker_destroy() { |
|
8897 |
this.destroyed = true; |
|
8898 |
if (this._webWorker) { |
|
8899 |
this._webWorker.terminate(); |
|
8900 |
this._webWorker = null; |
|
8901 |
} |
|
8902 |
pdfWorkerPorts.delete(this._port); |
|
8903 |
this._port = null; |
|
8904 |
if (this._messageHandler) { |
|
8905 |
this._messageHandler.destroy(); |
|
8906 |
this._messageHandler = null; |
|
8907 |
} |
|
8908 |
} |
|
8909 |
}; |
|
8910 |
PDFWorker.fromPort = function (params) { |
|
8911 |
if (!params || !params.port) { |
|
8912 |
throw new Error('PDFWorker.fromPort - invalid method signature.'); |
|
8913 |
} |
|
8914 |
if (pdfWorkerPorts.has(params.port)) { |
|
8915 |
return pdfWorkerPorts.get(params.port); |
|
8916 |
} |
|
8917 |
return new PDFWorker(params); |
|
8918 |
}; |
|
8919 |
PDFWorker.getWorkerSrc = function () { |
|
8920 |
return getWorkerSrc(); |
|
8921 |
}; |
|
8922 |
return PDFWorker; |
|
8923 |
}(); |
|
8924 |
|
|
8925 |
var WorkerTransport = function () { |
|
8926 |
function WorkerTransport(messageHandler, loadingTask, networkStream, params) { |
|
8927 |
_classCallCheck(this, WorkerTransport); |
|
8928 |
|
|
8929 |
this.messageHandler = messageHandler; |
|
8930 |
this.loadingTask = loadingTask; |
|
8931 |
this.commonObjs = new PDFObjects(); |
|
8932 |
this.fontLoader = new _font_loader.FontLoader(loadingTask.docId); |
|
8933 |
this._params = params; |
|
8934 |
this.CMapReaderFactory = new params.CMapReaderFactory({ |
|
8935 |
baseUrl: params.cMapUrl, |
|
8936 |
isCompressed: params.cMapPacked |
|
8937 |
}); |
|
8938 |
this.destroyed = false; |
|
8939 |
this.destroyCapability = null; |
|
8940 |
this._passwordCapability = null; |
|
8941 |
this._networkStream = networkStream; |
|
8942 |
this._fullReader = null; |
|
8943 |
this._lastProgress = null; |
|
8944 |
this.pageCache = []; |
|
8945 |
this.pagePromises = []; |
|
8946 |
this.downloadInfoCapability = (0, _util.createPromiseCapability)(); |
|
8947 |
this.setupMessageHandler(); |
|
8948 |
} |
|
8949 |
|
|
8950 |
_createClass(WorkerTransport, [{ |
|
8951 |
key: 'destroy', |
|
8952 |
value: function destroy() { |
|
8953 |
var _this8 = this; |
|
8954 |
|
|
8955 |
if (this.destroyCapability) { |
|
8956 |
return this.destroyCapability.promise; |
|
8957 |
} |
|
8958 |
this.destroyed = true; |
|
8959 |
this.destroyCapability = (0, _util.createPromiseCapability)(); |
|
8960 |
if (this._passwordCapability) { |
|
8961 |
this._passwordCapability.reject(new Error('Worker was destroyed during onPassword callback')); |
|
8962 |
} |
|
8963 |
var waitOn = []; |
|
8964 |
this.pageCache.forEach(function (page) { |
|
8965 |
if (page) { |
|
8966 |
waitOn.push(page._destroy()); |
|
8967 |
} |
|
8968 |
}); |
|
8969 |
this.pageCache = []; |
|
8970 |
this.pagePromises = []; |
|
8971 |
var terminated = this.messageHandler.sendWithPromise('Terminate', null); |
|
8972 |
waitOn.push(terminated); |
|
8973 |
Promise.all(waitOn).then(function () { |
|
8974 |
_this8.fontLoader.clear(); |
|
8975 |
if (_this8._networkStream) { |
|
8976 |
_this8._networkStream.cancelAllRequests(); |
|
8977 |
} |
|
8978 |
if (_this8.messageHandler) { |
|
8979 |
_this8.messageHandler.destroy(); |
|
8980 |
_this8.messageHandler = null; |
|
8981 |
} |
|
8982 |
_this8.destroyCapability.resolve(); |
|
8983 |
}, this.destroyCapability.reject); |
|
8984 |
return this.destroyCapability.promise; |
|
8985 |
} |
|
8986 |
}, { |
|
8987 |
key: 'setupMessageHandler', |
|
8988 |
value: function setupMessageHandler() { |
|
8989 |
var messageHandler = this.messageHandler, |
|
8990 |
loadingTask = this.loadingTask; |
|
8991 |
|
|
8992 |
messageHandler.on('GetReader', function (data, sink) { |
|
8993 |
var _this9 = this; |
|
8994 |
|
|
8995 |
(0, _util.assert)(this._networkStream); |
|
8996 |
this._fullReader = this._networkStream.getFullReader(); |
|
8997 |
this._fullReader.onProgress = function (evt) { |
|
8998 |
_this9._lastProgress = { |
|
8999 |
loaded: evt.loaded, |
|
9000 |
total: evt.total |
|
9001 |
}; |
|
9002 |
}; |
|
9003 |
sink.onPull = function () { |
|
9004 |
_this9._fullReader.read().then(function (_ref3) { |
|
9005 |
var value = _ref3.value, |
|
9006 |
done = _ref3.done; |
|
9007 |
|
|
9008 |
if (done) { |
|
9009 |
sink.close(); |
|
9010 |
return; |
|
9011 |
} |
|
9012 |
(0, _util.assert)((0, _util.isArrayBuffer)(value)); |
|
9013 |
sink.enqueue(new Uint8Array(value), 1, [value]); |
|
9014 |
}).catch(function (reason) { |
|
9015 |
sink.error(reason); |
|
9016 |
}); |
|
9017 |
}; |
|
9018 |
sink.onCancel = function (reason) { |
|
9019 |
_this9._fullReader.cancel(reason); |
|
9020 |
}; |
|
9021 |
}, this); |
|
9022 |
messageHandler.on('ReaderHeadersReady', function (data) { |
|
9023 |
var _this10 = this; |
|
9024 |
|
|
9025 |
var headersCapability = (0, _util.createPromiseCapability)(); |
|
9026 |
var fullReader = this._fullReader; |
|
9027 |
fullReader.headersReady.then(function () { |
|
9028 |
if (!fullReader.isStreamingSupported || !fullReader.isRangeSupported) { |
|
9029 |
if (_this10._lastProgress && loadingTask.onProgress) { |
|
9030 |
loadingTask.onProgress(_this10._lastProgress); |
|
9031 |
} |
|
9032 |
fullReader.onProgress = function (evt) { |
|
9033 |
if (loadingTask.onProgress) { |
|
9034 |
loadingTask.onProgress({ |
|
9035 |
loaded: evt.loaded, |
|
9036 |
total: evt.total |
|
9037 |
}); |
|
9038 |
} |
|
9039 |
}; |
|
9040 |
} |
|
9041 |
headersCapability.resolve({ |
|
9042 |
isStreamingSupported: fullReader.isStreamingSupported, |
|
9043 |
isRangeSupported: fullReader.isRangeSupported, |
|
9044 |
contentLength: fullReader.contentLength |
|
9045 |
}); |
|
9046 |
}, headersCapability.reject); |
|
9047 |
return headersCapability.promise; |
|
9048 |
}, this); |
|
9049 |
messageHandler.on('GetRangeReader', function (data, sink) { |
|
9050 |
(0, _util.assert)(this._networkStream); |
|
9051 |
var rangeReader = this._networkStream.getRangeReader(data.begin, data.end); |
|
9052 |
sink.onPull = function () { |
|
9053 |
rangeReader.read().then(function (_ref4) { |
|
9054 |
var value = _ref4.value, |
|
9055 |
done = _ref4.done; |
|
9056 |
|
|
9057 |
if (done) { |
|
9058 |
sink.close(); |
|
9059 |
return; |
|
9060 |
} |
|
9061 |
(0, _util.assert)((0, _util.isArrayBuffer)(value)); |
|
9062 |
sink.enqueue(new Uint8Array(value), 1, [value]); |
|
9063 |
}).catch(function (reason) { |
|
9064 |
sink.error(reason); |
|
9065 |
}); |
|
9066 |
}; |
|
9067 |
sink.onCancel = function (reason) { |
|
9068 |
rangeReader.cancel(reason); |
|
9069 |
}; |
|
9070 |
}, this); |
|
9071 |
messageHandler.on('GetDoc', function (_ref5) { |
|
9072 |
var pdfInfo = _ref5.pdfInfo; |
|
9073 |
|
|
9074 |
this.numPages = pdfInfo.numPages; |
|
9075 |
this.pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask); |
|
9076 |
loadingTask._capability.resolve(this.pdfDocument); |
|
9077 |
}, this); |
|
9078 |
messageHandler.on('PasswordRequest', function (exception) { |
|
9079 |
var _this11 = this; |
|
9080 |
|
|
9081 |
this._passwordCapability = (0, _util.createPromiseCapability)(); |
|
9082 |
if (loadingTask.onPassword) { |
|
9083 |
var updatePassword = function updatePassword(password) { |
|
9084 |
_this11._passwordCapability.resolve({ password: password }); |
|
9085 |
}; |
|
9086 |
try { |
|
9087 |
loadingTask.onPassword(updatePassword, exception.code); |
|
9088 |
} catch (ex) { |
|
9089 |
this._passwordCapability.reject(ex); |
|
9090 |
} |
|
9091 |
} else { |
|
9092 |
this._passwordCapability.reject(new _util.PasswordException(exception.message, exception.code)); |
|
9093 |
} |
|
9094 |
return this._passwordCapability.promise; |
|
9095 |
}, this); |
|
9096 |
messageHandler.on('PasswordException', function (exception) { |
|
9097 |
loadingTask._capability.reject(new _util.PasswordException(exception.message, exception.code)); |
|
9098 |
}, this); |
|
9099 |
messageHandler.on('InvalidPDF', function (exception) { |
|
9100 |
loadingTask._capability.reject(new _util.InvalidPDFException(exception.message)); |
|
9101 |
}, this); |
|
9102 |
messageHandler.on('MissingPDF', function (exception) { |
|
9103 |
loadingTask._capability.reject(new _util.MissingPDFException(exception.message)); |
|
9104 |
}, this); |
|
9105 |
messageHandler.on('UnexpectedResponse', function (exception) { |
|
9106 |
loadingTask._capability.reject(new _util.UnexpectedResponseException(exception.message, exception.status)); |
|
9107 |
}, this); |
|
9108 |
messageHandler.on('UnknownError', function (exception) { |
|
9109 |
loadingTask._capability.reject(new _util.UnknownErrorException(exception.message, exception.details)); |
|
9110 |
}, this); |
|
9111 |
messageHandler.on('DataLoaded', function (data) { |
|
9112 |
if (loadingTask.onProgress) { |
|
9113 |
loadingTask.onProgress({ |
|
9114 |
loaded: data.length, |
|
9115 |
total: data.length |
|
9116 |
}); |
|
9117 |
} |
|
9118 |
this.downloadInfoCapability.resolve(data); |
|
9119 |
}, this); |
|
9120 |
messageHandler.on('StartRenderPage', function (data) { |
|
9121 |
if (this.destroyed) { |
|
9122 |
return; |
|
9123 |
} |
|
9124 |
var page = this.pageCache[data.pageIndex]; |
|
9125 |
page._stats.timeEnd('Page Request'); |
|
9126 |
page._startRenderPage(data.transparency, data.intent); |
|
9127 |
}, this); |
|
9128 |
messageHandler.on('RenderPageChunk', function (data) { |
|
9129 |
if (this.destroyed) { |
|
9130 |
return; |
|
9131 |
} |
|
9132 |
var page = this.pageCache[data.pageIndex]; |
|
9133 |
page._renderPageChunk(data.operatorList, data.intent); |
|
9134 |
}, this); |
|
9135 |
messageHandler.on('commonobj', function (data) { |
|
9136 |
var _this12 = this; |
|
9137 |
|
|
9138 |
if (this.destroyed) { |
|
9139 |
return; |
|
9140 |
} |
|
9141 |
|
|
9142 |
var _data = _slicedToArray(data, 3), |
|
9143 |
id = _data[0], |
|
9144 |
type = _data[1], |
|
9145 |
exportedData = _data[2]; |
|
9146 |
|
|
9147 |
if (this.commonObjs.hasData(id)) { |
|
9148 |
return; |
|
9149 |
} |
|
9150 |
switch (type) { |
|
9151 |
case 'Font': |
|
9152 |
var params = this._params; |
|
9153 |
if ('error' in exportedData) { |
|
9154 |
var exportedError = exportedData.error; |
|
9155 |
(0, _util.warn)('Error during font loading: ' + exportedError); |
|
9156 |
this.commonObjs.resolve(id, exportedError); |
|
9157 |
break; |
|
9158 |
} |
|
9159 |
var fontRegistry = null; |
|
9160 |
if (params.pdfBug && _global_scope2.default.FontInspector && _global_scope2.default.FontInspector.enabled) { |
|
9161 |
fontRegistry = { |
|
9162 |
registerFont: function registerFont(font, url) { |
|
9163 |
_global_scope2.default['FontInspector'].fontAdded(font, url); |
|
9164 |
} |
|
9165 |
}; |
|
9166 |
} |
|
9167 |
var font = new _font_loader.FontFaceObject(exportedData, { |
|
9168 |
isEvalSupported: params.isEvalSupported, |
|
9169 |
disableFontFace: params.disableFontFace, |
|
9170 |
ignoreErrors: params.ignoreErrors, |
|
9171 |
onUnsupportedFeature: this._onUnsupportedFeature.bind(this), |
|
9172 |
fontRegistry: fontRegistry |
|
9173 |
}); |
|
9174 |
var fontReady = function fontReady(fontObjs) { |
|
9175 |
_this12.commonObjs.resolve(id, font); |
|
9176 |
}; |
|
9177 |
this.fontLoader.bind([font], fontReady); |
|
9178 |
break; |
|
9179 |
case 'FontPath': |
|
9180 |
this.commonObjs.resolve(id, exportedData); |
|
9181 |
break; |
|
9182 |
default: |
|
9183 |
throw new Error('Got unknown common object type ' + type); |
|
9184 |
} |
|
9185 |
}, this); |
|
9186 |
messageHandler.on('obj', function (data) { |
|
9187 |
if (this.destroyed) { |
|
9188 |
return; |
|
9189 |
} |
|
9190 |
|
|
9191 |
var _data2 = _slicedToArray(data, 4), |
|
9192 |
id = _data2[0], |
|
9193 |
pageIndex = _data2[1], |
|
9194 |
type = _data2[2], |
|
9195 |
imageData = _data2[3]; |
|
9196 |
|
|
9197 |
var pageProxy = this.pageCache[pageIndex]; |
|
9198 |
if (pageProxy.objs.hasData(id)) { |
|
9199 |
return; |
|
9200 |
} |
|
9201 |
switch (type) { |
|
9202 |
case 'JpegStream': |
|
9203 |
return new Promise(function (resolve, reject) { |
|
9204 |
var img = new Image(); |
|
9205 |
img.onload = function () { |
|
9206 |
resolve(img); |
|
9207 |
}; |
|
9208 |
img.onerror = function () { |
|
9209 |
reject(new Error('Error during JPEG image loading')); |
|
9210 |
}; |
|
9211 |
img.src = imageData; |
|
9212 |
}).then(function (img) { |
|
9213 |
pageProxy.objs.resolve(id, img); |
|
9214 |
}); |
|
9215 |
case 'Image': |
|
9216 |
pageProxy.objs.resolve(id, imageData); |
|
9217 |
var MAX_IMAGE_SIZE_TO_STORE = 8000000; |
|
9218 |
if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) { |
|
9219 |
pageProxy.cleanupAfterRender = true; |
|
9220 |
} |
|
9221 |
break; |
|
9222 |
default: |
|
9223 |
throw new Error('Got unknown object type ' + type); |
|
9224 |
} |
|
9225 |
}, this); |
|
9226 |
messageHandler.on('DocProgress', function (data) { |
|
9227 |
if (this.destroyed) { |
|
9228 |
return; |
|
9229 |
} |
|
9230 |
if (loadingTask.onProgress) { |
|
9231 |
loadingTask.onProgress({ |
|
9232 |
loaded: data.loaded, |
|
9233 |
total: data.total |
|
9234 |
}); |
|
9235 |
} |
|
9236 |
}, this); |
|
9237 |
messageHandler.on('PageError', function (data) { |
|
9238 |
if (this.destroyed) { |
|
9239 |
return; |
|
9240 |
} |
|
9241 |
var page = this.pageCache[data.pageNum - 1]; |
|
9242 |
var intentState = page.intentStates[data.intent]; |
|
9243 |
if (intentState.displayReadyCapability) { |
|
9244 |
intentState.displayReadyCapability.reject(data.error); |
|
9245 |
} else { |
|
9246 |
throw new Error(data.error); |
|
9247 |
} |
|
9248 |
if (intentState.operatorList) { |
|
9249 |
intentState.operatorList.lastChunk = true; |
|
9250 |
for (var i = 0; i < intentState.renderTasks.length; i++) { |
|
9251 |
intentState.renderTasks[i].operatorListChanged(); |
|
9252 |
} |
|
9253 |
} |
|
9254 |
}, this); |
|
9255 |
messageHandler.on('UnsupportedFeature', this._onUnsupportedFeature, this); |
|
9256 |
messageHandler.on('JpegDecode', function (data) { |
|
9257 |
if (this.destroyed) { |
|
9258 |
return Promise.reject(new Error('Worker was destroyed')); |
|
9259 |
} |
|
9260 |
if (typeof document === 'undefined') { |
|
9261 |
return Promise.reject(new Error('"document" is not defined.')); |
|
9262 |
} |
|
9263 |
|
|
9264 |
var _data3 = _slicedToArray(data, 2), |
|
9265 |
imageUrl = _data3[0], |
|
9266 |
components = _data3[1]; |
|
9267 |
|
|
9268 |
if (components !== 3 && components !== 1) { |
|
9269 |
return Promise.reject(new Error('Only 3 components or 1 component can be returned')); |
|
9270 |
} |
|
9271 |
return new Promise(function (resolve, reject) { |
|
9272 |
var img = new Image(); |
|
9273 |
img.onload = function () { |
|
9274 |
var width = img.width; |
|
9275 |
var height = img.height; |
|
9276 |
var size = width * height; |
|
9277 |
var rgbaLength = size * 4; |
|
9278 |
var buf = new Uint8ClampedArray(size * components); |
|
9279 |
var tmpCanvas = document.createElement('canvas'); |
|
9280 |
tmpCanvas.width = width; |
|
9281 |
tmpCanvas.height = height; |
|
9282 |
var tmpCtx = tmpCanvas.getContext('2d'); |
|
9283 |
tmpCtx.drawImage(img, 0, 0); |
|
9284 |
var data = tmpCtx.getImageData(0, 0, width, height).data; |
|
9285 |
if (components === 3) { |
|
9286 |
for (var i = 0, j = 0; i < rgbaLength; i += 4, j += 3) { |
|
9287 |
buf[j] = data[i]; |
|
9288 |
buf[j + 1] = data[i + 1]; |
|
9289 |
buf[j + 2] = data[i + 2]; |
|
9290 |
} |
|
9291 |
} else if (components === 1) { |
|
9292 |
for (var _i = 0, _j = 0; _i < rgbaLength; _i += 4, _j++) { |
|
9293 |
buf[_j] = data[_i]; |
|
9294 |
} |
|
9295 |
} |
|
9296 |
resolve({ |
|
9297 |
data: buf, |
|
9298 |
width: width, |
|
9299 |
height: height |
|
9300 |
}); |
|
9301 |
}; |
|
9302 |
img.onerror = function () { |
|
9303 |
reject(new Error('JpegDecode failed to load image')); |
|
9304 |
}; |
|
9305 |
img.src = imageUrl; |
|
9306 |
}); |
|
9307 |
}, this); |
|
9308 |
messageHandler.on('FetchBuiltInCMap', function (data) { |
|
9309 |
if (this.destroyed) { |
|
9310 |
return Promise.reject(new Error('Worker was destroyed')); |
|
9311 |
} |
|
9312 |
return this.CMapReaderFactory.fetch({ name: data.name }); |
|
9313 |
}, this); |
|
9314 |
} |
|
9315 |
}, { |
|
9316 |
key: '_onUnsupportedFeature', |
|
9317 |
value: function _onUnsupportedFeature(_ref6) { |
|
9318 |
var featureId = _ref6.featureId; |
|
9319 |
|
|
9320 |
if (this.destroyed) { |
|
9321 |
return; |
|
9322 |
} |
|
9323 |
if (this.loadingTask.onUnsupportedFeature) { |
|
9324 |
this.loadingTask.onUnsupportedFeature(featureId); |
|
9325 |
} |
|
9326 |
} |
|
9327 |
}, { |
|
9328 |
key: 'getData', |
|
9329 |
value: function getData() { |
|
9330 |
return this.messageHandler.sendWithPromise('GetData', null); |
|
9331 |
} |
|
9332 |
}, { |
|
9333 |
key: 'getPage', |
|
9334 |
value: function getPage(pageNumber) { |
|
9335 |
var _this13 = this; |
|
9336 |
|
|
9337 |
if (!Number.isInteger(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) { |
|
9338 |
return Promise.reject(new Error('Invalid page request')); |
|
9339 |
} |
|
9340 |
var pageIndex = pageNumber - 1; |
|
9341 |
if (pageIndex in this.pagePromises) { |
|
9342 |
return this.pagePromises[pageIndex]; |
|
9343 |
} |
|
9344 |
var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) { |
|
9345 |
if (_this13.destroyed) { |
|
9346 |
throw new Error('Transport destroyed'); |
|
9347 |
} |
|
9348 |
var page = new PDFPageProxy(pageIndex, pageInfo, _this13, _this13._params.pdfBug); |
|
9349 |
_this13.pageCache[pageIndex] = page; |
|
9350 |
return page; |
|
9351 |
}); |
|
9352 |
this.pagePromises[pageIndex] = promise; |
|
9353 |
return promise; |
|
9354 |
} |
|
9355 |
}, { |
|
9356 |
key: 'getPageIndex', |
|
9357 |
value: function getPageIndex(ref) { |
|
9358 |
return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) { |
|
9359 |
return Promise.reject(new Error(reason)); |
|
9360 |
}); |
|
9361 |
} |
|
9362 |
}, { |
|
9363 |
key: 'getAnnotations', |
|
9364 |
value: function getAnnotations(pageIndex, intent) { |
|
9365 |
return this.messageHandler.sendWithPromise('GetAnnotations', { |
|
9366 |
pageIndex: pageIndex, |
|
9367 |
intent: intent |
|
9368 |
}); |
|
9369 |
} |
|
9370 |
}, { |
|
9371 |
key: 'getDestinations', |
|
9372 |
value: function getDestinations() { |
|
9373 |
return this.messageHandler.sendWithPromise('GetDestinations', null); |
|
9374 |
} |
|
9375 |
}, { |
|
9376 |
key: 'getDestination', |
|
9377 |
value: function getDestination(id) { |
|
9378 |
if (typeof id !== 'string') { |
|
9379 |
return Promise.reject(new Error('Invalid destination request.')); |
|
9380 |
} |
|
9381 |
return this.messageHandler.sendWithPromise('GetDestination', { id: id }); |
|
9382 |
} |
|
9383 |
}, { |
|
9384 |
key: 'getPageLabels', |
|
9385 |
value: function getPageLabels() { |
|
9386 |
return this.messageHandler.sendWithPromise('GetPageLabels', null); |
|
9387 |
} |
|
9388 |
}, { |
|
9389 |
key: 'getPageMode', |
|
9390 |
value: function getPageMode() { |
|
9391 |
return this.messageHandler.sendWithPromise('GetPageMode', null); |
|
9392 |
} |
|
9393 |
}, { |
|
9394 |
key: 'getAttachments', |
|
9395 |
value: function getAttachments() { |
|
9396 |
return this.messageHandler.sendWithPromise('GetAttachments', null); |
|
9397 |
} |
|
9398 |
}, { |
|
9399 |
key: 'getJavaScript', |
|
9400 |
value: function getJavaScript() { |
|
9401 |
return this.messageHandler.sendWithPromise('GetJavaScript', null); |
|
9402 |
} |
|
9403 |
}, { |
|
9404 |
key: 'getOutline', |
|
9405 |
value: function getOutline() { |
|
9406 |
return this.messageHandler.sendWithPromise('GetOutline', null); |
|
9407 |
} |
|
9408 |
}, { |
|
9409 |
key: 'getPermissions', |
|
9410 |
value: function getPermissions() { |
|
9411 |
return this.messageHandler.sendWithPromise('GetPermissions', null); |
|
9412 |
} |
|
9413 |
}, { |
|
9414 |
key: 'getMetadata', |
|
9415 |
value: function getMetadata() { |
|
9416 |
var _this14 = this; |
|
9417 |
|
|
9418 |
return this.messageHandler.sendWithPromise('GetMetadata', null).then(function (results) { |
|
9419 |
return { |
|
9420 |
info: results[0], |
|
9421 |
metadata: results[1] ? new _metadata.Metadata(results[1]) : null, |
|
9422 |
contentDispositionFilename: _this14._fullReader ? _this14._fullReader.filename : null |
|
9423 |
}; |
|
9424 |
}); |
|
9425 |
} |
|
9426 |
}, { |
|
9427 |
key: 'getStats', |
|
9428 |
value: function getStats() { |
|
9429 |
return this.messageHandler.sendWithPromise('GetStats', null); |
|
9430 |
} |
|
9431 |
}, { |
|
9432 |
key: 'startCleanup', |
|
9433 |
value: function startCleanup() { |
|
9434 |
var _this15 = this; |
|
9435 |
|
|
9436 |
this.messageHandler.sendWithPromise('Cleanup', null).then(function () { |
|
9437 |
for (var i = 0, ii = _this15.pageCache.length; i < ii; i++) { |
|
9438 |
var page = _this15.pageCache[i]; |
|
9439 |
if (page) { |
|
9440 |
page.cleanup(); |
|
9441 |
} |
|
9442 |
} |
|
9443 |
_this15.commonObjs.clear(); |
|
9444 |
_this15.fontLoader.clear(); |
|
9445 |
}); |
|
9446 |
} |
|
9447 |
}, { |
|
9448 |
key: 'loadingParams', |
|
9449 |
get: function get() { |
|
9450 |
var params = this._params; |
|
9451 |
return (0, _util.shadow)(this, 'loadingParams', { |
|
9452 |
disableAutoFetch: params.disableAutoFetch, |
|
9453 |
disableCreateObjectURL: params.disableCreateObjectURL, |
|
9454 |
disableFontFace: params.disableFontFace, |
|
9455 |
nativeImageDecoderSupport: params.nativeImageDecoderSupport |
|
9456 |
}); |
|
9457 |
} |
|
9458 |
}]); |
|
9459 |
|
|
9460 |
return WorkerTransport; |
|
9461 |
}(); |
|
9462 |
|
|
9463 |
var PDFObjects = function PDFObjectsClosure() { |
|
9464 |
function PDFObjects() { |
|
9465 |
this.objs = Object.create(null); |
|
9466 |
} |
|
9467 |
PDFObjects.prototype = { |
|
9468 |
ensureObj: function PDFObjects_ensureObj(objId) { |
|
9469 |
if (this.objs[objId]) { |
|
9470 |
return this.objs[objId]; |
|
9471 |
} |
|
9472 |
var obj = { |
|
9473 |
capability: (0, _util.createPromiseCapability)(), |
|
9474 |
data: null, |
|
9475 |
resolved: false |
|
9476 |
}; |
|
9477 |
this.objs[objId] = obj; |
|
9478 |
return obj; |
|
9479 |
}, |
|
9480 |
get: function PDFObjects_get(objId, callback) { |
|
9481 |
if (callback) { |
|
9482 |
this.ensureObj(objId).capability.promise.then(callback); |
|
9483 |
return null; |
|
9484 |
} |
|
9485 |
var obj = this.objs[objId]; |
|
9486 |
if (!obj || !obj.resolved) { |
|
9487 |
throw new Error('Requesting object that isn\'t resolved yet ' + objId); |
|
9488 |
} |
|
9489 |
return obj.data; |
|
9490 |
}, |
|
9491 |
resolve: function PDFObjects_resolve(objId, data) { |
|
9492 |
var obj = this.ensureObj(objId); |
|
9493 |
obj.resolved = true; |
|
9494 |
obj.data = data; |
|
9495 |
obj.capability.resolve(data); |
|
9496 |
}, |
|
9497 |
isResolved: function PDFObjects_isResolved(objId) { |
|
9498 |
var objs = this.objs; |
|
9499 |
if (!objs[objId]) { |
|
9500 |
return false; |
|
9501 |
} |
|
9502 |
return objs[objId].resolved; |
|
9503 |
}, |
|
9504 |
hasData: function PDFObjects_hasData(objId) { |
|
9505 |
return this.isResolved(objId); |
|
9506 |
}, |
|
9507 |
getData: function PDFObjects_getData(objId) { |
|
9508 |
var objs = this.objs; |
|
9509 |
if (!objs[objId] || !objs[objId].resolved) { |
|
9510 |
return null; |
|
9511 |
} |
|
9512 |
return objs[objId].data; |
|
9513 |
}, |
|
9514 |
clear: function PDFObjects_clear() { |
|
9515 |
this.objs = Object.create(null); |
|
9516 |
} |
|
9517 |
}; |
|
9518 |
return PDFObjects; |
|
9519 |
}(); |
|
9520 |
var RenderTask = function RenderTaskClosure() { |
|
9521 |
function RenderTask(internalRenderTask) { |
|
9522 |
this._internalRenderTask = internalRenderTask; |
|
9523 |
this.onContinue = null; |
|
9524 |
} |
|
9525 |
RenderTask.prototype = { |
|
9526 |
get promise() { |
|
9527 |
return this._internalRenderTask.capability.promise; |
|
9528 |
}, |
|
9529 |
cancel: function RenderTask_cancel() { |
|
9530 |
this._internalRenderTask.cancel(); |
|
9531 |
}, |
|
9532 |
then: function RenderTask_then(onFulfilled, onRejected) { |
|
9533 |
return this.promise.then.apply(this.promise, arguments); |
|
9534 |
} |
|
9535 |
}; |
|
9536 |
return RenderTask; |
|
9537 |
}(); |
|
9538 |
var InternalRenderTask = function InternalRenderTaskClosure() { |
|
9539 |
var canvasInRendering = new WeakMap(); |
|
9540 |
function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber, canvasFactory, webGLContext) { |
|
9541 |
var pdfBug = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false; |
|
9542 |
|
|
9543 |
this.callback = callback; |
|
9544 |
this.params = params; |
|
9545 |
this.objs = objs; |
|
9546 |
this.commonObjs = commonObjs; |
|
9547 |
this.operatorListIdx = null; |
|
9548 |
this.operatorList = operatorList; |
|
9549 |
this.pageNumber = pageNumber; |
|
9550 |
this.canvasFactory = canvasFactory; |
|
9551 |
this.webGLContext = webGLContext; |
|
9552 |
this._pdfBug = pdfBug; |
|
9553 |
this.running = false; |
|
9554 |
this.graphicsReadyCallback = null; |
|
9555 |
this.graphicsReady = false; |
|
9556 |
this.useRequestAnimationFrame = false; |
|
9557 |
this.cancelled = false; |
|
9558 |
this.capability = (0, _util.createPromiseCapability)(); |
|
9559 |
this.task = new RenderTask(this); |
|
9560 |
this._continueBound = this._continue.bind(this); |
|
9561 |
this._scheduleNextBound = this._scheduleNext.bind(this); |
|
9562 |
this._nextBound = this._next.bind(this); |
|
9563 |
this._canvas = params.canvasContext.canvas; |
|
9564 |
} |
|
9565 |
InternalRenderTask.prototype = { |
|
9566 |
initializeGraphics: function initializeGraphics(transparency) { |
|
9567 |
if (this.cancelled) { |
|
9568 |
return; |
|
9569 |
} |
|
9570 |
if (this._canvas) { |
|
9571 |
if (canvasInRendering.has(this._canvas)) { |
|
9572 |
throw new Error('Cannot use the same canvas during multiple render() operations. ' + 'Use different canvas or ensure previous operations were ' + 'cancelled or completed.'); |
|
9573 |
} |
|
9574 |
canvasInRendering.set(this._canvas, this); |
|
9575 |
} |
|
9576 |
if (this._pdfBug && _global_scope2.default.StepperManager && _global_scope2.default.StepperManager.enabled) { |
|
9577 |
this.stepper = _global_scope2.default.StepperManager.create(this.pageNumber - 1); |
|
9578 |
this.stepper.init(this.operatorList); |
|
9579 |
this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint(); |
|
9580 |
} |
|
9581 |
var params = this.params; |
|
9582 |
this.gfx = new _canvas.CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext, params.imageLayer); |
|
9583 |
this.gfx.beginDrawing({ |
|
9584 |
transform: params.transform, |
|
9585 |
viewport: params.viewport, |
|
9586 |
transparency: transparency, |
|
9587 |
background: params.background |
|
9588 |
}); |
|
9589 |
this.operatorListIdx = 0; |
|
9590 |
this.graphicsReady = true; |
|
9591 |
if (this.graphicsReadyCallback) { |
|
9592 |
this.graphicsReadyCallback(); |
|
9593 |
} |
|
9594 |
}, |
|
9595 |
|
|
9596 |
cancel: function InternalRenderTask_cancel() { |
|
9597 |
this.running = false; |
|
9598 |
this.cancelled = true; |
|
9599 |
if (this._canvas) { |
|
9600 |
canvasInRendering.delete(this._canvas); |
|
9601 |
} |
|
9602 |
this.callback(new _dom_utils.RenderingCancelledException('Rendering cancelled, page ' + this.pageNumber, 'canvas')); |
|
9603 |
}, |
|
9604 |
operatorListChanged: function InternalRenderTask_operatorListChanged() { |
|
9605 |
if (!this.graphicsReady) { |
|
9606 |
if (!this.graphicsReadyCallback) { |
|
9607 |
this.graphicsReadyCallback = this._continueBound; |
|
9608 |
} |
|
9609 |
return; |
|
9610 |
} |
|
9611 |
if (this.stepper) { |
|
9612 |
this.stepper.updateOperatorList(this.operatorList); |
|
9613 |
} |
|
9614 |
if (this.running) { |
|
9615 |
return; |
|
9616 |
} |
|
9617 |
this._continue(); |
|
9618 |
}, |
|
9619 |
_continue: function InternalRenderTask__continue() { |
|
9620 |
this.running = true; |
|
9621 |
if (this.cancelled) { |
|
9622 |
return; |
|
9623 |
} |
|
9624 |
if (this.task.onContinue) { |
|
9625 |
this.task.onContinue(this._scheduleNextBound); |
|
9626 |
} else { |
|
9627 |
this._scheduleNext(); |
|
9628 |
} |
|
9629 |
}, |
|
9630 |
_scheduleNext: function InternalRenderTask__scheduleNext() { |
|
9631 |
var _this16 = this; |
|
9632 |
|
|
9633 |
if (this.useRequestAnimationFrame && typeof window !== 'undefined') { |
|
9634 |
window.requestAnimationFrame(function () { |
|
9635 |
_this16._nextBound().catch(_this16.callback); |
|
9636 |
}); |
|
9637 |
} else { |
|
9638 |
Promise.resolve().then(this._nextBound).catch(this.callback); |
|
9639 |
} |
|
9640 |
}, |
|
9641 |
_next: function InternalRenderTask__next() { |
|
9642 |
var _this17 = this; |
|
9643 |
|
|
9644 |
return new Promise(function () { |
|
9645 |
if (_this17.cancelled) { |
|
9646 |
return; |
|
9647 |
} |
|
9648 |
_this17.operatorListIdx = _this17.gfx.executeOperatorList(_this17.operatorList, _this17.operatorListIdx, _this17._continueBound, _this17.stepper); |
|
9649 |
if (_this17.operatorListIdx === _this17.operatorList.argsArray.length) { |
|
9650 |
_this17.running = false; |
|
9651 |
if (_this17.operatorList.lastChunk) { |
|
9652 |
_this17.gfx.endDrawing(); |
|
9653 |
if (_this17._canvas) { |
|
9654 |
canvasInRendering.delete(_this17._canvas); |
|
9655 |
} |
|
9656 |
_this17.callback(); |
|
9657 |
} |
|
9658 |
} |
|
9659 |
}); |
|
9660 |
} |
|
9661 |
}; |
|
9662 |
return InternalRenderTask; |
|
9663 |
}(); |
|
9664 |
var version, build; |
|
9665 |
{ |
|
9666 |
exports.version = version = '2.0.943'; |
|
9667 |
exports.build = build = 'dc98bf76'; |
|
9668 |
} |
|
9669 |
exports.getDocument = getDocument; |
|
9670 |
exports.LoopbackPort = LoopbackPort; |
|
9671 |
exports.PDFDataRangeTransport = PDFDataRangeTransport; |
|
9672 |
exports.PDFWorker = PDFWorker; |
|
9673 |
exports.PDFDocumentProxy = PDFDocumentProxy; |
|
9674 |
exports.PDFPageProxy = PDFPageProxy; |
|
9675 |
exports.setPDFNetworkStreamFactory = setPDFNetworkStreamFactory; |
|
9676 |
exports.version = version; |
|
9677 |
exports.build = build; |
|
9678 |
|
|
9679 |
/***/ }), |
|
9680 |
/* 130 */ |
|
9681 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
9682 |
|
|
9683 |
"use strict"; |
|
9684 |
|
|
9685 |
|
|
9686 |
Object.defineProperty(exports, "__esModule", { |
|
9687 |
value: true |
|
9688 |
}); |
|
9689 |
exports.loadScript = exports.DummyStatTimer = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.getFilenameFromUrl = exports.addLinkAttributes = exports.RenderingCancelledException = exports.PageViewport = undefined; |
|
9690 |
|
|
9691 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
|
9692 |
|
|
9693 |
var _util = __w_pdfjs_require__(1); |
|
9694 |
|
|
9695 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
9696 |
|
|
9697 |
var DEFAULT_LINK_REL = 'noopener noreferrer nofollow'; |
|
9698 |
var SVG_NS = 'http://www.w3.org/2000/svg'; |
|
9699 |
|
|
9700 |
var DOMCanvasFactory = function () { |
|
9701 |
function DOMCanvasFactory() { |
|
9702 |
_classCallCheck(this, DOMCanvasFactory); |
|
9703 |
} |
|
9704 |
|
|
9705 |
_createClass(DOMCanvasFactory, [{ |
|
9706 |
key: 'create', |
|
9707 |
value: function create(width, height) { |
|
9708 |
if (width <= 0 || height <= 0) { |
|
9709 |
throw new Error('invalid canvas size'); |
|
9710 |
} |
|
9711 |
var canvas = document.createElement('canvas'); |
|
9712 |
var context = canvas.getContext('2d'); |
|
9713 |
canvas.width = width; |
|
9714 |
canvas.height = height; |
|
9715 |
return { |
|
9716 |
canvas: canvas, |
|
9717 |
context: context |
|
9718 |
}; |
|
9719 |
} |
|
9720 |
}, { |
|
9721 |
key: 'reset', |
|
9722 |
value: function reset(canvasAndContext, width, height) { |
|
9723 |
if (!canvasAndContext.canvas) { |
|
9724 |
throw new Error('canvas is not specified'); |
|
9725 |
} |
|
9726 |
if (width <= 0 || height <= 0) { |
|
9727 |
throw new Error('invalid canvas size'); |
|
9728 |
} |
|
9729 |
canvasAndContext.canvas.width = width; |
|
9730 |
canvasAndContext.canvas.height = height; |
|
9731 |
} |
|
9732 |
}, { |
|
9733 |
key: 'destroy', |
|
9734 |
value: function destroy(canvasAndContext) { |
|
9735 |
if (!canvasAndContext.canvas) { |
|
9736 |
throw new Error('canvas is not specified'); |
|
9737 |
} |
|
9738 |
canvasAndContext.canvas.width = 0; |
|
9739 |
canvasAndContext.canvas.height = 0; |
|
9740 |
canvasAndContext.canvas = null; |
|
9741 |
canvasAndContext.context = null; |
|
9742 |
} |
|
9743 |
}]); |
|
9744 |
|
|
9745 |
return DOMCanvasFactory; |
|
9746 |
}(); |
|
9747 |
|
|
9748 |
var DOMCMapReaderFactory = function () { |
|
9749 |
function DOMCMapReaderFactory(_ref) { |
|
9750 |
var _ref$baseUrl = _ref.baseUrl, |
|
9751 |
baseUrl = _ref$baseUrl === undefined ? null : _ref$baseUrl, |
|
9752 |
_ref$isCompressed = _ref.isCompressed, |
|
9753 |
isCompressed = _ref$isCompressed === undefined ? false : _ref$isCompressed; |
|
9754 |
|
|
9755 |
_classCallCheck(this, DOMCMapReaderFactory); |
|
9756 |
|
|
9757 |
this.baseUrl = baseUrl; |
|
9758 |
this.isCompressed = isCompressed; |
|
9759 |
} |
|
9760 |
|
|
9761 |
_createClass(DOMCMapReaderFactory, [{ |
|
9762 |
key: 'fetch', |
|
9763 |
value: function fetch(_ref2) { |
|
9764 |
var _this = this; |
|
9765 |
|
|
9766 |
var name = _ref2.name; |
|
9767 |
|
|
9768 |
if (!this.baseUrl) { |
|
9769 |
return Promise.reject(new Error('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.')); |
|
9770 |
} |
|
9771 |
if (!name) { |
|
9772 |
return Promise.reject(new Error('CMap name must be specified.')); |
|
9773 |
} |
|
9774 |
return new Promise(function (resolve, reject) { |
|
9775 |
var url = _this.baseUrl + name + (_this.isCompressed ? '.bcmap' : ''); |
|
9776 |
var request = new XMLHttpRequest(); |
|
9777 |
request.open('GET', url, true); |
|
9778 |
if (_this.isCompressed) { |
|
9779 |
request.responseType = 'arraybuffer'; |
|
9780 |
} |
|
9781 |
request.onreadystatechange = function () { |
|
9782 |
if (request.readyState !== XMLHttpRequest.DONE) { |
|
9783 |
return; |
|
9784 |
} |
|
9785 |
if (request.status === 200 || request.status === 0) { |
|
9786 |
var data = void 0; |
|
9787 |
if (_this.isCompressed && request.response) { |
|
9788 |
data = new Uint8Array(request.response); |
|
9789 |
} else if (!_this.isCompressed && request.responseText) { |
|
9790 |
data = (0, _util.stringToBytes)(request.responseText); |
|
9791 |
} |
|
9792 |
if (data) { |
|
9793 |
resolve({ |
|
9794 |
cMapData: data, |
|
9795 |
compressionType: _this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE |
|
9796 |
}); |
|
9797 |
return; |
|
9798 |
} |
|
9799 |
} |
|
9800 |
reject(new Error('Unable to load ' + (_this.isCompressed ? 'binary ' : '') + 'CMap at: ' + url)); |
|
9801 |
}; |
|
9802 |
request.send(null); |
|
9803 |
}); |
|
9804 |
} |
|
9805 |
}]); |
|
9806 |
|
|
9807 |
return DOMCMapReaderFactory; |
|
9808 |
}(); |
|
9809 |
|
|
9810 |
var DOMSVGFactory = function () { |
|
9811 |
function DOMSVGFactory() { |
|
9812 |
_classCallCheck(this, DOMSVGFactory); |
|
9813 |
} |
|
9814 |
|
|
9815 |
_createClass(DOMSVGFactory, [{ |
|
9816 |
key: 'create', |
|
9817 |
value: function create(width, height) { |
|
9818 |
(0, _util.assert)(width > 0 && height > 0, 'Invalid SVG dimensions'); |
|
9819 |
var svg = document.createElementNS(SVG_NS, 'svg:svg'); |
|
9820 |
svg.setAttribute('version', '1.1'); |
|
9821 |
svg.setAttribute('width', width + 'px'); |
|
9822 |
svg.setAttribute('height', height + 'px'); |
|
9823 |
svg.setAttribute('preserveAspectRatio', 'none'); |
|
9824 |
svg.setAttribute('viewBox', '0 0 ' + width + ' ' + height); |
|
9825 |
return svg; |
|
9826 |
} |
|
9827 |
}, { |
|
9828 |
key: 'createElement', |
|
9829 |
value: function createElement(type) { |
|
9830 |
(0, _util.assert)(typeof type === 'string', 'Invalid SVG element type'); |
|
9831 |
return document.createElementNS(SVG_NS, type); |
|
9832 |
} |
|
9833 |
}]); |
|
9834 |
|
|
9835 |
return DOMSVGFactory; |
|
9836 |
}(); |
|
9837 |
|
|
9838 |
var PageViewport = function () { |
|
9839 |
function PageViewport(_ref3) { |
|
9840 |
var viewBox = _ref3.viewBox, |
|
9841 |
scale = _ref3.scale, |
|
9842 |
rotation = _ref3.rotation, |
|
9843 |
_ref3$offsetX = _ref3.offsetX, |
|
9844 |
offsetX = _ref3$offsetX === undefined ? 0 : _ref3$offsetX, |
|
9845 |
_ref3$offsetY = _ref3.offsetY, |
|
9846 |
offsetY = _ref3$offsetY === undefined ? 0 : _ref3$offsetY, |
|
9847 |
_ref3$dontFlip = _ref3.dontFlip, |
|
9848 |
dontFlip = _ref3$dontFlip === undefined ? false : _ref3$dontFlip; |
|
9849 |
|
|
9850 |
_classCallCheck(this, PageViewport); |
|
9851 |
|
|
9852 |
this.viewBox = viewBox; |
|
9853 |
this.scale = scale; |
|
9854 |
this.rotation = rotation; |
|
9855 |
this.offsetX = offsetX; |
|
9856 |
this.offsetY = offsetY; |
|
9857 |
var centerX = (viewBox[2] + viewBox[0]) / 2; |
|
9858 |
var centerY = (viewBox[3] + viewBox[1]) / 2; |
|
9859 |
var rotateA = void 0, |
|
9860 |
rotateB = void 0, |
|
9861 |
rotateC = void 0, |
|
9862 |
rotateD = void 0; |
|
9863 |
rotation = rotation % 360; |
|
9864 |
rotation = rotation < 0 ? rotation + 360 : rotation; |
|
9865 |
switch (rotation) { |
|
9866 |
case 180: |
|
9867 |
rotateA = -1; |
|
9868 |
rotateB = 0; |
|
9869 |
rotateC = 0; |
|
9870 |
rotateD = 1; |
|
9871 |
break; |
|
9872 |
case 90: |
|
9873 |
rotateA = 0; |
|
9874 |
rotateB = 1; |
|
9875 |
rotateC = 1; |
|
9876 |
rotateD = 0; |
|
9877 |
break; |
|
9878 |
case 270: |
|
9879 |
rotateA = 0; |
|
9880 |
rotateB = -1; |
|
9881 |
rotateC = -1; |
|
9882 |
rotateD = 0; |
|
9883 |
break; |
|
9884 |
default: |
|
9885 |
rotateA = 1; |
|
9886 |
rotateB = 0; |
|
9887 |
rotateC = 0; |
|
9888 |
rotateD = -1; |
|
9889 |
break; |
|
9890 |
} |
|
9891 |
if (dontFlip) { |
|
9892 |
rotateC = -rotateC; |
|
9893 |
rotateD = -rotateD; |
|
9894 |
} |
|
9895 |
var offsetCanvasX = void 0, |
|
9896 |
offsetCanvasY = void 0; |
|
9897 |
var width = void 0, |
|
9898 |
height = void 0; |
|
9899 |
if (rotateA === 0) { |
|
9900 |
offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX; |
|
9901 |
offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY; |
|
9902 |
width = Math.abs(viewBox[3] - viewBox[1]) * scale; |
|
9903 |
height = Math.abs(viewBox[2] - viewBox[0]) * scale; |
|
9904 |
} else { |
|
9905 |
offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX; |
|
9906 |
offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY; |
|
9907 |
width = Math.abs(viewBox[2] - viewBox[0]) * scale; |
|
9908 |
height = Math.abs(viewBox[3] - viewBox[1]) * scale; |
|
9909 |
} |
|
9910 |
this.transform = [rotateA * scale, rotateB * scale, rotateC * scale, rotateD * scale, offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY, offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY]; |
|
9911 |
this.width = width; |
|
9912 |
this.height = height; |
|
9913 |
} |
|
9914 |
|
|
9915 |
_createClass(PageViewport, [{ |
|
9916 |
key: 'clone', |
|
9917 |
value: function clone() { |
|
9918 |
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
|
9919 |
_ref4$scale = _ref4.scale, |
|
9920 |
scale = _ref4$scale === undefined ? this.scale : _ref4$scale, |
|
9921 |
_ref4$rotation = _ref4.rotation, |
|
9922 |
rotation = _ref4$rotation === undefined ? this.rotation : _ref4$rotation, |
|
9923 |
_ref4$dontFlip = _ref4.dontFlip, |
|
9924 |
dontFlip = _ref4$dontFlip === undefined ? false : _ref4$dontFlip; |
|
9925 |
|
|
9926 |
return new PageViewport({ |
|
9927 |
viewBox: this.viewBox.slice(), |
|
9928 |
scale: scale, |
|
9929 |
rotation: rotation, |
|
9930 |
offsetX: this.offsetX, |
|
9931 |
offsetY: this.offsetY, |
|
9932 |
dontFlip: dontFlip |
|
9933 |
}); |
|
9934 |
} |
|
9935 |
}, { |
|
9936 |
key: 'convertToViewportPoint', |
|
9937 |
value: function convertToViewportPoint(x, y) { |
|
9938 |
return _util.Util.applyTransform([x, y], this.transform); |
|
9939 |
} |
|
9940 |
}, { |
|
9941 |
key: 'convertToViewportRectangle', |
|
9942 |
value: function convertToViewportRectangle(rect) { |
|
9943 |
var tl = _util.Util.applyTransform([rect[0], rect[1]], this.transform); |
|
9944 |
var br = _util.Util.applyTransform([rect[2], rect[3]], this.transform); |
|
9945 |
return [tl[0], tl[1], br[0], br[1]]; |
|
9946 |
} |
|
9947 |
}, { |
|
9948 |
key: 'convertToPdfPoint', |
|
9949 |
value: function convertToPdfPoint(x, y) { |
|
9950 |
return _util.Util.applyInverseTransform([x, y], this.transform); |
|
9951 |
} |
|
9952 |
}]); |
|
9953 |
|
|
9954 |
return PageViewport; |
|
9955 |
}(); |
|
9956 |
|
|
9957 |
var RenderingCancelledException = function RenderingCancelledException() { |
|
9958 |
function RenderingCancelledException(msg, type) { |
|
9959 |
this.message = msg; |
|
9960 |
this.type = type; |
|
9961 |
} |
|
9962 |
RenderingCancelledException.prototype = new Error(); |
|
9963 |
RenderingCancelledException.prototype.name = 'RenderingCancelledException'; |
|
9964 |
RenderingCancelledException.constructor = RenderingCancelledException; |
|
9965 |
return RenderingCancelledException; |
|
9966 |
}(); |
|
9967 |
var LinkTarget = { |
|
9968 |
NONE: 0, |
|
9969 |
SELF: 1, |
|
9970 |
BLANK: 2, |
|
9971 |
PARENT: 3, |
|
9972 |
TOP: 4 |
|
9973 |
}; |
|
9974 |
var LinkTargetStringMap = ['', '_self', '_blank', '_parent', '_top']; |
|
9975 |
function addLinkAttributes(link) { |
|
9976 |
var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, |
|
9977 |
url = _ref5.url, |
|
9978 |
target = _ref5.target, |
|
9979 |
rel = _ref5.rel; |
|
9980 |
|
|
9981 |
link.href = link.title = url ? (0, _util.removeNullCharacters)(url) : ''; |
|
9982 |
if (url) { |
|
9983 |
var LinkTargetValues = Object.values(LinkTarget); |
|
9984 |
var targetIndex = LinkTargetValues.includes(target) ? target : LinkTarget.NONE; |
|
9985 |
link.target = LinkTargetStringMap[targetIndex]; |
|
9986 |
link.rel = typeof rel === 'string' ? rel : DEFAULT_LINK_REL; |
|
9987 |
} |
|
9988 |
} |
|
9989 |
function getFilenameFromUrl(url) { |
|
9990 |
var anchor = url.indexOf('#'); |
|
9991 |
var query = url.indexOf('?'); |
|
9992 |
var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length); |
|
9993 |
return url.substring(url.lastIndexOf('/', end) + 1, end); |
|
9994 |
} |
|
9995 |
|
|
9996 |
var StatTimer = function () { |
|
9997 |
function StatTimer() { |
|
9998 |
var enable = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; |
|
9999 |
|
|
10000 |
_classCallCheck(this, StatTimer); |
|
10001 |
|
|
10002 |
this.enabled = !!enable; |
|
10003 |
this.started = Object.create(null); |
|
10004 |
this.times = []; |
|
10005 |
} |
|
10006 |
|
|
10007 |
_createClass(StatTimer, [{ |
|
10008 |
key: 'time', |
|
10009 |
value: function time(name) { |
|
10010 |
if (!this.enabled) { |
|
10011 |
return; |
|
10012 |
} |
|
10013 |
if (name in this.started) { |
|
10014 |
(0, _util.warn)('Timer is already running for ' + name); |
|
10015 |
} |
|
10016 |
this.started[name] = Date.now(); |
|
10017 |
} |
|
10018 |
}, { |
|
10019 |
key: 'timeEnd', |
|
10020 |
value: function timeEnd(name) { |
|
10021 |
if (!this.enabled) { |
|
10022 |
return; |
|
10023 |
} |
|
10024 |
if (!(name in this.started)) { |
|
10025 |
(0, _util.warn)('Timer has not been started for ' + name); |
|
10026 |
} |
|
10027 |
this.times.push({ |
|
10028 |
'name': name, |
|
10029 |
'start': this.started[name], |
|
10030 |
'end': Date.now() |
|
10031 |
}); |
|
10032 |
delete this.started[name]; |
|
10033 |
} |
|
10034 |
}, { |
|
10035 |
key: 'toString', |
|
10036 |
value: function toString() { |
|
10037 |
var times = this.times; |
|
10038 |
var out = '', |
|
10039 |
longest = 0; |
|
10040 |
for (var i = 0, ii = times.length; i < ii; ++i) { |
|
10041 |
var name = times[i]['name']; |
|
10042 |
if (name.length > longest) { |
|
10043 |
longest = name.length; |
|
10044 |
} |
|
10045 |
} |
|
10046 |
for (var _i = 0, _ii = times.length; _i < _ii; ++_i) { |
|
10047 |
var span = times[_i]; |
|
10048 |
var duration = span.end - span.start; |
|
10049 |
out += span['name'].padEnd(longest) + ' ' + duration + 'ms\n'; |
|
10050 |
} |
|
10051 |
return out; |
|
10052 |
} |
|
10053 |
}]); |
|
10054 |
|
|
10055 |
return StatTimer; |
|
10056 |
}(); |
|
10057 |
|
|
10058 |
var DummyStatTimer = function () { |
|
10059 |
function DummyStatTimer() { |
|
10060 |
_classCallCheck(this, DummyStatTimer); |
|
10061 |
|
|
10062 |
(0, _util.unreachable)('Cannot initialize DummyStatTimer.'); |
|
10063 |
} |
|
10064 |
|
|
10065 |
_createClass(DummyStatTimer, null, [{ |
|
10066 |
key: 'time', |
|
10067 |
value: function time(name) {} |
|
10068 |
}, { |
|
10069 |
key: 'timeEnd', |
|
10070 |
value: function timeEnd(name) {} |
|
10071 |
}, { |
|
10072 |
key: 'toString', |
|
10073 |
value: function toString() { |
|
10074 |
return ''; |
|
10075 |
} |
|
10076 |
}]); |
|
10077 |
|
|
10078 |
return DummyStatTimer; |
|
10079 |
}(); |
|
10080 |
|
|
10081 |
function loadScript(src) { |
|
10082 |
return new Promise(function (resolve, reject) { |
|
10083 |
var script = document.createElement('script'); |
|
10084 |
script.src = src; |
|
10085 |
script.onload = resolve; |
|
10086 |
script.onerror = function () { |
|
10087 |
reject(new Error('Cannot load script at: ' + script.src)); |
|
10088 |
}; |
|
10089 |
(document.head || document.documentElement).appendChild(script); |
|
10090 |
}); |
|
10091 |
} |
|
10092 |
exports.PageViewport = PageViewport; |
|
10093 |
exports.RenderingCancelledException = RenderingCancelledException; |
|
10094 |
exports.addLinkAttributes = addLinkAttributes; |
|
10095 |
exports.getFilenameFromUrl = getFilenameFromUrl; |
|
10096 |
exports.LinkTarget = LinkTarget; |
|
10097 |
exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL; |
|
10098 |
exports.DOMCanvasFactory = DOMCanvasFactory; |
|
10099 |
exports.DOMCMapReaderFactory = DOMCMapReaderFactory; |
|
10100 |
exports.DOMSVGFactory = DOMSVGFactory; |
|
10101 |
exports.StatTimer = StatTimer; |
|
10102 |
exports.DummyStatTimer = DummyStatTimer; |
|
10103 |
exports.loadScript = loadScript; |
|
10104 |
|
|
10105 |
/***/ }), |
|
10106 |
/* 131 */ |
|
10107 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
10108 |
|
|
10109 |
"use strict"; |
|
10110 |
|
|
10111 |
|
|
10112 |
Object.defineProperty(exports, "__esModule", { |
|
10113 |
value: true |
|
10114 |
}); |
|
10115 |
exports.FontLoader = exports.FontFaceObject = undefined; |
|
10116 |
|
|
10117 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
|
10118 |
|
|
10119 |
var _util = __w_pdfjs_require__(1); |
|
10120 |
|
|
10121 |
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } |
|
10122 |
|
|
10123 |
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
|
10124 |
|
|
10125 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
10126 |
|
|
10127 |
var BaseFontLoader = function () { |
|
10128 |
function BaseFontLoader(docId) { |
|
10129 |
_classCallCheck(this, BaseFontLoader); |
|
10130 |
|
|
10131 |
if (this.constructor === BaseFontLoader) { |
|
10132 |
(0, _util.unreachable)('Cannot initialize BaseFontLoader.'); |
|
10133 |
} |
|
10134 |
this.docId = docId; |
|
10135 |
this.nativeFontFaces = []; |
|
10136 |
this.styleElement = null; |
|
10137 |
this.loadingContext = { |
|
10138 |
requests: [], |
|
10139 |
nextRequestId: 0 |
|
10140 |
}; |
|
10141 |
} |
|
10142 |
|
|
10143 |
_createClass(BaseFontLoader, [{ |
|
10144 |
key: 'addNativeFontFace', |
|
10145 |
value: function addNativeFontFace(nativeFontFace) { |
|
10146 |
this.nativeFontFaces.push(nativeFontFace); |
|
10147 |
document.fonts.add(nativeFontFace); |
|
10148 |
} |
|
10149 |
}, { |
|
10150 |
key: 'insertRule', |
|
10151 |
value: function insertRule(rule) { |
|
10152 |
var styleElement = this.styleElement; |
|
10153 |
if (!styleElement) { |
|
10154 |
styleElement = this.styleElement = document.createElement('style'); |
|
10155 |
styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId; |
|
10156 |
document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement); |
|
10157 |
} |
|
10158 |
var styleSheet = styleElement.sheet; |
|
10159 |
styleSheet.insertRule(rule, styleSheet.cssRules.length); |
|
10160 |
} |
|
10161 |
}, { |
|
10162 |
key: 'clear', |
|
10163 |
value: function clear() { |
|
10164 |
this.nativeFontFaces.forEach(function (nativeFontFace) { |
|
10165 |
document.fonts.delete(nativeFontFace); |
|
10166 |
}); |
|
10167 |
this.nativeFontFaces.length = 0; |
|
10168 |
if (this.styleElement) { |
|
10169 |
this.styleElement.remove(); |
|
10170 |
this.styleElement = null; |
|
10171 |
} |
|
10172 |
} |
|
10173 |
}, { |
|
10174 |
key: 'bind', |
|
10175 |
value: function bind(fonts, callback) { |
|
10176 |
var rules = []; |
|
10177 |
var fontsToLoad = []; |
|
10178 |
var fontLoadPromises = []; |
|
10179 |
var getNativeFontPromise = function getNativeFontPromise(nativeFontFace) { |
|
10180 |
return nativeFontFace.loaded.catch(function (reason) { |
|
10181 |
(0, _util.warn)('Failed to load font "' + nativeFontFace.family + '": ' + reason); |
|
10182 |
}); |
|
10183 |
}; |
|
10184 |
var _iteratorNormalCompletion = true; |
|
10185 |
var _didIteratorError = false; |
|
10186 |
var _iteratorError = undefined; |
|
10187 |
|
|
10188 |
try { |
|
10189 |
for (var _iterator = fonts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { |
|
10190 |
var font = _step.value; |
|
10191 |
|
|
10192 |
if (font.attached || font.missingFile) { |
|
10193 |
continue; |
|
10194 |
} |
|
10195 |
font.attached = true; |
|
10196 |
if (this.isFontLoadingAPISupported) { |
|
10197 |
var nativeFontFace = font.createNativeFontFace(); |
|
10198 |
if (nativeFontFace) { |
|
10199 |
this.addNativeFontFace(nativeFontFace); |
|
10200 |
fontLoadPromises.push(getNativeFontPromise(nativeFontFace)); |
|
10201 |
} |
|
10202 |
} else { |
|
10203 |
var rule = font.createFontFaceRule(); |
|
10204 |
if (rule) { |
|
10205 |
this.insertRule(rule); |
|
10206 |
rules.push(rule); |
|
10207 |
fontsToLoad.push(font); |
|
10208 |
} |
|
10209 |
} |
|
10210 |
} |
|
10211 |
} catch (err) { |
|
10212 |
_didIteratorError = true; |
|
10213 |
_iteratorError = err; |
|
10214 |
} finally { |
|
10215 |
try { |
|
10216 |
if (!_iteratorNormalCompletion && _iterator.return) { |
|
10217 |
_iterator.return(); |
|
10218 |
} |
|
10219 |
} finally { |
|
10220 |
if (_didIteratorError) { |
|
10221 |
throw _iteratorError; |
|
10222 |
} |
|
10223 |
} |
|
10224 |
} |
|
10225 |
|
|
10226 |
var request = this._queueLoadingCallback(callback); |
|
10227 |
if (this.isFontLoadingAPISupported) { |
|
10228 |
Promise.all(fontLoadPromises).then(request.complete); |
|
10229 |
} else if (rules.length > 0 && !this.isSyncFontLoadingSupported) { |
|
10230 |
this._prepareFontLoadEvent(rules, fontsToLoad, request); |
|
10231 |
} else { |
|
10232 |
request.complete(); |
|
10233 |
} |
|
10234 |
} |
|
10235 |
}, { |
|
10236 |
key: '_queueLoadingCallback', |
|
10237 |
value: function _queueLoadingCallback(callback) { |
|
10238 |
function completeRequest() { |
|
10239 |
(0, _util.assert)(!request.done, 'completeRequest() cannot be called twice.'); |
|
10240 |
request.done = true; |
|
10241 |
while (context.requests.length > 0 && context.requests[0].done) { |
|
10242 |
var otherRequest = context.requests.shift(); |
|
10243 |
setTimeout(otherRequest.callback, 0); |
|
10244 |
} |
|
10245 |
} |
|
10246 |
var context = this.loadingContext; |
|
10247 |
var request = { |
|
10248 |
id: 'pdfjs-font-loading-' + context.nextRequestId++, |
|
10249 |
done: false, |
|
10250 |
complete: completeRequest, |
|
10251 |
callback: callback |
|
10252 |
}; |
|
10253 |
context.requests.push(request); |
|
10254 |
return request; |
|
10255 |
} |
|
10256 |
}, { |
|
10257 |
key: '_prepareFontLoadEvent', |
|
10258 |
value: function _prepareFontLoadEvent(rules, fontsToLoad, request) { |
|
10259 |
(0, _util.unreachable)('Abstract method `_prepareFontLoadEvent`.'); |
|
10260 |
} |
|
10261 |
}, { |
|
10262 |
key: 'isFontLoadingAPISupported', |
|
10263 |
get: function get() { |
|
10264 |
(0, _util.unreachable)('Abstract method `isFontLoadingAPISupported`.'); |
|
10265 |
} |
|
10266 |
}, { |
|
10267 |
key: 'isSyncFontLoadingSupported', |
|
10268 |
get: function get() { |
|
10269 |
(0, _util.unreachable)('Abstract method `isSyncFontLoadingSupported`.'); |
|
10270 |
} |
|
10271 |
}, { |
|
10272 |
key: '_loadTestFont', |
|
10273 |
get: function get() { |
|
10274 |
(0, _util.unreachable)('Abstract method `_loadTestFont`.'); |
|
10275 |
} |
|
10276 |
}]); |
|
10277 |
|
|
10278 |
return BaseFontLoader; |
|
10279 |
}(); |
|
10280 |
|
|
10281 |
var FontLoader = void 0; |
|
10282 |
{ |
|
10283 |
exports.FontLoader = FontLoader = function (_BaseFontLoader) { |
|
10284 |
_inherits(GenericFontLoader, _BaseFontLoader); |
|
10285 |
|
|
10286 |
function GenericFontLoader(docId) { |
|
10287 |
_classCallCheck(this, GenericFontLoader); |
|
10288 |
|
|
10289 |
var _this = _possibleConstructorReturn(this, (GenericFontLoader.__proto__ || Object.getPrototypeOf(GenericFontLoader)).call(this, docId)); |
|
10290 |
|
|
10291 |
_this.loadTestFontId = 0; |
|
10292 |
return _this; |
|
10293 |
} |
|
10294 |
|
|
10295 |
_createClass(GenericFontLoader, [{ |
|
10296 |
key: '_prepareFontLoadEvent', |
|
10297 |
value: function _prepareFontLoadEvent(rules, fonts, request) { |
|
10298 |
function int32(data, offset) { |
|
10299 |
return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff; |
|
10300 |
} |
|
10301 |
function spliceString(s, offset, remove, insert) { |
|
10302 |
var chunk1 = s.substring(0, offset); |
|
10303 |
var chunk2 = s.substring(offset + remove); |
|
10304 |
return chunk1 + insert + chunk2; |
|
10305 |
} |
|
10306 |
var i = void 0, |
|
10307 |
ii = void 0; |
|
10308 |
var canvas = document.createElement('canvas'); |
|
10309 |
canvas.width = 1; |
|
10310 |
canvas.height = 1; |
|
10311 |
var ctx = canvas.getContext('2d'); |
|
10312 |
var called = 0; |
|
10313 |
function isFontReady(name, callback) { |
|
10314 |
called++; |
|
10315 |
if (called > 30) { |
|
10316 |
(0, _util.warn)('Load test font never loaded.'); |
|
10317 |
callback(); |
|
10318 |
return; |
|
10319 |
} |
|
10320 |
ctx.font = '30px ' + name; |
|
10321 |
ctx.fillText('.', 0, 20); |
|
10322 |
var imageData = ctx.getImageData(0, 0, 1, 1); |
|
10323 |
if (imageData.data[3] > 0) { |
|
10324 |
callback(); |
|
10325 |
return; |
|
10326 |
} |
|
10327 |
setTimeout(isFontReady.bind(null, name, callback)); |
|
10328 |
} |
|
10329 |
var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++; |
|
10330 |
var data = this._loadTestFont; |
|
10331 |
var COMMENT_OFFSET = 976; |
|
10332 |
data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId); |
|
10333 |
var CFF_CHECKSUM_OFFSET = 16; |
|
10334 |
var XXXX_VALUE = 0x58585858; |
|
10335 |
var checksum = int32(data, CFF_CHECKSUM_OFFSET); |
|
10336 |
for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) { |
|
10337 |
checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0; |
|
10338 |
} |
|
10339 |
if (i < loadTestFontId.length) { |
|
10340 |
checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0; |
|
10341 |
} |
|
10342 |
data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, (0, _util.string32)(checksum)); |
|
10343 |
var url = 'url(data:font/opentype;base64,' + btoa(data) + ');'; |
|
10344 |
var rule = '@font-face {font-family:"' + loadTestFontId + '";src:' + url + '}'; |
|
10345 |
this.insertRule(rule); |
|
10346 |
var names = []; |
|
10347 |
for (i = 0, ii = fonts.length; i < ii; i++) { |
|
10348 |
names.push(fonts[i].loadedName); |
|
10349 |
} |
|
10350 |
names.push(loadTestFontId); |
|
10351 |
var div = document.createElement('div'); |
|
10352 |
div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;'); |
|
10353 |
for (i = 0, ii = names.length; i < ii; ++i) { |
|
10354 |
var span = document.createElement('span'); |
|
10355 |
span.textContent = 'Hi'; |
|
10356 |
span.style.fontFamily = names[i]; |
|
10357 |
div.appendChild(span); |
|
10358 |
} |
|
10359 |
document.body.appendChild(div); |
|
10360 |
isFontReady(loadTestFontId, function () { |
|
10361 |
document.body.removeChild(div); |
|
10362 |
request.complete(); |
|
10363 |
}); |
|
10364 |
} |
|
10365 |
}, { |
|
10366 |
key: 'isFontLoadingAPISupported', |
|
10367 |
get: function get() { |
|
10368 |
var supported = typeof document !== 'undefined' && !!document.fonts; |
|
10369 |
if (supported && typeof navigator !== 'undefined') { |
|
10370 |
var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent); |
|
10371 |
if (m && m[1] < 63) { |
|
10372 |
supported = false; |
|
10373 |
} |
|
10374 |
} |
|
10375 |
return (0, _util.shadow)(this, 'isFontLoadingAPISupported', supported); |
|
10376 |
} |
|
10377 |
}, { |
|
10378 |
key: 'isSyncFontLoadingSupported', |
|
10379 |
get: function get() { |
|
10380 |
var supported = false; |
|
10381 |
if (typeof navigator === 'undefined') { |
|
10382 |
supported = true; |
|
10383 |
} else { |
|
10384 |
var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent); |
|
10385 |
if (m && m[1] >= 14) { |
|
10386 |
supported = true; |
|
10387 |
} |
|
10388 |
} |
|
10389 |
return (0, _util.shadow)(this, 'isSyncFontLoadingSupported', supported); |
|
10390 |
} |
|
10391 |
}, { |
|
10392 |
key: '_loadTestFont', |
|
10393 |
get: function get() { |
|
10394 |
var getLoadTestFont = function getLoadTestFont() { |
|
10395 |
return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQA' + 'FQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAA' + 'ALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgA' + 'AAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1' + 'AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD' + '6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACM' + 'AooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4D' + 'IP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAA' + 'AAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUA' + 'AQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgAB' + 'AAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABY' + 'AAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAA' + 'AC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAA' + 'AAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQAC' + 'AQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3' + 'Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTj' + 'FQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=='); |
|
10396 |
}; |
|
10397 |
return (0, _util.shadow)(this, '_loadTestFont', getLoadTestFont()); |
|
10398 |
} |
|
10399 |
}]); |
|
10400 |
|
|
10401 |
return GenericFontLoader; |
|
10402 |
}(BaseFontLoader); |
|
10403 |
} |
|
10404 |
var IsEvalSupportedCached = { |
|
10405 |
get value() { |
|
10406 |
return (0, _util.shadow)(this, 'value', (0, _util.isEvalSupported)()); |
|
10407 |
} |
|
10408 |
}; |
|
10409 |
|
|
10410 |
var FontFaceObject = function () { |
|
10411 |
function FontFaceObject(translatedData, _ref) { |
|
10412 |
var _ref$isEvalSupported = _ref.isEvalSupported, |
|
10413 |
isEvalSupported = _ref$isEvalSupported === undefined ? true : _ref$isEvalSupported, |
|
10414 |
_ref$disableFontFace = _ref.disableFontFace, |
|
10415 |
disableFontFace = _ref$disableFontFace === undefined ? false : _ref$disableFontFace, |
|
10416 |
_ref$ignoreErrors = _ref.ignoreErrors, |
|
10417 |
ignoreErrors = _ref$ignoreErrors === undefined ? false : _ref$ignoreErrors, |
|
10418 |
_ref$onUnsupportedFea = _ref.onUnsupportedFeature, |
|
10419 |
onUnsupportedFeature = _ref$onUnsupportedFea === undefined ? null : _ref$onUnsupportedFea, |
|
10420 |
_ref$fontRegistry = _ref.fontRegistry, |
|
10421 |
fontRegistry = _ref$fontRegistry === undefined ? null : _ref$fontRegistry; |
|
10422 |
|
|
10423 |
_classCallCheck(this, FontFaceObject); |
|
10424 |
|
|
10425 |
this.compiledGlyphs = Object.create(null); |
|
10426 |
for (var i in translatedData) { |
|
10427 |
this[i] = translatedData[i]; |
|
10428 |
} |
|
10429 |
this.isEvalSupported = isEvalSupported !== false; |
|
10430 |
this.disableFontFace = disableFontFace === true; |
|
10431 |
this.ignoreErrors = ignoreErrors === true; |
|
10432 |
this._onUnsupportedFeature = onUnsupportedFeature; |
|
10433 |
this.fontRegistry = fontRegistry; |
|
10434 |
} |
|
10435 |
|
|
10436 |
_createClass(FontFaceObject, [{ |
|
10437 |
key: 'createNativeFontFace', |
|
10438 |
value: function createNativeFontFace() { |
|
10439 |
if (!this.data || this.disableFontFace) { |
|
10440 |
return null; |
|
10441 |
} |
|
10442 |
var nativeFontFace = new FontFace(this.loadedName, this.data, {}); |
|
10443 |
if (this.fontRegistry) { |
|
10444 |
this.fontRegistry.registerFont(this); |
|
10445 |
} |
|
10446 |
return nativeFontFace; |
|
10447 |
} |
|
10448 |
}, { |
|
10449 |
key: 'createFontFaceRule', |
|
10450 |
value: function createFontFaceRule() { |
|
10451 |
if (!this.data || this.disableFontFace) { |
|
10452 |
return null; |
|
10453 |
} |
|
10454 |
var data = (0, _util.bytesToString)(new Uint8Array(this.data)); |
|
10455 |
var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');'; |
|
10456 |
var rule = '@font-face {font-family:"' + this.loadedName + '";src:' + url + '}'; |
|
10457 |
if (this.fontRegistry) { |
|
10458 |
this.fontRegistry.registerFont(this, url); |
|
10459 |
} |
|
10460 |
return rule; |
|
10461 |
} |
|
10462 |
}, { |
|
10463 |
key: 'getPathGenerator', |
|
10464 |
value: function getPathGenerator(objs, character) { |
|
10465 |
if (this.compiledGlyphs[character] !== undefined) { |
|
10466 |
return this.compiledGlyphs[character]; |
|
10467 |
} |
|
10468 |
var cmds = void 0, |
|
10469 |
current = void 0; |
|
10470 |
try { |
|
10471 |
cmds = objs.get(this.loadedName + '_path_' + character); |
|
10472 |
} catch (ex) { |
|
10473 |
if (!this.ignoreErrors) { |
|
10474 |
throw ex; |
|
10475 |
} |
|
10476 |
if (this._onUnsupportedFeature) { |
|
10477 |
this._onUnsupportedFeature({ featureId: _util.UNSUPPORTED_FEATURES.font }); |
|
10478 |
} |
|
10479 |
(0, _util.warn)('getPathGenerator - ignoring character: "' + ex + '".'); |
|
10480 |
return this.compiledGlyphs[character] = function (c, size) {}; |
|
10481 |
} |
|
10482 |
if (this.isEvalSupported && IsEvalSupportedCached.value) { |
|
10483 |
var args = void 0, |
|
10484 |
js = ''; |
|
10485 |
for (var i = 0, ii = cmds.length; i < ii; i++) { |
|
10486 |
current = cmds[i]; |
|
10487 |
if (current.args !== undefined) { |
|
10488 |
args = current.args.join(','); |
|
10489 |
} else { |
|
10490 |
args = ''; |
|
10491 |
} |
|
10492 |
js += 'c.' + current.cmd + '(' + args + ');\n'; |
|
10493 |
} |
|
10494 |
return this.compiledGlyphs[character] = new Function('c', 'size', js); |
|
10495 |
} |
|
10496 |
return this.compiledGlyphs[character] = function (c, size) { |
|
10497 |
for (var _i = 0, _ii = cmds.length; _i < _ii; _i++) { |
|
10498 |
current = cmds[_i]; |
|
10499 |
if (current.cmd === 'scale') { |
|
10500 |
current.args = [size, -size]; |
|
10501 |
} |
|
10502 |
c[current.cmd].apply(c, current.args); |
|
10503 |
} |
|
10504 |
}; |
|
10505 |
} |
|
10506 |
}]); |
|
10507 |
|
|
10508 |
return FontFaceObject; |
|
10509 |
}(); |
|
10510 |
|
|
10511 |
exports.FontFaceObject = FontFaceObject; |
|
10512 |
exports.FontLoader = FontLoader; |
|
10513 |
|
|
10514 |
/***/ }), |
|
10515 |
/* 132 */ |
|
10516 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
10517 |
|
|
10518 |
"use strict"; |
|
10519 |
|
|
10520 |
|
|
10521 |
var compatibilityParams = Object.create(null); |
|
10522 |
{ |
|
10523 |
var isNodeJS = __w_pdfjs_require__(4); |
|
10524 |
var userAgent = typeof navigator !== 'undefined' && navigator.userAgent || ''; |
|
10525 |
var isIE = /Trident/.test(userAgent); |
|
10526 |
var isIOSChrome = /CriOS/.test(userAgent); |
|
10527 |
(function checkOnBlobSupport() { |
|
10528 |
if (isIE || isIOSChrome) { |
|
10529 |
compatibilityParams.disableCreateObjectURL = true; |
|
10530 |
} |
|
10531 |
})(); |
|
10532 |
(function checkFontFaceAndImage() { |
|
10533 |
if (isNodeJS()) { |
|
10534 |
compatibilityParams.disableFontFace = true; |
|
10535 |
compatibilityParams.nativeImageDecoderSupport = 'none'; |
|
10536 |
} |
|
10537 |
})(); |
|
10538 |
} |
|
10539 |
exports.apiCompatibilityParams = Object.freeze(compatibilityParams); |
|
10540 |
|
|
10541 |
/***/ }), |
|
10542 |
/* 133 */ |
|
10543 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
10544 |
|
|
10545 |
"use strict"; |
|
10546 |
|
|
10547 |
|
|
10548 |
Object.defineProperty(exports, "__esModule", { |
|
10549 |
value: true |
|
10550 |
}); |
|
10551 |
exports.CanvasGraphics = undefined; |
|
10552 |
|
|
10553 |
var _util = __w_pdfjs_require__(1); |
|
10554 |
|
|
10555 |
var _pattern_helper = __w_pdfjs_require__(134); |
|
10556 |
|
|
10557 |
var MIN_FONT_SIZE = 16; |
|
10558 |
var MAX_FONT_SIZE = 100; |
|
10559 |
var MAX_GROUP_SIZE = 4096; |
|
10560 |
var MIN_WIDTH_FACTOR = 0.65; |
|
10561 |
var COMPILE_TYPE3_GLYPHS = true; |
|
10562 |
var MAX_SIZE_TO_COMPILE = 1000; |
|
10563 |
var FULL_CHUNK_HEIGHT = 16; |
|
10564 |
var IsLittleEndianCached = { |
|
10565 |
get value() { |
|
10566 |
return (0, _util.shadow)(IsLittleEndianCached, 'value', (0, _util.isLittleEndian)()); |
|
10567 |
} |
|
10568 |
}; |
|
10569 |
function addContextCurrentTransform(ctx) { |
|
10570 |
if (!ctx.mozCurrentTransform) { |
|
10571 |
ctx._originalSave = ctx.save; |
|
10572 |
ctx._originalRestore = ctx.restore; |
|
10573 |
ctx._originalRotate = ctx.rotate; |
|
10574 |
ctx._originalScale = ctx.scale; |
|
10575 |
ctx._originalTranslate = ctx.translate; |
|
10576 |
ctx._originalTransform = ctx.transform; |
|
10577 |
ctx._originalSetTransform = ctx.setTransform; |
|
10578 |
ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0]; |
|
10579 |
ctx._transformStack = []; |
|
10580 |
Object.defineProperty(ctx, 'mozCurrentTransform', { |
|
10581 |
get: function getCurrentTransform() { |
|
10582 |
return this._transformMatrix; |
|
10583 |
} |
|
10584 |
}); |
|
10585 |
Object.defineProperty(ctx, 'mozCurrentTransformInverse', { |
|
10586 |
get: function getCurrentTransformInverse() { |
|
10587 |
var m = this._transformMatrix; |
|
10588 |
var a = m[0], |
|
10589 |
b = m[1], |
|
10590 |
c = m[2], |
|
10591 |
d = m[3], |
|
10592 |
e = m[4], |
|
10593 |
f = m[5]; |
|
10594 |
var ad_bc = a * d - b * c; |
|
10595 |
var bc_ad = b * c - a * d; |
|
10596 |
return [d / ad_bc, b / bc_ad, c / bc_ad, a / ad_bc, (d * e - c * f) / bc_ad, (b * e - a * f) / ad_bc]; |
|
10597 |
} |
|
10598 |
}); |
|
10599 |
ctx.save = function ctxSave() { |
|
10600 |
var old = this._transformMatrix; |
|
10601 |
this._transformStack.push(old); |
|
10602 |
this._transformMatrix = old.slice(0, 6); |
|
10603 |
this._originalSave(); |
|
10604 |
}; |
|
10605 |
ctx.restore = function ctxRestore() { |
|
10606 |
var prev = this._transformStack.pop(); |
|
10607 |
if (prev) { |
|
10608 |
this._transformMatrix = prev; |
|
10609 |
this._originalRestore(); |
|
10610 |
} |
|
10611 |
}; |
|
10612 |
ctx.translate = function ctxTranslate(x, y) { |
|
10613 |
var m = this._transformMatrix; |
|
10614 |
m[4] = m[0] * x + m[2] * y + m[4]; |
|
10615 |
m[5] = m[1] * x + m[3] * y + m[5]; |
|
10616 |
this._originalTranslate(x, y); |
|
10617 |
}; |
|
10618 |
ctx.scale = function ctxScale(x, y) { |
|
10619 |
var m = this._transformMatrix; |
|
10620 |
m[0] = m[0] * x; |
|
10621 |
m[1] = m[1] * x; |
|
10622 |
m[2] = m[2] * y; |
|
10623 |
m[3] = m[3] * y; |
|
10624 |
this._originalScale(x, y); |
|
10625 |
}; |
|
10626 |
ctx.transform = function ctxTransform(a, b, c, d, e, f) { |
|
10627 |
var m = this._transformMatrix; |
|
10628 |
this._transformMatrix = [m[0] * a + m[2] * b, m[1] * a + m[3] * b, m[0] * c + m[2] * d, m[1] * c + m[3] * d, m[0] * e + m[2] * f + m[4], m[1] * e + m[3] * f + m[5]]; |
|
10629 |
ctx._originalTransform(a, b, c, d, e, f); |
|
10630 |
}; |
|
10631 |
ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) { |
|
10632 |
this._transformMatrix = [a, b, c, d, e, f]; |
|
10633 |
ctx._originalSetTransform(a, b, c, d, e, f); |
|
10634 |
}; |
|
10635 |
ctx.rotate = function ctxRotate(angle) { |
|
10636 |
var cosValue = Math.cos(angle); |
|
10637 |
var sinValue = Math.sin(angle); |
|
10638 |
var m = this._transformMatrix; |
|
10639 |
this._transformMatrix = [m[0] * cosValue + m[2] * sinValue, m[1] * cosValue + m[3] * sinValue, m[0] * -sinValue + m[2] * cosValue, m[1] * -sinValue + m[3] * cosValue, m[4], m[5]]; |
|
10640 |
this._originalRotate(angle); |
|
10641 |
}; |
|
10642 |
} |
|
10643 |
} |
|
10644 |
var CachedCanvases = function CachedCanvasesClosure() { |
|
10645 |
function CachedCanvases(canvasFactory) { |
|
10646 |
this.canvasFactory = canvasFactory; |
|
10647 |
this.cache = Object.create(null); |
|
10648 |
} |
|
10649 |
CachedCanvases.prototype = { |
|
10650 |
getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) { |
|
10651 |
var canvasEntry; |
|
10652 |
if (this.cache[id] !== undefined) { |
|
10653 |
canvasEntry = this.cache[id]; |
|
10654 |
this.canvasFactory.reset(canvasEntry, width, height); |
|
10655 |
canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0); |
|
10656 |
} else { |
|
10657 |
canvasEntry = this.canvasFactory.create(width, height); |
|
10658 |
this.cache[id] = canvasEntry; |
|
10659 |
} |
|
10660 |
if (trackTransform) { |
|
10661 |
addContextCurrentTransform(canvasEntry.context); |
|
10662 |
} |
|
10663 |
return canvasEntry; |
|
10664 |
}, |
|
10665 |
clear: function clear() { |
|
10666 |
for (var id in this.cache) { |
|
10667 |
var canvasEntry = this.cache[id]; |
|
10668 |
this.canvasFactory.destroy(canvasEntry); |
|
10669 |
delete this.cache[id]; |
|
10670 |
} |
|
10671 |
} |
|
10672 |
}; |
|
10673 |
return CachedCanvases; |
|
10674 |
}(); |
|
10675 |
function compileType3Glyph(imgData) { |
|
10676 |
var POINT_TO_PROCESS_LIMIT = 1000; |
|
10677 |
var width = imgData.width, |
|
10678 |
height = imgData.height; |
|
10679 |
var i, |
|
10680 |
j, |
|
10681 |
j0, |
|
10682 |
width1 = width + 1; |
|
10683 |
var points = new Uint8Array(width1 * (height + 1)); |
|
10684 |
var POINT_TYPES = new Uint8Array([0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0]); |
|
10685 |
var lineSize = width + 7 & ~7, |
|
10686 |
data0 = imgData.data; |
|
10687 |
var data = new Uint8Array(lineSize * height), |
|
10688 |
pos = 0, |
|
10689 |
ii; |
|
10690 |
for (i = 0, ii = data0.length; i < ii; i++) { |
|
10691 |
var mask = 128, |
|
10692 |
elem = data0[i]; |
|
10693 |
while (mask > 0) { |
|
10694 |
data[pos++] = elem & mask ? 0 : 255; |
|
10695 |
mask >>= 1; |
|
10696 |
} |
|
10697 |
} |
|
10698 |
var count = 0; |
|
10699 |
pos = 0; |
|
10700 |
if (data[pos] !== 0) { |
|
10701 |
points[0] = 1; |
|
10702 |
++count; |
|
10703 |
} |
|
10704 |
for (j = 1; j < width; j++) { |
|
10705 |
if (data[pos] !== data[pos + 1]) { |
|
10706 |
points[j] = data[pos] ? 2 : 1; |
|
10707 |
++count; |
|
10708 |
} |
|
10709 |
pos++; |
|
10710 |
} |
|
10711 |
if (data[pos] !== 0) { |
|
10712 |
points[j] = 2; |
|
10713 |
++count; |
|
10714 |
} |
|
10715 |
for (i = 1; i < height; i++) { |
|
10716 |
pos = i * lineSize; |
|
10717 |
j0 = i * width1; |
|
10718 |
if (data[pos - lineSize] !== data[pos]) { |
|
10719 |
points[j0] = data[pos] ? 1 : 8; |
|
10720 |
++count; |
|
10721 |
} |
|
10722 |
var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0); |
|
10723 |
for (j = 1; j < width; j++) { |
|
10724 |
sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0); |
|
10725 |
if (POINT_TYPES[sum]) { |
|
10726 |
points[j0 + j] = POINT_TYPES[sum]; |
|
10727 |
++count; |
|
10728 |
} |
|
10729 |
pos++; |
|
10730 |
} |
|
10731 |
if (data[pos - lineSize] !== data[pos]) { |
|
10732 |
points[j0 + j] = data[pos] ? 2 : 4; |
|
10733 |
++count; |
|
10734 |
} |
|
10735 |
if (count > POINT_TO_PROCESS_LIMIT) { |
|
10736 |
return null; |
|
10737 |
} |
|
10738 |
} |
|
10739 |
pos = lineSize * (height - 1); |
|
10740 |
j0 = i * width1; |
|
10741 |
if (data[pos] !== 0) { |
|
10742 |
points[j0] = 8; |
|
10743 |
++count; |
|
10744 |
} |
|
10745 |
for (j = 1; j < width; j++) { |
|
10746 |
if (data[pos] !== data[pos + 1]) { |
|
10747 |
points[j0 + j] = data[pos] ? 4 : 8; |
|
10748 |
++count; |
|
10749 |
} |
|
10750 |
pos++; |
|
10751 |
} |
|
10752 |
if (data[pos] !== 0) { |
|
10753 |
points[j0 + j] = 4; |
|
10754 |
++count; |
|
10755 |
} |
|
10756 |
if (count > POINT_TO_PROCESS_LIMIT) { |
|
10757 |
return null; |
|
10758 |
} |
|
10759 |
var steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]); |
|
10760 |
var outlines = []; |
|
10761 |
for (i = 0; count && i <= height; i++) { |
|
10762 |
var p = i * width1; |
|
10763 |
var end = p + width; |
|
10764 |
while (p < end && !points[p]) { |
|
10765 |
p++; |
|
10766 |
} |
|
10767 |
if (p === end) { |
|
10768 |
continue; |
|
10769 |
} |
|
10770 |
var coords = [p % width1, i]; |
|
10771 |
var type = points[p], |
|
10772 |
p0 = p, |
|
10773 |
pp; |
|
10774 |
do { |
|
10775 |
var step = steps[type]; |
|
10776 |
do { |
|
10777 |
p += step; |
|
10778 |
} while (!points[p]); |
|
10779 |
pp = points[p]; |
|
10780 |
if (pp !== 5 && pp !== 10) { |
|
10781 |
type = pp; |
|
10782 |
points[p] = 0; |
|
10783 |
} else { |
|
10784 |
type = pp & 0x33 * type >> 4; |
|
10785 |
points[p] &= type >> 2 | type << 2; |
|
10786 |
} |
|
10787 |
coords.push(p % width1); |
|
10788 |
coords.push(p / width1 | 0); |
|
10789 |
--count; |
|
10790 |
} while (p0 !== p); |
|
10791 |
outlines.push(coords); |
|
10792 |
--i; |
|
10793 |
} |
|
10794 |
var drawOutline = function drawOutline(c) { |
|
10795 |
c.save(); |
|
10796 |
c.scale(1 / width, -1 / height); |
|
10797 |
c.translate(0, -height); |
|
10798 |
c.beginPath(); |
|
10799 |
for (var i = 0, ii = outlines.length; i < ii; i++) { |
|
10800 |
var o = outlines[i]; |
|
10801 |
c.moveTo(o[0], o[1]); |
|
10802 |
for (var j = 2, jj = o.length; j < jj; j += 2) { |
|
10803 |
c.lineTo(o[j], o[j + 1]); |
|
10804 |
} |
|
10805 |
} |
|
10806 |
c.fill(); |
|
10807 |
c.beginPath(); |
|
10808 |
c.restore(); |
|
10809 |
}; |
|
10810 |
return drawOutline; |
|
10811 |
} |
|
10812 |
var CanvasExtraState = function CanvasExtraStateClosure() { |
|
10813 |
function CanvasExtraState() { |
|
10814 |
this.alphaIsShape = false; |
|
10815 |
this.fontSize = 0; |
|
10816 |
this.fontSizeScale = 1; |
|
10817 |
this.textMatrix = _util.IDENTITY_MATRIX; |
|
10818 |
this.textMatrixScale = 1; |
|
10819 |
this.fontMatrix = _util.FONT_IDENTITY_MATRIX; |
|
10820 |
this.leading = 0; |
|
10821 |
this.x = 0; |
|
10822 |
this.y = 0; |
|
10823 |
this.lineX = 0; |
|
10824 |
this.lineY = 0; |
|
10825 |
this.charSpacing = 0; |
|
10826 |
this.wordSpacing = 0; |
|
10827 |
this.textHScale = 1; |
|
10828 |
this.textRenderingMode = _util.TextRenderingMode.FILL; |
|
10829 |
this.textRise = 0; |
|
10830 |
this.fillColor = '#000000'; |
|
10831 |
this.strokeColor = '#000000'; |
|
10832 |
this.patternFill = false; |
|
10833 |
this.fillAlpha = 1; |
|
10834 |
this.strokeAlpha = 1; |
|
10835 |
this.lineWidth = 1; |
|
10836 |
this.activeSMask = null; |
|
10837 |
this.resumeSMaskCtx = null; |
|
10838 |
} |
|
10839 |
CanvasExtraState.prototype = { |
|
10840 |
clone: function CanvasExtraState_clone() { |
|
10841 |
return Object.create(this); |
|
10842 |
}, |
|
10843 |
setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) { |
|
10844 |
this.x = x; |
|
10845 |
this.y = y; |
|
10846 |
} |
|
10847 |
}; |
|
10848 |
return CanvasExtraState; |
|
10849 |
}(); |
|
10850 |
var CanvasGraphics = function CanvasGraphicsClosure() { |
|
10851 |
var EXECUTION_TIME = 15; |
|
10852 |
var EXECUTION_STEPS = 10; |
|
10853 |
function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer) { |
|
10854 |
this.ctx = canvasCtx; |
|
10855 |
this.current = new CanvasExtraState(); |
|
10856 |
this.stateStack = []; |
|
10857 |
this.pendingClip = null; |
|
10858 |
this.pendingEOFill = false; |
|
10859 |
this.res = null; |
|
10860 |
this.xobjs = null; |
|
10861 |
this.commonObjs = commonObjs; |
|
10862 |
this.objs = objs; |
|
10863 |
this.canvasFactory = canvasFactory; |
|
10864 |
this.webGLContext = webGLContext; |
|
10865 |
this.imageLayer = imageLayer; |
|
10866 |
this.groupStack = []; |
|
10867 |
this.processingType3 = null; |
|
10868 |
this.baseTransform = null; |
|
10869 |
this.baseTransformStack = []; |
|
10870 |
this.groupLevel = 0; |
|
10871 |
this.smaskStack = []; |
|
10872 |
this.smaskCounter = 0; |
|
10873 |
this.tempSMask = null; |
|
10874 |
this.cachedCanvases = new CachedCanvases(this.canvasFactory); |
|
10875 |
if (canvasCtx) { |
|
10876 |
addContextCurrentTransform(canvasCtx); |
|
10877 |
} |
|
10878 |
this._cachedGetSinglePixelWidth = null; |
|
10879 |
} |
|
10880 |
function putBinaryImageData(ctx, imgData) { |
|
10881 |
if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) { |
|
10882 |
ctx.putImageData(imgData, 0, 0); |
|
10883 |
return; |
|
10884 |
} |
|
10885 |
var height = imgData.height, |
|
10886 |
width = imgData.width; |
|
10887 |
var partialChunkHeight = height % FULL_CHUNK_HEIGHT; |
|
10888 |
var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT; |
|
10889 |
var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1; |
|
10890 |
var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT); |
|
10891 |
var srcPos = 0, |
|
10892 |
destPos; |
|
10893 |
var src = imgData.data; |
|
10894 |
var dest = chunkImgData.data; |
|
10895 |
var i, j, thisChunkHeight, elemsInThisChunk; |
|
10896 |
if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) { |
|
10897 |
var srcLength = src.byteLength; |
|
10898 |
var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2); |
|
10899 |
var dest32DataLength = dest32.length; |
|
10900 |
var fullSrcDiff = width + 7 >> 3; |
|
10901 |
var white = 0xFFFFFFFF; |
|
10902 |
var black = IsLittleEndianCached.value ? 0xFF000000 : 0x000000FF; |
|
10903 |
for (i = 0; i < totalChunks; i++) { |
|
10904 |
thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight; |
|
10905 |
destPos = 0; |
|
10906 |
for (j = 0; j < thisChunkHeight; j++) { |
|
10907 |
var srcDiff = srcLength - srcPos; |
|
10908 |
var k = 0; |
|
10909 |
var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7; |
|
10910 |
var kEndUnrolled = kEnd & ~7; |
|
10911 |
var mask = 0; |
|
10912 |
var srcByte = 0; |
|
10913 |
for (; k < kEndUnrolled; k += 8) { |
|
10914 |
srcByte = src[srcPos++]; |
|
10915 |
dest32[destPos++] = srcByte & 128 ? white : black; |
|
10916 |
dest32[destPos++] = srcByte & 64 ? white : black; |
|
10917 |
dest32[destPos++] = srcByte & 32 ? white : black; |
|
10918 |
dest32[destPos++] = srcByte & 16 ? white : black; |
|
10919 |
dest32[destPos++] = srcByte & 8 ? white : black; |
|
10920 |
dest32[destPos++] = srcByte & 4 ? white : black; |
|
10921 |
dest32[destPos++] = srcByte & 2 ? white : black; |
|
10922 |
dest32[destPos++] = srcByte & 1 ? white : black; |
|
10923 |
} |
|
10924 |
for (; k < kEnd; k++) { |
|
10925 |
if (mask === 0) { |
|
10926 |
srcByte = src[srcPos++]; |
|
10927 |
mask = 128; |
|
10928 |
} |
|
10929 |
dest32[destPos++] = srcByte & mask ? white : black; |
|
10930 |
mask >>= 1; |
|
10931 |
} |
|
10932 |
} |
|
10933 |
while (destPos < dest32DataLength) { |
|
10934 |
dest32[destPos++] = 0; |
|
10935 |
} |
|
10936 |
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); |
|
10937 |
} |
|
10938 |
} else if (imgData.kind === _util.ImageKind.RGBA_32BPP) { |
|
10939 |
j = 0; |
|
10940 |
elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4; |
|
10941 |
for (i = 0; i < fullChunks; i++) { |
|
10942 |
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk)); |
|
10943 |
srcPos += elemsInThisChunk; |
|
10944 |
ctx.putImageData(chunkImgData, 0, j); |
|
10945 |
j += FULL_CHUNK_HEIGHT; |
|
10946 |
} |
|
10947 |
if (i < totalChunks) { |
|
10948 |
elemsInThisChunk = width * partialChunkHeight * 4; |
|
10949 |
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk)); |
|
10950 |
ctx.putImageData(chunkImgData, 0, j); |
|
10951 |
} |
|
10952 |
} else if (imgData.kind === _util.ImageKind.RGB_24BPP) { |
|
10953 |
thisChunkHeight = FULL_CHUNK_HEIGHT; |
|
10954 |
elemsInThisChunk = width * thisChunkHeight; |
|
10955 |
for (i = 0; i < totalChunks; i++) { |
|
10956 |
if (i >= fullChunks) { |
|
10957 |
thisChunkHeight = partialChunkHeight; |
|
10958 |
elemsInThisChunk = width * thisChunkHeight; |
|
10959 |
} |
|
10960 |
destPos = 0; |
|
10961 |
for (j = elemsInThisChunk; j--;) { |
|
10962 |
dest[destPos++] = src[srcPos++]; |
|
10963 |
dest[destPos++] = src[srcPos++]; |
|
10964 |
dest[destPos++] = src[srcPos++]; |
|
10965 |
dest[destPos++] = 255; |
|
10966 |
} |
|
10967 |
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); |
|
10968 |
} |
|
10969 |
} else { |
|
10970 |
throw new Error('bad image kind: ' + imgData.kind); |
|
10971 |
} |
|
10972 |
} |
|
10973 |
function putBinaryImageMask(ctx, imgData) { |
|
10974 |
var height = imgData.height, |
|
10975 |
width = imgData.width; |
|
10976 |
var partialChunkHeight = height % FULL_CHUNK_HEIGHT; |
|
10977 |
var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT; |
|
10978 |
var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1; |
|
10979 |
var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT); |
|
10980 |
var srcPos = 0; |
|
10981 |
var src = imgData.data; |
|
10982 |
var dest = chunkImgData.data; |
|
10983 |
for (var i = 0; i < totalChunks; i++) { |
|
10984 |
var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight; |
|
10985 |
var destPos = 3; |
|
10986 |
for (var j = 0; j < thisChunkHeight; j++) { |
|
10987 |
var mask = 0; |
|
10988 |
for (var k = 0; k < width; k++) { |
|
10989 |
if (!mask) { |
|
10990 |
var elem = src[srcPos++]; |
|
10991 |
mask = 128; |
|
10992 |
} |
|
10993 |
dest[destPos] = elem & mask ? 0 : 255; |
|
10994 |
destPos += 4; |
|
10995 |
mask >>= 1; |
|
10996 |
} |
|
10997 |
} |
|
10998 |
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT); |
|
10999 |
} |
|
11000 |
} |
|
11001 |
function copyCtxState(sourceCtx, destCtx) { |
|
11002 |
var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha', 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit', 'globalCompositeOperation', 'font']; |
|
11003 |
for (var i = 0, ii = properties.length; i < ii; i++) { |
|
11004 |
var property = properties[i]; |
|
11005 |
if (sourceCtx[property] !== undefined) { |
|
11006 |
destCtx[property] = sourceCtx[property]; |
|
11007 |
} |
|
11008 |
} |
|
11009 |
if (sourceCtx.setLineDash !== undefined) { |
|
11010 |
destCtx.setLineDash(sourceCtx.getLineDash()); |
|
11011 |
destCtx.lineDashOffset = sourceCtx.lineDashOffset; |
|
11012 |
} |
|
11013 |
} |
|
11014 |
function resetCtxToDefault(ctx) { |
|
11015 |
ctx.strokeStyle = '#000000'; |
|
11016 |
ctx.fillStyle = '#000000'; |
|
11017 |
ctx.fillRule = 'nonzero'; |
|
11018 |
ctx.globalAlpha = 1; |
|
11019 |
ctx.lineWidth = 1; |
|
11020 |
ctx.lineCap = 'butt'; |
|
11021 |
ctx.lineJoin = 'miter'; |
|
11022 |
ctx.miterLimit = 10; |
|
11023 |
ctx.globalCompositeOperation = 'source-over'; |
|
11024 |
ctx.font = '10px sans-serif'; |
|
11025 |
if (ctx.setLineDash !== undefined) { |
|
11026 |
ctx.setLineDash([]); |
|
11027 |
ctx.lineDashOffset = 0; |
|
11028 |
} |
|
11029 |
} |
|
11030 |
function composeSMaskBackdrop(bytes, r0, g0, b0) { |
|
11031 |
var length = bytes.length; |
|
11032 |
for (var i = 3; i < length; i += 4) { |
|
11033 |
var alpha = bytes[i]; |
|
11034 |
if (alpha === 0) { |
|
11035 |
bytes[i - 3] = r0; |
|
11036 |
bytes[i - 2] = g0; |
|
11037 |
bytes[i - 1] = b0; |
|
11038 |
} else if (alpha < 255) { |
|
11039 |
var alpha_ = 255 - alpha; |
|
11040 |
bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8; |
|
11041 |
bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8; |
|
11042 |
bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8; |
|
11043 |
} |
|
11044 |
} |
|
11045 |
} |
|
11046 |
function composeSMaskAlpha(maskData, layerData, transferMap) { |
|
11047 |
var length = maskData.length; |
|
11048 |
var scale = 1 / 255; |
|
11049 |
for (var i = 3; i < length; i += 4) { |
|
11050 |
var alpha = transferMap ? transferMap[maskData[i]] : maskData[i]; |
|
11051 |
layerData[i] = layerData[i] * alpha * scale | 0; |
|
11052 |
} |
|
11053 |
} |
|
11054 |
function composeSMaskLuminosity(maskData, layerData, transferMap) { |
|
11055 |
var length = maskData.length; |
|
11056 |
for (var i = 3; i < length; i += 4) { |
|
11057 |
var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28; |
|
11058 |
layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16; |
|
11059 |
} |
|
11060 |
} |
|
11061 |
function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) { |
|
11062 |
var hasBackdrop = !!backdrop; |
|
11063 |
var r0 = hasBackdrop ? backdrop[0] : 0; |
|
11064 |
var g0 = hasBackdrop ? backdrop[1] : 0; |
|
11065 |
var b0 = hasBackdrop ? backdrop[2] : 0; |
|
11066 |
var composeFn; |
|
11067 |
if (subtype === 'Luminosity') { |
|
11068 |
composeFn = composeSMaskLuminosity; |
|
11069 |
} else { |
|
11070 |
composeFn = composeSMaskAlpha; |
|
11071 |
} |
|
11072 |
var PIXELS_TO_PROCESS = 1048576; |
|
11073 |
var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width)); |
|
11074 |
for (var row = 0; row < height; row += chunkSize) { |
|
11075 |
var chunkHeight = Math.min(chunkSize, height - row); |
|
11076 |
var maskData = maskCtx.getImageData(0, row, width, chunkHeight); |
|
11077 |
var layerData = layerCtx.getImageData(0, row, width, chunkHeight); |
|
11078 |
if (hasBackdrop) { |
|
11079 |
composeSMaskBackdrop(maskData.data, r0, g0, b0); |
|
11080 |
} |
|
11081 |
composeFn(maskData.data, layerData.data, transferMap); |
|
11082 |
maskCtx.putImageData(layerData, 0, row); |
|
11083 |
} |
|
11084 |
} |
|
11085 |
function composeSMask(ctx, smask, layerCtx, webGLContext) { |
|
11086 |
var mask = smask.canvas; |
|
11087 |
var maskCtx = smask.context; |
|
11088 |
ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY); |
|
11089 |
var backdrop = smask.backdrop || null; |
|
11090 |
if (!smask.transferMap && webGLContext.isEnabled) { |
|
11091 |
var composed = webGLContext.composeSMask({ |
|
11092 |
layer: layerCtx.canvas, |
|
11093 |
mask: mask, |
|
11094 |
properties: { |
|
11095 |
subtype: smask.subtype, |
|
11096 |
backdrop: backdrop |
|
11097 |
} |
|
11098 |
}); |
|
11099 |
ctx.setTransform(1, 0, 0, 1, 0, 0); |
|
11100 |
ctx.drawImage(composed, smask.offsetX, smask.offsetY); |
|
11101 |
return; |
|
11102 |
} |
|
11103 |
genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap); |
|
11104 |
ctx.drawImage(mask, 0, 0); |
|
11105 |
} |
|
11106 |
var LINE_CAP_STYLES = ['butt', 'round', 'square']; |
|
11107 |
var LINE_JOIN_STYLES = ['miter', 'round', 'bevel']; |
|
11108 |
var NORMAL_CLIP = {}; |
|
11109 |
var EO_CLIP = {}; |
|
11110 |
CanvasGraphics.prototype = { |
|
11111 |
beginDrawing: function beginDrawing(_ref) { |
|
11112 |
var transform = _ref.transform, |
|
11113 |
viewport = _ref.viewport, |
|
11114 |
transparency = _ref.transparency, |
|
11115 |
_ref$background = _ref.background, |
|
11116 |
background = _ref$background === undefined ? null : _ref$background; |
|
11117 |
|
|
11118 |
var width = this.ctx.canvas.width; |
|
11119 |
var height = this.ctx.canvas.height; |
|
11120 |
this.ctx.save(); |
|
11121 |
this.ctx.fillStyle = background || 'rgb(255, 255, 255)'; |
|
11122 |
this.ctx.fillRect(0, 0, width, height); |
|
11123 |
this.ctx.restore(); |
|
11124 |
if (transparency) { |
|
11125 |
var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true); |
|
11126 |
this.compositeCtx = this.ctx; |
|
11127 |
this.transparentCanvas = transparentCanvas.canvas; |
|
11128 |
this.ctx = transparentCanvas.context; |
|
11129 |
this.ctx.save(); |
|
11130 |
this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform); |
|
11131 |
} |
|
11132 |
this.ctx.save(); |
|
11133 |
resetCtxToDefault(this.ctx); |
|
11134 |
if (transform) { |
|
11135 |
this.ctx.transform.apply(this.ctx, transform); |
|
11136 |
} |
|
11137 |
this.ctx.transform.apply(this.ctx, viewport.transform); |
|
11138 |
this.baseTransform = this.ctx.mozCurrentTransform.slice(); |
|
11139 |
if (this.imageLayer) { |
|
11140 |
this.imageLayer.beginLayout(); |
|
11141 |
} |
|
11142 |
}, |
|
11143 |
|
|
11144 |
executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) { |
|
11145 |
var argsArray = operatorList.argsArray; |
|
11146 |
var fnArray = operatorList.fnArray; |
|
11147 |
var i = executionStartIdx || 0; |
|
11148 |
var argsArrayLen = argsArray.length; |
|
11149 |
if (argsArrayLen === i) { |
|
11150 |
return i; |
|
11151 |
} |
|
11152 |
var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function'; |
|
11153 |
var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0; |
|
11154 |
var steps = 0; |
|
11155 |
var commonObjs = this.commonObjs; |
|
11156 |
var objs = this.objs; |
|
11157 |
var fnId; |
|
11158 |
while (true) { |
|
11159 |
if (stepper !== undefined && i === stepper.nextBreakPoint) { |
|
11160 |
stepper.breakIt(i, continueCallback); |
|
11161 |
return i; |
|
11162 |
} |
|
11163 |
fnId = fnArray[i]; |
|
11164 |
if (fnId !== _util.OPS.dependency) { |
|
11165 |
this[fnId].apply(this, argsArray[i]); |
|
11166 |
} else { |
|
11167 |
var deps = argsArray[i]; |
|
11168 |
for (var n = 0, nn = deps.length; n < nn; n++) { |
|
11169 |
var depObjId = deps[n]; |
|
11170 |
var common = depObjId[0] === 'g' && depObjId[1] === '_'; |
|
11171 |
var objsPool = common ? commonObjs : objs; |
|
11172 |
if (!objsPool.isResolved(depObjId)) { |
|
11173 |
objsPool.get(depObjId, continueCallback); |
|
11174 |
return i; |
|
11175 |
} |
|
11176 |
} |
|
11177 |
} |
|
11178 |
i++; |
|
11179 |
if (i === argsArrayLen) { |
|
11180 |
return i; |
|
11181 |
} |
|
11182 |
if (chunkOperations && ++steps > EXECUTION_STEPS) { |
|
11183 |
if (Date.now() > endTime) { |
|
11184 |
continueCallback(); |
|
11185 |
return i; |
|
11186 |
} |
|
11187 |
steps = 0; |
|
11188 |
} |
|
11189 |
} |
|
11190 |
}, |
|
11191 |
endDrawing: function CanvasGraphics_endDrawing() { |
|
11192 |
if (this.current.activeSMask !== null) { |
|
11193 |
this.endSMaskGroup(); |
|
11194 |
} |
|
11195 |
this.ctx.restore(); |
|
11196 |
if (this.transparentCanvas) { |
|
11197 |
this.ctx = this.compositeCtx; |
|
11198 |
this.ctx.save(); |
|
11199 |
this.ctx.setTransform(1, 0, 0, 1, 0, 0); |
|
11200 |
this.ctx.drawImage(this.transparentCanvas, 0, 0); |
|
11201 |
this.ctx.restore(); |
|
11202 |
this.transparentCanvas = null; |
|
11203 |
} |
|
11204 |
this.cachedCanvases.clear(); |
|
11205 |
this.webGLContext.clear(); |
|
11206 |
if (this.imageLayer) { |
|
11207 |
this.imageLayer.endLayout(); |
|
11208 |
} |
|
11209 |
}, |
|
11210 |
setLineWidth: function CanvasGraphics_setLineWidth(width) { |
|
11211 |
this.current.lineWidth = width; |
|
11212 |
this.ctx.lineWidth = width; |
|
11213 |
}, |
|
11214 |
setLineCap: function CanvasGraphics_setLineCap(style) { |
|
11215 |
this.ctx.lineCap = LINE_CAP_STYLES[style]; |
|
11216 |
}, |
|
11217 |
setLineJoin: function CanvasGraphics_setLineJoin(style) { |
|
11218 |
this.ctx.lineJoin = LINE_JOIN_STYLES[style]; |
|
11219 |
}, |
|
11220 |
setMiterLimit: function CanvasGraphics_setMiterLimit(limit) { |
|
11221 |
this.ctx.miterLimit = limit; |
|
11222 |
}, |
|
11223 |
setDash: function CanvasGraphics_setDash(dashArray, dashPhase) { |
|
11224 |
var ctx = this.ctx; |
|
11225 |
if (ctx.setLineDash !== undefined) { |
|
11226 |
ctx.setLineDash(dashArray); |
|
11227 |
ctx.lineDashOffset = dashPhase; |
|
11228 |
} |
|
11229 |
}, |
|
11230 |
setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {}, |
|
11231 |
setFlatness: function CanvasGraphics_setFlatness(flatness) {}, |
|
11232 |
setGState: function CanvasGraphics_setGState(states) { |
|
11233 |
for (var i = 0, ii = states.length; i < ii; i++) { |
|
11234 |
var state = states[i]; |
|
11235 |
var key = state[0]; |
|
11236 |
var value = state[1]; |
|
11237 |
switch (key) { |
|
11238 |
case 'LW': |
|
11239 |
this.setLineWidth(value); |
|
11240 |
break; |
|
11241 |
case 'LC': |
|
11242 |
this.setLineCap(value); |
|
11243 |
break; |
|
11244 |
case 'LJ': |
|
11245 |
this.setLineJoin(value); |
|
11246 |
break; |
|
11247 |
case 'ML': |
|
11248 |
this.setMiterLimit(value); |
|
11249 |
break; |
|
11250 |
case 'D': |
|
11251 |
this.setDash(value[0], value[1]); |
|
11252 |
break; |
|
11253 |
case 'RI': |
|
11254 |
this.setRenderingIntent(value); |
|
11255 |
break; |
|
11256 |
case 'FL': |
|
11257 |
this.setFlatness(value); |
|
11258 |
break; |
|
11259 |
case 'Font': |
|
11260 |
this.setFont(value[0], value[1]); |
|
11261 |
break; |
|
11262 |
case 'CA': |
|
11263 |
this.current.strokeAlpha = state[1]; |
|
11264 |
break; |
|
11265 |
case 'ca': |
|
11266 |
this.current.fillAlpha = state[1]; |
|
11267 |
this.ctx.globalAlpha = state[1]; |
|
11268 |
break; |
|
11269 |
case 'BM': |
|
11270 |
this.ctx.globalCompositeOperation = value; |
|
11271 |
break; |
|
11272 |
case 'SMask': |
|
11273 |
if (this.current.activeSMask) { |
|
11274 |
if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) { |
|
11275 |
this.suspendSMaskGroup(); |
|
11276 |
} else { |
|
11277 |
this.endSMaskGroup(); |
|
11278 |
} |
|
11279 |
} |
|
11280 |
this.current.activeSMask = value ? this.tempSMask : null; |
|
11281 |
if (this.current.activeSMask) { |
|
11282 |
this.beginSMaskGroup(); |
|
11283 |
} |
|
11284 |
this.tempSMask = null; |
|
11285 |
break; |
|
11286 |
} |
|
11287 |
} |
|
11288 |
}, |
|
11289 |
beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() { |
|
11290 |
var activeSMask = this.current.activeSMask; |
|
11291 |
var drawnWidth = activeSMask.canvas.width; |
|
11292 |
var drawnHeight = activeSMask.canvas.height; |
|
11293 |
var cacheId = 'smaskGroupAt' + this.groupLevel; |
|
11294 |
var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true); |
|
11295 |
var currentCtx = this.ctx; |
|
11296 |
var currentTransform = currentCtx.mozCurrentTransform; |
|
11297 |
this.ctx.save(); |
|
11298 |
var groupCtx = scratchCanvas.context; |
|
11299 |
groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY); |
|
11300 |
groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY); |
|
11301 |
groupCtx.transform.apply(groupCtx, currentTransform); |
|
11302 |
activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse; |
|
11303 |
copyCtxState(currentCtx, groupCtx); |
|
11304 |
this.ctx = groupCtx; |
|
11305 |
this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]); |
|
11306 |
this.groupStack.push(currentCtx); |
|
11307 |
this.groupLevel++; |
|
11308 |
}, |
|
11309 |
suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() { |
|
11310 |
var groupCtx = this.ctx; |
|
11311 |
this.groupLevel--; |
|
11312 |
this.ctx = this.groupStack.pop(); |
|
11313 |
composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext); |
|
11314 |
this.ctx.restore(); |
|
11315 |
this.ctx.save(); |
|
11316 |
copyCtxState(groupCtx, this.ctx); |
|
11317 |
this.current.resumeSMaskCtx = groupCtx; |
|
11318 |
var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform); |
|
11319 |
this.ctx.transform.apply(this.ctx, deltaTransform); |
|
11320 |
groupCtx.save(); |
|
11321 |
groupCtx.setTransform(1, 0, 0, 1, 0, 0); |
|
11322 |
groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height); |
|
11323 |
groupCtx.restore(); |
|
11324 |
}, |
|
11325 |
resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() { |
|
11326 |
var groupCtx = this.current.resumeSMaskCtx; |
|
11327 |
var currentCtx = this.ctx; |
|
11328 |
this.ctx = groupCtx; |
|
11329 |
this.groupStack.push(currentCtx); |
|
11330 |
this.groupLevel++; |
|
11331 |
}, |
|
11332 |
endSMaskGroup: function CanvasGraphics_endSMaskGroup() { |
|
11333 |
var groupCtx = this.ctx; |
|
11334 |
this.groupLevel--; |
|
11335 |
this.ctx = this.groupStack.pop(); |
|
11336 |
composeSMask(this.ctx, this.current.activeSMask, groupCtx, this.webGLContext); |
|
11337 |
this.ctx.restore(); |
|
11338 |
copyCtxState(groupCtx, this.ctx); |
|
11339 |
var deltaTransform = _util.Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform); |
|
11340 |
this.ctx.transform.apply(this.ctx, deltaTransform); |
|
11341 |
}, |
|
11342 |
save: function CanvasGraphics_save() { |
|
11343 |
this.ctx.save(); |
|
11344 |
var old = this.current; |
|
11345 |
this.stateStack.push(old); |
|
11346 |
this.current = old.clone(); |
|
11347 |
this.current.resumeSMaskCtx = null; |
|
11348 |
}, |
|
11349 |
restore: function CanvasGraphics_restore() { |
|
11350 |
if (this.current.resumeSMaskCtx) { |
|
11351 |
this.resumeSMaskGroup(); |
|
11352 |
} |
|
11353 |
if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) { |
|
11354 |
this.endSMaskGroup(); |
|
11355 |
} |
|
11356 |
if (this.stateStack.length !== 0) { |
|
11357 |
this.current = this.stateStack.pop(); |
|
11358 |
this.ctx.restore(); |
|
11359 |
this.pendingClip = null; |
|
11360 |
this._cachedGetSinglePixelWidth = null; |
|
11361 |
} |
|
11362 |
}, |
|
11363 |
transform: function CanvasGraphics_transform(a, b, c, d, e, f) { |
|
11364 |
this.ctx.transform(a, b, c, d, e, f); |
|
11365 |
this._cachedGetSinglePixelWidth = null; |
|
11366 |
}, |
|
11367 |
constructPath: function CanvasGraphics_constructPath(ops, args) { |
|
11368 |
var ctx = this.ctx; |
|
11369 |
var current = this.current; |
|
11370 |
var x = current.x, |
|
11371 |
y = current.y; |
|
11372 |
for (var i = 0, j = 0, ii = ops.length; i < ii; i++) { |
|
11373 |
switch (ops[i] | 0) { |
|
11374 |
case _util.OPS.rectangle: |
|
11375 |
x = args[j++]; |
|
11376 |
y = args[j++]; |
|
11377 |
var width = args[j++]; |
|
11378 |
var height = args[j++]; |
|
11379 |
if (width === 0) { |
|
11380 |
width = this.getSinglePixelWidth(); |
|
11381 |
} |
|
11382 |
if (height === 0) { |
|
11383 |
height = this.getSinglePixelWidth(); |
|
11384 |
} |
|
11385 |
var xw = x + width; |
|
11386 |
var yh = y + height; |
|
11387 |
this.ctx.moveTo(x, y); |
|
11388 |
this.ctx.lineTo(xw, y); |
|
11389 |
this.ctx.lineTo(xw, yh); |
|
11390 |
this.ctx.lineTo(x, yh); |
|
11391 |
this.ctx.lineTo(x, y); |
|
11392 |
this.ctx.closePath(); |
|
11393 |
break; |
|
11394 |
case _util.OPS.moveTo: |
|
11395 |
x = args[j++]; |
|
11396 |
y = args[j++]; |
|
11397 |
ctx.moveTo(x, y); |
|
11398 |
break; |
|
11399 |
case _util.OPS.lineTo: |
|
11400 |
x = args[j++]; |
|
11401 |
y = args[j++]; |
|
11402 |
ctx.lineTo(x, y); |
|
11403 |
break; |
|
11404 |
case _util.OPS.curveTo: |
|
11405 |
x = args[j + 4]; |
|
11406 |
y = args[j + 5]; |
|
11407 |
ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y); |
|
11408 |
j += 6; |
|
11409 |
break; |
|
11410 |
case _util.OPS.curveTo2: |
|
11411 |
ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]); |
|
11412 |
x = args[j + 2]; |
|
11413 |
y = args[j + 3]; |
|
11414 |
j += 4; |
|
11415 |
break; |
|
11416 |
case _util.OPS.curveTo3: |
|
11417 |
x = args[j + 2]; |
|
11418 |
y = args[j + 3]; |
|
11419 |
ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y); |
|
11420 |
j += 4; |
|
11421 |
break; |
|
11422 |
case _util.OPS.closePath: |
|
11423 |
ctx.closePath(); |
|
11424 |
break; |
|
11425 |
} |
|
11426 |
} |
|
11427 |
current.setCurrentPoint(x, y); |
|
11428 |
}, |
|
11429 |
closePath: function CanvasGraphics_closePath() { |
|
11430 |
this.ctx.closePath(); |
|
11431 |
}, |
|
11432 |
stroke: function CanvasGraphics_stroke(consumePath) { |
|
11433 |
consumePath = typeof consumePath !== 'undefined' ? consumePath : true; |
|
11434 |
var ctx = this.ctx; |
|
11435 |
var strokeColor = this.current.strokeColor; |
|
11436 |
ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth); |
|
11437 |
ctx.globalAlpha = this.current.strokeAlpha; |
|
11438 |
if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') { |
|
11439 |
ctx.save(); |
|
11440 |
ctx.strokeStyle = strokeColor.getPattern(ctx, this); |
|
11441 |
ctx.stroke(); |
|
11442 |
ctx.restore(); |
|
11443 |
} else { |
|
11444 |
ctx.stroke(); |
|
11445 |
} |
|
11446 |
if (consumePath) { |
|
11447 |
this.consumePath(); |
|
11448 |
} |
|
11449 |
ctx.globalAlpha = this.current.fillAlpha; |
|
11450 |
}, |
|
11451 |
closeStroke: function CanvasGraphics_closeStroke() { |
|
11452 |
this.closePath(); |
|
11453 |
this.stroke(); |
|
11454 |
}, |
|
11455 |
fill: function CanvasGraphics_fill(consumePath) { |
|
11456 |
consumePath = typeof consumePath !== 'undefined' ? consumePath : true; |
|
11457 |
var ctx = this.ctx; |
|
11458 |
var fillColor = this.current.fillColor; |
|
11459 |
var isPatternFill = this.current.patternFill; |
|
11460 |
var needRestore = false; |
|
11461 |
if (isPatternFill) { |
|
11462 |
ctx.save(); |
|
11463 |
if (this.baseTransform) { |
|
11464 |
ctx.setTransform.apply(ctx, this.baseTransform); |
|
11465 |
} |
|
11466 |
ctx.fillStyle = fillColor.getPattern(ctx, this); |
|
11467 |
needRestore = true; |
|
11468 |
} |
|
11469 |
if (this.pendingEOFill) { |
|
11470 |
ctx.fill('evenodd'); |
|
11471 |
this.pendingEOFill = false; |
|
11472 |
} else { |
|
11473 |
ctx.fill(); |
|
11474 |
} |
|
11475 |
if (needRestore) { |
|
11476 |
ctx.restore(); |
|
11477 |
} |
|
11478 |
if (consumePath) { |
|
11479 |
this.consumePath(); |
|
11480 |
} |
|
11481 |
}, |
|
11482 |
eoFill: function CanvasGraphics_eoFill() { |
|
11483 |
this.pendingEOFill = true; |
|
11484 |
this.fill(); |
|
11485 |
}, |
|
11486 |
fillStroke: function CanvasGraphics_fillStroke() { |
|
11487 |
this.fill(false); |
|
11488 |
this.stroke(false); |
|
11489 |
this.consumePath(); |
|
11490 |
}, |
|
11491 |
eoFillStroke: function CanvasGraphics_eoFillStroke() { |
|
11492 |
this.pendingEOFill = true; |
|
11493 |
this.fillStroke(); |
|
11494 |
}, |
|
11495 |
closeFillStroke: function CanvasGraphics_closeFillStroke() { |
|
11496 |
this.closePath(); |
|
11497 |
this.fillStroke(); |
|
11498 |
}, |
|
11499 |
closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() { |
|
11500 |
this.pendingEOFill = true; |
|
11501 |
this.closePath(); |
|
11502 |
this.fillStroke(); |
|
11503 |
}, |
|
11504 |
endPath: function CanvasGraphics_endPath() { |
|
11505 |
this.consumePath(); |
|
11506 |
}, |
|
11507 |
clip: function CanvasGraphics_clip() { |
|
11508 |
this.pendingClip = NORMAL_CLIP; |
|
11509 |
}, |
|
11510 |
eoClip: function CanvasGraphics_eoClip() { |
|
11511 |
this.pendingClip = EO_CLIP; |
|
11512 |
}, |
|
11513 |
beginText: function CanvasGraphics_beginText() { |
|
11514 |
this.current.textMatrix = _util.IDENTITY_MATRIX; |
|
11515 |
this.current.textMatrixScale = 1; |
|
11516 |
this.current.x = this.current.lineX = 0; |
|
11517 |
this.current.y = this.current.lineY = 0; |
|
11518 |
}, |
|
11519 |
endText: function CanvasGraphics_endText() { |
|
11520 |
var paths = this.pendingTextPaths; |
|
11521 |
var ctx = this.ctx; |
|
11522 |
if (paths === undefined) { |
|
11523 |
ctx.beginPath(); |
|
11524 |
return; |
|
11525 |
} |
|
11526 |
ctx.save(); |
|
11527 |
ctx.beginPath(); |
|
11528 |
for (var i = 0; i < paths.length; i++) { |
|
11529 |
var path = paths[i]; |
|
11530 |
ctx.setTransform.apply(ctx, path.transform); |
|
11531 |
ctx.translate(path.x, path.y); |
|
11532 |
path.addToPath(ctx, path.fontSize); |
|
11533 |
} |
|
11534 |
ctx.restore(); |
|
11535 |
ctx.clip(); |
|
11536 |
ctx.beginPath(); |
|
11537 |
delete this.pendingTextPaths; |
|
11538 |
}, |
|
11539 |
setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) { |
|
11540 |
this.current.charSpacing = spacing; |
|
11541 |
}, |
|
11542 |
setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) { |
|
11543 |
this.current.wordSpacing = spacing; |
|
11544 |
}, |
|
11545 |
setHScale: function CanvasGraphics_setHScale(scale) { |
|
11546 |
this.current.textHScale = scale / 100; |
|
11547 |
}, |
|
11548 |
setLeading: function CanvasGraphics_setLeading(leading) { |
|
11549 |
this.current.leading = -leading; |
|
11550 |
}, |
|
11551 |
setFont: function CanvasGraphics_setFont(fontRefName, size) { |
|
11552 |
var fontObj = this.commonObjs.get(fontRefName); |
|
11553 |
var current = this.current; |
|
11554 |
if (!fontObj) { |
|
11555 |
throw new Error('Can\'t find font for ' + fontRefName); |
|
11556 |
} |
|
11557 |
current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX; |
|
11558 |
if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) { |
|
11559 |
(0, _util.warn)('Invalid font matrix for font ' + fontRefName); |
|
11560 |
} |
|
11561 |
if (size < 0) { |
|
11562 |
size = -size; |
|
11563 |
current.fontDirection = -1; |
|
11564 |
} else { |
|
11565 |
current.fontDirection = 1; |
|
11566 |
} |
|
11567 |
this.current.font = fontObj; |
|
11568 |
this.current.fontSize = size; |
|
11569 |
if (fontObj.isType3Font) { |
|
11570 |
return; |
|
11571 |
} |
|
11572 |
var name = fontObj.loadedName || 'sans-serif'; |
|
11573 |
var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal'; |
|
11574 |
var italic = fontObj.italic ? 'italic' : 'normal'; |
|
11575 |
var typeface = '"' + name + '", ' + fontObj.fallbackName; |
|
11576 |
var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size; |
|
11577 |
this.current.fontSizeScale = size / browserFontSize; |
|
11578 |
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface; |
|
11579 |
this.ctx.font = rule; |
|
11580 |
}, |
|
11581 |
setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) { |
|
11582 |
this.current.textRenderingMode = mode; |
|
11583 |
}, |
|
11584 |
setTextRise: function CanvasGraphics_setTextRise(rise) { |
|
11585 |
this.current.textRise = rise; |
|
11586 |
}, |
|
11587 |
moveText: function CanvasGraphics_moveText(x, y) { |
|
11588 |
this.current.x = this.current.lineX += x; |
|
11589 |
this.current.y = this.current.lineY += y; |
|
11590 |
}, |
|
11591 |
setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) { |
|
11592 |
this.setLeading(-y); |
|
11593 |
this.moveText(x, y); |
|
11594 |
}, |
|
11595 |
setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) { |
|
11596 |
this.current.textMatrix = [a, b, c, d, e, f]; |
|
11597 |
this.current.textMatrixScale = Math.sqrt(a * a + b * b); |
|
11598 |
this.current.x = this.current.lineX = 0; |
|
11599 |
this.current.y = this.current.lineY = 0; |
|
11600 |
}, |
|
11601 |
nextLine: function CanvasGraphics_nextLine() { |
|
11602 |
this.moveText(0, this.current.leading); |
|
11603 |
}, |
|
11604 |
paintChar: function paintChar(character, x, y, patternTransform) { |
|
11605 |
var ctx = this.ctx; |
|
11606 |
var current = this.current; |
|
11607 |
var font = current.font; |
|
11608 |
var textRenderingMode = current.textRenderingMode; |
|
11609 |
var fontSize = current.fontSize / current.fontSizeScale; |
|
11610 |
var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK; |
|
11611 |
var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG); |
|
11612 |
var patternFill = current.patternFill && font.data; |
|
11613 |
var addToPath; |
|
11614 |
if (font.disableFontFace || isAddToPathSet || patternFill) { |
|
11615 |
addToPath = font.getPathGenerator(this.commonObjs, character); |
|
11616 |
} |
|
11617 |
if (font.disableFontFace || patternFill) { |
|
11618 |
ctx.save(); |
|
11619 |
ctx.translate(x, y); |
|
11620 |
ctx.beginPath(); |
|
11621 |
addToPath(ctx, fontSize); |
|
11622 |
if (patternTransform) { |
|
11623 |
ctx.setTransform.apply(ctx, patternTransform); |
|
11624 |
} |
|
11625 |
if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) { |
|
11626 |
ctx.fill(); |
|
11627 |
} |
|
11628 |
if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) { |
|
11629 |
ctx.stroke(); |
|
11630 |
} |
|
11631 |
ctx.restore(); |
|
11632 |
} else { |
|
11633 |
if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) { |
|
11634 |
ctx.fillText(character, x, y); |
|
11635 |
} |
|
11636 |
if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) { |
|
11637 |
ctx.strokeText(character, x, y); |
|
11638 |
} |
|
11639 |
} |
|
11640 |
if (isAddToPathSet) { |
|
11641 |
var paths = this.pendingTextPaths || (this.pendingTextPaths = []); |
|
11642 |
paths.push({ |
|
11643 |
transform: ctx.mozCurrentTransform, |
|
11644 |
x: x, |
|
11645 |
y: y, |
|
11646 |
fontSize: fontSize, |
|
11647 |
addToPath: addToPath |
|
11648 |
}); |
|
11649 |
} |
|
11650 |
}, |
|
11651 |
|
|
11652 |
get isFontSubpixelAAEnabled() { |
|
11653 |
var ctx = this.canvasFactory.create(10, 10).context; |
|
11654 |
ctx.scale(1.5, 1); |
|
11655 |
ctx.fillText('I', 0, 10); |
|
11656 |
var data = ctx.getImageData(0, 0, 10, 10).data; |
|
11657 |
var enabled = false; |
|
11658 |
for (var i = 3; i < data.length; i += 4) { |
|
11659 |
if (data[i] > 0 && data[i] < 255) { |
|
11660 |
enabled = true; |
|
11661 |
break; |
|
11662 |
} |
|
11663 |
} |
|
11664 |
return (0, _util.shadow)(this, 'isFontSubpixelAAEnabled', enabled); |
|
11665 |
}, |
|
11666 |
showText: function CanvasGraphics_showText(glyphs) { |
|
11667 |
var current = this.current; |
|
11668 |
var font = current.font; |
|
11669 |
if (font.isType3Font) { |
|
11670 |
return this.showType3Text(glyphs); |
|
11671 |
} |
|
11672 |
var fontSize = current.fontSize; |
|
11673 |
if (fontSize === 0) { |
|
11674 |
return; |
|
11675 |
} |
|
11676 |
var ctx = this.ctx; |
|
11677 |
var fontSizeScale = current.fontSizeScale; |
|
11678 |
var charSpacing = current.charSpacing; |
|
11679 |
var wordSpacing = current.wordSpacing; |
|
11680 |
var fontDirection = current.fontDirection; |
|
11681 |
var textHScale = current.textHScale * fontDirection; |
|
11682 |
var glyphsLength = glyphs.length; |
|
11683 |
var vertical = font.vertical; |
|
11684 |
var spacingDir = vertical ? 1 : -1; |
|
11685 |
var defaultVMetrics = font.defaultVMetrics; |
|
11686 |
var widthAdvanceScale = fontSize * current.fontMatrix[0]; |
|
11687 |
var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill; |
|
11688 |
ctx.save(); |
|
11689 |
var patternTransform = void 0; |
|
11690 |
if (current.patternFill) { |
|
11691 |
ctx.save(); |
|
11692 |
var pattern = current.fillColor.getPattern(ctx, this); |
|
11693 |
patternTransform = ctx.mozCurrentTransform; |
|
11694 |
ctx.restore(); |
|
11695 |
ctx.fillStyle = pattern; |
|
11696 |
} |
|
11697 |
ctx.transform.apply(ctx, current.textMatrix); |
|
11698 |
ctx.translate(current.x, current.y + current.textRise); |
|
11699 |
if (fontDirection > 0) { |
|
11700 |
ctx.scale(textHScale, -1); |
|
11701 |
} else { |
|
11702 |
ctx.scale(textHScale, 1); |
|
11703 |
} |
|
11704 |
var lineWidth = current.lineWidth; |
|
11705 |
var scale = current.textMatrixScale; |
|
11706 |
if (scale === 0 || lineWidth === 0) { |
|
11707 |
var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK; |
|
11708 |
if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) { |
|
11709 |
this._cachedGetSinglePixelWidth = null; |
|
11710 |
lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR; |
|
11711 |
} |
|
11712 |
} else { |
|
11713 |
lineWidth /= scale; |
|
11714 |
} |
|
11715 |
if (fontSizeScale !== 1.0) { |
|
11716 |
ctx.scale(fontSizeScale, fontSizeScale); |
|
11717 |
lineWidth /= fontSizeScale; |
|
11718 |
} |
|
11719 |
ctx.lineWidth = lineWidth; |
|
11720 |
var x = 0, |
|
11721 |
i; |
|
11722 |
for (i = 0; i < glyphsLength; ++i) { |
|
11723 |
var glyph = glyphs[i]; |
|
11724 |
if ((0, _util.isNum)(glyph)) { |
|
11725 |
x += spacingDir * glyph * fontSize / 1000; |
|
11726 |
continue; |
|
11727 |
} |
|
11728 |
var restoreNeeded = false; |
|
11729 |
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing; |
|
11730 |
var character = glyph.fontChar; |
|
11731 |
var accent = glyph.accent; |
|
11732 |
var scaledX, scaledY, scaledAccentX, scaledAccentY; |
|
11733 |
var width = glyph.width; |
|
11734 |
if (vertical) { |
|
11735 |
var vmetric, vx, vy; |
|
11736 |
vmetric = glyph.vmetric || defaultVMetrics; |
|
11737 |
vx = glyph.vmetric ? vmetric[1] : width * 0.5; |
|
11738 |
vx = -vx * widthAdvanceScale; |
|
11739 |
vy = vmetric[2] * widthAdvanceScale; |
|
11740 |
width = vmetric ? -vmetric[0] : width; |
|
11741 |
scaledX = vx / fontSizeScale; |
|
11742 |
scaledY = (x + vy) / fontSizeScale; |
|
11743 |
} else { |
|
11744 |
scaledX = x / fontSizeScale; |
|
11745 |
scaledY = 0; |
|
11746 |
} |
|
11747 |
if (font.remeasure && width > 0) { |
|
11748 |
var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale; |
|
11749 |
if (width < measuredWidth && this.isFontSubpixelAAEnabled) { |
|
11750 |
var characterScaleX = width / measuredWidth; |
|
11751 |
restoreNeeded = true; |
|
11752 |
ctx.save(); |
|
11753 |
ctx.scale(characterScaleX, 1); |
|
11754 |
scaledX /= characterScaleX; |
|
11755 |
} else if (width !== measuredWidth) { |
|
11756 |
scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale; |
|
11757 |
} |
|
11758 |
} |
|
11759 |
if (glyph.isInFont || font.missingFile) { |
|
11760 |
if (simpleFillText && !accent) { |
|
11761 |
ctx.fillText(character, scaledX, scaledY); |
|
11762 |
} else { |
|
11763 |
this.paintChar(character, scaledX, scaledY, patternTransform); |
|
11764 |
if (accent) { |
|
11765 |
scaledAccentX = scaledX + accent.offset.x / fontSizeScale; |
|
11766 |
scaledAccentY = scaledY - accent.offset.y / fontSizeScale; |
|
11767 |
this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform); |
|
11768 |
} |
|
11769 |
} |
|
11770 |
} |
|
11771 |
var charWidth = width * widthAdvanceScale + spacing * fontDirection; |
|
11772 |
x += charWidth; |
|
11773 |
if (restoreNeeded) { |
|
11774 |
ctx.restore(); |
|
11775 |
} |
|
11776 |
} |
|
11777 |
if (vertical) { |
|
11778 |
current.y -= x * textHScale; |
|
11779 |
} else { |
|
11780 |
current.x += x * textHScale; |
|
11781 |
} |
|
11782 |
ctx.restore(); |
|
11783 |
}, |
|
11784 |
showType3Text: function CanvasGraphics_showType3Text(glyphs) { |
|
11785 |
var ctx = this.ctx; |
|
11786 |
var current = this.current; |
|
11787 |
var font = current.font; |
|
11788 |
var fontSize = current.fontSize; |
|
11789 |
var fontDirection = current.fontDirection; |
|
11790 |
var spacingDir = font.vertical ? 1 : -1; |
|
11791 |
var charSpacing = current.charSpacing; |
|
11792 |
var wordSpacing = current.wordSpacing; |
|
11793 |
var textHScale = current.textHScale * fontDirection; |
|
11794 |
var fontMatrix = current.fontMatrix || _util.FONT_IDENTITY_MATRIX; |
|
11795 |
var glyphsLength = glyphs.length; |
|
11796 |
var isTextInvisible = current.textRenderingMode === _util.TextRenderingMode.INVISIBLE; |
|
11797 |
var i, glyph, width, spacingLength; |
|
11798 |
if (isTextInvisible || fontSize === 0) { |
|
11799 |
return; |
|
11800 |
} |
|
11801 |
this._cachedGetSinglePixelWidth = null; |
|
11802 |
ctx.save(); |
|
11803 |
ctx.transform.apply(ctx, current.textMatrix); |
|
11804 |
ctx.translate(current.x, current.y); |
|
11805 |
ctx.scale(textHScale, fontDirection); |
|
11806 |
for (i = 0; i < glyphsLength; ++i) { |
|
11807 |
glyph = glyphs[i]; |
|
11808 |
if ((0, _util.isNum)(glyph)) { |
|
11809 |
spacingLength = spacingDir * glyph * fontSize / 1000; |
|
11810 |
this.ctx.translate(spacingLength, 0); |
|
11811 |
current.x += spacingLength * textHScale; |
|
11812 |
continue; |
|
11813 |
} |
|
11814 |
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing; |
|
11815 |
var operatorList = font.charProcOperatorList[glyph.operatorListId]; |
|
11816 |
if (!operatorList) { |
|
11817 |
(0, _util.warn)('Type3 character "' + glyph.operatorListId + '" is not available.'); |
|
11818 |
continue; |
|
11819 |
} |
|
11820 |
this.processingType3 = glyph; |
|
11821 |
this.save(); |
|
11822 |
ctx.scale(fontSize, fontSize); |
|
11823 |
ctx.transform.apply(ctx, fontMatrix); |
|
11824 |
this.executeOperatorList(operatorList); |
|
11825 |
this.restore(); |
|
11826 |
var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix); |
|
11827 |
width = transformed[0] * fontSize + spacing; |
|
11828 |
ctx.translate(width, 0); |
|
11829 |
current.x += width * textHScale; |
|
11830 |
} |
|
11831 |
ctx.restore(); |
|
11832 |
this.processingType3 = null; |
|
11833 |
}, |
|
11834 |
setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {}, |
|
11835 |
setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) { |
|
11836 |
this.ctx.rect(llx, lly, urx - llx, ury - lly); |
|
11837 |
this.clip(); |
|
11838 |
this.endPath(); |
|
11839 |
}, |
|
11840 |
getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) { |
|
11841 |
var _this = this; |
|
11842 |
|
|
11843 |
var pattern; |
|
11844 |
if (IR[0] === 'TilingPattern') { |
|
11845 |
var color = IR[1]; |
|
11846 |
var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice(); |
|
11847 |
var canvasGraphicsFactory = { |
|
11848 |
createCanvasGraphics: function createCanvasGraphics(ctx) { |
|
11849 |
return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory, _this.webGLContext); |
|
11850 |
} |
|
11851 |
}; |
|
11852 |
pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform); |
|
11853 |
} else { |
|
11854 |
pattern = (0, _pattern_helper.getShadingPatternFromIR)(IR); |
|
11855 |
} |
|
11856 |
return pattern; |
|
11857 |
}, |
|
11858 |
setStrokeColorN: function CanvasGraphics_setStrokeColorN() { |
|
11859 |
this.current.strokeColor = this.getColorN_Pattern(arguments); |
|
11860 |
}, |
|
11861 |
setFillColorN: function CanvasGraphics_setFillColorN() { |
|
11862 |
this.current.fillColor = this.getColorN_Pattern(arguments); |
|
11863 |
this.current.patternFill = true; |
|
11864 |
}, |
|
11865 |
setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) { |
|
11866 |
var color = _util.Util.makeCssRgb(r, g, b); |
|
11867 |
this.ctx.strokeStyle = color; |
|
11868 |
this.current.strokeColor = color; |
|
11869 |
}, |
|
11870 |
setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) { |
|
11871 |
var color = _util.Util.makeCssRgb(r, g, b); |
|
11872 |
this.ctx.fillStyle = color; |
|
11873 |
this.current.fillColor = color; |
|
11874 |
this.current.patternFill = false; |
|
11875 |
}, |
|
11876 |
shadingFill: function CanvasGraphics_shadingFill(patternIR) { |
|
11877 |
var ctx = this.ctx; |
|
11878 |
this.save(); |
|
11879 |
var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR); |
|
11880 |
ctx.fillStyle = pattern.getPattern(ctx, this, true); |
|
11881 |
var inv = ctx.mozCurrentTransformInverse; |
|
11882 |
if (inv) { |
|
11883 |
var canvas = ctx.canvas; |
|
11884 |
var width = canvas.width; |
|
11885 |
var height = canvas.height; |
|
11886 |
var bl = _util.Util.applyTransform([0, 0], inv); |
|
11887 |
var br = _util.Util.applyTransform([0, height], inv); |
|
11888 |
var ul = _util.Util.applyTransform([width, 0], inv); |
|
11889 |
var ur = _util.Util.applyTransform([width, height], inv); |
|
11890 |
var x0 = Math.min(bl[0], br[0], ul[0], ur[0]); |
|
11891 |
var y0 = Math.min(bl[1], br[1], ul[1], ur[1]); |
|
11892 |
var x1 = Math.max(bl[0], br[0], ul[0], ur[0]); |
|
11893 |
var y1 = Math.max(bl[1], br[1], ul[1], ur[1]); |
|
11894 |
this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0); |
|
11895 |
} else { |
|
11896 |
this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10); |
|
11897 |
} |
|
11898 |
this.restore(); |
|
11899 |
}, |
|
11900 |
beginInlineImage: function CanvasGraphics_beginInlineImage() { |
|
11901 |
(0, _util.unreachable)('Should not call beginInlineImage'); |
|
11902 |
}, |
|
11903 |
beginImageData: function CanvasGraphics_beginImageData() { |
|
11904 |
(0, _util.unreachable)('Should not call beginImageData'); |
|
11905 |
}, |
|
11906 |
paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) { |
|
11907 |
this.save(); |
|
11908 |
this.baseTransformStack.push(this.baseTransform); |
|
11909 |
if (Array.isArray(matrix) && matrix.length === 6) { |
|
11910 |
this.transform.apply(this, matrix); |
|
11911 |
} |
|
11912 |
this.baseTransform = this.ctx.mozCurrentTransform; |
|
11913 |
if (Array.isArray(bbox) && bbox.length === 4) { |
|
11914 |
var width = bbox[2] - bbox[0]; |
|
11915 |
var height = bbox[3] - bbox[1]; |
|
11916 |
this.ctx.rect(bbox[0], bbox[1], width, height); |
|
11917 |
this.clip(); |
|
11918 |
this.endPath(); |
|
11919 |
} |
|
11920 |
}, |
|
11921 |
paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() { |
|
11922 |
this.restore(); |
|
11923 |
this.baseTransform = this.baseTransformStack.pop(); |
|
11924 |
}, |
|
11925 |
beginGroup: function CanvasGraphics_beginGroup(group) { |
|
11926 |
this.save(); |
|
11927 |
var currentCtx = this.ctx; |
|
11928 |
if (!group.isolated) { |
|
11929 |
(0, _util.info)('TODO: Support non-isolated groups.'); |
|
11930 |
} |
|
11931 |
if (group.knockout) { |
|
11932 |
(0, _util.warn)('Knockout groups not supported.'); |
|
11933 |
} |
|
11934 |
var currentTransform = currentCtx.mozCurrentTransform; |
|
11935 |
if (group.matrix) { |
|
11936 |
currentCtx.transform.apply(currentCtx, group.matrix); |
|
11937 |
} |
|
11938 |
if (!group.bbox) { |
|
11939 |
throw new Error('Bounding box is required.'); |
|
11940 |
} |
|
11941 |
var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform); |
|
11942 |
var canvasBounds = [0, 0, currentCtx.canvas.width, currentCtx.canvas.height]; |
|
11943 |
bounds = _util.Util.intersect(bounds, canvasBounds) || [0, 0, 0, 0]; |
|
11944 |
var offsetX = Math.floor(bounds[0]); |
|
11945 |
var offsetY = Math.floor(bounds[1]); |
|
11946 |
var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1); |
|
11947 |
var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1); |
|
11948 |
var scaleX = 1, |
|
11949 |
scaleY = 1; |
|
11950 |
if (drawnWidth > MAX_GROUP_SIZE) { |
|
11951 |
scaleX = drawnWidth / MAX_GROUP_SIZE; |
|
11952 |
drawnWidth = MAX_GROUP_SIZE; |
|
11953 |
} |
|
11954 |
if (drawnHeight > MAX_GROUP_SIZE) { |
|
11955 |
scaleY = drawnHeight / MAX_GROUP_SIZE; |
|
11956 |
drawnHeight = MAX_GROUP_SIZE; |
|
11957 |
} |
|
11958 |
var cacheId = 'groupAt' + this.groupLevel; |
|
11959 |
if (group.smask) { |
|
11960 |
cacheId += '_smask_' + this.smaskCounter++ % 2; |
|
11961 |
} |
|
11962 |
var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true); |
|
11963 |
var groupCtx = scratchCanvas.context; |
|
11964 |
groupCtx.scale(1 / scaleX, 1 / scaleY); |
|
11965 |
groupCtx.translate(-offsetX, -offsetY); |
|
11966 |
groupCtx.transform.apply(groupCtx, currentTransform); |
|
11967 |
if (group.smask) { |
|
11968 |
this.smaskStack.push({ |
|
11969 |
canvas: scratchCanvas.canvas, |
|
11970 |
context: groupCtx, |
|
11971 |
offsetX: offsetX, |
|
11972 |
offsetY: offsetY, |
|
11973 |
scaleX: scaleX, |
|
11974 |
scaleY: scaleY, |
|
11975 |
subtype: group.smask.subtype, |
|
11976 |
backdrop: group.smask.backdrop, |
|
11977 |
transferMap: group.smask.transferMap || null, |
|
11978 |
startTransformInverse: null |
|
11979 |
}); |
|
11980 |
} else { |
|
11981 |
currentCtx.setTransform(1, 0, 0, 1, 0, 0); |
|
11982 |
currentCtx.translate(offsetX, offsetY); |
|
11983 |
currentCtx.scale(scaleX, scaleY); |
|
11984 |
} |
|
11985 |
copyCtxState(currentCtx, groupCtx); |
|
11986 |
this.ctx = groupCtx; |
|
11987 |
this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]); |
|
11988 |
this.groupStack.push(currentCtx); |
|
11989 |
this.groupLevel++; |
|
11990 |
this.current.activeSMask = null; |
|
11991 |
}, |
|
11992 |
endGroup: function CanvasGraphics_endGroup(group) { |
|
11993 |
this.groupLevel--; |
|
11994 |
var groupCtx = this.ctx; |
|
11995 |
this.ctx = this.groupStack.pop(); |
|
11996 |
if (this.ctx.imageSmoothingEnabled !== undefined) { |
|
11997 |
this.ctx.imageSmoothingEnabled = false; |
|
11998 |
} else { |
|
11999 |
this.ctx.mozImageSmoothingEnabled = false; |
|
12000 |
} |
|
12001 |
if (group.smask) { |
|
12002 |
this.tempSMask = this.smaskStack.pop(); |
|
12003 |
} else { |
|
12004 |
this.ctx.drawImage(groupCtx.canvas, 0, 0); |
|
12005 |
} |
|
12006 |
this.restore(); |
|
12007 |
}, |
|
12008 |
beginAnnotations: function CanvasGraphics_beginAnnotations() { |
|
12009 |
this.save(); |
|
12010 |
if (this.baseTransform) { |
|
12011 |
this.ctx.setTransform.apply(this.ctx, this.baseTransform); |
|
12012 |
} |
|
12013 |
}, |
|
12014 |
endAnnotations: function CanvasGraphics_endAnnotations() { |
|
12015 |
this.restore(); |
|
12016 |
}, |
|
12017 |
beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) { |
|
12018 |
this.save(); |
|
12019 |
resetCtxToDefault(this.ctx); |
|
12020 |
this.current = new CanvasExtraState(); |
|
12021 |
if (Array.isArray(rect) && rect.length === 4) { |
|
12022 |
var width = rect[2] - rect[0]; |
|
12023 |
var height = rect[3] - rect[1]; |
|
12024 |
this.ctx.rect(rect[0], rect[1], width, height); |
|
12025 |
this.clip(); |
|
12026 |
this.endPath(); |
|
12027 |
} |
|
12028 |
this.transform.apply(this, transform); |
|
12029 |
this.transform.apply(this, matrix); |
|
12030 |
}, |
|
12031 |
endAnnotation: function CanvasGraphics_endAnnotation() { |
|
12032 |
this.restore(); |
|
12033 |
}, |
|
12034 |
paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) { |
|
12035 |
var domImage = this.objs.get(objId); |
|
12036 |
if (!domImage) { |
|
12037 |
(0, _util.warn)('Dependent image isn\'t ready yet'); |
|
12038 |
return; |
|
12039 |
} |
|
12040 |
this.save(); |
|
12041 |
var ctx = this.ctx; |
|
12042 |
ctx.scale(1 / w, -1 / h); |
|
12043 |
ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h); |
|
12044 |
if (this.imageLayer) { |
|
12045 |
var currentTransform = ctx.mozCurrentTransformInverse; |
|
12046 |
var position = this.getCanvasPosition(0, 0); |
|
12047 |
this.imageLayer.appendImage({ |
|
12048 |
objId: objId, |
|
12049 |
left: position[0], |
|
12050 |
top: position[1], |
|
12051 |
width: w / currentTransform[0], |
|
12052 |
height: h / currentTransform[3] |
|
12053 |
}); |
|
12054 |
} |
|
12055 |
this.restore(); |
|
12056 |
}, |
|
12057 |
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) { |
|
12058 |
var ctx = this.ctx; |
|
12059 |
var width = img.width, |
|
12060 |
height = img.height; |
|
12061 |
var fillColor = this.current.fillColor; |
|
12062 |
var isPatternFill = this.current.patternFill; |
|
12063 |
var glyph = this.processingType3; |
|
12064 |
if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) { |
|
12065 |
if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) { |
|
12066 |
glyph.compiled = compileType3Glyph({ |
|
12067 |
data: img.data, |
|
12068 |
width: width, |
|
12069 |
height: height |
|
12070 |
}); |
|
12071 |
} else { |
|
12072 |
glyph.compiled = null; |
|
12073 |
} |
|
12074 |
} |
|
12075 |
if (glyph && glyph.compiled) { |
|
12076 |
glyph.compiled(ctx); |
|
12077 |
return; |
|
12078 |
} |
|
12079 |
var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height); |
|
12080 |
var maskCtx = maskCanvas.context; |
|
12081 |
maskCtx.save(); |
|
12082 |
putBinaryImageMask(maskCtx, img); |
|
12083 |
maskCtx.globalCompositeOperation = 'source-in'; |
|
12084 |
maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor; |
|
12085 |
maskCtx.fillRect(0, 0, width, height); |
|
12086 |
maskCtx.restore(); |
|
12087 |
this.paintInlineImageXObject(maskCanvas.canvas); |
|
12088 |
}, |
|
12089 |
paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) { |
|
12090 |
var width = imgData.width; |
|
12091 |
var height = imgData.height; |
|
12092 |
var fillColor = this.current.fillColor; |
|
12093 |
var isPatternFill = this.current.patternFill; |
|
12094 |
var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height); |
|
12095 |
var maskCtx = maskCanvas.context; |
|
12096 |
maskCtx.save(); |
|
12097 |
putBinaryImageMask(maskCtx, imgData); |
|
12098 |
maskCtx.globalCompositeOperation = 'source-in'; |
|
12099 |
maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor; |
|
12100 |
maskCtx.fillRect(0, 0, width, height); |
|
12101 |
maskCtx.restore(); |
|
12102 |
var ctx = this.ctx; |
|
12103 |
for (var i = 0, ii = positions.length; i < ii; i += 2) { |
|
12104 |
ctx.save(); |
|
12105 |
ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]); |
|
12106 |
ctx.scale(1, -1); |
|
12107 |
ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1); |
|
12108 |
ctx.restore(); |
|
12109 |
} |
|
12110 |
}, |
|
12111 |
paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) { |
|
12112 |
var ctx = this.ctx; |
|
12113 |
var fillColor = this.current.fillColor; |
|
12114 |
var isPatternFill = this.current.patternFill; |
|
12115 |
for (var i = 0, ii = images.length; i < ii; i++) { |
|
12116 |
var image = images[i]; |
|
12117 |
var width = image.width, |
|
12118 |
height = image.height; |
|
12119 |
var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height); |
|
12120 |
var maskCtx = maskCanvas.context; |
|
12121 |
maskCtx.save(); |
|
12122 |
putBinaryImageMask(maskCtx, image); |
|
12123 |
maskCtx.globalCompositeOperation = 'source-in'; |
|
12124 |
maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor; |
|
12125 |
maskCtx.fillRect(0, 0, width, height); |
|
12126 |
maskCtx.restore(); |
|
12127 |
ctx.save(); |
|
12128 |
ctx.transform.apply(ctx, image.transform); |
|
12129 |
ctx.scale(1, -1); |
|
12130 |
ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1); |
|
12131 |
ctx.restore(); |
|
12132 |
} |
|
12133 |
}, |
|
12134 |
paintImageXObject: function CanvasGraphics_paintImageXObject(objId) { |
|
12135 |
var imgData = this.objs.get(objId); |
|
12136 |
if (!imgData) { |
|
12137 |
(0, _util.warn)('Dependent image isn\'t ready yet'); |
|
12138 |
return; |
|
12139 |
} |
|
12140 |
this.paintInlineImageXObject(imgData); |
|
12141 |
}, |
|
12142 |
paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) { |
|
12143 |
var imgData = this.objs.get(objId); |
|
12144 |
if (!imgData) { |
|
12145 |
(0, _util.warn)('Dependent image isn\'t ready yet'); |
|
12146 |
return; |
|
12147 |
} |
|
12148 |
var width = imgData.width; |
|
12149 |
var height = imgData.height; |
|
12150 |
var map = []; |
|
12151 |
for (var i = 0, ii = positions.length; i < ii; i += 2) { |
|
12152 |
map.push({ |
|
12153 |
transform: [scaleX, 0, 0, scaleY, positions[i], positions[i + 1]], |
|
12154 |
x: 0, |
|
12155 |
y: 0, |
|
12156 |
w: width, |
|
12157 |
h: height |
|
12158 |
}); |
|
12159 |
} |
|
12160 |
this.paintInlineImageXObjectGroup(imgData, map); |
|
12161 |
}, |
|
12162 |
paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) { |
|
12163 |
var width = imgData.width; |
|
12164 |
var height = imgData.height; |
|
12165 |
var ctx = this.ctx; |
|
12166 |
this.save(); |
|
12167 |
ctx.scale(1 / width, -1 / height); |
|
12168 |
var currentTransform = ctx.mozCurrentTransformInverse; |
|
12169 |
var a = currentTransform[0], |
|
12170 |
b = currentTransform[1]; |
|
12171 |
var widthScale = Math.max(Math.sqrt(a * a + b * b), 1); |
|
12172 |
var c = currentTransform[2], |
|
12173 |
d = currentTransform[3]; |
|
12174 |
var heightScale = Math.max(Math.sqrt(c * c + d * d), 1); |
|
12175 |
var imgToPaint, tmpCanvas; |
|
12176 |
if (typeof HTMLElement === 'function' && imgData instanceof HTMLElement || !imgData.data) { |
|
12177 |
imgToPaint = imgData; |
|
12178 |
} else { |
|
12179 |
tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height); |
|
12180 |
var tmpCtx = tmpCanvas.context; |
|
12181 |
putBinaryImageData(tmpCtx, imgData); |
|
12182 |
imgToPaint = tmpCanvas.canvas; |
|
12183 |
} |
|
12184 |
var paintWidth = width, |
|
12185 |
paintHeight = height; |
|
12186 |
var tmpCanvasId = 'prescale1'; |
|
12187 |
while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) { |
|
12188 |
var newWidth = paintWidth, |
|
12189 |
newHeight = paintHeight; |
|
12190 |
if (widthScale > 2 && paintWidth > 1) { |
|
12191 |
newWidth = Math.ceil(paintWidth / 2); |
|
12192 |
widthScale /= paintWidth / newWidth; |
|
12193 |
} |
|
12194 |
if (heightScale > 2 && paintHeight > 1) { |
|
12195 |
newHeight = Math.ceil(paintHeight / 2); |
|
12196 |
heightScale /= paintHeight / newHeight; |
|
12197 |
} |
|
12198 |
tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight); |
|
12199 |
tmpCtx = tmpCanvas.context; |
|
12200 |
tmpCtx.clearRect(0, 0, newWidth, newHeight); |
|
12201 |
tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight); |
|
12202 |
imgToPaint = tmpCanvas.canvas; |
|
12203 |
paintWidth = newWidth; |
|
12204 |
paintHeight = newHeight; |
|
12205 |
tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1'; |
|
12206 |
} |
|
12207 |
ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height); |
|
12208 |
if (this.imageLayer) { |
|
12209 |
var position = this.getCanvasPosition(0, -height); |
|
12210 |
this.imageLayer.appendImage({ |
|
12211 |
imgData: imgData, |
|
12212 |
left: position[0], |
|
12213 |
top: position[1], |
|
12214 |
width: width / currentTransform[0], |
|
12215 |
height: height / currentTransform[3] |
|
12216 |
}); |
|
12217 |
} |
|
12218 |
this.restore(); |
|
12219 |
}, |
|
12220 |
paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) { |
|
12221 |
var ctx = this.ctx; |
|
12222 |
var w = imgData.width; |
|
12223 |
var h = imgData.height; |
|
12224 |
var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h); |
|
12225 |
var tmpCtx = tmpCanvas.context; |
|
12226 |
putBinaryImageData(tmpCtx, imgData); |
|
12227 |
for (var i = 0, ii = map.length; i < ii; i++) { |
|
12228 |
var entry = map[i]; |
|
12229 |
ctx.save(); |
|
12230 |
ctx.transform.apply(ctx, entry.transform); |
|
12231 |
ctx.scale(1, -1); |
|
12232 |
ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1); |
|
12233 |
if (this.imageLayer) { |
|
12234 |
var position = this.getCanvasPosition(entry.x, entry.y); |
|
12235 |
this.imageLayer.appendImage({ |
|
12236 |
imgData: imgData, |
|
12237 |
left: position[0], |
|
12238 |
top: position[1], |
|
12239 |
width: w, |
|
12240 |
height: h |
|
12241 |
}); |
|
12242 |
} |
|
12243 |
ctx.restore(); |
|
12244 |
} |
|
12245 |
}, |
|
12246 |
paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() { |
|
12247 |
this.ctx.fillRect(0, 0, 1, 1); |
|
12248 |
}, |
|
12249 |
paintXObject: function CanvasGraphics_paintXObject() { |
|
12250 |
(0, _util.warn)('Unsupported \'paintXObject\' command.'); |
|
12251 |
}, |
|
12252 |
markPoint: function CanvasGraphics_markPoint(tag) {}, |
|
12253 |
markPointProps: function CanvasGraphics_markPointProps(tag, properties) {}, |
|
12254 |
beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {}, |
|
12255 |
beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {}, |
|
12256 |
endMarkedContent: function CanvasGraphics_endMarkedContent() {}, |
|
12257 |
beginCompat: function CanvasGraphics_beginCompat() {}, |
|
12258 |
endCompat: function CanvasGraphics_endCompat() {}, |
|
12259 |
consumePath: function CanvasGraphics_consumePath() { |
|
12260 |
var ctx = this.ctx; |
|
12261 |
if (this.pendingClip) { |
|
12262 |
if (this.pendingClip === EO_CLIP) { |
|
12263 |
ctx.clip('evenodd'); |
|
12264 |
} else { |
|
12265 |
ctx.clip(); |
|
12266 |
} |
|
12267 |
this.pendingClip = null; |
|
12268 |
} |
|
12269 |
ctx.beginPath(); |
|
12270 |
}, |
|
12271 |
getSinglePixelWidth: function getSinglePixelWidth(scale) { |
|
12272 |
if (this._cachedGetSinglePixelWidth === null) { |
|
12273 |
var inverse = this.ctx.mozCurrentTransformInverse; |
|
12274 |
this._cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3])); |
|
12275 |
} |
|
12276 |
return this._cachedGetSinglePixelWidth; |
|
12277 |
}, |
|
12278 |
|
|
12279 |
getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) { |
|
12280 |
var transform = this.ctx.mozCurrentTransform; |
|
12281 |
return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]]; |
|
12282 |
} |
|
12283 |
}; |
|
12284 |
for (var op in _util.OPS) { |
|
12285 |
CanvasGraphics.prototype[_util.OPS[op]] = CanvasGraphics.prototype[op]; |
|
12286 |
} |
|
12287 |
return CanvasGraphics; |
|
12288 |
}(); |
|
12289 |
exports.CanvasGraphics = CanvasGraphics; |
|
12290 |
|
|
12291 |
/***/ }), |
|
12292 |
/* 134 */ |
|
12293 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
12294 |
|
|
12295 |
"use strict"; |
|
12296 |
|
|
12297 |
|
|
12298 |
Object.defineProperty(exports, "__esModule", { |
|
12299 |
value: true |
|
12300 |
}); |
|
12301 |
exports.TilingPattern = exports.getShadingPatternFromIR = undefined; |
|
12302 |
|
|
12303 |
var _util = __w_pdfjs_require__(1); |
|
12304 |
|
|
12305 |
var ShadingIRs = {}; |
|
12306 |
ShadingIRs.RadialAxial = { |
|
12307 |
fromIR: function RadialAxial_fromIR(raw) { |
|
12308 |
var type = raw[1]; |
|
12309 |
var colorStops = raw[2]; |
|
12310 |
var p0 = raw[3]; |
|
12311 |
var p1 = raw[4]; |
|
12312 |
var r0 = raw[5]; |
|
12313 |
var r1 = raw[6]; |
|
12314 |
return { |
|
12315 |
type: 'Pattern', |
|
12316 |
getPattern: function RadialAxial_getPattern(ctx) { |
|
12317 |
var grad; |
|
12318 |
if (type === 'axial') { |
|
12319 |
grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]); |
|
12320 |
} else if (type === 'radial') { |
|
12321 |
grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1); |
|
12322 |
} |
|
12323 |
for (var i = 0, ii = colorStops.length; i < ii; ++i) { |
|
12324 |
var c = colorStops[i]; |
|
12325 |
grad.addColorStop(c[0], c[1]); |
|
12326 |
} |
|
12327 |
return grad; |
|
12328 |
} |
|
12329 |
}; |
|
12330 |
} |
|
12331 |
}; |
|
12332 |
var createMeshCanvas = function createMeshCanvasClosure() { |
|
12333 |
function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) { |
|
12334 |
var coords = context.coords, |
|
12335 |
colors = context.colors; |
|
12336 |
var bytes = data.data, |
|
12337 |
rowSize = data.width * 4; |
|
12338 |
var tmp; |
|
12339 |
if (coords[p1 + 1] > coords[p2 + 1]) { |
|
12340 |
tmp = p1; |
|
12341 |
p1 = p2; |
|
12342 |
p2 = tmp; |
|
12343 |
tmp = c1; |
|
12344 |
c1 = c2; |
|
12345 |
c2 = tmp; |
|
12346 |
} |
|
12347 |
if (coords[p2 + 1] > coords[p3 + 1]) { |
|
12348 |
tmp = p2; |
|
12349 |
p2 = p3; |
|
12350 |
p3 = tmp; |
|
12351 |
tmp = c2; |
|
12352 |
c2 = c3; |
|
12353 |
c3 = tmp; |
|
12354 |
} |
|
12355 |
if (coords[p1 + 1] > coords[p2 + 1]) { |
|
12356 |
tmp = p1; |
|
12357 |
p1 = p2; |
|
12358 |
p2 = tmp; |
|
12359 |
tmp = c1; |
|
12360 |
c1 = c2; |
|
12361 |
c2 = tmp; |
|
12362 |
} |
|
12363 |
var x1 = (coords[p1] + context.offsetX) * context.scaleX; |
|
12364 |
var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY; |
|
12365 |
var x2 = (coords[p2] + context.offsetX) * context.scaleX; |
|
12366 |
var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY; |
|
12367 |
var x3 = (coords[p3] + context.offsetX) * context.scaleX; |
|
12368 |
var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY; |
|
12369 |
if (y1 >= y3) { |
|
12370 |
return; |
|
12371 |
} |
|
12372 |
var c1r = colors[c1], |
|
12373 |
c1g = colors[c1 + 1], |
|
12374 |
c1b = colors[c1 + 2]; |
|
12375 |
var c2r = colors[c2], |
|
12376 |
c2g = colors[c2 + 1], |
|
12377 |
c2b = colors[c2 + 2]; |
|
12378 |
var c3r = colors[c3], |
|
12379 |
c3g = colors[c3 + 1], |
|
12380 |
c3b = colors[c3 + 2]; |
|
12381 |
var minY = Math.round(y1), |
|
12382 |
maxY = Math.round(y3); |
|
12383 |
var xa, car, cag, cab; |
|
12384 |
var xb, cbr, cbg, cbb; |
|
12385 |
var k; |
|
12386 |
for (var y = minY; y <= maxY; y++) { |
|
12387 |
if (y < y2) { |
|
12388 |
k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2); |
|
12389 |
xa = x1 - (x1 - x2) * k; |
|
12390 |
car = c1r - (c1r - c2r) * k; |
|
12391 |
cag = c1g - (c1g - c2g) * k; |
|
12392 |
cab = c1b - (c1b - c2b) * k; |
|
12393 |
} else { |
|
12394 |
k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3); |
|
12395 |
xa = x2 - (x2 - x3) * k; |
|
12396 |
car = c2r - (c2r - c3r) * k; |
|
12397 |
cag = c2g - (c2g - c3g) * k; |
|
12398 |
cab = c2b - (c2b - c3b) * k; |
|
12399 |
} |
|
12400 |
k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3); |
|
12401 |
xb = x1 - (x1 - x3) * k; |
|
12402 |
cbr = c1r - (c1r - c3r) * k; |
|
12403 |
cbg = c1g - (c1g - c3g) * k; |
|
12404 |
cbb = c1b - (c1b - c3b) * k; |
|
12405 |
var x1_ = Math.round(Math.min(xa, xb)); |
|
12406 |
var x2_ = Math.round(Math.max(xa, xb)); |
|
12407 |
var j = rowSize * y + x1_ * 4; |
|
12408 |
for (var x = x1_; x <= x2_; x++) { |
|
12409 |
k = (xa - x) / (xa - xb); |
|
12410 |
k = k < 0 ? 0 : k > 1 ? 1 : k; |
|
12411 |
bytes[j++] = car - (car - cbr) * k | 0; |
|
12412 |
bytes[j++] = cag - (cag - cbg) * k | 0; |
|
12413 |
bytes[j++] = cab - (cab - cbb) * k | 0; |
|
12414 |
bytes[j++] = 255; |
|
12415 |
} |
|
12416 |
} |
|
12417 |
} |
|
12418 |
function drawFigure(data, figure, context) { |
|
12419 |
var ps = figure.coords; |
|
12420 |
var cs = figure.colors; |
|
12421 |
var i, ii; |
|
12422 |
switch (figure.type) { |
|
12423 |
case 'lattice': |
|
12424 |
var verticesPerRow = figure.verticesPerRow; |
|
12425 |
var rows = Math.floor(ps.length / verticesPerRow) - 1; |
|
12426 |
var cols = verticesPerRow - 1; |
|
12427 |
for (i = 0; i < rows; i++) { |
|
12428 |
var q = i * verticesPerRow; |
|
12429 |
for (var j = 0; j < cols; j++, q++) { |
|
12430 |
drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]); |
|
12431 |
drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]); |
|
12432 |
} |
|
12433 |
} |
|
12434 |
break; |
|
12435 |
case 'triangles': |
|
12436 |
for (i = 0, ii = ps.length; i < ii; i += 3) { |
|
12437 |
drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]); |
|
12438 |
} |
|
12439 |
break; |
|
12440 |
default: |
|
12441 |
throw new Error('illegal figure'); |
|
12442 |
} |
|
12443 |
} |
|
12444 |
function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases, webGLContext) { |
|
12445 |
var EXPECTED_SCALE = 1.1; |
|
12446 |
var MAX_PATTERN_SIZE = 3000; |
|
12447 |
var BORDER_SIZE = 2; |
|
12448 |
var offsetX = Math.floor(bounds[0]); |
|
12449 |
var offsetY = Math.floor(bounds[1]); |
|
12450 |
var boundsWidth = Math.ceil(bounds[2]) - offsetX; |
|
12451 |
var boundsHeight = Math.ceil(bounds[3]) - offsetY; |
|
12452 |
var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE); |
|
12453 |
var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE); |
|
12454 |
var scaleX = boundsWidth / width; |
|
12455 |
var scaleY = boundsHeight / height; |
|
12456 |
var context = { |
|
12457 |
coords: coords, |
|
12458 |
colors: colors, |
|
12459 |
offsetX: -offsetX, |
|
12460 |
offsetY: -offsetY, |
|
12461 |
scaleX: 1 / scaleX, |
|
12462 |
scaleY: 1 / scaleY |
|
12463 |
}; |
|
12464 |
var paddedWidth = width + BORDER_SIZE * 2; |
|
12465 |
var paddedHeight = height + BORDER_SIZE * 2; |
|
12466 |
var canvas, tmpCanvas, i, ii; |
|
12467 |
if (webGLContext.isEnabled) { |
|
12468 |
canvas = webGLContext.drawFigures({ |
|
12469 |
width: width, |
|
12470 |
height: height, |
|
12471 |
backgroundColor: backgroundColor, |
|
12472 |
figures: figures, |
|
12473 |
context: context |
|
12474 |
}); |
|
12475 |
tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false); |
|
12476 |
tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE); |
|
12477 |
canvas = tmpCanvas.canvas; |
|
12478 |
} else { |
|
12479 |
tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false); |
|
12480 |
var tmpCtx = tmpCanvas.context; |
|
12481 |
var data = tmpCtx.createImageData(width, height); |
|
12482 |
if (backgroundColor) { |
|
12483 |
var bytes = data.data; |
|
12484 |
for (i = 0, ii = bytes.length; i < ii; i += 4) { |
|
12485 |
bytes[i] = backgroundColor[0]; |
|
12486 |
bytes[i + 1] = backgroundColor[1]; |
|
12487 |
bytes[i + 2] = backgroundColor[2]; |
|
12488 |
bytes[i + 3] = 255; |
|
12489 |
} |
|
12490 |
} |
|
12491 |
for (i = 0; i < figures.length; i++) { |
|
12492 |
drawFigure(data, figures[i], context); |
|
12493 |
} |
|
12494 |
tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE); |
|
12495 |
canvas = tmpCanvas.canvas; |
|
12496 |
} |
|
12497 |
return { |
|
12498 |
canvas: canvas, |
|
12499 |
offsetX: offsetX - BORDER_SIZE * scaleX, |
|
12500 |
offsetY: offsetY - BORDER_SIZE * scaleY, |
|
12501 |
scaleX: scaleX, |
|
12502 |
scaleY: scaleY |
|
12503 |
}; |
|
12504 |
} |
|
12505 |
return createMeshCanvas; |
|
12506 |
}(); |
|
12507 |
ShadingIRs.Mesh = { |
|
12508 |
fromIR: function Mesh_fromIR(raw) { |
|
12509 |
var coords = raw[2]; |
|
12510 |
var colors = raw[3]; |
|
12511 |
var figures = raw[4]; |
|
12512 |
var bounds = raw[5]; |
|
12513 |
var matrix = raw[6]; |
|
12514 |
var background = raw[8]; |
|
12515 |
return { |
|
12516 |
type: 'Pattern', |
|
12517 |
getPattern: function Mesh_getPattern(ctx, owner, shadingFill) { |
|
12518 |
var scale; |
|
12519 |
if (shadingFill) { |
|
12520 |
scale = _util.Util.singularValueDecompose2dScale(ctx.mozCurrentTransform); |
|
12521 |
} else { |
|
12522 |
scale = _util.Util.singularValueDecompose2dScale(owner.baseTransform); |
|
12523 |
if (matrix) { |
|
12524 |
var matrixScale = _util.Util.singularValueDecompose2dScale(matrix); |
|
12525 |
scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]]; |
|
12526 |
} |
|
12527 |
} |
|
12528 |
var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases, owner.webGLContext); |
|
12529 |
if (!shadingFill) { |
|
12530 |
ctx.setTransform.apply(ctx, owner.baseTransform); |
|
12531 |
if (matrix) { |
|
12532 |
ctx.transform.apply(ctx, matrix); |
|
12533 |
} |
|
12534 |
} |
|
12535 |
ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY); |
|
12536 |
ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY); |
|
12537 |
return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat'); |
|
12538 |
} |
|
12539 |
}; |
|
12540 |
} |
|
12541 |
}; |
|
12542 |
ShadingIRs.Dummy = { |
|
12543 |
fromIR: function Dummy_fromIR() { |
|
12544 |
return { |
|
12545 |
type: 'Pattern', |
|
12546 |
getPattern: function Dummy_fromIR_getPattern() { |
|
12547 |
return 'hotpink'; |
|
12548 |
} |
|
12549 |
}; |
|
12550 |
} |
|
12551 |
}; |
|
12552 |
function getShadingPatternFromIR(raw) { |
|
12553 |
var shadingIR = ShadingIRs[raw[0]]; |
|
12554 |
if (!shadingIR) { |
|
12555 |
throw new Error('Unknown IR type: ' + raw[0]); |
|
12556 |
} |
|
12557 |
return shadingIR.fromIR(raw); |
|
12558 |
} |
|
12559 |
var TilingPattern = function TilingPatternClosure() { |
|
12560 |
var PaintType = { |
|
12561 |
COLORED: 1, |
|
12562 |
UNCOLORED: 2 |
|
12563 |
}; |
|
12564 |
var MAX_PATTERN_SIZE = 3000; |
|
12565 |
function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) { |
|
12566 |
this.operatorList = IR[2]; |
|
12567 |
this.matrix = IR[3] || [1, 0, 0, 1, 0, 0]; |
|
12568 |
this.bbox = IR[4]; |
|
12569 |
this.xstep = IR[5]; |
|
12570 |
this.ystep = IR[6]; |
|
12571 |
this.paintType = IR[7]; |
|
12572 |
this.tilingType = IR[8]; |
|
12573 |
this.color = color; |
|
12574 |
this.canvasGraphicsFactory = canvasGraphicsFactory; |
|
12575 |
this.baseTransform = baseTransform; |
|
12576 |
this.type = 'Pattern'; |
|
12577 |
this.ctx = ctx; |
|
12578 |
} |
|
12579 |
TilingPattern.prototype = { |
|
12580 |
createPatternCanvas: function TilinPattern_createPatternCanvas(owner) { |
|
12581 |
var operatorList = this.operatorList; |
|
12582 |
var bbox = this.bbox; |
|
12583 |
var xstep = this.xstep; |
|
12584 |
var ystep = this.ystep; |
|
12585 |
var paintType = this.paintType; |
|
12586 |
var tilingType = this.tilingType; |
|
12587 |
var color = this.color; |
|
12588 |
var canvasGraphicsFactory = this.canvasGraphicsFactory; |
|
12589 |
(0, _util.info)('TilingType: ' + tilingType); |
|
12590 |
var x0 = bbox[0], |
|
12591 |
y0 = bbox[1], |
|
12592 |
x1 = bbox[2], |
|
12593 |
y1 = bbox[3]; |
|
12594 |
var topLeft = [x0, y0]; |
|
12595 |
var botRight = [x0 + xstep, y0 + ystep]; |
|
12596 |
var width = botRight[0] - topLeft[0]; |
|
12597 |
var height = botRight[1] - topLeft[1]; |
|
12598 |
var matrixScale = _util.Util.singularValueDecompose2dScale(this.matrix); |
|
12599 |
var curMatrixScale = _util.Util.singularValueDecompose2dScale(this.baseTransform); |
|
12600 |
var combinedScale = [matrixScale[0] * curMatrixScale[0], matrixScale[1] * curMatrixScale[1]]; |
|
12601 |
width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE); |
|
12602 |
height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE); |
|
12603 |
var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true); |
|
12604 |
var tmpCtx = tmpCanvas.context; |
|
12605 |
var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx); |
|
12606 |
graphics.groupLevel = owner.groupLevel; |
|
12607 |
this.setFillAndStrokeStyleToContext(graphics, paintType, color); |
|
12608 |
this.setScale(width, height, xstep, ystep); |
|
12609 |
this.transformToScale(graphics); |
|
12610 |
var tmpTranslate = [1, 0, 0, 1, -topLeft[0], -topLeft[1]]; |
|
12611 |
graphics.transform.apply(graphics, tmpTranslate); |
|
12612 |
this.clipBbox(graphics, bbox, x0, y0, x1, y1); |
|
12613 |
graphics.executeOperatorList(operatorList); |
|
12614 |
return tmpCanvas.canvas; |
|
12615 |
}, |
|
12616 |
setScale: function TilingPattern_setScale(width, height, xstep, ystep) { |
|
12617 |
this.scale = [width / xstep, height / ystep]; |
|
12618 |
}, |
|
12619 |
transformToScale: function TilingPattern_transformToScale(graphics) { |
|
12620 |
var scale = this.scale; |
|
12621 |
var tmpScale = [scale[0], 0, 0, scale[1], 0, 0]; |
|
12622 |
graphics.transform.apply(graphics, tmpScale); |
|
12623 |
}, |
|
12624 |
scaleToContext: function TilingPattern_scaleToContext() { |
|
12625 |
var scale = this.scale; |
|
12626 |
this.ctx.scale(1 / scale[0], 1 / scale[1]); |
|
12627 |
}, |
|
12628 |
clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) { |
|
12629 |
if (Array.isArray(bbox) && bbox.length === 4) { |
|
12630 |
var bboxWidth = x1 - x0; |
|
12631 |
var bboxHeight = y1 - y0; |
|
12632 |
graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight); |
|
12633 |
graphics.clip(); |
|
12634 |
graphics.endPath(); |
|
12635 |
} |
|
12636 |
}, |
|
12637 |
setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(graphics, paintType, color) { |
|
12638 |
var context = graphics.ctx, |
|
12639 |
current = graphics.current; |
|
12640 |
switch (paintType) { |
|
12641 |
case PaintType.COLORED: |
|
12642 |
var ctx = this.ctx; |
|
12643 |
context.fillStyle = ctx.fillStyle; |
|
12644 |
context.strokeStyle = ctx.strokeStyle; |
|
12645 |
current.fillColor = ctx.fillStyle; |
|
12646 |
current.strokeColor = ctx.strokeStyle; |
|
12647 |
break; |
|
12648 |
case PaintType.UNCOLORED: |
|
12649 |
var cssColor = _util.Util.makeCssRgb(color[0], color[1], color[2]); |
|
12650 |
context.fillStyle = cssColor; |
|
12651 |
context.strokeStyle = cssColor; |
|
12652 |
current.fillColor = cssColor; |
|
12653 |
current.strokeColor = cssColor; |
|
12654 |
break; |
|
12655 |
default: |
|
12656 |
throw new _util.FormatError('Unsupported paint type: ' + paintType); |
|
12657 |
} |
|
12658 |
}, |
|
12659 |
getPattern: function TilingPattern_getPattern(ctx, owner) { |
|
12660 |
var temporaryPatternCanvas = this.createPatternCanvas(owner); |
|
12661 |
ctx = this.ctx; |
|
12662 |
ctx.setTransform.apply(ctx, this.baseTransform); |
|
12663 |
ctx.transform.apply(ctx, this.matrix); |
|
12664 |
this.scaleToContext(); |
|
12665 |
return ctx.createPattern(temporaryPatternCanvas, 'repeat'); |
|
12666 |
} |
|
12667 |
}; |
|
12668 |
return TilingPattern; |
|
12669 |
}(); |
|
12670 |
exports.getShadingPatternFromIR = getShadingPatternFromIR; |
|
12671 |
exports.TilingPattern = TilingPattern; |
|
12672 |
|
|
12673 |
/***/ }), |
|
12674 |
/* 135 */ |
|
12675 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
12676 |
|
|
12677 |
"use strict"; |
|
12678 |
|
|
12679 |
|
|
12680 |
Object.defineProperty(exports, "__esModule", { |
|
12681 |
value: true |
|
12682 |
}); |
|
12683 |
var GlobalWorkerOptions = Object.create(null); |
|
12684 |
GlobalWorkerOptions.workerPort = GlobalWorkerOptions.workerPort === undefined ? null : GlobalWorkerOptions.workerPort; |
|
12685 |
GlobalWorkerOptions.workerSrc = GlobalWorkerOptions.workerSrc === undefined ? '' : GlobalWorkerOptions.workerSrc; |
|
12686 |
exports.GlobalWorkerOptions = GlobalWorkerOptions; |
|
12687 |
|
|
12688 |
/***/ }), |
|
12689 |
/* 136 */ |
|
12690 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
12691 |
|
|
12692 |
"use strict"; |
|
12693 |
|
|
12694 |
|
|
12695 |
Object.defineProperty(exports, "__esModule", { |
|
12696 |
value: true |
|
12697 |
}); |
|
12698 |
exports.MessageHandler = undefined; |
|
12699 |
|
|
12700 |
var _regenerator = __w_pdfjs_require__(137); |
|
12701 |
|
|
12702 |
var _regenerator2 = _interopRequireDefault(_regenerator); |
|
12703 |
|
|
12704 |
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; }; |
|
12705 |
|
|
12706 |
var resolveCall = function () { |
|
12707 |
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee(fn, args) { |
|
12708 |
var thisArg = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; |
|
12709 |
return _regenerator2.default.wrap(function _callee$(_context) { |
|
12710 |
while (1) { |
|
12711 |
switch (_context.prev = _context.next) { |
|
12712 |
case 0: |
|
12713 |
if (fn) { |
|
12714 |
_context.next = 2; |
|
12715 |
break; |
|
12716 |
} |
|
12717 |
|
|
12718 |
return _context.abrupt('return'); |
|
12719 |
|
|
12720 |
case 2: |
|
12721 |
return _context.abrupt('return', fn.apply(thisArg, args)); |
|
12722 |
|
|
12723 |
case 3: |
|
12724 |
case 'end': |
|
12725 |
return _context.stop(); |
|
12726 |
} |
|
12727 |
} |
|
12728 |
}, _callee, this); |
|
12729 |
})); |
|
12730 |
|
|
12731 |
return function resolveCall(_x2, _x3) { |
|
12732 |
return _ref.apply(this, arguments); |
|
12733 |
}; |
|
12734 |
}(); |
|
12735 |
|
|
12736 |
var _util = __w_pdfjs_require__(1); |
|
12737 |
|
|
12738 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
12739 |
|
|
12740 |
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"); }); }; } |
|
12741 |
|
|
12742 |
function wrapReason(reason) { |
|
12743 |
if ((typeof reason === 'undefined' ? 'undefined' : _typeof(reason)) !== 'object') { |
|
12744 |
return reason; |
|
12745 |
} |
|
12746 |
switch (reason.name) { |
|
12747 |
case 'AbortException': |
|
12748 |
return new _util.AbortException(reason.message); |
|
12749 |
case 'MissingPDFException': |
|
12750 |
return new _util.MissingPDFException(reason.message); |
|
12751 |
case 'UnexpectedResponseException': |
|
12752 |
return new _util.UnexpectedResponseException(reason.message, reason.status); |
|
12753 |
default: |
|
12754 |
return new _util.UnknownErrorException(reason.message, reason.details); |
|
12755 |
} |
|
12756 |
} |
|
12757 |
function makeReasonSerializable(reason) { |
|
12758 |
if (!(reason instanceof Error) || reason instanceof _util.AbortException || reason instanceof _util.MissingPDFException || reason instanceof _util.UnexpectedResponseException || reason instanceof _util.UnknownErrorException) { |
|
12759 |
return reason; |
|
12760 |
} |
|
12761 |
return new _util.UnknownErrorException(reason.message, reason.toString()); |
|
12762 |
} |
|
12763 |
function resolveOrReject(capability, success, reason) { |
|
12764 |
if (success) { |
|
12765 |
capability.resolve(); |
|
12766 |
} else { |
|
12767 |
capability.reject(reason); |
|
12768 |
} |
|
12769 |
} |
|
12770 |
function finalize(promise) { |
|
12771 |
return Promise.resolve(promise).catch(function () {}); |
|
12772 |
} |
|
12773 |
function MessageHandler(sourceName, targetName, comObj) { |
|
12774 |
var _this = this; |
|
12775 |
|
|
12776 |
this.sourceName = sourceName; |
|
12777 |
this.targetName = targetName; |
|
12778 |
this.comObj = comObj; |
|
12779 |
this.callbackId = 1; |
|
12780 |
this.streamId = 1; |
|
12781 |
this.postMessageTransfers = true; |
|
12782 |
this.streamSinks = Object.create(null); |
|
12783 |
this.streamControllers = Object.create(null); |
|
12784 |
var callbacksCapabilities = this.callbacksCapabilities = Object.create(null); |
|
12785 |
var ah = this.actionHandler = Object.create(null); |
|
12786 |
this._onComObjOnMessage = function (event) { |
|
12787 |
var data = event.data; |
|
12788 |
if (data.targetName !== _this.sourceName) { |
|
12789 |
return; |
|
12790 |
} |
|
12791 |
if (data.stream) { |
|
12792 |
_this._processStreamMessage(data); |
|
12793 |
} else if (data.isReply) { |
|
12794 |
var callbackId = data.callbackId; |
|
12795 |
if (data.callbackId in callbacksCapabilities) { |
|
12796 |
var callback = callbacksCapabilities[callbackId]; |
|
12797 |
delete callbacksCapabilities[callbackId]; |
|
12798 |
if ('error' in data) { |
|
12799 |
callback.reject(wrapReason(data.error)); |
|
12800 |
} else { |
|
12801 |
callback.resolve(data.data); |
|
12802 |
} |
|
12803 |
} else { |
|
12804 |
throw new Error('Cannot resolve callback ' + callbackId); |
|
12805 |
} |
|
12806 |
} else if (data.action in ah) { |
|
12807 |
var action = ah[data.action]; |
|
12808 |
if (data.callbackId) { |
|
12809 |
var _sourceName = _this.sourceName; |
|
12810 |
var _targetName = data.sourceName; |
|
12811 |
Promise.resolve().then(function () { |
|
12812 |
return action[0].call(action[1], data.data); |
|
12813 |
}).then(function (result) { |
|
12814 |
comObj.postMessage({ |
|
12815 |
sourceName: _sourceName, |
|
12816 |
targetName: _targetName, |
|
12817 |
isReply: true, |
|
12818 |
callbackId: data.callbackId, |
|
12819 |
data: result |
|
12820 |
}); |
|
12821 |
}, function (reason) { |
|
12822 |
comObj.postMessage({ |
|
12823 |
sourceName: _sourceName, |
|
12824 |
targetName: _targetName, |
|
12825 |
isReply: true, |
|
12826 |
callbackId: data.callbackId, |
|
12827 |
error: makeReasonSerializable(reason) |
|
12828 |
}); |
|
12829 |
}); |
|
12830 |
} else if (data.streamId) { |
|
12831 |
_this._createStreamSink(data); |
|
12832 |
} else { |
|
12833 |
action[0].call(action[1], data.data); |
|
12834 |
} |
|
12835 |
} else { |
|
12836 |
throw new Error('Unknown action from worker: ' + data.action); |
|
12837 |
} |
|
12838 |
}; |
|
12839 |
comObj.addEventListener('message', this._onComObjOnMessage); |
|
12840 |
} |
|
12841 |
MessageHandler.prototype = { |
|
12842 |
on: function on(actionName, handler, scope) { |
|
12843 |
var ah = this.actionHandler; |
|
12844 |
if (ah[actionName]) { |
|
12845 |
throw new Error('There is already an actionName called "' + actionName + '"'); |
|
12846 |
} |
|
12847 |
ah[actionName] = [handler, scope]; |
|
12848 |
}, |
|
12849 |
send: function send(actionName, data, transfers) { |
|
12850 |
var message = { |
|
12851 |
sourceName: this.sourceName, |
|
12852 |
targetName: this.targetName, |
|
12853 |
action: actionName, |
|
12854 |
data: data |
|
12855 |
}; |
|
12856 |
this.postMessage(message, transfers); |
|
12857 |
}, |
|
12858 |
sendWithPromise: function sendWithPromise(actionName, data, transfers) { |
|
12859 |
var callbackId = this.callbackId++; |
|
12860 |
var message = { |
|
12861 |
sourceName: this.sourceName, |
|
12862 |
targetName: this.targetName, |
|
12863 |
action: actionName, |
|
12864 |
data: data, |
|
12865 |
callbackId: callbackId |
|
12866 |
}; |
|
12867 |
var capability = (0, _util.createPromiseCapability)(); |
|
12868 |
this.callbacksCapabilities[callbackId] = capability; |
|
12869 |
try { |
|
12870 |
this.postMessage(message, transfers); |
|
12871 |
} catch (e) { |
|
12872 |
capability.reject(e); |
|
12873 |
} |
|
12874 |
return capability.promise; |
|
12875 |
}, |
|
12876 |
sendWithStream: function sendWithStream(actionName, data, queueingStrategy, transfers) { |
|
12877 |
var _this2 = this; |
|
12878 |
|
|
12879 |
var streamId = this.streamId++; |
|
12880 |
var sourceName = this.sourceName; |
|
12881 |
var targetName = this.targetName; |
|
12882 |
return new _util.ReadableStream({ |
|
12883 |
start: function start(controller) { |
|
12884 |
var startCapability = (0, _util.createPromiseCapability)(); |
|
12885 |
_this2.streamControllers[streamId] = { |
|
12886 |
controller: controller, |
|
12887 |
startCall: startCapability, |
|
12888 |
isClosed: false |
|
12889 |
}; |
|
12890 |
_this2.postMessage({ |
|
12891 |
sourceName: sourceName, |
|
12892 |
targetName: targetName, |
|
12893 |
action: actionName, |
|
12894 |
streamId: streamId, |
|
12895 |
data: data, |
|
12896 |
desiredSize: controller.desiredSize |
|
12897 |
}); |
|
12898 |
return startCapability.promise; |
|
12899 |
}, |
|
12900 |
pull: function pull(controller) { |
|
12901 |
var pullCapability = (0, _util.createPromiseCapability)(); |
|
12902 |
_this2.streamControllers[streamId].pullCall = pullCapability; |
|
12903 |
_this2.postMessage({ |
|
12904 |
sourceName: sourceName, |
|
12905 |
targetName: targetName, |
|
12906 |
stream: 'pull', |
|
12907 |
streamId: streamId, |
|
12908 |
desiredSize: controller.desiredSize |
|
12909 |
}); |
|
12910 |
return pullCapability.promise; |
|
12911 |
}, |
|
12912 |
cancel: function cancel(reason) { |
|
12913 |
var cancelCapability = (0, _util.createPromiseCapability)(); |
|
12914 |
_this2.streamControllers[streamId].cancelCall = cancelCapability; |
|
12915 |
_this2.streamControllers[streamId].isClosed = true; |
|
12916 |
_this2.postMessage({ |
|
12917 |
sourceName: sourceName, |
|
12918 |
targetName: targetName, |
|
12919 |
stream: 'cancel', |
|
12920 |
reason: reason, |
|
12921 |
streamId: streamId |
|
12922 |
}); |
|
12923 |
return cancelCapability.promise; |
|
12924 |
} |
|
12925 |
}, queueingStrategy); |
|
12926 |
}, |
|
12927 |
_createStreamSink: function _createStreamSink(data) { |
|
12928 |
var _this3 = this; |
|
12929 |
|
|
12930 |
var self = this; |
|
12931 |
var action = this.actionHandler[data.action]; |
|
12932 |
var streamId = data.streamId; |
|
12933 |
var desiredSize = data.desiredSize; |
|
12934 |
var sourceName = this.sourceName; |
|
12935 |
var targetName = data.sourceName; |
|
12936 |
var capability = (0, _util.createPromiseCapability)(); |
|
12937 |
var sendStreamRequest = function sendStreamRequest(_ref2) { |
|
12938 |
var stream = _ref2.stream, |
|
12939 |
chunk = _ref2.chunk, |
|
12940 |
transfers = _ref2.transfers, |
|
12941 |
success = _ref2.success, |
|
12942 |
reason = _ref2.reason; |
|
12943 |
|
|
12944 |
_this3.postMessage({ |
|
12945 |
sourceName: sourceName, |
|
12946 |
targetName: targetName, |
|
12947 |
stream: stream, |
|
12948 |
streamId: streamId, |
|
12949 |
chunk: chunk, |
|
12950 |
success: success, |
|
12951 |
reason: reason |
|
12952 |
}, transfers); |
|
12953 |
}; |
|
12954 |
var streamSink = { |
|
12955 |
enqueue: function enqueue(chunk) { |
|
12956 |
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; |
|
12957 |
var transfers = arguments[2]; |
|
12958 |
|
|
12959 |
if (this.isCancelled) { |
|
12960 |
return; |
|
12961 |
} |
|
12962 |
var lastDesiredSize = this.desiredSize; |
|
12963 |
this.desiredSize -= size; |
|
12964 |
if (lastDesiredSize > 0 && this.desiredSize <= 0) { |
|
12965 |
this.sinkCapability = (0, _util.createPromiseCapability)(); |
|
12966 |
this.ready = this.sinkCapability.promise; |
|
12967 |
} |
|
12968 |
sendStreamRequest({ |
|
12969 |
stream: 'enqueue', |
|
12970 |
chunk: chunk, |
|
12971 |
transfers: transfers |
|
12972 |
}); |
|
12973 |
}, |
|
12974 |
close: function close() { |
|
12975 |
if (this.isCancelled) { |
|
12976 |
return; |
|
12977 |
} |
|
12978 |
this.isCancelled = true; |
|
12979 |
sendStreamRequest({ stream: 'close' }); |
|
12980 |
delete self.streamSinks[streamId]; |
|
12981 |
}, |
|
12982 |
error: function error(reason) { |
|
12983 |
if (this.isCancelled) { |
|
12984 |
return; |
|
12985 |
} |
|
12986 |
this.isCancelled = true; |
|
12987 |
sendStreamRequest({ |
|
12988 |
stream: 'error', |
|
12989 |
reason: reason |
|
12990 |
}); |
|
12991 |
}, |
|
12992 |
|
|
12993 |
sinkCapability: capability, |
|
12994 |
onPull: null, |
|
12995 |
onCancel: null, |
|
12996 |
isCancelled: false, |
|
12997 |
desiredSize: desiredSize, |
|
12998 |
ready: null |
|
12999 |
}; |
|
13000 |
streamSink.sinkCapability.resolve(); |
|
13001 |
streamSink.ready = streamSink.sinkCapability.promise; |
|
13002 |
this.streamSinks[streamId] = streamSink; |
|
13003 |
resolveCall(action[0], [data.data, streamSink], action[1]).then(function () { |
|
13004 |
sendStreamRequest({ |
|
13005 |
stream: 'start_complete', |
|
13006 |
success: true |
|
13007 |
}); |
|
13008 |
}, function (reason) { |
|
13009 |
sendStreamRequest({ |
|
13010 |
stream: 'start_complete', |
|
13011 |
success: false, |
|
13012 |
reason: reason |
|
13013 |
}); |
|
13014 |
}); |
|
13015 |
}, |
|
13016 |
_processStreamMessage: function _processStreamMessage(data) { |
|
13017 |
var _this4 = this; |
|
13018 |
|
|
13019 |
var sourceName = this.sourceName; |
|
13020 |
var targetName = data.sourceName; |
|
13021 |
var streamId = data.streamId; |
|
13022 |
var sendStreamResponse = function sendStreamResponse(_ref3) { |
|
13023 |
var stream = _ref3.stream, |
|
13024 |
success = _ref3.success, |
|
13025 |
reason = _ref3.reason; |
|
13026 |
|
|
13027 |
_this4.comObj.postMessage({ |
|
13028 |
sourceName: sourceName, |
|
13029 |
targetName: targetName, |
|
13030 |
stream: stream, |
|
13031 |
success: success, |
|
13032 |
streamId: streamId, |
|
13033 |
reason: reason |
|
13034 |
}); |
|
13035 |
}; |
|
13036 |
var deleteStreamController = function deleteStreamController() { |
|
13037 |
Promise.all([_this4.streamControllers[data.streamId].startCall, _this4.streamControllers[data.streamId].pullCall, _this4.streamControllers[data.streamId].cancelCall].map(function (capability) { |
|
13038 |
return capability && finalize(capability.promise); |
|
13039 |
})).then(function () { |
|
13040 |
delete _this4.streamControllers[data.streamId]; |
|
13041 |
}); |
|
13042 |
}; |
|
13043 |
switch (data.stream) { |
|
13044 |
case 'start_complete': |
|
13045 |
resolveOrReject(this.streamControllers[data.streamId].startCall, data.success, wrapReason(data.reason)); |
|
13046 |
break; |
|
13047 |
case 'pull_complete': |
|
13048 |
resolveOrReject(this.streamControllers[data.streamId].pullCall, data.success, wrapReason(data.reason)); |
|
13049 |
break; |
|
13050 |
case 'pull': |
|
13051 |
if (!this.streamSinks[data.streamId]) { |
|
13052 |
sendStreamResponse({ |
|
13053 |
stream: 'pull_complete', |
|
13054 |
success: true |
|
13055 |
}); |
|
13056 |
break; |
|
13057 |
} |
|
13058 |
if (this.streamSinks[data.streamId].desiredSize <= 0 && data.desiredSize > 0) { |
|
13059 |
this.streamSinks[data.streamId].sinkCapability.resolve(); |
|
13060 |
} |
|
13061 |
this.streamSinks[data.streamId].desiredSize = data.desiredSize; |
|
13062 |
resolveCall(this.streamSinks[data.streamId].onPull).then(function () { |
|
13063 |
sendStreamResponse({ |
|
13064 |
stream: 'pull_complete', |
|
13065 |
success: true |
|
13066 |
}); |
|
13067 |
}, function (reason) { |
|
13068 |
sendStreamResponse({ |
|
13069 |
stream: 'pull_complete', |
|
13070 |
success: false, |
|
13071 |
reason: reason |
|
13072 |
}); |
|
13073 |
}); |
|
13074 |
break; |
|
13075 |
case 'enqueue': |
|
13076 |
(0, _util.assert)(this.streamControllers[data.streamId], 'enqueue should have stream controller'); |
|
13077 |
if (!this.streamControllers[data.streamId].isClosed) { |
|
13078 |
this.streamControllers[data.streamId].controller.enqueue(data.chunk); |
|
13079 |
} |
|
13080 |
break; |
|
13081 |
case 'close': |
|
13082 |
(0, _util.assert)(this.streamControllers[data.streamId], 'close should have stream controller'); |
|
13083 |
if (this.streamControllers[data.streamId].isClosed) { |
|
13084 |
break; |
|
13085 |
} |
|
13086 |
this.streamControllers[data.streamId].isClosed = true; |
|
13087 |
this.streamControllers[data.streamId].controller.close(); |
|
13088 |
deleteStreamController(); |
|
13089 |
break; |
|
13090 |
case 'error': |
|
13091 |
(0, _util.assert)(this.streamControllers[data.streamId], 'error should have stream controller'); |
|
13092 |
this.streamControllers[data.streamId].controller.error(wrapReason(data.reason)); |
|
13093 |
deleteStreamController(); |
|
13094 |
break; |
|
13095 |
case 'cancel_complete': |
|
13096 |
resolveOrReject(this.streamControllers[data.streamId].cancelCall, data.success, wrapReason(data.reason)); |
|
13097 |
deleteStreamController(); |
|
13098 |
break; |
|
13099 |
case 'cancel': |
|
13100 |
if (!this.streamSinks[data.streamId]) { |
|
13101 |
break; |
|
13102 |
} |
|
13103 |
resolveCall(this.streamSinks[data.streamId].onCancel, [wrapReason(data.reason)]).then(function () { |
|
13104 |
sendStreamResponse({ |
|
13105 |
stream: 'cancel_complete', |
|
13106 |
success: true |
|
13107 |
}); |
|
13108 |
}, function (reason) { |
|
13109 |
sendStreamResponse({ |
|
13110 |
stream: 'cancel_complete', |
|
13111 |
success: false, |
|
13112 |
reason: reason |
|
13113 |
}); |
|
13114 |
}); |
|
13115 |
this.streamSinks[data.streamId].sinkCapability.reject(wrapReason(data.reason)); |
|
13116 |
this.streamSinks[data.streamId].isCancelled = true; |
|
13117 |
delete this.streamSinks[data.streamId]; |
|
13118 |
break; |
|
13119 |
default: |
|
13120 |
throw new Error('Unexpected stream case'); |
|
13121 |
} |
|
13122 |
}, |
|
13123 |
postMessage: function postMessage(message, transfers) { |
|
13124 |
if (transfers && this.postMessageTransfers) { |
|
13125 |
this.comObj.postMessage(message, transfers); |
|
13126 |
} else { |
|
13127 |
this.comObj.postMessage(message); |
|
13128 |
} |
|
13129 |
}, |
|
13130 |
destroy: function destroy() { |
|
13131 |
this.comObj.removeEventListener('message', this._onComObjOnMessage); |
|
13132 |
} |
|
13133 |
}; |
|
13134 |
exports.MessageHandler = MessageHandler; |
|
13135 |
|
|
13136 |
/***/ }), |
|
13137 |
/* 137 */ |
|
13138 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
13139 |
|
|
13140 |
"use strict"; |
|
13141 |
|
|
13142 |
|
|
13143 |
module.exports = __w_pdfjs_require__(138); |
|
13144 |
|
|
13145 |
/***/ }), |
|
13146 |
/* 138 */ |
|
13147 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
13148 |
|
|
13149 |
"use strict"; |
|
13150 |
|
|
13151 |
|
|
13152 |
var g = function () { |
|
13153 |
return this; |
|
13154 |
}() || Function("return this")(); |
|
13155 |
var hadRuntime = g.regeneratorRuntime && Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0; |
|
13156 |
var oldRuntime = hadRuntime && g.regeneratorRuntime; |
|
13157 |
g.regeneratorRuntime = undefined; |
|
13158 |
module.exports = __w_pdfjs_require__(139); |
|
13159 |
if (hadRuntime) { |
|
13160 |
g.regeneratorRuntime = oldRuntime; |
|
13161 |
} else { |
|
13162 |
try { |
|
13163 |
delete g.regeneratorRuntime; |
|
13164 |
} catch (e) { |
|
13165 |
g.regeneratorRuntime = undefined; |
|
13166 |
} |
|
13167 |
} |
|
13168 |
|
|
13169 |
/***/ }), |
|
13170 |
/* 139 */ |
|
13171 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
13172 |
|
|
13173 |
"use strict"; |
|
13174 |
/* WEBPACK VAR INJECTION */(function(module) { |
|
13175 |
|
|
13176 |
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; }; |
|
13177 |
|
|
13178 |
!function (global) { |
|
13179 |
"use strict"; |
|
13180 |
|
|
13181 |
var Op = Object.prototype; |
|
13182 |
var hasOwn = Op.hasOwnProperty; |
|
13183 |
var undefined; |
|
13184 |
var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
|
13185 |
var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
|
13186 |
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
|
13187 |
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
|
13188 |
var inModule = ( false ? undefined : _typeof(module)) === "object"; |
|
13189 |
var runtime = global.regeneratorRuntime; |
|
13190 |
if (runtime) { |
|
13191 |
if (inModule) { |
|
13192 |
module.exports = runtime; |
|
13193 |
} |
|
13194 |
return; |
|
13195 |
} |
|
13196 |
runtime = global.regeneratorRuntime = inModule ? module.exports : {}; |
|
13197 |
function wrap(innerFn, outerFn, self, tryLocsList) { |
|
13198 |
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; |
|
13199 |
var generator = Object.create(protoGenerator.prototype); |
|
13200 |
var context = new Context(tryLocsList || []); |
|
13201 |
generator._invoke = makeInvokeMethod(innerFn, self, context); |
|
13202 |
return generator; |
|
13203 |
} |
|
13204 |
runtime.wrap = wrap; |
|
13205 |
function tryCatch(fn, obj, arg) { |
|
13206 |
try { |
|
13207 |
return { |
|
13208 |
type: "normal", |
|
13209 |
arg: fn.call(obj, arg) |
|
13210 |
}; |
|
13211 |
} catch (err) { |
|
13212 |
return { |
|
13213 |
type: "throw", |
|
13214 |
arg: err |
|
13215 |
}; |
|
13216 |
} |
|
13217 |
} |
|
13218 |
var GenStateSuspendedStart = "suspendedStart"; |
|
13219 |
var GenStateSuspendedYield = "suspendedYield"; |
|
13220 |
var GenStateExecuting = "executing"; |
|
13221 |
var GenStateCompleted = "completed"; |
|
13222 |
var ContinueSentinel = {}; |
|
13223 |
function Generator() {} |
|
13224 |
function GeneratorFunction() {} |
|
13225 |
function GeneratorFunctionPrototype() {} |
|
13226 |
var IteratorPrototype = {}; |
|
13227 |
IteratorPrototype[iteratorSymbol] = function () { |
|
13228 |
return this; |
|
13229 |
}; |
|
13230 |
var getProto = Object.getPrototypeOf; |
|
13231 |
var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); |
|
13232 |
if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { |
|
13233 |
IteratorPrototype = NativeIteratorPrototype; |
|
13234 |
} |
|
13235 |
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); |
|
13236 |
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; |
|
13237 |
GeneratorFunctionPrototype.constructor = GeneratorFunction; |
|
13238 |
GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; |
|
13239 |
function defineIteratorMethods(prototype) { |
|
13240 |
["next", "throw", "return"].forEach(function (method) { |
|
13241 |
prototype[method] = function (arg) { |
|
13242 |
return this._invoke(method, arg); |
|
13243 |
}; |
|
13244 |
}); |
|
13245 |
} |
|
13246 |
runtime.isGeneratorFunction = function (genFun) { |
|
13247 |
var ctor = typeof genFun === "function" && genFun.constructor; |
|
13248 |
return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false; |
|
13249 |
}; |
|
13250 |
runtime.mark = function (genFun) { |
|
13251 |
if (Object.setPrototypeOf) { |
|
13252 |
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); |
|
13253 |
} else { |
|
13254 |
genFun.__proto__ = GeneratorFunctionPrototype; |
|
13255 |
if (!(toStringTagSymbol in genFun)) { |
|
13256 |
genFun[toStringTagSymbol] = "GeneratorFunction"; |
|
13257 |
} |
|
13258 |
} |
|
13259 |
genFun.prototype = Object.create(Gp); |
|
13260 |
return genFun; |
|
13261 |
}; |
|
13262 |
runtime.awrap = function (arg) { |
|
13263 |
return { __await: arg }; |
|
13264 |
}; |
|
13265 |
function AsyncIterator(generator) { |
|
13266 |
function invoke(method, arg, resolve, reject) { |
|
13267 |
var record = tryCatch(generator[method], generator, arg); |
|
13268 |
if (record.type === "throw") { |
|
13269 |
reject(record.arg); |
|
13270 |
} else { |
|
13271 |
var result = record.arg; |
|
13272 |
var value = result.value; |
|
13273 |
if (value && (typeof value === "undefined" ? "undefined" : _typeof(value)) === "object" && hasOwn.call(value, "__await")) { |
|
13274 |
return Promise.resolve(value.__await).then(function (value) { |
|
13275 |
invoke("next", value, resolve, reject); |
|
13276 |
}, function (err) { |
|
13277 |
invoke("throw", err, resolve, reject); |
|
13278 |
}); |
|
13279 |
} |
|
13280 |
return Promise.resolve(value).then(function (unwrapped) { |
|
13281 |
result.value = unwrapped; |
|
13282 |
resolve(result); |
|
13283 |
}, reject); |
|
13284 |
} |
|
13285 |
} |
|
13286 |
var previousPromise; |
|
13287 |
function enqueue(method, arg) { |
|
13288 |
function callInvokeWithMethodAndArg() { |
|
13289 |
return new Promise(function (resolve, reject) { |
|
13290 |
invoke(method, arg, resolve, reject); |
|
13291 |
}); |
|
13292 |
} |
|
13293 |
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); |
|
13294 |
} |
|
13295 |
this._invoke = enqueue; |
|
13296 |
} |
|
13297 |
defineIteratorMethods(AsyncIterator.prototype); |
|
13298 |
AsyncIterator.prototype[asyncIteratorSymbol] = function () { |
|
13299 |
return this; |
|
13300 |
}; |
|
13301 |
runtime.AsyncIterator = AsyncIterator; |
|
13302 |
runtime.async = function (innerFn, outerFn, self, tryLocsList) { |
|
13303 |
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList)); |
|
13304 |
return runtime.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { |
|
13305 |
return result.done ? result.value : iter.next(); |
|
13306 |
}); |
|
13307 |
}; |
|
13308 |
function makeInvokeMethod(innerFn, self, context) { |
|
13309 |
var state = GenStateSuspendedStart; |
|
13310 |
return function invoke(method, arg) { |
|
13311 |
if (state === GenStateExecuting) { |
|
13312 |
throw new Error("Generator is already running"); |
|
13313 |
} |
|
13314 |
if (state === GenStateCompleted) { |
|
13315 |
if (method === "throw") { |
|
13316 |
throw arg; |
|
13317 |
} |
|
13318 |
return doneResult(); |
|
13319 |
} |
|
13320 |
context.method = method; |
|
13321 |
context.arg = arg; |
|
13322 |
while (true) { |
|
13323 |
var delegate = context.delegate; |
|
13324 |
if (delegate) { |
|
13325 |
var delegateResult = maybeInvokeDelegate(delegate, context); |
|
13326 |
if (delegateResult) { |
|
13327 |
if (delegateResult === ContinueSentinel) continue; |
|
13328 |
return delegateResult; |
|
13329 |
} |
|
13330 |
} |
|
13331 |
if (context.method === "next") { |
|
13332 |
context.sent = context._sent = context.arg; |
|
13333 |
} else if (context.method === "throw") { |
|
13334 |
if (state === GenStateSuspendedStart) { |
|
13335 |
state = GenStateCompleted; |
|
13336 |
throw context.arg; |
|
13337 |
} |
|
13338 |
context.dispatchException(context.arg); |
|
13339 |
} else if (context.method === "return") { |
|
13340 |
context.abrupt("return", context.arg); |
|
13341 |
} |
|
13342 |
state = GenStateExecuting; |
|
13343 |
var record = tryCatch(innerFn, self, context); |
|
13344 |
if (record.type === "normal") { |
|
13345 |
state = context.done ? GenStateCompleted : GenStateSuspendedYield; |
|
13346 |
if (record.arg === ContinueSentinel) { |
|
13347 |
continue; |
|
13348 |
} |
|
13349 |
return { |
|
13350 |
value: record.arg, |
|
13351 |
done: context.done |
|
13352 |
}; |
|
13353 |
} else if (record.type === "throw") { |
|
13354 |
state = GenStateCompleted; |
|
13355 |
context.method = "throw"; |
|
13356 |
context.arg = record.arg; |
|
13357 |
} |
|
13358 |
} |
|
13359 |
}; |
|
13360 |
} |
|
13361 |
function maybeInvokeDelegate(delegate, context) { |
|
13362 |
var method = delegate.iterator[context.method]; |
|
13363 |
if (method === undefined) { |
|
13364 |
context.delegate = null; |
|
13365 |
if (context.method === "throw") { |
|
13366 |
if (delegate.iterator.return) { |
|
13367 |
context.method = "return"; |
|
13368 |
context.arg = undefined; |
|
13369 |
maybeInvokeDelegate(delegate, context); |
|
13370 |
if (context.method === "throw") { |
|
13371 |
return ContinueSentinel; |
|
13372 |
} |
|
13373 |
} |
|
13374 |
context.method = "throw"; |
|
13375 |
context.arg = new TypeError("The iterator does not provide a 'throw' method"); |
|
13376 |
} |
|
13377 |
return ContinueSentinel; |
|
13378 |
} |
|
13379 |
var record = tryCatch(method, delegate.iterator, context.arg); |
|
13380 |
if (record.type === "throw") { |
|
13381 |
context.method = "throw"; |
|
13382 |
context.arg = record.arg; |
|
13383 |
context.delegate = null; |
|
13384 |
return ContinueSentinel; |
|
13385 |
} |
|
13386 |
var info = record.arg; |
|
13387 |
if (!info) { |
|
13388 |
context.method = "throw"; |
|
13389 |
context.arg = new TypeError("iterator result is not an object"); |
|
13390 |
context.delegate = null; |
|
13391 |
return ContinueSentinel; |
|
13392 |
} |
|
13393 |
if (info.done) { |
|
13394 |
context[delegate.resultName] = info.value; |
|
13395 |
context.next = delegate.nextLoc; |
|
13396 |
if (context.method !== "return") { |
|
13397 |
context.method = "next"; |
|
13398 |
context.arg = undefined; |
|
13399 |
} |
|
13400 |
} else { |
|
13401 |
return info; |
|
13402 |
} |
|
13403 |
context.delegate = null; |
|
13404 |
return ContinueSentinel; |
|
13405 |
} |
|
13406 |
defineIteratorMethods(Gp); |
|
13407 |
Gp[toStringTagSymbol] = "Generator"; |
|
13408 |
Gp[iteratorSymbol] = function () { |
|
13409 |
return this; |
|
13410 |
}; |
|
13411 |
Gp.toString = function () { |
|
13412 |
return "[object Generator]"; |
|
13413 |
}; |
|
13414 |
function pushTryEntry(locs) { |
|
13415 |
var entry = { tryLoc: locs[0] }; |
|
13416 |
if (1 in locs) { |
|
13417 |
entry.catchLoc = locs[1]; |
|
13418 |
} |
|
13419 |
if (2 in locs) { |
|
13420 |
entry.finallyLoc = locs[2]; |
|
13421 |
entry.afterLoc = locs[3]; |
|
13422 |
} |
|
13423 |
this.tryEntries.push(entry); |
|
13424 |
} |
|
13425 |
function resetTryEntry(entry) { |
|
13426 |
var record = entry.completion || {}; |
|
13427 |
record.type = "normal"; |
|
13428 |
delete record.arg; |
|
13429 |
entry.completion = record; |
|
13430 |
} |
|
13431 |
function Context(tryLocsList) { |
|
13432 |
this.tryEntries = [{ tryLoc: "root" }]; |
|
13433 |
tryLocsList.forEach(pushTryEntry, this); |
|
13434 |
this.reset(true); |
|
13435 |
} |
|
13436 |
runtime.keys = function (object) { |
|
13437 |
var keys = []; |
|
13438 |
for (var key in object) { |
|
13439 |
keys.push(key); |
|
13440 |
} |
|
13441 |
keys.reverse(); |
|
13442 |
return function next() { |
|
13443 |
while (keys.length) { |
|
13444 |
var key = keys.pop(); |
|
13445 |
if (key in object) { |
|
13446 |
next.value = key; |
|
13447 |
next.done = false; |
|
13448 |
return next; |
|
13449 |
} |
|
13450 |
} |
|
13451 |
next.done = true; |
|
13452 |
return next; |
|
13453 |
}; |
|
13454 |
}; |
|
13455 |
function values(iterable) { |
|
13456 |
if (iterable) { |
|
13457 |
var iteratorMethod = iterable[iteratorSymbol]; |
|
13458 |
if (iteratorMethod) { |
|
13459 |
return iteratorMethod.call(iterable); |
|
13460 |
} |
|
13461 |
if (typeof iterable.next === "function") { |
|
13462 |
return iterable; |
|
13463 |
} |
|
13464 |
if (!isNaN(iterable.length)) { |
|
13465 |
var i = -1, |
|
13466 |
next = function next() { |
|
13467 |
while (++i < iterable.length) { |
|
13468 |
if (hasOwn.call(iterable, i)) { |
|
13469 |
next.value = iterable[i]; |
|
13470 |
next.done = false; |
|
13471 |
return next; |
|
13472 |
} |
|
13473 |
} |
|
13474 |
next.value = undefined; |
|
13475 |
next.done = true; |
|
13476 |
return next; |
|
13477 |
}; |
|
13478 |
return next.next = next; |
|
13479 |
} |
|
13480 |
} |
|
13481 |
return { next: doneResult }; |
|
13482 |
} |
|
13483 |
runtime.values = values; |
|
13484 |
function doneResult() { |
|
13485 |
return { |
|
13486 |
value: undefined, |
|
13487 |
done: true |
|
13488 |
}; |
|
13489 |
} |
|
13490 |
Context.prototype = { |
|
13491 |
constructor: Context, |
|
13492 |
reset: function reset(skipTempReset) { |
|
13493 |
this.prev = 0; |
|
13494 |
this.next = 0; |
|
13495 |
this.sent = this._sent = undefined; |
|
13496 |
this.done = false; |
|
13497 |
this.delegate = null; |
|
13498 |
this.method = "next"; |
|
13499 |
this.arg = undefined; |
|
13500 |
this.tryEntries.forEach(resetTryEntry); |
|
13501 |
if (!skipTempReset) { |
|
13502 |
for (var name in this) { |
|
13503 |
if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) { |
|
13504 |
this[name] = undefined; |
|
13505 |
} |
|
13506 |
} |
|
13507 |
} |
|
13508 |
}, |
|
13509 |
stop: function stop() { |
|
13510 |
this.done = true; |
|
13511 |
var rootEntry = this.tryEntries[0]; |
|
13512 |
var rootRecord = rootEntry.completion; |
|
13513 |
if (rootRecord.type === "throw") { |
|
13514 |
throw rootRecord.arg; |
|
13515 |
} |
|
13516 |
return this.rval; |
|
13517 |
}, |
|
13518 |
dispatchException: function dispatchException(exception) { |
|
13519 |
if (this.done) { |
|
13520 |
throw exception; |
|
13521 |
} |
|
13522 |
var context = this; |
|
13523 |
function handle(loc, caught) { |
|
13524 |
record.type = "throw"; |
|
13525 |
record.arg = exception; |
|
13526 |
context.next = loc; |
|
13527 |
if (caught) { |
|
13528 |
context.method = "next"; |
|
13529 |
context.arg = undefined; |
|
13530 |
} |
|
13531 |
return !!caught; |
|
13532 |
} |
|
13533 |
for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
13534 |
var entry = this.tryEntries[i]; |
|
13535 |
var record = entry.completion; |
|
13536 |
if (entry.tryLoc === "root") { |
|
13537 |
return handle("end"); |
|
13538 |
} |
|
13539 |
if (entry.tryLoc <= this.prev) { |
|
13540 |
var hasCatch = hasOwn.call(entry, "catchLoc"); |
|
13541 |
var hasFinally = hasOwn.call(entry, "finallyLoc"); |
|
13542 |
if (hasCatch && hasFinally) { |
|
13543 |
if (this.prev < entry.catchLoc) { |
|
13544 |
return handle(entry.catchLoc, true); |
|
13545 |
} else if (this.prev < entry.finallyLoc) { |
|
13546 |
return handle(entry.finallyLoc); |
|
13547 |
} |
|
13548 |
} else if (hasCatch) { |
|
13549 |
if (this.prev < entry.catchLoc) { |
|
13550 |
return handle(entry.catchLoc, true); |
|
13551 |
} |
|
13552 |
} else if (hasFinally) { |
|
13553 |
if (this.prev < entry.finallyLoc) { |
|
13554 |
return handle(entry.finallyLoc); |
|
13555 |
} |
|
13556 |
} else { |
|
13557 |
throw new Error("try statement without catch or finally"); |
|
13558 |
} |
|
13559 |
} |
|
13560 |
} |
|
13561 |
}, |
|
13562 |
abrupt: function abrupt(type, arg) { |
|
13563 |
for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
13564 |
var entry = this.tryEntries[i]; |
|
13565 |
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { |
|
13566 |
var finallyEntry = entry; |
|
13567 |
break; |
|
13568 |
} |
|
13569 |
} |
|
13570 |
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) { |
|
13571 |
finallyEntry = null; |
|
13572 |
} |
|
13573 |
var record = finallyEntry ? finallyEntry.completion : {}; |
|
13574 |
record.type = type; |
|
13575 |
record.arg = arg; |
|
13576 |
if (finallyEntry) { |
|
13577 |
this.method = "next"; |
|
13578 |
this.next = finallyEntry.finallyLoc; |
|
13579 |
return ContinueSentinel; |
|
13580 |
} |
|
13581 |
return this.complete(record); |
|
13582 |
}, |
|
13583 |
complete: function complete(record, afterLoc) { |
|
13584 |
if (record.type === "throw") { |
|
13585 |
throw record.arg; |
|
13586 |
} |
|
13587 |
if (record.type === "break" || record.type === "continue") { |
|
13588 |
this.next = record.arg; |
|
13589 |
} else if (record.type === "return") { |
|
13590 |
this.rval = this.arg = record.arg; |
|
13591 |
this.method = "return"; |
|
13592 |
this.next = "end"; |
|
13593 |
} else if (record.type === "normal" && afterLoc) { |
|
13594 |
this.next = afterLoc; |
|
13595 |
} |
|
13596 |
return ContinueSentinel; |
|
13597 |
}, |
|
13598 |
finish: function finish(finallyLoc) { |
|
13599 |
for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
13600 |
var entry = this.tryEntries[i]; |
|
13601 |
if (entry.finallyLoc === finallyLoc) { |
|
13602 |
this.complete(entry.completion, entry.afterLoc); |
|
13603 |
resetTryEntry(entry); |
|
13604 |
return ContinueSentinel; |
|
13605 |
} |
|
13606 |
} |
|
13607 |
}, |
|
13608 |
"catch": function _catch(tryLoc) { |
|
13609 |
for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
13610 |
var entry = this.tryEntries[i]; |
|
13611 |
if (entry.tryLoc === tryLoc) { |
|
13612 |
var record = entry.completion; |
|
13613 |
if (record.type === "throw") { |
|
13614 |
var thrown = record.arg; |
|
13615 |
resetTryEntry(entry); |
|
13616 |
} |
|
13617 |
return thrown; |
|
13618 |
} |
|
13619 |
} |
|
13620 |
throw new Error("illegal catch attempt"); |
|
13621 |
}, |
|
13622 |
delegateYield: function delegateYield(iterable, resultName, nextLoc) { |
|
13623 |
this.delegate = { |
|
13624 |
iterator: values(iterable), |
|
13625 |
resultName: resultName, |
|
13626 |
nextLoc: nextLoc |
|
13627 |
}; |
|
13628 |
if (this.method === "next") { |
|
13629 |
this.arg = undefined; |
|
13630 |
} |
|
13631 |
return ContinueSentinel; |
|
13632 |
} |
|
13633 |
}; |
|
13634 |
}(function () { |
|
13635 |
return this; |
|
13636 |
}() || Function("return this")()); |
|
13637 |
/* WEBPACK VAR INJECTION */}.call(this, __w_pdfjs_require__(140)(module))) |
|
13638 |
|
|
13639 |
/***/ }), |
|
13640 |
/* 140 */ |
|
13641 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
13642 |
|
|
13643 |
"use strict"; |
|
13644 |
|
|
13645 |
|
|
13646 |
module.exports = function (module) { |
|
13647 |
if (!module.webpackPolyfill) { |
|
13648 |
module.deprecate = function () {}; |
|
13649 |
module.paths = []; |
|
13650 |
if (!module.children) module.children = []; |
|
13651 |
Object.defineProperty(module, "loaded", { |
|
13652 |
enumerable: true, |
|
13653 |
get: function get() { |
|
13654 |
return module.l; |
|
13655 |
} |
|
13656 |
}); |
|
13657 |
Object.defineProperty(module, "id", { |
|
13658 |
enumerable: true, |
|
13659 |
get: function get() { |
|
13660 |
return module.i; |
|
13661 |
} |
|
13662 |
}); |
|
13663 |
module.webpackPolyfill = 1; |
|
13664 |
} |
|
13665 |
return module; |
|
13666 |
}; |
|
13667 |
|
|
13668 |
/***/ }), |
|
13669 |
/* 141 */ |
|
13670 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
13671 |
|
|
13672 |
"use strict"; |
|
13673 |
|
|
13674 |
|
|
13675 |
Object.defineProperty(exports, "__esModule", { |
|
13676 |
value: true |
|
13677 |
}); |
|
13678 |
exports.Metadata = undefined; |
|
13679 |
|
|
13680 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
|
13681 |
|
|
13682 |
var _util = __w_pdfjs_require__(1); |
|
13683 |
|
|
13684 |
var _xml_parser = __w_pdfjs_require__(142); |
|
13685 |
|
|
13686 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
13687 |
|
|
13688 |
var Metadata = function () { |
|
13689 |
function Metadata(data) { |
|
13690 |
_classCallCheck(this, Metadata); |
|
13691 |
|
|
13692 |
(0, _util.assert)(typeof data === 'string', 'Metadata: input is not a string'); |
|
13693 |
data = this._repair(data); |
|
13694 |
var parser = new _xml_parser.SimpleXMLParser(); |
|
13695 |
var xmlDocument = parser.parseFromString(data); |
|
13696 |
this._metadata = Object.create(null); |
|
13697 |
if (xmlDocument) { |
|
13698 |
this._parse(xmlDocument); |
|
13699 |
} |
|
13700 |
} |
|
13701 |
|
|
13702 |
_createClass(Metadata, [{ |
|
13703 |
key: '_repair', |
|
13704 |
value: function _repair(data) { |
|
13705 |
return data.replace(/>\\376\\377([^<]+)/g, function (all, codes) { |
|
13706 |
var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) { |
|
13707 |
return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1); |
|
13708 |
}).replace(/&(amp|apos|gt|lt|quot);/g, function (str, name) { |
|
13709 |
switch (name) { |
|
13710 |
case 'amp': |
|
13711 |
return '&'; |
|
13712 |
case 'apos': |
|
13713 |
return '\''; |
|
13714 |
case 'gt': |
|
13715 |
return '>'; |
|
13716 |
case 'lt': |
|
13717 |
return '<'; |
|
13718 |
case 'quot': |
|
13719 |
return '\"'; |
|
13720 |
} |
|
13721 |
throw new Error('_repair: ' + name + ' isn\'t defined.'); |
|
13722 |
}); |
|
13723 |
var chars = ''; |
|
13724 |
for (var i = 0, ii = bytes.length; i < ii; i += 2) { |
|
13725 |
var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1); |
|
13726 |
if (code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38) { |
|
13727 |
chars += String.fromCharCode(code); |
|
13728 |
} else { |
|
13729 |
chars += '&#x' + (0x10000 + code).toString(16).substring(1) + ';'; |
|
13730 |
} |
|
13731 |
} |
|
13732 |
return '>' + chars; |
|
13733 |
}); |
|
13734 |
} |
|
13735 |
}, { |
|
13736 |
key: '_parse', |
|
13737 |
value: function _parse(xmlDocument) { |
|
13738 |
var rdf = xmlDocument.documentElement; |
|
13739 |
if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') { |
|
13740 |
rdf = rdf.firstChild; |
|
13741 |
while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') { |
|
13742 |
rdf = rdf.nextSibling; |
|
13743 |
} |
|
13744 |
} |
|
13745 |
var nodeName = rdf ? rdf.nodeName.toLowerCase() : null; |
|
13746 |
if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) { |
|
13747 |
return; |
|
13748 |
} |
|
13749 |
var children = rdf.childNodes; |
|
13750 |
for (var i = 0, ii = children.length; i < ii; i++) { |
|
13751 |
var desc = children[i]; |
|
13752 |
if (desc.nodeName.toLowerCase() !== 'rdf:description') { |
|
13753 |
continue; |
|
13754 |
} |
|
13755 |
for (var j = 0, jj = desc.childNodes.length; j < jj; j++) { |
|
13756 |
if (desc.childNodes[j].nodeName.toLowerCase() !== '#text') { |
|
13757 |
var entry = desc.childNodes[j]; |
|
13758 |
var name = entry.nodeName.toLowerCase(); |
|
13759 |
this._metadata[name] = entry.textContent.trim(); |
|
13760 |
} |
|
13761 |
} |
|
13762 |
} |
|
13763 |
} |
|
13764 |
}, { |
|
13765 |
key: 'get', |
|
13766 |
value: function get(name) { |
|
13767 |
return this._metadata[name] || null; |
|
13768 |
} |
|
13769 |
}, { |
|
13770 |
key: 'getAll', |
|
13771 |
value: function getAll() { |
|
13772 |
return this._metadata; |
|
13773 |
} |
|
13774 |
}, { |
|
13775 |
key: 'has', |
|
13776 |
value: function has(name) { |
|
13777 |
return typeof this._metadata[name] !== 'undefined'; |
|
13778 |
} |
|
13779 |
}]); |
|
13780 |
|
|
13781 |
return Metadata; |
|
13782 |
}(); |
|
13783 |
|
|
13784 |
exports.Metadata = Metadata; |
|
13785 |
|
|
13786 |
/***/ }), |
|
13787 |
/* 142 */ |
|
13788 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
13789 |
|
|
13790 |
"use strict"; |
|
13791 |
|
|
13792 |
|
|
13793 |
Object.defineProperty(exports, "__esModule", { |
|
13794 |
value: true |
|
13795 |
}); |
|
13796 |
|
|
13797 |
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); |
|
13798 |
|
|
13799 |
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; |
|
13800 |
|
|
13801 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
|
13802 |
|
|
13803 |
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } |
|
13804 |
|
|
13805 |
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
|
13806 |
|
|
13807 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
13808 |
|
|
13809 |
var XMLParserErrorCode = { |
|
13810 |
NoError: 0, |
|
13811 |
EndOfDocument: -1, |
|
13812 |
UnterminatedCdat: -2, |
|
13813 |
UnterminatedXmlDeclaration: -3, |
|
13814 |
UnterminatedDoctypeDeclaration: -4, |
|
13815 |
UnterminatedComment: -5, |
|
13816 |
MalformedElement: -6, |
|
13817 |
OutOfMemory: -7, |
|
13818 |
UnterminatedAttributeValue: -8, |
|
13819 |
UnterminatedElement: -9, |
|
13820 |
ElementNeverBegun: -10 |
|
13821 |
}; |
|
13822 |
function isWhitespace(s, index) { |
|
13823 |
var ch = s[index]; |
|
13824 |
return ch === ' ' || ch === '\n' || ch === '\r' || ch === '\t'; |
|
13825 |
} |
|
13826 |
function isWhitespaceString(s) { |
|
13827 |
for (var i = 0, ii = s.length; i < ii; i++) { |
|
13828 |
if (!isWhitespace(s, i)) { |
|
13829 |
return false; |
|
13830 |
} |
|
13831 |
} |
|
13832 |
return true; |
|
13833 |
} |
|
13834 |
|
|
13835 |
var XMLParserBase = function () { |
|
13836 |
function XMLParserBase() { |
|
13837 |
_classCallCheck(this, XMLParserBase); |
|
13838 |
} |
|
13839 |
|
|
13840 |
_createClass(XMLParserBase, [{ |
|
13841 |
key: '_resolveEntities', |
|
13842 |
value: function _resolveEntities(s) { |
|
13843 |
return s.replace(/&([^;]+);/g, function (all, entity) { |
|
13844 |
if (entity.substring(0, 2) === '#x') { |
|
13845 |
return String.fromCharCode(parseInt(entity.substring(2), 16)); |
|
13846 |
} else if (entity.substring(0, 1) === '#') { |
|
13847 |
return String.fromCharCode(parseInt(entity.substring(1), 10)); |
|
13848 |
} |
|
13849 |
switch (entity) { |
|
13850 |
case 'lt': |
|
13851 |
return '<'; |
|
13852 |
case 'gt': |
|
13853 |
return '>'; |
|
13854 |
case 'amp': |
|
13855 |
return '&'; |
|
13856 |
case 'quot': |
|
13857 |
return '\"'; |
|
13858 |
} |
|
13859 |
return this.onResolveEntity(entity); |
|
13860 |
}); |
|
13861 |
} |
|
13862 |
}, { |
|
13863 |
key: '_parseContent', |
|
13864 |
value: function _parseContent(s, start) { |
|
13865 |
var pos = start, |
|
13866 |
name = void 0, |
|
13867 |
attributes = []; |
|
13868 |
function skipWs() { |
|
13869 |
while (pos < s.length && isWhitespace(s, pos)) { |
|
13870 |
++pos; |
|
13871 |
} |
|
13872 |
} |
|
13873 |
while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '>' && s[pos] !== '/') { |
|
13874 |
++pos; |
|
13875 |
} |
|
13876 |
name = s.substring(start, pos); |
|
13877 |
skipWs(); |
|
13878 |
while (pos < s.length && s[pos] !== '>' && s[pos] !== '/' && s[pos] !== '?') { |
|
13879 |
skipWs(); |
|
13880 |
var attrName = '', |
|
13881 |
attrValue = ''; |
|
13882 |
while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '=') { |
|
13883 |
attrName += s[pos]; |
|
13884 |
++pos; |
|
13885 |
} |
|
13886 |
skipWs(); |
|
13887 |
if (s[pos] !== '=') { |
|
13888 |
return null; |
|
13889 |
} |
|
13890 |
++pos; |
|
13891 |
skipWs(); |
|
13892 |
var attrEndChar = s[pos]; |
|
13893 |
if (attrEndChar !== '\"' && attrEndChar !== '\'') { |
|
13894 |
return null; |
|
13895 |
} |
|
13896 |
var attrEndIndex = s.indexOf(attrEndChar, ++pos); |
|
13897 |
if (attrEndIndex < 0) { |
|
13898 |
return null; |
|
13899 |
} |
|
13900 |
attrValue = s.substring(pos, attrEndIndex); |
|
13901 |
attributes.push({ |
|
13902 |
name: attrName, |
|
13903 |
value: this._resolveEntities(attrValue) |
|
13904 |
}); |
|
13905 |
pos = attrEndIndex + 1; |
|
13906 |
skipWs(); |
|
13907 |
} |
|
13908 |
return { |
|
13909 |
name: name, |
|
13910 |
attributes: attributes, |
|
13911 |
parsed: pos - start |
|
13912 |
}; |
|
13913 |
} |
|
13914 |
}, { |
|
13915 |
key: '_parseProcessingInstruction', |
|
13916 |
value: function _parseProcessingInstruction(s, start) { |
|
13917 |
var pos = start, |
|
13918 |
name = void 0, |
|
13919 |
value = void 0; |
|
13920 |
function skipWs() { |
|
13921 |
while (pos < s.length && isWhitespace(s, pos)) { |
|
13922 |
++pos; |
|
13923 |
} |
|
13924 |
} |
|
13925 |
while (pos < s.length && !isWhitespace(s, pos) && s[pos] !== '>' && s[pos] !== '/') { |
|
13926 |
++pos; |
|
13927 |
} |
|
13928 |
name = s.substring(start, pos); |
|
13929 |
skipWs(); |
|
13930 |
var attrStart = pos; |
|
13931 |
while (pos < s.length && (s[pos] !== '?' || s[pos + 1] !== '>')) { |
|
13932 |
++pos; |
|
13933 |
} |
|
13934 |
value = s.substring(attrStart, pos); |
|
13935 |
return { |
|
13936 |
name: name, |
|
13937 |
value: value, |
|
13938 |
parsed: pos - start |
|
13939 |
}; |
|
13940 |
} |
|
13941 |
}, { |
|
13942 |
key: 'parseXml', |
|
13943 |
value: function parseXml(s) { |
|
13944 |
var i = 0; |
|
13945 |
while (i < s.length) { |
|
13946 |
var ch = s[i]; |
|
13947 |
var j = i; |
|
13948 |
if (ch === '<') { |
|
13949 |
++j; |
|
13950 |
var ch2 = s[j]; |
|
13951 |
var q = void 0; |
|
13952 |
switch (ch2) { |
|
13953 |
case '/': |
|
13954 |
++j; |
|
13955 |
q = s.indexOf('>', j); |
|
13956 |
if (q < 0) { |
|
13957 |
this.onError(XMLParserErrorCode.UnterminatedElement); |
|
13958 |
return; |
|
13959 |
} |
|
13960 |
this.onEndElement(s.substring(j, q)); |
|
13961 |
j = q + 1; |
|
13962 |
break; |
|
13963 |
case '?': |
|
13964 |
++j; |
|
13965 |
var pi = this._parseProcessingInstruction(s, j); |
|
13966 |
if (s.substring(j + pi.parsed, j + pi.parsed + 2) !== '?>') { |
|
13967 |
this.onError(XMLParserErrorCode.UnterminatedXmlDeclaration); |
|
13968 |
return; |
|
13969 |
} |
|
13970 |
this.onPi(pi.name, pi.value); |
|
13971 |
j += pi.parsed + 2; |
|
13972 |
break; |
|
13973 |
case '!': |
|
13974 |
if (s.substring(j + 1, j + 3) === '--') { |
|
13975 |
q = s.indexOf('-->', j + 3); |
|
13976 |
if (q < 0) { |
|
13977 |
this.onError(XMLParserErrorCode.UnterminatedComment); |
|
13978 |
return; |
|
13979 |
} |
|
13980 |
this.onComment(s.substring(j + 3, q)); |
|
13981 |
j = q + 3; |
|
13982 |
} else if (s.substring(j + 1, j + 8) === '[CDATA[') { |
|
13983 |
q = s.indexOf(']]>', j + 8); |
|
13984 |
if (q < 0) { |
|
13985 |
this.onError(XMLParserErrorCode.UnterminatedCdat); |
|
13986 |
return; |
|
13987 |
} |
|
13988 |
this.onCdata(s.substring(j + 8, q)); |
|
13989 |
j = q + 3; |
|
13990 |
} else if (s.substring(j + 1, j + 8) === 'DOCTYPE') { |
|
13991 |
var q2 = s.indexOf('[', j + 8); |
|
13992 |
var complexDoctype = false; |
|
13993 |
q = s.indexOf('>', j + 8); |
|
13994 |
if (q < 0) { |
|
13995 |
this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration); |
|
13996 |
return; |
|
13997 |
} |
|
13998 |
if (q2 > 0 && q > q2) { |
|
13999 |
q = s.indexOf(']>', j + 8); |
|
14000 |
if (q < 0) { |
|
14001 |
this.onError(XMLParserErrorCode.UnterminatedDoctypeDeclaration); |
|
14002 |
return; |
|
14003 |
} |
|
14004 |
complexDoctype = true; |
|
14005 |
} |
|
14006 |
var doctypeContent = s.substring(j + 8, q + (complexDoctype ? 1 : 0)); |
|
14007 |
this.onDoctype(doctypeContent); |
|
14008 |
j = q + (complexDoctype ? 2 : 1); |
|
14009 |
} else { |
|
14010 |
this.onError(XMLParserErrorCode.MalformedElement); |
|
14011 |
return; |
|
14012 |
} |
|
14013 |
break; |
|
14014 |
default: |
|
14015 |
var content = this._parseContent(s, j); |
|
14016 |
if (content === null) { |
|
14017 |
this.onError(XMLParserErrorCode.MalformedElement); |
|
14018 |
return; |
|
14019 |
} |
|
14020 |
var isClosed = false; |
|
14021 |
if (s.substring(j + content.parsed, j + content.parsed + 2) === '/>') { |
|
14022 |
isClosed = true; |
|
14023 |
} else if (s.substring(j + content.parsed, j + content.parsed + 1) !== '>') { |
|
14024 |
this.onError(XMLParserErrorCode.UnterminatedElement); |
|
14025 |
return; |
|
14026 |
} |
|
14027 |
this.onBeginElement(content.name, content.attributes, isClosed); |
|
14028 |
j += content.parsed + (isClosed ? 2 : 1); |
|
14029 |
break; |
|
14030 |
} |
|
14031 |
} else { |
|
14032 |
while (j < s.length && s[j] !== '<') { |
|
14033 |
j++; |
|
14034 |
} |
|
14035 |
var text = s.substring(i, j); |
|
14036 |
this.onText(this._resolveEntities(text)); |
|
14037 |
} |
|
14038 |
i = j; |
|
14039 |
} |
|
14040 |
} |
|
14041 |
}, { |
|
14042 |
key: 'onResolveEntity', |
|
14043 |
value: function onResolveEntity(name) { |
|
14044 |
return '&' + name + ';'; |
|
14045 |
} |
|
14046 |
}, { |
|
14047 |
key: 'onPi', |
|
14048 |
value: function onPi(name, value) {} |
|
14049 |
}, { |
|
14050 |
key: 'onComment', |
|
14051 |
value: function onComment(text) {} |
|
14052 |
}, { |
|
14053 |
key: 'onCdata', |
|
14054 |
value: function onCdata(text) {} |
|
14055 |
}, { |
|
14056 |
key: 'onDoctype', |
|
14057 |
value: function onDoctype(doctypeContent) {} |
|
14058 |
}, { |
|
14059 |
key: 'onText', |
|
14060 |
value: function onText(text) {} |
|
14061 |
}, { |
|
14062 |
key: 'onBeginElement', |
|
14063 |
value: function onBeginElement(name, attributes, isEmpty) {} |
|
14064 |
}, { |
|
14065 |
key: 'onEndElement', |
|
14066 |
value: function onEndElement(name) {} |
|
14067 |
}, { |
|
14068 |
key: 'onError', |
|
14069 |
value: function onError(code) {} |
|
14070 |
}]); |
|
14071 |
|
|
14072 |
return XMLParserBase; |
|
14073 |
}(); |
|
14074 |
|
|
14075 |
var SimpleDOMNode = function () { |
|
14076 |
function SimpleDOMNode(nodeName, nodeValue) { |
|
14077 |
_classCallCheck(this, SimpleDOMNode); |
|
14078 |
|
|
14079 |
this.nodeName = nodeName; |
|
14080 |
this.nodeValue = nodeValue; |
|
14081 |
Object.defineProperty(this, 'parentNode', { |
|
14082 |
value: null, |
|
14083 |
writable: true |
|
14084 |
}); |
|
14085 |
} |
|
14086 |
|
|
14087 |
_createClass(SimpleDOMNode, [{ |
|
14088 |
key: 'hasChildNodes', |
|
14089 |
value: function hasChildNodes() { |
|
14090 |
return this.childNodes && this.childNodes.length > 0; |
|
14091 |
} |
|
14092 |
}, { |
|
14093 |
key: 'firstChild', |
|
14094 |
get: function get() { |
|
14095 |
return this.childNodes[0]; |
|
14096 |
} |
|
14097 |
}, { |
|
14098 |
key: 'nextSibling', |
|
14099 |
get: function get() { |
|
14100 |
var index = this.parentNode.childNodes.indexOf(this); |
|
14101 |
return this.parentNode.childNodes[index + 1]; |
|
14102 |
} |
|
14103 |
}, { |
|
14104 |
key: 'textContent', |
|
14105 |
get: function get() { |
|
14106 |
if (!this.childNodes) { |
|
14107 |
return this.nodeValue || ''; |
|
14108 |
} |
|
14109 |
return this.childNodes.map(function (child) { |
|
14110 |
return child.textContent; |
|
14111 |
}).join(''); |
|
14112 |
} |
|
14113 |
}]); |
|
14114 |
|
|
14115 |
return SimpleDOMNode; |
|
14116 |
}(); |
|
14117 |
|
|
14118 |
var SimpleXMLParser = function (_XMLParserBase) { |
|
14119 |
_inherits(SimpleXMLParser, _XMLParserBase); |
|
14120 |
|
|
14121 |
function SimpleXMLParser() { |
|
14122 |
_classCallCheck(this, SimpleXMLParser); |
|
14123 |
|
|
14124 |
var _this = _possibleConstructorReturn(this, (SimpleXMLParser.__proto__ || Object.getPrototypeOf(SimpleXMLParser)).call(this)); |
|
14125 |
|
|
14126 |
_this._currentFragment = null; |
|
14127 |
_this._stack = null; |
|
14128 |
_this._errorCode = XMLParserErrorCode.NoError; |
|
14129 |
return _this; |
|
14130 |
} |
|
14131 |
|
|
14132 |
_createClass(SimpleXMLParser, [{ |
|
14133 |
key: 'parseFromString', |
|
14134 |
value: function parseFromString(data) { |
|
14135 |
this._currentFragment = []; |
|
14136 |
this._stack = []; |
|
14137 |
this._errorCode = XMLParserErrorCode.NoError; |
|
14138 |
this.parseXml(data); |
|
14139 |
if (this._errorCode !== XMLParserErrorCode.NoError) { |
|
14140 |
return undefined; |
|
14141 |
} |
|
14142 |
|
|
14143 |
var _currentFragment = _slicedToArray(this._currentFragment, 1), |
|
14144 |
documentElement = _currentFragment[0]; |
|
14145 |
|
|
14146 |
if (!documentElement) { |
|
14147 |
return undefined; |
|
14148 |
} |
|
14149 |
return { documentElement: documentElement }; |
|
14150 |
} |
|
14151 |
}, { |
|
14152 |
key: 'onResolveEntity', |
|
14153 |
value: function onResolveEntity(name) { |
|
14154 |
switch (name) { |
|
14155 |
case 'apos': |
|
14156 |
return '\''; |
|
14157 |
} |
|
14158 |
return _get(SimpleXMLParser.prototype.__proto__ || Object.getPrototypeOf(SimpleXMLParser.prototype), 'onResolveEntity', this).call(this, name); |
|
14159 |
} |
|
14160 |
}, { |
|
14161 |
key: 'onText', |
|
14162 |
value: function onText(text) { |
|
14163 |
if (isWhitespaceString(text)) { |
|
14164 |
return; |
|
14165 |
} |
|
14166 |
var node = new SimpleDOMNode('#text', text); |
|
14167 |
this._currentFragment.push(node); |
|
14168 |
} |
|
14169 |
}, { |
|
14170 |
key: 'onCdata', |
|
14171 |
value: function onCdata(text) { |
|
14172 |
var node = new SimpleDOMNode('#text', text); |
|
14173 |
this._currentFragment.push(node); |
|
14174 |
} |
|
14175 |
}, { |
|
14176 |
key: 'onBeginElement', |
|
14177 |
value: function onBeginElement(name, attributes, isEmpty) { |
|
14178 |
var node = new SimpleDOMNode(name); |
|
14179 |
node.childNodes = []; |
|
14180 |
this._currentFragment.push(node); |
|
14181 |
if (isEmpty) { |
|
14182 |
return; |
|
14183 |
} |
|
14184 |
this._stack.push(this._currentFragment); |
|
14185 |
this._currentFragment = node.childNodes; |
|
14186 |
} |
|
14187 |
}, { |
|
14188 |
key: 'onEndElement', |
|
14189 |
value: function onEndElement(name) { |
|
14190 |
this._currentFragment = this._stack.pop(); |
|
14191 |
var lastElement = this._currentFragment[this._currentFragment.length - 1]; |
|
14192 |
for (var i = 0, ii = lastElement.childNodes.length; i < ii; i++) { |
|
14193 |
lastElement.childNodes[i].parentNode = lastElement; |
|
14194 |
} |
|
14195 |
} |
|
14196 |
}, { |
|
14197 |
key: 'onError', |
|
14198 |
value: function onError(code) { |
|
14199 |
this._errorCode = code; |
|
14200 |
} |
|
14201 |
}]); |
|
14202 |
|
|
14203 |
return SimpleXMLParser; |
|
14204 |
}(XMLParserBase); |
|
14205 |
|
|
14206 |
exports.SimpleXMLParser = SimpleXMLParser; |
|
14207 |
|
|
14208 |
/***/ }), |
|
14209 |
/* 143 */ |
|
14210 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
14211 |
|
|
14212 |
"use strict"; |
|
14213 |
|
|
14214 |
|
|
14215 |
Object.defineProperty(exports, "__esModule", { |
|
14216 |
value: true |
|
14217 |
}); |
|
14218 |
exports.PDFDataTransportStream = undefined; |
|
14219 |
|
|
14220 |
var _regenerator = __w_pdfjs_require__(137); |
|
14221 |
|
|
14222 |
var _regenerator2 = _interopRequireDefault(_regenerator); |
|
14223 |
|
|
14224 |
var _util = __w_pdfjs_require__(1); |
|
14225 |
|
|
14226 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
14227 |
|
|
14228 |
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"); }); }; } |
|
14229 |
|
|
14230 |
var PDFDataTransportStream = function PDFDataTransportStreamClosure() { |
|
14231 |
function PDFDataTransportStream(params, pdfDataRangeTransport) { |
|
14232 |
var _this = this; |
|
14233 |
|
|
14234 |
(0, _util.assert)(pdfDataRangeTransport); |
|
14235 |
this._queuedChunks = []; |
|
14236 |
var initialData = params.initialData; |
|
14237 |
if (initialData && initialData.length > 0) { |
|
14238 |
var buffer = new Uint8Array(initialData).buffer; |
|
14239 |
this._queuedChunks.push(buffer); |
|
14240 |
} |
|
14241 |
this._pdfDataRangeTransport = pdfDataRangeTransport; |
|
14242 |
this._isStreamingSupported = !params.disableStream; |
|
14243 |
this._isRangeSupported = !params.disableRange; |
|
14244 |
this._contentLength = params.length; |
|
14245 |
this._fullRequestReader = null; |
|
14246 |
this._rangeReaders = []; |
|
14247 |
this._pdfDataRangeTransport.addRangeListener(function (begin, chunk) { |
|
14248 |
_this._onReceiveData({ |
|
14249 |
begin: begin, |
|
14250 |
chunk: chunk |
|
14251 |
}); |
|
14252 |
}); |
|
14253 |
this._pdfDataRangeTransport.addProgressListener(function (loaded) { |
|
14254 |
_this._onProgress({ loaded: loaded }); |
|
14255 |
}); |
|
14256 |
this._pdfDataRangeTransport.addProgressiveReadListener(function (chunk) { |
|
14257 |
_this._onReceiveData({ chunk: chunk }); |
|
14258 |
}); |
|
14259 |
this._pdfDataRangeTransport.transportReady(); |
|
14260 |
} |
|
14261 |
PDFDataTransportStream.prototype = { |
|
14262 |
_onReceiveData: function PDFDataTransportStream_onReceiveData(args) { |
|
14263 |
var buffer = new Uint8Array(args.chunk).buffer; |
|
14264 |
if (args.begin === undefined) { |
|
14265 |
if (this._fullRequestReader) { |
|
14266 |
this._fullRequestReader._enqueue(buffer); |
|
14267 |
} else { |
|
14268 |
this._queuedChunks.push(buffer); |
|
14269 |
} |
|
14270 |
} else { |
|
14271 |
var found = this._rangeReaders.some(function (rangeReader) { |
|
14272 |
if (rangeReader._begin !== args.begin) { |
|
14273 |
return false; |
|
14274 |
} |
|
14275 |
rangeReader._enqueue(buffer); |
|
14276 |
return true; |
|
14277 |
}); |
|
14278 |
(0, _util.assert)(found); |
|
14279 |
} |
|
14280 |
}, |
|
14281 |
_onProgress: function PDFDataTransportStream_onDataProgress(evt) { |
|
14282 |
if (this._rangeReaders.length > 0) { |
|
14283 |
var firstReader = this._rangeReaders[0]; |
|
14284 |
if (firstReader.onProgress) { |
|
14285 |
firstReader.onProgress({ loaded: evt.loaded }); |
|
14286 |
} |
|
14287 |
} |
|
14288 |
}, |
|
14289 |
_removeRangeReader: function PDFDataTransportStream_removeRangeReader(reader) { |
|
14290 |
var i = this._rangeReaders.indexOf(reader); |
|
14291 |
if (i >= 0) { |
|
14292 |
this._rangeReaders.splice(i, 1); |
|
14293 |
} |
|
14294 |
}, |
|
14295 |
getFullReader: function PDFDataTransportStream_getFullReader() { |
|
14296 |
(0, _util.assert)(!this._fullRequestReader); |
|
14297 |
var queuedChunks = this._queuedChunks; |
|
14298 |
this._queuedChunks = null; |
|
14299 |
return new PDFDataTransportStreamReader(this, queuedChunks); |
|
14300 |
}, |
|
14301 |
getRangeReader: function PDFDataTransportStream_getRangeReader(begin, end) { |
|
14302 |
var reader = new PDFDataTransportStreamRangeReader(this, begin, end); |
|
14303 |
this._pdfDataRangeTransport.requestDataRange(begin, end); |
|
14304 |
this._rangeReaders.push(reader); |
|
14305 |
return reader; |
|
14306 |
}, |
|
14307 |
cancelAllRequests: function PDFDataTransportStream_cancelAllRequests(reason) { |
|
14308 |
if (this._fullRequestReader) { |
|
14309 |
this._fullRequestReader.cancel(reason); |
|
14310 |
} |
|
14311 |
var readers = this._rangeReaders.slice(0); |
|
14312 |
readers.forEach(function (rangeReader) { |
|
14313 |
rangeReader.cancel(reason); |
|
14314 |
}); |
|
14315 |
this._pdfDataRangeTransport.abort(); |
|
14316 |
} |
|
14317 |
}; |
|
14318 |
function PDFDataTransportStreamReader(stream, queuedChunks) { |
|
14319 |
this._stream = stream; |
|
14320 |
this._done = false; |
|
14321 |
this._filename = null; |
|
14322 |
this._queuedChunks = queuedChunks || []; |
|
14323 |
this._requests = []; |
|
14324 |
this._headersReady = Promise.resolve(); |
|
14325 |
stream._fullRequestReader = this; |
|
14326 |
this.onProgress = null; |
|
14327 |
} |
|
14328 |
PDFDataTransportStreamReader.prototype = { |
|
14329 |
_enqueue: function PDFDataTransportStreamReader_enqueue(chunk) { |
|
14330 |
if (this._done) { |
|
14331 |
return; |
|
14332 |
} |
|
14333 |
if (this._requests.length > 0) { |
|
14334 |
var requestCapability = this._requests.shift(); |
|
14335 |
requestCapability.resolve({ |
|
14336 |
value: chunk, |
|
14337 |
done: false |
|
14338 |
}); |
|
14339 |
return; |
|
14340 |
} |
|
14341 |
this._queuedChunks.push(chunk); |
|
14342 |
}, |
|
14343 |
get headersReady() { |
|
14344 |
return this._headersReady; |
|
14345 |
}, |
|
14346 |
get filename() { |
|
14347 |
return this._filename; |
|
14348 |
}, |
|
14349 |
get isRangeSupported() { |
|
14350 |
return this._stream._isRangeSupported; |
|
14351 |
}, |
|
14352 |
get isStreamingSupported() { |
|
14353 |
return this._stream._isStreamingSupported; |
|
14354 |
}, |
|
14355 |
get contentLength() { |
|
14356 |
return this._stream._contentLength; |
|
14357 |
}, |
|
14358 |
read: function () { |
|
14359 |
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() { |
|
14360 |
var chunk, requestCapability; |
|
14361 |
return _regenerator2.default.wrap(function _callee$(_context) { |
|
14362 |
while (1) { |
|
14363 |
switch (_context.prev = _context.next) { |
|
14364 |
case 0: |
|
14365 |
if (!(this._queuedChunks.length > 0)) { |
|
14366 |
_context.next = 3; |
|
14367 |
break; |
|
14368 |
} |
|
14369 |
|
|
14370 |
chunk = this._queuedChunks.shift(); |
|
14371 |
return _context.abrupt('return', { |
|
14372 |
value: chunk, |
|
14373 |
done: false |
|
14374 |
}); |
|
14375 |
|
|
14376 |
case 3: |
|
14377 |
if (!this._done) { |
|
14378 |
_context.next = 5; |
|
14379 |
break; |
|
14380 |
} |
|
14381 |
|
|
14382 |
return _context.abrupt('return', { |
|
14383 |
value: undefined, |
|
14384 |
done: true |
|
14385 |
}); |
|
14386 |
|
|
14387 |
case 5: |
|
14388 |
requestCapability = (0, _util.createPromiseCapability)(); |
|
14389 |
|
|
14390 |
this._requests.push(requestCapability); |
|
14391 |
return _context.abrupt('return', requestCapability.promise); |
|
14392 |
|
|
14393 |
case 8: |
|
14394 |
case 'end': |
|
14395 |
return _context.stop(); |
|
14396 |
} |
|
14397 |
} |
|
14398 |
}, _callee, this); |
|
14399 |
})); |
|
14400 |
|
|
14401 |
function read() { |
|
14402 |
return _ref.apply(this, arguments); |
|
14403 |
} |
|
14404 |
|
|
14405 |
return read; |
|
14406 |
}(), |
|
14407 |
|
|
14408 |
cancel: function PDFDataTransportStreamReader_cancel(reason) { |
|
14409 |
this._done = true; |
|
14410 |
this._requests.forEach(function (requestCapability) { |
|
14411 |
requestCapability.resolve({ |
|
14412 |
value: undefined, |
|
14413 |
done: true |
|
14414 |
}); |
|
14415 |
}); |
|
14416 |
this._requests = []; |
|
14417 |
} |
|
14418 |
}; |
|
14419 |
function PDFDataTransportStreamRangeReader(stream, begin, end) { |
|
14420 |
this._stream = stream; |
|
14421 |
this._begin = begin; |
|
14422 |
this._end = end; |
|
14423 |
this._queuedChunk = null; |
|
14424 |
this._requests = []; |
|
14425 |
this._done = false; |
|
14426 |
this.onProgress = null; |
|
14427 |
} |
|
14428 |
PDFDataTransportStreamRangeReader.prototype = { |
|
14429 |
_enqueue: function PDFDataTransportStreamRangeReader_enqueue(chunk) { |
|
14430 |
if (this._done) { |
|
14431 |
return; |
|
14432 |
} |
|
14433 |
if (this._requests.length === 0) { |
|
14434 |
this._queuedChunk = chunk; |
|
14435 |
} else { |
|
14436 |
var requestsCapability = this._requests.shift(); |
|
14437 |
requestsCapability.resolve({ |
|
14438 |
value: chunk, |
|
14439 |
done: false |
|
14440 |
}); |
|
14441 |
this._requests.forEach(function (requestCapability) { |
|
14442 |
requestCapability.resolve({ |
|
14443 |
value: undefined, |
|
14444 |
done: true |
|
14445 |
}); |
|
14446 |
}); |
|
14447 |
this._requests = []; |
|
14448 |
} |
|
14449 |
this._done = true; |
|
14450 |
this._stream._removeRangeReader(this); |
|
14451 |
}, |
|
14452 |
get isStreamingSupported() { |
|
14453 |
return false; |
|
14454 |
}, |
|
14455 |
read: function () { |
|
14456 |
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { |
|
14457 |
var chunk, requestCapability; |
|
14458 |
return _regenerator2.default.wrap(function _callee2$(_context2) { |
|
14459 |
while (1) { |
|
14460 |
switch (_context2.prev = _context2.next) { |
|
14461 |
case 0: |
|
14462 |
if (!this._queuedChunk) { |
|
14463 |
_context2.next = 4; |
|
14464 |
break; |
|
14465 |
} |
|
14466 |
|
|
14467 |
chunk = this._queuedChunk; |
|
14468 |
|
|
14469 |
this._queuedChunk = null; |
|
14470 |
return _context2.abrupt('return', { |
|
14471 |
value: chunk, |
|
14472 |
done: false |
|
14473 |
}); |
|
14474 |
|
|
14475 |
case 4: |
|
14476 |
if (!this._done) { |
|
14477 |
_context2.next = 6; |
|
14478 |
break; |
|
14479 |
} |
|
14480 |
|
|
14481 |
return _context2.abrupt('return', { |
|
14482 |
value: undefined, |
|
14483 |
done: true |
|
14484 |
}); |
|
14485 |
|
|
14486 |
case 6: |
|
14487 |
requestCapability = (0, _util.createPromiseCapability)(); |
|
14488 |
|
|
14489 |
this._requests.push(requestCapability); |
|
14490 |
return _context2.abrupt('return', requestCapability.promise); |
|
14491 |
|
|
14492 |
case 9: |
|
14493 |
case 'end': |
|
14494 |
return _context2.stop(); |
|
14495 |
} |
|
14496 |
} |
|
14497 |
}, _callee2, this); |
|
14498 |
})); |
|
14499 |
|
|
14500 |
function read() { |
|
14501 |
return _ref2.apply(this, arguments); |
|
14502 |
} |
|
14503 |
|
|
14504 |
return read; |
|
14505 |
}(), |
|
14506 |
|
|
14507 |
cancel: function PDFDataTransportStreamRangeReader_cancel(reason) { |
|
14508 |
this._done = true; |
|
14509 |
this._requests.forEach(function (requestCapability) { |
|
14510 |
requestCapability.resolve({ |
|
14511 |
value: undefined, |
|
14512 |
done: true |
|
14513 |
}); |
|
14514 |
}); |
|
14515 |
this._requests = []; |
|
14516 |
this._stream._removeRangeReader(this); |
|
14517 |
} |
|
14518 |
}; |
|
14519 |
return PDFDataTransportStream; |
|
14520 |
}(); |
|
14521 |
exports.PDFDataTransportStream = PDFDataTransportStream; |
|
14522 |
|
|
14523 |
/***/ }), |
|
14524 |
/* 144 */ |
|
14525 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
14526 |
|
|
14527 |
"use strict"; |
|
14528 |
|
|
14529 |
|
|
14530 |
Object.defineProperty(exports, "__esModule", { |
|
14531 |
value: true |
|
14532 |
}); |
|
14533 |
exports.WebGLContext = undefined; |
|
14534 |
|
|
14535 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
|
14536 |
|
|
14537 |
var _util = __w_pdfjs_require__(1); |
|
14538 |
|
|
14539 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
14540 |
|
|
14541 |
var WebGLContext = function () { |
|
14542 |
function WebGLContext(_ref) { |
|
14543 |
var _ref$enable = _ref.enable, |
|
14544 |
enable = _ref$enable === undefined ? false : _ref$enable; |
|
14545 |
|
|
14546 |
_classCallCheck(this, WebGLContext); |
|
14547 |
|
|
14548 |
this._enabled = enable === true; |
|
14549 |
} |
|
14550 |
|
|
14551 |
_createClass(WebGLContext, [{ |
|
14552 |
key: 'composeSMask', |
|
14553 |
value: function composeSMask(_ref2) { |
|
14554 |
var layer = _ref2.layer, |
|
14555 |
mask = _ref2.mask, |
|
14556 |
properties = _ref2.properties; |
|
14557 |
|
|
14558 |
return WebGLUtils.composeSMask(layer, mask, properties); |
|
14559 |
} |
|
14560 |
}, { |
|
14561 |
key: 'drawFigures', |
|
14562 |
value: function drawFigures(_ref3) { |
|
14563 |
var width = _ref3.width, |
|
14564 |
height = _ref3.height, |
|
14565 |
backgroundColor = _ref3.backgroundColor, |
|
14566 |
figures = _ref3.figures, |
|
14567 |
context = _ref3.context; |
|
14568 |
|
|
14569 |
return WebGLUtils.drawFigures(width, height, backgroundColor, figures, context); |
|
14570 |
} |
|
14571 |
}, { |
|
14572 |
key: 'clear', |
|
14573 |
value: function clear() { |
|
14574 |
WebGLUtils.cleanup(); |
|
14575 |
} |
|
14576 |
}, { |
|
14577 |
key: 'isEnabled', |
|
14578 |
get: function get() { |
|
14579 |
var enabled = this._enabled; |
|
14580 |
if (enabled) { |
|
14581 |
enabled = WebGLUtils.tryInitGL(); |
|
14582 |
} |
|
14583 |
return (0, _util.shadow)(this, 'isEnabled', enabled); |
|
14584 |
} |
|
14585 |
}]); |
|
14586 |
|
|
14587 |
return WebGLContext; |
|
14588 |
}(); |
|
14589 |
|
|
14590 |
var WebGLUtils = function WebGLUtilsClosure() { |
|
14591 |
function loadShader(gl, code, shaderType) { |
|
14592 |
var shader = gl.createShader(shaderType); |
|
14593 |
gl.shaderSource(shader, code); |
|
14594 |
gl.compileShader(shader); |
|
14595 |
var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS); |
|
14596 |
if (!compiled) { |
|
14597 |
var errorMsg = gl.getShaderInfoLog(shader); |
|
14598 |
throw new Error('Error during shader compilation: ' + errorMsg); |
|
14599 |
} |
|
14600 |
return shader; |
|
14601 |
} |
|
14602 |
function createVertexShader(gl, code) { |
|
14603 |
return loadShader(gl, code, gl.VERTEX_SHADER); |
|
14604 |
} |
|
14605 |
function createFragmentShader(gl, code) { |
|
14606 |
return loadShader(gl, code, gl.FRAGMENT_SHADER); |
|
14607 |
} |
|
14608 |
function createProgram(gl, shaders) { |
|
14609 |
var program = gl.createProgram(); |
|
14610 |
for (var i = 0, ii = shaders.length; i < ii; ++i) { |
|
14611 |
gl.attachShader(program, shaders[i]); |
|
14612 |
} |
|
14613 |
gl.linkProgram(program); |
|
14614 |
var linked = gl.getProgramParameter(program, gl.LINK_STATUS); |
|
14615 |
if (!linked) { |
|
14616 |
var errorMsg = gl.getProgramInfoLog(program); |
|
14617 |
throw new Error('Error during program linking: ' + errorMsg); |
|
14618 |
} |
|
14619 |
return program; |
|
14620 |
} |
|
14621 |
function createTexture(gl, image, textureId) { |
|
14622 |
gl.activeTexture(textureId); |
|
14623 |
var texture = gl.createTexture(); |
|
14624 |
gl.bindTexture(gl.TEXTURE_2D, texture); |
|
14625 |
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE); |
|
14626 |
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE); |
|
14627 |
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); |
|
14628 |
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); |
|
14629 |
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image); |
|
14630 |
return texture; |
|
14631 |
} |
|
14632 |
var currentGL, currentCanvas; |
|
14633 |
function generateGL() { |
|
14634 |
if (currentGL) { |
|
14635 |
return; |
|
14636 |
} |
|
14637 |
currentCanvas = document.createElement('canvas'); |
|
14638 |
currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false }); |
|
14639 |
} |
|
14640 |
var smaskVertexShaderCode = '\ |
|
14641 |
attribute vec2 a_position; \ |
|
14642 |
attribute vec2 a_texCoord; \ |
|
14643 |
\ |
|
14644 |
uniform vec2 u_resolution; \ |
|
14645 |
\ |
|
14646 |
varying vec2 v_texCoord; \ |
|
14647 |
\ |
|
14648 |
void main() { \ |
|
14649 |
vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \ |
|
14650 |
gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \ |
|
14651 |
\ |
|
14652 |
v_texCoord = a_texCoord; \ |
|
14653 |
} '; |
|
14654 |
var smaskFragmentShaderCode = '\ |
|
14655 |
precision mediump float; \ |
|
14656 |
\ |
|
14657 |
uniform vec4 u_backdrop; \ |
|
14658 |
uniform int u_subtype; \ |
|
14659 |
uniform sampler2D u_image; \ |
|
14660 |
uniform sampler2D u_mask; \ |
|
14661 |
\ |
|
14662 |
varying vec2 v_texCoord; \ |
|
14663 |
\ |
|
14664 |
void main() { \ |
|
14665 |
vec4 imageColor = texture2D(u_image, v_texCoord); \ |
|
14666 |
vec4 maskColor = texture2D(u_mask, v_texCoord); \ |
|
14667 |
if (u_backdrop.a > 0.0) { \ |
|
14668 |
maskColor.rgb = maskColor.rgb * maskColor.a + \ |
|
14669 |
u_backdrop.rgb * (1.0 - maskColor.a); \ |
|
14670 |
} \ |
|
14671 |
float lum; \ |
|
14672 |
if (u_subtype == 0) { \ |
|
14673 |
lum = maskColor.a; \ |
|
14674 |
} else { \ |
|
14675 |
lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \ |
|
14676 |
maskColor.b * 0.11; \ |
|
14677 |
} \ |
|
14678 |
imageColor.a *= lum; \ |
|
14679 |
imageColor.rgb *= imageColor.a; \ |
|
14680 |
gl_FragColor = imageColor; \ |
|
14681 |
} '; |
|
14682 |
var smaskCache = null; |
|
14683 |
function initSmaskGL() { |
|
14684 |
var canvas, gl; |
|
14685 |
generateGL(); |
|
14686 |
canvas = currentCanvas; |
|
14687 |
currentCanvas = null; |
|
14688 |
gl = currentGL; |
|
14689 |
currentGL = null; |
|
14690 |
var vertexShader = createVertexShader(gl, smaskVertexShaderCode); |
|
14691 |
var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode); |
|
14692 |
var program = createProgram(gl, [vertexShader, fragmentShader]); |
|
14693 |
gl.useProgram(program); |
|
14694 |
var cache = {}; |
|
14695 |
cache.gl = gl; |
|
14696 |
cache.canvas = canvas; |
|
14697 |
cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution'); |
|
14698 |
cache.positionLocation = gl.getAttribLocation(program, 'a_position'); |
|
14699 |
cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop'); |
|
14700 |
cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype'); |
|
14701 |
var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord'); |
|
14702 |
var texLayerLocation = gl.getUniformLocation(program, 'u_image'); |
|
14703 |
var texMaskLocation = gl.getUniformLocation(program, 'u_mask'); |
|
14704 |
var texCoordBuffer = gl.createBuffer(); |
|
14705 |
gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer); |
|
14706 |
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0]), gl.STATIC_DRAW); |
|
14707 |
gl.enableVertexAttribArray(texCoordLocation); |
|
14708 |
gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0); |
|
14709 |
gl.uniform1i(texLayerLocation, 0); |
|
14710 |
gl.uniform1i(texMaskLocation, 1); |
|
14711 |
smaskCache = cache; |
|
14712 |
} |
|
14713 |
function composeSMask(layer, mask, properties) { |
|
14714 |
var width = layer.width, |
|
14715 |
height = layer.height; |
|
14716 |
if (!smaskCache) { |
|
14717 |
initSmaskGL(); |
|
14718 |
} |
|
14719 |
var cache = smaskCache, |
|
14720 |
canvas = cache.canvas, |
|
14721 |
gl = cache.gl; |
|
14722 |
canvas.width = width; |
|
14723 |
canvas.height = height; |
|
14724 |
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); |
|
14725 |
gl.uniform2f(cache.resolutionLocation, width, height); |
|
14726 |
if (properties.backdrop) { |
|
14727 |
gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1); |
|
14728 |
} else { |
|
14729 |
gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0); |
|
14730 |
} |
|
14731 |
gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0); |
|
14732 |
var texture = createTexture(gl, layer, gl.TEXTURE0); |
|
14733 |
var maskTexture = createTexture(gl, mask, gl.TEXTURE1); |
|
14734 |
var buffer = gl.createBuffer(); |
|
14735 |
gl.bindBuffer(gl.ARRAY_BUFFER, buffer); |
|
14736 |
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([0, 0, width, 0, 0, height, 0, height, width, 0, width, height]), gl.STATIC_DRAW); |
|
14737 |
gl.enableVertexAttribArray(cache.positionLocation); |
|
14738 |
gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0); |
|
14739 |
gl.clearColor(0, 0, 0, 0); |
|
14740 |
gl.enable(gl.BLEND); |
|
14741 |
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA); |
|
14742 |
gl.clear(gl.COLOR_BUFFER_BIT); |
|
14743 |
gl.drawArrays(gl.TRIANGLES, 0, 6); |
|
14744 |
gl.flush(); |
|
14745 |
gl.deleteTexture(texture); |
|
14746 |
gl.deleteTexture(maskTexture); |
|
14747 |
gl.deleteBuffer(buffer); |
|
14748 |
return canvas; |
|
14749 |
} |
|
14750 |
var figuresVertexShaderCode = '\ |
|
14751 |
attribute vec2 a_position; \ |
|
14752 |
attribute vec3 a_color; \ |
|
14753 |
\ |
|
14754 |
uniform vec2 u_resolution; \ |
|
14755 |
uniform vec2 u_scale; \ |
|
14756 |
uniform vec2 u_offset; \ |
|
14757 |
\ |
|
14758 |
varying vec4 v_color; \ |
|
14759 |
\ |
|
14760 |
void main() { \ |
|
14761 |
vec2 position = (a_position + u_offset) * u_scale; \ |
|
14762 |
vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \ |
|
14763 |
gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \ |
|
14764 |
\ |
|
14765 |
v_color = vec4(a_color / 255.0, 1.0); \ |
|
14766 |
} '; |
|
14767 |
var figuresFragmentShaderCode = '\ |
|
14768 |
precision mediump float; \ |
|
14769 |
\ |
|
14770 |
varying vec4 v_color; \ |
|
14771 |
\ |
|
14772 |
void main() { \ |
|
14773 |
gl_FragColor = v_color; \ |
|
14774 |
} '; |
|
14775 |
var figuresCache = null; |
|
14776 |
function initFiguresGL() { |
|
14777 |
var canvas, gl; |
|
14778 |
generateGL(); |
|
14779 |
canvas = currentCanvas; |
|
14780 |
currentCanvas = null; |
|
14781 |
gl = currentGL; |
|
14782 |
currentGL = null; |
|
14783 |
var vertexShader = createVertexShader(gl, figuresVertexShaderCode); |
|
14784 |
var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode); |
|
14785 |
var program = createProgram(gl, [vertexShader, fragmentShader]); |
|
14786 |
gl.useProgram(program); |
|
14787 |
var cache = {}; |
|
14788 |
cache.gl = gl; |
|
14789 |
cache.canvas = canvas; |
|
14790 |
cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution'); |
|
14791 |
cache.scaleLocation = gl.getUniformLocation(program, 'u_scale'); |
|
14792 |
cache.offsetLocation = gl.getUniformLocation(program, 'u_offset'); |
|
14793 |
cache.positionLocation = gl.getAttribLocation(program, 'a_position'); |
|
14794 |
cache.colorLocation = gl.getAttribLocation(program, 'a_color'); |
|
14795 |
figuresCache = cache; |
|
14796 |
} |
|
14797 |
function drawFigures(width, height, backgroundColor, figures, context) { |
|
14798 |
if (!figuresCache) { |
|
14799 |
initFiguresGL(); |
|
14800 |
} |
|
14801 |
var cache = figuresCache, |
|
14802 |
canvas = cache.canvas, |
|
14803 |
gl = cache.gl; |
|
14804 |
canvas.width = width; |
|
14805 |
canvas.height = height; |
|
14806 |
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight); |
|
14807 |
gl.uniform2f(cache.resolutionLocation, width, height); |
|
14808 |
var count = 0; |
|
14809 |
var i, ii, rows; |
|
14810 |
for (i = 0, ii = figures.length; i < ii; i++) { |
|
14811 |
switch (figures[i].type) { |
|
14812 |
case 'lattice': |
|
14813 |
rows = figures[i].coords.length / figures[i].verticesPerRow | 0; |
|
14814 |
count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6; |
|
14815 |
break; |
|
14816 |
case 'triangles': |
|
14817 |
count += figures[i].coords.length; |
|
14818 |
break; |
|
14819 |
} |
|
14820 |
} |
|
14821 |
var coords = new Float32Array(count * 2); |
|
14822 |
var colors = new Uint8Array(count * 3); |
|
14823 |
var coordsMap = context.coords, |
|
14824 |
colorsMap = context.colors; |
|
14825 |
var pIndex = 0, |
|
14826 |
cIndex = 0; |
|
14827 |
for (i = 0, ii = figures.length; i < ii; i++) { |
|
14828 |
var figure = figures[i], |
|
14829 |
ps = figure.coords, |
|
14830 |
cs = figure.colors; |
|
14831 |
switch (figure.type) { |
|
14832 |
case 'lattice': |
|
14833 |
var cols = figure.verticesPerRow; |
|
14834 |
rows = ps.length / cols | 0; |
|
14835 |
for (var row = 1; row < rows; row++) { |
|
14836 |
var offset = row * cols + 1; |
|
14837 |
for (var col = 1; col < cols; col++, offset++) { |
|
14838 |
coords[pIndex] = coordsMap[ps[offset - cols - 1]]; |
|
14839 |
coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1]; |
|
14840 |
coords[pIndex + 2] = coordsMap[ps[offset - cols]]; |
|
14841 |
coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1]; |
|
14842 |
coords[pIndex + 4] = coordsMap[ps[offset - 1]]; |
|
14843 |
coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1]; |
|
14844 |
colors[cIndex] = colorsMap[cs[offset - cols - 1]]; |
|
14845 |
colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1]; |
|
14846 |
colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2]; |
|
14847 |
colors[cIndex + 3] = colorsMap[cs[offset - cols]]; |
|
14848 |
colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1]; |
|
14849 |
colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2]; |
|
14850 |
colors[cIndex + 6] = colorsMap[cs[offset - 1]]; |
|
14851 |
colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1]; |
|
14852 |
colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2]; |
|
14853 |
coords[pIndex + 6] = coords[pIndex + 2]; |
|
14854 |
coords[pIndex + 7] = coords[pIndex + 3]; |
|
14855 |
coords[pIndex + 8] = coords[pIndex + 4]; |
|
14856 |
coords[pIndex + 9] = coords[pIndex + 5]; |
|
14857 |
coords[pIndex + 10] = coordsMap[ps[offset]]; |
|
14858 |
coords[pIndex + 11] = coordsMap[ps[offset] + 1]; |
|
14859 |
colors[cIndex + 9] = colors[cIndex + 3]; |
|
14860 |
colors[cIndex + 10] = colors[cIndex + 4]; |
|
14861 |
colors[cIndex + 11] = colors[cIndex + 5]; |
|
14862 |
colors[cIndex + 12] = colors[cIndex + 6]; |
|
14863 |
colors[cIndex + 13] = colors[cIndex + 7]; |
|
14864 |
colors[cIndex + 14] = colors[cIndex + 8]; |
|
14865 |
colors[cIndex + 15] = colorsMap[cs[offset]]; |
|
14866 |
colors[cIndex + 16] = colorsMap[cs[offset] + 1]; |
|
14867 |
colors[cIndex + 17] = colorsMap[cs[offset] + 2]; |
|
14868 |
pIndex += 12; |
|
14869 |
cIndex += 18; |
|
14870 |
} |
|
14871 |
} |
|
14872 |
break; |
|
14873 |
case 'triangles': |
|
14874 |
for (var j = 0, jj = ps.length; j < jj; j++) { |
|
14875 |
coords[pIndex] = coordsMap[ps[j]]; |
|
14876 |
coords[pIndex + 1] = coordsMap[ps[j] + 1]; |
|
14877 |
colors[cIndex] = colorsMap[cs[j]]; |
|
14878 |
colors[cIndex + 1] = colorsMap[cs[j] + 1]; |
|
14879 |
colors[cIndex + 2] = colorsMap[cs[j] + 2]; |
|
14880 |
pIndex += 2; |
|
14881 |
cIndex += 3; |
|
14882 |
} |
|
14883 |
break; |
|
14884 |
} |
|
14885 |
} |
|
14886 |
if (backgroundColor) { |
|
14887 |
gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0); |
|
14888 |
} else { |
|
14889 |
gl.clearColor(0, 0, 0, 0); |
|
14890 |
} |
|
14891 |
gl.clear(gl.COLOR_BUFFER_BIT); |
|
14892 |
var coordsBuffer = gl.createBuffer(); |
|
14893 |
gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer); |
|
14894 |
gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW); |
|
14895 |
gl.enableVertexAttribArray(cache.positionLocation); |
|
14896 |
gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0); |
|
14897 |
var colorsBuffer = gl.createBuffer(); |
|
14898 |
gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer); |
|
14899 |
gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW); |
|
14900 |
gl.enableVertexAttribArray(cache.colorLocation); |
|
14901 |
gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0); |
|
14902 |
gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY); |
|
14903 |
gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY); |
|
14904 |
gl.drawArrays(gl.TRIANGLES, 0, count); |
|
14905 |
gl.flush(); |
|
14906 |
gl.deleteBuffer(coordsBuffer); |
|
14907 |
gl.deleteBuffer(colorsBuffer); |
|
14908 |
return canvas; |
|
14909 |
} |
|
14910 |
return { |
|
14911 |
tryInitGL: function tryInitGL() { |
|
14912 |
try { |
|
14913 |
generateGL(); |
|
14914 |
return !!currentGL; |
|
14915 |
} catch (ex) {} |
|
14916 |
return false; |
|
14917 |
}, |
|
14918 |
|
|
14919 |
composeSMask: composeSMask, |
|
14920 |
drawFigures: drawFigures, |
|
14921 |
cleanup: function cleanup() { |
|
14922 |
if (smaskCache && smaskCache.canvas) { |
|
14923 |
smaskCache.canvas.width = 0; |
|
14924 |
smaskCache.canvas.height = 0; |
|
14925 |
} |
|
14926 |
if (figuresCache && figuresCache.canvas) { |
|
14927 |
figuresCache.canvas.width = 0; |
|
14928 |
figuresCache.canvas.height = 0; |
|
14929 |
} |
|
14930 |
smaskCache = null; |
|
14931 |
figuresCache = null; |
|
14932 |
} |
|
14933 |
}; |
|
14934 |
}(); |
|
14935 |
exports.WebGLContext = WebGLContext; |
|
14936 |
|
|
14937 |
/***/ }), |
|
14938 |
/* 145 */ |
|
14939 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
14940 |
|
|
14941 |
"use strict"; |
|
14942 |
|
|
14943 |
|
|
14944 |
Object.defineProperty(exports, "__esModule", { |
|
14945 |
value: true |
|
14946 |
}); |
|
14947 |
exports.renderTextLayer = undefined; |
|
14948 |
|
|
14949 |
var _util = __w_pdfjs_require__(1); |
|
14950 |
|
|
14951 |
var _global_scope = __w_pdfjs_require__(3); |
|
14952 |
|
|
14953 |
var _global_scope2 = _interopRequireDefault(_global_scope); |
|
14954 |
|
|
14955 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
14956 |
|
|
14957 |
var renderTextLayer = function renderTextLayerClosure() { |
|
14958 |
var MAX_TEXT_DIVS_TO_RENDER = 100000; |
|
14959 |
var NonWhitespaceRegexp = /\S/; |
|
14960 |
function isAllWhitespace(str) { |
|
14961 |
return !NonWhitespaceRegexp.test(str); |
|
14962 |
} |
|
14963 |
var styleBuf = ['left: ', 0, 'px; top: ', 0, 'px; font-size: ', 0, 'px; font-family: ', '', ';']; |
|
14964 |
function appendText(task, geom, styles) { |
|
14965 |
var textDiv = document.createElement('div'); |
|
14966 |
var textDivProperties = { |
|
14967 |
style: null, |
|
14968 |
angle: 0, |
|
14969 |
canvasWidth: 0, |
|
14970 |
isWhitespace: false, |
|
14971 |
originalTransform: null, |
|
14972 |
paddingBottom: 0, |
|
14973 |
paddingLeft: 0, |
|
14974 |
paddingRight: 0, |
|
14975 |
paddingTop: 0, |
|
14976 |
scale: 1 |
|
14977 |
}; |
|
14978 |
task._textDivs.push(textDiv); |
|
14979 |
if (isAllWhitespace(geom.str)) { |
|
14980 |
textDivProperties.isWhitespace = true; |
|
14981 |
task._textDivProperties.set(textDiv, textDivProperties); |
|
14982 |
return; |
|
14983 |
} |
|
14984 |
var tx = _util.Util.transform(task._viewport.transform, geom.transform); |
|
14985 |
var angle = Math.atan2(tx[1], tx[0]); |
|
14986 |
var style = styles[geom.fontName]; |
|
14987 |
if (style.vertical) { |
|
14988 |
angle += Math.PI / 2; |
|
14989 |
} |
|
14990 |
var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]); |
|
14991 |
var fontAscent = fontHeight; |
|
14992 |
if (style.ascent) { |
|
14993 |
fontAscent = style.ascent * fontAscent; |
|
14994 |
} else if (style.descent) { |
|
14995 |
fontAscent = (1 + style.descent) * fontAscent; |
|
14996 |
} |
|
14997 |
var left; |
|
14998 |
var top; |
|
14999 |
if (angle === 0) { |
|
15000 |
left = tx[4]; |
|
15001 |
top = tx[5] - fontAscent; |
|
15002 |
} else { |
|
15003 |
left = tx[4] + fontAscent * Math.sin(angle); |
|
15004 |
top = tx[5] - fontAscent * Math.cos(angle); |
|
15005 |
} |
|
15006 |
styleBuf[1] = left; |
|
15007 |
styleBuf[3] = top; |
|
15008 |
styleBuf[5] = fontHeight; |
|
15009 |
styleBuf[7] = style.fontFamily; |
|
15010 |
textDivProperties.style = styleBuf.join(''); |
|
15011 |
textDiv.setAttribute('style', textDivProperties.style); |
|
15012 |
textDiv.textContent = geom.str; |
|
15013 |
if (task._fontInspectorEnabled) { |
|
15014 |
textDiv.dataset.fontName = geom.fontName; |
|
15015 |
} |
|
15016 |
if (angle !== 0) { |
|
15017 |
textDivProperties.angle = angle * (180 / Math.PI); |
|
15018 |
} |
|
15019 |
if (geom.str.length > 1) { |
|
15020 |
if (style.vertical) { |
|
15021 |
textDivProperties.canvasWidth = geom.height * task._viewport.scale; |
|
15022 |
} else { |
|
15023 |
textDivProperties.canvasWidth = geom.width * task._viewport.scale; |
|
15024 |
} |
|
15025 |
} |
|
15026 |
task._textDivProperties.set(textDiv, textDivProperties); |
|
15027 |
if (task._textContentStream) { |
|
15028 |
task._layoutText(textDiv); |
|
15029 |
} |
|
15030 |
if (task._enhanceTextSelection) { |
|
15031 |
var angleCos = 1, |
|
15032 |
angleSin = 0; |
|
15033 |
if (angle !== 0) { |
|
15034 |
angleCos = Math.cos(angle); |
|
15035 |
angleSin = Math.sin(angle); |
|
15036 |
} |
|
15037 |
var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale; |
|
15038 |
var divHeight = fontHeight; |
|
15039 |
var m, b; |
|
15040 |
if (angle !== 0) { |
|
15041 |
m = [angleCos, angleSin, -angleSin, angleCos, left, top]; |
|
15042 |
b = _util.Util.getAxialAlignedBoundingBox([0, 0, divWidth, divHeight], m); |
|
15043 |
} else { |
|
15044 |
b = [left, top, left + divWidth, top + divHeight]; |
|
15045 |
} |
|
15046 |
task._bounds.push({ |
|
15047 |
left: b[0], |
|
15048 |
top: b[1], |
|
15049 |
right: b[2], |
|
15050 |
bottom: b[3], |
|
15051 |
div: textDiv, |
|
15052 |
size: [divWidth, divHeight], |
|
15053 |
m: m |
|
15054 |
}); |
|
15055 |
} |
|
15056 |
} |
|
15057 |
function render(task) { |
|
15058 |
if (task._canceled) { |
|
15059 |
return; |
|
15060 |
} |
|
15061 |
var textDivs = task._textDivs; |
|
15062 |
var capability = task._capability; |
|
15063 |
var textDivsLength = textDivs.length; |
|
15064 |
if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) { |
|
15065 |
task._renderingDone = true; |
|
15066 |
capability.resolve(); |
|
15067 |
return; |
|
15068 |
} |
|
15069 |
if (!task._textContentStream) { |
|
15070 |
for (var i = 0; i < textDivsLength; i++) { |
|
15071 |
task._layoutText(textDivs[i]); |
|
15072 |
} |
|
15073 |
} |
|
15074 |
task._renderingDone = true; |
|
15075 |
capability.resolve(); |
|
15076 |
} |
|
15077 |
function expand(task) { |
|
15078 |
var bounds = task._bounds; |
|
15079 |
var viewport = task._viewport; |
|
15080 |
var expanded = expandBounds(viewport.width, viewport.height, bounds); |
|
15081 |
for (var i = 0; i < expanded.length; i++) { |
|
15082 |
var div = bounds[i].div; |
|
15083 |
var divProperties = task._textDivProperties.get(div); |
|
15084 |
if (divProperties.angle === 0) { |
|
15085 |
divProperties.paddingLeft = bounds[i].left - expanded[i].left; |
|
15086 |
divProperties.paddingTop = bounds[i].top - expanded[i].top; |
|
15087 |
divProperties.paddingRight = expanded[i].right - bounds[i].right; |
|
15088 |
divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom; |
|
15089 |
task._textDivProperties.set(div, divProperties); |
|
15090 |
continue; |
|
15091 |
} |
|
15092 |
var e = expanded[i], |
|
15093 |
b = bounds[i]; |
|
15094 |
var m = b.m, |
|
15095 |
c = m[0], |
|
15096 |
s = m[1]; |
|
15097 |
var points = [[0, 0], [0, b.size[1]], [b.size[0], 0], b.size]; |
|
15098 |
var ts = new Float64Array(64); |
|
15099 |
points.forEach(function (p, i) { |
|
15100 |
var t = _util.Util.applyTransform(p, m); |
|
15101 |
ts[i + 0] = c && (e.left - t[0]) / c; |
|
15102 |
ts[i + 4] = s && (e.top - t[1]) / s; |
|
15103 |
ts[i + 8] = c && (e.right - t[0]) / c; |
|
15104 |
ts[i + 12] = s && (e.bottom - t[1]) / s; |
|
15105 |
ts[i + 16] = s && (e.left - t[0]) / -s; |
|
15106 |
ts[i + 20] = c && (e.top - t[1]) / c; |
|
15107 |
ts[i + 24] = s && (e.right - t[0]) / -s; |
|
15108 |
ts[i + 28] = c && (e.bottom - t[1]) / c; |
|
15109 |
ts[i + 32] = c && (e.left - t[0]) / -c; |
|
15110 |
ts[i + 36] = s && (e.top - t[1]) / -s; |
|
15111 |
ts[i + 40] = c && (e.right - t[0]) / -c; |
|
15112 |
ts[i + 44] = s && (e.bottom - t[1]) / -s; |
|
15113 |
ts[i + 48] = s && (e.left - t[0]) / s; |
|
15114 |
ts[i + 52] = c && (e.top - t[1]) / -c; |
|
15115 |
ts[i + 56] = s && (e.right - t[0]) / s; |
|
15116 |
ts[i + 60] = c && (e.bottom - t[1]) / -c; |
|
15117 |
}); |
|
15118 |
var findPositiveMin = function findPositiveMin(ts, offset, count) { |
|
15119 |
var result = 0; |
|
15120 |
for (var i = 0; i < count; i++) { |
|
15121 |
var t = ts[offset++]; |
|
15122 |
if (t > 0) { |
|
15123 |
result = result ? Math.min(t, result) : t; |
|
15124 |
} |
|
15125 |
} |
|
15126 |
return result; |
|
15127 |
}; |
|
15128 |
var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s)); |
|
15129 |
divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale; |
|
15130 |
divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale; |
|
15131 |
divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale; |
|
15132 |
divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale; |
|
15133 |
task._textDivProperties.set(div, divProperties); |
|
15134 |
} |
|
15135 |
} |
|
15136 |
function expandBounds(width, height, boxes) { |
|
15137 |
var bounds = boxes.map(function (box, i) { |
|
15138 |
return { |
|
15139 |
x1: box.left, |
|
15140 |
y1: box.top, |
|
15141 |
x2: box.right, |
|
15142 |
y2: box.bottom, |
|
15143 |
index: i, |
|
15144 |
x1New: undefined, |
|
15145 |
x2New: undefined |
|
15146 |
}; |
|
15147 |
}); |
|
15148 |
expandBoundsLTR(width, bounds); |
|
15149 |
var expanded = new Array(boxes.length); |
|
15150 |
bounds.forEach(function (b) { |
|
15151 |
var i = b.index; |
|
15152 |
expanded[i] = { |
|
15153 |
left: b.x1New, |
|
15154 |
top: 0, |
|
15155 |
right: b.x2New, |
|
15156 |
bottom: 0 |
|
15157 |
}; |
|
15158 |
}); |
|
15159 |
boxes.map(function (box, i) { |
|
15160 |
var e = expanded[i], |
|
15161 |
b = bounds[i]; |
|
15162 |
b.x1 = box.top; |
|
15163 |
b.y1 = width - e.right; |
|
15164 |
b.x2 = box.bottom; |
|
15165 |
b.y2 = width - e.left; |
|
15166 |
b.index = i; |
|
15167 |
b.x1New = undefined; |
|
15168 |
b.x2New = undefined; |
|
15169 |
}); |
|
15170 |
expandBoundsLTR(height, bounds); |
|
15171 |
bounds.forEach(function (b) { |
|
15172 |
var i = b.index; |
|
15173 |
expanded[i].top = b.x1New; |
|
15174 |
expanded[i].bottom = b.x2New; |
|
15175 |
}); |
|
15176 |
return expanded; |
|
15177 |
} |
|
15178 |
function expandBoundsLTR(width, bounds) { |
|
15179 |
bounds.sort(function (a, b) { |
|
15180 |
return a.x1 - b.x1 || a.index - b.index; |
|
15181 |
}); |
|
15182 |
var fakeBoundary = { |
|
15183 |
x1: -Infinity, |
|
15184 |
y1: -Infinity, |
|
15185 |
x2: 0, |
|
15186 |
y2: Infinity, |
|
15187 |
index: -1, |
|
15188 |
x1New: 0, |
|
15189 |
x2New: 0 |
|
15190 |
}; |
|
15191 |
var horizon = [{ |
|
15192 |
start: -Infinity, |
|
15193 |
end: Infinity, |
|
15194 |
boundary: fakeBoundary |
|
15195 |
}]; |
|
15196 |
bounds.forEach(function (boundary) { |
|
15197 |
var i = 0; |
|
15198 |
while (i < horizon.length && horizon[i].end <= boundary.y1) { |
|
15199 |
i++; |
|
15200 |
} |
|
15201 |
var j = horizon.length - 1; |
|
15202 |
while (j >= 0 && horizon[j].start >= boundary.y2) { |
|
15203 |
j--; |
|
15204 |
} |
|
15205 |
var horizonPart, affectedBoundary; |
|
15206 |
var q, |
|
15207 |
k, |
|
15208 |
maxXNew = -Infinity; |
|
15209 |
for (q = i; q <= j; q++) { |
|
15210 |
horizonPart = horizon[q]; |
|
15211 |
affectedBoundary = horizonPart.boundary; |
|
15212 |
var xNew; |
|
15213 |
if (affectedBoundary.x2 > boundary.x1) { |
|
15214 |
xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1; |
|
15215 |
} else if (affectedBoundary.x2New === undefined) { |
|
15216 |
xNew = (affectedBoundary.x2 + boundary.x1) / 2; |
|
15217 |
} else { |
|
15218 |
xNew = affectedBoundary.x2New; |
|
15219 |
} |
|
15220 |
if (xNew > maxXNew) { |
|
15221 |
maxXNew = xNew; |
|
15222 |
} |
|
15223 |
} |
|
15224 |
boundary.x1New = maxXNew; |
|
15225 |
for (q = i; q <= j; q++) { |
|
15226 |
horizonPart = horizon[q]; |
|
15227 |
affectedBoundary = horizonPart.boundary; |
|
15228 |
if (affectedBoundary.x2New === undefined) { |
|
15229 |
if (affectedBoundary.x2 > boundary.x1) { |
|
15230 |
if (affectedBoundary.index > boundary.index) { |
|
15231 |
affectedBoundary.x2New = affectedBoundary.x2; |
|
15232 |
} |
|
15233 |
} else { |
|
15234 |
affectedBoundary.x2New = maxXNew; |
|
15235 |
} |
|
15236 |
} else if (affectedBoundary.x2New > maxXNew) { |
|
15237 |
affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2); |
|
15238 |
} |
|
15239 |
} |
|
15240 |
var changedHorizon = [], |
|
15241 |
lastBoundary = null; |
|
15242 |
for (q = i; q <= j; q++) { |
|
15243 |
horizonPart = horizon[q]; |
|
15244 |
affectedBoundary = horizonPart.boundary; |
|
15245 |
var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary; |
|
15246 |
if (lastBoundary === useBoundary) { |
|
15247 |
changedHorizon[changedHorizon.length - 1].end = horizonPart.end; |
|
15248 |
} else { |
|
15249 |
changedHorizon.push({ |
|
15250 |
start: horizonPart.start, |
|
15251 |
end: horizonPart.end, |
|
15252 |
boundary: useBoundary |
|
15253 |
}); |
|
15254 |
lastBoundary = useBoundary; |
|
15255 |
} |
|
15256 |
} |
|
15257 |
if (horizon[i].start < boundary.y1) { |
|
15258 |
changedHorizon[0].start = boundary.y1; |
|
15259 |
changedHorizon.unshift({ |
|
15260 |
start: horizon[i].start, |
|
15261 |
end: boundary.y1, |
|
15262 |
boundary: horizon[i].boundary |
|
15263 |
}); |
|
15264 |
} |
|
15265 |
if (boundary.y2 < horizon[j].end) { |
|
15266 |
changedHorizon[changedHorizon.length - 1].end = boundary.y2; |
|
15267 |
changedHorizon.push({ |
|
15268 |
start: boundary.y2, |
|
15269 |
end: horizon[j].end, |
|
15270 |
boundary: horizon[j].boundary |
|
15271 |
}); |
|
15272 |
} |
|
15273 |
for (q = i; q <= j; q++) { |
|
15274 |
horizonPart = horizon[q]; |
|
15275 |
affectedBoundary = horizonPart.boundary; |
|
15276 |
if (affectedBoundary.x2New !== undefined) { |
|
15277 |
continue; |
|
15278 |
} |
|
15279 |
var used = false; |
|
15280 |
for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) { |
|
15281 |
used = horizon[k].boundary === affectedBoundary; |
|
15282 |
} |
|
15283 |
for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) { |
|
15284 |
used = horizon[k].boundary === affectedBoundary; |
|
15285 |
} |
|
15286 |
for (k = 0; !used && k < changedHorizon.length; k++) { |
|
15287 |
used = changedHorizon[k].boundary === affectedBoundary; |
|
15288 |
} |
|
15289 |
if (!used) { |
|
15290 |
affectedBoundary.x2New = maxXNew; |
|
15291 |
} |
|
15292 |
} |
|
15293 |
Array.prototype.splice.apply(horizon, [i, j - i + 1].concat(changedHorizon)); |
|
15294 |
}); |
|
15295 |
horizon.forEach(function (horizonPart) { |
|
15296 |
var affectedBoundary = horizonPart.boundary; |
|
15297 |
if (affectedBoundary.x2New === undefined) { |
|
15298 |
affectedBoundary.x2New = Math.max(width, affectedBoundary.x2); |
|
15299 |
} |
|
15300 |
}); |
|
15301 |
} |
|
15302 |
function TextLayerRenderTask(_ref) { |
|
15303 |
var textContent = _ref.textContent, |
|
15304 |
textContentStream = _ref.textContentStream, |
|
15305 |
container = _ref.container, |
|
15306 |
viewport = _ref.viewport, |
|
15307 |
textDivs = _ref.textDivs, |
|
15308 |
textContentItemsStr = _ref.textContentItemsStr, |
|
15309 |
enhanceTextSelection = _ref.enhanceTextSelection; |
|
15310 |
|
|
15311 |
this._textContent = textContent; |
|
15312 |
this._textContentStream = textContentStream; |
|
15313 |
this._container = container; |
|
15314 |
this._viewport = viewport; |
|
15315 |
this._textDivs = textDivs || []; |
|
15316 |
this._textContentItemsStr = textContentItemsStr || []; |
|
15317 |
this._enhanceTextSelection = !!enhanceTextSelection; |
|
15318 |
this._fontInspectorEnabled = !!(_global_scope2.default.FontInspector && _global_scope2.default.FontInspector.enabled); |
|
15319 |
this._reader = null; |
|
15320 |
this._layoutTextLastFontSize = null; |
|
15321 |
this._layoutTextLastFontFamily = null; |
|
15322 |
this._layoutTextCtx = null; |
|
15323 |
this._textDivProperties = new WeakMap(); |
|
15324 |
this._renderingDone = false; |
|
15325 |
this._canceled = false; |
|
15326 |
this._capability = (0, _util.createPromiseCapability)(); |
|
15327 |
this._renderTimer = null; |
|
15328 |
this._bounds = []; |
|
15329 |
} |
|
15330 |
TextLayerRenderTask.prototype = { |
|
15331 |
get promise() { |
|
15332 |
return this._capability.promise; |
|
15333 |
}, |
|
15334 |
cancel: function TextLayer_cancel() { |
|
15335 |
if (this._reader) { |
|
15336 |
this._reader.cancel(new _util.AbortException('text layer task cancelled')); |
|
15337 |
this._reader = null; |
|
15338 |
} |
|
15339 |
this._canceled = true; |
|
15340 |
if (this._renderTimer !== null) { |
|
15341 |
clearTimeout(this._renderTimer); |
|
15342 |
this._renderTimer = null; |
|
15343 |
} |
|
15344 |
this._capability.reject('canceled'); |
|
15345 |
}, |
|
15346 |
_processItems: function _processItems(items, styleCache) { |
|
15347 |
for (var i = 0, len = items.length; i < len; i++) { |
|
15348 |
this._textContentItemsStr.push(items[i].str); |
|
15349 |
appendText(this, items[i], styleCache); |
|
15350 |
} |
|
15351 |
}, |
|
15352 |
_layoutText: function _layoutText(textDiv) { |
|
15353 |
var textLayerFrag = this._container; |
|
15354 |
var textDivProperties = this._textDivProperties.get(textDiv); |
|
15355 |
if (textDivProperties.isWhitespace) { |
|
15356 |
return; |
|
15357 |
} |
|
15358 |
var fontSize = textDiv.style.fontSize; |
|
15359 |
var fontFamily = textDiv.style.fontFamily; |
|
15360 |
if (fontSize !== this._layoutTextLastFontSize || fontFamily !== this._layoutTextLastFontFamily) { |
|
15361 |
this._layoutTextCtx.font = fontSize + ' ' + fontFamily; |
|
15362 |
this._layoutTextLastFontSize = fontSize; |
|
15363 |
this._layoutTextLastFontFamily = fontFamily; |
|
15364 |
} |
|
15365 |
var width = this._layoutTextCtx.measureText(textDiv.textContent).width; |
|
15366 |
var transform = ''; |
|
15367 |
if (textDivProperties.canvasWidth !== 0 && width > 0) { |
|
15368 |
textDivProperties.scale = textDivProperties.canvasWidth / width; |
|
15369 |
transform = 'scaleX(' + textDivProperties.scale + ')'; |
|
15370 |
} |
|
15371 |
if (textDivProperties.angle !== 0) { |
|
15372 |
transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform; |
|
15373 |
} |
|
15374 |
if (transform !== '') { |
|
15375 |
textDivProperties.originalTransform = transform; |
|
15376 |
textDiv.style.transform = transform; |
|
15377 |
} |
|
15378 |
this._textDivProperties.set(textDiv, textDivProperties); |
|
15379 |
textLayerFrag.appendChild(textDiv); |
|
15380 |
}, |
|
15381 |
|
|
15382 |
_render: function TextLayer_render(timeout) { |
|
15383 |
var _this = this; |
|
15384 |
|
|
15385 |
var capability = (0, _util.createPromiseCapability)(); |
|
15386 |
var styleCache = Object.create(null); |
|
15387 |
var canvas = document.createElement('canvas'); |
|
15388 |
canvas.mozOpaque = true; |
|
15389 |
this._layoutTextCtx = canvas.getContext('2d', { alpha: false }); |
|
15390 |
if (this._textContent) { |
|
15391 |
var textItems = this._textContent.items; |
|
15392 |
var textStyles = this._textContent.styles; |
|
15393 |
this._processItems(textItems, textStyles); |
|
15394 |
capability.resolve(); |
|
15395 |
} else if (this._textContentStream) { |
|
15396 |
var pump = function pump() { |
|
15397 |
_this._reader.read().then(function (_ref2) { |
|
15398 |
var value = _ref2.value, |
|
15399 |
done = _ref2.done; |
|
15400 |
|
|
15401 |
if (done) { |
|
15402 |
capability.resolve(); |
|
15403 |
return; |
|
15404 |
} |
|
15405 |
Object.assign(styleCache, value.styles); |
|
15406 |
_this._processItems(value.items, styleCache); |
|
15407 |
pump(); |
|
15408 |
}, capability.reject); |
|
15409 |
}; |
|
15410 |
this._reader = this._textContentStream.getReader(); |
|
15411 |
pump(); |
|
15412 |
} else { |
|
15413 |
throw new Error('Neither "textContent" nor "textContentStream"' + ' parameters specified.'); |
|
15414 |
} |
|
15415 |
capability.promise.then(function () { |
|
15416 |
styleCache = null; |
|
15417 |
if (!timeout) { |
|
15418 |
render(_this); |
|
15419 |
} else { |
|
15420 |
_this._renderTimer = setTimeout(function () { |
|
15421 |
render(_this); |
|
15422 |
_this._renderTimer = null; |
|
15423 |
}, timeout); |
|
15424 |
} |
|
15425 |
}, this._capability.reject); |
|
15426 |
}, |
|
15427 |
expandTextDivs: function TextLayer_expandTextDivs(expandDivs) { |
|
15428 |
if (!this._enhanceTextSelection || !this._renderingDone) { |
|
15429 |
return; |
|
15430 |
} |
|
15431 |
if (this._bounds !== null) { |
|
15432 |
expand(this); |
|
15433 |
this._bounds = null; |
|
15434 |
} |
|
15435 |
for (var i = 0, ii = this._textDivs.length; i < ii; i++) { |
|
15436 |
var div = this._textDivs[i]; |
|
15437 |
var divProperties = this._textDivProperties.get(div); |
|
15438 |
if (divProperties.isWhitespace) { |
|
15439 |
continue; |
|
15440 |
} |
|
15441 |
if (expandDivs) { |
|
15442 |
var transform = '', |
|
15443 |
padding = ''; |
|
15444 |
if (divProperties.scale !== 1) { |
|
15445 |
transform = 'scaleX(' + divProperties.scale + ')'; |
|
15446 |
} |
|
15447 |
if (divProperties.angle !== 0) { |
|
15448 |
transform = 'rotate(' + divProperties.angle + 'deg) ' + transform; |
|
15449 |
} |
|
15450 |
if (divProperties.paddingLeft !== 0) { |
|
15451 |
padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;'; |
|
15452 |
transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)'; |
|
15453 |
} |
|
15454 |
if (divProperties.paddingTop !== 0) { |
|
15455 |
padding += ' padding-top: ' + divProperties.paddingTop + 'px;'; |
|
15456 |
transform += ' translateY(' + -divProperties.paddingTop + 'px)'; |
|
15457 |
} |
|
15458 |
if (divProperties.paddingRight !== 0) { |
|
15459 |
padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;'; |
|
15460 |
} |
|
15461 |
if (divProperties.paddingBottom !== 0) { |
|
15462 |
padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;'; |
|
15463 |
} |
|
15464 |
if (padding !== '') { |
|
15465 |
div.setAttribute('style', divProperties.style + padding); |
|
15466 |
} |
|
15467 |
if (transform !== '') { |
|
15468 |
div.style.transform = transform; |
|
15469 |
} |
|
15470 |
} else { |
|
15471 |
div.style.padding = 0; |
|
15472 |
div.style.transform = divProperties.originalTransform || ''; |
|
15473 |
} |
|
15474 |
} |
|
15475 |
} |
|
15476 |
}; |
|
15477 |
function renderTextLayer(renderParameters) { |
|
15478 |
var task = new TextLayerRenderTask({ |
|
15479 |
textContent: renderParameters.textContent, |
|
15480 |
textContentStream: renderParameters.textContentStream, |
|
15481 |
container: renderParameters.container, |
|
15482 |
viewport: renderParameters.viewport, |
|
15483 |
textDivs: renderParameters.textDivs, |
|
15484 |
textContentItemsStr: renderParameters.textContentItemsStr, |
|
15485 |
enhanceTextSelection: renderParameters.enhanceTextSelection |
|
15486 |
}); |
|
15487 |
task._render(renderParameters.timeout); |
|
15488 |
return task; |
|
15489 |
} |
|
15490 |
return renderTextLayer; |
|
15491 |
}(); |
|
15492 |
exports.renderTextLayer = renderTextLayer; |
|
15493 |
|
|
15494 |
/***/ }), |
|
15495 |
/* 146 */ |
|
15496 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
15497 |
|
|
15498 |
"use strict"; |
|
15499 |
|
|
15500 |
|
|
15501 |
Object.defineProperty(exports, "__esModule", { |
|
15502 |
value: true |
|
15503 |
}); |
|
15504 |
exports.AnnotationLayer = undefined; |
|
15505 |
|
|
15506 |
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; |
|
15507 |
|
|
15508 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
|
15509 |
|
|
15510 |
var _dom_utils = __w_pdfjs_require__(130); |
|
15511 |
|
|
15512 |
var _util = __w_pdfjs_require__(1); |
|
15513 |
|
|
15514 |
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } |
|
15515 |
|
|
15516 |
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
|
15517 |
|
|
15518 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
15519 |
|
|
15520 |
var AnnotationElementFactory = function () { |
|
15521 |
function AnnotationElementFactory() { |
|
15522 |
_classCallCheck(this, AnnotationElementFactory); |
|
15523 |
} |
|
15524 |
|
|
15525 |
_createClass(AnnotationElementFactory, null, [{ |
|
15526 |
key: 'create', |
|
15527 |
value: function create(parameters) { |
|
15528 |
var subtype = parameters.data.annotationType; |
|
15529 |
switch (subtype) { |
|
15530 |
case _util.AnnotationType.LINK: |
|
15531 |
return new LinkAnnotationElement(parameters); |
|
15532 |
case _util.AnnotationType.TEXT: |
|
15533 |
return new TextAnnotationElement(parameters); |
|
15534 |
case _util.AnnotationType.WIDGET: |
|
15535 |
var fieldType = parameters.data.fieldType; |
|
15536 |
switch (fieldType) { |
|
15537 |
case 'Tx': |
|
15538 |
return new TextWidgetAnnotationElement(parameters); |
|
15539 |
case 'Btn': |
|
15540 |
if (parameters.data.radioButton) { |
|
15541 |
return new RadioButtonWidgetAnnotationElement(parameters); |
|
15542 |
} else if (parameters.data.checkBox) { |
|
15543 |
return new CheckboxWidgetAnnotationElement(parameters); |
|
15544 |
} |
|
15545 |
return new PushButtonWidgetAnnotationElement(parameters); |
|
15546 |
case 'Ch': |
|
15547 |
return new ChoiceWidgetAnnotationElement(parameters); |
|
15548 |
} |
|
15549 |
return new WidgetAnnotationElement(parameters); |
|
15550 |
case _util.AnnotationType.POPUP: |
|
15551 |
return new PopupAnnotationElement(parameters); |
|
15552 |
case _util.AnnotationType.LINE: |
|
15553 |
return new LineAnnotationElement(parameters); |
|
15554 |
case _util.AnnotationType.SQUARE: |
|
15555 |
return new SquareAnnotationElement(parameters); |
|
15556 |
case _util.AnnotationType.CIRCLE: |
|
15557 |
return new CircleAnnotationElement(parameters); |
|
15558 |
case _util.AnnotationType.POLYLINE: |
|
15559 |
return new PolylineAnnotationElement(parameters); |
|
15560 |
case _util.AnnotationType.INK: |
|
15561 |
return new InkAnnotationElement(parameters); |
|
15562 |
case _util.AnnotationType.POLYGON: |
|
15563 |
return new PolygonAnnotationElement(parameters); |
|
15564 |
case _util.AnnotationType.HIGHLIGHT: |
|
15565 |
return new HighlightAnnotationElement(parameters); |
|
15566 |
case _util.AnnotationType.UNDERLINE: |
|
15567 |
return new UnderlineAnnotationElement(parameters); |
|
15568 |
case _util.AnnotationType.SQUIGGLY: |
|
15569 |
return new SquigglyAnnotationElement(parameters); |
|
15570 |
case _util.AnnotationType.STRIKEOUT: |
|
15571 |
return new StrikeOutAnnotationElement(parameters); |
|
15572 |
case _util.AnnotationType.STAMP: |
|
15573 |
return new StampAnnotationElement(parameters); |
|
15574 |
case _util.AnnotationType.FILEATTACHMENT: |
|
15575 |
return new FileAttachmentAnnotationElement(parameters); |
|
15576 |
default: |
|
15577 |
return new AnnotationElement(parameters); |
|
15578 |
} |
|
15579 |
} |
|
15580 |
}]); |
|
15581 |
|
|
15582 |
return AnnotationElementFactory; |
|
15583 |
}(); |
|
15584 |
|
|
15585 |
var AnnotationElement = function () { |
|
15586 |
function AnnotationElement(parameters) { |
|
15587 |
var isRenderable = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; |
|
15588 |
var ignoreBorder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
|
15589 |
|
|
15590 |
_classCallCheck(this, AnnotationElement); |
|
15591 |
|
|
15592 |
this.isRenderable = isRenderable; |
|
15593 |
this.data = parameters.data; |
|
15594 |
this.layer = parameters.layer; |
|
15595 |
this.page = parameters.page; |
|
15596 |
this.viewport = parameters.viewport; |
|
15597 |
this.linkService = parameters.linkService; |
|
15598 |
this.downloadManager = parameters.downloadManager; |
|
15599 |
this.imageResourcesPath = parameters.imageResourcesPath; |
|
15600 |
this.renderInteractiveForms = parameters.renderInteractiveForms; |
|
15601 |
this.svgFactory = parameters.svgFactory; |
|
15602 |
if (isRenderable) { |
|
15603 |
this.container = this._createContainer(ignoreBorder); |
|
15604 |
} |
|
15605 |
} |
|
15606 |
|
|
15607 |
_createClass(AnnotationElement, [{ |
|
15608 |
key: '_createContainer', |
|
15609 |
value: function _createContainer() { |
|
15610 |
var ignoreBorder = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
|
15611 |
|
|
15612 |
var data = this.data, |
|
15613 |
page = this.page, |
|
15614 |
viewport = this.viewport; |
|
15615 |
var container = document.createElement('section'); |
|
15616 |
var width = data.rect[2] - data.rect[0]; |
|
15617 |
var height = data.rect[3] - data.rect[1]; |
|
15618 |
container.setAttribute('data-annotation-id', data.id); |
|
15619 |
var rect = _util.Util.normalizeRect([data.rect[0], page.view[3] - data.rect[1] + page.view[1], data.rect[2], page.view[3] - data.rect[3] + page.view[1]]); |
|
15620 |
container.style.transform = 'matrix(' + viewport.transform.join(',') + ')'; |
|
15621 |
container.style.transformOrigin = -rect[0] + 'px ' + -rect[1] + 'px'; |
|
15622 |
if (!ignoreBorder && data.borderStyle.width > 0) { |
|
15623 |
container.style.borderWidth = data.borderStyle.width + 'px'; |
|
15624 |
if (data.borderStyle.style !== _util.AnnotationBorderStyleType.UNDERLINE) { |
|
15625 |
width = width - 2 * data.borderStyle.width; |
|
15626 |
height = height - 2 * data.borderStyle.width; |
|
15627 |
} |
|
15628 |
var horizontalRadius = data.borderStyle.horizontalCornerRadius; |
|
15629 |
var verticalRadius = data.borderStyle.verticalCornerRadius; |
|
15630 |
if (horizontalRadius > 0 || verticalRadius > 0) { |
|
15631 |
var radius = horizontalRadius + 'px / ' + verticalRadius + 'px'; |
|
15632 |
container.style.borderRadius = radius; |
|
15633 |
} |
|
15634 |
switch (data.borderStyle.style) { |
|
15635 |
case _util.AnnotationBorderStyleType.SOLID: |
|
15636 |
container.style.borderStyle = 'solid'; |
|
15637 |
break; |
|
15638 |
case _util.AnnotationBorderStyleType.DASHED: |
|
15639 |
container.style.borderStyle = 'dashed'; |
|
15640 |
break; |
|
15641 |
case _util.AnnotationBorderStyleType.BEVELED: |
|
15642 |
(0, _util.warn)('Unimplemented border style: beveled'); |
|
15643 |
break; |
|
15644 |
case _util.AnnotationBorderStyleType.INSET: |
|
15645 |
(0, _util.warn)('Unimplemented border style: inset'); |
|
15646 |
break; |
|
15647 |
case _util.AnnotationBorderStyleType.UNDERLINE: |
|
15648 |
container.style.borderBottomStyle = 'solid'; |
|
15649 |
break; |
|
15650 |
default: |
|
15651 |
break; |
|
15652 |
} |
|
15653 |
if (data.color) { |
|
15654 |
container.style.borderColor = _util.Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0); |
|
15655 |
} else { |
|
15656 |
container.style.borderWidth = 0; |
|
15657 |
} |
|
15658 |
} |
|
15659 |
container.style.left = rect[0] + 'px'; |
|
15660 |
container.style.top = rect[1] + 'px'; |
|
15661 |
container.style.width = width + 'px'; |
|
15662 |
container.style.height = height + 'px'; |
|
15663 |
return container; |
|
15664 |
} |
|
15665 |
}, { |
|
15666 |
key: '_createPopup', |
|
15667 |
value: function _createPopup(container, trigger, data) { |
|
15668 |
if (!trigger) { |
|
15669 |
trigger = document.createElement('div'); |
|
15670 |
trigger.style.height = container.style.height; |
|
15671 |
trigger.style.width = container.style.width; |
|
15672 |
container.appendChild(trigger); |
|
15673 |
} |
|
15674 |
var popupElement = new PopupElement({ |
|
15675 |
container: container, |
|
15676 |
trigger: trigger, |
|
15677 |
color: data.color, |
|
15678 |
title: data.title, |
|
15679 |
contents: data.contents, |
|
15680 |
hideWrapper: true |
|
15681 |
}); |
|
15682 |
var popup = popupElement.render(); |
|
15683 |
popup.style.left = container.style.width; |
|
15684 |
container.appendChild(popup); |
|
15685 |
} |
|
15686 |
}, { |
|
15687 |
key: 'render', |
|
15688 |
value: function render() { |
|
15689 |
(0, _util.unreachable)('Abstract method `AnnotationElement.render` called'); |
|
15690 |
} |
|
15691 |
}]); |
|
15692 |
|
|
15693 |
return AnnotationElement; |
|
15694 |
}(); |
|
15695 |
|
|
15696 |
var LinkAnnotationElement = function (_AnnotationElement) { |
|
15697 |
_inherits(LinkAnnotationElement, _AnnotationElement); |
|
15698 |
|
|
15699 |
function LinkAnnotationElement(parameters) { |
|
15700 |
_classCallCheck(this, LinkAnnotationElement); |
|
15701 |
|
|
15702 |
var isRenderable = !!(parameters.data.url || parameters.data.dest || parameters.data.action); |
|
15703 |
return _possibleConstructorReturn(this, (LinkAnnotationElement.__proto__ || Object.getPrototypeOf(LinkAnnotationElement)).call(this, parameters, isRenderable)); |
|
15704 |
} |
|
15705 |
|
|
15706 |
_createClass(LinkAnnotationElement, [{ |
|
15707 |
key: 'render', |
|
15708 |
value: function render() { |
|
15709 |
this.container.className = 'linkAnnotation'; |
|
15710 |
var data = this.data, |
|
15711 |
linkService = this.linkService; |
|
15712 |
|
|
15713 |
var link = document.createElement('a'); |
|
15714 |
(0, _dom_utils.addLinkAttributes)(link, { |
|
15715 |
url: data.url, |
|
15716 |
target: data.newWindow ? _dom_utils.LinkTarget.BLANK : linkService.externalLinkTarget, |
|
15717 |
rel: linkService.externalLinkRel |
|
15718 |
}); |
|
15719 |
if (!data.url) { |
|
15720 |
if (data.action) { |
|
15721 |
this._bindNamedAction(link, data.action); |
|
15722 |
} else { |
|
15723 |
this._bindLink(link, data.dest); |
|
15724 |
} |
|
15725 |
} |
|
15726 |
this.container.appendChild(link); |
|
15727 |
return this.container; |
|
15728 |
} |
|
15729 |
}, { |
|
15730 |
key: '_bindLink', |
|
15731 |
value: function _bindLink(link, destination) { |
|
15732 |
var _this2 = this; |
|
15733 |
|
|
15734 |
link.href = this.linkService.getDestinationHash(destination); |
|
15735 |
link.onclick = function () { |
|
15736 |
if (destination) { |
|
15737 |
_this2.linkService.navigateTo(destination); |
|
15738 |
} |
|
15739 |
return false; |
|
15740 |
}; |
|
15741 |
if (destination) { |
|
15742 |
link.className = 'internalLink'; |
|
15743 |
} |
|
15744 |
} |
|
15745 |
}, { |
|
15746 |
key: '_bindNamedAction', |
|
15747 |
value: function _bindNamedAction(link, action) { |
|
15748 |
var _this3 = this; |
|
15749 |
|
|
15750 |
link.href = this.linkService.getAnchorUrl(''); |
|
15751 |
link.onclick = function () { |
|
15752 |
_this3.linkService.executeNamedAction(action); |
|
15753 |
return false; |
|
15754 |
}; |
|
15755 |
link.className = 'internalLink'; |
|
15756 |
} |
|
15757 |
}]); |
|
15758 |
|
|
15759 |
return LinkAnnotationElement; |
|
15760 |
}(AnnotationElement); |
|
15761 |
|
|
15762 |
var TextAnnotationElement = function (_AnnotationElement2) { |
|
15763 |
_inherits(TextAnnotationElement, _AnnotationElement2); |
|
15764 |
|
|
15765 |
function TextAnnotationElement(parameters) { |
|
15766 |
_classCallCheck(this, TextAnnotationElement); |
|
15767 |
|
|
15768 |
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); |
|
15769 |
return _possibleConstructorReturn(this, (TextAnnotationElement.__proto__ || Object.getPrototypeOf(TextAnnotationElement)).call(this, parameters, isRenderable)); |
|
15770 |
} |
|
15771 |
|
|
15772 |
_createClass(TextAnnotationElement, [{ |
|
15773 |
key: 'render', |
|
15774 |
value: function render() { |
|
15775 |
this.container.className = 'textAnnotation'; |
|
15776 |
var image = document.createElement('img'); |
|
15777 |
image.style.height = this.container.style.height; |
|
15778 |
image.style.width = this.container.style.width; |
|
15779 |
image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg'; |
|
15780 |
image.alt = '[{{type}} Annotation]'; |
|
15781 |
image.dataset.l10nId = 'text_annotation_type'; |
|
15782 |
image.dataset.l10nArgs = JSON.stringify({ type: this.data.name }); |
|
15783 |
if (!this.data.hasPopup) { |
|
15784 |
this._createPopup(this.container, image, this.data); |
|
15785 |
} |
|
15786 |
this.container.appendChild(image); |
|
15787 |
return this.container; |
|
15788 |
} |
|
15789 |
}]); |
|
15790 |
|
|
15791 |
return TextAnnotationElement; |
|
15792 |
}(AnnotationElement); |
|
15793 |
|
|
15794 |
var WidgetAnnotationElement = function (_AnnotationElement3) { |
|
15795 |
_inherits(WidgetAnnotationElement, _AnnotationElement3); |
|
15796 |
|
|
15797 |
function WidgetAnnotationElement() { |
|
15798 |
_classCallCheck(this, WidgetAnnotationElement); |
|
15799 |
|
|
15800 |
return _possibleConstructorReturn(this, (WidgetAnnotationElement.__proto__ || Object.getPrototypeOf(WidgetAnnotationElement)).apply(this, arguments)); |
|
15801 |
} |
|
15802 |
|
|
15803 |
_createClass(WidgetAnnotationElement, [{ |
|
15804 |
key: 'render', |
|
15805 |
value: function render() { |
|
15806 |
return this.container; |
|
15807 |
} |
|
15808 |
}]); |
|
15809 |
|
|
15810 |
return WidgetAnnotationElement; |
|
15811 |
}(AnnotationElement); |
|
15812 |
|
|
15813 |
var TextWidgetAnnotationElement = function (_WidgetAnnotationElem) { |
|
15814 |
_inherits(TextWidgetAnnotationElement, _WidgetAnnotationElem); |
|
15815 |
|
|
15816 |
function TextWidgetAnnotationElement(parameters) { |
|
15817 |
_classCallCheck(this, TextWidgetAnnotationElement); |
|
15818 |
|
|
15819 |
var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue; |
|
15820 |
return _possibleConstructorReturn(this, (TextWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(TextWidgetAnnotationElement)).call(this, parameters, isRenderable)); |
|
15821 |
} |
|
15822 |
|
|
15823 |
_createClass(TextWidgetAnnotationElement, [{ |
|
15824 |
key: 'render', |
|
15825 |
value: function render() { |
|
15826 |
var TEXT_ALIGNMENT = ['left', 'center', 'right']; |
|
15827 |
this.container.className = 'textWidgetAnnotation'; |
|
15828 |
var element = null; |
|
15829 |
if (this.renderInteractiveForms) { |
|
15830 |
if (this.data.multiLine) { |
|
15831 |
element = document.createElement('textarea'); |
|
15832 |
element.textContent = this.data.fieldValue; |
|
15833 |
} else { |
|
15834 |
element = document.createElement('input'); |
|
15835 |
element.type = 'text'; |
|
15836 |
element.setAttribute('value', this.data.fieldValue); |
|
15837 |
} |
|
15838 |
element.disabled = this.data.readOnly; |
|
15839 |
if (this.data.maxLen !== null) { |
|
15840 |
element.maxLength = this.data.maxLen; |
|
15841 |
} |
|
15842 |
if (this.data.comb) { |
|
15843 |
var fieldWidth = this.data.rect[2] - this.data.rect[0]; |
|
15844 |
var combWidth = fieldWidth / this.data.maxLen; |
|
15845 |
element.classList.add('comb'); |
|
15846 |
element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)'; |
|
15847 |
} |
|
15848 |
} else { |
|
15849 |
element = document.createElement('div'); |
|
15850 |
element.textContent = this.data.fieldValue; |
|
15851 |
element.style.verticalAlign = 'middle'; |
|
15852 |
element.style.display = 'table-cell'; |
|
15853 |
var font = null; |
|
15854 |
if (this.data.fontRefName) { |
|
15855 |
font = this.page.commonObjs.getData(this.data.fontRefName); |
|
15856 |
} |
|
15857 |
this._setTextStyle(element, font); |
|
15858 |
} |
|
15859 |
if (this.data.textAlignment !== null) { |
|
15860 |
element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment]; |
|
15861 |
} |
|
15862 |
this.container.appendChild(element); |
|
15863 |
return this.container; |
|
15864 |
} |
|
15865 |
}, { |
|
15866 |
key: '_setTextStyle', |
|
15867 |
value: function _setTextStyle(element, font) { |
|
15868 |
var style = element.style; |
|
15869 |
style.fontSize = this.data.fontSize + 'px'; |
|
15870 |
style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr'; |
|
15871 |
if (!font) { |
|
15872 |
return; |
|
15873 |
} |
|
15874 |
style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal'; |
|
15875 |
style.fontStyle = font.italic ? 'italic' : 'normal'; |
|
15876 |
var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : ''; |
|
15877 |
var fallbackName = font.fallbackName || 'Helvetica, sans-serif'; |
|
15878 |
style.fontFamily = fontFamily + fallbackName; |
|
15879 |
} |
|
15880 |
}]); |
|
15881 |
|
|
15882 |
return TextWidgetAnnotationElement; |
|
15883 |
}(WidgetAnnotationElement); |
|
15884 |
|
|
15885 |
var CheckboxWidgetAnnotationElement = function (_WidgetAnnotationElem2) { |
|
15886 |
_inherits(CheckboxWidgetAnnotationElement, _WidgetAnnotationElem2); |
|
15887 |
|
|
15888 |
function CheckboxWidgetAnnotationElement(parameters) { |
|
15889 |
_classCallCheck(this, CheckboxWidgetAnnotationElement); |
|
15890 |
|
|
15891 |
return _possibleConstructorReturn(this, (CheckboxWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(CheckboxWidgetAnnotationElement)).call(this, parameters, parameters.renderInteractiveForms)); |
|
15892 |
} |
|
15893 |
|
|
15894 |
_createClass(CheckboxWidgetAnnotationElement, [{ |
|
15895 |
key: 'render', |
|
15896 |
value: function render() { |
|
15897 |
this.container.className = 'buttonWidgetAnnotation checkBox'; |
|
15898 |
var element = document.createElement('input'); |
|
15899 |
element.disabled = this.data.readOnly; |
|
15900 |
element.type = 'checkbox'; |
|
15901 |
if (this.data.fieldValue && this.data.fieldValue !== 'Off') { |
|
15902 |
element.setAttribute('checked', true); |
|
15903 |
} |
|
15904 |
this.container.appendChild(element); |
|
15905 |
return this.container; |
|
15906 |
} |
|
15907 |
}]); |
|
15908 |
|
|
15909 |
return CheckboxWidgetAnnotationElement; |
|
15910 |
}(WidgetAnnotationElement); |
|
15911 |
|
|
15912 |
var RadioButtonWidgetAnnotationElement = function (_WidgetAnnotationElem3) { |
|
15913 |
_inherits(RadioButtonWidgetAnnotationElement, _WidgetAnnotationElem3); |
|
15914 |
|
|
15915 |
function RadioButtonWidgetAnnotationElement(parameters) { |
|
15916 |
_classCallCheck(this, RadioButtonWidgetAnnotationElement); |
|
15917 |
|
|
15918 |
return _possibleConstructorReturn(this, (RadioButtonWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(RadioButtonWidgetAnnotationElement)).call(this, parameters, parameters.renderInteractiveForms)); |
|
15919 |
} |
|
15920 |
|
|
15921 |
_createClass(RadioButtonWidgetAnnotationElement, [{ |
|
15922 |
key: 'render', |
|
15923 |
value: function render() { |
|
15924 |
this.container.className = 'buttonWidgetAnnotation radioButton'; |
|
15925 |
var element = document.createElement('input'); |
|
15926 |
element.disabled = this.data.readOnly; |
|
15927 |
element.type = 'radio'; |
|
15928 |
element.name = this.data.fieldName; |
|
15929 |
if (this.data.fieldValue === this.data.buttonValue) { |
|
15930 |
element.setAttribute('checked', true); |
|
15931 |
} |
|
15932 |
this.container.appendChild(element); |
|
15933 |
return this.container; |
|
15934 |
} |
|
15935 |
}]); |
|
15936 |
|
|
15937 |
return RadioButtonWidgetAnnotationElement; |
|
15938 |
}(WidgetAnnotationElement); |
|
15939 |
|
|
15940 |
var PushButtonWidgetAnnotationElement = function (_LinkAnnotationElemen) { |
|
15941 |
_inherits(PushButtonWidgetAnnotationElement, _LinkAnnotationElemen); |
|
15942 |
|
|
15943 |
function PushButtonWidgetAnnotationElement() { |
|
15944 |
_classCallCheck(this, PushButtonWidgetAnnotationElement); |
|
15945 |
|
|
15946 |
return _possibleConstructorReturn(this, (PushButtonWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(PushButtonWidgetAnnotationElement)).apply(this, arguments)); |
|
15947 |
} |
|
15948 |
|
|
15949 |
_createClass(PushButtonWidgetAnnotationElement, [{ |
|
15950 |
key: 'render', |
|
15951 |
value: function render() { |
|
15952 |
var container = _get(PushButtonWidgetAnnotationElement.prototype.__proto__ || Object.getPrototypeOf(PushButtonWidgetAnnotationElement.prototype), 'render', this).call(this); |
|
15953 |
container.className = 'buttonWidgetAnnotation pushButton'; |
|
15954 |
return container; |
|
15955 |
} |
|
15956 |
}]); |
|
15957 |
|
|
15958 |
return PushButtonWidgetAnnotationElement; |
|
15959 |
}(LinkAnnotationElement); |
|
15960 |
|
|
15961 |
var ChoiceWidgetAnnotationElement = function (_WidgetAnnotationElem4) { |
|
15962 |
_inherits(ChoiceWidgetAnnotationElement, _WidgetAnnotationElem4); |
|
15963 |
|
|
15964 |
function ChoiceWidgetAnnotationElement(parameters) { |
|
15965 |
_classCallCheck(this, ChoiceWidgetAnnotationElement); |
|
15966 |
|
|
15967 |
return _possibleConstructorReturn(this, (ChoiceWidgetAnnotationElement.__proto__ || Object.getPrototypeOf(ChoiceWidgetAnnotationElement)).call(this, parameters, parameters.renderInteractiveForms)); |
|
15968 |
} |
|
15969 |
|
|
15970 |
_createClass(ChoiceWidgetAnnotationElement, [{ |
|
15971 |
key: 'render', |
|
15972 |
value: function render() { |
|
15973 |
this.container.className = 'choiceWidgetAnnotation'; |
|
15974 |
var selectElement = document.createElement('select'); |
|
15975 |
selectElement.disabled = this.data.readOnly; |
|
15976 |
if (!this.data.combo) { |
|
15977 |
selectElement.size = this.data.options.length; |
|
15978 |
if (this.data.multiSelect) { |
|
15979 |
selectElement.multiple = true; |
|
15980 |
} |
|
15981 |
} |
|
15982 |
for (var i = 0, ii = this.data.options.length; i < ii; i++) { |
|
15983 |
var option = this.data.options[i]; |
|
15984 |
var optionElement = document.createElement('option'); |
|
15985 |
optionElement.textContent = option.displayValue; |
|
15986 |
optionElement.value = option.exportValue; |
|
15987 |
if (this.data.fieldValue.includes(option.displayValue)) { |
|
15988 |
optionElement.setAttribute('selected', true); |
|
15989 |
} |
|
15990 |
selectElement.appendChild(optionElement); |
|
15991 |
} |
|
15992 |
this.container.appendChild(selectElement); |
|
15993 |
return this.container; |
|
15994 |
} |
|
15995 |
}]); |
|
15996 |
|
|
15997 |
return ChoiceWidgetAnnotationElement; |
|
15998 |
}(WidgetAnnotationElement); |
|
15999 |
|
|
16000 |
var PopupAnnotationElement = function (_AnnotationElement4) { |
|
16001 |
_inherits(PopupAnnotationElement, _AnnotationElement4); |
|
16002 |
|
|
16003 |
function PopupAnnotationElement(parameters) { |
|
16004 |
_classCallCheck(this, PopupAnnotationElement); |
|
16005 |
|
|
16006 |
var isRenderable = !!(parameters.data.title || parameters.data.contents); |
|
16007 |
return _possibleConstructorReturn(this, (PopupAnnotationElement.__proto__ || Object.getPrototypeOf(PopupAnnotationElement)).call(this, parameters, isRenderable)); |
|
16008 |
} |
|
16009 |
|
|
16010 |
_createClass(PopupAnnotationElement, [{ |
|
16011 |
key: 'render', |
|
16012 |
value: function render() { |
|
16013 |
var IGNORE_TYPES = ['Line', 'Square', 'Circle', 'PolyLine', 'Polygon', 'Ink']; |
|
16014 |
this.container.className = 'popupAnnotation'; |
|
16015 |
if (IGNORE_TYPES.includes(this.data.parentType)) { |
|
16016 |
return this.container; |
|
16017 |
} |
|
16018 |
var selector = '[data-annotation-id="' + this.data.parentId + '"]'; |
|
16019 |
var parentElement = this.layer.querySelector(selector); |
|
16020 |
if (!parentElement) { |
|
16021 |
return this.container; |
|
16022 |
} |
|
16023 |
var popup = new PopupElement({ |
|
16024 |
container: this.container, |
|
16025 |
trigger: parentElement, |
|
16026 |
color: this.data.color, |
|
16027 |
title: this.data.title, |
|
16028 |
contents: this.data.contents |
|
16029 |
}); |
|
16030 |
var parentLeft = parseFloat(parentElement.style.left); |
|
16031 |
var parentWidth = parseFloat(parentElement.style.width); |
|
16032 |
this.container.style.transformOrigin = -(parentLeft + parentWidth) + 'px -' + parentElement.style.top; |
|
16033 |
this.container.style.left = parentLeft + parentWidth + 'px'; |
|
16034 |
this.container.appendChild(popup.render()); |
|
16035 |
return this.container; |
|
16036 |
} |
|
16037 |
}]); |
|
16038 |
|
|
16039 |
return PopupAnnotationElement; |
|
16040 |
}(AnnotationElement); |
|
16041 |
|
|
16042 |
var PopupElement = function () { |
|
16043 |
function PopupElement(parameters) { |
|
16044 |
_classCallCheck(this, PopupElement); |
|
16045 |
|
|
16046 |
this.container = parameters.container; |
|
16047 |
this.trigger = parameters.trigger; |
|
16048 |
this.color = parameters.color; |
|
16049 |
this.title = parameters.title; |
|
16050 |
this.contents = parameters.contents; |
|
16051 |
this.hideWrapper = parameters.hideWrapper || false; |
|
16052 |
this.pinned = false; |
|
16053 |
} |
|
16054 |
|
|
16055 |
_createClass(PopupElement, [{ |
|
16056 |
key: 'render', |
|
16057 |
value: function render() { |
|
16058 |
var BACKGROUND_ENLIGHT = 0.7; |
|
16059 |
var wrapper = document.createElement('div'); |
|
16060 |
wrapper.className = 'popupWrapper'; |
|
16061 |
this.hideElement = this.hideWrapper ? wrapper : this.container; |
|
16062 |
this.hideElement.setAttribute('hidden', true); |
|
16063 |
var popup = document.createElement('div'); |
|
16064 |
popup.className = 'popup'; |
|
16065 |
var color = this.color; |
|
16066 |
if (color) { |
|
16067 |
var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0]; |
|
16068 |
var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1]; |
|
16069 |
var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2]; |
|
16070 |
popup.style.backgroundColor = _util.Util.makeCssRgb(r | 0, g | 0, b | 0); |
|
16071 |
} |
|
16072 |
var contents = this._formatContents(this.contents); |
|
16073 |
var title = document.createElement('h1'); |
|
16074 |
title.textContent = this.title; |
|
16075 |
this.trigger.addEventListener('click', this._toggle.bind(this)); |
|
16076 |
this.trigger.addEventListener('mouseover', this._show.bind(this, false)); |
|
16077 |
this.trigger.addEventListener('mouseout', this._hide.bind(this, false)); |
|
16078 |
popup.addEventListener('click', this._hide.bind(this, true)); |
|
16079 |
popup.appendChild(title); |
|
16080 |
popup.appendChild(contents); |
|
16081 |
wrapper.appendChild(popup); |
|
16082 |
return wrapper; |
|
16083 |
} |
|
16084 |
}, { |
|
16085 |
key: '_formatContents', |
|
16086 |
value: function _formatContents(contents) { |
|
16087 |
var p = document.createElement('p'); |
|
16088 |
var lines = contents.split(/(?:\r\n?|\n)/); |
|
16089 |
for (var i = 0, ii = lines.length; i < ii; ++i) { |
|
16090 |
var line = lines[i]; |
|
16091 |
p.appendChild(document.createTextNode(line)); |
|
16092 |
if (i < ii - 1) { |
|
16093 |
p.appendChild(document.createElement('br')); |
|
16094 |
} |
|
16095 |
} |
|
16096 |
return p; |
|
16097 |
} |
|
16098 |
}, { |
|
16099 |
key: '_toggle', |
|
16100 |
value: function _toggle() { |
|
16101 |
if (this.pinned) { |
|
16102 |
this._hide(true); |
|
16103 |
} else { |
|
16104 |
this._show(true); |
|
16105 |
} |
|
16106 |
} |
|
16107 |
}, { |
|
16108 |
key: '_show', |
|
16109 |
value: function _show() { |
|
16110 |
var pin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
|
16111 |
|
|
16112 |
if (pin) { |
|
16113 |
this.pinned = true; |
|
16114 |
} |
|
16115 |
if (this.hideElement.hasAttribute('hidden')) { |
|
16116 |
this.hideElement.removeAttribute('hidden'); |
|
16117 |
this.container.style.zIndex += 1; |
|
16118 |
} |
|
16119 |
} |
|
16120 |
}, { |
|
16121 |
key: '_hide', |
|
16122 |
value: function _hide() { |
|
16123 |
var unpin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; |
|
16124 |
|
|
16125 |
if (unpin) { |
|
16126 |
this.pinned = false; |
|
16127 |
} |
|
16128 |
if (!this.hideElement.hasAttribute('hidden') && !this.pinned) { |
|
16129 |
this.hideElement.setAttribute('hidden', true); |
|
16130 |
this.container.style.zIndex -= 1; |
|
16131 |
} |
|
16132 |
} |
|
16133 |
}]); |
|
16134 |
|
|
16135 |
return PopupElement; |
|
16136 |
}(); |
|
16137 |
|
|
16138 |
var LineAnnotationElement = function (_AnnotationElement5) { |
|
16139 |
_inherits(LineAnnotationElement, _AnnotationElement5); |
|
16140 |
|
|
16141 |
function LineAnnotationElement(parameters) { |
|
16142 |
_classCallCheck(this, LineAnnotationElement); |
|
16143 |
|
|
16144 |
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); |
|
16145 |
return _possibleConstructorReturn(this, (LineAnnotationElement.__proto__ || Object.getPrototypeOf(LineAnnotationElement)).call(this, parameters, isRenderable, true)); |
|
16146 |
} |
|
16147 |
|
|
16148 |
_createClass(LineAnnotationElement, [{ |
|
16149 |
key: 'render', |
|
16150 |
value: function render() { |
|
16151 |
this.container.className = 'lineAnnotation'; |
|
16152 |
var data = this.data; |
|
16153 |
var width = data.rect[2] - data.rect[0]; |
|
16154 |
var height = data.rect[3] - data.rect[1]; |
|
16155 |
var svg = this.svgFactory.create(width, height); |
|
16156 |
var line = this.svgFactory.createElement('svg:line'); |
|
16157 |
line.setAttribute('x1', data.rect[2] - data.lineCoordinates[0]); |
|
16158 |
line.setAttribute('y1', data.rect[3] - data.lineCoordinates[1]); |
|
16159 |
line.setAttribute('x2', data.rect[2] - data.lineCoordinates[2]); |
|
16160 |
line.setAttribute('y2', data.rect[3] - data.lineCoordinates[3]); |
|
16161 |
line.setAttribute('stroke-width', data.borderStyle.width); |
|
16162 |
line.setAttribute('stroke', 'transparent'); |
|
16163 |
svg.appendChild(line); |
|
16164 |
this.container.append(svg); |
|
16165 |
this._createPopup(this.container, line, data); |
|
16166 |
return this.container; |
|
16167 |
} |
|
16168 |
}]); |
|
16169 |
|
|
16170 |
return LineAnnotationElement; |
|
16171 |
}(AnnotationElement); |
|
16172 |
|
|
16173 |
var SquareAnnotationElement = function (_AnnotationElement6) { |
|
16174 |
_inherits(SquareAnnotationElement, _AnnotationElement6); |
|
16175 |
|
|
16176 |
function SquareAnnotationElement(parameters) { |
|
16177 |
_classCallCheck(this, SquareAnnotationElement); |
|
16178 |
|
|
16179 |
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); |
|
16180 |
return _possibleConstructorReturn(this, (SquareAnnotationElement.__proto__ || Object.getPrototypeOf(SquareAnnotationElement)).call(this, parameters, isRenderable, true)); |
|
16181 |
} |
|
16182 |
|
|
16183 |
_createClass(SquareAnnotationElement, [{ |
|
16184 |
key: 'render', |
|
16185 |
value: function render() { |
|
16186 |
this.container.className = 'squareAnnotation'; |
|
16187 |
var data = this.data; |
|
16188 |
var width = data.rect[2] - data.rect[0]; |
|
16189 |
var height = data.rect[3] - data.rect[1]; |
|
16190 |
var svg = this.svgFactory.create(width, height); |
|
16191 |
var borderWidth = data.borderStyle.width; |
|
16192 |
var square = this.svgFactory.createElement('svg:rect'); |
|
16193 |
square.setAttribute('x', borderWidth / 2); |
|
16194 |
square.setAttribute('y', borderWidth / 2); |
|
16195 |
square.setAttribute('width', width - borderWidth); |
|
16196 |
square.setAttribute('height', height - borderWidth); |
|
16197 |
square.setAttribute('stroke-width', borderWidth); |
|
16198 |
square.setAttribute('stroke', 'transparent'); |
|
16199 |
square.setAttribute('fill', 'none'); |
|
16200 |
svg.appendChild(square); |
|
16201 |
this.container.append(svg); |
|
16202 |
this._createPopup(this.container, square, data); |
|
16203 |
return this.container; |
|
16204 |
} |
|
16205 |
}]); |
|
16206 |
|
|
16207 |
return SquareAnnotationElement; |
|
16208 |
}(AnnotationElement); |
|
16209 |
|
|
16210 |
var CircleAnnotationElement = function (_AnnotationElement7) { |
|
16211 |
_inherits(CircleAnnotationElement, _AnnotationElement7); |
|
16212 |
|
|
16213 |
function CircleAnnotationElement(parameters) { |
|
16214 |
_classCallCheck(this, CircleAnnotationElement); |
|
16215 |
|
|
16216 |
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); |
|
16217 |
return _possibleConstructorReturn(this, (CircleAnnotationElement.__proto__ || Object.getPrototypeOf(CircleAnnotationElement)).call(this, parameters, isRenderable, true)); |
|
16218 |
} |
|
16219 |
|
|
16220 |
_createClass(CircleAnnotationElement, [{ |
|
16221 |
key: 'render', |
|
16222 |
value: function render() { |
|
16223 |
this.container.className = 'circleAnnotation'; |
|
16224 |
var data = this.data; |
|
16225 |
var width = data.rect[2] - data.rect[0]; |
|
16226 |
var height = data.rect[3] - data.rect[1]; |
|
16227 |
var svg = this.svgFactory.create(width, height); |
|
16228 |
var borderWidth = data.borderStyle.width; |
|
16229 |
var circle = this.svgFactory.createElement('svg:ellipse'); |
|
16230 |
circle.setAttribute('cx', width / 2); |
|
16231 |
circle.setAttribute('cy', height / 2); |
|
16232 |
circle.setAttribute('rx', width / 2 - borderWidth / 2); |
|
16233 |
circle.setAttribute('ry', height / 2 - borderWidth / 2); |
|
16234 |
circle.setAttribute('stroke-width', borderWidth); |
|
16235 |
circle.setAttribute('stroke', 'transparent'); |
|
16236 |
circle.setAttribute('fill', 'none'); |
|
16237 |
svg.appendChild(circle); |
|
16238 |
this.container.append(svg); |
|
16239 |
this._createPopup(this.container, circle, data); |
|
16240 |
return this.container; |
|
16241 |
} |
|
16242 |
}]); |
|
16243 |
|
|
16244 |
return CircleAnnotationElement; |
|
16245 |
}(AnnotationElement); |
|
16246 |
|
|
16247 |
var PolylineAnnotationElement = function (_AnnotationElement8) { |
|
16248 |
_inherits(PolylineAnnotationElement, _AnnotationElement8); |
|
16249 |
|
|
16250 |
function PolylineAnnotationElement(parameters) { |
|
16251 |
_classCallCheck(this, PolylineAnnotationElement); |
|
16252 |
|
|
16253 |
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); |
|
16254 |
|
|
16255 |
var _this15 = _possibleConstructorReturn(this, (PolylineAnnotationElement.__proto__ || Object.getPrototypeOf(PolylineAnnotationElement)).call(this, parameters, isRenderable, true)); |
|
16256 |
|
|
16257 |
_this15.containerClassName = 'polylineAnnotation'; |
|
16258 |
_this15.svgElementName = 'svg:polyline'; |
|
16259 |
return _this15; |
|
16260 |
} |
|
16261 |
|
|
16262 |
_createClass(PolylineAnnotationElement, [{ |
|
16263 |
key: 'render', |
|
16264 |
value: function render() { |
|
16265 |
this.container.className = this.containerClassName; |
|
16266 |
var data = this.data; |
|
16267 |
var width = data.rect[2] - data.rect[0]; |
|
16268 |
var height = data.rect[3] - data.rect[1]; |
|
16269 |
var svg = this.svgFactory.create(width, height); |
|
16270 |
var vertices = data.vertices; |
|
16271 |
var points = []; |
|
16272 |
for (var i = 0, ii = vertices.length; i < ii; i++) { |
|
16273 |
var x = vertices[i].x - data.rect[0]; |
|
16274 |
var y = data.rect[3] - vertices[i].y; |
|
16275 |
points.push(x + ',' + y); |
|
16276 |
} |
|
16277 |
points = points.join(' '); |
|
16278 |
var borderWidth = data.borderStyle.width; |
|
16279 |
var polyline = this.svgFactory.createElement(this.svgElementName); |
|
16280 |
polyline.setAttribute('points', points); |
|
16281 |
polyline.setAttribute('stroke-width', borderWidth); |
|
16282 |
polyline.setAttribute('stroke', 'transparent'); |
|
16283 |
polyline.setAttribute('fill', 'none'); |
|
16284 |
svg.appendChild(polyline); |
|
16285 |
this.container.append(svg); |
|
16286 |
this._createPopup(this.container, polyline, data); |
|
16287 |
return this.container; |
|
16288 |
} |
|
16289 |
}]); |
|
16290 |
|
|
16291 |
return PolylineAnnotationElement; |
|
16292 |
}(AnnotationElement); |
|
16293 |
|
|
16294 |
var PolygonAnnotationElement = function (_PolylineAnnotationEl) { |
|
16295 |
_inherits(PolygonAnnotationElement, _PolylineAnnotationEl); |
|
16296 |
|
|
16297 |
function PolygonAnnotationElement(parameters) { |
|
16298 |
_classCallCheck(this, PolygonAnnotationElement); |
|
16299 |
|
|
16300 |
var _this16 = _possibleConstructorReturn(this, (PolygonAnnotationElement.__proto__ || Object.getPrototypeOf(PolygonAnnotationElement)).call(this, parameters)); |
|
16301 |
|
|
16302 |
_this16.containerClassName = 'polygonAnnotation'; |
|
16303 |
_this16.svgElementName = 'svg:polygon'; |
|
16304 |
return _this16; |
|
16305 |
} |
|
16306 |
|
|
16307 |
return PolygonAnnotationElement; |
|
16308 |
}(PolylineAnnotationElement); |
|
16309 |
|
|
16310 |
var InkAnnotationElement = function (_AnnotationElement9) { |
|
16311 |
_inherits(InkAnnotationElement, _AnnotationElement9); |
|
16312 |
|
|
16313 |
function InkAnnotationElement(parameters) { |
|
16314 |
_classCallCheck(this, InkAnnotationElement); |
|
16315 |
|
|
16316 |
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); |
|
16317 |
|
|
16318 |
var _this17 = _possibleConstructorReturn(this, (InkAnnotationElement.__proto__ || Object.getPrototypeOf(InkAnnotationElement)).call(this, parameters, isRenderable, true)); |
|
16319 |
|
|
16320 |
_this17.containerClassName = 'inkAnnotation'; |
|
16321 |
_this17.svgElementName = 'svg:polyline'; |
|
16322 |
return _this17; |
|
16323 |
} |
|
16324 |
|
|
16325 |
_createClass(InkAnnotationElement, [{ |
|
16326 |
key: 'render', |
|
16327 |
value: function render() { |
|
16328 |
this.container.className = this.containerClassName; |
|
16329 |
var data = this.data; |
|
16330 |
var width = data.rect[2] - data.rect[0]; |
|
16331 |
var height = data.rect[3] - data.rect[1]; |
|
16332 |
var svg = this.svgFactory.create(width, height); |
|
16333 |
var inkLists = data.inkLists; |
|
16334 |
for (var i = 0, ii = inkLists.length; i < ii; i++) { |
|
16335 |
var inkList = inkLists[i]; |
|
16336 |
var points = []; |
|
16337 |
for (var j = 0, jj = inkList.length; j < jj; j++) { |
|
16338 |
var x = inkList[j].x - data.rect[0]; |
|
16339 |
var y = data.rect[3] - inkList[j].y; |
|
16340 |
points.push(x + ',' + y); |
|
16341 |
} |
|
16342 |
points = points.join(' '); |
|
16343 |
var borderWidth = data.borderStyle.width; |
|
16344 |
var polyline = this.svgFactory.createElement(this.svgElementName); |
|
16345 |
polyline.setAttribute('points', points); |
|
16346 |
polyline.setAttribute('stroke-width', borderWidth); |
|
16347 |
polyline.setAttribute('stroke', 'transparent'); |
|
16348 |
polyline.setAttribute('fill', 'none'); |
|
16349 |
this._createPopup(this.container, polyline, data); |
|
16350 |
svg.appendChild(polyline); |
|
16351 |
} |
|
16352 |
this.container.append(svg); |
|
16353 |
return this.container; |
|
16354 |
} |
|
16355 |
}]); |
|
16356 |
|
|
16357 |
return InkAnnotationElement; |
|
16358 |
}(AnnotationElement); |
|
16359 |
|
|
16360 |
var HighlightAnnotationElement = function (_AnnotationElement10) { |
|
16361 |
_inherits(HighlightAnnotationElement, _AnnotationElement10); |
|
16362 |
|
|
16363 |
function HighlightAnnotationElement(parameters) { |
|
16364 |
_classCallCheck(this, HighlightAnnotationElement); |
|
16365 |
|
|
16366 |
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); |
|
16367 |
return _possibleConstructorReturn(this, (HighlightAnnotationElement.__proto__ || Object.getPrototypeOf(HighlightAnnotationElement)).call(this, parameters, isRenderable, true)); |
|
16368 |
} |
|
16369 |
|
|
16370 |
_createClass(HighlightAnnotationElement, [{ |
|
16371 |
key: 'render', |
|
16372 |
value: function render() { |
|
16373 |
this.container.className = 'highlightAnnotation'; |
|
16374 |
if (!this.data.hasPopup) { |
|
16375 |
this._createPopup(this.container, null, this.data); |
|
16376 |
} |
|
16377 |
return this.container; |
|
16378 |
} |
|
16379 |
}]); |
|
16380 |
|
|
16381 |
return HighlightAnnotationElement; |
|
16382 |
}(AnnotationElement); |
|
16383 |
|
|
16384 |
var UnderlineAnnotationElement = function (_AnnotationElement11) { |
|
16385 |
_inherits(UnderlineAnnotationElement, _AnnotationElement11); |
|
16386 |
|
|
16387 |
function UnderlineAnnotationElement(parameters) { |
|
16388 |
_classCallCheck(this, UnderlineAnnotationElement); |
|
16389 |
|
|
16390 |
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); |
|
16391 |
return _possibleConstructorReturn(this, (UnderlineAnnotationElement.__proto__ || Object.getPrototypeOf(UnderlineAnnotationElement)).call(this, parameters, isRenderable, true)); |
|
16392 |
} |
|
16393 |
|
|
16394 |
_createClass(UnderlineAnnotationElement, [{ |
|
16395 |
key: 'render', |
|
16396 |
value: function render() { |
|
16397 |
this.container.className = 'underlineAnnotation'; |
|
16398 |
if (!this.data.hasPopup) { |
|
16399 |
this._createPopup(this.container, null, this.data); |
|
16400 |
} |
|
16401 |
return this.container; |
|
16402 |
} |
|
16403 |
}]); |
|
16404 |
|
|
16405 |
return UnderlineAnnotationElement; |
|
16406 |
}(AnnotationElement); |
|
16407 |
|
|
16408 |
var SquigglyAnnotationElement = function (_AnnotationElement12) { |
|
16409 |
_inherits(SquigglyAnnotationElement, _AnnotationElement12); |
|
16410 |
|
|
16411 |
function SquigglyAnnotationElement(parameters) { |
|
16412 |
_classCallCheck(this, SquigglyAnnotationElement); |
|
16413 |
|
|
16414 |
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); |
|
16415 |
return _possibleConstructorReturn(this, (SquigglyAnnotationElement.__proto__ || Object.getPrototypeOf(SquigglyAnnotationElement)).call(this, parameters, isRenderable, true)); |
|
16416 |
} |
|
16417 |
|
|
16418 |
_createClass(SquigglyAnnotationElement, [{ |
|
16419 |
key: 'render', |
|
16420 |
value: function render() { |
|
16421 |
this.container.className = 'squigglyAnnotation'; |
|
16422 |
if (!this.data.hasPopup) { |
|
16423 |
this._createPopup(this.container, null, this.data); |
|
16424 |
} |
|
16425 |
return this.container; |
|
16426 |
} |
|
16427 |
}]); |
|
16428 |
|
|
16429 |
return SquigglyAnnotationElement; |
|
16430 |
}(AnnotationElement); |
|
16431 |
|
|
16432 |
var StrikeOutAnnotationElement = function (_AnnotationElement13) { |
|
16433 |
_inherits(StrikeOutAnnotationElement, _AnnotationElement13); |
|
16434 |
|
|
16435 |
function StrikeOutAnnotationElement(parameters) { |
|
16436 |
_classCallCheck(this, StrikeOutAnnotationElement); |
|
16437 |
|
|
16438 |
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); |
|
16439 |
return _possibleConstructorReturn(this, (StrikeOutAnnotationElement.__proto__ || Object.getPrototypeOf(StrikeOutAnnotationElement)).call(this, parameters, isRenderable, true)); |
|
16440 |
} |
|
16441 |
|
|
16442 |
_createClass(StrikeOutAnnotationElement, [{ |
|
16443 |
key: 'render', |
|
16444 |
value: function render() { |
|
16445 |
this.container.className = 'strikeoutAnnotation'; |
|
16446 |
if (!this.data.hasPopup) { |
|
16447 |
this._createPopup(this.container, null, this.data); |
|
16448 |
} |
|
16449 |
return this.container; |
|
16450 |
} |
|
16451 |
}]); |
|
16452 |
|
|
16453 |
return StrikeOutAnnotationElement; |
|
16454 |
}(AnnotationElement); |
|
16455 |
|
|
16456 |
var StampAnnotationElement = function (_AnnotationElement14) { |
|
16457 |
_inherits(StampAnnotationElement, _AnnotationElement14); |
|
16458 |
|
|
16459 |
function StampAnnotationElement(parameters) { |
|
16460 |
_classCallCheck(this, StampAnnotationElement); |
|
16461 |
|
|
16462 |
var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents); |
|
16463 |
return _possibleConstructorReturn(this, (StampAnnotationElement.__proto__ || Object.getPrototypeOf(StampAnnotationElement)).call(this, parameters, isRenderable, true)); |
|
16464 |
} |
|
16465 |
|
|
16466 |
_createClass(StampAnnotationElement, [{ |
|
16467 |
key: 'render', |
|
16468 |
value: function render() { |
|
16469 |
this.container.className = 'stampAnnotation'; |
|
16470 |
if (!this.data.hasPopup) { |
|
16471 |
this._createPopup(this.container, null, this.data); |
|
16472 |
} |
|
16473 |
return this.container; |
|
16474 |
} |
|
16475 |
}]); |
|
16476 |
|
|
16477 |
return StampAnnotationElement; |
|
16478 |
}(AnnotationElement); |
|
16479 |
|
|
16480 |
var FileAttachmentAnnotationElement = function (_AnnotationElement15) { |
|
16481 |
_inherits(FileAttachmentAnnotationElement, _AnnotationElement15); |
|
16482 |
|
|
16483 |
function FileAttachmentAnnotationElement(parameters) { |
|
16484 |
_classCallCheck(this, FileAttachmentAnnotationElement); |
|
16485 |
|
|
16486 |
var _this23 = _possibleConstructorReturn(this, (FileAttachmentAnnotationElement.__proto__ || Object.getPrototypeOf(FileAttachmentAnnotationElement)).call(this, parameters, true)); |
|
16487 |
|
|
16488 |
var _this23$data$file = _this23.data.file, |
|
16489 |
filename = _this23$data$file.filename, |
|
16490 |
content = _this23$data$file.content; |
|
16491 |
|
|
16492 |
_this23.filename = (0, _dom_utils.getFilenameFromUrl)(filename); |
|
16493 |
_this23.content = content; |
|
16494 |
if (_this23.linkService.eventBus) { |
|
16495 |
_this23.linkService.eventBus.dispatch('fileattachmentannotation', { |
|
16496 |
source: _this23, |
|
16497 |
id: (0, _util.stringToPDFString)(filename), |
|
16498 |
filename: filename, |
|
16499 |
content: content |
|
16500 |
}); |
|
16501 |
} |
|
16502 |
return _this23; |
|
16503 |
} |
|
16504 |
|
|
16505 |
_createClass(FileAttachmentAnnotationElement, [{ |
|
16506 |
key: 'render', |
|
16507 |
value: function render() { |
|
16508 |
this.container.className = 'fileAttachmentAnnotation'; |
|
16509 |
var trigger = document.createElement('div'); |
|
16510 |
trigger.style.height = this.container.style.height; |
|
16511 |
trigger.style.width = this.container.style.width; |
|
16512 |
trigger.addEventListener('dblclick', this._download.bind(this)); |
|
16513 |
if (!this.data.hasPopup && (this.data.title || this.data.contents)) { |
|
16514 |
this._createPopup(this.container, trigger, this.data); |
|
16515 |
} |
|
16516 |
this.container.appendChild(trigger); |
|
16517 |
return this.container; |
|
16518 |
} |
|
16519 |
}, { |
|
16520 |
key: '_download', |
|
16521 |
value: function _download() { |
|
16522 |
if (!this.downloadManager) { |
|
16523 |
(0, _util.warn)('Download cannot be started due to unavailable download manager'); |
|
16524 |
return; |
|
16525 |
} |
|
16526 |
this.downloadManager.downloadData(this.content, this.filename, ''); |
|
16527 |
} |
|
16528 |
}]); |
|
16529 |
|
|
16530 |
return FileAttachmentAnnotationElement; |
|
16531 |
}(AnnotationElement); |
|
16532 |
|
|
16533 |
var AnnotationLayer = function () { |
|
16534 |
function AnnotationLayer() { |
|
16535 |
_classCallCheck(this, AnnotationLayer); |
|
16536 |
} |
|
16537 |
|
|
16538 |
_createClass(AnnotationLayer, null, [{ |
|
16539 |
key: 'render', |
|
16540 |
value: function render(parameters) { |
|
16541 |
for (var i = 0, ii = parameters.annotations.length; i < ii; i++) { |
|
16542 |
var data = parameters.annotations[i]; |
|
16543 |
if (!data) { |
|
16544 |
continue; |
|
16545 |
} |
|
16546 |
var element = AnnotationElementFactory.create({ |
|
16547 |
data: data, |
|
16548 |
layer: parameters.div, |
|
16549 |
page: parameters.page, |
|
16550 |
viewport: parameters.viewport, |
|
16551 |
linkService: parameters.linkService, |
|
16552 |
downloadManager: parameters.downloadManager, |
|
16553 |
imageResourcesPath: parameters.imageResourcesPath || '', |
|
16554 |
renderInteractiveForms: parameters.renderInteractiveForms || false, |
|
16555 |
svgFactory: new _dom_utils.DOMSVGFactory() |
|
16556 |
}); |
|
16557 |
if (element.isRenderable) { |
|
16558 |
parameters.div.appendChild(element.render()); |
|
16559 |
} |
|
16560 |
} |
|
16561 |
} |
|
16562 |
}, { |
|
16563 |
key: 'update', |
|
16564 |
value: function update(parameters) { |
|
16565 |
for (var i = 0, ii = parameters.annotations.length; i < ii; i++) { |
|
16566 |
var data = parameters.annotations[i]; |
|
16567 |
var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]'); |
|
16568 |
if (element) { |
|
16569 |
element.style.transform = 'matrix(' + parameters.viewport.transform.join(',') + ')'; |
|
16570 |
} |
|
16571 |
} |
|
16572 |
parameters.div.removeAttribute('hidden'); |
|
16573 |
} |
|
16574 |
}]); |
|
16575 |
|
|
16576 |
return AnnotationLayer; |
|
16577 |
}(); |
|
16578 |
|
|
16579 |
exports.AnnotationLayer = AnnotationLayer; |
|
16580 |
|
|
16581 |
/***/ }), |
|
16582 |
/* 147 */ |
|
16583 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
16584 |
|
|
16585 |
"use strict"; |
|
16586 |
|
|
16587 |
|
|
16588 |
Object.defineProperty(exports, "__esModule", { |
|
16589 |
value: true |
|
16590 |
}); |
|
16591 |
exports.SVGGraphics = undefined; |
|
16592 |
|
|
16593 |
var _util = __w_pdfjs_require__(1); |
|
16594 |
|
|
16595 |
var _dom_utils = __w_pdfjs_require__(130); |
|
16596 |
|
|
16597 |
var _is_node = __w_pdfjs_require__(4); |
|
16598 |
|
|
16599 |
var _is_node2 = _interopRequireDefault(_is_node); |
|
16600 |
|
|
16601 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
16602 |
|
|
16603 |
var SVGGraphics = function SVGGraphics() { |
|
16604 |
throw new Error('Not implemented: SVGGraphics'); |
|
16605 |
}; |
|
16606 |
{ |
|
16607 |
var SVG_DEFAULTS = { |
|
16608 |
fontStyle: 'normal', |
|
16609 |
fontWeight: 'normal', |
|
16610 |
fillColor: '#000000' |
|
16611 |
}; |
|
16612 |
var convertImgDataToPng = function convertImgDataToPngClosure() { |
|
16613 |
var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]); |
|
16614 |
var CHUNK_WRAPPER_SIZE = 12; |
|
16615 |
var crcTable = new Int32Array(256); |
|
16616 |
for (var i = 0; i < 256; i++) { |
|
16617 |
var c = i; |
|
16618 |
for (var h = 0; h < 8; h++) { |
|
16619 |
if (c & 1) { |
|
16620 |
c = 0xedB88320 ^ c >> 1 & 0x7fffffff; |
|
16621 |
} else { |
|
16622 |
c = c >> 1 & 0x7fffffff; |
|
16623 |
} |
|
16624 |
} |
|
16625 |
crcTable[i] = c; |
|
16626 |
} |
|
16627 |
function crc32(data, start, end) { |
|
16628 |
var crc = -1; |
|
16629 |
for (var i = start; i < end; i++) { |
|
16630 |
var a = (crc ^ data[i]) & 0xff; |
|
16631 |
var b = crcTable[a]; |
|
16632 |
crc = crc >>> 8 ^ b; |
|
16633 |
} |
|
16634 |
return crc ^ -1; |
|
16635 |
} |
|
16636 |
function writePngChunk(type, body, data, offset) { |
|
16637 |
var p = offset; |
|
16638 |
var len = body.length; |
|
16639 |
data[p] = len >> 24 & 0xff; |
|
16640 |
data[p + 1] = len >> 16 & 0xff; |
|
16641 |
data[p + 2] = len >> 8 & 0xff; |
|
16642 |
data[p + 3] = len & 0xff; |
|
16643 |
p += 4; |
|
16644 |
data[p] = type.charCodeAt(0) & 0xff; |
|
16645 |
data[p + 1] = type.charCodeAt(1) & 0xff; |
|
16646 |
data[p + 2] = type.charCodeAt(2) & 0xff; |
|
16647 |
data[p + 3] = type.charCodeAt(3) & 0xff; |
|
16648 |
p += 4; |
|
16649 |
data.set(body, p); |
|
16650 |
p += body.length; |
|
16651 |
var crc = crc32(data, offset + 4, p); |
|
16652 |
data[p] = crc >> 24 & 0xff; |
|
16653 |
data[p + 1] = crc >> 16 & 0xff; |
|
16654 |
data[p + 2] = crc >> 8 & 0xff; |
|
16655 |
data[p + 3] = crc & 0xff; |
|
16656 |
} |
|
16657 |
function adler32(data, start, end) { |
|
16658 |
var a = 1; |
|
16659 |
var b = 0; |
|
16660 |
for (var i = start; i < end; ++i) { |
|
16661 |
a = (a + (data[i] & 0xff)) % 65521; |
|
16662 |
b = (b + a) % 65521; |
|
16663 |
} |
|
16664 |
return b << 16 | a; |
|
16665 |
} |
|
16666 |
function deflateSync(literals) { |
|
16667 |
if (!(0, _is_node2.default)()) { |
|
16668 |
return deflateSyncUncompressed(literals); |
|
16669 |
} |
|
16670 |
try { |
|
16671 |
var input; |
|
16672 |
if (parseInt(process.versions.node) >= 8) { |
|
16673 |
input = literals; |
|
16674 |
} else { |
|
16675 |
input = new Buffer(literals); |
|
16676 |
} |
|
16677 |
var output = require('zlib').deflateSync(input, { level: 9 }); |
|
16678 |
return output instanceof Uint8Array ? output : new Uint8Array(output); |
|
16679 |
} catch (e) { |
|
16680 |
(0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e); |
|
16681 |
} |
|
16682 |
return deflateSyncUncompressed(literals); |
|
16683 |
} |
|
16684 |
function deflateSyncUncompressed(literals) { |
|
16685 |
var len = literals.length; |
|
16686 |
var maxBlockLength = 0xFFFF; |
|
16687 |
var deflateBlocks = Math.ceil(len / maxBlockLength); |
|
16688 |
var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4); |
|
16689 |
var pi = 0; |
|
16690 |
idat[pi++] = 0x78; |
|
16691 |
idat[pi++] = 0x9c; |
|
16692 |
var pos = 0; |
|
16693 |
while (len > maxBlockLength) { |
|
16694 |
idat[pi++] = 0x00; |
|
16695 |
idat[pi++] = 0xff; |
|
16696 |
idat[pi++] = 0xff; |
|
16697 |
idat[pi++] = 0x00; |
|
16698 |
idat[pi++] = 0x00; |
|
16699 |
idat.set(literals.subarray(pos, pos + maxBlockLength), pi); |
|
16700 |
pi += maxBlockLength; |
|
16701 |
pos += maxBlockLength; |
|
16702 |
len -= maxBlockLength; |
|
16703 |
} |
|
16704 |
idat[pi++] = 0x01; |
|
16705 |
idat[pi++] = len & 0xff; |
|
16706 |
idat[pi++] = len >> 8 & 0xff; |
|
16707 |
idat[pi++] = ~len & 0xffff & 0xff; |
|
16708 |
idat[pi++] = (~len & 0xffff) >> 8 & 0xff; |
|
16709 |
idat.set(literals.subarray(pos), pi); |
|
16710 |
pi += literals.length - pos; |
|
16711 |
var adler = adler32(literals, 0, literals.length); |
|
16712 |
idat[pi++] = adler >> 24 & 0xff; |
|
16713 |
idat[pi++] = adler >> 16 & 0xff; |
|
16714 |
idat[pi++] = adler >> 8 & 0xff; |
|
16715 |
idat[pi++] = adler & 0xff; |
|
16716 |
return idat; |
|
16717 |
} |
|
16718 |
function encode(imgData, kind, forceDataSchema, isMask) { |
|
16719 |
var width = imgData.width; |
|
16720 |
var height = imgData.height; |
|
16721 |
var bitDepth, colorType, lineSize; |
|
16722 |
var bytes = imgData.data; |
|
16723 |
switch (kind) { |
|
16724 |
case _util.ImageKind.GRAYSCALE_1BPP: |
|
16725 |
colorType = 0; |
|
16726 |
bitDepth = 1; |
|
16727 |
lineSize = width + 7 >> 3; |
|
16728 |
break; |
|
16729 |
case _util.ImageKind.RGB_24BPP: |
|
16730 |
colorType = 2; |
|
16731 |
bitDepth = 8; |
|
16732 |
lineSize = width * 3; |
|
16733 |
break; |
|
16734 |
case _util.ImageKind.RGBA_32BPP: |
|
16735 |
colorType = 6; |
|
16736 |
bitDepth = 8; |
|
16737 |
lineSize = width * 4; |
|
16738 |
break; |
|
16739 |
default: |
|
16740 |
throw new Error('invalid format'); |
|
16741 |
} |
|
16742 |
var literals = new Uint8Array((1 + lineSize) * height); |
|
16743 |
var offsetLiterals = 0, |
|
16744 |
offsetBytes = 0; |
|
16745 |
var y, i; |
|
16746 |
for (y = 0; y < height; ++y) { |
|
16747 |
literals[offsetLiterals++] = 0; |
|
16748 |
literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals); |
|
16749 |
offsetBytes += lineSize; |
|
16750 |
offsetLiterals += lineSize; |
|
16751 |
} |
|
16752 |
if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) { |
|
16753 |
offsetLiterals = 0; |
|
16754 |
for (y = 0; y < height; y++) { |
|
16755 |
offsetLiterals++; |
|
16756 |
for (i = 0; i < lineSize; i++) { |
|
16757 |
literals[offsetLiterals++] ^= 0xFF; |
|
16758 |
} |
|
16759 |
} |
|
16760 |
} |
|
16761 |
var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]); |
|
16762 |
var idat = deflateSync(literals); |
|
16763 |
var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length; |
|
16764 |
var data = new Uint8Array(pngLength); |
|
16765 |
var offset = 0; |
|
16766 |
data.set(PNG_HEADER, offset); |
|
16767 |
offset += PNG_HEADER.length; |
|
16768 |
writePngChunk('IHDR', ihdr, data, offset); |
|
16769 |
offset += CHUNK_WRAPPER_SIZE + ihdr.length; |
|
16770 |
writePngChunk('IDATA', idat, data, offset); |
|
16771 |
offset += CHUNK_WRAPPER_SIZE + idat.length; |
|
16772 |
writePngChunk('IEND', new Uint8Array(0), data, offset); |
|
16773 |
return (0, _util.createObjectURL)(data, 'image/png', forceDataSchema); |
|
16774 |
} |
|
16775 |
return function convertImgDataToPng(imgData, forceDataSchema, isMask) { |
|
16776 |
var kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind; |
|
16777 |
return encode(imgData, kind, forceDataSchema, isMask); |
|
16778 |
}; |
|
16779 |
}(); |
|
16780 |
var SVGExtraState = function SVGExtraStateClosure() { |
|
16781 |
function SVGExtraState() { |
|
16782 |
this.fontSizeScale = 1; |
|
16783 |
this.fontWeight = SVG_DEFAULTS.fontWeight; |
|
16784 |
this.fontSize = 0; |
|
16785 |
this.textMatrix = _util.IDENTITY_MATRIX; |
|
16786 |
this.fontMatrix = _util.FONT_IDENTITY_MATRIX; |
|
16787 |
this.leading = 0; |
|
16788 |
this.textRenderingMode = _util.TextRenderingMode.FILL; |
|
16789 |
this.x = 0; |
|
16790 |
this.y = 0; |
|
16791 |
this.lineX = 0; |
|
16792 |
this.lineY = 0; |
|
16793 |
this.charSpacing = 0; |
|
16794 |
this.wordSpacing = 0; |
|
16795 |
this.textHScale = 1; |
|
16796 |
this.textRise = 0; |
|
16797 |
this.fillColor = SVG_DEFAULTS.fillColor; |
|
16798 |
this.strokeColor = '#000000'; |
|
16799 |
this.fillAlpha = 1; |
|
16800 |
this.strokeAlpha = 1; |
|
16801 |
this.lineWidth = 1; |
|
16802 |
this.lineJoin = ''; |
|
16803 |
this.lineCap = ''; |
|
16804 |
this.miterLimit = 0; |
|
16805 |
this.dashArray = []; |
|
16806 |
this.dashPhase = 0; |
|
16807 |
this.dependencies = []; |
|
16808 |
this.activeClipUrl = null; |
|
16809 |
this.clipGroup = null; |
|
16810 |
this.maskId = ''; |
|
16811 |
} |
|
16812 |
SVGExtraState.prototype = { |
|
16813 |
clone: function SVGExtraState_clone() { |
|
16814 |
return Object.create(this); |
|
16815 |
}, |
|
16816 |
setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) { |
|
16817 |
this.x = x; |
|
16818 |
this.y = y; |
|
16819 |
} |
|
16820 |
}; |
|
16821 |
return SVGExtraState; |
|
16822 |
}(); |
|
16823 |
exports.SVGGraphics = SVGGraphics = function SVGGraphicsClosure() { |
|
16824 |
function opListToTree(opList) { |
|
16825 |
var opTree = []; |
|
16826 |
var tmp = []; |
|
16827 |
var opListLen = opList.length; |
|
16828 |
for (var x = 0; x < opListLen; x++) { |
|
16829 |
if (opList[x].fn === 'save') { |
|
16830 |
opTree.push({ |
|
16831 |
'fnId': 92, |
|
16832 |
'fn': 'group', |
|
16833 |
'items': [] |
|
16834 |
}); |
|
16835 |
tmp.push(opTree); |
|
16836 |
opTree = opTree[opTree.length - 1].items; |
|
16837 |
continue; |
|
16838 |
} |
|
16839 |
if (opList[x].fn === 'restore') { |
|
16840 |
opTree = tmp.pop(); |
|
16841 |
} else { |
|
16842 |
opTree.push(opList[x]); |
|
16843 |
} |
|
16844 |
} |
|
16845 |
return opTree; |
|
16846 |
} |
|
16847 |
function pf(value) { |
|
16848 |
if (Number.isInteger(value)) { |
|
16849 |
return value.toString(); |
|
16850 |
} |
|
16851 |
var s = value.toFixed(10); |
|
16852 |
var i = s.length - 1; |
|
16853 |
if (s[i] !== '0') { |
|
16854 |
return s; |
|
16855 |
} |
|
16856 |
do { |
|
16857 |
i--; |
|
16858 |
} while (s[i] === '0'); |
|
16859 |
return s.substring(0, s[i] === '.' ? i : i + 1); |
|
16860 |
} |
|
16861 |
function pm(m) { |
|
16862 |
if (m[4] === 0 && m[5] === 0) { |
|
16863 |
if (m[1] === 0 && m[2] === 0) { |
|
16864 |
if (m[0] === 1 && m[3] === 1) { |
|
16865 |
return ''; |
|
16866 |
} |
|
16867 |
return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')'; |
|
16868 |
} |
|
16869 |
if (m[0] === m[3] && m[1] === -m[2]) { |
|
16870 |
var a = Math.acos(m[0]) * 180 / Math.PI; |
|
16871 |
return 'rotate(' + pf(a) + ')'; |
|
16872 |
} |
|
16873 |
} else { |
|
16874 |
if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) { |
|
16875 |
return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')'; |
|
16876 |
} |
|
16877 |
} |
|
16878 |
return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')'; |
|
16879 |
} |
|
16880 |
function SVGGraphics(commonObjs, objs, forceDataSchema) { |
|
16881 |
this.svgFactory = new _dom_utils.DOMSVGFactory(); |
|
16882 |
this.current = new SVGExtraState(); |
|
16883 |
this.transformMatrix = _util.IDENTITY_MATRIX; |
|
16884 |
this.transformStack = []; |
|
16885 |
this.extraStack = []; |
|
16886 |
this.commonObjs = commonObjs; |
|
16887 |
this.objs = objs; |
|
16888 |
this.pendingClip = null; |
|
16889 |
this.pendingEOFill = false; |
|
16890 |
this.embedFonts = false; |
|
16891 |
this.embeddedFonts = Object.create(null); |
|
16892 |
this.cssStyle = null; |
|
16893 |
this.forceDataSchema = !!forceDataSchema; |
|
16894 |
} |
|
16895 |
var XML_NS = 'http://www.w3.org/XML/1998/namespace'; |
|
16896 |
var XLINK_NS = 'http://www.w3.org/1999/xlink'; |
|
16897 |
var LINE_CAP_STYLES = ['butt', 'round', 'square']; |
|
16898 |
var LINE_JOIN_STYLES = ['miter', 'round', 'bevel']; |
|
16899 |
var clipCount = 0; |
|
16900 |
var maskCount = 0; |
|
16901 |
SVGGraphics.prototype = { |
|
16902 |
save: function SVGGraphics_save() { |
|
16903 |
this.transformStack.push(this.transformMatrix); |
|
16904 |
var old = this.current; |
|
16905 |
this.extraStack.push(old); |
|
16906 |
this.current = old.clone(); |
|
16907 |
}, |
|
16908 |
restore: function SVGGraphics_restore() { |
|
16909 |
this.transformMatrix = this.transformStack.pop(); |
|
16910 |
this.current = this.extraStack.pop(); |
|
16911 |
this.pendingClip = null; |
|
16912 |
this.tgrp = null; |
|
16913 |
}, |
|
16914 |
group: function SVGGraphics_group(items) { |
|
16915 |
this.save(); |
|
16916 |
this.executeOpTree(items); |
|
16917 |
this.restore(); |
|
16918 |
}, |
|
16919 |
loadDependencies: function SVGGraphics_loadDependencies(operatorList) { |
|
16920 |
var _this = this; |
|
16921 |
|
|
16922 |
var fnArray = operatorList.fnArray; |
|
16923 |
var fnArrayLen = fnArray.length; |
|
16924 |
var argsArray = operatorList.argsArray; |
|
16925 |
for (var i = 0; i < fnArrayLen; i++) { |
|
16926 |
if (_util.OPS.dependency === fnArray[i]) { |
|
16927 |
var deps = argsArray[i]; |
|
16928 |
for (var n = 0, nn = deps.length; n < nn; n++) { |
|
16929 |
var obj = deps[n]; |
|
16930 |
var common = obj.substring(0, 2) === 'g_'; |
|
16931 |
var promise; |
|
16932 |
if (common) { |
|
16933 |
promise = new Promise(function (resolve) { |
|
16934 |
_this.commonObjs.get(obj, resolve); |
|
16935 |
}); |
|
16936 |
} else { |
|
16937 |
promise = new Promise(function (resolve) { |
|
16938 |
_this.objs.get(obj, resolve); |
|
16939 |
}); |
|
16940 |
} |
|
16941 |
this.current.dependencies.push(promise); |
|
16942 |
} |
|
16943 |
} |
|
16944 |
} |
|
16945 |
return Promise.all(this.current.dependencies); |
|
16946 |
}, |
|
16947 |
transform: function SVGGraphics_transform(a, b, c, d, e, f) { |
|
16948 |
var transformMatrix = [a, b, c, d, e, f]; |
|
16949 |
this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix); |
|
16950 |
this.tgrp = null; |
|
16951 |
}, |
|
16952 |
getSVG: function SVGGraphics_getSVG(operatorList, viewport) { |
|
16953 |
var _this2 = this; |
|
16954 |
|
|
16955 |
this.viewport = viewport; |
|
16956 |
var svgElement = this._initialize(viewport); |
|
16957 |
return this.loadDependencies(operatorList).then(function () { |
|
16958 |
_this2.transformMatrix = _util.IDENTITY_MATRIX; |
|
16959 |
var opTree = _this2.convertOpList(operatorList); |
|
16960 |
_this2.executeOpTree(opTree); |
|
16961 |
return svgElement; |
|
16962 |
}); |
|
16963 |
}, |
|
16964 |
convertOpList: function SVGGraphics_convertOpList(operatorList) { |
|
16965 |
var argsArray = operatorList.argsArray; |
|
16966 |
var fnArray = operatorList.fnArray; |
|
16967 |
var fnArrayLen = fnArray.length; |
|
16968 |
var REVOPS = []; |
|
16969 |
var opList = []; |
|
16970 |
for (var op in _util.OPS) { |
|
16971 |
REVOPS[_util.OPS[op]] = op; |
|
16972 |
} |
|
16973 |
for (var x = 0; x < fnArrayLen; x++) { |
|
16974 |
var fnId = fnArray[x]; |
|
16975 |
opList.push({ |
|
16976 |
'fnId': fnId, |
|
16977 |
'fn': REVOPS[fnId], |
|
16978 |
'args': argsArray[x] |
|
16979 |
}); |
|
16980 |
} |
|
16981 |
return opListToTree(opList); |
|
16982 |
}, |
|
16983 |
executeOpTree: function SVGGraphics_executeOpTree(opTree) { |
|
16984 |
var opTreeLen = opTree.length; |
|
16985 |
for (var x = 0; x < opTreeLen; x++) { |
|
16986 |
var fn = opTree[x].fn; |
|
16987 |
var fnId = opTree[x].fnId; |
|
16988 |
var args = opTree[x].args; |
|
16989 |
switch (fnId | 0) { |
|
16990 |
case _util.OPS.beginText: |
|
16991 |
this.beginText(); |
|
16992 |
break; |
|
16993 |
case _util.OPS.dependency: |
|
16994 |
break; |
|
16995 |
case _util.OPS.setLeading: |
|
16996 |
this.setLeading(args); |
|
16997 |
break; |
|
16998 |
case _util.OPS.setLeadingMoveText: |
|
16999 |
this.setLeadingMoveText(args[0], args[1]); |
|
17000 |
break; |
|
17001 |
case _util.OPS.setFont: |
|
17002 |
this.setFont(args); |
|
17003 |
break; |
|
17004 |
case _util.OPS.showText: |
|
17005 |
this.showText(args[0]); |
|
17006 |
break; |
|
17007 |
case _util.OPS.showSpacedText: |
|
17008 |
this.showText(args[0]); |
|
17009 |
break; |
|
17010 |
case _util.OPS.endText: |
|
17011 |
this.endText(); |
|
17012 |
break; |
|
17013 |
case _util.OPS.moveText: |
|
17014 |
this.moveText(args[0], args[1]); |
|
17015 |
break; |
|
17016 |
case _util.OPS.setCharSpacing: |
|
17017 |
this.setCharSpacing(args[0]); |
|
17018 |
break; |
|
17019 |
case _util.OPS.setWordSpacing: |
|
17020 |
this.setWordSpacing(args[0]); |
|
17021 |
break; |
|
17022 |
case _util.OPS.setHScale: |
|
17023 |
this.setHScale(args[0]); |
|
17024 |
break; |
|
17025 |
case _util.OPS.setTextMatrix: |
|
17026 |
this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]); |
|
17027 |
break; |
|
17028 |
case _util.OPS.setTextRise: |
|
17029 |
this.setTextRise(args[0]); |
|
17030 |
break; |
|
17031 |
case _util.OPS.setTextRenderingMode: |
|
17032 |
this.setTextRenderingMode(args[0]); |
|
17033 |
break; |
|
17034 |
case _util.OPS.setLineWidth: |
|
17035 |
this.setLineWidth(args[0]); |
|
17036 |
break; |
|
17037 |
case _util.OPS.setLineJoin: |
|
17038 |
this.setLineJoin(args[0]); |
|
17039 |
break; |
|
17040 |
case _util.OPS.setLineCap: |
|
17041 |
this.setLineCap(args[0]); |
|
17042 |
break; |
|
17043 |
case _util.OPS.setMiterLimit: |
|
17044 |
this.setMiterLimit(args[0]); |
|
17045 |
break; |
|
17046 |
case _util.OPS.setFillRGBColor: |
|
17047 |
this.setFillRGBColor(args[0], args[1], args[2]); |
|
17048 |
break; |
|
17049 |
case _util.OPS.setStrokeRGBColor: |
|
17050 |
this.setStrokeRGBColor(args[0], args[1], args[2]); |
|
17051 |
break; |
|
17052 |
case _util.OPS.setDash: |
|
17053 |
this.setDash(args[0], args[1]); |
|
17054 |
break; |
|
17055 |
case _util.OPS.setGState: |
|
17056 |
this.setGState(args[0]); |
|
17057 |
break; |
|
17058 |
case _util.OPS.fill: |
|
17059 |
this.fill(); |
|
17060 |
break; |
|
17061 |
case _util.OPS.eoFill: |
|
17062 |
this.eoFill(); |
|
17063 |
break; |
|
17064 |
case _util.OPS.stroke: |
|
17065 |
this.stroke(); |
|
17066 |
break; |
|
17067 |
case _util.OPS.fillStroke: |
|
17068 |
this.fillStroke(); |
|
17069 |
break; |
|
17070 |
case _util.OPS.eoFillStroke: |
|
17071 |
this.eoFillStroke(); |
|
17072 |
break; |
|
17073 |
case _util.OPS.clip: |
|
17074 |
this.clip('nonzero'); |
|
17075 |
break; |
|
17076 |
case _util.OPS.eoClip: |
|
17077 |
this.clip('evenodd'); |
|
17078 |
break; |
|
17079 |
case _util.OPS.paintSolidColorImageMask: |
|
17080 |
this.paintSolidColorImageMask(); |
|
17081 |
break; |
|
17082 |
case _util.OPS.paintJpegXObject: |
|
17083 |
this.paintJpegXObject(args[0], args[1], args[2]); |
|
17084 |
break; |
|
17085 |
case _util.OPS.paintImageXObject: |
|
17086 |
this.paintImageXObject(args[0]); |
|
17087 |
break; |
|
17088 |
case _util.OPS.paintInlineImageXObject: |
|
17089 |
this.paintInlineImageXObject(args[0]); |
|
17090 |
break; |
|
17091 |
case _util.OPS.paintImageMaskXObject: |
|
17092 |
this.paintImageMaskXObject(args[0]); |
|
17093 |
break; |
|
17094 |
case _util.OPS.paintFormXObjectBegin: |
|
17095 |
this.paintFormXObjectBegin(args[0], args[1]); |
|
17096 |
break; |
|
17097 |
case _util.OPS.paintFormXObjectEnd: |
|
17098 |
this.paintFormXObjectEnd(); |
|
17099 |
break; |
|
17100 |
case _util.OPS.closePath: |
|
17101 |
this.closePath(); |
|
17102 |
break; |
|
17103 |
case _util.OPS.closeStroke: |
|
17104 |
this.closeStroke(); |
|
17105 |
break; |
|
17106 |
case _util.OPS.closeFillStroke: |
|
17107 |
this.closeFillStroke(); |
|
17108 |
break; |
|
17109 |
case _util.OPS.closeEOFillStroke: |
|
17110 |
this.closeEOFillStroke(); |
|
17111 |
break; |
|
17112 |
case _util.OPS.nextLine: |
|
17113 |
this.nextLine(); |
|
17114 |
break; |
|
17115 |
case _util.OPS.transform: |
|
17116 |
this.transform(args[0], args[1], args[2], args[3], args[4], args[5]); |
|
17117 |
break; |
|
17118 |
case _util.OPS.constructPath: |
|
17119 |
this.constructPath(args[0], args[1]); |
|
17120 |
break; |
|
17121 |
case _util.OPS.endPath: |
|
17122 |
this.endPath(); |
|
17123 |
break; |
|
17124 |
case 92: |
|
17125 |
this.group(opTree[x].items); |
|
17126 |
break; |
|
17127 |
default: |
|
17128 |
(0, _util.warn)('Unimplemented operator ' + fn); |
|
17129 |
break; |
|
17130 |
} |
|
17131 |
} |
|
17132 |
}, |
|
17133 |
setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) { |
|
17134 |
this.current.wordSpacing = wordSpacing; |
|
17135 |
}, |
|
17136 |
setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) { |
|
17137 |
this.current.charSpacing = charSpacing; |
|
17138 |
}, |
|
17139 |
nextLine: function SVGGraphics_nextLine() { |
|
17140 |
this.moveText(0, this.current.leading); |
|
17141 |
}, |
|
17142 |
setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) { |
|
17143 |
var current = this.current; |
|
17144 |
this.current.textMatrix = this.current.lineMatrix = [a, b, c, d, e, f]; |
|
17145 |
this.current.x = this.current.lineX = 0; |
|
17146 |
this.current.y = this.current.lineY = 0; |
|
17147 |
current.xcoords = []; |
|
17148 |
current.tspan = this.svgFactory.createElement('svg:tspan'); |
|
17149 |
current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); |
|
17150 |
current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px'); |
|
17151 |
current.tspan.setAttributeNS(null, 'y', pf(-current.y)); |
|
17152 |
current.txtElement = this.svgFactory.createElement('svg:text'); |
|
17153 |
current.txtElement.appendChild(current.tspan); |
|
17154 |
}, |
|
17155 |
beginText: function SVGGraphics_beginText() { |
|
17156 |
this.current.x = this.current.lineX = 0; |
|
17157 |
this.current.y = this.current.lineY = 0; |
|
17158 |
this.current.textMatrix = _util.IDENTITY_MATRIX; |
|
17159 |
this.current.lineMatrix = _util.IDENTITY_MATRIX; |
|
17160 |
this.current.tspan = this.svgFactory.createElement('svg:tspan'); |
|
17161 |
this.current.txtElement = this.svgFactory.createElement('svg:text'); |
|
17162 |
this.current.txtgrp = this.svgFactory.createElement('svg:g'); |
|
17163 |
this.current.xcoords = []; |
|
17164 |
}, |
|
17165 |
moveText: function SVGGraphics_moveText(x, y) { |
|
17166 |
var current = this.current; |
|
17167 |
this.current.x = this.current.lineX += x; |
|
17168 |
this.current.y = this.current.lineY += y; |
|
17169 |
current.xcoords = []; |
|
17170 |
current.tspan = this.svgFactory.createElement('svg:tspan'); |
|
17171 |
current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); |
|
17172 |
current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px'); |
|
17173 |
current.tspan.setAttributeNS(null, 'y', pf(-current.y)); |
|
17174 |
}, |
|
17175 |
showText: function SVGGraphics_showText(glyphs) { |
|
17176 |
var current = this.current; |
|
17177 |
var font = current.font; |
|
17178 |
var fontSize = current.fontSize; |
|
17179 |
if (fontSize === 0) { |
|
17180 |
return; |
|
17181 |
} |
|
17182 |
var charSpacing = current.charSpacing; |
|
17183 |
var wordSpacing = current.wordSpacing; |
|
17184 |
var fontDirection = current.fontDirection; |
|
17185 |
var textHScale = current.textHScale * fontDirection; |
|
17186 |
var glyphsLength = glyphs.length; |
|
17187 |
var vertical = font.vertical; |
|
17188 |
var widthAdvanceScale = fontSize * current.fontMatrix[0]; |
|
17189 |
var x = 0, |
|
17190 |
i; |
|
17191 |
for (i = 0; i < glyphsLength; ++i) { |
|
17192 |
var glyph = glyphs[i]; |
|
17193 |
if (glyph === null) { |
|
17194 |
x += fontDirection * wordSpacing; |
|
17195 |
continue; |
|
17196 |
} else if ((0, _util.isNum)(glyph)) { |
|
17197 |
x += -glyph * fontSize * 0.001; |
|
17198 |
continue; |
|
17199 |
} |
|
17200 |
var width = glyph.width; |
|
17201 |
var character = glyph.fontChar; |
|
17202 |
var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing; |
|
17203 |
var charWidth = width * widthAdvanceScale + spacing * fontDirection; |
|
17204 |
if (!glyph.isInFont && !font.missingFile) { |
|
17205 |
x += charWidth; |
|
17206 |
continue; |
|
17207 |
} |
|
17208 |
current.xcoords.push(current.x + x * textHScale); |
|
17209 |
current.tspan.textContent += character; |
|
17210 |
x += charWidth; |
|
17211 |
} |
|
17212 |
if (vertical) { |
|
17213 |
current.y -= x * textHScale; |
|
17214 |
} else { |
|
17215 |
current.x += x * textHScale; |
|
17216 |
} |
|
17217 |
current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' ')); |
|
17218 |
current.tspan.setAttributeNS(null, 'y', pf(-current.y)); |
|
17219 |
current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); |
|
17220 |
current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px'); |
|
17221 |
if (current.fontStyle !== SVG_DEFAULTS.fontStyle) { |
|
17222 |
current.tspan.setAttributeNS(null, 'font-style', current.fontStyle); |
|
17223 |
} |
|
17224 |
if (current.fontWeight !== SVG_DEFAULTS.fontWeight) { |
|
17225 |
current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight); |
|
17226 |
} |
|
17227 |
var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK; |
|
17228 |
if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) { |
|
17229 |
if (current.fillColor !== SVG_DEFAULTS.fillColor) { |
|
17230 |
current.tspan.setAttributeNS(null, 'fill', current.fillColor); |
|
17231 |
} |
|
17232 |
if (current.fillAlpha < 1) { |
|
17233 |
current.tspan.setAttributeNS(null, 'fill-opacity', current.fillAlpha); |
|
17234 |
} |
|
17235 |
} else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) { |
|
17236 |
current.tspan.setAttributeNS(null, 'fill', 'transparent'); |
|
17237 |
} else { |
|
17238 |
current.tspan.setAttributeNS(null, 'fill', 'none'); |
|
17239 |
} |
|
17240 |
if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) { |
|
17241 |
this._setStrokeAttributes(current.tspan); |
|
17242 |
} |
|
17243 |
var textMatrix = current.textMatrix; |
|
17244 |
if (current.textRise !== 0) { |
|
17245 |
textMatrix = textMatrix.slice(); |
|
17246 |
textMatrix[5] += current.textRise; |
|
17247 |
} |
|
17248 |
current.txtElement.setAttributeNS(null, 'transform', pm(textMatrix) + ' scale(1, -1)'); |
|
17249 |
current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve'); |
|
17250 |
current.txtElement.appendChild(current.tspan); |
|
17251 |
current.txtgrp.appendChild(current.txtElement); |
|
17252 |
this._ensureTransformGroup().appendChild(current.txtElement); |
|
17253 |
}, |
|
17254 |
setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) { |
|
17255 |
this.setLeading(-y); |
|
17256 |
this.moveText(x, y); |
|
17257 |
}, |
|
17258 |
addFontStyle: function SVGGraphics_addFontStyle(fontObj) { |
|
17259 |
if (!this.cssStyle) { |
|
17260 |
this.cssStyle = this.svgFactory.createElement('svg:style'); |
|
17261 |
this.cssStyle.setAttributeNS(null, 'type', 'text/css'); |
|
17262 |
this.defs.appendChild(this.cssStyle); |
|
17263 |
} |
|
17264 |
var url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema); |
|
17265 |
this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n'; |
|
17266 |
}, |
|
17267 |
setFont: function SVGGraphics_setFont(details) { |
|
17268 |
var current = this.current; |
|
17269 |
var fontObj = this.commonObjs.get(details[0]); |
|
17270 |
var size = details[1]; |
|
17271 |
this.current.font = fontObj; |
|
17272 |
if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) { |
|
17273 |
this.addFontStyle(fontObj); |
|
17274 |
this.embeddedFonts[fontObj.loadedName] = fontObj; |
|
17275 |
} |
|
17276 |
current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX; |
|
17277 |
var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal'; |
|
17278 |
var italic = fontObj.italic ? 'italic' : 'normal'; |
|
17279 |
if (size < 0) { |
|
17280 |
size = -size; |
|
17281 |
current.fontDirection = -1; |
|
17282 |
} else { |
|
17283 |
current.fontDirection = 1; |
|
17284 |
} |
|
17285 |
current.fontSize = size; |
|
17286 |
current.fontFamily = fontObj.loadedName; |
|
17287 |
current.fontWeight = bold; |
|
17288 |
current.fontStyle = italic; |
|
17289 |
current.tspan = this.svgFactory.createElement('svg:tspan'); |
|
17290 |
current.tspan.setAttributeNS(null, 'y', pf(-current.y)); |
|
17291 |
current.xcoords = []; |
|
17292 |
}, |
|
17293 |
endText: function endText() { |
|
17294 |
var current = this.current; |
|
17295 |
if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && current.txtElement && current.txtElement.hasChildNodes()) { |
|
17296 |
current.element = current.txtElement; |
|
17297 |
this.clip('nonzero'); |
|
17298 |
this.endPath(); |
|
17299 |
} |
|
17300 |
}, |
|
17301 |
|
|
17302 |
setLineWidth: function SVGGraphics_setLineWidth(width) { |
|
17303 |
this.current.lineWidth = width; |
|
17304 |
}, |
|
17305 |
setLineCap: function SVGGraphics_setLineCap(style) { |
|
17306 |
this.current.lineCap = LINE_CAP_STYLES[style]; |
|
17307 |
}, |
|
17308 |
setLineJoin: function SVGGraphics_setLineJoin(style) { |
|
17309 |
this.current.lineJoin = LINE_JOIN_STYLES[style]; |
|
17310 |
}, |
|
17311 |
setMiterLimit: function SVGGraphics_setMiterLimit(limit) { |
|
17312 |
this.current.miterLimit = limit; |
|
17313 |
}, |
|
17314 |
setStrokeAlpha: function SVGGraphics_setStrokeAlpha(strokeAlpha) { |
|
17315 |
this.current.strokeAlpha = strokeAlpha; |
|
17316 |
}, |
|
17317 |
setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) { |
|
17318 |
var color = _util.Util.makeCssRgb(r, g, b); |
|
17319 |
this.current.strokeColor = color; |
|
17320 |
}, |
|
17321 |
setFillAlpha: function SVGGraphics_setFillAlpha(fillAlpha) { |
|
17322 |
this.current.fillAlpha = fillAlpha; |
|
17323 |
}, |
|
17324 |
setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) { |
|
17325 |
var color = _util.Util.makeCssRgb(r, g, b); |
|
17326 |
this.current.fillColor = color; |
|
17327 |
this.current.tspan = this.svgFactory.createElement('svg:tspan'); |
|
17328 |
this.current.xcoords = []; |
|
17329 |
}, |
|
17330 |
setDash: function SVGGraphics_setDash(dashArray, dashPhase) { |
|
17331 |
this.current.dashArray = dashArray; |
|
17332 |
this.current.dashPhase = dashPhase; |
|
17333 |
}, |
|
17334 |
constructPath: function SVGGraphics_constructPath(ops, args) { |
|
17335 |
var current = this.current; |
|
17336 |
var x = current.x, |
|
17337 |
y = current.y; |
|
17338 |
current.path = this.svgFactory.createElement('svg:path'); |
|
17339 |
var d = []; |
|
17340 |
var opLength = ops.length; |
|
17341 |
for (var i = 0, j = 0; i < opLength; i++) { |
|
17342 |
switch (ops[i] | 0) { |
|
17343 |
case _util.OPS.rectangle: |
|
17344 |
x = args[j++]; |
|
17345 |
y = args[j++]; |
|
17346 |
var width = args[j++]; |
|
17347 |
var height = args[j++]; |
|
17348 |
var xw = x + width; |
|
17349 |
var yh = y + height; |
|
17350 |
d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z'); |
|
17351 |
break; |
|
17352 |
case _util.OPS.moveTo: |
|
17353 |
x = args[j++]; |
|
17354 |
y = args[j++]; |
|
17355 |
d.push('M', pf(x), pf(y)); |
|
17356 |
break; |
|
17357 |
case _util.OPS.lineTo: |
|
17358 |
x = args[j++]; |
|
17359 |
y = args[j++]; |
|
17360 |
d.push('L', pf(x), pf(y)); |
|
17361 |
break; |
|
17362 |
case _util.OPS.curveTo: |
|
17363 |
x = args[j + 4]; |
|
17364 |
y = args[j + 5]; |
|
17365 |
d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y)); |
|
17366 |
j += 6; |
|
17367 |
break; |
|
17368 |
case _util.OPS.curveTo2: |
|
17369 |
x = args[j + 2]; |
|
17370 |
y = args[j + 3]; |
|
17371 |
d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3])); |
|
17372 |
j += 4; |
|
17373 |
break; |
|
17374 |
case _util.OPS.curveTo3: |
|
17375 |
x = args[j + 2]; |
|
17376 |
y = args[j + 3]; |
|
17377 |
d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y)); |
|
17378 |
j += 4; |
|
17379 |
break; |
|
17380 |
case _util.OPS.closePath: |
|
17381 |
d.push('Z'); |
|
17382 |
break; |
|
17383 |
} |
|
17384 |
} |
|
17385 |
current.path.setAttributeNS(null, 'd', d.join(' ')); |
|
17386 |
current.path.setAttributeNS(null, 'fill', 'none'); |
|
17387 |
this._ensureTransformGroup().appendChild(current.path); |
|
17388 |
current.element = current.path; |
|
17389 |
current.setCurrentPoint(x, y); |
|
17390 |
}, |
|
17391 |
endPath: function SVGGraphics_endPath() { |
|
17392 |
if (!this.pendingClip) { |
|
17393 |
return; |
|
17394 |
} |
|
17395 |
var current = this.current; |
|
17396 |
var clipId = 'clippath' + clipCount; |
|
17397 |
clipCount++; |
|
17398 |
var clipPath = this.svgFactory.createElement('svg:clipPath'); |
|
17399 |
clipPath.setAttributeNS(null, 'id', clipId); |
|
17400 |
clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix)); |
|
17401 |
var clipElement = current.element.cloneNode(true); |
|
17402 |
if (this.pendingClip === 'evenodd') { |
|
17403 |
clipElement.setAttributeNS(null, 'clip-rule', 'evenodd'); |
|
17404 |
} else { |
|
17405 |
clipElement.setAttributeNS(null, 'clip-rule', 'nonzero'); |
|
17406 |
} |
|
17407 |
this.pendingClip = null; |
|
17408 |
clipPath.appendChild(clipElement); |
|
17409 |
this.defs.appendChild(clipPath); |
|
17410 |
if (current.activeClipUrl) { |
|
17411 |
current.clipGroup = null; |
|
17412 |
this.extraStack.forEach(function (prev) { |
|
17413 |
prev.clipGroup = null; |
|
17414 |
}); |
|
17415 |
clipPath.setAttributeNS(null, 'clip-path', current.activeClipUrl); |
|
17416 |
} |
|
17417 |
current.activeClipUrl = 'url(#' + clipId + ')'; |
|
17418 |
this.tgrp = null; |
|
17419 |
}, |
|
17420 |
clip: function SVGGraphics_clip(type) { |
|
17421 |
this.pendingClip = type; |
|
17422 |
}, |
|
17423 |
closePath: function SVGGraphics_closePath() { |
|
17424 |
var current = this.current; |
|
17425 |
if (current.path) { |
|
17426 |
var d = current.path.getAttributeNS(null, 'd'); |
|
17427 |
d += 'Z'; |
|
17428 |
current.path.setAttributeNS(null, 'd', d); |
|
17429 |
} |
|
17430 |
}, |
|
17431 |
setLeading: function SVGGraphics_setLeading(leading) { |
|
17432 |
this.current.leading = -leading; |
|
17433 |
}, |
|
17434 |
setTextRise: function SVGGraphics_setTextRise(textRise) { |
|
17435 |
this.current.textRise = textRise; |
|
17436 |
}, |
|
17437 |
setTextRenderingMode: function setTextRenderingMode(textRenderingMode) { |
|
17438 |
this.current.textRenderingMode = textRenderingMode; |
|
17439 |
}, |
|
17440 |
|
|
17441 |
setHScale: function SVGGraphics_setHScale(scale) { |
|
17442 |
this.current.textHScale = scale / 100; |
|
17443 |
}, |
|
17444 |
setGState: function SVGGraphics_setGState(states) { |
|
17445 |
for (var i = 0, ii = states.length; i < ii; i++) { |
|
17446 |
var state = states[i]; |
|
17447 |
var key = state[0]; |
|
17448 |
var value = state[1]; |
|
17449 |
switch (key) { |
|
17450 |
case 'LW': |
|
17451 |
this.setLineWidth(value); |
|
17452 |
break; |
|
17453 |
case 'LC': |
|
17454 |
this.setLineCap(value); |
|
17455 |
break; |
|
17456 |
case 'LJ': |
|
17457 |
this.setLineJoin(value); |
|
17458 |
break; |
|
17459 |
case 'ML': |
|
17460 |
this.setMiterLimit(value); |
|
17461 |
break; |
|
17462 |
case 'D': |
|
17463 |
this.setDash(value[0], value[1]); |
|
17464 |
break; |
|
17465 |
case 'Font': |
|
17466 |
this.setFont(value); |
|
17467 |
break; |
|
17468 |
case 'CA': |
|
17469 |
this.setStrokeAlpha(value); |
|
17470 |
break; |
|
17471 |
case 'ca': |
|
17472 |
this.setFillAlpha(value); |
|
17473 |
break; |
|
17474 |
default: |
|
17475 |
(0, _util.warn)('Unimplemented graphic state ' + key); |
|
17476 |
break; |
|
17477 |
} |
|
17478 |
} |
|
17479 |
}, |
|
17480 |
fill: function SVGGraphics_fill() { |
|
17481 |
var current = this.current; |
|
17482 |
if (current.element) { |
|
17483 |
current.element.setAttributeNS(null, 'fill', current.fillColor); |
|
17484 |
current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha); |
|
17485 |
this.endPath(); |
|
17486 |
} |
|
17487 |
}, |
|
17488 |
stroke: function SVGGraphics_stroke() { |
|
17489 |
var current = this.current; |
|
17490 |
if (current.element) { |
|
17491 |
this._setStrokeAttributes(current.element); |
|
17492 |
current.element.setAttributeNS(null, 'fill', 'none'); |
|
17493 |
this.endPath(); |
|
17494 |
} |
|
17495 |
}, |
|
17496 |
_setStrokeAttributes: function _setStrokeAttributes(element) { |
|
17497 |
var current = this.current; |
|
17498 |
element.setAttributeNS(null, 'stroke', current.strokeColor); |
|
17499 |
element.setAttributeNS(null, 'stroke-opacity', current.strokeAlpha); |
|
17500 |
element.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit)); |
|
17501 |
element.setAttributeNS(null, 'stroke-linecap', current.lineCap); |
|
17502 |
element.setAttributeNS(null, 'stroke-linejoin', current.lineJoin); |
|
17503 |
element.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px'); |
|
17504 |
element.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' ')); |
|
17505 |
element.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px'); |
|
17506 |
}, |
|
17507 |
|
|
17508 |
eoFill: function SVGGraphics_eoFill() { |
|
17509 |
if (this.current.element) { |
|
17510 |
this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd'); |
|
17511 |
} |
|
17512 |
this.fill(); |
|
17513 |
}, |
|
17514 |
fillStroke: function SVGGraphics_fillStroke() { |
|
17515 |
this.stroke(); |
|
17516 |
this.fill(); |
|
17517 |
}, |
|
17518 |
eoFillStroke: function SVGGraphics_eoFillStroke() { |
|
17519 |
if (this.current.element) { |
|
17520 |
this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd'); |
|
17521 |
} |
|
17522 |
this.fillStroke(); |
|
17523 |
}, |
|
17524 |
closeStroke: function SVGGraphics_closeStroke() { |
|
17525 |
this.closePath(); |
|
17526 |
this.stroke(); |
|
17527 |
}, |
|
17528 |
closeFillStroke: function SVGGraphics_closeFillStroke() { |
|
17529 |
this.closePath(); |
|
17530 |
this.fillStroke(); |
|
17531 |
}, |
|
17532 |
closeEOFillStroke: function closeEOFillStroke() { |
|
17533 |
this.closePath(); |
|
17534 |
this.eoFillStroke(); |
|
17535 |
}, |
|
17536 |
|
|
17537 |
paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() { |
|
17538 |
var current = this.current; |
|
17539 |
var rect = this.svgFactory.createElement('svg:rect'); |
|
17540 |
rect.setAttributeNS(null, 'x', '0'); |
|
17541 |
rect.setAttributeNS(null, 'y', '0'); |
|
17542 |
rect.setAttributeNS(null, 'width', '1px'); |
|
17543 |
rect.setAttributeNS(null, 'height', '1px'); |
|
17544 |
rect.setAttributeNS(null, 'fill', current.fillColor); |
|
17545 |
this._ensureTransformGroup().appendChild(rect); |
|
17546 |
}, |
|
17547 |
paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) { |
|
17548 |
var imgObj = this.objs.get(objId); |
|
17549 |
var imgEl = this.svgFactory.createElement('svg:image'); |
|
17550 |
imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src); |
|
17551 |
imgEl.setAttributeNS(null, 'width', pf(w)); |
|
17552 |
imgEl.setAttributeNS(null, 'height', pf(h)); |
|
17553 |
imgEl.setAttributeNS(null, 'x', '0'); |
|
17554 |
imgEl.setAttributeNS(null, 'y', pf(-h)); |
|
17555 |
imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')'); |
|
17556 |
this._ensureTransformGroup().appendChild(imgEl); |
|
17557 |
}, |
|
17558 |
paintImageXObject: function SVGGraphics_paintImageXObject(objId) { |
|
17559 |
var imgData = this.objs.get(objId); |
|
17560 |
if (!imgData) { |
|
17561 |
(0, _util.warn)('Dependent image isn\'t ready yet'); |
|
17562 |
return; |
|
17563 |
} |
|
17564 |
this.paintInlineImageXObject(imgData); |
|
17565 |
}, |
|
17566 |
paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) { |
|
17567 |
var width = imgData.width; |
|
17568 |
var height = imgData.height; |
|
17569 |
var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask); |
|
17570 |
var cliprect = this.svgFactory.createElement('svg:rect'); |
|
17571 |
cliprect.setAttributeNS(null, 'x', '0'); |
|
17572 |
cliprect.setAttributeNS(null, 'y', '0'); |
|
17573 |
cliprect.setAttributeNS(null, 'width', pf(width)); |
|
17574 |
cliprect.setAttributeNS(null, 'height', pf(height)); |
|
17575 |
this.current.element = cliprect; |
|
17576 |
this.clip('nonzero'); |
|
17577 |
var imgEl = this.svgFactory.createElement('svg:image'); |
|
17578 |
imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc); |
|
17579 |
imgEl.setAttributeNS(null, 'x', '0'); |
|
17580 |
imgEl.setAttributeNS(null, 'y', pf(-height)); |
|
17581 |
imgEl.setAttributeNS(null, 'width', pf(width) + 'px'); |
|
17582 |
imgEl.setAttributeNS(null, 'height', pf(height) + 'px'); |
|
17583 |
imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')'); |
|
17584 |
if (mask) { |
|
17585 |
mask.appendChild(imgEl); |
|
17586 |
} else { |
|
17587 |
this._ensureTransformGroup().appendChild(imgEl); |
|
17588 |
} |
|
17589 |
}, |
|
17590 |
paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) { |
|
17591 |
var current = this.current; |
|
17592 |
var width = imgData.width; |
|
17593 |
var height = imgData.height; |
|
17594 |
var fillColor = current.fillColor; |
|
17595 |
current.maskId = 'mask' + maskCount++; |
|
17596 |
var mask = this.svgFactory.createElement('svg:mask'); |
|
17597 |
mask.setAttributeNS(null, 'id', current.maskId); |
|
17598 |
var rect = this.svgFactory.createElement('svg:rect'); |
|
17599 |
rect.setAttributeNS(null, 'x', '0'); |
|
17600 |
rect.setAttributeNS(null, 'y', '0'); |
|
17601 |
rect.setAttributeNS(null, 'width', pf(width)); |
|
17602 |
rect.setAttributeNS(null, 'height', pf(height)); |
|
17603 |
rect.setAttributeNS(null, 'fill', fillColor); |
|
17604 |
rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')'); |
|
17605 |
this.defs.appendChild(mask); |
|
17606 |
this._ensureTransformGroup().appendChild(rect); |
|
17607 |
this.paintInlineImageXObject(imgData, mask); |
|
17608 |
}, |
|
17609 |
paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) { |
|
17610 |
if (Array.isArray(matrix) && matrix.length === 6) { |
|
17611 |
this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); |
|
17612 |
} |
|
17613 |
if (Array.isArray(bbox) && bbox.length === 4) { |
|
17614 |
var width = bbox[2] - bbox[0]; |
|
17615 |
var height = bbox[3] - bbox[1]; |
|
17616 |
var cliprect = this.svgFactory.createElement('svg:rect'); |
|
17617 |
cliprect.setAttributeNS(null, 'x', bbox[0]); |
|
17618 |
cliprect.setAttributeNS(null, 'y', bbox[1]); |
|
17619 |
cliprect.setAttributeNS(null, 'width', pf(width)); |
|
17620 |
cliprect.setAttributeNS(null, 'height', pf(height)); |
|
17621 |
this.current.element = cliprect; |
|
17622 |
this.clip('nonzero'); |
|
17623 |
this.endPath(); |
|
17624 |
} |
|
17625 |
}, |
|
17626 |
paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {}, |
|
17627 |
_initialize: function _initialize(viewport) { |
|
17628 |
var svg = this.svgFactory.create(viewport.width, viewport.height); |
|
17629 |
var definitions = this.svgFactory.createElement('svg:defs'); |
|
17630 |
svg.appendChild(definitions); |
|
17631 |
this.defs = definitions; |
|
17632 |
var rootGroup = this.svgFactory.createElement('svg:g'); |
|
17633 |
rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform)); |
|
17634 |
svg.appendChild(rootGroup); |
|
17635 |
this.svg = rootGroup; |
|
17636 |
return svg; |
|
17637 |
}, |
|
17638 |
|
|
17639 |
_ensureClipGroup: function SVGGraphics_ensureClipGroup() { |
|
17640 |
if (!this.current.clipGroup) { |
|
17641 |
var clipGroup = this.svgFactory.createElement('svg:g'); |
|
17642 |
clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl); |
|
17643 |
this.svg.appendChild(clipGroup); |
|
17644 |
this.current.clipGroup = clipGroup; |
|
17645 |
} |
|
17646 |
return this.current.clipGroup; |
|
17647 |
}, |
|
17648 |
_ensureTransformGroup: function SVGGraphics_ensureTransformGroup() { |
|
17649 |
if (!this.tgrp) { |
|
17650 |
this.tgrp = this.svgFactory.createElement('svg:g'); |
|
17651 |
this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix)); |
|
17652 |
if (this.current.activeClipUrl) { |
|
17653 |
this._ensureClipGroup().appendChild(this.tgrp); |
|
17654 |
} else { |
|
17655 |
this.svg.appendChild(this.tgrp); |
|
17656 |
} |
|
17657 |
} |
|
17658 |
return this.tgrp; |
|
17659 |
} |
|
17660 |
}; |
|
17661 |
return SVGGraphics; |
|
17662 |
}(); |
|
17663 |
} |
|
17664 |
exports.SVGGraphics = SVGGraphics; |
|
17665 |
|
|
17666 |
/***/ }), |
|
17667 |
/* 148 */ |
|
17668 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
17669 |
|
|
17670 |
"use strict"; |
|
17671 |
|
|
17672 |
|
|
17673 |
Object.defineProperty(exports, "__esModule", { |
|
17674 |
value: true |
|
17675 |
}); |
|
17676 |
exports.PDFNodeStream = undefined; |
|
17677 |
|
|
17678 |
var _regenerator = __w_pdfjs_require__(137); |
|
17679 |
|
|
17680 |
var _regenerator2 = _interopRequireDefault(_regenerator); |
|
17681 |
|
|
17682 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
|
17683 |
|
|
17684 |
var _util = __w_pdfjs_require__(1); |
|
17685 |
|
|
17686 |
var _network_utils = __w_pdfjs_require__(149); |
|
17687 |
|
|
17688 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
17689 |
|
|
17690 |
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } |
|
17691 |
|
|
17692 |
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
|
17693 |
|
|
17694 |
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"); }); }; } |
|
17695 |
|
|
17696 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
17697 |
|
|
17698 |
var fs = require('fs'); |
|
17699 |
var http = require('http'); |
|
17700 |
var https = require('https'); |
|
17701 |
var url = require('url'); |
|
17702 |
|
|
17703 |
var fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//; |
|
17704 |
function parseUrl(sourceUrl) { |
|
17705 |
var parsedUrl = url.parse(sourceUrl); |
|
17706 |
if (parsedUrl.protocol === 'file:' || parsedUrl.host) { |
|
17707 |
return parsedUrl; |
|
17708 |
} |
|
17709 |
if (/^[a-z]:[/\\]/i.test(sourceUrl)) { |
|
17710 |
return url.parse('file:///' + sourceUrl); |
|
17711 |
} |
|
17712 |
if (!parsedUrl.host) { |
|
17713 |
parsedUrl.protocol = 'file:'; |
|
17714 |
} |
|
17715 |
return parsedUrl; |
|
17716 |
} |
|
17717 |
|
|
17718 |
var PDFNodeStream = function () { |
|
17719 |
function PDFNodeStream(source) { |
|
17720 |
_classCallCheck(this, PDFNodeStream); |
|
17721 |
|
|
17722 |
this.source = source; |
|
17723 |
this.url = parseUrl(source.url); |
|
17724 |
this.isHttp = this.url.protocol === 'http:' || this.url.protocol === 'https:'; |
|
17725 |
this.isFsUrl = this.url.protocol === 'file:'; |
|
17726 |
this.httpHeaders = this.isHttp && source.httpHeaders || {}; |
|
17727 |
this._fullRequest = null; |
|
17728 |
this._rangeRequestReaders = []; |
|
17729 |
} |
|
17730 |
|
|
17731 |
_createClass(PDFNodeStream, [{ |
|
17732 |
key: 'getFullReader', |
|
17733 |
value: function getFullReader() { |
|
17734 |
(0, _util.assert)(!this._fullRequest); |
|
17735 |
this._fullRequest = this.isFsUrl ? new PDFNodeStreamFsFullReader(this) : new PDFNodeStreamFullReader(this); |
|
17736 |
return this._fullRequest; |
|
17737 |
} |
|
17738 |
}, { |
|
17739 |
key: 'getRangeReader', |
|
17740 |
value: function getRangeReader(start, end) { |
|
17741 |
var rangeReader = this.isFsUrl ? new PDFNodeStreamFsRangeReader(this, start, end) : new PDFNodeStreamRangeReader(this, start, end); |
|
17742 |
this._rangeRequestReaders.push(rangeReader); |
|
17743 |
return rangeReader; |
|
17744 |
} |
|
17745 |
}, { |
|
17746 |
key: 'cancelAllRequests', |
|
17747 |
value: function cancelAllRequests(reason) { |
|
17748 |
if (this._fullRequest) { |
|
17749 |
this._fullRequest.cancel(reason); |
|
17750 |
} |
|
17751 |
var readers = this._rangeRequestReaders.slice(0); |
|
17752 |
readers.forEach(function (reader) { |
|
17753 |
reader.cancel(reason); |
|
17754 |
}); |
|
17755 |
} |
|
17756 |
}]); |
|
17757 |
|
|
17758 |
return PDFNodeStream; |
|
17759 |
}(); |
|
17760 |
|
|
17761 |
var BaseFullReader = function () { |
|
17762 |
function BaseFullReader(stream) { |
|
17763 |
_classCallCheck(this, BaseFullReader); |
|
17764 |
|
|
17765 |
this._url = stream.url; |
|
17766 |
this._done = false; |
|
17767 |
this._storedError = null; |
|
17768 |
this.onProgress = null; |
|
17769 |
var source = stream.source; |
|
17770 |
this._contentLength = source.length; |
|
17771 |
this._loaded = 0; |
|
17772 |
this._filename = null; |
|
17773 |
this._disableRange = source.disableRange || false; |
|
17774 |
this._rangeChunkSize = source.rangeChunkSize; |
|
17775 |
if (!this._rangeChunkSize && !this._disableRange) { |
|
17776 |
this._disableRange = true; |
|
17777 |
} |
|
17778 |
this._isStreamingSupported = !source.disableStream; |
|
17779 |
this._isRangeSupported = !source.disableRange; |
|
17780 |
this._readableStream = null; |
|
17781 |
this._readCapability = (0, _util.createPromiseCapability)(); |
|
17782 |
this._headersCapability = (0, _util.createPromiseCapability)(); |
|
17783 |
} |
|
17784 |
|
|
17785 |
_createClass(BaseFullReader, [{ |
|
17786 |
key: 'read', |
|
17787 |
value: function () { |
|
17788 |
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() { |
|
17789 |
var chunk, buffer; |
|
17790 |
return _regenerator2.default.wrap(function _callee$(_context) { |
|
17791 |
while (1) { |
|
17792 |
switch (_context.prev = _context.next) { |
|
17793 |
case 0: |
|
17794 |
_context.next = 2; |
|
17795 |
return this._readCapability.promise; |
|
17796 |
|
|
17797 |
case 2: |
|
17798 |
if (!this._done) { |
|
17799 |
_context.next = 4; |
|
17800 |
break; |
|
17801 |
} |
|
17802 |
|
|
17803 |
return _context.abrupt('return', { |
|
17804 |
value: undefined, |
|
17805 |
done: true |
|
17806 |
}); |
|
17807 |
|
|
17808 |
case 4: |
|
17809 |
if (!this._storedError) { |
|
17810 |
_context.next = 6; |
|
17811 |
break; |
|
17812 |
} |
|
17813 |
|
|
17814 |
throw this._storedError; |
|
17815 |
|
|
17816 |
case 6: |
|
17817 |
chunk = this._readableStream.read(); |
|
17818 |
|
|
17819 |
if (!(chunk === null)) { |
|
17820 |
_context.next = 10; |
|
17821 |
break; |
|
17822 |
} |
|
17823 |
|
|
17824 |
this._readCapability = (0, _util.createPromiseCapability)(); |
|
17825 |
return _context.abrupt('return', this.read()); |
|
17826 |
|
|
17827 |
case 10: |
|
17828 |
this._loaded += chunk.length; |
|
17829 |
if (this.onProgress) { |
|
17830 |
this.onProgress({ |
|
17831 |
loaded: this._loaded, |
|
17832 |
total: this._contentLength |
|
17833 |
}); |
|
17834 |
} |
|
17835 |
buffer = new Uint8Array(chunk).buffer; |
|
17836 |
return _context.abrupt('return', { |
|
17837 |
value: buffer, |
|
17838 |
done: false |
|
17839 |
}); |
|
17840 |
|
|
17841 |
case 14: |
|
17842 |
case 'end': |
|
17843 |
return _context.stop(); |
|
17844 |
} |
|
17845 |
} |
|
17846 |
}, _callee, this); |
|
17847 |
})); |
|
17848 |
|
|
17849 |
function read() { |
|
17850 |
return _ref.apply(this, arguments); |
|
17851 |
} |
|
17852 |
|
|
17853 |
return read; |
|
17854 |
}() |
|
17855 |
}, { |
|
17856 |
key: 'cancel', |
|
17857 |
value: function cancel(reason) { |
|
17858 |
if (!this._readableStream) { |
|
17859 |
this._error(reason); |
|
17860 |
return; |
|
17861 |
} |
|
17862 |
this._readableStream.destroy(reason); |
|
17863 |
} |
|
17864 |
}, { |
|
17865 |
key: '_error', |
|
17866 |
value: function _error(reason) { |
|
17867 |
this._storedError = reason; |
|
17868 |
this._readCapability.resolve(); |
|
17869 |
} |
|
17870 |
}, { |
|
17871 |
key: '_setReadableStream', |
|
17872 |
value: function _setReadableStream(readableStream) { |
|
17873 |
var _this = this; |
|
17874 |
|
|
17875 |
this._readableStream = readableStream; |
|
17876 |
readableStream.on('readable', function () { |
|
17877 |
_this._readCapability.resolve(); |
|
17878 |
}); |
|
17879 |
readableStream.on('end', function () { |
|
17880 |
readableStream.destroy(); |
|
17881 |
_this._done = true; |
|
17882 |
_this._readCapability.resolve(); |
|
17883 |
}); |
|
17884 |
readableStream.on('error', function (reason) { |
|
17885 |
_this._error(reason); |
|
17886 |
}); |
|
17887 |
if (!this._isStreamingSupported && this._isRangeSupported) { |
|
17888 |
this._error(new _util.AbortException('streaming is disabled')); |
|
17889 |
} |
|
17890 |
if (this._storedError) { |
|
17891 |
this._readableStream.destroy(this._storedError); |
|
17892 |
} |
|
17893 |
} |
|
17894 |
}, { |
|
17895 |
key: 'headersReady', |
|
17896 |
get: function get() { |
|
17897 |
return this._headersCapability.promise; |
|
17898 |
} |
|
17899 |
}, { |
|
17900 |
key: 'filename', |
|
17901 |
get: function get() { |
|
17902 |
return this._filename; |
|
17903 |
} |
|
17904 |
}, { |
|
17905 |
key: 'contentLength', |
|
17906 |
get: function get() { |
|
17907 |
return this._contentLength; |
|
17908 |
} |
|
17909 |
}, { |
|
17910 |
key: 'isRangeSupported', |
|
17911 |
get: function get() { |
|
17912 |
return this._isRangeSupported; |
|
17913 |
} |
|
17914 |
}, { |
|
17915 |
key: 'isStreamingSupported', |
|
17916 |
get: function get() { |
|
17917 |
return this._isStreamingSupported; |
|
17918 |
} |
|
17919 |
}]); |
|
17920 |
|
|
17921 |
return BaseFullReader; |
|
17922 |
}(); |
|
17923 |
|
|
17924 |
var BaseRangeReader = function () { |
|
17925 |
function BaseRangeReader(stream) { |
|
17926 |
_classCallCheck(this, BaseRangeReader); |
|
17927 |
|
|
17928 |
this._url = stream.url; |
|
17929 |
this._done = false; |
|
17930 |
this._storedError = null; |
|
17931 |
this.onProgress = null; |
|
17932 |
this._loaded = 0; |
|
17933 |
this._readableStream = null; |
|
17934 |
this._readCapability = (0, _util.createPromiseCapability)(); |
|
17935 |
var source = stream.source; |
|
17936 |
this._isStreamingSupported = !source.disableStream; |
|
17937 |
} |
|
17938 |
|
|
17939 |
_createClass(BaseRangeReader, [{ |
|
17940 |
key: 'read', |
|
17941 |
value: function () { |
|
17942 |
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { |
|
17943 |
var chunk, buffer; |
|
17944 |
return _regenerator2.default.wrap(function _callee2$(_context2) { |
|
17945 |
while (1) { |
|
17946 |
switch (_context2.prev = _context2.next) { |
|
17947 |
case 0: |
|
17948 |
_context2.next = 2; |
|
17949 |
return this._readCapability.promise; |
|
17950 |
|
|
17951 |
case 2: |
|
17952 |
if (!this._done) { |
|
17953 |
_context2.next = 4; |
|
17954 |
break; |
|
17955 |
} |
|
17956 |
|
|
17957 |
return _context2.abrupt('return', { |
|
17958 |
value: undefined, |
|
17959 |
done: true |
|
17960 |
}); |
|
17961 |
|
|
17962 |
case 4: |
|
17963 |
if (!this._storedError) { |
|
17964 |
_context2.next = 6; |
|
17965 |
break; |
|
17966 |
} |
|
17967 |
|
|
17968 |
throw this._storedError; |
|
17969 |
|
|
17970 |
case 6: |
|
17971 |
chunk = this._readableStream.read(); |
|
17972 |
|
|
17973 |
if (!(chunk === null)) { |
|
17974 |
_context2.next = 10; |
|
17975 |
break; |
|
17976 |
} |
|
17977 |
|
|
17978 |
this._readCapability = (0, _util.createPromiseCapability)(); |
|
17979 |
return _context2.abrupt('return', this.read()); |
|
17980 |
|
|
17981 |
case 10: |
|
17982 |
this._loaded += chunk.length; |
|
17983 |
if (this.onProgress) { |
|
17984 |
this.onProgress({ loaded: this._loaded }); |
|
17985 |
} |
|
17986 |
buffer = new Uint8Array(chunk).buffer; |
|
17987 |
return _context2.abrupt('return', { |
|
17988 |
value: buffer, |
|
17989 |
done: false |
|
17990 |
}); |
|
17991 |
|
|
17992 |
case 14: |
|
17993 |
case 'end': |
|
17994 |
return _context2.stop(); |
|
17995 |
} |
|
17996 |
} |
|
17997 |
}, _callee2, this); |
|
17998 |
})); |
|
17999 |
|
|
18000 |
function read() { |
|
18001 |
return _ref2.apply(this, arguments); |
|
18002 |
} |
|
18003 |
|
|
18004 |
return read; |
|
18005 |
}() |
|
18006 |
}, { |
|
18007 |
key: 'cancel', |
|
18008 |
value: function cancel(reason) { |
|
18009 |
if (!this._readableStream) { |
|
18010 |
this._error(reason); |
|
18011 |
return; |
|
18012 |
} |
|
18013 |
this._readableStream.destroy(reason); |
|
18014 |
} |
|
18015 |
}, { |
|
18016 |
key: '_error', |
|
18017 |
value: function _error(reason) { |
|
18018 |
this._storedError = reason; |
|
18019 |
this._readCapability.resolve(); |
|
18020 |
} |
|
18021 |
}, { |
|
18022 |
key: '_setReadableStream', |
|
18023 |
value: function _setReadableStream(readableStream) { |
|
18024 |
var _this2 = this; |
|
18025 |
|
|
18026 |
this._readableStream = readableStream; |
|
18027 |
readableStream.on('readable', function () { |
|
18028 |
_this2._readCapability.resolve(); |
|
18029 |
}); |
|
18030 |
readableStream.on('end', function () { |
|
18031 |
readableStream.destroy(); |
|
18032 |
_this2._done = true; |
|
18033 |
_this2._readCapability.resolve(); |
|
18034 |
}); |
|
18035 |
readableStream.on('error', function (reason) { |
|
18036 |
_this2._error(reason); |
|
18037 |
}); |
|
18038 |
if (this._storedError) { |
|
18039 |
this._readableStream.destroy(this._storedError); |
|
18040 |
} |
|
18041 |
} |
|
18042 |
}, { |
|
18043 |
key: 'isStreamingSupported', |
|
18044 |
get: function get() { |
|
18045 |
return this._isStreamingSupported; |
|
18046 |
} |
|
18047 |
}]); |
|
18048 |
|
|
18049 |
return BaseRangeReader; |
|
18050 |
}(); |
|
18051 |
|
|
18052 |
function createRequestOptions(url, headers) { |
|
18053 |
return { |
|
18054 |
protocol: url.protocol, |
|
18055 |
auth: url.auth, |
|
18056 |
host: url.hostname, |
|
18057 |
port: url.port, |
|
18058 |
path: url.path, |
|
18059 |
method: 'GET', |
|
18060 |
headers: headers |
|
18061 |
}; |
|
18062 |
} |
|
18063 |
|
|
18064 |
var PDFNodeStreamFullReader = function (_BaseFullReader) { |
|
18065 |
_inherits(PDFNodeStreamFullReader, _BaseFullReader); |
|
18066 |
|
|
18067 |
function PDFNodeStreamFullReader(stream) { |
|
18068 |
_classCallCheck(this, PDFNodeStreamFullReader); |
|
18069 |
|
|
18070 |
var _this3 = _possibleConstructorReturn(this, (PDFNodeStreamFullReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFullReader)).call(this, stream)); |
|
18071 |
|
|
18072 |
var handleResponse = function handleResponse(response) { |
|
18073 |
if (response.statusCode === 404) { |
|
18074 |
var error = new _util.MissingPDFException('Missing PDF "' + _this3._url + '".'); |
|
18075 |
_this3._storedError = error; |
|
18076 |
_this3._headersCapability.reject(error); |
|
18077 |
return; |
|
18078 |
} |
|
18079 |
_this3._headersCapability.resolve(); |
|
18080 |
_this3._setReadableStream(response); |
|
18081 |
var getResponseHeader = function getResponseHeader(name) { |
|
18082 |
return _this3._readableStream.headers[name.toLowerCase()]; |
|
18083 |
}; |
|
18084 |
|
|
18085 |
var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({ |
|
18086 |
getResponseHeader: getResponseHeader, |
|
18087 |
isHttp: stream.isHttp, |
|
18088 |
rangeChunkSize: _this3._rangeChunkSize, |
|
18089 |
disableRange: _this3._disableRange |
|
18090 |
}), |
|
18091 |
allowRangeRequests = _validateRangeRequest.allowRangeRequests, |
|
18092 |
suggestedLength = _validateRangeRequest.suggestedLength; |
|
18093 |
|
|
18094 |
_this3._isRangeSupported = allowRangeRequests; |
|
18095 |
_this3._contentLength = suggestedLength || _this3._contentLength; |
|
18096 |
_this3._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader); |
|
18097 |
}; |
|
18098 |
_this3._request = null; |
|
18099 |
if (_this3._url.protocol === 'http:') { |
|
18100 |
_this3._request = http.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse); |
|
18101 |
} else { |
|
18102 |
_this3._request = https.request(createRequestOptions(_this3._url, stream.httpHeaders), handleResponse); |
|
18103 |
} |
|
18104 |
_this3._request.on('error', function (reason) { |
|
18105 |
_this3._storedError = reason; |
|
18106 |
_this3._headersCapability.reject(reason); |
|
18107 |
}); |
|
18108 |
_this3._request.end(); |
|
18109 |
return _this3; |
|
18110 |
} |
|
18111 |
|
|
18112 |
return PDFNodeStreamFullReader; |
|
18113 |
}(BaseFullReader); |
|
18114 |
|
|
18115 |
var PDFNodeStreamRangeReader = function (_BaseRangeReader) { |
|
18116 |
_inherits(PDFNodeStreamRangeReader, _BaseRangeReader); |
|
18117 |
|
|
18118 |
function PDFNodeStreamRangeReader(stream, start, end) { |
|
18119 |
_classCallCheck(this, PDFNodeStreamRangeReader); |
|
18120 |
|
|
18121 |
var _this4 = _possibleConstructorReturn(this, (PDFNodeStreamRangeReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamRangeReader)).call(this, stream)); |
|
18122 |
|
|
18123 |
_this4._httpHeaders = {}; |
|
18124 |
for (var property in stream.httpHeaders) { |
|
18125 |
var value = stream.httpHeaders[property]; |
|
18126 |
if (typeof value === 'undefined') { |
|
18127 |
continue; |
|
18128 |
} |
|
18129 |
_this4._httpHeaders[property] = value; |
|
18130 |
} |
|
18131 |
_this4._httpHeaders['Range'] = 'bytes=' + start + '-' + (end - 1); |
|
18132 |
var handleResponse = function handleResponse(response) { |
|
18133 |
if (response.statusCode === 404) { |
|
18134 |
var error = new _util.MissingPDFException('Missing PDF "' + _this4._url + '".'); |
|
18135 |
_this4._storedError = error; |
|
18136 |
return; |
|
18137 |
} |
|
18138 |
_this4._setReadableStream(response); |
|
18139 |
}; |
|
18140 |
_this4._request = null; |
|
18141 |
if (_this4._url.protocol === 'http:') { |
|
18142 |
_this4._request = http.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse); |
|
18143 |
} else { |
|
18144 |
_this4._request = https.request(createRequestOptions(_this4._url, _this4._httpHeaders), handleResponse); |
|
18145 |
} |
|
18146 |
_this4._request.on('error', function (reason) { |
|
18147 |
_this4._storedError = reason; |
|
18148 |
}); |
|
18149 |
_this4._request.end(); |
|
18150 |
return _this4; |
|
18151 |
} |
|
18152 |
|
|
18153 |
return PDFNodeStreamRangeReader; |
|
18154 |
}(BaseRangeReader); |
|
18155 |
|
|
18156 |
var PDFNodeStreamFsFullReader = function (_BaseFullReader2) { |
|
18157 |
_inherits(PDFNodeStreamFsFullReader, _BaseFullReader2); |
|
18158 |
|
|
18159 |
function PDFNodeStreamFsFullReader(stream) { |
|
18160 |
_classCallCheck(this, PDFNodeStreamFsFullReader); |
|
18161 |
|
|
18162 |
var _this5 = _possibleConstructorReturn(this, (PDFNodeStreamFsFullReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsFullReader)).call(this, stream)); |
|
18163 |
|
|
18164 |
var path = decodeURIComponent(_this5._url.path); |
|
18165 |
if (fileUriRegex.test(_this5._url.href)) { |
|
18166 |
path = path.replace(/^\//, ''); |
|
18167 |
} |
|
18168 |
fs.lstat(path, function (error, stat) { |
|
18169 |
if (error) { |
|
18170 |
if (error.code === 'ENOENT') { |
|
18171 |
error = new _util.MissingPDFException('Missing PDF "' + path + '".'); |
|
18172 |
} |
|
18173 |
_this5._storedError = error; |
|
18174 |
_this5._headersCapability.reject(error); |
|
18175 |
return; |
|
18176 |
} |
|
18177 |
_this5._contentLength = stat.size; |
|
18178 |
_this5._setReadableStream(fs.createReadStream(path)); |
|
18179 |
_this5._headersCapability.resolve(); |
|
18180 |
}); |
|
18181 |
return _this5; |
|
18182 |
} |
|
18183 |
|
|
18184 |
return PDFNodeStreamFsFullReader; |
|
18185 |
}(BaseFullReader); |
|
18186 |
|
|
18187 |
var PDFNodeStreamFsRangeReader = function (_BaseRangeReader2) { |
|
18188 |
_inherits(PDFNodeStreamFsRangeReader, _BaseRangeReader2); |
|
18189 |
|
|
18190 |
function PDFNodeStreamFsRangeReader(stream, start, end) { |
|
18191 |
_classCallCheck(this, PDFNodeStreamFsRangeReader); |
|
18192 |
|
|
18193 |
var _this6 = _possibleConstructorReturn(this, (PDFNodeStreamFsRangeReader.__proto__ || Object.getPrototypeOf(PDFNodeStreamFsRangeReader)).call(this, stream)); |
|
18194 |
|
|
18195 |
var path = decodeURIComponent(_this6._url.path); |
|
18196 |
if (fileUriRegex.test(_this6._url.href)) { |
|
18197 |
path = path.replace(/^\//, ''); |
|
18198 |
} |
|
18199 |
_this6._setReadableStream(fs.createReadStream(path, { |
|
18200 |
start: start, |
|
18201 |
end: end - 1 |
|
18202 |
})); |
|
18203 |
return _this6; |
|
18204 |
} |
|
18205 |
|
|
18206 |
return PDFNodeStreamFsRangeReader; |
|
18207 |
}(BaseRangeReader); |
|
18208 |
|
|
18209 |
exports.PDFNodeStream = PDFNodeStream; |
|
18210 |
|
|
18211 |
/***/ }), |
|
18212 |
/* 149 */ |
|
18213 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
18214 |
|
|
18215 |
"use strict"; |
|
18216 |
|
|
18217 |
|
|
18218 |
Object.defineProperty(exports, "__esModule", { |
|
18219 |
value: true |
|
18220 |
}); |
|
18221 |
exports.validateResponseStatus = exports.validateRangeRequestCapabilities = exports.extractFilenameFromHeader = exports.createResponseStatusError = undefined; |
|
18222 |
|
|
18223 |
var _util = __w_pdfjs_require__(1); |
|
18224 |
|
|
18225 |
var _content_disposition = __w_pdfjs_require__(150); |
|
18226 |
|
|
18227 |
function validateRangeRequestCapabilities(_ref) { |
|
18228 |
var getResponseHeader = _ref.getResponseHeader, |
|
18229 |
isHttp = _ref.isHttp, |
|
18230 |
rangeChunkSize = _ref.rangeChunkSize, |
|
18231 |
disableRange = _ref.disableRange; |
|
18232 |
|
|
18233 |
(0, _util.assert)(rangeChunkSize > 0, 'Range chunk size must be larger than zero'); |
|
18234 |
var returnValues = { |
|
18235 |
allowRangeRequests: false, |
|
18236 |
suggestedLength: undefined |
|
18237 |
}; |
|
18238 |
var length = parseInt(getResponseHeader('Content-Length'), 10); |
|
18239 |
if (!Number.isInteger(length)) { |
|
18240 |
return returnValues; |
|
18241 |
} |
|
18242 |
returnValues.suggestedLength = length; |
|
18243 |
if (length <= 2 * rangeChunkSize) { |
|
18244 |
return returnValues; |
|
18245 |
} |
|
18246 |
if (disableRange || !isHttp) { |
|
18247 |
return returnValues; |
|
18248 |
} |
|
18249 |
if (getResponseHeader('Accept-Ranges') !== 'bytes') { |
|
18250 |
return returnValues; |
|
18251 |
} |
|
18252 |
var contentEncoding = getResponseHeader('Content-Encoding') || 'identity'; |
|
18253 |
if (contentEncoding !== 'identity') { |
|
18254 |
return returnValues; |
|
18255 |
} |
|
18256 |
returnValues.allowRangeRequests = true; |
|
18257 |
return returnValues; |
|
18258 |
} |
|
18259 |
function extractFilenameFromHeader(getResponseHeader) { |
|
18260 |
var contentDisposition = getResponseHeader('Content-Disposition'); |
|
18261 |
if (contentDisposition) { |
|
18262 |
var filename = (0, _content_disposition.getFilenameFromContentDispositionHeader)(contentDisposition); |
|
18263 |
if (/\.pdf$/i.test(filename)) { |
|
18264 |
return filename; |
|
18265 |
} |
|
18266 |
} |
|
18267 |
return null; |
|
18268 |
} |
|
18269 |
function createResponseStatusError(status, url) { |
|
18270 |
if (status === 404 || status === 0 && /^file:/.test(url)) { |
|
18271 |
return new _util.MissingPDFException('Missing PDF "' + url + '".'); |
|
18272 |
} |
|
18273 |
return new _util.UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status); |
|
18274 |
} |
|
18275 |
function validateResponseStatus(status) { |
|
18276 |
return status === 200 || status === 206; |
|
18277 |
} |
|
18278 |
exports.createResponseStatusError = createResponseStatusError; |
|
18279 |
exports.extractFilenameFromHeader = extractFilenameFromHeader; |
|
18280 |
exports.validateRangeRequestCapabilities = validateRangeRequestCapabilities; |
|
18281 |
exports.validateResponseStatus = validateResponseStatus; |
|
18282 |
|
|
18283 |
/***/ }), |
|
18284 |
/* 150 */ |
|
18285 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
18286 |
|
|
18287 |
"use strict"; |
|
18288 |
|
|
18289 |
|
|
18290 |
Object.defineProperty(exports, "__esModule", { |
|
18291 |
value: true |
|
18292 |
}); |
|
18293 |
|
|
18294 |
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }(); |
|
18295 |
|
|
18296 |
function getFilenameFromContentDispositionHeader(contentDisposition) { |
|
18297 |
var needsEncodingFixup = true; |
|
18298 |
var tmp = toParamRegExp('filename\\*', 'i').exec(contentDisposition); |
|
18299 |
if (tmp) { |
|
18300 |
tmp = tmp[1]; |
|
18301 |
var filename = rfc2616unquote(tmp); |
|
18302 |
filename = unescape(filename); |
|
18303 |
filename = rfc5987decode(filename); |
|
18304 |
filename = rfc2047decode(filename); |
|
18305 |
return fixupEncoding(filename); |
|
18306 |
} |
|
18307 |
tmp = rfc2231getparam(contentDisposition); |
|
18308 |
if (tmp) { |
|
18309 |
var _filename = rfc2047decode(tmp); |
|
18310 |
return fixupEncoding(_filename); |
|
18311 |
} |
|
18312 |
tmp = toParamRegExp('filename', 'i').exec(contentDisposition); |
|
18313 |
if (tmp) { |
|
18314 |
tmp = tmp[1]; |
|
18315 |
var _filename2 = rfc2616unquote(tmp); |
|
18316 |
_filename2 = rfc2047decode(_filename2); |
|
18317 |
return fixupEncoding(_filename2); |
|
18318 |
} |
|
18319 |
function toParamRegExp(attributePattern, flags) { |
|
18320 |
return new RegExp('(?:^|;)\\s*' + attributePattern + '\\s*=\\s*' + '(' + '[^";\\s][^;\\s]*' + '|' + '"(?:[^"\\\\]|\\\\"?)+"?' + ')', flags); |
|
18321 |
} |
|
18322 |
function textdecode(encoding, value) { |
|
18323 |
if (encoding) { |
|
18324 |
if (!/^[\x00-\xFF]+$/.test(value)) { |
|
18325 |
return value; |
|
18326 |
} |
|
18327 |
try { |
|
18328 |
var decoder = new TextDecoder(encoding, { fatal: true }); |
|
18329 |
var bytes = new Array(value.length); |
|
18330 |
for (var i = 0; i < value.length; ++i) { |
|
18331 |
bytes[i] = value.charCodeAt(i); |
|
18332 |
} |
|
18333 |
value = decoder.decode(new Uint8Array(bytes)); |
|
18334 |
needsEncodingFixup = false; |
|
18335 |
} catch (e) { |
|
18336 |
if (/^utf-?8$/i.test(encoding)) { |
|
18337 |
try { |
|
18338 |
value = decodeURIComponent(escape(value)); |
|
18339 |
needsEncodingFixup = false; |
|
18340 |
} catch (err) {} |
|
18341 |
} |
|
18342 |
} |
|
18343 |
} |
|
18344 |
return value; |
|
18345 |
} |
|
18346 |
function fixupEncoding(value) { |
|
18347 |
if (needsEncodingFixup && /[\x80-\xff]/.test(value)) { |
|
18348 |
value = textdecode('utf-8', value); |
|
18349 |
if (needsEncodingFixup) { |
|
18350 |
value = textdecode('iso-8859-1', value); |
|
18351 |
} |
|
18352 |
} |
|
18353 |
return value; |
|
18354 |
} |
|
18355 |
function rfc2231getparam(contentDisposition) { |
|
18356 |
var matches = [], |
|
18357 |
match = void 0; |
|
18358 |
var iter = toParamRegExp('filename\\*((?!0\\d)\\d+)(\\*?)', 'ig'); |
|
18359 |
while ((match = iter.exec(contentDisposition)) !== null) { |
|
18360 |
var _match = match, |
|
18361 |
_match2 = _slicedToArray(_match, 4), |
|
18362 |
n = _match2[1], |
|
18363 |
quot = _match2[2], |
|
18364 |
part = _match2[3]; |
|
18365 |
|
|
18366 |
n = parseInt(n, 10); |
|
18367 |
if (n in matches) { |
|
18368 |
if (n === 0) { |
|
18369 |
break; |
|
18370 |
} |
|
18371 |
continue; |
|
18372 |
} |
|
18373 |
matches[n] = [quot, part]; |
|
18374 |
} |
|
18375 |
var parts = []; |
|
18376 |
for (var _n = 0; _n < matches.length; ++_n) { |
|
18377 |
if (!(_n in matches)) { |
|
18378 |
break; |
|
18379 |
} |
|
18380 |
|
|
18381 |
var _matches$_n = _slicedToArray(matches[_n], 2), |
|
18382 |
_quot = _matches$_n[0], |
|
18383 |
_part = _matches$_n[1]; |
|
18384 |
|
|
18385 |
_part = rfc2616unquote(_part); |
|
18386 |
if (_quot) { |
|
18387 |
_part = unescape(_part); |
|
18388 |
if (_n === 0) { |
|
18389 |
_part = rfc5987decode(_part); |
|
18390 |
} |
|
18391 |
} |
|
18392 |
parts.push(_part); |
|
18393 |
} |
|
18394 |
return parts.join(''); |
|
18395 |
} |
|
18396 |
function rfc2616unquote(value) { |
|
18397 |
if (value.charAt(0) === '"') { |
|
18398 |
var parts = value.slice(1).split('\\"'); |
|
18399 |
for (var i = 0; i < parts.length; ++i) { |
|
18400 |
var quotindex = parts[i].indexOf('"'); |
|
18401 |
if (quotindex !== -1) { |
|
18402 |
parts[i] = parts[i].slice(0, quotindex); |
|
18403 |
parts.length = i + 1; |
|
18404 |
} |
|
18405 |
parts[i] = parts[i].replace(/\\(.)/g, '$1'); |
|
18406 |
} |
|
18407 |
value = parts.join('"'); |
|
18408 |
} |
|
18409 |
return value; |
|
18410 |
} |
|
18411 |
function rfc5987decode(extvalue) { |
|
18412 |
var encodingend = extvalue.indexOf('\''); |
|
18413 |
if (encodingend === -1) { |
|
18414 |
return extvalue; |
|
18415 |
} |
|
18416 |
var encoding = extvalue.slice(0, encodingend); |
|
18417 |
var langvalue = extvalue.slice(encodingend + 1); |
|
18418 |
var value = langvalue.replace(/^[^']*'/, ''); |
|
18419 |
return textdecode(encoding, value); |
|
18420 |
} |
|
18421 |
function rfc2047decode(value) { |
|
18422 |
if (value.slice(0, 2) !== '=?' || /[\x00-\x19\x80-\xff]/.test(value)) { |
|
18423 |
return value; |
|
18424 |
} |
|
18425 |
return value.replace(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g, function (_, charset, encoding, text) { |
|
18426 |
if (encoding === 'q' || encoding === 'Q') { |
|
18427 |
text = text.replace(/_/g, ' '); |
|
18428 |
text = text.replace(/=([0-9a-fA-F]{2})/g, function (_, hex) { |
|
18429 |
return String.fromCharCode(parseInt(hex, 16)); |
|
18430 |
}); |
|
18431 |
return textdecode(charset, text); |
|
18432 |
} |
|
18433 |
try { |
|
18434 |
text = atob(text); |
|
18435 |
} catch (e) {} |
|
18436 |
return textdecode(charset, text); |
|
18437 |
}); |
|
18438 |
} |
|
18439 |
return ''; |
|
18440 |
} |
|
18441 |
exports.getFilenameFromContentDispositionHeader = getFilenameFromContentDispositionHeader; |
|
18442 |
|
|
18443 |
/***/ }), |
|
18444 |
/* 151 */ |
|
18445 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
18446 |
|
|
18447 |
"use strict"; |
|
18448 |
|
|
18449 |
|
|
18450 |
Object.defineProperty(exports, "__esModule", { |
|
18451 |
value: true |
|
18452 |
}); |
|
18453 |
exports.PDFFetchStream = undefined; |
|
18454 |
|
|
18455 |
var _regenerator = __w_pdfjs_require__(137); |
|
18456 |
|
|
18457 |
var _regenerator2 = _interopRequireDefault(_regenerator); |
|
18458 |
|
|
18459 |
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); |
|
18460 |
|
|
18461 |
var _util = __w_pdfjs_require__(1); |
|
18462 |
|
|
18463 |
var _network_utils = __w_pdfjs_require__(149); |
|
18464 |
|
|
18465 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
18466 |
|
|
18467 |
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"); }); }; } |
|
18468 |
|
|
18469 |
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
18470 |
|
|
18471 |
function createFetchOptions(headers, withCredentials, abortController) { |
|
18472 |
return { |
|
18473 |
method: 'GET', |
|
18474 |
headers: headers, |
|
18475 |
signal: abortController && abortController.signal, |
|
18476 |
mode: 'cors', |
|
18477 |
credentials: withCredentials ? 'include' : 'same-origin', |
|
18478 |
redirect: 'follow' |
|
18479 |
}; |
|
18480 |
} |
|
18481 |
|
|
18482 |
var PDFFetchStream = function () { |
|
18483 |
function PDFFetchStream(source) { |
|
18484 |
_classCallCheck(this, PDFFetchStream); |
|
18485 |
|
|
18486 |
this.source = source; |
|
18487 |
this.isHttp = /^https?:/i.test(source.url); |
|
18488 |
this.httpHeaders = this.isHttp && source.httpHeaders || {}; |
|
18489 |
this._fullRequestReader = null; |
|
18490 |
this._rangeRequestReaders = []; |
|
18491 |
} |
|
18492 |
|
|
18493 |
_createClass(PDFFetchStream, [{ |
|
18494 |
key: 'getFullReader', |
|
18495 |
value: function getFullReader() { |
|
18496 |
(0, _util.assert)(!this._fullRequestReader); |
|
18497 |
this._fullRequestReader = new PDFFetchStreamReader(this); |
|
18498 |
return this._fullRequestReader; |
|
18499 |
} |
|
18500 |
}, { |
|
18501 |
key: 'getRangeReader', |
|
18502 |
value: function getRangeReader(begin, end) { |
|
18503 |
var reader = new PDFFetchStreamRangeReader(this, begin, end); |
|
18504 |
this._rangeRequestReaders.push(reader); |
|
18505 |
return reader; |
|
18506 |
} |
|
18507 |
}, { |
|
18508 |
key: 'cancelAllRequests', |
|
18509 |
value: function cancelAllRequests(reason) { |
|
18510 |
if (this._fullRequestReader) { |
|
18511 |
this._fullRequestReader.cancel(reason); |
|
18512 |
} |
|
18513 |
var readers = this._rangeRequestReaders.slice(0); |
|
18514 |
readers.forEach(function (reader) { |
|
18515 |
reader.cancel(reason); |
|
18516 |
}); |
|
18517 |
} |
|
18518 |
}]); |
|
18519 |
|
|
18520 |
return PDFFetchStream; |
|
18521 |
}(); |
|
18522 |
|
|
18523 |
var PDFFetchStreamReader = function () { |
|
18524 |
function PDFFetchStreamReader(stream) { |
|
18525 |
var _this = this; |
|
18526 |
|
|
18527 |
_classCallCheck(this, PDFFetchStreamReader); |
|
18528 |
|
|
18529 |
this._stream = stream; |
|
18530 |
this._reader = null; |
|
18531 |
this._loaded = 0; |
|
18532 |
this._filename = null; |
|
18533 |
var source = stream.source; |
|
18534 |
this._withCredentials = source.withCredentials; |
|
18535 |
this._contentLength = source.length; |
|
18536 |
this._headersCapability = (0, _util.createPromiseCapability)(); |
|
18537 |
this._disableRange = source.disableRange || false; |
|
18538 |
this._rangeChunkSize = source.rangeChunkSize; |
|
18539 |
if (!this._rangeChunkSize && !this._disableRange) { |
|
18540 |
this._disableRange = true; |
|
18541 |
} |
|
18542 |
if (typeof AbortController !== 'undefined') { |
|
18543 |
this._abortController = new AbortController(); |
|
18544 |
} |
|
18545 |
this._isStreamingSupported = !source.disableStream; |
|
18546 |
this._isRangeSupported = !source.disableRange; |
|
18547 |
this._headers = new Headers(); |
|
18548 |
for (var property in this._stream.httpHeaders) { |
|
18549 |
var value = this._stream.httpHeaders[property]; |
|
18550 |
if (typeof value === 'undefined') { |
|
18551 |
continue; |
|
18552 |
} |
|
18553 |
this._headers.append(property, value); |
|
18554 |
} |
|
18555 |
var url = source.url; |
|
18556 |
fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) { |
|
18557 |
if (!(0, _network_utils.validateResponseStatus)(response.status)) { |
|
18558 |
throw (0, _network_utils.createResponseStatusError)(response.status, url); |
|
18559 |
} |
|
18560 |
_this._reader = response.body.getReader(); |
|
18561 |
_this._headersCapability.resolve(); |
|
18562 |
var getResponseHeader = function getResponseHeader(name) { |
|
18563 |
return response.headers.get(name); |
|
18564 |
}; |
|
18565 |
|
|
18566 |
var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({ |
|
18567 |
getResponseHeader: getResponseHeader, |
|
18568 |
isHttp: _this._stream.isHttp, |
|
18569 |
rangeChunkSize: _this._rangeChunkSize, |
|
18570 |
disableRange: _this._disableRange |
|
18571 |
}), |
|
18572 |
allowRangeRequests = _validateRangeRequest.allowRangeRequests, |
|
18573 |
suggestedLength = _validateRangeRequest.suggestedLength; |
|
18574 |
|
|
18575 |
_this._isRangeSupported = allowRangeRequests; |
|
18576 |
_this._contentLength = suggestedLength || _this._contentLength; |
|
18577 |
_this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader); |
|
18578 |
if (!_this._isStreamingSupported && _this._isRangeSupported) { |
|
18579 |
_this.cancel(new _util.AbortException('streaming is disabled')); |
|
18580 |
} |
|
18581 |
}).catch(this._headersCapability.reject); |
|
18582 |
this.onProgress = null; |
|
18583 |
} |
|
18584 |
|
|
18585 |
_createClass(PDFFetchStreamReader, [{ |
|
18586 |
key: 'read', |
|
18587 |
value: function () { |
|
18588 |
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() { |
|
18589 |
var _ref2, value, done, buffer; |
|
18590 |
|
|
18591 |
return _regenerator2.default.wrap(function _callee$(_context) { |
|
18592 |
while (1) { |
|
18593 |
switch (_context.prev = _context.next) { |
|
18594 |
case 0: |
|
18595 |
_context.next = 2; |
|
18596 |
return this._headersCapability.promise; |
|
18597 |
|
|
18598 |
case 2: |
|
18599 |
_context.next = 4; |
|
18600 |
return this._reader.read(); |
|
18601 |
|
|
18602 |
case 4: |
|
18603 |
_ref2 = _context.sent; |
|
18604 |
value = _ref2.value; |
|
18605 |
done = _ref2.done; |
|
18606 |
|
|
18607 |
if (!done) { |
|
18608 |
_context.next = 9; |
|
18609 |
break; |
|
18610 |
} |
|
18611 |
|
|
18612 |
return _context.abrupt('return', { |
|
18613 |
value: value, |
|
18614 |
done: done |
|
18615 |
}); |
|
18616 |
|
|
18617 |
case 9: |
|
18618 |
this._loaded += value.byteLength; |
|
18619 |
if (this.onProgress) { |
|
18620 |
this.onProgress({ |
|
18621 |
loaded: this._loaded, |
|
18622 |
total: this._contentLength |
|
18623 |
}); |
|
18624 |
} |
|
18625 |
buffer = new Uint8Array(value).buffer; |
|
18626 |
return _context.abrupt('return', { |
|
18627 |
value: buffer, |
|
18628 |
done: false |
|
18629 |
}); |
|
18630 |
|
|
18631 |
case 13: |
|
18632 |
case 'end': |
|
18633 |
return _context.stop(); |
|
18634 |
} |
|
18635 |
} |
|
18636 |
}, _callee, this); |
|
18637 |
})); |
|
18638 |
|
|
18639 |
function read() { |
|
18640 |
return _ref.apply(this, arguments); |
|
18641 |
} |
|
18642 |
|
|
18643 |
return read; |
|
18644 |
}() |
|
18645 |
}, { |
|
18646 |
key: 'cancel', |
|
18647 |
value: function cancel(reason) { |
|
18648 |
if (this._reader) { |
|
18649 |
this._reader.cancel(reason); |
|
18650 |
} |
|
18651 |
if (this._abortController) { |
|
18652 |
this._abortController.abort(); |
|
18653 |
} |
|
18654 |
} |
|
18655 |
}, { |
|
18656 |
key: 'headersReady', |
|
18657 |
get: function get() { |
|
18658 |
return this._headersCapability.promise; |
|
18659 |
} |
|
18660 |
}, { |
|
18661 |
key: 'filename', |
|
18662 |
get: function get() { |
|
18663 |
return this._filename; |
|
18664 |
} |
|
18665 |
}, { |
|
18666 |
key: 'contentLength', |
|
18667 |
get: function get() { |
|
18668 |
return this._contentLength; |
|
18669 |
} |
|
18670 |
}, { |
|
18671 |
key: 'isRangeSupported', |
|
18672 |
get: function get() { |
|
18673 |
return this._isRangeSupported; |
|
18674 |
} |
|
18675 |
}, { |
|
18676 |
key: 'isStreamingSupported', |
|
18677 |
get: function get() { |
|
18678 |
return this._isStreamingSupported; |
|
18679 |
} |
|
18680 |
}]); |
|
18681 |
|
|
18682 |
return PDFFetchStreamReader; |
|
18683 |
}(); |
|
18684 |
|
|
18685 |
var PDFFetchStreamRangeReader = function () { |
|
18686 |
function PDFFetchStreamRangeReader(stream, begin, end) { |
|
18687 |
var _this2 = this; |
|
18688 |
|
|
18689 |
_classCallCheck(this, PDFFetchStreamRangeReader); |
|
18690 |
|
|
18691 |
this._stream = stream; |
|
18692 |
this._reader = null; |
|
18693 |
this._loaded = 0; |
|
18694 |
var source = stream.source; |
|
18695 |
this._withCredentials = source.withCredentials; |
|
18696 |
this._readCapability = (0, _util.createPromiseCapability)(); |
|
18697 |
this._isStreamingSupported = !source.disableStream; |
|
18698 |
if (typeof AbortController !== 'undefined') { |
|
18699 |
this._abortController = new AbortController(); |
|
18700 |
} |
|
18701 |
this._headers = new Headers(); |
|
18702 |
for (var property in this._stream.httpHeaders) { |
|
18703 |
var value = this._stream.httpHeaders[property]; |
|
18704 |
if (typeof value === 'undefined') { |
|
18705 |
continue; |
|
18706 |
} |
|
18707 |
this._headers.append(property, value); |
|
18708 |
} |
|
18709 |
var rangeStr = begin + '-' + (end - 1); |
|
18710 |
this._headers.append('Range', 'bytes=' + rangeStr); |
|
18711 |
var url = source.url; |
|
18712 |
fetch(url, createFetchOptions(this._headers, this._withCredentials, this._abortController)).then(function (response) { |
|
18713 |
if (!(0, _network_utils.validateResponseStatus)(response.status)) { |
|
18714 |
throw (0, _network_utils.createResponseStatusError)(response.status, url); |
|
18715 |
} |
|
18716 |
_this2._readCapability.resolve(); |
|
18717 |
_this2._reader = response.body.getReader(); |
|
18718 |
}); |
|
18719 |
this.onProgress = null; |
|
18720 |
} |
|
18721 |
|
|
18722 |
_createClass(PDFFetchStreamRangeReader, [{ |
|
18723 |
key: 'read', |
|
18724 |
value: function () { |
|
18725 |
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { |
|
18726 |
var _ref4, value, done, buffer; |
|
18727 |
|
|
18728 |
return _regenerator2.default.wrap(function _callee2$(_context2) { |
|
18729 |
while (1) { |
|
18730 |
switch (_context2.prev = _context2.next) { |
|
18731 |
case 0: |
|
18732 |
_context2.next = 2; |
|
18733 |
return this._readCapability.promise; |
|
18734 |
|
|
18735 |
case 2: |
|
18736 |
_context2.next = 4; |
|
18737 |
return this._reader.read(); |
|
18738 |
|
|
18739 |
case 4: |
|
18740 |
_ref4 = _context2.sent; |
|
18741 |
value = _ref4.value; |
|
18742 |
done = _ref4.done; |
|
18743 |
|
|
18744 |
if (!done) { |
|
18745 |
_context2.next = 9; |
|
18746 |
break; |
|
18747 |
} |
|
18748 |
|
|
18749 |
return _context2.abrupt('return', { |
|
18750 |
value: value, |
|
18751 |
done: done |
|
18752 |
}); |
|
18753 |
|
|
18754 |
case 9: |
|
18755 |
this._loaded += value.byteLength; |
|
18756 |
if (this.onProgress) { |
|
18757 |
this.onProgress({ loaded: this._loaded }); |
|
18758 |
} |
|
18759 |
buffer = new Uint8Array(value).buffer; |
|
18760 |
return _context2.abrupt('return', { |
|
18761 |
value: buffer, |
|
18762 |
done: false |
|
18763 |
}); |
|
18764 |
|
|
18765 |
case 13: |
|
18766 |
case 'end': |
|
18767 |
return _context2.stop(); |
|
18768 |
} |
|
18769 |
} |
|
18770 |
}, _callee2, this); |
|
18771 |
})); |
|
18772 |
|
|
18773 |
function read() { |
|
18774 |
return _ref3.apply(this, arguments); |
|
18775 |
} |
|
18776 |
|
|
18777 |
return read; |
|
18778 |
}() |
|
18779 |
}, { |
|
18780 |
key: 'cancel', |
|
18781 |
value: function cancel(reason) { |
|
18782 |
if (this._reader) { |
|
18783 |
this._reader.cancel(reason); |
|
18784 |
} |
|
18785 |
if (this._abortController) { |
|
18786 |
this._abortController.abort(); |
|
18787 |
} |
|
18788 |
} |
|
18789 |
}, { |
|
18790 |
key: 'isStreamingSupported', |
|
18791 |
get: function get() { |
|
18792 |
return this._isStreamingSupported; |
|
18793 |
} |
|
18794 |
}]); |
|
18795 |
|
|
18796 |
return PDFFetchStreamRangeReader; |
|
18797 |
}(); |
|
18798 |
|
|
18799 |
exports.PDFFetchStream = PDFFetchStream; |
|
18800 |
|
|
18801 |
/***/ }), |
|
18802 |
/* 152 */ |
|
18803 |
/***/ (function(module, exports, __w_pdfjs_require__) { |
|
18804 |
|
|
18805 |
"use strict"; |
|
18806 |
|
|
18807 |
|
|
18808 |
Object.defineProperty(exports, "__esModule", { |
|
18809 |
value: true |
|
18810 |
}); |
|
18811 |
exports.NetworkManager = exports.PDFNetworkStream = undefined; |
|
18812 |
|
|
18813 |
var _regenerator = __w_pdfjs_require__(137); |
|
18814 |
|
|
18815 |
var _regenerator2 = _interopRequireDefault(_regenerator); |
|
18816 |
|
|
18817 |
var _util = __w_pdfjs_require__(1); |
|
18818 |
|
|
18819 |
var _network_utils = __w_pdfjs_require__(149); |
|
18820 |
|
|
18821 |
var _global_scope = __w_pdfjs_require__(3); |
|
18822 |
|
|
18823 |
var _global_scope2 = _interopRequireDefault(_global_scope); |
|
18824 |
|
|
18825 |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
18826 |
|
|
18827 |
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"); }); }; } |
|
18828 |
|
|
18829 |
; |
|
18830 |
var OK_RESPONSE = 200; |
|
18831 |
var PARTIAL_CONTENT_RESPONSE = 206; |
|
18832 |
function NetworkManager(url, args) { |
|
18833 |
this.url = url; |
|
18834 |
args = args || {}; |
|
18835 |
this.isHttp = /^https?:/i.test(url); |
|
18836 |
this.httpHeaders = this.isHttp && args.httpHeaders || {}; |
|
18837 |
this.withCredentials = args.withCredentials || false; |
|
18838 |
this.getXhr = args.getXhr || function NetworkManager_getXhr() { |
|
18839 |
return new XMLHttpRequest(); |
|
18840 |
}; |
|
18841 |
this.currXhrId = 0; |
|
18842 |
this.pendingRequests = Object.create(null); |
|
18843 |
this.loadedRequests = Object.create(null); |
|
18844 |
} |
|
18845 |
function getArrayBuffer(xhr) { |
|
18846 |
var data = xhr.response; |
|
18847 |
if (typeof data !== 'string') { |
|
18848 |
return data; |
|
18849 |
} |
|
18850 |
var array = (0, _util.stringToBytes)(data); |
|
18851 |
return array.buffer; |
|
18852 |
} |
|
18853 |
var supportsMozChunked = function supportsMozChunkedClosure() { |
|
18854 |
try { |
|
18855 |
var x = new XMLHttpRequest(); |
|
18856 |
x.open('GET', _global_scope2.default.location.href); |
|
18857 |
x.responseType = 'moz-chunked-arraybuffer'; |
|
18858 |
return x.responseType === 'moz-chunked-arraybuffer'; |
|
18859 |
} catch (e) { |
|
18860 |
return false; |
|
18861 |
} |
|
18862 |
}(); |
|
18863 |
NetworkManager.prototype = { |
|
18864 |
requestRange: function NetworkManager_requestRange(begin, end, listeners) { |
|
18865 |
var args = { |
|
18866 |
begin: begin, |
|
18867 |
end: end |
|
18868 |
}; |
|
18869 |
for (var prop in listeners) { |
|
18870 |
args[prop] = listeners[prop]; |
|
18871 |
} |
|
18872 |
return this.request(args); |
|
18873 |
}, |
|
18874 |
requestFull: function NetworkManager_requestFull(listeners) { |
|
18875 |
return this.request(listeners); |
|
18876 |
}, |
|
18877 |
request: function NetworkManager_request(args) { |
|
18878 |
var xhr = this.getXhr(); |
|
18879 |
var xhrId = this.currXhrId++; |
|
18880 |
var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr }; |
|
18881 |
xhr.open('GET', this.url); |
|
18882 |
xhr.withCredentials = this.withCredentials; |
|
18883 |
for (var property in this.httpHeaders) { |
|
18884 |
var value = this.httpHeaders[property]; |
|
18885 |
if (typeof value === 'undefined') { |
|
18886 |
continue; |
|
18887 |
} |
|
18888 |
xhr.setRequestHeader(property, value); |
|
18889 |
} |
|
18890 |
if (this.isHttp && 'begin' in args && 'end' in args) { |
|
18891 |
var rangeStr = args.begin + '-' + (args.end - 1); |
|
18892 |
xhr.setRequestHeader('Range', 'bytes=' + rangeStr); |
|
18893 |
pendingRequest.expectedStatus = 206; |
|
18894 |
} else { |
|
18895 |
pendingRequest.expectedStatus = 200; |
|
18896 |
} |
|
18897 |
var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData; |
|
18898 |
if (useMozChunkedLoading) { |
|
18899 |
xhr.responseType = 'moz-chunked-arraybuffer'; |
|
18900 |
pendingRequest.onProgressiveData = args.onProgressiveData; |
|
18901 |
pendingRequest.mozChunked = true; |
|
18902 |
} else { |
|
18903 |
xhr.responseType = 'arraybuffer'; |
|
18904 |
} |
|
18905 |
if (args.onError) { |
|
18906 |
xhr.onerror = function (evt) { |
|
18907 |
args.onError(xhr.status); |
|
18908 |
}; |
|
18909 |
} |
|
18910 |
xhr.onreadystatechange = this.onStateChange.bind(this, xhrId); |
|
18911 |
xhr.onprogress = this.onProgress.bind(this, xhrId); |
|
18912 |
pendingRequest.onHeadersReceived = args.onHeadersReceived; |
|
18913 |
pendingRequest.onDone = args.onDone; |
|
18914 |
pendingRequest.onError = args.onError; |
|
18915 |
pendingRequest.onProgress = args.onProgress; |
|
18916 |
xhr.send(null); |
|
18917 |
return xhrId; |
|
18918 |
}, |
|
18919 |
onProgress: function NetworkManager_onProgress(xhrId, evt) { |
|
18920 |
var pendingRequest = this.pendingRequests[xhrId]; |
|
18921 |
if (!pendingRequest) { |
|
18922 |
return; |
|
18923 |
} |
|
18924 |
if (pendingRequest.mozChunked) { |
|
18925 |
var chunk = getArrayBuffer(pendingRequest.xhr); |
|
18926 |
pendingRequest.onProgressiveData(chunk); |
|
18927 |
} |
|
18928 |
var onProgress = pendingRequest.onProgress; |
|
18929 |
if (onProgress) { |
|
18930 |
onProgress(evt); |
|
18931 |
} |
|
18932 |
}, |
|
18933 |
onStateChange: function NetworkManager_onStateChange(xhrId, evt) { |
|
18934 |
var pendingRequest = this.pendingRequests[xhrId]; |
|
18935 |
if (!pendingRequest) { |
|
18936 |
return; |
|
18937 |
} |
|
18938 |
var xhr = pendingRequest.xhr; |
|
18939 |
if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) { |
|
18940 |
pendingRequest.onHeadersReceived(); |
|
18941 |
delete pendingRequest.onHeadersReceived; |
|
18942 |
} |
|
18943 |
if (xhr.readyState !== 4) { |
|
18944 |
return; |
|
18945 |
} |
|
18946 |
if (!(xhrId in this.pendingRequests)) { |
|
18947 |
return; |
|
18948 |
} |
|
18949 |
delete this.pendingRequests[xhrId]; |
|
18950 |
if (xhr.status === 0 && this.isHttp) { |
|
18951 |
if (pendingRequest.onError) { |
|
18952 |
pendingRequest.onError(xhr.status); |
|
18953 |
} |
|
18954 |
return; |
|
18955 |
} |
|
18956 |
var xhrStatus = xhr.status || OK_RESPONSE; |
|
18957 |
var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE; |
|
18958 |
if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) { |
|
18959 |
if (pendingRequest.onError) { |
|
18960 |
pendingRequest.onError(xhr.status); |
|
18961 |
} |
|
18962 |
return; |
|
18963 |
} |
|
18964 |
this.loadedRequests[xhrId] = true; |
|
18965 |
var chunk = getArrayBuffer(xhr); |
|
18966 |
if (xhrStatus === PARTIAL_CONTENT_RESPONSE) { |
|
18967 |
var rangeHeader = xhr.getResponseHeader('Content-Range'); |
|
18968 |
var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader); |
|
18969 |
var begin = parseInt(matches[1], 10); |
|
18970 |
pendingRequest.onDone({ |
|
18971 |
begin: begin, |
|
18972 |
chunk: chunk |
|
18973 |
}); |
|
18974 |
} else if (pendingRequest.onProgressiveData) { |
|
18975 |
pendingRequest.onDone(null); |
|
18976 |
} else if (chunk) { |
|
18977 |
pendingRequest.onDone({ |
|
18978 |
begin: 0, |
|
18979 |
chunk: chunk |
|
18980 |
}); |
|
18981 |
} else if (pendingRequest.onError) { |
|
18982 |
pendingRequest.onError(xhr.status); |
|
18983 |
} |
|
18984 |
}, |
|
18985 |
hasPendingRequests: function NetworkManager_hasPendingRequests() { |
|
18986 |
for (var xhrId in this.pendingRequests) { |
|
18987 |
return true; |
|
18988 |
} |
|
18989 |
return false; |
|
18990 |
}, |
|
18991 |
getRequestXhr: function NetworkManager_getXhr(xhrId) { |
|
18992 |
return this.pendingRequests[xhrId].xhr; |
|
18993 |
}, |
|
18994 |
isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) { |
|
18995 |
return !!this.pendingRequests[xhrId].onProgressiveData; |
|
18996 |
}, |
|
18997 |
isPendingRequest: function NetworkManager_isPendingRequest(xhrId) { |
|
18998 |
return xhrId in this.pendingRequests; |
|
18999 |
}, |
|
19000 |
isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) { |
|
19001 |
return xhrId in this.loadedRequests; |
|
19002 |
}, |
|
19003 |
abortAllRequests: function NetworkManager_abortAllRequests() { |
|
19004 |
for (var xhrId in this.pendingRequests) { |
|
19005 |
this.abortRequest(xhrId | 0); |
|
19006 |
} |
|
19007 |
}, |
|
19008 |
abortRequest: function NetworkManager_abortRequest(xhrId) { |
|
19009 |
var xhr = this.pendingRequests[xhrId].xhr; |
|
19010 |
delete this.pendingRequests[xhrId]; |
|
19011 |
xhr.abort(); |
|
19012 |
} |
|
19013 |
}; |
|
19014 |
function PDFNetworkStream(source) { |
|
19015 |
this._source = source; |
|
19016 |
this._manager = new NetworkManager(source.url, { |
|
19017 |
httpHeaders: source.httpHeaders, |
|
19018 |
withCredentials: source.withCredentials |
|
19019 |
}); |
|
19020 |
this._rangeChunkSize = source.rangeChunkSize; |
|
19021 |
this._fullRequestReader = null; |
|
19022 |
this._rangeRequestReaders = []; |
|
19023 |
} |
|
19024 |
PDFNetworkStream.prototype = { |
|
19025 |
_onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) { |
|
19026 |
var i = this._rangeRequestReaders.indexOf(reader); |
|
19027 |
if (i >= 0) { |
|
19028 |
this._rangeRequestReaders.splice(i, 1); |
|
19029 |
} |
|
19030 |
}, |
|
19031 |
getFullReader: function PDFNetworkStream_getFullReader() { |
|
19032 |
(0, _util.assert)(!this._fullRequestReader); |
|
19033 |
this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._source); |
|
19034 |
return this._fullRequestReader; |
|
19035 |
}, |
|
19036 |
getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) { |
|
19037 |
var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end); |
|
19038 |
reader.onClosed = this._onRangeRequestReaderClosed.bind(this); |
|
19039 |
this._rangeRequestReaders.push(reader); |
|
19040 |
return reader; |
|
19041 |
}, |
|
19042 |
cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) { |
|
19043 |
if (this._fullRequestReader) { |
|
19044 |
this._fullRequestReader.cancel(reason); |
|
19045 |
} |
|
19046 |
var readers = this._rangeRequestReaders.slice(0); |
|
19047 |
readers.forEach(function (reader) { |
|
19048 |
reader.cancel(reason); |
|
19049 |
}); |
|
19050 |
} |
|
19051 |
}; |
|
19052 |
function PDFNetworkStreamFullRequestReader(manager, source) { |
|
19053 |
this._manager = manager; |
|
19054 |
var args = { |
|
19055 |
onHeadersReceived: this._onHeadersReceived.bind(this), |
|
19056 |
onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this), |
|
19057 |
onDone: this._onDone.bind(this), |
|
19058 |
onError: this._onError.bind(this), |
|
19059 |
onProgress: this._onProgress.bind(this) |
|
19060 |
}; |
|
19061 |
this._url = source.url; |
|
19062 |
this._fullRequestId = manager.requestFull(args); |
|
19063 |
this._headersReceivedCapability = (0, _util.createPromiseCapability)(); |
|
19064 |
this._disableRange = source.disableRange || false; |
|
19065 |
this._contentLength = source.length; |
|
19066 |
this._rangeChunkSize = source.rangeChunkSize; |
|
19067 |
if (!this._rangeChunkSize && !this._disableRange) { |
|
19068 |
this._disableRange = true; |
|
19069 |
} |
|
19070 |
this._isStreamingSupported = false; |
|
19071 |
this._isRangeSupported = false; |
|
19072 |
this._cachedChunks = []; |
|
19073 |
this._requests = []; |
|
19074 |
this._done = false; |
|
19075 |
this._storedError = undefined; |
|
19076 |
this._filename = null; |
|
19077 |
this.onProgress = null; |
|
19078 |
} |
|
19079 |
PDFNetworkStreamFullRequestReader.prototype = { |
|
19080 |
_onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() { |
|
19081 |
var fullRequestXhrId = this._fullRequestId; |
|
19082 |
var fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId); |
|
19083 |
var getResponseHeader = function getResponseHeader(name) { |
|
19084 |
return fullRequestXhr.getResponseHeader(name); |
|
19085 |
}; |
|
19086 |
|
|
19087 |
var _validateRangeRequest = (0, _network_utils.validateRangeRequestCapabilities)({ |
|
19088 |
getResponseHeader: getResponseHeader, |
|
19089 |
isHttp: this._manager.isHttp, |
|
19090 |
rangeChunkSize: this._rangeChunkSize, |
|
19091 |
disableRange: this._disableRange |
|
19092 |
}), |
|
19093 |
allowRangeRequests = _validateRangeRequest.allowRangeRequests, |
|
19094 |
suggestedLength = _validateRangeRequest.suggestedLength; |
|
19095 |
|
|
19096 |
if (allowRangeRequests) { |
|
19097 |
this._isRangeSupported = true; |
|
19098 |
} |
|
19099 |
this._contentLength = suggestedLength || this._contentLength; |
|
19100 |
this._filename = (0, _network_utils.extractFilenameFromHeader)(getResponseHeader); |
|
19101 |
var networkManager = this._manager; |
|
19102 |
if (networkManager.isStreamingRequest(fullRequestXhrId)) { |
|
19103 |
this._isStreamingSupported = true; |
|
19104 |
} else if (this._isRangeSupported) { |
|
19105 |
networkManager.abortRequest(fullRequestXhrId); |
|
19106 |
} |
|
19107 |
this._headersReceivedCapability.resolve(); |
|
19108 |
}, |
|
19109 |
_onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) { |
|
19110 |
if (this._requests.length > 0) { |
|
19111 |
var requestCapability = this._requests.shift(); |
|
19112 |
requestCapability.resolve({ |
|
19113 |
value: chunk, |
|
19114 |
done: false |
|
19115 |
}); |
|
19116 |
} else { |
|
19117 |
this._cachedChunks.push(chunk); |
|
19118 |
} |
|
19119 |
}, |
|
19120 |
_onDone: function PDFNetworkStreamFullRequestReader_onDone(args) { |
|
19121 |
if (args) { |
|
19122 |
this._onProgressiveData(args.chunk); |
|
19123 |
} |
|
19124 |
this._done = true; |
|
19125 |
if (this._cachedChunks.length > 0) { |
|
19126 |
return; |
|
19127 |
} |
|
19128 |
this._requests.forEach(function (requestCapability) { |
|
19129 |
requestCapability.resolve({ |
|
19130 |
value: undefined, |
|
19131 |
done: true |
|
19132 |
}); |
|
19133 |
}); |
|
19134 |
this._requests = []; |
|
19135 |
}, |
|
19136 |
_onError: function PDFNetworkStreamFullRequestReader_onError(status) { |
|
19137 |
var url = this._url; |
|
19138 |
var exception = (0, _network_utils.createResponseStatusError)(status, url); |
|
19139 |
this._storedError = exception; |
|
19140 |
this._headersReceivedCapability.reject(exception); |
|
19141 |
this._requests.forEach(function (requestCapability) { |
|
19142 |
requestCapability.reject(exception); |
|
19143 |
}); |
|
19144 |
this._requests = []; |
|
19145 |
this._cachedChunks = []; |
|
19146 |
}, |
|
19147 |
_onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) { |
|
19148 |
if (this.onProgress) { |
|
19149 |
this.onProgress({ |
|
19150 |
loaded: data.loaded, |
|
19151 |
total: data.lengthComputable ? data.total : this._contentLength |
|
19152 |
}); |
|
19153 |
} |
|
19154 |
}, |
|
19155 |
get filename() { |
|
19156 |
return this._filename; |
|
19157 |
}, |
|
19158 |
get isRangeSupported() { |
|
19159 |
return this._isRangeSupported; |
|
19160 |
}, |
|
19161 |
get isStreamingSupported() { |
|
19162 |
return this._isStreamingSupported; |
|
19163 |
}, |
|
19164 |
get contentLength() { |
|
19165 |
return this._contentLength; |
|
19166 |
}, |
|
19167 |
get headersReady() { |
|
19168 |
return this._headersReceivedCapability.promise; |
|
19169 |
}, |
|
19170 |
read: function () { |
|
19171 |
var _ref = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee() { |
|
19172 |
var chunk, requestCapability; |
|
19173 |
return _regenerator2.default.wrap(function _callee$(_context) { |
|
19174 |
while (1) { |
|
19175 |
switch (_context.prev = _context.next) { |
|
19176 |
case 0: |
|
19177 |
if (!this._storedError) { |
|
19178 |
_context.next = 2; |
|
19179 |
break; |
|
19180 |
} |
|
19181 |
|
|
19182 |
throw this._storedError; |
|
19183 |
|
|
19184 |
case 2: |
|
19185 |
if (!(this._cachedChunks.length > 0)) { |
|
19186 |
_context.next = 5; |
|
19187 |
break; |
|
19188 |
} |
|
19189 |
|
|
19190 |
chunk = this._cachedChunks.shift(); |
|
19191 |
return _context.abrupt('return', { |
|
19192 |
value: chunk, |
|
19193 |
done: false |
|
19194 |
}); |
|
19195 |
|
|
19196 |
case 5: |
|
19197 |
if (!this._done) { |
|
19198 |
_context.next = 7; |
|
19199 |
break; |
|
19200 |
} |
|
19201 |
|
|
19202 |
return _context.abrupt('return', { |
|
19203 |
value: undefined, |
|
19204 |
done: true |
|
19205 |
}); |
|
19206 |
|
|
19207 |
case 7: |
|
19208 |
requestCapability = (0, _util.createPromiseCapability)(); |
|
19209 |
|
|
19210 |
this._requests.push(requestCapability); |
|
19211 |
return _context.abrupt('return', requestCapability.promise); |
|
19212 |
|
|
19213 |
case 10: |
|
19214 |
case 'end': |
|
19215 |
return _context.stop(); |
|
19216 |
} |
|
19217 |
} |
|
19218 |
}, _callee, this); |
|
19219 |
})); |
|
19220 |
|
|
19221 |
function read() { |
|
19222 |
return _ref.apply(this, arguments); |
|
19223 |
} |
|
19224 |
|
|
19225 |
return read; |
|
19226 |
}(), |
|
19227 |
|
|
19228 |
cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) { |
|
19229 |
this._done = true; |
|
19230 |
this._headersReceivedCapability.reject(reason); |
|
19231 |
this._requests.forEach(function (requestCapability) { |
|
19232 |
requestCapability.resolve({ |
|
19233 |
value: undefined, |
|
19234 |
done: true |
|
19235 |
}); |
|
19236 |
}); |
|
19237 |
this._requests = []; |
|
19238 |
if (this._manager.isPendingRequest(this._fullRequestId)) { |
|
19239 |
this._manager.abortRequest(this._fullRequestId); |
|
19240 |
} |
|
19241 |
this._fullRequestReader = null; |
|
19242 |
} |
|
19243 |
}; |
|
19244 |
function PDFNetworkStreamRangeRequestReader(manager, begin, end) { |
|
19245 |
this._manager = manager; |
|
19246 |
var args = { |
|
19247 |
onDone: this._onDone.bind(this), |
|
19248 |
onProgress: this._onProgress.bind(this) |
|
19249 |
}; |
|
19250 |
this._requestId = manager.requestRange(begin, end, args); |
|
19251 |
this._requests = []; |
|
19252 |
this._queuedChunk = null; |
|
19253 |
this._done = false; |
|
19254 |
this.onProgress = null; |
|
19255 |
this.onClosed = null; |
|
19256 |
} |
|
19257 |
PDFNetworkStreamRangeRequestReader.prototype = { |
|
19258 |
_close: function PDFNetworkStreamRangeRequestReader_close() { |
|
19259 |
if (this.onClosed) { |
|
19260 |
this.onClosed(this); |
|
19261 |
} |
|
19262 |
}, |
|
19263 |
_onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) { |
|
19264 |
var chunk = data.chunk; |
|
19265 |
if (this._requests.length > 0) { |
|
19266 |
var requestCapability = this._requests.shift(); |
|
19267 |
requestCapability.resolve({ |
|
19268 |
value: chunk, |
|
19269 |
done: false |
|
19270 |
}); |
|
19271 |
} else { |
|
19272 |
this._queuedChunk = chunk; |
|
19273 |
} |
|
19274 |
this._done = true; |
|
19275 |
this._requests.forEach(function (requestCapability) { |
|
19276 |
requestCapability.resolve({ |
|
19277 |
value: undefined, |
|
19278 |
done: true |
|
19279 |
}); |
|
19280 |
}); |
|
19281 |
this._requests = []; |
|
19282 |
this._close(); |
|
19283 |
}, |
|
19284 |
_onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) { |
|
19285 |
if (!this.isStreamingSupported && this.onProgress) { |
|
19286 |
this.onProgress({ loaded: evt.loaded }); |
|
19287 |
} |
|
19288 |
}, |
|
19289 |
get isStreamingSupported() { |
|
19290 |
return false; |
|
19291 |
}, |
|
19292 |
read: function () { |
|
19293 |
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regenerator2.default.mark(function _callee2() { |
|
19294 |
var chunk, requestCapability; |
|
19295 |
return _regenerator2.default.wrap(function _callee2$(_context2) { |
|
19296 |
while (1) { |
|
19297 |
switch (_context2.prev = _context2.next) { |
|
19298 |
case 0: |
|
19299 |
if (!(this._queuedChunk !== null)) { |
|
19300 |
_context2.next = 4; |
|
19301 |
break; |
|
19302 |
} |
|
19303 |
|
|
19304 |
chunk = this._queuedChunk; |
|
19305 |
|
|
19306 |
this._queuedChunk = null; |
|
19307 |
return _context2.abrupt('return', { |
|
19308 |
value: chunk, |
|
19309 |
done: false |
|
19310 |
}); |
|
19311 |
|
|
19312 |
case 4: |
|
19313 |
if (!this._done) { |
|
19314 |
_context2.next = 6; |
|
19315 |
break; |
|
19316 |
} |
|
19317 |
|
|
19318 |
return _context2.abrupt('return', { |
|
19319 |
value: undefined, |
|
19320 |
done: true |
|
19321 |
}); |
|
19322 |
|
|
19323 |
case 6: |
|
19324 |
requestCapability = (0, _util.createPromiseCapability)(); |
|
19325 |
|
|
19326 |
this._requests.push(requestCapability); |
|
19327 |
return _context2.abrupt('return', requestCapability.promise); |
|
19328 |
|
|
19329 |
case 9: |
|
19330 |
case 'end': |
|
19331 |
return _context2.stop(); |
|
19332 |
} |
|
19333 |
} |
|
19334 |
}, _callee2, this); |
|
19335 |
})); |
|
19336 |
|
|
19337 |
function read() { |
|
19338 |
return _ref2.apply(this, arguments); |
|
19339 |
} |
|
19340 |
|
|
19341 |
return read; |
|
19342 |
}(), |
|
19343 |
|
|
19344 |
cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) { |
|
19345 |
this._done = true; |
|
19346 |
this._requests.forEach(function (requestCapability) { |
|
19347 |
requestCapability.resolve({ |
|
19348 |
value: undefined, |
|
19349 |
done: true |
|
19350 |
}); |
|
19351 |
}); |
|
19352 |
this._requests = []; |
|
19353 |
if (this._manager.isPendingRequest(this._requestId)) { |
|
19354 |
this._manager.abortRequest(this._requestId); |
|
19355 |
} |
|
19356 |
this._close(); |
|
19357 |
} |
|
19358 |
}; |
|
19359 |
exports.PDFNetworkStream = PDFNetworkStream; |
|
19360 |
exports.NetworkManager = NetworkManager; |
|
19361 |
|
|
19362 |
/***/ }) |
|
19363 |
/******/ ]); |
|
19364 |
}); |
|
19365 |
//# sourceMappingURL=pdf.js.map |