@chialab/pdfjs-lib 1.0.0-alpha.14 → 1.0.0-alpha.16

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.
package/README.md CHANGED
@@ -7,12 +7,12 @@
7
7
 
8
8
  ## Features
9
9
 
10
- * Browser and Node (and Bun) optimized builds using ES modules
11
- * Bundler-friendly
12
- * Polyfills included
13
- * Extended annotation models support
14
- * SVG renderer for PDF pages
15
- * Improved TextLayer extraction with structure information
10
+ - Browser and Node (and Bun) optimized builds using ES modules
11
+ - Bundler-friendly
12
+ - Polyfills included
13
+ - Extended annotation models support
14
+ - SVG renderer for PDF pages
15
+ - Improved TextLayer extraction with structure information
16
16
 
17
17
  ## Install
18
18
 
@@ -26,4 +26,12 @@ yarn add @chialab/pdfjs-lib
26
26
 
27
27
  ```
28
28
  pnpm add @chialab/pdfjs-lib
29
- ```
29
+ ```
30
+
31
+ ## Before building
32
+
33
+ Before building the library:
34
+
35
+ ```
36
+ git submodule init && git submodule update
37
+ ```
@@ -1640,6 +1640,91 @@ deleteStreamController_fn = async function(streamController, streamId) {
1640
1640
  delete this.streamControllers[streamId];
1641
1641
  };
1642
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
+
1643
1728
  // src/pdf.js/src/shared/murmurhash3.js
1644
1729
  var SEED = 3285377520;
1645
1730
  var MASK_HIGH = 4294901760;
@@ -1897,5 +1982,8 @@ export {
1897
1982
  MessageHandler,
1898
1983
  convertToRGBA,
1899
1984
  convertBlackAndWhiteToRGBA,
1900
- grayToRGBA
1985
+ grayToRGBA,
1986
+ ColorConverters,
1987
+ DateFormats,
1988
+ TimeFormats
1901
1989
  };