watermark-js-plus 1.6.3 → 1.6.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.
Files changed (46) hide show
  1. package/dist/es/src/core/watermark.js +49 -53
  2. package/dist/ie/es/node_modules/core-js/internals/array-from.js +11 -3
  3. package/dist/ie/es/node_modules/core-js/internals/array-set-length.js +39 -0
  4. package/dist/ie/es/node_modules/core-js/internals/check-correctness-of-iteration.js +2 -0
  5. package/dist/ie/es/node_modules/core-js/internals/environment-is-ios.js +1 -2
  6. package/dist/ie/es/node_modules/core-js/internals/function-bind-native.js +1 -1
  7. package/dist/ie/es/node_modules/core-js/internals/function-name.js +1 -1
  8. package/dist/ie/es/node_modules/core-js/internals/is-array.js +20 -0
  9. package/dist/ie/es/node_modules/core-js/internals/iterate.js +8 -3
  10. package/dist/ie/es/node_modules/core-js/internals/shared-store.js +3 -3
  11. package/dist/ie/es/node_modules/core-js/internals/to-string-tag-support.js +1 -1
  12. package/dist/ie/es/node_modules/core-js/modules/es.array.fill.js +1 -1
  13. package/dist/ie/es/node_modules/core-js/modules/es.array.from.js +1 -1
  14. package/dist/ie/es/node_modules/core-js/modules/es.array.includes.js +8 -2
  15. package/dist/ie/es/node_modules/core-js/modules/es.promise.js +1 -1
  16. package/dist/ie/es/src/core/watermark.js +49 -53
  17. package/dist/ie/index.cjs.js +135 -69
  18. package/dist/ie/index.cjs.js.map +1 -1
  19. package/dist/ie/index.cjs.min.js +1 -1
  20. package/dist/ie/index.esm.js +135 -69
  21. package/dist/ie/index.esm.js.map +1 -1
  22. package/dist/ie/index.esm.min.js +1 -1
  23. package/dist/ie/index.iife.js +135 -69
  24. package/dist/ie/index.iife.js.map +1 -1
  25. package/dist/ie/index.iife.min.js +1 -1
  26. package/dist/ie/index.umd.js +135 -69
  27. package/dist/ie/index.umd.js.map +1 -1
  28. package/dist/ie/index.umd.min.js +1 -1
  29. package/dist/index.cjs.js +50 -54
  30. package/dist/index.cjs.js.map +1 -1
  31. package/dist/index.cjs.min.js +1 -1
  32. package/dist/index.esm.js +50 -54
  33. package/dist/index.esm.js.map +1 -1
  34. package/dist/index.esm.min.js +1 -1
  35. package/dist/index.iife.js +50 -54
  36. package/dist/index.iife.js.map +1 -1
  37. package/dist/index.iife.min.js +1 -1
  38. package/dist/index.umd.js +50 -54
  39. package/dist/index.umd.js.map +1 -1
  40. package/dist/index.umd.min.js +1 -1
  41. package/dist/types/core/watermark.d.ts +3 -2
  42. package/package.json +57 -51
  43. /package/dist/ie/es/_virtual/{es.array.fill2.js → es2.array.fill.js} +0 -0
  44. /package/dist/ie/es/_virtual/{es.array.from2.js → es2.array.from.js} +0 -0
  45. /package/dist/ie/es/_virtual/{es.array.includes2.js → es2.array.includes.js} +0 -0
  46. /package/dist/ie/es/_virtual/{es.promise2.js → es2.promise.js} +0 -0
@@ -64,17 +64,18 @@ var Watermark = /** @class */ (function () {
64
64
  return [2 /*return*/];
65
65
  }
66
66
  this.isCreating = true;
67
+ _h.label = 1;
68
+ case 1:
69
+ _h.trys.push([1, , 3, 4]);
67
70
  if (!this.validateUnique()) {
68
- this.isCreating = false;
69
71
  return [2 /*return*/];
70
72
  }
71
73
  if (!this.validateContent()) {
72
- this.isCreating = false;
73
74
  return [2 /*return*/];
74
75
  }
75
76
  firstDraw = isUndefined(this.watermarkDom);
76
77
  return [4 /*yield*/, ((_a = this.watermarkCanvas) === null || _a === void 0 ? void 0 : _a.draw())];
77
- case 1:
78
+ case 2:
78
79
  _h.sent();
79
80
  this.layoutCanvas = renderLayout(this.options, (_b = this.watermarkCanvas) === null || _b === void 0 ? void 0 : _b.getCanvas());
80
81
  image = convertImage(this.layoutCanvas);
@@ -84,22 +85,25 @@ var Watermark = /** @class */ (function () {
84
85
  this.watermarkDom.__WATERMARK__ = 'watermark';
85
86
  this.watermarkDom.__WATERMARK__INSTANCE__ = this;
86
87
  parentElementType = this.checkParentElementType();
87
- this.watermarkDom.style.cssText = "\n z-index:".concat(this.options.zIndex, "!important;display:block!important;visibility:visible!important;transform:none!important;scale:none!important;\n ").concat(parentElementType === 'custom' ? 'top:0!important;bottom:0!important;left:0!important;right:0!important;height:100%!important;pointer-events:none!important;position:absolute!important;' : 'position:relative!important;', "\n ");
88
+ this.watermarkDom.style.cssText = "\n z-index:".concat(this.options.zIndex, "!important;display:block!important;visibility:visible!important;transform:none!important;scale:none!important;\n ").concat(parentElementType === 'custom' ? 'top:0!important;bottom:0!important;left:0!important;right:0!important;height:100%!important;pointer-events:none!important;position:absolute!important;' : 'position:relative!important;', "\n ");
88
89
  backgroundSize = generateBackgroundSize(this.options);
89
- watermarkInnerDom.style.cssText = "\n display:block!important;visibility:visible!important;pointer-events:none;top:0;bottom:0;left:0;right:0;transform:none!important;scale:none!important;\n position:".concat(parentElementType === 'root' ? 'fixed' : 'absolute', "!important;-webkit-print-color-adjust:exact!important;width:100%!important;height:100%!important;\n z-index:").concat(this.options.zIndex, "!important;background-image:url(").concat(image, ")!important;background-repeat:").concat(this.options.backgroundRepeat, "!important;\n background-size:").concat(backgroundSize[0], "px ").concat(backgroundSize[1], "px!important;background-position:").concat(this.options.backgroundPosition, ";\n ").concat(generateAnimationStyle(this.options.movable, this.options.backgroundRepeat), "\n ");
90
+ watermarkInnerDom.style.cssText = "\n display:block!important;visibility:visible!important;pointer-events:none;top:0;bottom:0;left:0;right:0;transform:none!important;scale:none!important;\n position:".concat(parentElementType === 'root' ? 'fixed' : 'absolute', "!important;-webkit-print-color-adjust:exact!important;width:100%!important;height:100%!important;\n z-index:").concat(this.options.zIndex, "!important;background-image:url(").concat(image, ")!important;background-repeat:").concat(this.options.backgroundRepeat, "!important;\n background-size:").concat(backgroundSize[0], "px ").concat(backgroundSize[1], "px!important;background-position:").concat(this.options.backgroundPosition, ";\n ").concat(generateAnimationStyle(this.options.movable, this.options.backgroundRepeat), "\n ");
90
91
  this.watermarkDom.appendChild(watermarkInnerDom);
91
92
  this.parentElement.appendChild(this.watermarkDom);
92
93
  if (this.options.mutationObserve) {
93
94
  try {
94
- this.bindMutationObserve();
95
+ this.bindMutationObserver();
95
96
  }
96
97
  catch (_j) {
97
98
  (_e = (_d = this.options).onObserveError) === null || _e === void 0 ? void 0 : _e.call(_d);
98
99
  }
99
100
  }
100
101
  firstDraw && ((_g = (_f = this.options).onSuccess) === null || _g === void 0 ? void 0 : _g.call(_f));
102
+ return [3 /*break*/, 4];
103
+ case 3:
101
104
  this.isCreating = false;
102
- return [2 /*return*/];
105
+ return [7 /*endfinally*/];
106
+ case 4: return [2 /*return*/];
103
107
  }
104
108
  });
105
109
  });
@@ -122,7 +126,7 @@ var Watermark = /** @class */ (function () {
122
126
  var _a, _b, _c, _d, _e, _f, _g, _h;
123
127
  (_b = (_a = this.options).onBeforeDestroy) === null || _b === void 0 ? void 0 : _b.call(_a);
124
128
  (_c = this.observer) === null || _c === void 0 ? void 0 : _c.disconnect();
125
- (_d = this.parentObserve) === null || _d === void 0 ? void 0 : _d.disconnect();
129
+ (_d = this.parentObserver) === null || _d === void 0 ? void 0 : _d.disconnect();
126
130
  (_f = (_e = this.watermarkDom) === null || _e === void 0 ? void 0 : _e.parentNode) === null || _f === void 0 ? void 0 : _f.removeChild(this.watermarkDom);
127
131
  (_h = (_g = this.options).onDestroyed) === null || _h === void 0 ? void 0 : _h.call(_g);
128
132
  };
@@ -182,64 +186,56 @@ var Watermark = /** @class */ (function () {
182
186
  }
183
187
  return 'custom';
184
188
  };
185
- Watermark.prototype.bindMutationObserve = function () {
186
- var _this = this;
187
- if (!this.watermarkDom) {
188
- return;
189
- }
190
- this.observer = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
191
- return __generator(this, function (_a) {
192
- switch (_a.label) {
189
+ Watermark.prototype.recreateOnMutation = function () {
190
+ return __awaiter(this, void 0, void 0, function () {
191
+ var _b, _c;
192
+ return __generator(this, function (_d) {
193
+ switch (_d.label) {
193
194
  case 0:
194
- if (!(mutationsList.length > 0)) return [3 /*break*/, 2];
195
+ _d.trys.push([0, 2, , 3]);
195
196
  this.remove();
196
197
  return [4 /*yield*/, this.create()];
197
198
  case 1:
198
- _a.sent();
199
- _a.label = 2;
200
- case 2: return [2 /*return*/];
199
+ _d.sent();
200
+ return [3 /*break*/, 3];
201
+ case 2:
202
+ _d.sent();
203
+ (_c = (_b = this.options).onObserveError) === null || _c === void 0 ? void 0 : _c.call(_b);
204
+ return [3 /*break*/, 3];
205
+ case 3: return [2 /*return*/];
201
206
  }
202
207
  });
203
- }); });
208
+ });
209
+ };
210
+ Watermark.prototype.bindMutationObserver = function () {
211
+ var _this = this;
212
+ if (!this.watermarkDom) {
213
+ return;
214
+ }
215
+ this.observer = new MutationObserver(function (mutationsList) {
216
+ if (mutationsList.length > 0) {
217
+ void _this.recreateOnMutation();
218
+ }
219
+ });
204
220
  this.observer.observe(this.watermarkDom, {
205
221
  attributes: true, // 属性的变动
222
+ attributeFilter: ['style', 'class', 'hidden', 'id'], // 仅监听会影响水印展示或标识的属性
206
223
  childList: true, // 子节点的变动(指新增,删除或者更改)
207
224
  subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
208
225
  characterData: true, // 节点内容或节点文本的变动。
209
226
  });
210
- this.parentObserve = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
211
- var _i, mutationsList_1, item;
212
- var _a;
213
- return __generator(this, function (_b) {
214
- switch (_b.label) {
215
- case 0:
216
- _i = 0, mutationsList_1 = mutationsList;
217
- _b.label = 1;
218
- case 1:
219
- if (!(_i < mutationsList_1.length)) return [3 /*break*/, 4];
220
- item = mutationsList_1[_i];
221
- if (!((item === null || item === void 0 ? void 0 : item.target) === this.watermarkDom ||
222
- ((_a = item === null || item === void 0 ? void 0 : item.removedNodes) === null || _a === void 0 ? void 0 : _a[0]) === this.watermarkDom ||
223
- (item.type === 'childList' &&
224
- item.target === this.parentElement &&
225
- item.target.lastChild !== this.watermarkDom))) return [3 /*break*/, 3];
226
- this.remove();
227
- return [4 /*yield*/, this.create()];
228
- case 2:
229
- _b.sent();
230
- _b.label = 3;
231
- case 3:
232
- _i++;
233
- return [3 /*break*/, 1];
234
- case 4: return [2 /*return*/];
235
- }
236
- });
237
- }); });
238
- this.parentObserve.observe(this.parentElement, {
239
- attributes: true, // 属性的变动
227
+ this.parentObserver = new MutationObserver(function (mutationsList) {
228
+ var watermarkDom = _this.watermarkDom;
229
+ if (!watermarkDom) {
230
+ return;
231
+ }
232
+ var watermarkRemoved = mutationsList.some(function (item) { return Array.from(item.removedNodes).includes(watermarkDom); });
233
+ if (watermarkRemoved) {
234
+ void _this.recreateOnMutation();
235
+ }
236
+ });
237
+ this.parentObserver.observe(this.parentElement, {
240
238
  childList: true, // 子节点的变动(指新增,删除或者更改)
241
- subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
242
- characterData: true, // 节点内容或节点文本的变动。
243
239
  });
244
240
  };
245
241
  return Watermark;
@@ -6,8 +6,10 @@ import { __require as requireIsArrayIteratorMethod } from './is-array-iterator-m
6
6
  import { __require as requireIsConstructor } from './is-constructor.js';
7
7
  import { __require as requireLengthOfArrayLike } from './length-of-array-like.js';
8
8
  import { __require as requireCreateProperty } from './create-property.js';
9
+ import { __require as requireArraySetLength } from './array-set-length.js';
9
10
  import { __require as requireGetIterator } from './get-iterator.js';
10
11
  import { __require as requireGetIteratorMethod } from './get-iterator-method.js';
12
+ import { __require as requireIteratorClose } from './iterator-close.js';
11
13
 
12
14
  var arrayFrom;
13
15
  var hasRequiredArrayFrom;
@@ -23,20 +25,22 @@ function requireArrayFrom () {
23
25
  var isConstructor = requireIsConstructor();
24
26
  var lengthOfArrayLike = requireLengthOfArrayLike();
25
27
  var createProperty = requireCreateProperty();
28
+ var setArrayLength = requireArraySetLength();
26
29
  var getIterator = requireGetIterator();
27
30
  var getIteratorMethod = requireGetIteratorMethod();
31
+ var iteratorClose = requireIteratorClose();
28
32
 
29
33
  var $Array = Array;
30
34
 
31
35
  // `Array.from` method implementation
32
36
  // https://tc39.es/ecma262/#sec-array.from
33
37
  arrayFrom = function from(arrayLike /* , mapfn = undefined, thisArg = undefined */) {
34
- var O = toObject(arrayLike);
35
38
  var IS_CONSTRUCTOR = isConstructor(this);
36
39
  var argumentsLength = arguments.length;
37
40
  var mapfn = argumentsLength > 1 ? arguments[1] : undefined;
38
41
  var mapping = mapfn !== undefined;
39
42
  if (mapping) mapfn = bind(mapfn, argumentsLength > 2 ? arguments[2] : undefined);
43
+ var O = toObject(arrayLike);
40
44
  var iteratorMethod = getIteratorMethod(O);
41
45
  var index = 0;
42
46
  var length, result, step, iterator, next, value;
@@ -47,7 +51,11 @@ function requireArrayFrom () {
47
51
  next = iterator.next;
48
52
  for (;!(step = call(next, iterator)).done; index++) {
49
53
  value = mapping ? callWithSafeIterationClosing(iterator, mapfn, [step.value, index], true) : step.value;
50
- createProperty(result, index, value);
54
+ try {
55
+ createProperty(result, index, value);
56
+ } catch (error) {
57
+ iteratorClose(iterator, 'throw', error);
58
+ }
51
59
  }
52
60
  } else {
53
61
  length = lengthOfArrayLike(O);
@@ -57,7 +65,7 @@ function requireArrayFrom () {
57
65
  createProperty(result, index, value);
58
66
  }
59
67
  }
60
- result.length = index;
68
+ setArrayLength(result, index);
61
69
  return result;
62
70
  };
63
71
  return arrayFrom;
@@ -0,0 +1,39 @@
1
+ import { __require as requireDescriptors } from './descriptors.js';
2
+ import { __require as requireIsArray } from './is-array.js';
3
+
4
+ var arraySetLength;
5
+ var hasRequiredArraySetLength;
6
+
7
+ function requireArraySetLength () {
8
+ if (hasRequiredArraySetLength) return arraySetLength;
9
+ hasRequiredArraySetLength = 1;
10
+ var DESCRIPTORS = requireDescriptors();
11
+ var isArray = requireIsArray();
12
+
13
+ var $TypeError = TypeError;
14
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
15
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
16
+
17
+ // Safari < 13 does not throw an error in this case
18
+ var SILENT_ON_NON_WRITABLE_LENGTH_SET = DESCRIPTORS && !function () {
19
+ // makes no sense without proper strict mode support
20
+ if (this !== undefined) return true;
21
+ try {
22
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
23
+ Object.defineProperty([], 'length', { writable: false }).length = 1;
24
+ } catch (error) {
25
+ return error instanceof TypeError;
26
+ }
27
+ }();
28
+
29
+ arraySetLength = SILENT_ON_NON_WRITABLE_LENGTH_SET ? function (O, length) {
30
+ if (isArray(O) && !getOwnPropertyDescriptor(O, 'length').writable) {
31
+ throw new $TypeError('Cannot set read only .length');
32
+ } return O.length = length;
33
+ } : function (O, length) {
34
+ return O.length = length;
35
+ };
36
+ return arraySetLength;
37
+ }
38
+
39
+ export { requireArraySetLength as __require };
@@ -21,6 +21,7 @@ function requireCheckCorrectnessOfIteration () {
21
21
  SAFE_CLOSING = true;
22
22
  }
23
23
  };
24
+ // eslint-disable-next-line unicorn/no-immediate-mutation -- ES3 syntax limitation
24
25
  iteratorWithReturn[ITERATOR] = function () {
25
26
  return this;
26
27
  };
@@ -35,6 +36,7 @@ function requireCheckCorrectnessOfIteration () {
35
36
  var ITERATION_SUPPORT = false;
36
37
  try {
37
38
  var object = {};
39
+ // eslint-disable-next-line unicorn/no-immediate-mutation -- ES3 syntax limitation
38
40
  object[ITERATOR] = function () {
39
41
  return {
40
42
  next: function () {
@@ -8,8 +8,7 @@ function requireEnvironmentIsIos () {
8
8
  hasRequiredEnvironmentIsIos = 1;
9
9
  var userAgent = requireEnvironmentUserAgent();
10
10
 
11
- // eslint-disable-next-line redos/no-vulnerable -- safe
12
- environmentIsIos = /(?:ipad|iphone|ipod).*applewebkit/i.test(userAgent);
11
+ environmentIsIos = /ipad|iphone|ipod/i.test(userAgent) && /applewebkit/i.test(userAgent);
13
12
  return environmentIsIos;
14
13
  }
15
14
 
@@ -10,7 +10,7 @@ function requireFunctionBindNative () {
10
10
 
11
11
  functionBindNative = !fails(function () {
12
12
  // eslint-disable-next-line es/no-function-prototype-bind -- safe
13
- var test = (function () { /* empty */ }).bind();
13
+ var test = function () { /* empty */ }.bind();
14
14
  // eslint-disable-next-line no-prototype-builtins -- safe
15
15
  return typeof test != 'function' || test.hasOwnProperty('prototype');
16
16
  });
@@ -16,7 +16,7 @@ function requireFunctionName () {
16
16
 
17
17
  var EXISTS = hasOwn(FunctionPrototype, 'name');
18
18
  // additional protection from minified / mangled / dropped function names
19
- var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something';
19
+ var PROPER = EXISTS && function something() { /* empty */ }.name === 'something';
20
20
  var CONFIGURABLE = EXISTS && (!DESCRIPTORS || (DESCRIPTORS && getDescriptor(FunctionPrototype, 'name').configurable));
21
21
 
22
22
  functionName = {
@@ -0,0 +1,20 @@
1
+ import { __require as requireClassofRaw } from './classof-raw.js';
2
+
3
+ var isArray;
4
+ var hasRequiredIsArray;
5
+
6
+ function requireIsArray () {
7
+ if (hasRequiredIsArray) return isArray;
8
+ hasRequiredIsArray = 1;
9
+ var classof = requireClassofRaw();
10
+
11
+ // `IsArray` abstract operation
12
+ // https://tc39.es/ecma262/#sec-isarray
13
+ // eslint-disable-next-line es/no-array-isarray -- safe
14
+ isArray = Array.isArray || function isArray(argument) {
15
+ return classof(argument) === 'Array';
16
+ };
17
+ return isArray;
18
+ }
19
+
20
+ export { requireIsArray as __require };
@@ -45,7 +45,9 @@ function requireIterate () {
45
45
  var iterator, iterFn, index, length, result, next, step;
46
46
 
47
47
  var stop = function (condition) {
48
- if (iterator) iteratorClose(iterator, 'normal');
48
+ var $iterator = iterator;
49
+ iterator = undefined;
50
+ if ($iterator) iteratorClose($iterator, 'normal');
49
51
  return new Result(true, condition);
50
52
  };
51
53
 
@@ -75,10 +77,13 @@ function requireIterate () {
75
77
 
76
78
  next = IS_RECORD ? iterable.next : iterator.next;
77
79
  while (!(step = call(next, iterator)).done) {
80
+ // `IteratorValue` errors should propagate without closing the iterator
81
+ var value = step.value;
78
82
  try {
79
- result = callFn(step.value);
83
+ result = callFn(value);
80
84
  } catch (error) {
81
- iteratorClose(iterator, 'throw', error);
85
+ if (iterator) iteratorClose(iterator, 'throw', error);
86
+ else throw error;
82
87
  }
83
88
  if (typeof result == 'object' && result && isPrototypeOf(ResultPrototype, result)) return result;
84
89
  } return new Result(false);
@@ -16,10 +16,10 @@ function requireSharedStore () {
16
16
  var store = sharedStore.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {});
17
17
 
18
18
  (store.versions || (store.versions = [])).push({
19
- version: '3.44.0',
19
+ version: '3.49.0',
20
20
  mode: IS_PURE ? 'pure' : 'global',
21
- copyright: '© 2014-2025 Denis Pushkarev (zloirock.ru)',
22
- license: 'https://github.com/zloirock/core-js/blob/v3.44.0/LICENSE',
21
+ copyright: '© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.',
22
+ license: 'https://github.com/zloirock/core-js/blob/v3.49.0/LICENSE',
23
23
  source: 'https://github.com/zloirock/core-js'
24
24
  });
25
25
  return sharedStore.exports;
@@ -10,7 +10,7 @@ function requireToStringTagSupport () {
10
10
 
11
11
  var TO_STRING_TAG = wellKnownSymbol('toStringTag');
12
12
  var test = {};
13
-
13
+ // eslint-disable-next-line unicorn/no-immediate-mutation -- ES3 syntax limitation
14
14
  test[TO_STRING_TAG] = 'z';
15
15
 
16
16
  toStringTagSupport = String(test) === '[object z]';
@@ -1,4 +1,4 @@
1
- import { __exports as es_array_fill } from '../../../_virtual/es.array.fill2.js';
1
+ import { __exports as es_array_fill } from '../../../_virtual/es2.array.fill.js';
2
2
  import { __require as require_export } from '../internals/export.js';
3
3
  import { __require as requireArrayFill } from '../internals/array-fill.js';
4
4
  import { __require as requireAddToUnscopables } from '../internals/add-to-unscopables.js';
@@ -1,4 +1,4 @@
1
- import { __exports as es_array_from } from '../../../_virtual/es.array.from2.js';
1
+ import { __exports as es_array_from } from '../../../_virtual/es2.array.from.js';
2
2
  import { __require as require_export } from '../internals/export.js';
3
3
  import { __require as requireArrayFrom } from '../internals/array-from.js';
4
4
  import { __require as requireCheckCorrectnessOfIteration } from '../internals/check-correctness-of-iteration.js';
@@ -1,4 +1,4 @@
1
- import { __exports as es_array_includes } from '../../../_virtual/es.array.includes2.js';
1
+ import { __exports as es_array_includes } from '../../../_virtual/es2.array.includes.js';
2
2
  import { __require as require_export } from '../internals/export.js';
3
3
  import { __require as requireArrayIncludes } from '../internals/array-includes.js';
4
4
  import { __require as requireFails } from '../internals/fails.js';
@@ -20,9 +20,15 @@ function requireEs_array_includes () {
20
20
  return !Array(1).includes();
21
21
  });
22
22
 
23
+ // Safari 26.4- bug
24
+ var BROKEN_ON_SPARSE_WITH_FROM_INDEX = fails(function () {
25
+ // eslint-disable-next-line no-sparse-arrays, es/no-array-prototype-includes -- detection
26
+ return [, 1].includes(undefined, 1);
27
+ });
28
+
23
29
  // `Array.prototype.includes` method
24
30
  // https://tc39.es/ecma262/#sec-array.prototype.includes
25
- $({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
31
+ $({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE || BROKEN_ON_SPARSE_WITH_FROM_INDEX }, {
26
32
  includes: function includes(el /* , fromIndex = 0 */) {
27
33
  return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
28
34
  }
@@ -1,4 +1,4 @@
1
- import { __exports as es_promise } from '../../../_virtual/es.promise2.js';
1
+ import { __exports as es_promise } from '../../../_virtual/es2.promise.js';
2
2
  import { __require as requireEs_promise_constructor } from './es.promise.constructor.js';
3
3
  import { __require as requireEs_promise_all } from './es.promise.all.js';
4
4
  import { __require as requireEs_promise_catch } from './es.promise.catch.js';
@@ -64,17 +64,18 @@ var Watermark = /** @class */ (function () {
64
64
  return [2 /*return*/];
65
65
  }
66
66
  this.isCreating = true;
67
+ _h.label = 1;
68
+ case 1:
69
+ _h.trys.push([1, , 3, 4]);
67
70
  if (!this.validateUnique()) {
68
- this.isCreating = false;
69
71
  return [2 /*return*/];
70
72
  }
71
73
  if (!this.validateContent()) {
72
- this.isCreating = false;
73
74
  return [2 /*return*/];
74
75
  }
75
76
  firstDraw = isUndefined(this.watermarkDom);
76
77
  return [4 /*yield*/, ((_a = this.watermarkCanvas) === null || _a === void 0 ? void 0 : _a.draw())];
77
- case 1:
78
+ case 2:
78
79
  _h.sent();
79
80
  this.layoutCanvas = renderLayout(this.options, (_b = this.watermarkCanvas) === null || _b === void 0 ? void 0 : _b.getCanvas());
80
81
  image = convertImage(this.layoutCanvas);
@@ -84,22 +85,25 @@ var Watermark = /** @class */ (function () {
84
85
  this.watermarkDom.__WATERMARK__ = 'watermark';
85
86
  this.watermarkDom.__WATERMARK__INSTANCE__ = this;
86
87
  parentElementType = this.checkParentElementType();
87
- this.watermarkDom.style.cssText = "\n z-index:".concat(this.options.zIndex, "!important;display:block!important;visibility:visible!important;transform:none!important;scale:none!important;\n ").concat(parentElementType === 'custom' ? 'top:0!important;bottom:0!important;left:0!important;right:0!important;height:100%!important;pointer-events:none!important;position:absolute!important;' : 'position:relative!important;', "\n ");
88
+ this.watermarkDom.style.cssText = "\n z-index:".concat(this.options.zIndex, "!important;display:block!important;visibility:visible!important;transform:none!important;scale:none!important;\n ").concat(parentElementType === 'custom' ? 'top:0!important;bottom:0!important;left:0!important;right:0!important;height:100%!important;pointer-events:none!important;position:absolute!important;' : 'position:relative!important;', "\n ");
88
89
  backgroundSize = generateBackgroundSize(this.options);
89
- watermarkInnerDom.style.cssText = "\n display:block!important;visibility:visible!important;pointer-events:none;top:0;bottom:0;left:0;right:0;transform:none!important;scale:none!important;\n position:".concat(parentElementType === 'root' ? 'fixed' : 'absolute', "!important;-webkit-print-color-adjust:exact!important;width:100%!important;height:100%!important;\n z-index:").concat(this.options.zIndex, "!important;background-image:url(").concat(image, ")!important;background-repeat:").concat(this.options.backgroundRepeat, "!important;\n background-size:").concat(backgroundSize[0], "px ").concat(backgroundSize[1], "px!important;background-position:").concat(this.options.backgroundPosition, ";\n ").concat(generateAnimationStyle(this.options.movable, this.options.backgroundRepeat), "\n ");
90
+ watermarkInnerDom.style.cssText = "\n display:block!important;visibility:visible!important;pointer-events:none;top:0;bottom:0;left:0;right:0;transform:none!important;scale:none!important;\n position:".concat(parentElementType === 'root' ? 'fixed' : 'absolute', "!important;-webkit-print-color-adjust:exact!important;width:100%!important;height:100%!important;\n z-index:").concat(this.options.zIndex, "!important;background-image:url(").concat(image, ")!important;background-repeat:").concat(this.options.backgroundRepeat, "!important;\n background-size:").concat(backgroundSize[0], "px ").concat(backgroundSize[1], "px!important;background-position:").concat(this.options.backgroundPosition, ";\n ").concat(generateAnimationStyle(this.options.movable, this.options.backgroundRepeat), "\n ");
90
91
  this.watermarkDom.appendChild(watermarkInnerDom);
91
92
  this.parentElement.appendChild(this.watermarkDom);
92
93
  if (this.options.mutationObserve) {
93
94
  try {
94
- this.bindMutationObserve();
95
+ this.bindMutationObserver();
95
96
  }
96
97
  catch (_j) {
97
98
  (_e = (_d = this.options).onObserveError) === null || _e === void 0 ? void 0 : _e.call(_d);
98
99
  }
99
100
  }
100
101
  firstDraw && ((_g = (_f = this.options).onSuccess) === null || _g === void 0 ? void 0 : _g.call(_f));
102
+ return [3 /*break*/, 4];
103
+ case 3:
101
104
  this.isCreating = false;
102
- return [2 /*return*/];
105
+ return [7 /*endfinally*/];
106
+ case 4: return [2 /*return*/];
103
107
  }
104
108
  });
105
109
  });
@@ -122,7 +126,7 @@ var Watermark = /** @class */ (function () {
122
126
  var _a, _b, _c, _d, _e, _f, _g, _h;
123
127
  (_b = (_a = this.options).onBeforeDestroy) === null || _b === void 0 ? void 0 : _b.call(_a);
124
128
  (_c = this.observer) === null || _c === void 0 ? void 0 : _c.disconnect();
125
- (_d = this.parentObserve) === null || _d === void 0 ? void 0 : _d.disconnect();
129
+ (_d = this.parentObserver) === null || _d === void 0 ? void 0 : _d.disconnect();
126
130
  (_f = (_e = this.watermarkDom) === null || _e === void 0 ? void 0 : _e.parentNode) === null || _f === void 0 ? void 0 : _f.removeChild(this.watermarkDom);
127
131
  (_h = (_g = this.options).onDestroyed) === null || _h === void 0 ? void 0 : _h.call(_g);
128
132
  };
@@ -182,64 +186,56 @@ var Watermark = /** @class */ (function () {
182
186
  }
183
187
  return 'custom';
184
188
  };
185
- Watermark.prototype.bindMutationObserve = function () {
186
- var _this = this;
187
- if (!this.watermarkDom) {
188
- return;
189
- }
190
- this.observer = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
191
- return __generator(this, function (_a) {
192
- switch (_a.label) {
189
+ Watermark.prototype.recreateOnMutation = function () {
190
+ return __awaiter(this, void 0, void 0, function () {
191
+ var _b, _c;
192
+ return __generator(this, function (_d) {
193
+ switch (_d.label) {
193
194
  case 0:
194
- if (!(mutationsList.length > 0)) return [3 /*break*/, 2];
195
+ _d.trys.push([0, 2, , 3]);
195
196
  this.remove();
196
197
  return [4 /*yield*/, this.create()];
197
198
  case 1:
198
- _a.sent();
199
- _a.label = 2;
200
- case 2: return [2 /*return*/];
199
+ _d.sent();
200
+ return [3 /*break*/, 3];
201
+ case 2:
202
+ _d.sent();
203
+ (_c = (_b = this.options).onObserveError) === null || _c === void 0 ? void 0 : _c.call(_b);
204
+ return [3 /*break*/, 3];
205
+ case 3: return [2 /*return*/];
201
206
  }
202
207
  });
203
- }); });
208
+ });
209
+ };
210
+ Watermark.prototype.bindMutationObserver = function () {
211
+ var _this = this;
212
+ if (!this.watermarkDom) {
213
+ return;
214
+ }
215
+ this.observer = new MutationObserver(function (mutationsList) {
216
+ if (mutationsList.length > 0) {
217
+ void _this.recreateOnMutation();
218
+ }
219
+ });
204
220
  this.observer.observe(this.watermarkDom, {
205
221
  attributes: true, // 属性的变动
222
+ attributeFilter: ['style', 'class', 'hidden', 'id'], // 仅监听会影响水印展示或标识的属性
206
223
  childList: true, // 子节点的变动(指新增,删除或者更改)
207
224
  subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
208
225
  characterData: true, // 节点内容或节点文本的变动。
209
226
  });
210
- this.parentObserve = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
211
- var _i, mutationsList_1, item;
212
- var _a;
213
- return __generator(this, function (_b) {
214
- switch (_b.label) {
215
- case 0:
216
- _i = 0, mutationsList_1 = mutationsList;
217
- _b.label = 1;
218
- case 1:
219
- if (!(_i < mutationsList_1.length)) return [3 /*break*/, 4];
220
- item = mutationsList_1[_i];
221
- if (!((item === null || item === void 0 ? void 0 : item.target) === this.watermarkDom ||
222
- ((_a = item === null || item === void 0 ? void 0 : item.removedNodes) === null || _a === void 0 ? void 0 : _a[0]) === this.watermarkDom ||
223
- (item.type === 'childList' &&
224
- item.target === this.parentElement &&
225
- item.target.lastChild !== this.watermarkDom))) return [3 /*break*/, 3];
226
- this.remove();
227
- return [4 /*yield*/, this.create()];
228
- case 2:
229
- _b.sent();
230
- _b.label = 3;
231
- case 3:
232
- _i++;
233
- return [3 /*break*/, 1];
234
- case 4: return [2 /*return*/];
235
- }
236
- });
237
- }); });
238
- this.parentObserve.observe(this.parentElement, {
239
- attributes: true, // 属性的变动
227
+ this.parentObserver = new MutationObserver(function (mutationsList) {
228
+ var watermarkDom = _this.watermarkDom;
229
+ if (!watermarkDom) {
230
+ return;
231
+ }
232
+ var watermarkRemoved = mutationsList.some(function (item) { return Array.from(item.removedNodes).includes(watermarkDom); });
233
+ if (watermarkRemoved) {
234
+ void _this.recreateOnMutation();
235
+ }
236
+ });
237
+ this.parentObserver.observe(this.parentElement, {
240
238
  childList: true, // 子节点的变动(指新增,删除或者更改)
241
- subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
242
- characterData: true, // 节点内容或节点文本的变动。
243
239
  });
244
240
  };
245
241
  return Watermark;