@chialab/pdfjs-lib 1.0.0-alpha.18 → 1.0.0-alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/browser/NodeCanvasFactory-OREYUFNU.js +58 -0
  2. package/dist/browser/chunk-5IWODJWD.js +801 -0
  3. package/dist/browser/chunk-MXRUYXDD.js +1127 -0
  4. package/dist/browser/{chunk-O4CM6PII.js → chunk-NJUB3B5A.js} +5 -787
  5. package/dist/browser/index.js +68 -1107
  6. package/dist/browser/worker.js +16 -14
  7. package/dist/lib/NodeCanvasFactory.d.ts +9 -0
  8. package/dist/lib/NodeFilterFactory.d.ts +10 -0
  9. package/dist/lib/utils.d.ts +1 -1
  10. package/dist/node/NodeCanvasFactory-N32SOXPQ.js +8 -0
  11. package/dist/node/chunk-QCIN557M.js +1424 -0
  12. package/dist/node/{chunk-4FQTXXTH.js → chunk-XMKSLA4K.js} +5 -787
  13. package/dist/node/chunk-ZKUTXCS2.js +801 -0
  14. package/dist/node/index.js +115 -1482
  15. package/dist/node/worker.js +16 -14
  16. package/dist/pdf.js/src/display/api.d.ts +5 -5
  17. package/dist/pdf.js/src/display/display_utils.d.ts +1 -1
  18. package/dist/pdf.js/src/display/draw_layer.d.ts +2 -2
  19. package/dist/pdf.js/src/display/editor/alt_text.d.ts +1 -1
  20. package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +1 -1
  21. package/dist/pdf.js/src/display/editor/color_picker.d.ts +1 -1
  22. package/dist/pdf.js/src/display/editor/draw.d.ts +7 -7
  23. package/dist/pdf.js/src/display/editor/drawers/freedraw.d.ts +3 -3
  24. package/dist/pdf.js/src/display/editor/drawers/signaturedraw.d.ts +13 -13
  25. package/dist/pdf.js/src/display/editor/editor.d.ts +1 -1
  26. package/dist/pdf.js/src/display/editor/freetext.d.ts +2 -2
  27. package/dist/pdf.js/src/display/editor/highlight.d.ts +4 -4
  28. package/dist/pdf.js/src/display/editor/stamp.d.ts +1 -1
  29. package/dist/pdf.js/src/display/editor/toolbar.d.ts +2 -2
  30. package/dist/pdf.js/src/display/text_layer.d.ts +9 -9
  31. package/dist/pdf.js/src/display/worker_options.d.ts +2 -2
  32. package/dist/pdf.js/src/shared/util.d.ts +2 -2
  33. package/dist/pdf.js/web/text_accessibility.d.ts +1 -1
  34. package/package.json +2 -2
  35. package/dist/pdf.js/src/display/cmap_reader_factory.d.ts +0 -25
  36. package/dist/pdf.js/src/display/node_utils.d.ts +0 -32
  37. package/dist/pdf.js/src/display/wasm_factory.d.ts +0 -20
@@ -1,51 +1,8 @@
1
1
  import {
2
2
  __privateAdd,
3
- __privateGet,
4
- __privateMethod,
5
- __privateSet
3
+ __privateMethod
6
4
  } from "./chunk-7MW5RQZ5.js";
7
5
 
8
- // src/lib/polyfills.ts
9
- if (!Array.prototype.at) {
10
- Object.defineProperty(Array.prototype, "at", {
11
- value: function at(index) {
12
- return this[index >= 0 ? index : this.length + index];
13
- },
14
- enumerable: false
15
- });
16
- }
17
- if (!Promise.withResolvers) {
18
- Promise.withResolvers = function withResolvers() {
19
- let resolve;
20
- let reject;
21
- const promise = new this((res, rej) => {
22
- resolve = res;
23
- reject = rej;
24
- });
25
- return {
26
- resolve,
27
- reject,
28
- promise
29
- };
30
- };
31
- }
32
- if (!("try" in Promise)) {
33
- Object.defineProperty(Promise, "try", {
34
- value: function tryFn(fn, ...args) {
35
- return new this(
36
- (resolve, reject) => {
37
- try {
38
- resolve(fn(...args));
39
- } catch (error) {
40
- reject(error);
41
- }
42
- }
43
- );
44
- },
45
- enumerable: false
46
- });
47
- }
48
-
49
6
  // src/pdf.js/src/shared/util.js
50
7
  var isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
51
8
  var FONT_IDENTITY_MATRIX = [1e-3, 0, 0, 1e-3, 0, 0];
@@ -422,7 +379,7 @@ function shadow(obj, prop, value, nonSerializable = false) {
422
379
  });
423
380
  return value;
424
381
  }
425
- var BaseException = function BaseExceptionClosure() {
382
+ var BaseException = (function BaseExceptionClosure() {
426
383
  function BaseException2(message, name) {
427
384
  if (false) {
428
385
  unreachable("Cannot initialize BaseException.");
@@ -433,7 +390,7 @@ var BaseException = function BaseExceptionClosure() {
433
390
  BaseException2.prototype = new Error();
434
391
  BaseException2.constructor = BaseException2;
435
392
  return BaseException2;
436
- }();
393
+ })();
437
394
  var PasswordException = class extends BaseException {
438
395
  constructor(msg, code) {
439
396
  super(msg, "PasswordException");
@@ -1185,737 +1142,6 @@ if (false) {
1185
1142
  };
1186
1143
  }
1187
1144
 
1188
- // src/pdf.js/src/shared/message_handler.js
1189
- var CallbackKind = {
1190
- DATA: 1,
1191
- ERROR: 2
1192
- };
1193
- var StreamKind = {
1194
- CANCEL: 1,
1195
- CANCEL_COMPLETE: 2,
1196
- CLOSE: 3,
1197
- ENQUEUE: 4,
1198
- ERROR: 5,
1199
- PULL: 6,
1200
- PULL_COMPLETE: 7,
1201
- START_COMPLETE: 8
1202
- };
1203
- function onFn() {
1204
- }
1205
- function wrapReason(ex) {
1206
- if (ex instanceof AbortException || ex instanceof InvalidPDFException || ex instanceof PasswordException || ex instanceof ResponseException || ex instanceof UnknownErrorException) {
1207
- return ex;
1208
- }
1209
- if (!(ex instanceof Error || typeof ex === "object" && ex !== null)) {
1210
- unreachable(
1211
- 'wrapReason: Expected "reason" to be a (possibly cloned) Error.'
1212
- );
1213
- }
1214
- switch (ex.name) {
1215
- case "AbortException":
1216
- return new AbortException(ex.message);
1217
- case "InvalidPDFException":
1218
- return new InvalidPDFException(ex.message);
1219
- case "PasswordException":
1220
- return new PasswordException(ex.message, ex.code);
1221
- case "ResponseException":
1222
- return new ResponseException(ex.message, ex.status, ex.missing);
1223
- case "UnknownErrorException":
1224
- return new UnknownErrorException(ex.message, ex.details);
1225
- }
1226
- return new UnknownErrorException(ex.message, ex.toString());
1227
- }
1228
- var _messageAC, _MessageHandler_instances, onMessage_fn, createStreamSink_fn, processStreamMessage_fn, deleteStreamController_fn;
1229
- var MessageHandler = class {
1230
- constructor(sourceName, targetName, comObj) {
1231
- __privateAdd(this, _MessageHandler_instances);
1232
- __privateAdd(this, _messageAC, new AbortController());
1233
- this.sourceName = sourceName;
1234
- this.targetName = targetName;
1235
- this.comObj = comObj;
1236
- this.callbackId = 1;
1237
- this.streamId = 1;
1238
- this.streamSinks = /* @__PURE__ */ Object.create(null);
1239
- this.streamControllers = /* @__PURE__ */ Object.create(null);
1240
- this.callbackCapabilities = /* @__PURE__ */ Object.create(null);
1241
- this.actionHandler = /* @__PURE__ */ Object.create(null);
1242
- comObj.addEventListener("message", __privateMethod(this, _MessageHandler_instances, onMessage_fn).bind(this), {
1243
- signal: __privateGet(this, _messageAC).signal
1244
- });
1245
- }
1246
- on(actionName, handler) {
1247
- if (false) {
1248
- assert(
1249
- typeof handler === "function",
1250
- 'MessageHandler.on: Expected "handler" to be a function.'
1251
- );
1252
- }
1253
- const ah = this.actionHandler;
1254
- if (ah[actionName]) {
1255
- throw new Error(`There is already an actionName called "${actionName}"`);
1256
- }
1257
- ah[actionName] = handler;
1258
- }
1259
- /**
1260
- * Sends a message to the comObj to invoke the action with the supplied data.
1261
- * @param {string} actionName - Action to call.
1262
- * @param {JSON} data - JSON data to send.
1263
- * @param {Array} [transfers] - List of transfers/ArrayBuffers.
1264
- */
1265
- send(actionName, data, transfers) {
1266
- this.comObj.postMessage(
1267
- {
1268
- sourceName: this.sourceName,
1269
- targetName: this.targetName,
1270
- action: actionName,
1271
- data
1272
- },
1273
- transfers
1274
- );
1275
- }
1276
- /**
1277
- * Sends a message to the comObj to invoke the action with the supplied data.
1278
- * Expects that the other side will callback with the response.
1279
- * @param {string} actionName - Action to call.
1280
- * @param {JSON} data - JSON data to send.
1281
- * @param {Array} [transfers] - List of transfers/ArrayBuffers.
1282
- * @returns {Promise} Promise to be resolved with response data.
1283
- */
1284
- sendWithPromise(actionName, data, transfers) {
1285
- const callbackId = this.callbackId++;
1286
- const capability = Promise.withResolvers();
1287
- this.callbackCapabilities[callbackId] = capability;
1288
- try {
1289
- this.comObj.postMessage(
1290
- {
1291
- sourceName: this.sourceName,
1292
- targetName: this.targetName,
1293
- action: actionName,
1294
- callbackId,
1295
- data
1296
- },
1297
- transfers
1298
- );
1299
- } catch (ex) {
1300
- capability.reject(ex);
1301
- }
1302
- return capability.promise;
1303
- }
1304
- /**
1305
- * Sends a message to the comObj to invoke the action with the supplied data.
1306
- * Expect that the other side will callback to signal 'start_complete'.
1307
- * @param {string} actionName - Action to call.
1308
- * @param {JSON} data - JSON data to send.
1309
- * @param {Object} queueingStrategy - Strategy to signal backpressure based on
1310
- * internal queue.
1311
- * @param {Array} [transfers] - List of transfers/ArrayBuffers.
1312
- * @returns {ReadableStream} ReadableStream to read data in chunks.
1313
- */
1314
- sendWithStream(actionName, data, queueingStrategy, transfers) {
1315
- const streamId = this.streamId++, sourceName = this.sourceName, targetName = this.targetName, comObj = this.comObj;
1316
- return new ReadableStream(
1317
- {
1318
- start: (controller) => {
1319
- const startCapability = Promise.withResolvers();
1320
- this.streamControllers[streamId] = {
1321
- controller,
1322
- startCall: startCapability,
1323
- pullCall: null,
1324
- cancelCall: null,
1325
- isClosed: false
1326
- };
1327
- comObj.postMessage(
1328
- {
1329
- sourceName,
1330
- targetName,
1331
- action: actionName,
1332
- streamId,
1333
- data,
1334
- desiredSize: controller.desiredSize
1335
- },
1336
- transfers
1337
- );
1338
- return startCapability.promise;
1339
- },
1340
- pull: (controller) => {
1341
- const pullCapability = Promise.withResolvers();
1342
- this.streamControllers[streamId].pullCall = pullCapability;
1343
- comObj.postMessage({
1344
- sourceName,
1345
- targetName,
1346
- stream: StreamKind.PULL,
1347
- streamId,
1348
- desiredSize: controller.desiredSize
1349
- });
1350
- return pullCapability.promise;
1351
- },
1352
- cancel: (reason) => {
1353
- assert(reason instanceof Error, "cancel must have a valid reason");
1354
- const cancelCapability = Promise.withResolvers();
1355
- this.streamControllers[streamId].cancelCall = cancelCapability;
1356
- this.streamControllers[streamId].isClosed = true;
1357
- comObj.postMessage({
1358
- sourceName,
1359
- targetName,
1360
- stream: StreamKind.CANCEL,
1361
- streamId,
1362
- reason: wrapReason(reason)
1363
- });
1364
- return cancelCapability.promise;
1365
- }
1366
- },
1367
- queueingStrategy
1368
- );
1369
- }
1370
- destroy() {
1371
- __privateGet(this, _messageAC)?.abort();
1372
- __privateSet(this, _messageAC, null);
1373
- }
1374
- };
1375
- _messageAC = new WeakMap();
1376
- _MessageHandler_instances = new WeakSet();
1377
- onMessage_fn = function({ data }) {
1378
- if (data.targetName !== this.sourceName) {
1379
- return;
1380
- }
1381
- if (data.stream) {
1382
- __privateMethod(this, _MessageHandler_instances, processStreamMessage_fn).call(this, data);
1383
- return;
1384
- }
1385
- if (data.callback) {
1386
- const callbackId = data.callbackId;
1387
- const capability = this.callbackCapabilities[callbackId];
1388
- if (!capability) {
1389
- throw new Error(`Cannot resolve callback ${callbackId}`);
1390
- }
1391
- delete this.callbackCapabilities[callbackId];
1392
- if (data.callback === CallbackKind.DATA) {
1393
- capability.resolve(data.data);
1394
- } else if (data.callback === CallbackKind.ERROR) {
1395
- capability.reject(wrapReason(data.reason));
1396
- } else {
1397
- throw new Error("Unexpected callback case");
1398
- }
1399
- return;
1400
- }
1401
- const action = this.actionHandler[data.action];
1402
- if (!action) {
1403
- throw new Error(`Unknown action from worker: ${data.action}`);
1404
- }
1405
- if (data.callbackId) {
1406
- const sourceName = this.sourceName, targetName = data.sourceName, comObj = this.comObj;
1407
- Promise.try(action, data.data).then(
1408
- function(result) {
1409
- comObj.postMessage({
1410
- sourceName,
1411
- targetName,
1412
- callback: CallbackKind.DATA,
1413
- callbackId: data.callbackId,
1414
- data: result
1415
- });
1416
- },
1417
- function(reason) {
1418
- comObj.postMessage({
1419
- sourceName,
1420
- targetName,
1421
- callback: CallbackKind.ERROR,
1422
- callbackId: data.callbackId,
1423
- reason: wrapReason(reason)
1424
- });
1425
- }
1426
- );
1427
- return;
1428
- }
1429
- if (data.streamId) {
1430
- __privateMethod(this, _MessageHandler_instances, createStreamSink_fn).call(this, data);
1431
- return;
1432
- }
1433
- action(data.data);
1434
- };
1435
- createStreamSink_fn = function(data) {
1436
- const streamId = data.streamId, sourceName = this.sourceName, targetName = data.sourceName, comObj = this.comObj;
1437
- const self = this, action = this.actionHandler[data.action];
1438
- const streamSink = {
1439
- enqueue(chunk, size = 1, transfers) {
1440
- if (this.isCancelled) {
1441
- return;
1442
- }
1443
- const lastDesiredSize = this.desiredSize;
1444
- this.desiredSize -= size;
1445
- if (lastDesiredSize > 0 && this.desiredSize <= 0) {
1446
- this.sinkCapability = Promise.withResolvers();
1447
- this.ready = this.sinkCapability.promise;
1448
- }
1449
- comObj.postMessage(
1450
- {
1451
- sourceName,
1452
- targetName,
1453
- stream: StreamKind.ENQUEUE,
1454
- streamId,
1455
- chunk
1456
- },
1457
- transfers
1458
- );
1459
- },
1460
- close() {
1461
- if (this.isCancelled) {
1462
- return;
1463
- }
1464
- this.isCancelled = true;
1465
- comObj.postMessage({
1466
- sourceName,
1467
- targetName,
1468
- stream: StreamKind.CLOSE,
1469
- streamId
1470
- });
1471
- delete self.streamSinks[streamId];
1472
- },
1473
- error(reason) {
1474
- assert(reason instanceof Error, "error must have a valid reason");
1475
- if (this.isCancelled) {
1476
- return;
1477
- }
1478
- this.isCancelled = true;
1479
- comObj.postMessage({
1480
- sourceName,
1481
- targetName,
1482
- stream: StreamKind.ERROR,
1483
- streamId,
1484
- reason: wrapReason(reason)
1485
- });
1486
- },
1487
- sinkCapability: Promise.withResolvers(),
1488
- onPull: null,
1489
- onCancel: null,
1490
- isCancelled: false,
1491
- desiredSize: data.desiredSize,
1492
- ready: null
1493
- };
1494
- streamSink.sinkCapability.resolve();
1495
- streamSink.ready = streamSink.sinkCapability.promise;
1496
- this.streamSinks[streamId] = streamSink;
1497
- Promise.try(action, data.data, streamSink).then(
1498
- function() {
1499
- comObj.postMessage({
1500
- sourceName,
1501
- targetName,
1502
- stream: StreamKind.START_COMPLETE,
1503
- streamId,
1504
- success: true
1505
- });
1506
- },
1507
- function(reason) {
1508
- comObj.postMessage({
1509
- sourceName,
1510
- targetName,
1511
- stream: StreamKind.START_COMPLETE,
1512
- streamId,
1513
- reason: wrapReason(reason)
1514
- });
1515
- }
1516
- );
1517
- };
1518
- processStreamMessage_fn = function(data) {
1519
- const streamId = data.streamId, sourceName = this.sourceName, targetName = data.sourceName, comObj = this.comObj;
1520
- const streamController = this.streamControllers[streamId], streamSink = this.streamSinks[streamId];
1521
- switch (data.stream) {
1522
- case StreamKind.START_COMPLETE:
1523
- if (data.success) {
1524
- streamController.startCall.resolve();
1525
- } else {
1526
- streamController.startCall.reject(wrapReason(data.reason));
1527
- }
1528
- break;
1529
- case StreamKind.PULL_COMPLETE:
1530
- if (data.success) {
1531
- streamController.pullCall.resolve();
1532
- } else {
1533
- streamController.pullCall.reject(wrapReason(data.reason));
1534
- }
1535
- break;
1536
- case StreamKind.PULL:
1537
- if (!streamSink) {
1538
- comObj.postMessage({
1539
- sourceName,
1540
- targetName,
1541
- stream: StreamKind.PULL_COMPLETE,
1542
- streamId,
1543
- success: true
1544
- });
1545
- break;
1546
- }
1547
- if (streamSink.desiredSize <= 0 && data.desiredSize > 0) {
1548
- streamSink.sinkCapability.resolve();
1549
- }
1550
- streamSink.desiredSize = data.desiredSize;
1551
- Promise.try(streamSink.onPull || onFn).then(
1552
- function() {
1553
- comObj.postMessage({
1554
- sourceName,
1555
- targetName,
1556
- stream: StreamKind.PULL_COMPLETE,
1557
- streamId,
1558
- success: true
1559
- });
1560
- },
1561
- function(reason) {
1562
- comObj.postMessage({
1563
- sourceName,
1564
- targetName,
1565
- stream: StreamKind.PULL_COMPLETE,
1566
- streamId,
1567
- reason: wrapReason(reason)
1568
- });
1569
- }
1570
- );
1571
- break;
1572
- case StreamKind.ENQUEUE:
1573
- assert(streamController, "enqueue should have stream controller");
1574
- if (streamController.isClosed) {
1575
- break;
1576
- }
1577
- streamController.controller.enqueue(data.chunk);
1578
- break;
1579
- case StreamKind.CLOSE:
1580
- assert(streamController, "close should have stream controller");
1581
- if (streamController.isClosed) {
1582
- break;
1583
- }
1584
- streamController.isClosed = true;
1585
- streamController.controller.close();
1586
- __privateMethod(this, _MessageHandler_instances, deleteStreamController_fn).call(this, streamController, streamId);
1587
- break;
1588
- case StreamKind.ERROR:
1589
- assert(streamController, "error should have stream controller");
1590
- streamController.controller.error(wrapReason(data.reason));
1591
- __privateMethod(this, _MessageHandler_instances, deleteStreamController_fn).call(this, streamController, streamId);
1592
- break;
1593
- case StreamKind.CANCEL_COMPLETE:
1594
- if (data.success) {
1595
- streamController.cancelCall.resolve();
1596
- } else {
1597
- streamController.cancelCall.reject(wrapReason(data.reason));
1598
- }
1599
- __privateMethod(this, _MessageHandler_instances, deleteStreamController_fn).call(this, streamController, streamId);
1600
- break;
1601
- case StreamKind.CANCEL:
1602
- if (!streamSink) {
1603
- break;
1604
- }
1605
- const dataReason = wrapReason(data.reason);
1606
- Promise.try(streamSink.onCancel || onFn, dataReason).then(
1607
- function() {
1608
- comObj.postMessage({
1609
- sourceName,
1610
- targetName,
1611
- stream: StreamKind.CANCEL_COMPLETE,
1612
- streamId,
1613
- success: true
1614
- });
1615
- },
1616
- function(reason) {
1617
- comObj.postMessage({
1618
- sourceName,
1619
- targetName,
1620
- stream: StreamKind.CANCEL_COMPLETE,
1621
- streamId,
1622
- reason: wrapReason(reason)
1623
- });
1624
- }
1625
- );
1626
- streamSink.sinkCapability.reject(dataReason);
1627
- streamSink.isCancelled = true;
1628
- delete this.streamSinks[streamId];
1629
- break;
1630
- default:
1631
- throw new Error("Unexpected stream case");
1632
- }
1633
- };
1634
- deleteStreamController_fn = async function(streamController, streamId) {
1635
- await Promise.allSettled([
1636
- streamController.startCall?.promise,
1637
- streamController.pullCall?.promise,
1638
- streamController.cancelCall?.promise
1639
- ]);
1640
- delete this.streamControllers[streamId];
1641
- };
1642
-
1643
- // src/pdf.js/src/shared/scripting_utils.js
1644
- function makeColorComp(n) {
1645
- return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
1646
- }
1647
- function scaleAndClamp(x) {
1648
- return Math.max(0, Math.min(255, 255 * x));
1649
- }
1650
- var ColorConverters = class {
1651
- static CMYK_G([c, y, m, k]) {
1652
- return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
1653
- }
1654
- static G_CMYK([g]) {
1655
- return ["CMYK", 0, 0, 0, 1 - g];
1656
- }
1657
- static G_RGB([g]) {
1658
- return ["RGB", g, g, g];
1659
- }
1660
- static G_rgb([g]) {
1661
- g = scaleAndClamp(g);
1662
- return [g, g, g];
1663
- }
1664
- static G_HTML([g]) {
1665
- const G = makeColorComp(g);
1666
- return `#${G}${G}${G}`;
1667
- }
1668
- static RGB_G([r, g, b]) {
1669
- return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
1670
- }
1671
- static RGB_rgb(color) {
1672
- return color.map(scaleAndClamp);
1673
- }
1674
- static RGB_HTML(color) {
1675
- return `#${color.map(makeColorComp).join("")}`;
1676
- }
1677
- static T_HTML() {
1678
- return "#00000000";
1679
- }
1680
- static T_rgb() {
1681
- return [null];
1682
- }
1683
- static CMYK_RGB([c, y, m, k]) {
1684
- return [
1685
- "RGB",
1686
- 1 - Math.min(1, c + k),
1687
- 1 - Math.min(1, m + k),
1688
- 1 - Math.min(1, y + k)
1689
- ];
1690
- }
1691
- static CMYK_rgb([c, y, m, k]) {
1692
- return [
1693
- scaleAndClamp(1 - Math.min(1, c + k)),
1694
- scaleAndClamp(1 - Math.min(1, m + k)),
1695
- scaleAndClamp(1 - Math.min(1, y + k))
1696
- ];
1697
- }
1698
- static CMYK_HTML(components) {
1699
- const rgb = this.CMYK_RGB(components).slice(1);
1700
- return this.RGB_HTML(rgb);
1701
- }
1702
- static RGB_CMYK([r, g, b]) {
1703
- const c = 1 - r;
1704
- const m = 1 - g;
1705
- const y = 1 - b;
1706
- const k = Math.min(c, m, y);
1707
- return ["CMYK", c, m, y, k];
1708
- }
1709
- };
1710
- var DateFormats = [
1711
- "m/d",
1712
- "m/d/yy",
1713
- "mm/dd/yy",
1714
- "mm/yy",
1715
- "d-mmm",
1716
- "d-mmm-yy",
1717
- "dd-mmm-yy",
1718
- "yy-mm-dd",
1719
- "mmm-yy",
1720
- "mmmm-yy",
1721
- "mmm d, yyyy",
1722
- "mmmm d, yyyy",
1723
- "m/d/yy h:MM tt",
1724
- "m/d/yy HH:MM"
1725
- ];
1726
- var TimeFormats = ["HH:MM", "h:MM tt", "HH:MM:ss", "h:MM:ss tt"];
1727
-
1728
- // src/pdf.js/src/shared/murmurhash3.js
1729
- var SEED = 3285377520;
1730
- var MASK_HIGH = 4294901760;
1731
- var MASK_LOW = 65535;
1732
- var MurmurHash3_64 = class {
1733
- constructor(seed) {
1734
- this.h1 = seed ? seed & 4294967295 : SEED;
1735
- this.h2 = seed ? seed & 4294967295 : SEED;
1736
- }
1737
- update(input) {
1738
- let data, length;
1739
- if (typeof input === "string") {
1740
- data = new Uint8Array(input.length * 2);
1741
- length = 0;
1742
- for (let i = 0, ii = input.length; i < ii; i++) {
1743
- const code = input.charCodeAt(i);
1744
- if (code <= 255) {
1745
- data[length++] = code;
1746
- } else {
1747
- data[length++] = code >>> 8;
1748
- data[length++] = code & 255;
1749
- }
1750
- }
1751
- } else if (ArrayBuffer.isView(input)) {
1752
- data = input.slice();
1753
- length = data.byteLength;
1754
- } else {
1755
- throw new Error("Invalid data format, must be a string or TypedArray.");
1756
- }
1757
- const blockCounts = length >> 2;
1758
- const tailLength = length - blockCounts * 4;
1759
- const dataUint32 = new Uint32Array(data.buffer, 0, blockCounts);
1760
- let k1 = 0, k2 = 0;
1761
- let h1 = this.h1, h2 = this.h2;
1762
- const C1 = 3432918353, C2 = 461845907;
1763
- const C1_LOW = C1 & MASK_LOW, C2_LOW = C2 & MASK_LOW;
1764
- for (let i = 0; i < blockCounts; i++) {
1765
- if (i & 1) {
1766
- k1 = dataUint32[i];
1767
- k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
1768
- k1 = k1 << 15 | k1 >>> 17;
1769
- k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
1770
- h1 ^= k1;
1771
- h1 = h1 << 13 | h1 >>> 19;
1772
- h1 = h1 * 5 + 3864292196;
1773
- } else {
1774
- k2 = dataUint32[i];
1775
- k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
1776
- k2 = k2 << 15 | k2 >>> 17;
1777
- k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
1778
- h2 ^= k2;
1779
- h2 = h2 << 13 | h2 >>> 19;
1780
- h2 = h2 * 5 + 3864292196;
1781
- }
1782
- }
1783
- k1 = 0;
1784
- switch (tailLength) {
1785
- case 3:
1786
- k1 ^= data[blockCounts * 4 + 2] << 16;
1787
- /* falls through */
1788
- case 2:
1789
- k1 ^= data[blockCounts * 4 + 1] << 8;
1790
- /* falls through */
1791
- case 1:
1792
- k1 ^= data[blockCounts * 4];
1793
- k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
1794
- k1 = k1 << 15 | k1 >>> 17;
1795
- k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
1796
- if (blockCounts & 1) {
1797
- h1 ^= k1;
1798
- } else {
1799
- h2 ^= k1;
1800
- }
1801
- }
1802
- this.h1 = h1;
1803
- this.h2 = h2;
1804
- }
1805
- hexdigest() {
1806
- let h1 = this.h1, h2 = this.h2;
1807
- h1 ^= h2 >>> 1;
1808
- h1 = h1 * 3981806797 & MASK_HIGH | h1 * 36045 & MASK_LOW;
1809
- h2 = h2 * 4283543511 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 2950163797 & MASK_HIGH) >>> 16;
1810
- h1 ^= h2 >>> 1;
1811
- h1 = h1 * 444984403 & MASK_HIGH | h1 * 60499 & MASK_LOW;
1812
- h2 = h2 * 3301882366 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 3120437893 & MASK_HIGH) >>> 16;
1813
- h1 ^= h2 >>> 1;
1814
- return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
1815
- }
1816
- };
1817
-
1818
- // src/pdf.js/src/shared/image_utils.js
1819
- function convertToRGBA(params) {
1820
- switch (params.kind) {
1821
- case ImageKind.GRAYSCALE_1BPP:
1822
- return convertBlackAndWhiteToRGBA(params);
1823
- case ImageKind.RGB_24BPP:
1824
- return convertRGBToRGBA(params);
1825
- }
1826
- return null;
1827
- }
1828
- function convertBlackAndWhiteToRGBA({
1829
- src,
1830
- srcPos = 0,
1831
- dest,
1832
- width,
1833
- height,
1834
- nonBlackColor = 4294967295,
1835
- inverseDecode = false
1836
- }) {
1837
- const black = FeatureTest.isLittleEndian ? 4278190080 : 255;
1838
- const [zeroMapping, oneMapping] = inverseDecode ? [nonBlackColor, black] : [black, nonBlackColor];
1839
- const widthInSource = width >> 3;
1840
- const widthRemainder = width & 7;
1841
- const srcLength = src.length;
1842
- dest = new Uint32Array(dest.buffer);
1843
- let destPos = 0;
1844
- for (let i = 0; i < height; i++) {
1845
- for (const max = srcPos + widthInSource; srcPos < max; srcPos++) {
1846
- const elem2 = srcPos < srcLength ? src[srcPos] : 255;
1847
- dest[destPos++] = elem2 & 128 ? oneMapping : zeroMapping;
1848
- dest[destPos++] = elem2 & 64 ? oneMapping : zeroMapping;
1849
- dest[destPos++] = elem2 & 32 ? oneMapping : zeroMapping;
1850
- dest[destPos++] = elem2 & 16 ? oneMapping : zeroMapping;
1851
- dest[destPos++] = elem2 & 8 ? oneMapping : zeroMapping;
1852
- dest[destPos++] = elem2 & 4 ? oneMapping : zeroMapping;
1853
- dest[destPos++] = elem2 & 2 ? oneMapping : zeroMapping;
1854
- dest[destPos++] = elem2 & 1 ? oneMapping : zeroMapping;
1855
- }
1856
- if (widthRemainder === 0) {
1857
- continue;
1858
- }
1859
- const elem = srcPos < srcLength ? src[srcPos++] : 255;
1860
- for (let j = 0; j < widthRemainder; j++) {
1861
- dest[destPos++] = elem & 1 << 7 - j ? oneMapping : zeroMapping;
1862
- }
1863
- }
1864
- return { srcPos, destPos };
1865
- }
1866
- function convertRGBToRGBA({
1867
- src,
1868
- srcPos = 0,
1869
- dest,
1870
- destPos = 0,
1871
- width,
1872
- height
1873
- }) {
1874
- let i = 0;
1875
- const len = width * height * 3;
1876
- const len32 = len >> 2;
1877
- const src32 = new Uint32Array(src.buffer, srcPos, len32);
1878
- if (FeatureTest.isLittleEndian) {
1879
- for (; i < len32 - 2; i += 3, destPos += 4) {
1880
- const s1 = src32[i];
1881
- const s2 = src32[i + 1];
1882
- const s3 = src32[i + 2];
1883
- dest[destPos] = s1 | 4278190080;
1884
- dest[destPos + 1] = s1 >>> 24 | s2 << 8 | 4278190080;
1885
- dest[destPos + 2] = s2 >>> 16 | s3 << 16 | 4278190080;
1886
- dest[destPos + 3] = s3 >>> 8 | 4278190080;
1887
- }
1888
- for (let j = i * 4, jj = srcPos + len; j < jj; j += 3) {
1889
- dest[destPos++] = src[j] | src[j + 1] << 8 | src[j + 2] << 16 | 4278190080;
1890
- }
1891
- } else {
1892
- for (; i < len32 - 2; i += 3, destPos += 4) {
1893
- const s1 = src32[i];
1894
- const s2 = src32[i + 1];
1895
- const s3 = src32[i + 2];
1896
- dest[destPos] = s1 | 255;
1897
- dest[destPos + 1] = s1 << 24 | s2 >>> 8 | 255;
1898
- dest[destPos + 2] = s2 << 16 | s3 >>> 16 | 255;
1899
- dest[destPos + 3] = s3 << 8 | 255;
1900
- }
1901
- for (let j = i * 4, jj = srcPos + len; j < jj; j += 3) {
1902
- dest[destPos++] = src[j] << 24 | src[j + 1] << 16 | src[j + 2] << 8 | 255;
1903
- }
1904
- }
1905
- return { srcPos: srcPos + len, destPos };
1906
- }
1907
- function grayToRGBA(src, dest) {
1908
- if (FeatureTest.isLittleEndian) {
1909
- for (let i = 0, ii = src.length; i < ii; i++) {
1910
- dest[i] = src[i] * 65793 | 4278190080;
1911
- }
1912
- } else {
1913
- for (let i = 0, ii = src.length; i < ii; i++) {
1914
- dest[i] = src[i] * 16843008 | 255;
1915
- }
1916
- }
1917
- }
1918
-
1919
1145
  export {
1920
1146
  isNodeJS,
1921
1147
  FONT_IDENTITY_MATRIX,
@@ -1953,6 +1179,7 @@ export {
1953
1179
  shadow,
1954
1180
  BaseException,
1955
1181
  PasswordException,
1182
+ UnknownErrorException,
1956
1183
  InvalidPDFException,
1957
1184
  ResponseException,
1958
1185
  FormatError,
@@ -1976,14 +1203,5 @@ export {
1976
1203
  MathClamp,
1977
1204
  toHexUtil,
1978
1205
  toBase64Util,
1979
- fromBase64Util,
1980
- MurmurHash3_64,
1981
- wrapReason,
1982
- MessageHandler,
1983
- convertToRGBA,
1984
- convertBlackAndWhiteToRGBA,
1985
- grayToRGBA,
1986
- ColorConverters,
1987
- DateFormats,
1988
- TimeFormats
1206
+ fromBase64Util
1989
1207
  };