@laminapdf/wasm 0.2.0-alpha.6 → 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
  *
@@ -273,6 +292,22 @@ export class WasmDocument {
273
292
  ret = wasm.wasmdocument_isEncrypted(this.__wbg_ptr);
274
293
  return ret !== 0;
275
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
+ }
276
311
  /**
277
312
  * Opens a document from its bytes.
278
313
  *
@@ -393,6 +428,22 @@ export class WasmDocument {
393
428
  }
394
429
  return WasmPage.__wrap(ret[0]);
395
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
+ }
396
447
  /**
397
448
  * Rebases onto `bytes`, the output of a save whose rebase failed (`not-rebased`).
398
449
  *
@@ -425,6 +476,23 @@ export class WasmDocument {
425
476
  }
426
477
  return takeFromExternrefTable0(ret[0]);
427
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
+ }
428
496
  /**
429
497
  * A save as a job, stepped with a budget of work units (ADR 0028 §3, §4).
430
498
  *
@@ -482,6 +550,22 @@ export class WasmDocument {
482
550
  ret = wasm.wasmdocument_warnings(this.__wbg_ptr);
483
551
  return WasmWarningCursor.__wrap(ret);
484
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
+ }
485
569
  }
486
570
  if (Symbol.dispose) WasmDocument.prototype[Symbol.dispose] = WasmDocument.prototype.free;
487
571
 
Binary file