watermark-js-plus 1.5.8 → 1.5.9

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 (62) hide show
  1. package/dist/ie/index.cjs.js +88 -78
  2. package/dist/ie/index.cjs.js.map +1 -1
  3. package/dist/ie/index.cjs.min.js +1 -1
  4. package/dist/ie/index.esm.js +88 -78
  5. package/dist/ie/index.esm.js.map +1 -1
  6. package/dist/ie/index.esm.min.js +1 -1
  7. package/dist/ie/index.iife.js +88 -78
  8. package/dist/ie/index.iife.js.map +1 -1
  9. package/dist/ie/index.iife.min.js +1 -1
  10. package/dist/ie/index.umd.js +88 -78
  11. package/dist/ie/index.umd.js.map +1 -1
  12. package/dist/ie/index.umd.min.js +1 -1
  13. package/dist/index.cjs.js +86 -76
  14. package/dist/index.cjs.js.map +1 -1
  15. package/dist/index.cjs.min.js +1 -1
  16. package/dist/index.esm.js +86 -76
  17. package/dist/index.esm.js.map +1 -1
  18. package/dist/index.esm.min.js +1 -1
  19. package/dist/index.iife.js +86 -76
  20. package/dist/index.iife.js.map +1 -1
  21. package/dist/index.iife.min.js +1 -1
  22. package/dist/index.umd.js +86 -76
  23. package/dist/index.umd.js.map +1 -1
  24. package/dist/index.umd.min.js +1 -1
  25. package/dist/types/{src/types → types}/index.d.ts +1 -0
  26. package/package.json +45 -32
  27. package/dist/ie/types/src/types/index.d.ts +0 -128
  28. package/dist/ie/types/tests/core/blind.test.d.ts +0 -1
  29. package/dist/ie/types/tests/core/image.test.d.ts +0 -1
  30. package/dist/ie/types/tests/core/watermark.test.d.ts +0 -1
  31. package/dist/ie/types/tests/utils/index.d.ts +0 -2
  32. package/dist/ie/types/tests/utils/index.test.d.ts +0 -1
  33. package/dist/types/src/core/blind.d.ts +0 -19
  34. package/dist/types/src/core/canvas.d.ts +0 -51
  35. package/dist/types/src/core/image.d.ts +0 -22
  36. package/dist/types/src/core/layout/grid.d.ts +0 -14
  37. package/dist/types/src/core/layout/index.d.ts +0 -4
  38. package/dist/types/src/core/watermark.d.ts +0 -48
  39. package/dist/types/src/index.d.ts +0 -5
  40. package/dist/types/src/index.ie.d.ts +0 -7
  41. package/dist/types/src/style/index.d.ts +0 -1
  42. package/dist/types/src/utils/index.d.ts +0 -14
  43. package/dist/types/src/utils/initialization.d.ts +0 -19
  44. package/dist/types/src/utils/protection.d.ts +0 -2
  45. package/dist/types/tests/core/blind.test.d.ts +0 -1
  46. package/dist/types/tests/core/image.test.d.ts +0 -1
  47. package/dist/types/tests/core/watermark.test.d.ts +0 -1
  48. package/dist/types/tests/utils/index.d.ts +0 -2
  49. package/dist/types/tests/utils/index.test.d.ts +0 -1
  50. /package/dist/{ie/types/src → types}/core/blind.d.ts +0 -0
  51. /package/dist/{ie/types/src → types}/core/canvas.d.ts +0 -0
  52. /package/dist/{ie/types/src → types}/core/image.d.ts +0 -0
  53. /package/dist/{ie/types/src → types}/core/layout/grid.d.ts +0 -0
  54. /package/dist/{ie/types/src → types}/core/layout/index.d.ts +0 -0
  55. /package/dist/{ie/types/src → types}/core/watermark.d.ts +0 -0
  56. /package/dist/{ie/types/src → types}/index.d.ts +0 -0
  57. /package/dist/{ie/types/src → types}/index.ie.d.ts +0 -0
  58. /package/dist/{ie/types/src → types}/style/index.d.ts +0 -0
  59. /package/dist/{ie/types/src → types}/utils/index.d.ts +0 -0
  60. /package/dist/{ie/types/src → types}/utils/initialization.d.ts +0 -0
  61. /package/dist/types/{src/utils → utils}/polyfill.d.ts +0 -0
  62. /package/dist/{ie/types/src → types}/utils/protection.d.ts +0 -0
package/dist/index.umd.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * watermark-js-plus v1.5.8
2
+ * watermark-js-plus v1.5.9
3
3
  * (c) 2022-2024 Michael Sun
4
4
  * Released under the MIT License.
5
5
  */
@@ -36,7 +36,7 @@
36
36
  }
37
37
  }
38
38
 
39
- var css_248z = "@keyframes watermark{0%{background-position:0 0}25%{background-position:100% 100%}50%{background-position:0 0}75%{background-position:100% -100%}to{background-position:0 0}}";
39
+ var css_248z = "@keyframes watermark{0%{background-position:0 0}25%{background-position:100% 100%}50%{background-position:100% 0}75%{background-position:0 100%}to{background-position:0 0}}";
40
40
  styleInject(css_248z);
41
41
 
42
42
  /******************************************************************************
@@ -53,7 +53,7 @@
53
53
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
54
54
  PERFORMANCE OF THIS SOFTWARE.
55
55
  ***************************************************************************** */
56
- /* global Reflect, Promise */
56
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
57
57
 
58
58
  var extendStatics = function(d, b) {
59
59
  extendStatics = Object.setPrototypeOf ||
@@ -92,8 +92,8 @@
92
92
  }
93
93
 
94
94
  function __generator(thisArg, body) {
95
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
96
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
95
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
96
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
97
97
  function verb(n) { return function (v) { return step([n, v]); }; }
98
98
  function step(op) {
99
99
  if (f) throw new TypeError("Generator is already executing.");
@@ -117,7 +117,12 @@
117
117
  } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
118
118
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
119
119
  }
120
- }
120
+ }
121
+
122
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
123
+ var e = new Error(message);
124
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
125
+ };
121
126
 
122
127
  var convertImage = function (canvas) {
123
128
  return canvas.toDataURL('image/png', 1);
@@ -168,7 +173,7 @@
168
173
  switch (_b.label) {
169
174
  case 0:
170
175
  svgElement = createSVGElement('svg', {
171
- xmlns: 'http://www.w3.org/2000/svg'
176
+ xmlns: 'http://www.w3.org/2000/svg',
172
177
  });
173
178
  bodyElement = document.createElement('div');
174
179
  bodyElement.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
@@ -190,14 +195,14 @@
190
195
  svgElement.setAttribute('height', height.toString());
191
196
  foreignObjectElement = createSVGElement('foreignObject', {
192
197
  width: width.toString(),
193
- height: height.toString()
198
+ height: height.toString(),
194
199
  });
195
200
  foreignObjectElement.appendChild(bodyElement);
196
201
  svgElement.appendChild(foreignObjectElement);
197
202
  return [2 /*return*/, {
198
203
  element: svgElement,
199
204
  width: width,
200
- height: height
205
+ height: height,
201
206
  }];
202
207
  }
203
208
  });
@@ -265,7 +270,8 @@
265
270
  var convertSVGToImage = function (svg) {
266
271
  var richContent = svg.outerHTML
267
272
  .replace(/<(img|br|input|hr|embed)(.*?)>/g, '<$1$2/>')
268
- .replace(/\n/g, '').replace(/\t/g, '')
273
+ .replace(/\n/g, '')
274
+ .replace(/\t/g, '')
269
275
  .replace(/#/g, '%23');
270
276
  return "data:image/svg+xml;charset=utf-8,".concat(richContent);
271
277
  };
@@ -281,7 +287,7 @@
281
287
  if (width === void 0) { width = undefined; }
282
288
  if (height === void 0) { height = undefined; }
283
289
  var image = new Image();
284
- image.setAttribute('crossOrigin', 'Anonymous');
290
+ image.setAttribute('crossOrigin', 'anonymous');
285
291
  !isUndefined(width) && (image.width = width);
286
292
  !isUndefined(height) && (image.height = height);
287
293
  image.src = url;
@@ -329,7 +335,7 @@
329
335
  onSuccess: function () { },
330
336
  onBeforeDestroy: function () { },
331
337
  onDestroyed: function () { },
332
- onObserveError: function () { }
338
+ onObserveError: function () { },
333
339
  };
334
340
  var generateRecommendOptions = function (canvas, options, args) {
335
341
  var ctx = canvas.getContext('2d');
@@ -342,7 +348,7 @@
342
348
  ctx.letterSpacing = options.letterSpacing;
343
349
  ctx.wordSpacing = options.wordSpacing;
344
350
  if (options === null || options === void 0 ? void 0 : options.rotate) {
345
- options.rotate = (360 - options.rotate % 360) * (Math.PI / 180);
351
+ options.rotate = (360 - (options.rotate % 360)) * (Math.PI / 180);
346
352
  }
347
353
  if (isUndefined(args.textRowMaxWidth)) {
348
354
  options.textRowMaxWidth = options.width;
@@ -351,21 +357,21 @@
351
357
  image: {
352
358
  rect: {
353
359
  width: options.imageWidth,
354
- height: options.imageHeight
360
+ height: options.imageHeight,
355
361
  },
356
362
  position: {
357
363
  x: 0,
358
- y: 0
359
- }
364
+ y: 0,
365
+ },
360
366
  },
361
367
  textLine: {
362
368
  data: [],
363
- yOffsetValue: 0
369
+ yOffsetValue: 0,
364
370
  },
365
371
  advancedStyleParams: {
366
372
  linear: {
367
373
  x0: 0,
368
- x1: 0
374
+ x1: 0,
369
375
  },
370
376
  radial: {
371
377
  x0: 0,
@@ -373,15 +379,15 @@
373
379
  r0: 0,
374
380
  x1: 0,
375
381
  y1: 0,
376
- r1: 0
382
+ r1: 0,
377
383
  },
378
384
  conic: {
379
385
  x: 0,
380
386
  y: 0,
381
- startAngle: 0
387
+ startAngle: 0,
382
388
  },
383
- pattern: {}
384
- }
389
+ pattern: {},
390
+ },
385
391
  };
386
392
  switch (options.contentType) {
387
393
  case 'text':
@@ -431,14 +437,14 @@
431
437
  result.advancedStyleParams.linear.x0 = -options.width / 2;
432
438
  result.advancedStyleParams.linear.x1 = options.width / 2;
433
439
  // result.advancedStyleParams.radial.x0 = 0
434
- result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
440
+ result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
435
441
  // result.advancedStyleParams.radial.r0 = 0
436
442
  // result.advancedStyleParams.radial.x1 = 0
437
443
  // result.advancedStyleParams.radial.y1 = 0
438
- result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
444
+ result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
439
445
  // result.advancedStyleParams.radial.r1 = options.width / 2
440
446
  // result.advancedStyleParams.conic.x = 0
441
- result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
447
+ result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
442
448
  break;
443
449
  case 'top-start':
444
450
  translateX = 0;
@@ -448,13 +454,13 @@
448
454
  result.advancedStyleParams.linear.x0 = 0;
449
455
  result.advancedStyleParams.linear.x1 = options.width;
450
456
  result.advancedStyleParams.radial.x0 = options.width / 2;
451
- result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
457
+ result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
452
458
  // result.advancedStyleParams.radial.r0 = 0
453
459
  result.advancedStyleParams.radial.x1 = options.width / 2;
454
- result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
460
+ result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
455
461
  // result.advancedStyleParams.radial.r1 = options.width / 2
456
462
  result.advancedStyleParams.conic.x = options.width / 2;
457
- result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
463
+ result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
458
464
  break;
459
465
  case 'top-end':
460
466
  translateX = options.width;
@@ -464,13 +470,13 @@
464
470
  result.advancedStyleParams.linear.x0 = 0;
465
471
  result.advancedStyleParams.linear.x1 = -options.width;
466
472
  result.advancedStyleParams.radial.x0 = -options.width / 2;
467
- result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
473
+ result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
468
474
  // result.advancedStyleParams.radial.r0 = 0
469
475
  result.advancedStyleParams.radial.x1 = -options.width / 2;
470
- result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
476
+ result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
471
477
  // result.advancedStyleParams.radial.r1 = options.width / 2
472
478
  result.advancedStyleParams.conic.x = -options.width / 2;
473
- result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
479
+ result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
474
480
  break;
475
481
  case 'bottom':
476
482
  translateX = options.width / 2;
@@ -480,13 +486,13 @@
480
486
  result.advancedStyleParams.linear.x0 = -options.width / 2;
481
487
  result.advancedStyleParams.linear.x1 = options.width / 2;
482
488
  // result.advancedStyleParams.radial.x0 = 0
483
- result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
489
+ result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
484
490
  // result.advancedStyleParams.radial.r0 = 0
485
491
  // result.advancedStyleParams.radial.x1 = 0
486
- result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
492
+ result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
487
493
  // result.advancedStyleParams.radial.r1 = options.width / 2
488
494
  result.advancedStyleParams.conic.x = 0;
489
- result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
495
+ result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
490
496
  break;
491
497
  case 'bottom-start':
492
498
  translateX = 0;
@@ -496,13 +502,13 @@
496
502
  result.advancedStyleParams.linear.x0 = 0;
497
503
  result.advancedStyleParams.linear.x1 = options.width;
498
504
  result.advancedStyleParams.radial.x0 = options.width / 2;
499
- result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
505
+ result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
500
506
  // result.advancedStyleParams.radial.r0 = 0
501
507
  result.advancedStyleParams.radial.x1 = options.width / 2;
502
- result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
508
+ result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
503
509
  // result.advancedStyleParams.radial.r1 = options.width / 2
504
510
  result.advancedStyleParams.conic.x = options.width / 2;
505
- result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
511
+ result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
506
512
  break;
507
513
  case 'bottom-end':
508
514
  translateX = options.width;
@@ -512,13 +518,13 @@
512
518
  result.advancedStyleParams.linear.x0 = 0;
513
519
  result.advancedStyleParams.linear.x1 = -options.width;
514
520
  result.advancedStyleParams.radial.x0 = -options.width / 2;
515
- result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
521
+ result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
516
522
  // result.advancedStyleParams.radial.r0 = 0
517
523
  result.advancedStyleParams.radial.x1 = -options.width / 2;
518
- result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
524
+ result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
519
525
  // result.advancedStyleParams.radial.r1 = options.width / 2
520
526
  result.advancedStyleParams.conic.x = -options.width / 2;
521
- result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
527
+ result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
522
528
  break;
523
529
  case 'left':
524
530
  translateX = 0;
@@ -560,12 +566,13 @@
560
566
  if (['text', 'multi-line-text'].includes(options.contentType)) {
561
567
  switch (options.textBaseline) {
562
568
  case 'middle':
563
- result.textLine.yOffsetValue = (result.textLine.data.length - 1) * options.lineHeight / 2;
569
+ result.textLine.yOffsetValue = ((result.textLine.data.length - 1) * options.lineHeight) / 2;
564
570
  break;
565
571
  case 'bottom':
566
572
  case 'alphabetic':
567
573
  case 'ideographic':
568
- result.textLine.yOffsetValue = (result.textLine.data.length - 1) * options.lineHeight + (options.lineHeight - parseInt(options.fontSize)) / 2;
574
+ result.textLine.yOffsetValue =
575
+ (result.textLine.data.length - 1) * options.lineHeight + (options.lineHeight - parseInt(options.fontSize)) / 2;
569
576
  break;
570
577
  case 'top':
571
578
  case 'hanging':
@@ -583,11 +590,11 @@
583
590
  if (need) {
584
591
  Object.defineProperty(window, 'MutationObserver', {
585
592
  writable: false,
586
- configurable: false
593
+ configurable: false,
587
594
  });
588
595
  Object.defineProperty(window, 'requestAnimationFrame', {
589
596
  writable: false,
590
- configurable: false
597
+ configurable: false,
591
598
  });
592
599
  }
593
600
  });
@@ -716,7 +723,7 @@
716
723
  };
717
724
  WatermarkCanvas.prototype.createLinearGradient = function (ctx) {
718
725
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
719
- var gradient = ctx.createLinearGradient(getValue((_c = (_b = (_a = this.options.advancedStyle) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.linear) === null || _c === void 0 ? void 0 : _c.x0, this.recommendOptions.advancedStyleParams.linear.x0), getValue((_f = (_e = (_d = this.options.advancedStyle) === null || _d === void 0 ? void 0 : _d.params) === null || _e === void 0 ? void 0 : _e.linear) === null || _f === void 0 ? void 0 : _f.y0, 0), getValue((_j = (_h = (_g = this.options.advancedStyle) === null || _g === void 0 ? void 0 : _g.params) === null || _h === void 0 ? void 0 : _h.linear) === null || _j === void 0 ? void 0 : _j.x1, this.recommendOptions.advancedStyleParams.linear.x1), getValue((_m = (_l = (_k = this.options.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.linear) === null || _m === void 0 ? void 0 : _m.y1, 0));
726
+ var gradient = ctx.createLinearGradient((getValue((_c = (_b = (_a = this.options.advancedStyle) === null || _a === void 0 ? void 0 : _a.params) === null || _b === void 0 ? void 0 : _b.linear) === null || _c === void 0 ? void 0 : _c.x0, this.recommendOptions.advancedStyleParams.linear.x0)), getValue((_f = (_e = (_d = this.options.advancedStyle) === null || _d === void 0 ? void 0 : _d.params) === null || _e === void 0 ? void 0 : _e.linear) === null || _f === void 0 ? void 0 : _f.y0, 0), (getValue((_j = (_h = (_g = this.options.advancedStyle) === null || _g === void 0 ? void 0 : _g.params) === null || _h === void 0 ? void 0 : _h.linear) === null || _j === void 0 ? void 0 : _j.x1, this.recommendOptions.advancedStyleParams.linear.x1)), getValue((_m = (_l = (_k = this.options.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.linear) === null || _m === void 0 ? void 0 : _m.y1, 0));
720
727
  (_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.colorStops) === null || _q === void 0 ? void 0 : _q.forEach(function (item) {
721
728
  gradient.addColorStop(item.offset, item.color);
722
729
  });
@@ -724,7 +731,7 @@
724
731
  };
725
732
  WatermarkCanvas.prototype.createConicGradient = function (ctx) {
726
733
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
727
- var gradient = ctx.createConicGradient(getValue((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.conic) === null || _d === void 0 ? void 0 : _d.startAngle, 0), getValue((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.conic) === null || _h === void 0 ? void 0 : _h.x, this.recommendOptions.advancedStyleParams.conic.x), getValue((_m = (_l = (_k = (_j = this.options) === null || _j === void 0 ? void 0 : _j.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.conic) === null || _m === void 0 ? void 0 : _m.y, this.recommendOptions.advancedStyleParams.conic.y));
734
+ var gradient = ctx.createConicGradient(getValue((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.conic) === null || _d === void 0 ? void 0 : _d.startAngle, 0), (getValue((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.conic) === null || _h === void 0 ? void 0 : _h.x, this.recommendOptions.advancedStyleParams.conic.x)), (getValue((_m = (_l = (_k = (_j = this.options) === null || _j === void 0 ? void 0 : _j.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.conic) === null || _m === void 0 ? void 0 : _m.y, this.recommendOptions.advancedStyleParams.conic.y)));
728
735
  (_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.colorStops) === null || _q === void 0 ? void 0 : _q.forEach(function (item) {
729
736
  gradient.addColorStop(item.offset, item.color);
730
737
  });
@@ -732,7 +739,7 @@
732
739
  };
733
740
  WatermarkCanvas.prototype.createRadialGradient = function (ctx) {
734
741
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
735
- var gradient = ctx.createRadialGradient(getValue((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.radial) === null || _d === void 0 ? void 0 : _d.x0, this.recommendOptions.advancedStyleParams.radial.x0), getValue((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.radial) === null || _h === void 0 ? void 0 : _h.y0, this.recommendOptions.advancedStyleParams.radial.y0), getValue((_m = (_l = (_k = (_j = this.options) === null || _j === void 0 ? void 0 : _j.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.radial) === null || _m === void 0 ? void 0 : _m.r0, this.recommendOptions.advancedStyleParams.radial.r0), getValue((_r = (_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.params) === null || _q === void 0 ? void 0 : _q.radial) === null || _r === void 0 ? void 0 : _r.x1, this.recommendOptions.advancedStyleParams.radial.x1), getValue((_v = (_u = (_t = (_s = this.options) === null || _s === void 0 ? void 0 : _s.advancedStyle) === null || _t === void 0 ? void 0 : _t.params) === null || _u === void 0 ? void 0 : _u.radial) === null || _v === void 0 ? void 0 : _v.y1, this.recommendOptions.advancedStyleParams.radial.y1), getValue((_z = (_y = (_x = (_w = this.options) === null || _w === void 0 ? void 0 : _w.advancedStyle) === null || _x === void 0 ? void 0 : _x.params) === null || _y === void 0 ? void 0 : _y.radial) === null || _z === void 0 ? void 0 : _z.r1, this.recommendOptions.advancedStyleParams.radial.r1));
742
+ var gradient = ctx.createRadialGradient((getValue((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.radial) === null || _d === void 0 ? void 0 : _d.x0, this.recommendOptions.advancedStyleParams.radial.x0)), (getValue((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.radial) === null || _h === void 0 ? void 0 : _h.y0, this.recommendOptions.advancedStyleParams.radial.y0)), (getValue((_m = (_l = (_k = (_j = this.options) === null || _j === void 0 ? void 0 : _j.advancedStyle) === null || _k === void 0 ? void 0 : _k.params) === null || _l === void 0 ? void 0 : _l.radial) === null || _m === void 0 ? void 0 : _m.r0, this.recommendOptions.advancedStyleParams.radial.r0)), (getValue((_r = (_q = (_p = (_o = this.options) === null || _o === void 0 ? void 0 : _o.advancedStyle) === null || _p === void 0 ? void 0 : _p.params) === null || _q === void 0 ? void 0 : _q.radial) === null || _r === void 0 ? void 0 : _r.x1, this.recommendOptions.advancedStyleParams.radial.x1)), (getValue((_v = (_u = (_t = (_s = this.options) === null || _s === void 0 ? void 0 : _s.advancedStyle) === null || _t === void 0 ? void 0 : _t.params) === null || _u === void 0 ? void 0 : _u.radial) === null || _v === void 0 ? void 0 : _v.y1, this.recommendOptions.advancedStyleParams.radial.y1)), (getValue((_z = (_y = (_x = (_w = this.options) === null || _w === void 0 ? void 0 : _w.advancedStyle) === null || _x === void 0 ? void 0 : _x.params) === null || _y === void 0 ? void 0 : _y.radial) === null || _z === void 0 ? void 0 : _z.r1, this.recommendOptions.advancedStyleParams.radial.r1)));
736
743
  (_2 = (_1 = (_0 = this.options) === null || _0 === void 0 ? void 0 : _0.advancedStyle) === null || _1 === void 0 ? void 0 : _1.colorStops) === null || _2 === void 0 ? void 0 : _2.forEach(function (item) {
737
744
  gradient.addColorStop(item.offset, item.color);
738
745
  });
@@ -740,7 +747,7 @@
740
747
  };
741
748
  WatermarkCanvas.prototype.createPattern = function (ctx) {
742
749
  var _a, _b, _c, _d, _e, _f, _g, _h;
743
- return ctx.createPattern((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.pattern) === null || _d === void 0 ? void 0 : _d.image, ((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.pattern) === null || _h === void 0 ? void 0 : _h.repetition) || '');
750
+ return ctx.createPattern(((_d = (_c = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.advancedStyle) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.pattern) === null || _d === void 0 ? void 0 : _d.image), ((_h = (_g = (_f = (_e = this.options) === null || _e === void 0 ? void 0 : _e.advancedStyle) === null || _f === void 0 ? void 0 : _f.params) === null || _g === void 0 ? void 0 : _g.pattern) === null || _h === void 0 ? void 0 : _h.repetition) || '');
744
751
  };
745
752
  WatermarkCanvas.prototype.setText = function (ctx, params) {
746
753
  var methodName = 'fillText';
@@ -754,7 +761,7 @@
754
761
  text: this.options.content,
755
762
  x: 0,
756
763
  y: 0 - this.recommendOptions.textLine.yOffsetValue,
757
- maxWidth: this.options.textRowMaxWidth || this.options.width
764
+ maxWidth: this.options.textRowMaxWidth || this.options.width,
758
765
  });
759
766
  resolve(ctx.canvas);
760
767
  };
@@ -788,7 +795,12 @@
788
795
  var lines = this.recommendOptions.textLine.data;
789
796
  var yOffsetValue = this.recommendOptions.textLine.yOffsetValue;
790
797
  lines.forEach(function (text, index) {
791
- _this.setText(ctx, { text: text, x: 0, y: _this.options.lineHeight * index - yOffsetValue, maxWidth: _this.options.textRowMaxWidth || _this.options.width });
798
+ _this.setText(ctx, {
799
+ text: text,
800
+ x: 0,
801
+ y: _this.options.lineHeight * index - yOffsetValue,
802
+ maxWidth: _this.options.textRowMaxWidth || _this.options.width,
803
+ });
792
804
  });
793
805
  resolve(ctx.canvas);
794
806
  };
@@ -815,10 +827,10 @@
815
827
  var rect = { width: this.options.imageWidth || 0, height: this.options.imageHeight || 0 };
816
828
  switch (true) {
817
829
  case rect.width !== 0 && rect.height === 0:
818
- rect.height = rect.width * image.height / image.width;
830
+ rect.height = (rect.width * image.height) / image.width;
819
831
  break;
820
832
  case rect.width === 0 && rect.height !== 0:
821
- rect.width = rect.height * image.width / image.height;
833
+ rect.width = (rect.height * image.width) / image.height;
822
834
  break;
823
835
  case rect.width === 0 && rect.height === 0:
824
836
  rect.width = image.width;
@@ -831,7 +843,7 @@
831
843
  var _a, _b;
832
844
  var result = {
833
845
  x: -imageWidth / 2,
834
- y: -imageHeight / 2
846
+ y: -imageHeight / 2,
835
847
  };
836
848
  switch (this.options.translatePlacement) {
837
849
  case 'top':
@@ -888,7 +900,7 @@
888
900
  }
889
901
  GridLayout.prototype.draw = function () {
890
902
  var _a, _b, _c, _d, _e, _f, _g, _h;
891
- var layoutCanvas = WatermarkCanvas.createCanvas(((_a = this.options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.width) || (this.partialWidth * this.cols + this.gap[0] * this.cols), ((_b = this.options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.height) || (this.partialHeight * this.rows + this.gap[1] * this.rows));
903
+ var layoutCanvas = WatermarkCanvas.createCanvas(((_a = this.options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.width) || this.partialWidth * this.cols + this.gap[0] * this.cols, ((_b = this.options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.height) || this.partialHeight * this.rows + this.gap[1] * this.rows);
892
904
  var layoutContext = layoutCanvas.getContext('2d');
893
905
  if ((_c = this.options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.backgroundImage) {
894
906
  layoutContext === null || layoutContext === void 0 ? void 0 : layoutContext.drawImage((_d = this.options.gridLayoutOptions) === null || _d === void 0 ? void 0 : _d.backgroundImage, 0, 0, (_e = this.options.gridLayoutOptions) === null || _e === void 0 ? void 0 : _e.width, (_f = this.options.gridLayoutOptions) === null || _f === void 0 ? void 0 : _f.height);
@@ -917,21 +929,14 @@
917
929
  var generateBackgroundSize = function (options) {
918
930
  var _a, _b, _c;
919
931
  switch (options.layout) {
920
- case 'grid':
921
- {
922
- var cols = ((_a = options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.cols) || 1;
923
- var rows = ((_b = options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.rows) || 1;
924
- var gap = ((_c = options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.gap) || [0, 0];
925
- return [
926
- options.width * cols + gap[0] * cols,
927
- options.height * rows + gap[1] * rows
928
- ];
929
- }
932
+ case 'grid': {
933
+ var cols = ((_a = options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.cols) || 1;
934
+ var rows = ((_b = options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.rows) || 1;
935
+ var gap = ((_c = options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.gap) || [0, 0];
936
+ return [options.width * cols + gap[0] * cols, options.height * rows + gap[1] * rows];
937
+ }
930
938
  default:
931
- return [
932
- options.width,
933
- options.height
934
- ];
939
+ return [options.width, options.height];
935
940
  }
936
941
  };
937
942
 
@@ -1016,14 +1021,14 @@
1016
1021
  parentElementType = this.checkParentElementType();
1017
1022
  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 ");
1018
1023
  backgroundSize = generateBackgroundSize(this.options);
1019
- 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(this.options.movable ? 'animation: 200s ease 0s infinite normal none running watermark !important;' : '', "\n ");
1024
+ 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(this.options.movable ? 'animation: 200s linear 0s infinite alternate watermark !important;' : '', "\n ");
1020
1025
  this.watermarkDom.appendChild(watermarkInnerDom);
1021
1026
  this.parentElement.appendChild(this.watermarkDom);
1022
1027
  if (this.options.mutationObserve) {
1023
1028
  try {
1024
1029
  this.bindMutationObserve();
1025
1030
  }
1026
- catch (e) {
1031
+ catch (_j) {
1027
1032
  (_e = (_d = this.options).onObserveError) === null || _e === void 0 ? void 0 : _e.call(_d);
1028
1033
  }
1029
1034
  }
@@ -1155,7 +1160,7 @@
1155
1160
  attributes: true, // 属性的变动
1156
1161
  childList: true, // 子节点的变动(指新增,删除或者更改)
1157
1162
  subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
1158
- characterData: true // 节点内容或节点文本的变动。
1163
+ characterData: true, // 节点内容或节点文本的变动。
1159
1164
  });
1160
1165
  this.parentObserve = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
1161
1166
  var _i, mutationsList_1, item;
@@ -1170,7 +1175,9 @@
1170
1175
  item = mutationsList_1[_i];
1171
1176
  if (!((item === null || item === void 0 ? void 0 : item.target) === this.watermarkDom ||
1172
1177
  ((_a = item === null || item === void 0 ? void 0 : item.removedNodes) === null || _a === void 0 ? void 0 : _a[0]) === this.watermarkDom ||
1173
- (item.type === 'childList' && item.target === this.parentElement && item.target.lastChild !== this.watermarkDom))) return [3 /*break*/, 3];
1178
+ (item.type === 'childList' &&
1179
+ item.target === this.parentElement &&
1180
+ item.target.lastChild !== this.watermarkDom))) return [3 /*break*/, 3];
1174
1181
  this.remove();
1175
1182
  return [4 /*yield*/, this.create()];
1176
1183
  case 2:
@@ -1187,7 +1194,7 @@
1187
1194
  attributes: true, // 属性的变动
1188
1195
  childList: true, // 子节点的变动(指新增,删除或者更改)
1189
1196
  subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
1190
- characterData: true // 节点内容或节点文本的变动。
1197
+ characterData: true, // 节点内容或节点文本的变动。
1191
1198
  });
1192
1199
  };
1193
1200
  Watermark.prototype.bindCheckWatermarkElementEvent = function () {
@@ -1215,7 +1222,7 @@
1215
1222
  if (props === void 0) { props = {}; }
1216
1223
  var defaultProps = {
1217
1224
  globalAlpha: 0.005,
1218
- mode: 'blind'
1225
+ mode: 'blind',
1219
1226
  };
1220
1227
  return _super.call(this, __assign(__assign({}, props), defaultProps)) || this;
1221
1228
  }
@@ -1287,12 +1294,15 @@
1287
1294
  */
1288
1295
  function ImageWatermark(args) {
1289
1296
  if (args === void 0) { args = {}; }
1290
- var _a;
1297
+ var _a, _b;
1291
1298
  this.drew = false;
1292
1299
  this.props = args;
1293
1300
  this.options = __assign(__assign({}, initialOptions), args);
1301
+ if (this.props.crossOrigin) {
1302
+ (_a = this.props.dom) === null || _a === void 0 ? void 0 : _a.setAttribute('crossOrigin', 'anonymous');
1303
+ }
1294
1304
  this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
1295
- this.originalSrc = (_a = this.props.dom) === null || _a === void 0 ? void 0 : _a.src;
1305
+ this.originalSrc = (_b = this.props.dom) === null || _b === void 0 ? void 0 : _b.src;
1296
1306
  this.backgroundImage = this.getBackgroundImage();
1297
1307
  }
1298
1308
  ImageWatermark.prototype.create = function () {