@chialab/pdfjs-lib 1.0.0-alpha.21 → 1.0.0-alpha.22

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.
@@ -25118,7 +25118,7 @@ var SvgCanvasContext = class {
25118
25118
  constructor(width, height, canvas) {
25119
25119
  __publicField(this, "_width");
25120
25120
  __publicField(this, "_height");
25121
- __publicField(this, "_canvas");
25121
+ __publicField(this, "_canvas", null);
25122
25122
  __publicField(this, "_ctx", null);
25123
25123
  __publicField(this, "_currentStyle", {
25124
25124
  strokeStyle: "#000000",
@@ -25177,6 +25177,9 @@ var SvgCanvasContext = class {
25177
25177
  this.resetTransform();
25178
25178
  }
25179
25179
  get canvas() {
25180
+ if (!this._canvas) {
25181
+ throw new Error("Canvas is destroyed");
25182
+ }
25180
25183
  return this._canvas;
25181
25184
  }
25182
25185
  get fillStyle() {
@@ -25275,8 +25278,8 @@ var SvgCanvasContext = class {
25275
25278
  resize(width, height) {
25276
25279
  this._width = width;
25277
25280
  this._height = height;
25278
- this._canvas.width = width;
25279
- this._canvas.height = height;
25281
+ this.canvas.width = width;
25282
+ this.canvas.height = height;
25280
25283
  this._root.attrs.width = width;
25281
25284
  this._root.attrs.height = height;
25282
25285
  }
@@ -26002,6 +26005,13 @@ var SvgCanvasContext = class {
26002
26005
  this._groupStack = [];
26003
26006
  this._parents.clear();
26004
26007
  }
26008
+ destroy() {
26009
+ this._clearCanvas();
26010
+ this.canvas.width = 0;
26011
+ this.canvas.height = 0;
26012
+ this._ctx = null;
26013
+ this._canvas = null;
26014
+ }
26005
26015
  };
26006
26016
  async function createSvgContext(width, height) {
26007
26017
  const canvas = await createCanvas(width, height);
@@ -26020,6 +26030,11 @@ async function toSvgNode(ctx) {
26020
26030
  async function toSvgString(ctx) {
26021
26031
  return renderSvgNode(await toSvgNode(ctx));
26022
26032
  }
26033
+ function destroySvgContext(ctx) {
26034
+ if (ctx instanceof SvgCanvasContext) {
26035
+ ctx.destroy();
26036
+ }
26037
+ }
26023
26038
 
26024
26039
  // src/lib/PDFPageProxy.ts
26025
26040
  async function loadNodeCanvasFactory() {
@@ -26871,6 +26886,7 @@ export {
26871
26886
  createSvgContext,
26872
26887
  createTextLayer,
26873
26888
  createValidAbsoluteUrl,
26889
+ destroySvgContext,
26874
26890
  fetchData,
26875
26891
  getDocument,
26876
26892
  getFilenameFromUrl,
@@ -158,8 +158,10 @@ export declare class SvgCanvasContext {
158
158
  protected _addPathCommand(command: string): void;
159
159
  protected _applyText(text: string, x: number, y: number, action: 'fill'): void;
160
160
  protected _clearCanvas(): void;
161
+ destroy(): void;
161
162
  }
162
163
  export declare function createSvgContext(width: number, height: number): Promise<CanvasRenderingContext2D>;
163
164
  export declare function toSvgNode(ctx: CanvasRenderingContext2D): Promise<SvgRoot>;
164
165
  export declare function toSvgString(ctx: CanvasRenderingContext2D): Promise<string>;
166
+ export declare function destroySvgContext(ctx: CanvasRenderingContext2D): void;
165
167
  export {};
@@ -24162,7 +24162,7 @@ var SvgCanvasContext = class {
24162
24162
  constructor(width, height, canvas) {
24163
24163
  __publicField(this, "_width");
24164
24164
  __publicField(this, "_height");
24165
- __publicField(this, "_canvas");
24165
+ __publicField(this, "_canvas", null);
24166
24166
  __publicField(this, "_ctx", null);
24167
24167
  __publicField(this, "_currentStyle", {
24168
24168
  strokeStyle: "#000000",
@@ -24221,6 +24221,9 @@ var SvgCanvasContext = class {
24221
24221
  this.resetTransform();
24222
24222
  }
24223
24223
  get canvas() {
24224
+ if (!this._canvas) {
24225
+ throw new Error("Canvas is destroyed");
24226
+ }
24224
24227
  return this._canvas;
24225
24228
  }
24226
24229
  get fillStyle() {
@@ -24319,8 +24322,8 @@ var SvgCanvasContext = class {
24319
24322
  resize(width, height) {
24320
24323
  this._width = width;
24321
24324
  this._height = height;
24322
- this._canvas.width = width;
24323
- this._canvas.height = height;
24325
+ this.canvas.width = width;
24326
+ this.canvas.height = height;
24324
24327
  this._root.attrs.width = width;
24325
24328
  this._root.attrs.height = height;
24326
24329
  }
@@ -25046,6 +25049,13 @@ var SvgCanvasContext = class {
25046
25049
  this._groupStack = [];
25047
25050
  this._parents.clear();
25048
25051
  }
25052
+ destroy() {
25053
+ this._clearCanvas();
25054
+ this.canvas.width = 0;
25055
+ this.canvas.height = 0;
25056
+ this._ctx = null;
25057
+ this._canvas = null;
25058
+ }
25049
25059
  };
25050
25060
  async function createSvgContext(width, height) {
25051
25061
  const canvas = await createCanvas(width, height);
@@ -25064,6 +25074,11 @@ async function toSvgNode(ctx) {
25064
25074
  async function toSvgString(ctx) {
25065
25075
  return renderSvgNode(await toSvgNode(ctx));
25066
25076
  }
25077
+ function destroySvgContext(ctx) {
25078
+ if (ctx instanceof SvgCanvasContext) {
25079
+ ctx.destroy();
25080
+ }
25081
+ }
25067
25082
 
25068
25083
  // src/lib/PDFPageProxy.ts
25069
25084
  async function loadNodeCanvasFactory() {
@@ -25915,6 +25930,7 @@ export {
25915
25930
  createSvgContext,
25916
25931
  createTextLayer,
25917
25932
  createValidAbsoluteUrl,
25933
+ destroySvgContext,
25918
25934
  fetchData,
25919
25935
  getDocument,
25920
25936
  getFilenameFromUrl,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chialab/pdfjs-lib",
3
3
  "description": "A custom Mozilla's PDF.js build with better Node support and extras.",
4
- "version": "1.0.0-alpha.21",
4
+ "version": "1.0.0-alpha.22",
5
5
  "type": "module",
6
6
  "author": "Chialab <dev@chialab.it>",
7
7
  "license": "MIT",