watermark-js-plus 1.5.4 → 1.5.6
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/ie/index.cjs.js +13 -15
- package/dist/ie/index.cjs.js.map +1 -1
- package/dist/ie/index.cjs.min.js +1 -1
- package/dist/ie/index.esm.js +13 -15
- package/dist/ie/index.esm.js.map +1 -1
- package/dist/ie/index.esm.min.js +1 -1
- package/dist/ie/index.iife.js +13 -15
- package/dist/ie/index.iife.js.map +1 -1
- package/dist/ie/index.iife.min.js +1 -1
- package/dist/ie/index.umd.js +13 -15
- package/dist/ie/index.umd.js.map +1 -1
- package/dist/ie/index.umd.min.js +1 -1
- package/dist/ie/types/src/core/watermark.d.ts +1 -1
- package/dist/ie/types/src/types/index.d.ts +1 -0
- package/dist/ie/types/src/utils/protection.d.ts +2 -0
- package/dist/index.cjs.js +13 -15
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.esm.js +13 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.iife.js +13 -15
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.umd.js +13 -15
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/types/src/core/watermark.d.ts +1 -1
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/utils/protection.d.ts +2 -0
- package/package.json +8 -8
- package/dist/ie/types/src/utils/bootstrap.d.ts +0 -2
- package/dist/types/src/utils/bootstrap.d.ts +0 -2
package/dist/ie/index.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* watermark-js-plus v1.5.
|
|
2
|
+
* watermark-js-plus v1.5.6
|
|
3
3
|
* (c) 2022-2024 Michael Sun
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -3469,6 +3469,7 @@ var initialOptions = {
|
|
|
3469
3469
|
globalAlpha: 0.5,
|
|
3470
3470
|
mode: 'default',
|
|
3471
3471
|
mutationObserve: true,
|
|
3472
|
+
monitorProtection: false,
|
|
3472
3473
|
movable: false,
|
|
3473
3474
|
parent: 'body',
|
|
3474
3475
|
onSuccess: function () { },
|
|
@@ -3721,8 +3722,11 @@ var generateRecommendOptions = function (canvas, options, args) {
|
|
|
3721
3722
|
return result;
|
|
3722
3723
|
};
|
|
3723
3724
|
|
|
3724
|
-
var
|
|
3725
|
-
if (typeof window
|
|
3725
|
+
var protection = (function (need) {
|
|
3726
|
+
if (typeof window === 'undefined') {
|
|
3727
|
+
return;
|
|
3728
|
+
}
|
|
3729
|
+
if (need) {
|
|
3726
3730
|
Object.defineProperty(window, 'MutationObserver', {
|
|
3727
3731
|
writable: false,
|
|
3728
3732
|
configurable: false
|
|
@@ -3767,7 +3771,10 @@ var WatermarkCanvas = /** @class */ (function () {
|
|
|
3767
3771
|
throw new Error('get context error');
|
|
3768
3772
|
}
|
|
3769
3773
|
ctx.restore();
|
|
3774
|
+
ctx.resetTransform();
|
|
3770
3775
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
3776
|
+
var ratio = window.devicePixelRatio || 1;
|
|
3777
|
+
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
|
|
3771
3778
|
};
|
|
3772
3779
|
WatermarkCanvas.prototype.getCanvas = function () {
|
|
3773
3780
|
return this.canvas;
|
|
@@ -4090,7 +4097,7 @@ var Watermark = /** @class */ (function () {
|
|
|
4090
4097
|
this.options = __assign(__assign({}, initialOptions), args);
|
|
4091
4098
|
this.changeParentElement(this.options.parent);
|
|
4092
4099
|
this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
|
|
4093
|
-
|
|
4100
|
+
protection(this.options.monitorProtection);
|
|
4094
4101
|
}
|
|
4095
4102
|
/**
|
|
4096
4103
|
* Change watermark options
|
|
@@ -4107,6 +4114,7 @@ var Watermark = /** @class */ (function () {
|
|
|
4107
4114
|
switch (_a.label) {
|
|
4108
4115
|
case 0:
|
|
4109
4116
|
this.initConfigData(args, mode);
|
|
4117
|
+
protection(this.options.monitorProtection);
|
|
4110
4118
|
if (!redraw) return [3 /*break*/, 2];
|
|
4111
4119
|
this.remove();
|
|
4112
4120
|
return [4 /*yield*/, this.create()];
|
|
@@ -4182,16 +4190,7 @@ var Watermark = /** @class */ (function () {
|
|
|
4182
4190
|
Watermark.prototype.check = function () {
|
|
4183
4191
|
return __awaiter(this, void 0, void 0, function () {
|
|
4184
4192
|
return __generator(this, function (_a) {
|
|
4185
|
-
|
|
4186
|
-
case 0:
|
|
4187
|
-
if (!!this.parentElement.contains(this.watermarkDom)) return [3 /*break*/, 2];
|
|
4188
|
-
this.remove();
|
|
4189
|
-
return [4 /*yield*/, this.create()];
|
|
4190
|
-
case 1:
|
|
4191
|
-
_a.sent();
|
|
4192
|
-
_a.label = 2;
|
|
4193
|
-
case 2: return [2 /*return*/];
|
|
4194
|
-
}
|
|
4193
|
+
return [2 /*return*/, this.parentElement.contains(this.watermarkDom)];
|
|
4195
4194
|
});
|
|
4196
4195
|
});
|
|
4197
4196
|
};
|
|
@@ -4253,7 +4252,6 @@ var Watermark = /** @class */ (function () {
|
|
|
4253
4252
|
case 'text':
|
|
4254
4253
|
return this.options.content.length > 0;
|
|
4255
4254
|
}
|
|
4256
|
-
return false;
|
|
4257
4255
|
};
|
|
4258
4256
|
Watermark.prototype.checkParentElementType = function () {
|
|
4259
4257
|
if (['html', 'body'].includes(this.parentElement.tagName.toLocaleLowerCase())) {
|