@laminapdf/wasm 0.2.0-alpha.5 → 0.2.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,25 @@ export class WasmDocument {
205
205
  wasm.__wbg_wasmdocument_free(ptr, 0);
206
206
 
207
207
  }
208
+ /**
209
+ * Makes `bytes`, the whole output of `saveCopy`, the document's saved file (it rebases onto
210
+ * them), once they are written where the document lives; `historyCleared` is the copy's
211
+ * report's.
212
+ *
213
+ * # Errors
214
+ * `nested-transaction`, `saved-not-rebased`; `not-rebased` when `bytes` can't be read.
215
+ * @param {Uint8Array} bytes
216
+ * @param {boolean} historyCleared
217
+ */
218
+ adoptCopy(bytes, historyCleared) {
219
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
220
+ const len0 = WASM_VECTOR_LEN;
221
+ let ret;
222
+ ret = wasm.wasmdocument_adoptCopy(this.__wbg_ptr, ptr0, len0, historyCleared);
223
+ if (ret[1]) {
224
+ throw takeFromExternrefTable0(ret[0]);
225
+ }
226
+ }
208
227
  /**
209
228
  * Applies an op log (`{ "v": 1, "ops": [ … ] }`) as one transaction.
210
229
  *
@@ -264,6 +283,31 @@ export class WasmDocument {
264
283
  }
265
284
  return takeFromExternrefTable0(ret[0]);
266
285
  }
286
+ /**
287
+ * Whether the file is encrypted (it opened with its password, or the empty one).
288
+ * @returns {boolean}
289
+ */
290
+ isEncrypted() {
291
+ let ret;
292
+ ret = wasm.wasmdocument_isEncrypted(this.__wbg_ptr);
293
+ return ret !== 0;
294
+ }
295
+ /**
296
+ * The document's metadata, read from Info and XMP together, with the fields where they
297
+ * disagree.
298
+ *
299
+ * # Errors
300
+ * Reading errors.
301
+ * @returns {DocumentMetadata}
302
+ */
303
+ metadata() {
304
+ let ret;
305
+ ret = wasm.wasmdocument_metadata(this.__wbg_ptr);
306
+ if (ret[2]) {
307
+ throw takeFromExternrefTable0(ret[1]);
308
+ }
309
+ return takeFromExternrefTable0(ret[0]);
310
+ }
267
311
  /**
268
312
  * Opens a document from its bytes.
269
313
  *
@@ -384,6 +428,22 @@ export class WasmDocument {
384
428
  }
385
429
  return WasmPage.__wrap(ret[0]);
386
430
  }
431
+ /**
432
+ * How a save with `options` would go, without saving.
433
+ *
434
+ * # Errors
435
+ * `invalid-argument` / `unknown-option` for bad options; reading errors.
436
+ * @param {SaveOptionsInit | undefined} options
437
+ * @returns {PlannedSaveJs}
438
+ */
439
+ plan(options) {
440
+ let ret;
441
+ ret = wasm.wasmdocument_plan(this.__wbg_ptr, options);
442
+ if (ret[2]) {
443
+ throw takeFromExternrefTable0(ret[1]);
444
+ }
445
+ return takeFromExternrefTable0(ret[0]);
446
+ }
387
447
  /**
388
448
  * Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
389
449
  *
@@ -401,11 +461,12 @@ export class WasmDocument {
401
461
  }
402
462
  }
403
463
  /**
404
- * Redoes the newest undone transaction; `undefined` when there is nothing to redo.
464
+ * Redoes the newest undone transaction: how it went and the pages it touched; `undefined`
465
+ * when there is nothing to redo.
405
466
  *
406
467
  * # Errors
407
468
  * As [`WasmDocument::undo`].
408
- * @returns {UndoOutcomeJs | undefined}
469
+ * @returns {RevertedJs | undefined}
409
470
  */
410
471
  redo() {
411
472
  let ret;
@@ -415,6 +476,23 @@ export class WasmDocument {
415
476
  }
416
477
  return takeFromExternrefTable0(ret[0]);
417
478
  }
479
+ /**
480
+ * Writes what `save` would and leaves the document as it was: not rebased, its changes
481
+ * still unsaved, the save-time stamp in the copy only (Save a copy).
482
+ *
483
+ * # Errors
484
+ * As `save`; the document is unchanged either way.
485
+ * @param {SaveOptionsInit | undefined} options
486
+ * @returns {{ bytes: Uint8Array<ArrayBuffer>; report: SaveReportJs }}
487
+ */
488
+ saveCopy(options) {
489
+ let ret;
490
+ ret = wasm.wasmdocument_saveCopy(this.__wbg_ptr, options);
491
+ if (ret[2]) {
492
+ throw takeFromExternrefTable0(ret[1]);
493
+ }
494
+ return takeFromExternrefTable0(ret[0]);
495
+ }
418
496
  /**
419
497
  * A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
420
498
  *
@@ -448,11 +526,12 @@ export class WasmDocument {
448
526
  return takeFromExternrefTable0(ret[0]);
449
527
  }
450
528
  /**
451
- * Undoes the newest transaction; `undefined` when there is nothing to undo.
529
+ * Undoes the newest transaction: how it went and the pages it touched; `undefined` when
530
+ * there is nothing to undo.
452
531
  *
453
532
  * # Errors
454
533
  * `nested-transaction`, `saved-not-rebased`; reading errors.
455
- * @returns {UndoOutcomeJs | undefined}
534
+ * @returns {RevertedJs | undefined}
456
535
  */
457
536
  undo() {
458
537
  let ret;
@@ -471,6 +550,22 @@ export class WasmDocument {
471
550
  ret = wasm.wasmdocument_warnings(this.__wbg_ptr);
472
551
  return WasmWarningCursor.__wrap(ret);
473
552
  }
553
+ /**
554
+ * The signature restrictions `op` would break if it were applied and saved.
555
+ *
556
+ * # Errors
557
+ * `invalid-argument` for a value that isn't an op; reading errors.
558
+ * @param {Op} op
559
+ * @returns {ViolationJs[]}
560
+ */
561
+ wouldViolate(op) {
562
+ let ret;
563
+ ret = wasm.wasmdocument_wouldViolate(this.__wbg_ptr, op);
564
+ if (ret[2]) {
565
+ throw takeFromExternrefTable0(ret[1]);
566
+ }
567
+ return takeFromExternrefTable0(ret[0]);
568
+ }
474
569
  }
475
570
  if (Symbol.dispose) WasmDocument.prototype[Symbol.dispose] = WasmDocument.prototype.free;
476
571
 
Binary file