@2018kguo/recto 0.1.0 → 0.3.0

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 (44) hide show
  1. package/dist/assets.d.ts +11 -6
  2. package/dist/assets.js +123 -42
  3. package/dist/document.d.ts +48 -2
  4. package/dist/document.js +109 -4
  5. package/dist/engine.d.ts +17 -9
  6. package/dist/engine.js +223 -45
  7. package/dist/errors.d.ts +4 -2
  8. package/dist/errors.js +4 -1
  9. package/dist/index.d.ts +12 -1
  10. package/dist/index.js +13 -0
  11. package/dist/pool-worker.d.ts +14 -0
  12. package/dist/pool-worker.js +65 -0
  13. package/dist/pool.d.ts +36 -0
  14. package/dist/pool.js +287 -0
  15. package/dist/ranged.d.ts +10 -0
  16. package/dist/ranged.js +38 -11
  17. package/package.json +2 -1
  18. package/wasm/FoxitDingbats.pfb +0 -0
  19. package/wasm/FoxitFixed.pfb +0 -0
  20. package/wasm/FoxitFixedBold.pfb +0 -0
  21. package/wasm/FoxitFixedBoldItalic.pfb +0 -0
  22. package/wasm/FoxitFixedItalic.pfb +0 -0
  23. package/wasm/FoxitSans.pfb +0 -0
  24. package/wasm/FoxitSansBold.pfb +0 -0
  25. package/wasm/FoxitSansBoldItalic.pfb +0 -0
  26. package/wasm/FoxitSansItalic.pfb +0 -0
  27. package/wasm/FoxitSerif.pfb +0 -0
  28. package/wasm/FoxitSerifBold.pfb +0 -0
  29. package/wasm/FoxitSerifBoldItalic.pfb +0 -0
  30. package/wasm/FoxitSerifItalic.pfb +0 -0
  31. package/wasm/FoxitSymbol.pfb +0 -0
  32. package/wasm/THIRD_PARTY_NOTICES +2 -158
  33. package/wasm/cmaps.deflate +0 -0
  34. package/wasm/pins.d.mts +1 -1
  35. package/wasm/pins.mjs +19 -3
  36. package/wasm/recto-more.wasm +0 -0
  37. package/wasm/recto-rare.wasm +0 -0
  38. package/wasm/recto-render.wasm +0 -0
  39. package/wasm/recto.gen.d.mts +2 -1
  40. package/wasm/recto.gen.mjs +118 -12
  41. package/wasm/recto.types.d.mts +46 -1
  42. package/wasm/recto.wasm +0 -0
  43. package/wasm/cmaps.brotli +0 -0
  44. package/wasm/fonts.bin +0 -0
@@ -198,7 +198,7 @@ Copyright (c) 2005-2008, The Android Open Source Project
198
198
  END OF TERMS AND CONDITIONS
199
199
 
200
200
  ==============================================================================
201
- Foxit fonts (fonts.bin)
201
+ Foxit fonts (Foxit*.pfb)
202
202
  ==============================================================================
203
203
 
204
204
  // Copyright 2014 PDFium Authors. All rights reserved.
@@ -230,7 +230,7 @@ Foxit fonts (fonts.bin)
230
230
  // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
231
231
 
232
232
  ==============================================================================
233
- Adobe CMap resources (cmaps.brotli)
233
+ Adobe CMap resources (cmaps.deflate)
234
234
  ==============================================================================
235
235
 
236
236
  Copyright 1990-2023 Adobe. All rights reserved.
@@ -862,34 +862,6 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
862
862
  IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
863
863
  DEALINGS IN THE SOFTWARE.
864
864
 
865
- ==============================================================================
866
- fastrand 2.5.0 (compiled into recto.wasm; Apache-2.0 OR MIT)
867
- ==============================================================================
868
-
869
- Permission is hereby granted, free of charge, to any
870
- person obtaining a copy of this software and associated
871
- documentation files (the "Software"), to deal in the
872
- Software without restriction, including without
873
- limitation the rights to use, copy, modify, merge,
874
- publish, distribute, sublicense, and/or sell copies of
875
- the Software, and to permit persons to whom the Software
876
- is furnished to do so, subject to the following
877
- conditions:
878
-
879
- The above copyright notice and this permission notice
880
- shall be included in all copies or substantial portions
881
- of the Software.
882
-
883
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
884
- ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
885
- TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
886
- PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
887
- SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
888
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
889
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
890
- IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
891
- DEALINGS IN THE SOFTWARE.
892
-
893
865
  ==============================================================================
894
866
  fdeflate 0.3.7 (compiled into recto.wasm; MIT OR Apache-2.0)
895
867
  ==============================================================================
@@ -1544,106 +1516,6 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
1544
1516
  IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
1545
1517
  DEALINGS IN THE SOFTWARE.
1546
1518
 
1547
- ==============================================================================
1548
- phf 0.13.1 (compiled into recto.wasm; MIT)
1549
- ==============================================================================
1550
-
1551
- The MIT License (MIT)
1552
-
1553
- Copyright (c) 2014-2022 Steven Fackler, Yuki Okushi
1554
-
1555
- Permission is hereby granted, free of charge, to any person obtaining a copy of
1556
- this software and associated documentation files (the "Software"), to deal in
1557
- the Software without restriction, including without limitation the rights to
1558
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1559
- the Software, and to permit persons to whom the Software is furnished to do so,
1560
- subject to the following conditions:
1561
-
1562
- The above copyright notice and this permission notice shall be included in all
1563
- copies or substantial portions of the Software.
1564
-
1565
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1566
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1567
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
1568
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1569
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1570
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1571
-
1572
- ==============================================================================
1573
- phf_generator 0.13.1 (compiled into recto.wasm; MIT)
1574
- ==============================================================================
1575
-
1576
- The MIT License (MIT)
1577
-
1578
- Copyright (c) 2014-2022 Steven Fackler, Yuki Okushi
1579
-
1580
- Permission is hereby granted, free of charge, to any person obtaining a copy of
1581
- this software and associated documentation files (the "Software"), to deal in
1582
- the Software without restriction, including without limitation the rights to
1583
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1584
- the Software, and to permit persons to whom the Software is furnished to do so,
1585
- subject to the following conditions:
1586
-
1587
- The above copyright notice and this permission notice shall be included in all
1588
- copies or substantial portions of the Software.
1589
-
1590
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1591
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1592
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
1593
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1594
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1595
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1596
-
1597
- ==============================================================================
1598
- phf_macros 0.13.1 (compiled into recto.wasm; MIT)
1599
- ==============================================================================
1600
-
1601
- The MIT License (MIT)
1602
-
1603
- Copyright (c) 2014-2022 Steven Fackler, Yuki Okushi
1604
-
1605
- Permission is hereby granted, free of charge, to any person obtaining a copy of
1606
- this software and associated documentation files (the "Software"), to deal in
1607
- the Software without restriction, including without limitation the rights to
1608
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1609
- the Software, and to permit persons to whom the Software is furnished to do so,
1610
- subject to the following conditions:
1611
-
1612
- The above copyright notice and this permission notice shall be included in all
1613
- copies or substantial portions of the Software.
1614
-
1615
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1616
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1617
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
1618
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1619
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1620
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1621
-
1622
- ==============================================================================
1623
- phf_shared 0.13.1 (compiled into recto.wasm; MIT)
1624
- ==============================================================================
1625
-
1626
- The MIT License (MIT)
1627
-
1628
- Copyright (c) 2014-2022 Steven Fackler, Yuki Okushi
1629
-
1630
- Permission is hereby granted, free of charge, to any person obtaining a copy of
1631
- this software and associated documentation files (the "Software"), to deal in
1632
- the Software without restriction, including without limitation the rights to
1633
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
1634
- the Software, and to permit persons to whom the Software is furnished to do so,
1635
- subject to the following conditions:
1636
-
1637
- The above copyright notice and this permission notice shall be included in all
1638
- copies or substantial portions of the Software.
1639
-
1640
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1641
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1642
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
1643
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1644
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1645
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1646
-
1647
1519
  ==============================================================================
1648
1520
  pic-scale 0.7.12 (compiled into recto.wasm; BSD-3-Clause OR Apache-2.0)
1649
1521
  ==============================================================================
@@ -2024,34 +1896,6 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
2024
1896
  IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2025
1897
  DEALINGS IN THE SOFTWARE.
2026
1898
 
2027
- ==============================================================================
2028
- syn 2.0.119 (compiled into recto.wasm; MIT OR Apache-2.0)
2029
- ==============================================================================
2030
-
2031
- Permission is hereby granted, free of charge, to any
2032
- person obtaining a copy of this software and associated
2033
- documentation files (the "Software"), to deal in the
2034
- Software without restriction, including without
2035
- limitation the rights to use, copy, modify, merge,
2036
- publish, distribute, sublicense, and/or sell copies of
2037
- the Software, and to permit persons to whom the Software
2038
- is furnished to do so, subject to the following
2039
- conditions:
2040
-
2041
- The above copyright notice and this permission notice
2042
- shall be included in all copies or substantial portions
2043
- of the Software.
2044
-
2045
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
2046
- ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
2047
- TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
2048
- PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
2049
- SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
2050
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
2051
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
2052
- IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
2053
- DEALINGS IN THE SOFTWARE.
2054
-
2055
1899
  ==============================================================================
2056
1900
  syn 3.0.9 (compiled into recto.wasm; MIT OR Apache-2.0)
2057
1901
  ==============================================================================
Binary file
package/wasm/pins.d.mts CHANGED
@@ -1 +1 @@
1
- export declare const PINS: Record<"recto.wasm" | "fonts.bin" | "cjk-fallback.ttf" | "cmaps.brotli", string>;
1
+ export declare const PINS: Record<"recto.wasm" | "recto-render.wasm" | "recto-more.wasm" | "recto-rare.wasm" | "FoxitFixed.pfb" | "FoxitFixedBold.pfb" | "FoxitFixedBoldItalic.pfb" | "FoxitFixedItalic.pfb" | "FoxitSans.pfb" | "FoxitSansBold.pfb" | "FoxitSansBoldItalic.pfb" | "FoxitSansItalic.pfb" | "FoxitSerif.pfb" | "FoxitSerifBold.pfb" | "FoxitSerifBoldItalic.pfb" | "FoxitSerifItalic.pfb" | "FoxitSymbol.pfb" | "FoxitDingbats.pfb" | "cjk-fallback.ttf" | "cmaps.deflate", string>;
package/wasm/pins.mjs CHANGED
@@ -1,7 +1,23 @@
1
1
  // Generated by scripts/package-wasm.mjs.
2
2
  export const PINS = {
3
- "recto.wasm": "3d377c0a72a0f4d529cbae0b5d2b99fee7362485259a8f193fb99eff9c7277e4",
4
- "fonts.bin": "98b2cdac11db0a4b8b3fa8c308f0ca8dcd5a79a88a3e43ba1ba280149c0ae797",
3
+ "recto.wasm": "1ca7ee27355011de489c91749e764c9ac76fcb0f37020f96273075f5fe4d4841",
4
+ "recto-render.wasm": "356f4f94b1cf4125247da4991f1ff827879e5cf1c35354ecb572e53545b01b2c",
5
+ "recto-more.wasm": "a4d05fc178ebc4696f72dfd2b3f3d027ac30931383363754b9629be69dd80f99",
6
+ "recto-rare.wasm": "e5f0137133d92c8bf2aacbc6e2363c55276b258d0dc81bcaa8ba7a9c2c891f2a",
7
+ "FoxitFixed.pfb": "b6c8fe53f134b8b6d4578cd2d544df4cee9624c4efa8d51a560fb40ea296101b",
8
+ "FoxitFixedBold.pfb": "f1b7159702973f54fc86254ea38bcf3712b2a736eb3a0995751e9f4bb45ad603",
9
+ "FoxitFixedBoldItalic.pfb": "8a000945843bd31add06aee63bf9fd41b7578b4f3242a4b7cd46349ad9d24d4d",
10
+ "FoxitFixedItalic.pfb": "5007faf8320fa1fcc08b8894b356ad976f60b992ba29ee5272578bbdebaf3876",
11
+ "FoxitSans.pfb": "a02339e95d20db14cbdfc1c6baf359cd36a091d5434925c3a4040f60e1a1af9e",
12
+ "FoxitSansBold.pfb": "7bdfa36de1d5757dcfaf8b8a4be95c6e41c40fa70dbed9d78bf979a7b9959054",
13
+ "FoxitSansBoldItalic.pfb": "555ce45924338e2e4b32821910221ce85da691fd59a9723c4c971a7c5627fc8b",
14
+ "FoxitSansItalic.pfb": "7751cbefeda351708dae8c4a88db043411bc39ab2ae2097685da845d4d16f307",
15
+ "FoxitSerif.pfb": "4f57d2b9d884af8f907bf22df6019b52d86cbf6214fdbd02b1ae05472a543f35",
16
+ "FoxitSerifBold.pfb": "0bdf4b04e964139818d51eda03d566ba999fc3ba2421b1c6c51f9dc969022e80",
17
+ "FoxitSerifBoldItalic.pfb": "a406cac82583bf98175cb62c87ed5e95c45fbb34eece63a10b0a13e793cb2e10",
18
+ "FoxitSerifItalic.pfb": "610ae0687198045c4db5d1a6650fd5e92536631706382eb8b72e38df578d0ae9",
19
+ "FoxitSymbol.pfb": "47967d055530e7357088a08403115425643ec2cdfd6201ba8af0fbd7116c1539",
20
+ "FoxitDingbats.pfb": "845c752392b6c914fb989c75a08b7792b88f542d2499042ef2889f8c814a16ed",
5
21
  "cjk-fallback.ttf": "8a4dea0899424438af25a6f1f6eb61e5d111d85367eece0a5d30170861ae6b2e",
6
- "cmaps.brotli": "ddf37af521d904d5646c2fc37b2b7e912dc1b56f0d210190b61f598154758e46"
22
+ "cmaps.deflate": "4664ac3a868d2e255c961ed4d8be4b236d61f47ee0ce3d285355ab4af245d7df"
7
23
  };
Binary file
Binary file
Binary file
@@ -1,2 +1,3 @@
1
1
  import type * as Glue from "./recto.types.mjs";
2
- export declare function createGlue(): Pick<typeof Glue, "Annotations" | "Document" | "PageObjects" | "PageScan" | "PageText" | "RenderedPage" | "setAssetLoader" | "initSync">;
2
+ export declare function createGlue(placeholders: Record<string, object>, finalizing: (free: () => void) => void): Pick<typeof Glue, "Annotations" | "Document" | "PageObjects" | "PageScan" | "PageText" | "RenderTask" | "RenderedPage" | "setAssetLoader" | "sha256" | "initSync">;
3
+ export declare const PART_TABLE: string;
@@ -1,5 +1,5 @@
1
1
  // Generated by scripts/package-wasm.mjs from wasm-bindgen's glue.
2
- export function createGlue() {
2
+ export function createGlue(placeholders, finalizing) {
3
3
  /* @ts-self-types="./recto.d.ts" */
4
4
 
5
5
  /**
@@ -142,6 +142,21 @@ class Document {
142
142
  }
143
143
  return Annotations.__wrap(ret[0]);
144
144
  }
145
+ /**
146
+ * @returns {number}
147
+ */
148
+ fileLength() {
149
+ const ret = wasm.document_fileLength(this.__wbg_ptr);
150
+ return ret >>> 0;
151
+ }
152
+ /**
153
+ * Where the file is in this instance's memory, to reopen it on the full engine without a copy.
154
+ * @returns {number}
155
+ */
156
+ filePointer() {
157
+ const ret = wasm.document_filePointer(this.__wbg_ptr);
158
+ return ret >>> 0;
159
+ }
145
160
  /**
146
161
  * @param {number} index
147
162
  * @returns {PageObjects}
@@ -218,6 +233,14 @@ class Document {
218
233
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
219
234
  return v1;
220
235
  }
236
+ /**
237
+ * One string per page, or null if the file gives no labels.
238
+ * @returns {any}
239
+ */
240
+ pageLabels() {
241
+ const ret = wasm.document_pageLabels(this.__wbg_ptr);
242
+ return ret;
243
+ }
221
244
  /**
222
245
  * `PdfPageText` columns.
223
246
  * @param {number} index
@@ -230,6 +253,20 @@ class Document {
230
253
  }
231
254
  return PageText.__wrap(ret[0]);
232
255
  }
256
+ /**
257
+ * A render that returns to its caller between slices, for as long as it's asked to run.
258
+ * @param {number} index
259
+ * @param {number} width
260
+ * @param {number} max_height
261
+ * @returns {RenderTask}
262
+ */
263
+ renderTask(index, width, max_height) {
264
+ const ret = wasm.document_renderTask(this.__wbg_ptr, index, width, max_height);
265
+ if (ret[2]) {
266
+ throw takeFromExternrefTable0(ret[1]);
267
+ }
268
+ return RenderTask.__wrap(ret[0]);
269
+ }
233
270
  /**
234
271
  * @param {number} index
235
272
  * @param {number} width
@@ -255,6 +292,16 @@ class Document {
255
292
  }
256
293
  return PageScan.__wrap(ret[0]);
257
294
  }
295
+ /**
296
+ * `[pages, pageLabels, outline]`: whether a limit cut each short.
297
+ * @returns {Uint8Array}
298
+ */
299
+ structureTruncated() {
300
+ const ret = wasm.document_structureTruncated(this.__wbg_ptr);
301
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
302
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
303
+ return v1;
304
+ }
258
305
  /**
259
306
  * Text and annotations (no objects).
260
307
  * @param {number} index
@@ -648,6 +695,43 @@ class PageText {
648
695
  }
649
696
  if (Symbol.dispose) PageText.prototype[Symbol.dispose] = PageText.prototype.free;
650
697
 
698
+ class RenderTask {
699
+ static __wrap(ptr) {
700
+ const obj = Object.create(RenderTask.prototype);
701
+ obj.__wbg_ptr = ptr;
702
+ RenderTaskFinalization.register(obj, obj.__wbg_ptr, obj);
703
+ return obj;
704
+ }
705
+ __destroy_into_raw() {
706
+ const ptr = this.__wbg_ptr;
707
+ this.__wbg_ptr = 0;
708
+ RenderTaskFinalization.unregister(this);
709
+ return ptr;
710
+ }
711
+ free() {
712
+ const ptr = this.__destroy_into_raw();
713
+ wasm.__wbg_rendertask_free(ptr, 0);
714
+ }
715
+ /**
716
+ * Rasterizes what `step` drew: the rest of the page, in one call.
717
+ * @returns {RenderedPage}
718
+ */
719
+ finish() {
720
+ const ret = wasm.rendertask_finish(this.__wbg_ptr);
721
+ return RenderedPage.__wrap(ret);
722
+ }
723
+ /**
724
+ * Runs for about `budget_ms`; true once the page's content is done.
725
+ * @param {number} budget_ms
726
+ * @returns {boolean}
727
+ */
728
+ step(budget_ms) {
729
+ const ret = wasm.rendertask_step(this.__wbg_ptr, budget_ms);
730
+ return ret !== 0;
731
+ }
732
+ }
733
+ if (Symbol.dispose) RenderTask.prototype[Symbol.dispose] = RenderTask.prototype.free;
734
+
651
735
  class RenderedPage {
652
736
  static __wrap(ptr) {
653
737
  const obj = Object.create(RenderedPage.prototype);
@@ -720,17 +804,31 @@ if (Symbol.dispose) RenderedPage.prototype[Symbol.dispose] = RenderedPage.protot
720
804
  /**
721
805
  * The host's asset loader: `(index) => Uint8Array | undefined`, called
722
806
  * synchronously the first time a document needs a built-in font (0..13,
723
- * `fonts.bin` order), the CJK fallback (14) or the predefined CMaps (15).
807
+ * `STANDARD_FONTS` order), the CJK fallback (14) or the predefined CMaps (15).
724
808
  * Fonts are kept per instance; the CMaps are decompressed once and kept.
725
809
  * @param {Function} loader
726
810
  */
727
811
  function setAssetLoader(loader) {
728
812
  wasm.setAssetLoader(loader);
729
813
  }
814
+
815
+ /**
816
+ * SHA-256, for the JavaScript side's checks on large assets it read synchronously.
817
+ * @param {Uint8Array} bytes
818
+ * @returns {Uint8Array}
819
+ */
820
+ function sha256(bytes) {
821
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
822
+ const len0 = WASM_VECTOR_LEN;
823
+ const ret = wasm.sha256(ptr0, len0);
824
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
825
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
826
+ return v2;
827
+ }
730
828
  function __wbg_get_imports() {
731
829
  const import0 = {
732
830
  __proto__: null,
733
- __wbg_Error_c1f57494f0e0f78b: function(arg0, arg1) {
831
+ __wbg_Error_ea7352bf93a3f61d: function(arg0, arg1) {
734
832
  const ret = Error(getStringFromWasm0(arg0, arg1));
735
833
  return ret;
736
834
  },
@@ -765,6 +863,10 @@ function __wbg_get_imports() {
765
863
  const ret = new Array();
766
864
  return ret;
767
865
  },
866
+ __wbg_now_aa4ccb83129e9e55: function() {
867
+ const ret = Date.now();
868
+ return ret;
869
+ },
768
870
  __wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
769
871
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
770
872
  },
@@ -772,7 +874,7 @@ function __wbg_get_imports() {
772
874
  const ret = arg0.push(arg1);
773
875
  return ret;
774
876
  },
775
- __wbg_set_e4e464ef2e7b25d9: function() { return handleError(function (arg0, arg1, arg2) {
877
+ __wbg_set_807eb08c2580223b: function() { return handleError(function (arg0, arg1, arg2) {
776
878
  const ret = Reflect.set(arg0, arg1, arg2);
777
879
  return ret;
778
880
  }, arguments); },
@@ -798,28 +900,31 @@ function __wbg_get_imports() {
798
900
  };
799
901
  return {
800
902
  __proto__: null,
801
- "./recto_bg.js": import0,
903
+ "./recto_bg.js": import0, ...placeholders,
802
904
  };
803
905
  }
804
906
 
805
907
  const AnnotationsFinalization = (typeof FinalizationRegistry === 'undefined')
806
908
  ? { register: () => {}, unregister: () => {} }
807
- : new FinalizationRegistry(ptr => wasm.__wbg_annotations_free(ptr, 1));
909
+ : new FinalizationRegistry(ptr => finalizing(() => wasm.__wbg_annotations_free(ptr, 1)));
808
910
  const DocumentFinalization = (typeof FinalizationRegistry === 'undefined')
809
911
  ? { register: () => {}, unregister: () => {} }
810
- : new FinalizationRegistry(ptr => wasm.__wbg_document_free(ptr, 1));
912
+ : new FinalizationRegistry(ptr => finalizing(() => wasm.__wbg_document_free(ptr, 1)));
811
913
  const PageObjectsFinalization = (typeof FinalizationRegistry === 'undefined')
812
914
  ? { register: () => {}, unregister: () => {} }
813
- : new FinalizationRegistry(ptr => wasm.__wbg_pageobjects_free(ptr, 1));
915
+ : new FinalizationRegistry(ptr => finalizing(() => wasm.__wbg_pageobjects_free(ptr, 1)));
814
916
  const PageScanFinalization = (typeof FinalizationRegistry === 'undefined')
815
917
  ? { register: () => {}, unregister: () => {} }
816
- : new FinalizationRegistry(ptr => wasm.__wbg_pagescan_free(ptr, 1));
918
+ : new FinalizationRegistry(ptr => finalizing(() => wasm.__wbg_pagescan_free(ptr, 1)));
817
919
  const PageTextFinalization = (typeof FinalizationRegistry === 'undefined')
818
920
  ? { register: () => {}, unregister: () => {} }
819
- : new FinalizationRegistry(ptr => wasm.__wbg_pagetext_free(ptr, 1));
921
+ : new FinalizationRegistry(ptr => finalizing(() => wasm.__wbg_pagetext_free(ptr, 1)));
922
+ const RenderTaskFinalization = (typeof FinalizationRegistry === 'undefined')
923
+ ? { register: () => {}, unregister: () => {} }
924
+ : new FinalizationRegistry(ptr => finalizing(() => wasm.__wbg_rendertask_free(ptr, 1)));
820
925
  const RenderedPageFinalization = (typeof FinalizationRegistry === 'undefined')
821
926
  ? { register: () => {}, unregister: () => {} }
822
- : new FinalizationRegistry(ptr => wasm.__wbg_renderedpage_free(ptr, 1));
927
+ : new FinalizationRegistry(ptr => finalizing(() => wasm.__wbg_renderedpage_free(ptr, 1)));
823
928
 
824
929
  function addToExternrefTable0(obj) {
825
930
  const idx = wasm.__externref_table_alloc();
@@ -1093,5 +1198,6 @@ async function __wbg_init(module_or_path) {
1093
1198
 
1094
1199
 
1095
1200
 
1096
- return { Annotations, Document, PageObjects, PageScan, PageText, RenderedPage, setAssetLoader, initSync };
1201
+ return { Annotations, Document, PageObjects, PageScan, PageText, RenderTask, RenderedPage, setAssetLoader, sha256, initSync };
1097
1202
  }
1203
+ export const PART_TABLE = "%c";
@@ -25,6 +25,11 @@ export class Document {
25
25
  free(): void;
26
26
  [Symbol.dispose](): void;
27
27
  annotations(index: number): Annotations;
28
+ fileLength(): number;
29
+ /**
30
+ * Where the file is in this instance's memory, to reopen it on the full engine without a copy.
31
+ */
32
+ filePointer(): number;
28
33
  objects(index: number): PageObjects;
29
34
  /**
30
35
  * A file of `length` bytes read by range. `read(offset, length)`
@@ -41,15 +46,27 @@ export class Document {
41
46
  * [width, height, rotation]
42
47
  */
43
48
  pageInfo(index: number): Float32Array<ArrayBuffer>;
49
+ /**
50
+ * One string per page, or null if the file gives no labels.
51
+ */
52
+ pageLabels(): any;
44
53
  /**
45
54
  * `PdfPageText` columns.
46
55
  */
47
56
  pageText(index: number): PageText;
57
+ /**
58
+ * A render that returns to its caller between slices, for as long as it's asked to run.
59
+ */
60
+ renderTask(index: number, width: number, max_height: number): RenderTask;
48
61
  render(index: number, width: number, max_height: number): RenderedPage;
49
62
  /**
50
63
  * Text, objects and annotations from one interpretation of the page.
51
64
  */
52
65
  scan(index: number): PageScan;
66
+ /**
67
+ * `[pages, pageLabels, outline]`: whether a limit cut each short.
68
+ */
69
+ structureTruncated(): Uint8Array<ArrayBuffer>;
53
70
  /**
54
71
  * Text and annotations (no objects).
55
72
  */
@@ -121,6 +138,20 @@ export class PageText {
121
138
  readonly wordLastChar: Uint32Array<ArrayBuffer>;
122
139
  }
123
140
 
141
+ export class RenderTask {
142
+ private constructor();
143
+ free(): void;
144
+ [Symbol.dispose](): void;
145
+ /**
146
+ * Rasterizes what `step` drew: the rest of the page, in one call.
147
+ */
148
+ finish(): RenderedPage;
149
+ /**
150
+ * Runs for about `budget_ms`; true once the page's content is done.
151
+ */
152
+ step(budget_ms: number): boolean;
153
+ }
154
+
124
155
  export class RenderedPage {
125
156
  private constructor();
126
157
  free(): void;
@@ -137,11 +168,16 @@ export class RenderedPage {
137
168
  /**
138
169
  * The host's asset loader: `(index) => Uint8Array | undefined`, called
139
170
  * synchronously the first time a document needs a built-in font (0..13,
140
- * `fonts.bin` order), the CJK fallback (14) or the predefined CMaps (15).
171
+ * `STANDARD_FONTS` order), the CJK fallback (14) or the predefined CMaps (15).
141
172
  * Fonts are kept per instance; the CMaps are decompressed once and kept.
142
173
  */
143
174
  export function setAssetLoader(loader: (index: number) => Uint8Array | undefined): void;
144
175
 
176
+ /**
177
+ * SHA-256, for the JavaScript side's checks on large assets it read synchronously.
178
+ */
179
+ export function sha256(bytes: Uint8Array): Uint8Array<ArrayBuffer>;
180
+
145
181
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
146
182
 
147
183
  export interface InitOutput {
@@ -155,6 +191,7 @@ export interface InitOutput {
155
191
  readonly __wbg_pagescan_free: (a: number, b: number) => void;
156
192
  readonly __wbg_pagetext_free: (a: number, b: number) => void;
157
193
  readonly __wbg_renderedpage_free: (a: number, b: number) => void;
194
+ readonly __wbg_rendertask_free: (a: number, b: number) => void;
158
195
  readonly __wbg_set_renderedpage_height: (a: number, b: number) => void;
159
196
  readonly __wbg_set_renderedpage_truncated: (a: number, b: number) => void;
160
197
  readonly __wbg_set_renderedpage_width: (a: number, b: number) => void;
@@ -169,15 +206,20 @@ export interface InitOutput {
169
206
  readonly annotations_hasField: (a: number) => [number, number];
170
207
  readonly annotations_subtypes: (a: number) => [number, number];
171
208
  readonly document_annotations: (a: number, b: number) => [number, number, number];
209
+ readonly document_fileLength: (a: number) => number;
210
+ readonly document_filePointer: (a: number) => number;
172
211
  readonly document_objects: (a: number, b: number) => [number, number, number];
173
212
  readonly document_open: (a: number, b: number, c: number, d: number) => [number, number, number];
174
213
  readonly document_openRanged: (a: number, b: number, c: any, d: number, e: number) => [number, number, number];
175
214
  readonly document_outline: (a: number) => any;
176
215
  readonly document_pageCount: (a: number) => number;
177
216
  readonly document_pageInfo: (a: number, b: number) => [number, number, number, number];
217
+ readonly document_pageLabels: (a: number) => any;
178
218
  readonly document_pageText: (a: number, b: number) => [number, number, number];
179
219
  readonly document_render: (a: number, b: number, c: number, d: number) => [number, number, number];
220
+ readonly document_renderTask: (a: number, b: number, c: number, d: number) => [number, number, number];
180
221
  readonly document_scan: (a: number, b: number) => [number, number, number];
222
+ readonly document_structureTruncated: (a: number) => [number, number];
181
223
  readonly document_textAndAnnotations: (a: number, b: number) => [number, number, number];
182
224
  readonly pageobjects_imageBoxes: (a: number) => [number, number];
183
225
  readonly pageobjects_imagePixels: (a: number) => [number, number];
@@ -215,7 +257,10 @@ export interface InitOutput {
215
257
  readonly pagetext_wordFirstChar: (a: number) => [number, number];
216
258
  readonly pagetext_wordLastChar: (a: number) => [number, number];
217
259
  readonly renderedpage_takeRgba: (a: number) => [number, number];
260
+ readonly rendertask_finish: (a: number) => number;
261
+ readonly rendertask_step: (a: number, b: number) => number;
218
262
  readonly setAssetLoader: (a: any) => void;
263
+ readonly sha256: (a: number, b: number) => [number, number];
219
264
  readonly __wbindgen_exn_store: (a: number) => void;
220
265
  readonly __externref_table_alloc: () => number;
221
266
  readonly __wbindgen_externrefs: WebAssembly.Table;
package/wasm/recto.wasm CHANGED
Binary file
package/wasm/cmaps.brotli DELETED
Binary file
package/wasm/fonts.bin DELETED
Binary file