@laminapdf/wasm 0.2.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.
@@ -205,6 +205,29 @@ export class WasmDocument {
205
205
  wasm.__wbg_wasmdocument_free(ptr, 0);
206
206
 
207
207
  }
208
+ /**
209
+ * Adds another PDF as a source document: `{ id, pages }`, its ID (64 hex digits, the
210
+ * SHA-256 of `bytes`) and its page IDs in order. An encrypted one opens with `password`,
211
+ * which no op ever holds.
212
+ *
213
+ * # Errors
214
+ * `wrong-password`, `password-required`, and the errors of a file that doesn't open.
215
+ * @param {Uint8Array} bytes
216
+ * @param {string | null} [password]
217
+ * @returns {{ id: string; pages: string[] }}
218
+ */
219
+ addSource(bytes, password) {
220
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
221
+ const len0 = WASM_VECTOR_LEN;
222
+ var ptr1 = isLikeNone(password) ? 0 : passStringToWasm0(password, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
223
+ var len1 = WASM_VECTOR_LEN;
224
+ let ret;
225
+ ret = wasm.wasmdocument_addSource(this.__wbg_ptr, ptr0, len0, ptr1, len1);
226
+ if (ret[2]) {
227
+ throw takeFromExternrefTable0(ret[1]);
228
+ }
229
+ return takeFromExternrefTable0(ret[0]);
230
+ }
208
231
  /**
209
232
  * Makes `bytes`, the whole output of `saveCopy`, the document's saved file (it rebases onto
210
233
  * them), once they are written where the document lives; `historyCleared` is the copy's
@@ -259,6 +282,23 @@ export class WasmDocument {
259
282
  }
260
283
  return takeFromExternrefTable0(ret[0]);
261
284
  }
285
+ /**
286
+ * A new document of `pages` of this one, in the order given.
287
+ *
288
+ * # Errors
289
+ * `invalid-argument` for a value that isn't a list of page IDs, `unknown-page`; reading
290
+ * errors.
291
+ * @param {string[]} pages
292
+ * @returns {WasmDocument}
293
+ */
294
+ extractPages(pages) {
295
+ let ret;
296
+ ret = wasm.wasmdocument_extractPages(this.__wbg_ptr, pages);
297
+ if (ret[2]) {
298
+ throw takeFromExternrefTable0(ret[1]);
299
+ }
300
+ return WasmDocument.__wrap(ret[0]);
301
+ }
262
302
  /**
263
303
  * Whether there are changes no save has written yet.
264
304
  * @returns {boolean}
@@ -292,6 +332,26 @@ export class WasmDocument {
292
332
  ret = wasm.wasmdocument_isEncrypted(this.__wbg_ptr);
293
333
  return ret !== 0;
294
334
  }
335
+ /**
336
+ * A new document of `inputs` (each `{ bytes, password?, title? }`) one after another,
337
+ * with their bookmarks, named destinations, form fields, layers and page labels; `options`
338
+ * as `mergeDocuments`' (`outline`, `fields`).
339
+ *
340
+ * # Errors
341
+ * `invalid-argument` / `unknown-option` for bad values, `wrong-password`,
342
+ * `password-required`, and the errors of a file that doesn't open.
343
+ * @param {{ bytes: Uint8Array; password?: string; title?: string }[]} inputs
344
+ * @param {MergeOptions | undefined} options
345
+ * @returns {WasmDocument}
346
+ */
347
+ static merge(inputs, options) {
348
+ let ret;
349
+ ret = wasm.wasmdocument_merge(inputs, options);
350
+ if (ret[2]) {
351
+ throw takeFromExternrefTable0(ret[1]);
352
+ }
353
+ return WasmDocument.__wrap(ret[0]);
354
+ }
295
355
  /**
296
356
  * The document's metadata, read from Info and XMP together, with the fields where they
297
357
  * disagree.
@@ -525,6 +585,26 @@ export class WasmDocument {
525
585
  }
526
586
  return takeFromExternrefTable0(ret[0]);
527
587
  }
588
+ /**
589
+ * This document cut into new ones: `{ count: n }` parts of `n` pages, `{ ranges: [[id, …],
590
+ * …] }` one part per list of page IDs, or `{ bookmarks: level }` a part from each bookmark
591
+ * at that depth (1: the top level). Each part carries what its pages reach and the
592
+ * bookmarks that go to them.
593
+ *
594
+ * # Errors
595
+ * `invalid-argument` / `unknown-option` for a value that isn't one of those, `unknown-page`,
596
+ * `no-pages-left` for an empty list; reading errors.
597
+ * @param {{ readonly count: number } | { readonly ranges: readonly (readonly string[])[] } | { readonly bookmarks: number }} by
598
+ * @returns {WasmDocument[]}
599
+ */
600
+ split(by) {
601
+ let ret;
602
+ ret = wasm.wasmdocument_split(this.__wbg_ptr, by);
603
+ if (ret[2]) {
604
+ throw takeFromExternrefTable0(ret[1]);
605
+ }
606
+ return takeFromExternrefTable0(ret[0]);
607
+ }
528
608
  /**
529
609
  * Undoes the newest transaction: how it went and the pages it touched; `undefined` when
530
610
  * there is nothing to undo.
@@ -566,6 +646,21 @@ export class WasmDocument {
566
646
  }
567
647
  return takeFromExternrefTable0(ret[0]);
568
648
  }
649
+ /**
650
+ * The document's XMP packet as text, with the edits made so far.
651
+ *
652
+ * # Errors
653
+ * Reading errors.
654
+ * @returns {XmpTextJs}
655
+ */
656
+ xmpPacket() {
657
+ let ret;
658
+ ret = wasm.wasmdocument_xmpPacket(this.__wbg_ptr);
659
+ if (ret[2]) {
660
+ throw takeFromExternrefTable0(ret[1]);
661
+ }
662
+ return takeFromExternrefTable0(ret[0]);
663
+ }
569
664
  }
570
665
  if (Symbol.dispose) WasmDocument.prototype[Symbol.dispose] = WasmDocument.prototype.free;
571
666
 
@@ -1447,14 +1542,48 @@ function __wbg_get_imports() {
1447
1542
  __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
1448
1543
  throw new Error(getStringFromWasm0(arg0, arg1));
1449
1544
  },
1545
+ __wbg_get_31af05bd4842a84f: function() { return handleError(function (arg0, arg1) {
1546
+ const ret = Reflect.get(arg0, arg1);
1547
+ return ret;
1548
+ }, arguments); },
1549
+ __wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
1550
+ const ret = arg0[arg1 >>> 0];
1551
+ return ret;
1552
+ },
1553
+ __wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
1554
+ let result;
1555
+ try {
1556
+ result = arg0 instanceof Uint8Array;
1557
+ } catch (_) {
1558
+ result = false;
1559
+ }
1560
+ const ret = result;
1561
+ return ret;
1562
+ },
1563
+ __wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
1564
+ const ret = Array.isArray(arg0);
1565
+ return ret;
1566
+ },
1450
1567
  __wbg_keys_440be172f17c0265: function(arg0) {
1451
1568
  const ret = Object.keys(arg0);
1452
1569
  return ret;
1453
1570
  },
1571
+ __wbg_length_7f3c00c40364105e: function(arg0) {
1572
+ const ret = arg0.length;
1573
+ return ret;
1574
+ },
1575
+ __wbg_length_d4bdea10311bd9cf: function(arg0) {
1576
+ const ret = arg0.length;
1577
+ return ret;
1578
+ },
1454
1579
  __wbg_new_617a8cdb8bb1130e: function() {
1455
1580
  const ret = new Object();
1456
1581
  return ret;
1457
1582
  },
1583
+ __wbg_new_ee2291f50781bf1d: function() {
1584
+ const ret = new Array();
1585
+ return ret;
1586
+ },
1458
1587
  __wbg_new_from_slice_9a868026ffa4208a: function(arg0, arg1) {
1459
1588
  const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
1460
1589
  return ret;
@@ -1467,6 +1596,13 @@ function __wbg_get_imports() {
1467
1596
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
1468
1597
  return ret;
1469
1598
  }, arguments); },
1599
+ __wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
1600
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
1601
+ },
1602
+ __wbg_push_2baf45db356cf468: function(arg0, arg1) {
1603
+ const ret = arg0.push(arg1);
1604
+ return ret;
1605
+ },
1470
1606
  __wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
1471
1607
  const ret = Reflect.set(arg0, arg1, arg2);
1472
1608
  return ret;
@@ -1482,6 +1618,10 @@ function __wbg_get_imports() {
1482
1618
  const ret = JSON.stringify(arg0);
1483
1619
  return ret;
1484
1620
  }, arguments); },
1621
+ __wbg_wasmdocument_new: function(arg0) {
1622
+ const ret = WasmDocument.__wrap(arg0);
1623
+ return ret;
1624
+ },
1485
1625
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
1486
1626
  // Cast intrinsic for `Ref(String) -> Externref`.
1487
1627
  const ret = getStringFromWasm0(arg0, arg1);
Binary file