Skip to content

Commit 39a2053

Browse files
committedNov 8, 2024
chore: renaming toBytes to toUnit8Array
1 parent b9d157f commit 39a2053

File tree

11 files changed

+15
-109
lines changed

11 files changed

+15
-109
lines changed
 

‎examples/sample-pdf-viewer/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async function run() {
4949
bitmap.fill(0, 0, width, height);
5050
page.render(bitmap, 0, 0, width, height, 0, flags);
5151

52-
const data = bitmap.toBytes();
52+
const data = bitmap.toUint8Array();
5353

5454
bitmap.close();
5555
page.close();
@@ -59,6 +59,8 @@ async function run() {
5959
const canvas = document.getElementById('canvas') as HTMLCanvasElement;
6060
const ctx = canvas!.getContext('2d');
6161
ctx!.putImageData(imageData, 0, 0);
62+
63+
viewer.dispose();
6264
}
6365

6466
run();

‎examples/sample-wasm-bindgen/Cargo.toml

-14
This file was deleted.

‎examples/sample-wasm-bindgen/index.html

-18
This file was deleted.

‎examples/sample-wasm-bindgen/index.ts

-49
This file was deleted.

‎examples/sample-wasm-bindgen/package.json

-16
This file was deleted.

‎examples/sample-wasm-bindgen/src/lib.rs

-9
This file was deleted.

‎examples/sample/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ async function run() {
115115
const canvas = document.getElementById('canvas') as HTMLCanvasElement;
116116
const ctx = canvas!.getContext('2d');
117117
ctx!.putImageData(imageData, 0, 0);
118+
119+
wasmExports.FPDF_DestroyLibrary();
118120
}
119121

120122
run();

‎packages/pdf-viewer/__tests__/lorem-ipsum.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,6 @@ test('pdf lorem ipsum', async () => {
6969

7070
doc.close();
7171
expect(doc.pointer).toBe(0);
72+
73+
viewer.dispose();
7274
});

‎packages/pdf-viewer/__tests__/minimal.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,6 @@ test('pdf minimal', async () => {
6969

7070
doc.close();
7171
expect(doc.pointer).toBe(0);
72+
73+
viewer.dispose();
7274
});

‎packages/pdf-viewer/src/bitmap.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class Bitmap {
3131
return this.runtime.fillBitmap(this.ptr, left, top, width, height, color);
3232
}
3333

34-
toBytes() {
34+
toUint8Array() {
3535
const stride = this.runtime.bitmapStride(this.ptr);
3636
const height = this.runtime.bitmapHeight(this.ptr);
3737
const bufferPtr = this.runtime.bitmapBuffer(this.ptr);

‎packages/pdf-viewer/src/viewer.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ export class Viewer {
7373
return new Bitmap(this.runtime, ptr, format);
7474
}
7575

76-
[Symbol.dispose]() {
76+
dispose() {
7777
this.runtime.deinit();
7878
}
79+
80+
[Symbol.dispose]() {
81+
this.dispose();
82+
}
7983
}

0 commit comments

Comments
 (0)