watermark-js-plus 1.5.4 → 1.5.5

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * watermark-js-plus v1.5.4
2
+ * watermark-js-plus v1.5.5
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 bootstrap = (function () {
3725
- if (typeof window !== 'undefined') {
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
@@ -4090,7 +4094,7 @@ var Watermark = /** @class */ (function () {
4090
4094
  this.options = __assign(__assign({}, initialOptions), args);
4091
4095
  this.changeParentElement(this.options.parent);
4092
4096
  this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
4093
- bootstrap();
4097
+ protection(this.options.monitorProtection);
4094
4098
  }
4095
4099
  /**
4096
4100
  * Change watermark options
@@ -4107,6 +4111,7 @@ var Watermark = /** @class */ (function () {
4107
4111
  switch (_a.label) {
4108
4112
  case 0:
4109
4113
  this.initConfigData(args, mode);
4114
+ protection(this.options.monitorProtection);
4110
4115
  if (!redraw) return [3 /*break*/, 2];
4111
4116
  this.remove();
4112
4117
  return [4 /*yield*/, this.create()];
@@ -4182,16 +4187,7 @@ var Watermark = /** @class */ (function () {
4182
4187
  Watermark.prototype.check = function () {
4183
4188
  return __awaiter(this, void 0, void 0, function () {
4184
4189
  return __generator(this, function (_a) {
4185
- switch (_a.label) {
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
- }
4190
+ return [2 /*return*/, this.parentElement.contains(this.watermarkDom)];
4195
4191
  });
4196
4192
  });
4197
4193
  };
@@ -4253,7 +4249,6 @@ var Watermark = /** @class */ (function () {
4253
4249
  case 'text':
4254
4250
  return this.options.content.length > 0;
4255
4251
  }
4256
- return false;
4257
4252
  };
4258
4253
  Watermark.prototype.checkParentElementType = function () {
4259
4254
  if (['html', 'body'].includes(this.parentElement.tagName.toLocaleLowerCase())) {