@quillmark/wasm 0.66.1 → 0.67.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.
package/README.md CHANGED
@@ -85,6 +85,48 @@ Render with a pre-parsed `Document`.
85
85
  ### `quill.open(parsed)` + `session.render(opts?)`
86
86
  Open once, render all or selected pages (`opts.pages`).
87
87
 
88
+ The session also exposes `pageCount`, `backendId`, `warnings` (snapshot of
89
+ session-level diagnostics attached at `open` time), `pageSize(page)`, and
90
+ `paint(ctx, page, scale)` for canvas previews. See below.
91
+
92
+ ### Canvas Preview (Typst only)
93
+
94
+ `session.paint(ctx, page, scale)` rasterizes a page directly into a
95
+ `CanvasRenderingContext2D`, skipping PNG/SVG byte round-trips. Pair with
96
+ `session.pageSize(page)` to size the canvas:
97
+
98
+ ```ts
99
+ const dpr = window.devicePixelRatio || 1;
100
+ const userZoom = 1; // your zoom UI
101
+ const scale = dpr * userZoom; // multiplier on 72 ppi
102
+
103
+ const { widthPt, heightPt } = session.pageSize(0);
104
+ // Reassigning canvas.width/height clears the backing store, which is what
105
+ // you want between pages. If you reuse the same canvas at the same size
106
+ // (e.g. repaint after a zoom that didn't change scale), call
107
+ // ctx.clearRect(0, 0, canvas.width, canvas.height) before paint instead.
108
+ canvas.width = Math.round(widthPt * scale); // device px
109
+ canvas.height = Math.round(heightPt * scale);
110
+ canvas.style.width = `${widthPt * userZoom}px`;
111
+ canvas.style.height = `${heightPt * userZoom}px`;
112
+
113
+ session.paint(canvas.getContext("2d"), 0, scale);
114
+ ```
115
+
116
+ - `scale` is a multiplier on Typst's natural 72 ppi (1 pt → 1 device
117
+ pixel at `scale = 1`). Always include `devicePixelRatio` for crisp
118
+ output.
119
+ - `pageCount` and `pageSize(page)` are stable for the session's
120
+ lifetime (immutable snapshot) — cache them.
121
+ - Setting `canvas.width` / `canvas.height` clears the backing store; if
122
+ you reuse a canvas without resizing, call `clearRect` before `paint`.
123
+ - Currently main-thread only: `paint` accepts `CanvasRenderingContext2D`,
124
+ not `OffscreenCanvasRenderingContext2D`. Worker support is on the
125
+ follow-up list.
126
+ - Backend support: Typst only. Calling `paint` on a session opened by
127
+ any other backend throws an error that includes the resolved
128
+ `backendId`.
129
+
88
130
  ### Errors
89
131
 
90
132
  Every method that can fail throws a JS `Error` with `.diagnostics` attached:
package/bundler/wasm.d.ts CHANGED
@@ -13,6 +13,19 @@ export interface CardInput {
13
13
  }
14
14
 
15
15
 
16
+
17
+ /**
18
+ * Page dimensions in Typst points (1 pt = 1/72 inch).
19
+ *
20
+ * Returned by `RenderSession.pageSize`. Use these to size a canvas backing
21
+ * store (`widthPt * scale × heightPt * scale`) before calling `paint`.
22
+ */
23
+ export interface PageSize {
24
+ widthPt: number;
25
+ heightPt: number;
26
+ }
27
+
28
+
16
29
  export interface Artifact {
17
30
  format: OutputFormat;
18
31
  bytes: Uint8Array;
@@ -382,14 +395,67 @@ export class RenderSession {
382
395
  private constructor();
383
396
  free(): void;
384
397
  [Symbol.dispose](): void;
398
+ /**
399
+ * Page dimensions in Typst points (1 pt = 1/72 inch).
400
+ *
401
+ * Stable for a given `page` across the session's lifetime — the
402
+ * compiled document is an immutable snapshot, so callers can cache
403
+ * results.
404
+ *
405
+ * Throws if the underlying backend has no canvas painter (i.e. is not
406
+ * the Typst backend) or if `page` is out of range.
407
+ */
408
+ pageSize(page: number): PageSize;
409
+ /**
410
+ * Paint `page` into a 2D canvas context.
411
+ *
412
+ * `scale` multiplies Typst's natural 72 ppi (1 pt → 1 device pixel at
413
+ * `scale = 1`). Typical usage:
414
+ * `scale = (window.devicePixelRatio || 1) * userZoom`.
415
+ *
416
+ * The caller must size `ctx.canvas` so that
417
+ * `canvas.width === round(widthPt * scale)` and `canvas.height ===
418
+ * round(heightPt * scale)` *before* calling `paint`. Setting
419
+ * `canvas.width` / `canvas.height` clears the backing store, which is
420
+ * the recommended way to handle page-to-page transitions; if you
421
+ * reuse a canvas without resizing, call
422
+ * `ctx.clearRect(0, 0, canvas.width, canvas.height)` first to avoid
423
+ * stale pixels showing through transparent regions.
424
+ *
425
+ * `paint` writes into the backing store at origin `(0, 0)` and does
426
+ * not clear outside the rendered region.
427
+ *
428
+ * Throws if the backend does not support canvas preview (the message
429
+ * includes the resolved `backendId` for debugging), or if `page` is
430
+ * out of range.
431
+ */
432
+ paint(ctx: CanvasRenderingContext2D, page: number, scale: number): void;
385
433
  /**
386
434
  * Render all or selected pages from this session.
387
435
  */
388
436
  render(opts?: RenderOptions | null): RenderResult;
437
+ /**
438
+ * The backend that produced this session (e.g. `"typst"`).
439
+ */
440
+ readonly backendId: string;
389
441
  /**
390
442
  * Number of pages in this render session.
443
+ *
444
+ * Stable for the lifetime of the session — the underlying compiled
445
+ * document is an immutable snapshot.
391
446
  */
392
447
  readonly pageCount: number;
448
+ /**
449
+ * Session-level warnings attached at `quill.open(...)` time.
450
+ *
451
+ * Snapshot of any non-fatal diagnostics emitted while opening the
452
+ * session (e.g. version compatibility shims). Stable across the
453
+ * session's lifetime. These are also appended to
454
+ * [`RenderResult.warnings`] on every `render()` call; the accessor
455
+ * surfaces them to canvas-preview consumers that don't go through
456
+ * `render()`.
457
+ */
458
+ readonly warnings: Diagnostic[];
393
459
  }
394
460
 
395
461
  /**
@@ -757,14 +757,104 @@ export class RenderSession {
757
757
  const ptr = this.__destroy_into_raw();
758
758
  wasm.__wbg_rendersession_free(ptr, 0);
759
759
  }
760
+ /**
761
+ * The backend that produced this session (e.g. `"typst"`).
762
+ * @returns {string}
763
+ */
764
+ get backendId() {
765
+ let deferred1_0;
766
+ let deferred1_1;
767
+ try {
768
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
769
+ wasm.rendersession_backendId(retptr, this.__wbg_ptr);
770
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
771
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
772
+ deferred1_0 = r0;
773
+ deferred1_1 = r1;
774
+ return getStringFromWasm0(r0, r1);
775
+ } finally {
776
+ wasm.__wbindgen_add_to_stack_pointer(16);
777
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
778
+ }
779
+ }
760
780
  /**
761
781
  * Number of pages in this render session.
782
+ *
783
+ * Stable for the lifetime of the session — the underlying compiled
784
+ * document is an immutable snapshot.
762
785
  * @returns {number}
763
786
  */
764
787
  get pageCount() {
765
788
  const ret = wasm.rendersession_pageCount(this.__wbg_ptr);
766
789
  return ret >>> 0;
767
790
  }
791
+ /**
792
+ * Page dimensions in Typst points (1 pt = 1/72 inch).
793
+ *
794
+ * Stable for a given `page` across the session's lifetime — the
795
+ * compiled document is an immutable snapshot, so callers can cache
796
+ * results.
797
+ *
798
+ * Throws if the underlying backend has no canvas painter (i.e. is not
799
+ * the Typst backend) or if `page` is out of range.
800
+ * @param {number} page
801
+ * @returns {PageSize}
802
+ */
803
+ pageSize(page) {
804
+ try {
805
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
806
+ wasm.rendersession_pageSize(retptr, this.__wbg_ptr, page);
807
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
808
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
809
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
810
+ if (r2) {
811
+ throw takeObject(r1);
812
+ }
813
+ return takeObject(r0);
814
+ } finally {
815
+ wasm.__wbindgen_add_to_stack_pointer(16);
816
+ }
817
+ }
818
+ /**
819
+ * Paint `page` into a 2D canvas context.
820
+ *
821
+ * `scale` multiplies Typst's natural 72 ppi (1 pt → 1 device pixel at
822
+ * `scale = 1`). Typical usage:
823
+ * `scale = (window.devicePixelRatio || 1) * userZoom`.
824
+ *
825
+ * The caller must size `ctx.canvas` so that
826
+ * `canvas.width === round(widthPt * scale)` and `canvas.height ===
827
+ * round(heightPt * scale)` *before* calling `paint`. Setting
828
+ * `canvas.width` / `canvas.height` clears the backing store, which is
829
+ * the recommended way to handle page-to-page transitions; if you
830
+ * reuse a canvas without resizing, call
831
+ * `ctx.clearRect(0, 0, canvas.width, canvas.height)` first to avoid
832
+ * stale pixels showing through transparent regions.
833
+ *
834
+ * `paint` writes into the backing store at origin `(0, 0)` and does
835
+ * not clear outside the rendered region.
836
+ *
837
+ * Throws if the backend does not support canvas preview (the message
838
+ * includes the resolved `backendId` for debugging), or if `page` is
839
+ * out of range.
840
+ * @param {CanvasRenderingContext2D} ctx
841
+ * @param {number} page
842
+ * @param {number} scale
843
+ */
844
+ paint(ctx, page, scale) {
845
+ try {
846
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
847
+ wasm.rendersession_paint(retptr, this.__wbg_ptr, addBorrowedObject(ctx), page, scale);
848
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
849
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
850
+ if (r1) {
851
+ throw takeObject(r0);
852
+ }
853
+ } finally {
854
+ wasm.__wbindgen_add_to_stack_pointer(16);
855
+ heap[stack_pointer++] = undefined;
856
+ }
857
+ }
768
858
  /**
769
859
  * Render all or selected pages from this session.
770
860
  * @param {RenderOptions | null} [opts]
@@ -785,6 +875,21 @@ export class RenderSession {
785
875
  wasm.__wbindgen_add_to_stack_pointer(16);
786
876
  }
787
877
  }
878
+ /**
879
+ * Session-level warnings attached at `quill.open(...)` time.
880
+ *
881
+ * Snapshot of any non-fatal diagnostics emitted while opening the
882
+ * session (e.g. version compatibility shims). Stable across the
883
+ * session's lifetime. These are also appended to
884
+ * [`RenderResult.warnings`] on every `render()` call; the accessor
885
+ * surfaces them to canvas-preview consumers that don't go through
886
+ * `render()`.
887
+ * @returns {Diagnostic[]}
888
+ */
889
+ get warnings() {
890
+ const ret = wasm.rendersession_warnings(this.__wbg_ptr);
891
+ return takeObject(ret);
892
+ }
788
893
  }
789
894
  if (Symbol.dispose) RenderSession.prototype[Symbol.dispose] = RenderSession.prototype.free;
790
895
 
@@ -1040,6 +1145,10 @@ export function __wbg_new_aa8d0fa9762c29bd() {
1040
1145
  const ret = new Object();
1041
1146
  return addHeapObject(ret);
1042
1147
  }
1148
+ export function __wbg_new_with_u8_clamped_array_and_sh_fe957411824b5158() { return handleError(function (arg0, arg1, arg2, arg3) {
1149
+ const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
1150
+ return addHeapObject(ret);
1151
+ }, arguments); }
1043
1152
  export function __wbg_next_0340c4ae324393c3() { return handleError(function (arg0) {
1044
1153
  const ret = getObject(arg0).next();
1045
1154
  return addHeapObject(ret);
@@ -1055,6 +1164,9 @@ export function __wbg_now_a9b7df1cbee90986() {
1055
1164
  export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
1056
1165
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
1057
1166
  }
1167
+ export function __wbg_putImageData_c810e62ea70e761d() { return handleError(function (arg0, arg1, arg2, arg3) {
1168
+ getObject(arg0).putImageData(getObject(arg1), arg2, arg3);
1169
+ }, arguments); }
1058
1170
  export function __wbg_set_022bee52d0b05b19() { return handleError(function (arg0, arg1, arg2) {
1059
1171
  const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1060
1172
  return ret;
@@ -1143,6 +1255,12 @@ function _assertClass(instance, klass) {
1143
1255
  }
1144
1256
  }
1145
1257
 
1258
+ function addBorrowedObject(obj) {
1259
+ if (stack_pointer == 1) throw new Error('out of js stack');
1260
+ heap[--stack_pointer] = obj;
1261
+ return stack_pointer;
1262
+ }
1263
+
1146
1264
  function debugString(val) {
1147
1265
  // primitive types
1148
1266
  const type = typeof val;
@@ -1219,6 +1337,11 @@ function getArrayU8FromWasm0(ptr, len) {
1219
1337
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1220
1338
  }
1221
1339
 
1340
+ function getClampedArrayU8FromWasm0(ptr, len) {
1341
+ ptr = ptr >>> 0;
1342
+ return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1343
+ }
1344
+
1222
1345
  let cachedDataViewMemory0 = null;
1223
1346
  function getDataViewMemory0() {
1224
1347
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -1240,6 +1363,14 @@ function getUint8ArrayMemory0() {
1240
1363
  return cachedUint8ArrayMemory0;
1241
1364
  }
1242
1365
 
1366
+ let cachedUint8ClampedArrayMemory0 = null;
1367
+ function getUint8ClampedArrayMemory0() {
1368
+ if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) {
1369
+ cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
1370
+ }
1371
+ return cachedUint8ClampedArrayMemory0;
1372
+ }
1373
+
1243
1374
  function getObject(idx) { return heap[idx]; }
1244
1375
 
1245
1376
  function handleError(f, args) {
@@ -1296,6 +1427,8 @@ function passStringToWasm0(arg, malloc, realloc) {
1296
1427
  return ptr;
1297
1428
  }
1298
1429
 
1430
+ let stack_pointer = 1024;
1431
+
1299
1432
  function takeObject(idx) {
1300
1433
  const ret = getObject(idx);
1301
1434
  dropObject(idx);
Binary file
@@ -37,8 +37,12 @@ export const quill_open: (a: number, b: number, c: number) => void;
37
37
  export const quill_render: (a: number, b: number, c: number, d: number) => void;
38
38
  export const quillmark_new: () => number;
39
39
  export const quillmark_quill: (a: number, b: number, c: number) => void;
40
+ export const rendersession_backendId: (a: number, b: number) => void;
40
41
  export const rendersession_pageCount: (a: number) => number;
42
+ export const rendersession_pageSize: (a: number, b: number, c: number) => void;
43
+ export const rendersession_paint: (a: number, b: number, c: number, d: number, e: number) => void;
41
44
  export const rendersession_render: (a: number, b: number, c: number) => void;
45
+ export const rendersession_warnings: (a: number) => number;
42
46
  export const lut_inverse_interp16: (a: number, b: number, c: number) => number;
43
47
  export const qcms_profile_precache_output_transform: (a: number) => void;
44
48
  export const qcms_white_point_sRGB: (a: number) => void;
@@ -13,6 +13,19 @@ export interface CardInput {
13
13
  }
14
14
 
15
15
 
16
+
17
+ /**
18
+ * Page dimensions in Typst points (1 pt = 1/72 inch).
19
+ *
20
+ * Returned by `RenderSession.pageSize`. Use these to size a canvas backing
21
+ * store (`widthPt * scale × heightPt * scale`) before calling `paint`.
22
+ */
23
+ export interface PageSize {
24
+ widthPt: number;
25
+ heightPt: number;
26
+ }
27
+
28
+
16
29
  export interface Artifact {
17
30
  format: OutputFormat;
18
31
  bytes: Uint8Array;
@@ -382,14 +395,67 @@ export class RenderSession {
382
395
  private constructor();
383
396
  free(): void;
384
397
  [Symbol.dispose](): void;
398
+ /**
399
+ * Page dimensions in Typst points (1 pt = 1/72 inch).
400
+ *
401
+ * Stable for a given `page` across the session's lifetime — the
402
+ * compiled document is an immutable snapshot, so callers can cache
403
+ * results.
404
+ *
405
+ * Throws if the underlying backend has no canvas painter (i.e. is not
406
+ * the Typst backend) or if `page` is out of range.
407
+ */
408
+ pageSize(page: number): PageSize;
409
+ /**
410
+ * Paint `page` into a 2D canvas context.
411
+ *
412
+ * `scale` multiplies Typst's natural 72 ppi (1 pt → 1 device pixel at
413
+ * `scale = 1`). Typical usage:
414
+ * `scale = (window.devicePixelRatio || 1) * userZoom`.
415
+ *
416
+ * The caller must size `ctx.canvas` so that
417
+ * `canvas.width === round(widthPt * scale)` and `canvas.height ===
418
+ * round(heightPt * scale)` *before* calling `paint`. Setting
419
+ * `canvas.width` / `canvas.height` clears the backing store, which is
420
+ * the recommended way to handle page-to-page transitions; if you
421
+ * reuse a canvas without resizing, call
422
+ * `ctx.clearRect(0, 0, canvas.width, canvas.height)` first to avoid
423
+ * stale pixels showing through transparent regions.
424
+ *
425
+ * `paint` writes into the backing store at origin `(0, 0)` and does
426
+ * not clear outside the rendered region.
427
+ *
428
+ * Throws if the backend does not support canvas preview (the message
429
+ * includes the resolved `backendId` for debugging), or if `page` is
430
+ * out of range.
431
+ */
432
+ paint(ctx: CanvasRenderingContext2D, page: number, scale: number): void;
385
433
  /**
386
434
  * Render all or selected pages from this session.
387
435
  */
388
436
  render(opts?: RenderOptions | null): RenderResult;
437
+ /**
438
+ * The backend that produced this session (e.g. `"typst"`).
439
+ */
440
+ readonly backendId: string;
389
441
  /**
390
442
  * Number of pages in this render session.
443
+ *
444
+ * Stable for the lifetime of the session — the underlying compiled
445
+ * document is an immutable snapshot.
391
446
  */
392
447
  readonly pageCount: number;
448
+ /**
449
+ * Session-level warnings attached at `quill.open(...)` time.
450
+ *
451
+ * Snapshot of any non-fatal diagnostics emitted while opening the
452
+ * session (e.g. version compatibility shims). Stable across the
453
+ * session's lifetime. These are also appended to
454
+ * [`RenderResult.warnings`] on every `render()` call; the accessor
455
+ * surfaces them to canvas-preview consumers that don't go through
456
+ * `render()`.
457
+ */
458
+ readonly warnings: Diagnostic[];
393
459
  }
394
460
 
395
461
  /**
package/node-esm/wasm.js CHANGED
@@ -761,14 +761,104 @@ export class RenderSession {
761
761
  const ptr = this.__destroy_into_raw();
762
762
  wasm.__wbg_rendersession_free(ptr, 0);
763
763
  }
764
+ /**
765
+ * The backend that produced this session (e.g. `"typst"`).
766
+ * @returns {string}
767
+ */
768
+ get backendId() {
769
+ let deferred1_0;
770
+ let deferred1_1;
771
+ try {
772
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
773
+ wasm.rendersession_backendId(retptr, this.__wbg_ptr);
774
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
775
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
776
+ deferred1_0 = r0;
777
+ deferred1_1 = r1;
778
+ return getStringFromWasm0(r0, r1);
779
+ } finally {
780
+ wasm.__wbindgen_add_to_stack_pointer(16);
781
+ wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
782
+ }
783
+ }
764
784
  /**
765
785
  * Number of pages in this render session.
786
+ *
787
+ * Stable for the lifetime of the session — the underlying compiled
788
+ * document is an immutable snapshot.
766
789
  * @returns {number}
767
790
  */
768
791
  get pageCount() {
769
792
  const ret = wasm.rendersession_pageCount(this.__wbg_ptr);
770
793
  return ret >>> 0;
771
794
  }
795
+ /**
796
+ * Page dimensions in Typst points (1 pt = 1/72 inch).
797
+ *
798
+ * Stable for a given `page` across the session's lifetime — the
799
+ * compiled document is an immutable snapshot, so callers can cache
800
+ * results.
801
+ *
802
+ * Throws if the underlying backend has no canvas painter (i.e. is not
803
+ * the Typst backend) or if `page` is out of range.
804
+ * @param {number} page
805
+ * @returns {PageSize}
806
+ */
807
+ pageSize(page) {
808
+ try {
809
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
810
+ wasm.rendersession_pageSize(retptr, this.__wbg_ptr, page);
811
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
812
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
813
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
814
+ if (r2) {
815
+ throw takeObject(r1);
816
+ }
817
+ return takeObject(r0);
818
+ } finally {
819
+ wasm.__wbindgen_add_to_stack_pointer(16);
820
+ }
821
+ }
822
+ /**
823
+ * Paint `page` into a 2D canvas context.
824
+ *
825
+ * `scale` multiplies Typst's natural 72 ppi (1 pt → 1 device pixel at
826
+ * `scale = 1`). Typical usage:
827
+ * `scale = (window.devicePixelRatio || 1) * userZoom`.
828
+ *
829
+ * The caller must size `ctx.canvas` so that
830
+ * `canvas.width === round(widthPt * scale)` and `canvas.height ===
831
+ * round(heightPt * scale)` *before* calling `paint`. Setting
832
+ * `canvas.width` / `canvas.height` clears the backing store, which is
833
+ * the recommended way to handle page-to-page transitions; if you
834
+ * reuse a canvas without resizing, call
835
+ * `ctx.clearRect(0, 0, canvas.width, canvas.height)` first to avoid
836
+ * stale pixels showing through transparent regions.
837
+ *
838
+ * `paint` writes into the backing store at origin `(0, 0)` and does
839
+ * not clear outside the rendered region.
840
+ *
841
+ * Throws if the backend does not support canvas preview (the message
842
+ * includes the resolved `backendId` for debugging), or if `page` is
843
+ * out of range.
844
+ * @param {CanvasRenderingContext2D} ctx
845
+ * @param {number} page
846
+ * @param {number} scale
847
+ */
848
+ paint(ctx, page, scale) {
849
+ try {
850
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
851
+ wasm.rendersession_paint(retptr, this.__wbg_ptr, addBorrowedObject(ctx), page, scale);
852
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
853
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
854
+ if (r1) {
855
+ throw takeObject(r0);
856
+ }
857
+ } finally {
858
+ wasm.__wbindgen_add_to_stack_pointer(16);
859
+ heap[stack_pointer++] = undefined;
860
+ }
861
+ }
772
862
  /**
773
863
  * Render all or selected pages from this session.
774
864
  * @param {RenderOptions | null} [opts]
@@ -789,6 +879,21 @@ export class RenderSession {
789
879
  wasm.__wbindgen_add_to_stack_pointer(16);
790
880
  }
791
881
  }
882
+ /**
883
+ * Session-level warnings attached at `quill.open(...)` time.
884
+ *
885
+ * Snapshot of any non-fatal diagnostics emitted while opening the
886
+ * session (e.g. version compatibility shims). Stable across the
887
+ * session's lifetime. These are also appended to
888
+ * [`RenderResult.warnings`] on every `render()` call; the accessor
889
+ * surfaces them to canvas-preview consumers that don't go through
890
+ * `render()`.
891
+ * @returns {Diagnostic[]}
892
+ */
893
+ get warnings() {
894
+ const ret = wasm.rendersession_warnings(this.__wbg_ptr);
895
+ return takeObject(ret);
896
+ }
792
897
  }
793
898
  if (Symbol.dispose) RenderSession.prototype[Symbol.dispose] = RenderSession.prototype.free;
794
899
 
@@ -1047,6 +1152,10 @@ function __wbg_get_imports() {
1047
1152
  const ret = new Object();
1048
1153
  return addHeapObject(ret);
1049
1154
  },
1155
+ __wbg_new_with_u8_clamped_array_and_sh_fe957411824b5158: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1156
+ const ret = new ImageData(getClampedArrayU8FromWasm0(arg0, arg1), arg2 >>> 0, arg3 >>> 0);
1157
+ return addHeapObject(ret);
1158
+ }, arguments); },
1050
1159
  __wbg_next_0340c4ae324393c3: function() { return handleError(function (arg0) {
1051
1160
  const ret = getObject(arg0).next();
1052
1161
  return addHeapObject(ret);
@@ -1062,6 +1171,9 @@ function __wbg_get_imports() {
1062
1171
  __wbg_prototypesetcall_a6b02eb00b0f4ce2: function(arg0, arg1, arg2) {
1063
1172
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
1064
1173
  },
1174
+ __wbg_putImageData_c810e62ea70e761d: function() { return handleError(function (arg0, arg1, arg2, arg3) {
1175
+ getObject(arg0).putImageData(getObject(arg1), arg2, arg3);
1176
+ }, arguments); },
1065
1177
  __wbg_set_022bee52d0b05b19: function() { return handleError(function (arg0, arg1, arg2) {
1066
1178
  const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1067
1179
  return ret;
@@ -1157,6 +1269,12 @@ function _assertClass(instance, klass) {
1157
1269
  }
1158
1270
  }
1159
1271
 
1272
+ function addBorrowedObject(obj) {
1273
+ if (stack_pointer == 1) throw new Error('out of js stack');
1274
+ heap[--stack_pointer] = obj;
1275
+ return stack_pointer;
1276
+ }
1277
+
1160
1278
  function debugString(val) {
1161
1279
  // primitive types
1162
1280
  const type = typeof val;
@@ -1233,6 +1351,11 @@ function getArrayU8FromWasm0(ptr, len) {
1233
1351
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1234
1352
  }
1235
1353
 
1354
+ function getClampedArrayU8FromWasm0(ptr, len) {
1355
+ ptr = ptr >>> 0;
1356
+ return getUint8ClampedArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
1357
+ }
1358
+
1236
1359
  let cachedDataViewMemory0 = null;
1237
1360
  function getDataViewMemory0() {
1238
1361
  if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
@@ -1254,6 +1377,14 @@ function getUint8ArrayMemory0() {
1254
1377
  return cachedUint8ArrayMemory0;
1255
1378
  }
1256
1379
 
1380
+ let cachedUint8ClampedArrayMemory0 = null;
1381
+ function getUint8ClampedArrayMemory0() {
1382
+ if (cachedUint8ClampedArrayMemory0 === null || cachedUint8ClampedArrayMemory0.byteLength === 0) {
1383
+ cachedUint8ClampedArrayMemory0 = new Uint8ClampedArray(wasm.memory.buffer);
1384
+ }
1385
+ return cachedUint8ClampedArrayMemory0;
1386
+ }
1387
+
1257
1388
  function getObject(idx) { return heap[idx]; }
1258
1389
 
1259
1390
  function handleError(f, args) {
@@ -1310,6 +1441,8 @@ function passStringToWasm0(arg, malloc, realloc) {
1310
1441
  return ptr;
1311
1442
  }
1312
1443
 
1444
+ let stack_pointer = 1024;
1445
+
1313
1446
  function takeObject(idx) {
1314
1447
  const ret = getObject(idx);
1315
1448
  dropObject(idx);
Binary file
@@ -37,8 +37,12 @@ export const quill_open: (a: number, b: number, c: number) => void;
37
37
  export const quill_render: (a: number, b: number, c: number, d: number) => void;
38
38
  export const quillmark_new: () => number;
39
39
  export const quillmark_quill: (a: number, b: number, c: number) => void;
40
+ export const rendersession_backendId: (a: number, b: number) => void;
40
41
  export const rendersession_pageCount: (a: number) => number;
42
+ export const rendersession_pageSize: (a: number, b: number, c: number) => void;
43
+ export const rendersession_paint: (a: number, b: number, c: number, d: number, e: number) => void;
41
44
  export const rendersession_render: (a: number, b: number, c: number) => void;
45
+ export const rendersession_warnings: (a: number) => number;
42
46
  export const lut_inverse_interp16: (a: number, b: number, c: number) => number;
43
47
  export const qcms_profile_precache_output_transform: (a: number) => void;
44
48
  export const qcms_white_point_sRGB: (a: number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillmark/wasm",
3
- "version": "0.66.1",
3
+ "version": "0.67.0",
4
4
  "description": "WebAssembly bindings for quillmark",
5
5
  "type": "module",
6
6
  "license": "MIT OR Apache-2.0",