@inweb/viewer-visualize 26.12.0 → 26.12.3
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/dist/viewer-visualize.js
CHANGED
|
@@ -4256,7 +4256,7 @@
|
|
|
4256
4256
|
: {};
|
|
4257
4257
|
const Konva$2 = {
|
|
4258
4258
|
_global: glob,
|
|
4259
|
-
version: '10.0.
|
|
4259
|
+
version: '10.0.12',
|
|
4260
4260
|
isBrowser: detectBrowser(),
|
|
4261
4261
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
4262
4262
|
dblClickWindow: 400,
|
|
@@ -4298,7 +4298,7 @@
|
|
|
4298
4298
|
document: glob.document,
|
|
4299
4299
|
_injectGlobal(Konva) {
|
|
4300
4300
|
if (typeof glob.Konva !== 'undefined') {
|
|
4301
|
-
console.error('
|
|
4301
|
+
console.error('Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.');
|
|
4302
4302
|
}
|
|
4303
4303
|
glob.Konva = Konva;
|
|
4304
4304
|
},
|
|
@@ -4473,7 +4473,7 @@ js: import "konva/skia-backend";
|
|
|
4473
4473
|
return result;
|
|
4474
4474
|
}
|
|
4475
4475
|
}
|
|
4476
|
-
const OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH
|
|
4476
|
+
const OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH = '#', EMPTY_STRING$1 = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {
|
|
4477
4477
|
aliceblue: [240, 248, 255],
|
|
4478
4478
|
antiquewhite: [250, 235, 215],
|
|
4479
4479
|
aqua: [0, 255, 255],
|
|
@@ -4625,6 +4625,7 @@ js: import "konva/skia-backend";
|
|
|
4625
4625
|
yellowgreen: [154, 205, 5],
|
|
4626
4626
|
}, RGB_REGEX = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;
|
|
4627
4627
|
let animQueue = [];
|
|
4628
|
+
let _isCanvasFarblingActive = null;
|
|
4628
4629
|
const req = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame) ||
|
|
4629
4630
|
function (f) {
|
|
4630
4631
|
setTimeout(f, 60);
|
|
@@ -4720,7 +4721,7 @@ js: import "konva/skia-backend";
|
|
|
4720
4721
|
return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
4721
4722
|
},
|
|
4722
4723
|
_hexToRgb(hex) {
|
|
4723
|
-
hex = hex.replace(HASH
|
|
4724
|
+
hex = hex.replace(HASH, EMPTY_STRING$1);
|
|
4724
4725
|
const bigint = parseInt(hex, 16);
|
|
4725
4726
|
return {
|
|
4726
4727
|
r: (bigint >> 16) & 255,
|
|
@@ -4733,7 +4734,58 @@ js: import "konva/skia-backend";
|
|
|
4733
4734
|
while (randColor.length < 6) {
|
|
4734
4735
|
randColor = ZERO + randColor;
|
|
4735
4736
|
}
|
|
4736
|
-
return HASH
|
|
4737
|
+
return HASH + randColor;
|
|
4738
|
+
},
|
|
4739
|
+
isCanvasFarblingActive() {
|
|
4740
|
+
if (_isCanvasFarblingActive !== null) {
|
|
4741
|
+
return _isCanvasFarblingActive;
|
|
4742
|
+
}
|
|
4743
|
+
if (typeof document === 'undefined') {
|
|
4744
|
+
_isCanvasFarblingActive = false;
|
|
4745
|
+
return false;
|
|
4746
|
+
}
|
|
4747
|
+
const c = this.createCanvasElement();
|
|
4748
|
+
c.width = 10;
|
|
4749
|
+
c.height = 10;
|
|
4750
|
+
const ctx = c.getContext('2d', {
|
|
4751
|
+
willReadFrequently: true,
|
|
4752
|
+
});
|
|
4753
|
+
ctx.clearRect(0, 0, 10, 10);
|
|
4754
|
+
ctx.fillStyle = '#282828';
|
|
4755
|
+
ctx.fillRect(0, 0, 10, 10);
|
|
4756
|
+
const d = ctx.getImageData(0, 0, 10, 10).data;
|
|
4757
|
+
let isFarbling = false;
|
|
4758
|
+
for (let i = 0; i < 100; i++) {
|
|
4759
|
+
if (d[i * 4] !== 40 ||
|
|
4760
|
+
d[i * 4 + 1] !== 40 ||
|
|
4761
|
+
d[i * 4 + 2] !== 40 ||
|
|
4762
|
+
d[i * 4 + 3] !== 255) {
|
|
4763
|
+
isFarbling = true;
|
|
4764
|
+
break;
|
|
4765
|
+
}
|
|
4766
|
+
}
|
|
4767
|
+
_isCanvasFarblingActive = isFarbling;
|
|
4768
|
+
this.releaseCanvas(c);
|
|
4769
|
+
return _isCanvasFarblingActive;
|
|
4770
|
+
},
|
|
4771
|
+
getHitColor() {
|
|
4772
|
+
const color = this.getRandomColor();
|
|
4773
|
+
return this.isCanvasFarblingActive()
|
|
4774
|
+
? this.getSnappedHexColor(color)
|
|
4775
|
+
: color;
|
|
4776
|
+
},
|
|
4777
|
+
getHitColorKey(r, g, b) {
|
|
4778
|
+
if (this.isCanvasFarblingActive()) {
|
|
4779
|
+
r = Math.round(r / 5) * 5;
|
|
4780
|
+
g = Math.round(g / 5) * 5;
|
|
4781
|
+
b = Math.round(b / 5) * 5;
|
|
4782
|
+
}
|
|
4783
|
+
return HASH + this._rgbToHex(r, g, b);
|
|
4784
|
+
},
|
|
4785
|
+
getSnappedHexColor(hex) {
|
|
4786
|
+
const rgb = this._hexToRgb(hex);
|
|
4787
|
+
return (HASH +
|
|
4788
|
+
this._rgbToHex(Math.round(rgb.r / 5) * 5, Math.round(rgb.g / 5) * 5, Math.round(rgb.b / 5) * 5));
|
|
4737
4789
|
},
|
|
4738
4790
|
getRGB(color) {
|
|
4739
4791
|
let rgb;
|
|
@@ -4745,7 +4797,7 @@ js: import "konva/skia-backend";
|
|
|
4745
4797
|
b: rgb[2],
|
|
4746
4798
|
};
|
|
4747
4799
|
}
|
|
4748
|
-
else if (color[0] === HASH
|
|
4800
|
+
else if (color[0] === HASH) {
|
|
4749
4801
|
return this._hexToRgb(color.substring(1));
|
|
4750
4802
|
}
|
|
4751
4803
|
else if (color.substr(0, 4) === RGB_PAREN) {
|
|
@@ -5829,42 +5881,12 @@ js: import "konva/skia-backend";
|
|
|
5829
5881
|
this.setSize(config.width, config.height);
|
|
5830
5882
|
}
|
|
5831
5883
|
}
|
|
5832
|
-
function isCanvasFarblingActive() {
|
|
5833
|
-
const c = Util.createCanvasElement();
|
|
5834
|
-
c.width = 1;
|
|
5835
|
-
c.height = 1;
|
|
5836
|
-
const ctx = c.getContext('2d', {
|
|
5837
|
-
willReadFrequently: true,
|
|
5838
|
-
});
|
|
5839
|
-
ctx.clearRect(0, 0, 1, 1);
|
|
5840
|
-
ctx.fillStyle = 'rgba(255,0,255,1)';
|
|
5841
|
-
ctx.fillRect(0, 0, 1, 1);
|
|
5842
|
-
const d = ctx.getImageData(0, 0, 1, 1).data;
|
|
5843
|
-
const exact = d[0] === 255 && d[1] === 0 && d[2] === 255 && d[3] === 255;
|
|
5844
|
-
return !exact;
|
|
5845
|
-
}
|
|
5846
|
-
function isBraveBrowser() {
|
|
5847
|
-
var _a, _b;
|
|
5848
|
-
if (typeof navigator === 'undefined') {
|
|
5849
|
-
return false;
|
|
5850
|
-
}
|
|
5851
|
-
return (_b = (_a = navigator.brave) === null || _a === void 0 ? void 0 : _a.isBrave()) !== null && _b !== void 0 ? _b : false;
|
|
5852
|
-
}
|
|
5853
|
-
let warned = false;
|
|
5854
|
-
function checkHitCanvasSupport() {
|
|
5855
|
-
if (isBraveBrowser() && isCanvasFarblingActive() && !warned) {
|
|
5856
|
-
warned = true;
|
|
5857
|
-
Util.error('Looks like you have "Brave shield" enabled in your browser. It breaks KonvaJS internals. Please disable it. You may need to ask your users to do the same.');
|
|
5858
|
-
}
|
|
5859
|
-
return isBraveBrowser() && isCanvasFarblingActive();
|
|
5860
|
-
}
|
|
5861
5884
|
class HitCanvas extends Canvas {
|
|
5862
5885
|
constructor(config = { width: 0, height: 0 }) {
|
|
5863
5886
|
super(config);
|
|
5864
5887
|
this.hitCanvas = true;
|
|
5865
5888
|
this.context = new HitContext(this);
|
|
5866
5889
|
this.setSize(config.width, config.height);
|
|
5867
|
-
checkHitCanvasSupport();
|
|
5868
5890
|
}
|
|
5869
5891
|
}
|
|
5870
5892
|
|
|
@@ -6720,7 +6742,7 @@ js: import "konva/skia-backend";
|
|
|
6720
6742
|
return ancestors;
|
|
6721
6743
|
}
|
|
6722
6744
|
getAttrs() {
|
|
6723
|
-
return
|
|
6745
|
+
return this.attrs || {};
|
|
6724
6746
|
}
|
|
6725
6747
|
setAttrs(config) {
|
|
6726
6748
|
this._batchTransformChanges(() => {
|
|
@@ -8893,11 +8915,18 @@ js: import "konva/skia-backend";
|
|
|
8893
8915
|
constructor(config) {
|
|
8894
8916
|
super(config);
|
|
8895
8917
|
let key;
|
|
8918
|
+
let attempts = 0;
|
|
8896
8919
|
while (true) {
|
|
8897
|
-
key = Util.
|
|
8920
|
+
key = Util.getHitColor();
|
|
8898
8921
|
if (key && !(key in shapes)) {
|
|
8899
8922
|
break;
|
|
8900
8923
|
}
|
|
8924
|
+
attempts++;
|
|
8925
|
+
if (attempts >= 10000) {
|
|
8926
|
+
Util.warn('Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it.');
|
|
8927
|
+
key = Util.getRandomColor();
|
|
8928
|
+
break;
|
|
8929
|
+
}
|
|
8901
8930
|
}
|
|
8902
8931
|
this.colorKey = key;
|
|
8903
8932
|
shapes[key] = this;
|
|
@@ -9180,8 +9209,10 @@ js: import "konva/skia-backend";
|
|
|
9180
9209
|
if (hasShadow) {
|
|
9181
9210
|
context._applyShadow(this);
|
|
9182
9211
|
}
|
|
9183
|
-
|
|
9184
|
-
|
|
9212
|
+
if (!cachingSelf) {
|
|
9213
|
+
context._applyOpacity(this);
|
|
9214
|
+
context._applyGlobalCompositeOperation(this);
|
|
9215
|
+
}
|
|
9185
9216
|
context.drawImage(bc._canvas, bc.x || 0, bc.y || 0, bc.width / ratio, bc.height / ratio);
|
|
9186
9217
|
}
|
|
9187
9218
|
else {
|
|
@@ -9375,7 +9406,7 @@ js: import "konva/skia-backend";
|
|
|
9375
9406
|
setDrawHitFunc: 'setHitFunc',
|
|
9376
9407
|
});
|
|
9377
9408
|
|
|
9378
|
-
const
|
|
9409
|
+
const BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS = [
|
|
9379
9410
|
{ x: 0, y: 0 },
|
|
9380
9411
|
{ x: -1, y: -1 },
|
|
9381
9412
|
{ x: 1, y: -1 },
|
|
@@ -9593,8 +9624,8 @@ js: import "konva/skia-backend";
|
|
|
9593
9624
|
const p = this.hitCanvas.context.getImageData(Math.round(pos.x * ratio), Math.round(pos.y * ratio), 1, 1).data;
|
|
9594
9625
|
const p3 = p[3];
|
|
9595
9626
|
if (p3 === 255) {
|
|
9596
|
-
const colorKey = Util.
|
|
9597
|
-
const shape = shapes[
|
|
9627
|
+
const colorKey = Util.getHitColorKey(p[0], p[1], p[2]);
|
|
9628
|
+
const shape = shapes[colorKey];
|
|
9598
9629
|
if (shape) {
|
|
9599
9630
|
return {
|
|
9600
9631
|
shape: shape,
|
|
@@ -12299,12 +12330,12 @@ js: import "konva/skia-backend";
|
|
|
12299
12330
|
context.fillStrokeShape(this);
|
|
12300
12331
|
}
|
|
12301
12332
|
getWidth() {
|
|
12302
|
-
var _a, _b;
|
|
12303
|
-
return (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.width;
|
|
12333
|
+
var _a, _b, _c;
|
|
12334
|
+
return (_c = (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 0;
|
|
12304
12335
|
}
|
|
12305
12336
|
getHeight() {
|
|
12306
|
-
var _a, _b;
|
|
12307
|
-
return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height;
|
|
12337
|
+
var _a, _b, _c;
|
|
12338
|
+
return (_c = (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height) !== null && _c !== void 0 ? _c : 0;
|
|
12308
12339
|
}
|
|
12309
12340
|
static fromURL(url, callback, onError = null) {
|
|
12310
12341
|
const img = Util.createImageElement();
|
|
@@ -12320,6 +12351,7 @@ js: import "konva/skia-backend";
|
|
|
12320
12351
|
}
|
|
12321
12352
|
};
|
|
12322
12353
|
Image$1.prototype.className = 'Image';
|
|
12354
|
+
Image$1.prototype._attrsAffectingSize = ['image'];
|
|
12323
12355
|
_registerNode(Image$1);
|
|
12324
12356
|
Factory.addGetterSetter(Image$1, 'cornerRadius', 0, getNumberOrArrayOfNumbersValidator(4));
|
|
12325
12357
|
Factory.addGetterSetter(Image$1, 'image');
|
|
@@ -12547,8 +12579,8 @@ js: import "konva/skia-backend";
|
|
|
12547
12579
|
getSelfRect() {
|
|
12548
12580
|
const points = this._getPoints();
|
|
12549
12581
|
let minX = points[0].x;
|
|
12550
|
-
let maxX = points[0].
|
|
12551
|
-
let minY = points[0].
|
|
12582
|
+
let maxX = points[0].x;
|
|
12583
|
+
let minY = points[0].y;
|
|
12552
12584
|
let maxY = points[0].y;
|
|
12553
12585
|
points.forEach((point) => {
|
|
12554
12586
|
minX = Math.min(minX, point.x);
|
|
@@ -12900,6 +12932,7 @@ js: import "konva/skia-backend";
|
|
|
12900
12932
|
context.stroke();
|
|
12901
12933
|
context.restore();
|
|
12902
12934
|
}
|
|
12935
|
+
const lineThroughStartX = lineTranslateX;
|
|
12903
12936
|
if (direction !== RTL &&
|
|
12904
12937
|
(letterSpacing !== 0 || align === JUSTIFY || charRenderFunc)) {
|
|
12905
12938
|
const spacesNumber = text.split(' ').length - 1;
|
|
@@ -12951,7 +12984,7 @@ js: import "konva/skia-backend";
|
|
|
12951
12984
|
const yOffset = !Konva$2.legacyTextRendering
|
|
12952
12985
|
? -Math.round(fontSize / 4)
|
|
12953
12986
|
: 0;
|
|
12954
|
-
const x =
|
|
12987
|
+
const x = lineThroughStartX;
|
|
12955
12988
|
context.moveTo(x, translateY + lineTranslateY + yOffset);
|
|
12956
12989
|
const lineWidth = align === JUSTIFY && !lastLine ? totalWidth - padding * 2 : width;
|
|
12957
12990
|
context.lineTo(x + Math.round(lineWidth), translateY + lineTranslateY + yOffset);
|
|
@@ -13254,7 +13287,9 @@ js: import "konva/skia-backend";
|
|
|
13254
13287
|
const fill = this.fill();
|
|
13255
13288
|
const fontSize = this.fontSize();
|
|
13256
13289
|
const glyphInfo = this.glyphInfo;
|
|
13257
|
-
|
|
13290
|
+
const hasUnderline = textDecoration.indexOf('underline') !== -1;
|
|
13291
|
+
const hasLineThrough = textDecoration.indexOf('line-through') !== -1;
|
|
13292
|
+
if (hasUnderline) {
|
|
13258
13293
|
context.beginPath();
|
|
13259
13294
|
}
|
|
13260
13295
|
for (let i = 0; i < glyphInfo.length; i++) {
|
|
@@ -13264,15 +13299,32 @@ js: import "konva/skia-backend";
|
|
|
13264
13299
|
context.rotate(glyphInfo[i].rotation);
|
|
13265
13300
|
this.partialText = glyphInfo[i].text;
|
|
13266
13301
|
context.fillStrokeShape(this);
|
|
13267
|
-
if (
|
|
13302
|
+
if (hasUnderline) {
|
|
13268
13303
|
if (i === 0) {
|
|
13269
13304
|
context.moveTo(0, fontSize / 2 + 1);
|
|
13270
13305
|
}
|
|
13271
|
-
context.lineTo(
|
|
13306
|
+
context.lineTo(glyphInfo[i].width, fontSize / 2 + 1);
|
|
13272
13307
|
}
|
|
13273
13308
|
context.restore();
|
|
13274
13309
|
}
|
|
13275
|
-
if (
|
|
13310
|
+
if (hasUnderline) {
|
|
13311
|
+
context.strokeStyle = fill;
|
|
13312
|
+
context.lineWidth = fontSize / 20;
|
|
13313
|
+
context.stroke();
|
|
13314
|
+
}
|
|
13315
|
+
if (hasLineThrough) {
|
|
13316
|
+
context.beginPath();
|
|
13317
|
+
for (let i = 0; i < glyphInfo.length; i++) {
|
|
13318
|
+
context.save();
|
|
13319
|
+
const p0 = glyphInfo[i].p0;
|
|
13320
|
+
context.translate(p0.x, p0.y);
|
|
13321
|
+
context.rotate(glyphInfo[i].rotation);
|
|
13322
|
+
if (i === 0) {
|
|
13323
|
+
context.moveTo(0, 0);
|
|
13324
|
+
}
|
|
13325
|
+
context.lineTo(glyphInfo[i].width, 0);
|
|
13326
|
+
context.restore();
|
|
13327
|
+
}
|
|
13276
13328
|
context.strokeStyle = fill;
|
|
13277
13329
|
context.lineWidth = fontSize / 20;
|
|
13278
13330
|
context.stroke();
|
|
@@ -13385,6 +13437,7 @@ js: import "konva/skia-backend";
|
|
|
13385
13437
|
rotation: rotation,
|
|
13386
13438
|
p0: charStartPoint,
|
|
13387
13439
|
p1: charEndPoint,
|
|
13440
|
+
width: width,
|
|
13388
13441
|
});
|
|
13389
13442
|
offsetToGlyph += glyphWidth;
|
|
13390
13443
|
}
|
|
@@ -16871,14 +16924,13 @@ js: import "konva/skia-backend";
|
|
|
16871
16924
|
});
|
|
16872
16925
|
};
|
|
16873
16926
|
this.pan = () => {
|
|
16874
|
-
this.
|
|
16875
|
-
markupObject.updateScreenCoordinates();
|
|
16876
|
-
});
|
|
16927
|
+
this.updateScreenCoordinatesForAll();
|
|
16877
16928
|
};
|
|
16878
16929
|
this.zoomAt = () => {
|
|
16879
|
-
this.
|
|
16880
|
-
|
|
16881
|
-
|
|
16930
|
+
this.updateScreenCoordinatesForAll();
|
|
16931
|
+
};
|
|
16932
|
+
this.changeCameraMode = () => {
|
|
16933
|
+
this.clearOverlay();
|
|
16882
16934
|
};
|
|
16883
16935
|
this.redirectToViewer = (event) => {
|
|
16884
16936
|
if (this._viewer)
|
|
@@ -16912,11 +16964,13 @@ js: import "konva/skia-backend";
|
|
|
16912
16964
|
this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
|
|
16913
16965
|
this._viewer.addEventListener("pan", this.pan);
|
|
16914
16966
|
this._viewer.addEventListener("zoomat", this.zoomAt);
|
|
16967
|
+
this._viewer.addEventListener("changecameramode", this.changeCameraMode);
|
|
16915
16968
|
}
|
|
16916
16969
|
}
|
|
16917
16970
|
dispose() {
|
|
16918
16971
|
var _a, _b;
|
|
16919
16972
|
if (this._viewer) {
|
|
16973
|
+
this._viewer.removeEventListener("changecameramode", this.changeCameraMode);
|
|
16920
16974
|
this._viewer.removeEventListener("zoomat", this.zoomAt);
|
|
16921
16975
|
this._viewer.removeEventListener("pan", this.pan);
|
|
16922
16976
|
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
@@ -17091,6 +17145,11 @@ js: import "konva/skia-backend";
|
|
|
17091
17145
|
ref.parent === this._groupGeometry ||
|
|
17092
17146
|
ref.parent === this._groupTexts);
|
|
17093
17147
|
}
|
|
17148
|
+
updateScreenCoordinatesForAll() {
|
|
17149
|
+
this.getObjects().forEach((markupObject) => {
|
|
17150
|
+
markupObject.updateScreenCoordinates();
|
|
17151
|
+
});
|
|
17152
|
+
}
|
|
17094
17153
|
initializeKonva() {
|
|
17095
17154
|
const stage = new Konva.Stage({
|
|
17096
17155
|
container: this._markupContainer,
|