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

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.
@@ -25147,7 +25147,7 @@ var SvgCanvasContext = class {
25147
25147
  __publicField(this, "_transformMatrixStack", []);
25148
25148
  __publicField(this, "_root");
25149
25149
  __publicField(this, "_defs");
25150
- __publicField(this, "_currentGroup");
25150
+ __publicField(this, "_currentGroup", null);
25151
25151
  __publicField(this, "_currentElement", null);
25152
25152
  __publicField(this, "_currentMarked", null);
25153
25153
  __publicField(this, "_transformMatrix", new DOMMatrix([1, 0, 0, 1, 0, 0]));
@@ -25273,7 +25273,10 @@ var SvgCanvasContext = class {
25273
25273
  this._currentStyle.miterLimit = value;
25274
25274
  }
25275
25275
  getNode() {
25276
- return this._root;
25276
+ if (typeof structuredClone === "function") {
25277
+ return structuredClone(this._root);
25278
+ }
25279
+ return JSON.parse(JSON.stringify(this._root));
25277
25280
  }
25278
25281
  resize(width, height) {
25279
25282
  this._width = width;
@@ -25284,7 +25287,7 @@ var SvgCanvasContext = class {
25284
25287
  this._root.attrs.height = height;
25285
25288
  }
25286
25289
  save() {
25287
- this._groupStack.push(this._currentGroup);
25290
+ this._groupStack.push(this._currentGroup ?? this._root);
25288
25291
  this._currentGroup = this._ensureTransformationGroup();
25289
25292
  this._styleStack.push(this._getStyleState());
25290
25293
  this._transformMatrixStack.push(this.getTransform());
@@ -25756,10 +25759,10 @@ var SvgCanvasContext = class {
25756
25759
  return;
25757
25760
  }
25758
25761
  if (!this._currentMarked) {
25759
- this._addNode(node, this._currentGroup);
25762
+ this._addNode(node, this._currentGroup ?? this._root);
25760
25763
  return;
25761
25764
  }
25762
- let group = this._currentGroup;
25765
+ let group = this._currentGroup ?? this._root;
25763
25766
  if (this._currentMarked.elements.length === 0) {
25764
25767
  const markedStackToAdd = [this._currentMarked];
25765
25768
  let i;
@@ -26000,17 +26003,28 @@ var SvgCanvasContext = class {
26000
26003
  }
26001
26004
  _clearCanvas() {
26002
26005
  this._defs.children = [];
26003
- this._root.children = [this._defs];
26006
+ this._addNode(this._defs, this._root);
26004
26007
  this._currentGroup = this._root;
26005
26008
  this._groupStack = [];
26006
26009
  this._parents.clear();
26007
26010
  }
26008
26011
  destroy() {
26009
- this._clearCanvas();
26010
26012
  this.canvas.width = 0;
26011
26013
  this.canvas.height = 0;
26014
+ this._styleStack = [];
26015
+ this._groupStack = [];
26016
+ this._markedStack = [];
26017
+ this._transformMatrixStack = [];
26012
26018
  this._ctx = null;
26013
26019
  this._canvas = null;
26020
+ this._currentGroup = null;
26021
+ this._currentElement = null;
26022
+ this._currentMarked = null;
26023
+ this._currentPosition = {};
26024
+ this._transformMatrix = new DOMMatrix();
26025
+ this._root.children = [];
26026
+ this._defs.children = [];
26027
+ this._parents.clear();
26014
26028
  }
26015
26029
  };
26016
26030
  async function createSvgContext(width, height) {
@@ -24191,7 +24191,7 @@ var SvgCanvasContext = class {
24191
24191
  __publicField(this, "_transformMatrixStack", []);
24192
24192
  __publicField(this, "_root");
24193
24193
  __publicField(this, "_defs");
24194
- __publicField(this, "_currentGroup");
24194
+ __publicField(this, "_currentGroup", null);
24195
24195
  __publicField(this, "_currentElement", null);
24196
24196
  __publicField(this, "_currentMarked", null);
24197
24197
  __publicField(this, "_transformMatrix", new DOMMatrix([1, 0, 0, 1, 0, 0]));
@@ -24317,7 +24317,10 @@ var SvgCanvasContext = class {
24317
24317
  this._currentStyle.miterLimit = value;
24318
24318
  }
24319
24319
  getNode() {
24320
- return this._root;
24320
+ if (typeof structuredClone === "function") {
24321
+ return structuredClone(this._root);
24322
+ }
24323
+ return JSON.parse(JSON.stringify(this._root));
24321
24324
  }
24322
24325
  resize(width, height) {
24323
24326
  this._width = width;
@@ -24328,7 +24331,7 @@ var SvgCanvasContext = class {
24328
24331
  this._root.attrs.height = height;
24329
24332
  }
24330
24333
  save() {
24331
- this._groupStack.push(this._currentGroup);
24334
+ this._groupStack.push(this._currentGroup ?? this._root);
24332
24335
  this._currentGroup = this._ensureTransformationGroup();
24333
24336
  this._styleStack.push(this._getStyleState());
24334
24337
  this._transformMatrixStack.push(this.getTransform());
@@ -24800,10 +24803,10 @@ var SvgCanvasContext = class {
24800
24803
  return;
24801
24804
  }
24802
24805
  if (!this._currentMarked) {
24803
- this._addNode(node, this._currentGroup);
24806
+ this._addNode(node, this._currentGroup ?? this._root);
24804
24807
  return;
24805
24808
  }
24806
- let group = this._currentGroup;
24809
+ let group = this._currentGroup ?? this._root;
24807
24810
  if (this._currentMarked.elements.length === 0) {
24808
24811
  const markedStackToAdd = [this._currentMarked];
24809
24812
  let i;
@@ -25044,17 +25047,28 @@ var SvgCanvasContext = class {
25044
25047
  }
25045
25048
  _clearCanvas() {
25046
25049
  this._defs.children = [];
25047
- this._root.children = [this._defs];
25050
+ this._addNode(this._defs, this._root);
25048
25051
  this._currentGroup = this._root;
25049
25052
  this._groupStack = [];
25050
25053
  this._parents.clear();
25051
25054
  }
25052
25055
  destroy() {
25053
- this._clearCanvas();
25054
25056
  this.canvas.width = 0;
25055
25057
  this.canvas.height = 0;
25058
+ this._styleStack = [];
25059
+ this._groupStack = [];
25060
+ this._markedStack = [];
25061
+ this._transformMatrixStack = [];
25056
25062
  this._ctx = null;
25057
25063
  this._canvas = null;
25064
+ this._currentGroup = null;
25065
+ this._currentElement = null;
25066
+ this._currentMarked = null;
25067
+ this._currentPosition = {};
25068
+ this._transformMatrix = new DOMMatrix();
25069
+ this._root.children = [];
25070
+ this._defs.children = [];
25071
+ this._parents.clear();
25058
25072
  }
25059
25073
  };
25060
25074
  async function createSvgContext(width, height) {
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.22",
4
+ "version": "1.0.0-alpha.24",
5
5
  "type": "module",
6
6
  "author": "Chialab <dev@chialab.it>",
7
7
  "license": "MIT",