@inweb/viewer-visualize 25.8.19 → 25.8.20

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.
@@ -12268,7 +12268,14 @@
12268
12268
  this._ref = ref;
12269
12269
  return;
12270
12270
  }
12271
- if (!params || !params.points) return;
12271
+ if (!params) params = {};
12272
+ if (!params.points) params.points = [ {
12273
+ x: 50,
12274
+ y: 50
12275
+ }, {
12276
+ x: 100,
12277
+ y: 100
12278
+ } ];
12272
12279
  const konvaPoints = [];
12273
12280
  params.points.forEach((point => konvaPoints.push(point.x, point.y)));
12274
12281
  this._ref = new Konva.Line({
@@ -12370,7 +12377,12 @@
12370
12377
  this._ref = ref;
12371
12378
  return;
12372
12379
  }
12373
- if (!params || !params.position || !params.text) return;
12380
+ if (!params) params = {};
12381
+ if (!params.position) params.position = {
12382
+ x: 100,
12383
+ y: 100
12384
+ };
12385
+ if (!params.text) params.text = "default";
12374
12386
  this._ref = new Konva.Text({
12375
12387
  x: params.position.x,
12376
12388
  y: params.position.y,
@@ -12472,7 +12484,11 @@
12472
12484
  this._ref = ref;
12473
12485
  return;
12474
12486
  }
12475
- if (!params || !params.position) return;
12487
+ if (!params) params = {};
12488
+ if (!params.position) params.position = {
12489
+ x: 100,
12490
+ y: 100
12491
+ };
12476
12492
  this._ref = new Konva.Rect({
12477
12493
  stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
12478
12494
  strokeWidth: (_b = params.lineWidth) !== null && _b !== void 0 ? _b : 4,
@@ -12582,7 +12598,15 @@
12582
12598
  this._ref = ref;
12583
12599
  return;
12584
12600
  }
12585
- if (!params || !params.position || !params.radius) return;
12601
+ if (!params) params = {};
12602
+ if (!params.position) params.position = {
12603
+ x: 100,
12604
+ y: 100
12605
+ };
12606
+ if (!params.radius) params.radius = {
12607
+ x: 25,
12608
+ y: 25
12609
+ };
12586
12610
  this._ref = new Konva.Ellipse({
12587
12611
  stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
12588
12612
  strokeWidth: (_b = params.lineWidth) !== null && _b !== void 0 ? _b : 4,
@@ -12704,7 +12728,15 @@
12704
12728
  this._ref = ref;
12705
12729
  return;
12706
12730
  }
12707
- if (!params || !params.start || !params.end) return;
12731
+ if (!params) params = {};
12732
+ if (!params.start) params.start = {
12733
+ x: 50,
12734
+ y: 50
12735
+ };
12736
+ if (!params.end) params.end = {
12737
+ x: 100,
12738
+ y: 100
12739
+ };
12708
12740
  this._ref = new Konva.Arrow({
12709
12741
  stroke: (_a = params.color) !== null && _a !== void 0 ? _a : "#ff0000",
12710
12742
  fill: (_b = params.color) !== null && _b !== void 0 ? _b : "#ff0000",
@@ -12801,22 +12833,24 @@
12801
12833
  var _a, _b;
12802
12834
  this._ratio = 1;
12803
12835
  this.EPSILON = 1e-5;
12836
+ this.BASE64_NOT_FOUND = "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAADsAAAA7AF5KHG9AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAmhJREFUWIXtlr9rVEEQxz+H8RQUJIdeIopYm0vkCg0GBBtbG1NF7Kxt7dR/IGIw/uhTaBNLERURg2kCEUyCYCPi70b0InjGS57FzOZN3r19d+9HJIVfWO52dma/s7Mz8xa2KAaBCWAR+AkECWOmSOIdwC1gtQOpHc+NfQ8wClQ8+1d0vcdH/lQ3bSIRGAZ2pTjAqNovANXIWlXlAXA2zvi2Ln4AjqYgtagYEutENSLvjRoOImFv5iB32Ae8UrLXwFBk3h9ndF0VJnKSO9gTu3yKu5Z1LKnS8YIcABgw5Ks692JZFXcXRJ46Aq6kikCnHNi/mQ50WwVtfaIoBzL3gRk2drSscJ2wrc4VvUoe2wn/41/iBfoVLRnBGnDSY3AAKacy8AmYR+o7K1zCl6wgrgpOAc/MuhvfgMuk+1JGHQgSBcAloKXy78AjYBppJk5/noTulseBMZ23iD/piHFkEdgTQzKk+5wHjmHC3cmBg0BD5xcSTrFXyQPgIWFtDwMvab+2N8DpbhyY1v/3E8gdDgNfVX9SCVZ0/gW4B0wB71S2BpxLcuCM/jaQSHSDEeAX4VMuAG4gTzyHbcAVXXO6GxxwIX+vvxe7JHcYQ07nHqklj96UIW/YhSWzMKcep8VVtf8B1Dw6h4DfhB+sdbgn2R+gnoEc5NR3dZ+3QJ9H74HqXLPCGlJyTfI9y3YCs0owq3OLOpKkLeBI1HhSDT/mdKIPiUCARMTlQx34TMLjtww8IczmO8AJ/N/2JNSQXAiQ671JePePge0+wzJSQq4FFzlaenIvucUAkiQLhC/mLGNZ9xgn5s63BP4CCk0QDtm4BhoAAAAASUVORK5CYII=";
12837
+ this.BASE64_HEADER_START = "data:image/";
12804
12838
  if (ref) {
12839
+ if (!ref.src || !ref.src.startsWith(this.BASE64_HEADER_START)) ref.src = this.BASE64_NOT_FOUND;
12840
+ if (ref.height() <= this.EPSILON) ref.height(32);
12841
+ if (ref.width() <= this.EPSILON) ref.width(32);
12805
12842
  this._ref = ref;
12806
12843
  this._canvasImage = ref.image();
12807
12844
  this._ratio = this._ref.height() <= this.EPSILON || this._ref.width() <= this.EPSILON ? 1 : this._ref.height() / this._ref.width();
12808
12845
  return;
12809
12846
  }
12810
- if (!params || !params.position || !params.src) return;
12847
+ if (!params) params = {};
12848
+ if (!params.position) params.position = {
12849
+ x: 50,
12850
+ y: 50
12851
+ };
12852
+ if (!params.src || !params.src.startsWith(this.BASE64_HEADER_START)) params.src = this.BASE64_NOT_FOUND;
12811
12853
  this._canvasImage = new Image;
12812
- this._ref = new Konva.Image({
12813
- x: params.position.x,
12814
- y: params.position.y,
12815
- image: this._canvasImage,
12816
- width: (_a = params.width) !== null && _a !== void 0 ? _a : 0,
12817
- height: (_b = params.height) !== null && _b !== void 0 ? _b : 0,
12818
- draggable: true
12819
- });
12820
12854
  this._canvasImage.onload = () => {
12821
12855
  this._ref.image(this._canvasImage);
12822
12856
  if (this._ref.height() <= this.EPSILON) this._ref.height(this._canvasImage.height);
@@ -12836,7 +12870,19 @@
12836
12870
  }
12837
12871
  }
12838
12872
  };
12873
+ this._canvasImage.onerror = () => {
12874
+ this._canvasImage.onerror = function() {};
12875
+ this._canvasImage.src = this.BASE64_NOT_FOUND;
12876
+ };
12839
12877
  this._canvasImage.src = params.src;
12878
+ this._ref = new Konva.Image({
12879
+ x: params.position.x,
12880
+ y: params.position.y,
12881
+ image: this._canvasImage,
12882
+ width: (_a = params.width) !== null && _a !== void 0 ? _a : 0,
12883
+ height: (_b = params.height) !== null && _b !== void 0 ? _b : 0,
12884
+ draggable: true
12885
+ });
12840
12886
  this._ref.on("transform", (e => {
12841
12887
  const attrs = e.target.attrs;
12842
12888
  if (attrs.rotation !== this._ref.rotation()) this._ref.rotation(attrs.rotation);
@@ -12935,7 +12981,11 @@
12935
12981
  this._ref = ref;
12936
12982
  return;
12937
12983
  }
12938
- if (!params || !params.position) return;
12984
+ if (!params) params = {};
12985
+ if (!params.position) params.position = {
12986
+ x: 100,
12987
+ y: 100
12988
+ };
12939
12989
  const arcRadius = 16;
12940
12990
  this._ref = new Konva.Shape({
12941
12991
  x: params.position.x,