watermark-js-plus 1.5.8 → 1.6.0

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 +107 -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 +107 -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 +107 -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 +107 -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 +105 -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 +105 -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 +105 -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 +105 -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/dist/{ie/types/src → types}/utils/index.d.ts +1 -0
  27. package/package.json +45 -32
  28. package/dist/ie/types/src/types/index.d.ts +0 -128
  29. package/dist/ie/types/tests/core/blind.test.d.ts +0 -1
  30. package/dist/ie/types/tests/core/image.test.d.ts +0 -1
  31. package/dist/ie/types/tests/core/watermark.test.d.ts +0 -1
  32. package/dist/ie/types/tests/utils/index.d.ts +0 -2
  33. package/dist/ie/types/tests/utils/index.test.d.ts +0 -1
  34. package/dist/types/src/core/blind.d.ts +0 -19
  35. package/dist/types/src/core/canvas.d.ts +0 -51
  36. package/dist/types/src/core/image.d.ts +0 -22
  37. package/dist/types/src/core/layout/grid.d.ts +0 -14
  38. package/dist/types/src/core/layout/index.d.ts +0 -4
  39. package/dist/types/src/core/watermark.d.ts +0 -48
  40. package/dist/types/src/index.d.ts +0 -5
  41. package/dist/types/src/index.ie.d.ts +0 -7
  42. package/dist/types/src/style/index.d.ts +0 -1
  43. package/dist/types/src/utils/index.d.ts +0 -14
  44. package/dist/types/src/utils/initialization.d.ts +0 -19
  45. package/dist/types/src/utils/protection.d.ts +0 -2
  46. package/dist/types/tests/core/blind.test.d.ts +0 -1
  47. package/dist/types/tests/core/image.test.d.ts +0 -1
  48. package/dist/types/tests/core/watermark.test.d.ts +0 -1
  49. package/dist/types/tests/utils/index.d.ts +0 -2
  50. package/dist/types/tests/utils/index.test.d.ts +0 -1
  51. /package/dist/{ie/types/src → types}/core/blind.d.ts +0 -0
  52. /package/dist/{ie/types/src → types}/core/canvas.d.ts +0 -0
  53. /package/dist/{ie/types/src → types}/core/image.d.ts +0 -0
  54. /package/dist/{ie/types/src → types}/core/layout/grid.d.ts +0 -0
  55. /package/dist/{ie/types/src → types}/core/layout/index.d.ts +0 -0
  56. /package/dist/{ie/types/src → types}/core/watermark.d.ts +0 -0
  57. /package/dist/{ie/types/src → types}/index.d.ts +0 -0
  58. /package/dist/{ie/types/src → types}/index.ie.d.ts +0 -0
  59. /package/dist/{ie/types/src → types}/style/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
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * watermark-js-plus v1.5.8
2
+ * watermark-js-plus v1.6.0
3
3
  * (c) 2022-2024 Michael Sun
4
4
  * Released under the MIT License.
5
5
  */
@@ -560,10 +560,10 @@
560
560
  var store = sharedStore.exports = globalThis[SHARED] || defineGlobalProperty(SHARED, {});
561
561
 
562
562
  (store.versions || (store.versions = [])).push({
563
- version: '3.40.0',
563
+ version: '3.41.0',
564
564
  mode: IS_PURE ? 'pure' : 'global',
565
565
  copyright: '© 2014-2025 Denis Pushkarev (zloirock.ru)',
566
- license: 'https://github.com/zloirock/core-js/blob/v3.40.0/LICENSE',
566
+ license: 'https://github.com/zloirock/core-js/blob/v3.41.0/LICENSE',
567
567
  source: 'https://github.com/zloirock/core-js'
568
568
  });
569
569
  return sharedStore.exports;
@@ -4219,7 +4219,7 @@
4219
4219
  }
4220
4220
  }
4221
4221
 
4222
- 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}}";
4222
+ 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}}@keyframes watermark-horizontal{0%{background-position-x:0}to{background-position-x:100%}}@keyframes watermark-vertical{0%{background-position-y:0}to{background-position-y:100%}}";
4223
4223
  styleInject(css_248z);
4224
4224
 
4225
4225
  /******************************************************************************
@@ -4236,7 +4236,7 @@
4236
4236
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
4237
4237
  PERFORMANCE OF THIS SOFTWARE.
4238
4238
  ***************************************************************************** */
4239
- /* global Reflect, Promise */
4239
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
4240
4240
 
4241
4241
  var extendStatics = function(d, b) {
4242
4242
  extendStatics = Object.setPrototypeOf ||
@@ -4275,8 +4275,8 @@
4275
4275
  }
4276
4276
 
4277
4277
  function __generator(thisArg, body) {
4278
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
4279
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4278
+ 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);
4279
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
4280
4280
  function verb(n) { return function (v) { return step([n, v]); }; }
4281
4281
  function step(op) {
4282
4282
  if (f) throw new TypeError("Generator is already executing.");
@@ -4300,7 +4300,12 @@
4300
4300
  } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
4301
4301
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
4302
4302
  }
4303
- }
4303
+ }
4304
+
4305
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
4306
+ var e = new Error(message);
4307
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
4308
+ };
4304
4309
 
4305
4310
  var convertImage = function (canvas) {
4306
4311
  return canvas.toDataURL('image/png', 1);
@@ -4351,7 +4356,7 @@
4351
4356
  switch (_b.label) {
4352
4357
  case 0:
4353
4358
  svgElement = createSVGElement('svg', {
4354
- xmlns: 'http://www.w3.org/2000/svg'
4359
+ xmlns: 'http://www.w3.org/2000/svg',
4355
4360
  });
4356
4361
  bodyElement = document.createElement('div');
4357
4362
  bodyElement.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
@@ -4373,14 +4378,14 @@
4373
4378
  svgElement.setAttribute('height', height.toString());
4374
4379
  foreignObjectElement = createSVGElement('foreignObject', {
4375
4380
  width: width.toString(),
4376
- height: height.toString()
4381
+ height: height.toString(),
4377
4382
  });
4378
4383
  foreignObjectElement.appendChild(bodyElement);
4379
4384
  svgElement.appendChild(foreignObjectElement);
4380
4385
  return [2 /*return*/, {
4381
4386
  element: svgElement,
4382
4387
  width: width,
4383
- height: height
4388
+ height: height,
4384
4389
  }];
4385
4390
  }
4386
4391
  });
@@ -4448,7 +4453,8 @@
4448
4453
  var convertSVGToImage = function (svg) {
4449
4454
  var richContent = svg.outerHTML
4450
4455
  .replace(/<(img|br|input|hr|embed)(.*?)>/g, '<$1$2/>')
4451
- .replace(/\n/g, '').replace(/\t/g, '')
4456
+ .replace(/\n/g, '')
4457
+ .replace(/\t/g, '')
4452
4458
  .replace(/#/g, '%23');
4453
4459
  return "data:image/svg+xml;charset=utf-8,".concat(richContent);
4454
4460
  };
@@ -4464,7 +4470,7 @@
4464
4470
  if (width === void 0) { width = undefined; }
4465
4471
  if (height === void 0) { height = undefined; }
4466
4472
  var image = new Image();
4467
- image.setAttribute('crossOrigin', 'Anonymous');
4473
+ image.setAttribute('crossOrigin', 'anonymous');
4468
4474
  !isUndefined(width) && (image.width = width);
4469
4475
  !isUndefined(height) && (image.height = height);
4470
4476
  image.src = url;
@@ -4477,6 +4483,25 @@
4477
4483
  var generateMatrix = function (rows, columns, value) {
4478
4484
  return Array.from({ length: rows }, function () { return new Array(columns).fill(value); });
4479
4485
  };
4486
+ var generateAnimationStyle = function (movable, backgroundRepeat) {
4487
+ if (!movable) {
4488
+ return '';
4489
+ }
4490
+ var horizontalDuration = Math.random() * (8 - 2) + 2;
4491
+ var verticalDuration = Math.random() * (4 - 2) + 2;
4492
+ switch (backgroundRepeat) {
4493
+ case 'repeat':
4494
+ return 'animation: 200s linear 0s infinite alternate watermark !important;';
4495
+ case 'repeat-x':
4496
+ return "animation: ".concat(horizontalDuration, "s ease-in 0s infinite alternate watermark-vertical !important;'");
4497
+ case 'repeat-y':
4498
+ return "animation: ".concat(verticalDuration, "s ease-out 0s infinite alternate watermark-horizontal !important;'");
4499
+ case 'no-repeat':
4500
+ return "animation: ".concat(horizontalDuration, "s ease-in 0s infinite alternate watermark-horizontal, ").concat(verticalDuration, "s ease-out 0s infinite alternate watermark-vertical !important;");
4501
+ default:
4502
+ return '';
4503
+ }
4504
+ };
4480
4505
 
4481
4506
  var initialOptions = {
4482
4507
  width: 300,
@@ -4512,7 +4537,7 @@
4512
4537
  onSuccess: function () { },
4513
4538
  onBeforeDestroy: function () { },
4514
4539
  onDestroyed: function () { },
4515
- onObserveError: function () { }
4540
+ onObserveError: function () { },
4516
4541
  };
4517
4542
  var generateRecommendOptions = function (canvas, options, args) {
4518
4543
  var ctx = canvas.getContext('2d');
@@ -4525,7 +4550,7 @@
4525
4550
  ctx.letterSpacing = options.letterSpacing;
4526
4551
  ctx.wordSpacing = options.wordSpacing;
4527
4552
  if (options === null || options === void 0 ? void 0 : options.rotate) {
4528
- options.rotate = (360 - options.rotate % 360) * (Math.PI / 180);
4553
+ options.rotate = (360 - (options.rotate % 360)) * (Math.PI / 180);
4529
4554
  }
4530
4555
  if (isUndefined(args.textRowMaxWidth)) {
4531
4556
  options.textRowMaxWidth = options.width;
@@ -4534,21 +4559,21 @@
4534
4559
  image: {
4535
4560
  rect: {
4536
4561
  width: options.imageWidth,
4537
- height: options.imageHeight
4562
+ height: options.imageHeight,
4538
4563
  },
4539
4564
  position: {
4540
4565
  x: 0,
4541
- y: 0
4542
- }
4566
+ y: 0,
4567
+ },
4543
4568
  },
4544
4569
  textLine: {
4545
4570
  data: [],
4546
- yOffsetValue: 0
4571
+ yOffsetValue: 0,
4547
4572
  },
4548
4573
  advancedStyleParams: {
4549
4574
  linear: {
4550
4575
  x0: 0,
4551
- x1: 0
4576
+ x1: 0,
4552
4577
  },
4553
4578
  radial: {
4554
4579
  x0: 0,
@@ -4556,15 +4581,15 @@
4556
4581
  r0: 0,
4557
4582
  x1: 0,
4558
4583
  y1: 0,
4559
- r1: 0
4584
+ r1: 0,
4560
4585
  },
4561
4586
  conic: {
4562
4587
  x: 0,
4563
4588
  y: 0,
4564
- startAngle: 0
4589
+ startAngle: 0,
4565
4590
  },
4566
- pattern: {}
4567
- }
4591
+ pattern: {},
4592
+ },
4568
4593
  };
4569
4594
  switch (options.contentType) {
4570
4595
  case 'text':
@@ -4614,14 +4639,14 @@
4614
4639
  result.advancedStyleParams.linear.x0 = -options.width / 2;
4615
4640
  result.advancedStyleParams.linear.x1 = options.width / 2;
4616
4641
  // result.advancedStyleParams.radial.x0 = 0
4617
- result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
4642
+ result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
4618
4643
  // result.advancedStyleParams.radial.r0 = 0
4619
4644
  // result.advancedStyleParams.radial.x1 = 0
4620
4645
  // result.advancedStyleParams.radial.y1 = 0
4621
- result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
4646
+ result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
4622
4647
  // result.advancedStyleParams.radial.r1 = options.width / 2
4623
4648
  // result.advancedStyleParams.conic.x = 0
4624
- result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
4649
+ result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
4625
4650
  break;
4626
4651
  case 'top-start':
4627
4652
  translateX = 0;
@@ -4631,13 +4656,13 @@
4631
4656
  result.advancedStyleParams.linear.x0 = 0;
4632
4657
  result.advancedStyleParams.linear.x1 = options.width;
4633
4658
  result.advancedStyleParams.radial.x0 = options.width / 2;
4634
- result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
4659
+ result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
4635
4660
  // result.advancedStyleParams.radial.r0 = 0
4636
4661
  result.advancedStyleParams.radial.x1 = options.width / 2;
4637
- result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
4662
+ result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
4638
4663
  // result.advancedStyleParams.radial.r1 = options.width / 2
4639
4664
  result.advancedStyleParams.conic.x = options.width / 2;
4640
- result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
4665
+ result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
4641
4666
  break;
4642
4667
  case 'top-end':
4643
4668
  translateX = options.width;
@@ -4647,13 +4672,13 @@
4647
4672
  result.advancedStyleParams.linear.x0 = 0;
4648
4673
  result.advancedStyleParams.linear.x1 = -options.width;
4649
4674
  result.advancedStyleParams.radial.x0 = -options.width / 2;
4650
- result.advancedStyleParams.radial.y0 = result.textLine.data.length * options.lineHeight / 2;
4675
+ result.advancedStyleParams.radial.y0 = (result.textLine.data.length * options.lineHeight) / 2;
4651
4676
  // result.advancedStyleParams.radial.r0 = 0
4652
4677
  result.advancedStyleParams.radial.x1 = -options.width / 2;
4653
- result.advancedStyleParams.radial.y1 = result.textLine.data.length * options.lineHeight / 2;
4678
+ result.advancedStyleParams.radial.y1 = (result.textLine.data.length * options.lineHeight) / 2;
4654
4679
  // result.advancedStyleParams.radial.r1 = options.width / 2
4655
4680
  result.advancedStyleParams.conic.x = -options.width / 2;
4656
- result.advancedStyleParams.conic.y = result.textLine.data.length * options.lineHeight / 2;
4681
+ result.advancedStyleParams.conic.y = (result.textLine.data.length * options.lineHeight) / 2;
4657
4682
  break;
4658
4683
  case 'bottom':
4659
4684
  translateX = options.width / 2;
@@ -4663,13 +4688,13 @@
4663
4688
  result.advancedStyleParams.linear.x0 = -options.width / 2;
4664
4689
  result.advancedStyleParams.linear.x1 = options.width / 2;
4665
4690
  // result.advancedStyleParams.radial.x0 = 0
4666
- result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
4691
+ result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
4667
4692
  // result.advancedStyleParams.radial.r0 = 0
4668
4693
  // result.advancedStyleParams.radial.x1 = 0
4669
- result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
4694
+ result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
4670
4695
  // result.advancedStyleParams.radial.r1 = options.width / 2
4671
4696
  result.advancedStyleParams.conic.x = 0;
4672
- result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
4697
+ result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
4673
4698
  break;
4674
4699
  case 'bottom-start':
4675
4700
  translateX = 0;
@@ -4679,13 +4704,13 @@
4679
4704
  result.advancedStyleParams.linear.x0 = 0;
4680
4705
  result.advancedStyleParams.linear.x1 = options.width;
4681
4706
  result.advancedStyleParams.radial.x0 = options.width / 2;
4682
- result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
4707
+ result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
4683
4708
  // result.advancedStyleParams.radial.r0 = 0
4684
4709
  result.advancedStyleParams.radial.x1 = options.width / 2;
4685
- result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
4710
+ result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
4686
4711
  // result.advancedStyleParams.radial.r1 = options.width / 2
4687
4712
  result.advancedStyleParams.conic.x = options.width / 2;
4688
- result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
4713
+ result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
4689
4714
  break;
4690
4715
  case 'bottom-end':
4691
4716
  translateX = options.width;
@@ -4695,13 +4720,13 @@
4695
4720
  result.advancedStyleParams.linear.x0 = 0;
4696
4721
  result.advancedStyleParams.linear.x1 = -options.width;
4697
4722
  result.advancedStyleParams.radial.x0 = -options.width / 2;
4698
- result.advancedStyleParams.radial.y0 = -result.textLine.data.length * options.lineHeight / 2;
4723
+ result.advancedStyleParams.radial.y0 = (-result.textLine.data.length * options.lineHeight) / 2;
4699
4724
  // result.advancedStyleParams.radial.r0 = 0
4700
4725
  result.advancedStyleParams.radial.x1 = -options.width / 2;
4701
- result.advancedStyleParams.radial.y1 = -result.textLine.data.length * options.lineHeight / 2;
4726
+ result.advancedStyleParams.radial.y1 = (-result.textLine.data.length * options.lineHeight) / 2;
4702
4727
  // result.advancedStyleParams.radial.r1 = options.width / 2
4703
4728
  result.advancedStyleParams.conic.x = -options.width / 2;
4704
- result.advancedStyleParams.conic.y = -result.textLine.data.length * options.lineHeight / 2;
4729
+ result.advancedStyleParams.conic.y = (-result.textLine.data.length * options.lineHeight) / 2;
4705
4730
  break;
4706
4731
  case 'left':
4707
4732
  translateX = 0;
@@ -4743,12 +4768,13 @@
4743
4768
  if (['text', 'multi-line-text'].includes(options.contentType)) {
4744
4769
  switch (options.textBaseline) {
4745
4770
  case 'middle':
4746
- result.textLine.yOffsetValue = (result.textLine.data.length - 1) * options.lineHeight / 2;
4771
+ result.textLine.yOffsetValue = ((result.textLine.data.length - 1) * options.lineHeight) / 2;
4747
4772
  break;
4748
4773
  case 'bottom':
4749
4774
  case 'alphabetic':
4750
4775
  case 'ideographic':
4751
- result.textLine.yOffsetValue = (result.textLine.data.length - 1) * options.lineHeight + (options.lineHeight - parseInt(options.fontSize)) / 2;
4776
+ result.textLine.yOffsetValue =
4777
+ (result.textLine.data.length - 1) * options.lineHeight + (options.lineHeight - parseInt(options.fontSize)) / 2;
4752
4778
  break;
4753
4779
  case 'top':
4754
4780
  case 'hanging':
@@ -4766,11 +4792,11 @@
4766
4792
  if (need) {
4767
4793
  Object.defineProperty(window, 'MutationObserver', {
4768
4794
  writable: false,
4769
- configurable: false
4795
+ configurable: false,
4770
4796
  });
4771
4797
  Object.defineProperty(window, 'requestAnimationFrame', {
4772
4798
  writable: false,
4773
- configurable: false
4799
+ configurable: false,
4774
4800
  });
4775
4801
  }
4776
4802
  });
@@ -4899,7 +4925,7 @@
4899
4925
  };
4900
4926
  WatermarkCanvas.prototype.createLinearGradient = function (ctx) {
4901
4927
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
4902
- 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));
4928
+ 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));
4903
4929
  (_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) {
4904
4930
  gradient.addColorStop(item.offset, item.color);
4905
4931
  });
@@ -4907,7 +4933,7 @@
4907
4933
  };
4908
4934
  WatermarkCanvas.prototype.createConicGradient = function (ctx) {
4909
4935
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
4910
- 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));
4936
+ 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)));
4911
4937
  (_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) {
4912
4938
  gradient.addColorStop(item.offset, item.color);
4913
4939
  });
@@ -4915,7 +4941,7 @@
4915
4941
  };
4916
4942
  WatermarkCanvas.prototype.createRadialGradient = function (ctx) {
4917
4943
  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;
4918
- 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));
4944
+ 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)));
4919
4945
  (_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) {
4920
4946
  gradient.addColorStop(item.offset, item.color);
4921
4947
  });
@@ -4923,7 +4949,7 @@
4923
4949
  };
4924
4950
  WatermarkCanvas.prototype.createPattern = function (ctx) {
4925
4951
  var _a, _b, _c, _d, _e, _f, _g, _h;
4926
- 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) || '');
4952
+ 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) || '');
4927
4953
  };
4928
4954
  WatermarkCanvas.prototype.setText = function (ctx, params) {
4929
4955
  var methodName = 'fillText';
@@ -4937,7 +4963,7 @@
4937
4963
  text: this.options.content,
4938
4964
  x: 0,
4939
4965
  y: 0 - this.recommendOptions.textLine.yOffsetValue,
4940
- maxWidth: this.options.textRowMaxWidth || this.options.width
4966
+ maxWidth: this.options.textRowMaxWidth || this.options.width,
4941
4967
  });
4942
4968
  resolve(ctx.canvas);
4943
4969
  };
@@ -4971,7 +4997,12 @@
4971
4997
  var lines = this.recommendOptions.textLine.data;
4972
4998
  var yOffsetValue = this.recommendOptions.textLine.yOffsetValue;
4973
4999
  lines.forEach(function (text, index) {
4974
- _this.setText(ctx, { text: text, x: 0, y: _this.options.lineHeight * index - yOffsetValue, maxWidth: _this.options.textRowMaxWidth || _this.options.width });
5000
+ _this.setText(ctx, {
5001
+ text: text,
5002
+ x: 0,
5003
+ y: _this.options.lineHeight * index - yOffsetValue,
5004
+ maxWidth: _this.options.textRowMaxWidth || _this.options.width,
5005
+ });
4975
5006
  });
4976
5007
  resolve(ctx.canvas);
4977
5008
  };
@@ -4998,10 +5029,10 @@
4998
5029
  var rect = { width: this.options.imageWidth || 0, height: this.options.imageHeight || 0 };
4999
5030
  switch (true) {
5000
5031
  case rect.width !== 0 && rect.height === 0:
5001
- rect.height = rect.width * image.height / image.width;
5032
+ rect.height = (rect.width * image.height) / image.width;
5002
5033
  break;
5003
5034
  case rect.width === 0 && rect.height !== 0:
5004
- rect.width = rect.height * image.width / image.height;
5035
+ rect.width = (rect.height * image.width) / image.height;
5005
5036
  break;
5006
5037
  case rect.width === 0 && rect.height === 0:
5007
5038
  rect.width = image.width;
@@ -5014,7 +5045,7 @@
5014
5045
  var _a, _b;
5015
5046
  var result = {
5016
5047
  x: -imageWidth / 2,
5017
- y: -imageHeight / 2
5048
+ y: -imageHeight / 2,
5018
5049
  };
5019
5050
  switch (this.options.translatePlacement) {
5020
5051
  case 'top':
@@ -5071,7 +5102,7 @@
5071
5102
  }
5072
5103
  GridLayout.prototype.draw = function () {
5073
5104
  var _a, _b, _c, _d, _e, _f, _g, _h;
5074
- 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));
5105
+ 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);
5075
5106
  var layoutContext = layoutCanvas.getContext('2d');
5076
5107
  if ((_c = this.options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.backgroundImage) {
5077
5108
  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);
@@ -5100,21 +5131,14 @@
5100
5131
  var generateBackgroundSize = function (options) {
5101
5132
  var _a, _b, _c;
5102
5133
  switch (options.layout) {
5103
- case 'grid':
5104
- {
5105
- var cols = ((_a = options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.cols) || 1;
5106
- var rows = ((_b = options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.rows) || 1;
5107
- var gap = ((_c = options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.gap) || [0, 0];
5108
- return [
5109
- options.width * cols + gap[0] * cols,
5110
- options.height * rows + gap[1] * rows
5111
- ];
5112
- }
5134
+ case 'grid': {
5135
+ var cols = ((_a = options.gridLayoutOptions) === null || _a === void 0 ? void 0 : _a.cols) || 1;
5136
+ var rows = ((_b = options.gridLayoutOptions) === null || _b === void 0 ? void 0 : _b.rows) || 1;
5137
+ var gap = ((_c = options.gridLayoutOptions) === null || _c === void 0 ? void 0 : _c.gap) || [0, 0];
5138
+ return [options.width * cols + gap[0] * cols, options.height * rows + gap[1] * rows];
5139
+ }
5113
5140
  default:
5114
- return [
5115
- options.width,
5116
- options.height
5117
- ];
5141
+ return [options.width, options.height];
5118
5142
  }
5119
5143
  };
5120
5144
 
@@ -5199,14 +5223,14 @@
5199
5223
  parentElementType = this.checkParentElementType();
5200
5224
  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 ");
5201
5225
  backgroundSize = generateBackgroundSize(this.options);
5202
- 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 ");
5226
+ 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 ");
5203
5227
  this.watermarkDom.appendChild(watermarkInnerDom);
5204
5228
  this.parentElement.appendChild(this.watermarkDom);
5205
5229
  if (this.options.mutationObserve) {
5206
5230
  try {
5207
5231
  this.bindMutationObserve();
5208
5232
  }
5209
- catch (e) {
5233
+ catch (_j) {
5210
5234
  (_e = (_d = this.options).onObserveError) === null || _e === void 0 ? void 0 : _e.call(_d);
5211
5235
  }
5212
5236
  }
@@ -5338,7 +5362,7 @@
5338
5362
  attributes: true, // 属性的变动
5339
5363
  childList: true, // 子节点的变动(指新增,删除或者更改)
5340
5364
  subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
5341
- characterData: true // 节点内容或节点文本的变动。
5365
+ characterData: true, // 节点内容或节点文本的变动。
5342
5366
  });
5343
5367
  this.parentObserve = new MutationObserver(function (mutationsList) { return __awaiter(_this, void 0, void 0, function () {
5344
5368
  var _i, mutationsList_1, item;
@@ -5353,7 +5377,9 @@
5353
5377
  item = mutationsList_1[_i];
5354
5378
  if (!((item === null || item === void 0 ? void 0 : item.target) === this.watermarkDom ||
5355
5379
  ((_a = item === null || item === void 0 ? void 0 : item.removedNodes) === null || _a === void 0 ? void 0 : _a[0]) === this.watermarkDom ||
5356
- (item.type === 'childList' && item.target === this.parentElement && item.target.lastChild !== this.watermarkDom))) return [3 /*break*/, 3];
5380
+ (item.type === 'childList' &&
5381
+ item.target === this.parentElement &&
5382
+ item.target.lastChild !== this.watermarkDom))) return [3 /*break*/, 3];
5357
5383
  this.remove();
5358
5384
  return [4 /*yield*/, this.create()];
5359
5385
  case 2:
@@ -5370,7 +5396,7 @@
5370
5396
  attributes: true, // 属性的变动
5371
5397
  childList: true, // 子节点的变动(指新增,删除或者更改)
5372
5398
  subtree: true, // 布尔值,表示是否将该观察器应用于该节点的所有后代节点。
5373
- characterData: true // 节点内容或节点文本的变动。
5399
+ characterData: true, // 节点内容或节点文本的变动。
5374
5400
  });
5375
5401
  };
5376
5402
  Watermark.prototype.bindCheckWatermarkElementEvent = function () {
@@ -5398,7 +5424,7 @@
5398
5424
  if (props === void 0) { props = {}; }
5399
5425
  var defaultProps = {
5400
5426
  globalAlpha: 0.005,
5401
- mode: 'blind'
5427
+ mode: 'blind',
5402
5428
  };
5403
5429
  return _super.call(this, __assign(__assign({}, props), defaultProps)) || this;
5404
5430
  }
@@ -5470,12 +5496,15 @@
5470
5496
  */
5471
5497
  function ImageWatermark(args) {
5472
5498
  if (args === void 0) { args = {}; }
5473
- var _a;
5499
+ var _a, _b;
5474
5500
  this.drew = false;
5475
5501
  this.props = args;
5476
5502
  this.options = __assign(__assign({}, initialOptions), args);
5503
+ if (this.props.crossOrigin) {
5504
+ (_a = this.props.dom) === null || _a === void 0 ? void 0 : _a.setAttribute('crossOrigin', 'anonymous');
5505
+ }
5477
5506
  this.watermarkCanvas = new WatermarkCanvas(this.props, this.options);
5478
- this.originalSrc = (_a = this.props.dom) === null || _a === void 0 ? void 0 : _a.src;
5507
+ this.originalSrc = (_b = this.props.dom) === null || _b === void 0 ? void 0 : _b.src;
5479
5508
  this.backgroundImage = this.getBackgroundImage();
5480
5509
  }
5481
5510
  ImageWatermark.prototype.create = function () {