@tsparticles/plugin-polygon-mask 3.0.0-alpha.1 → 3.0.0-beta.1

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 (52) hide show
  1. package/README.md +15 -11
  2. package/browser/Options/Classes/PolygonMask.js +6 -12
  3. package/browser/Options/Classes/PolygonMaskDraw.js +2 -19
  4. package/browser/Options/Classes/PolygonMaskDrawStroke.js +3 -4
  5. package/browser/PolygonMaskInstance.js +298 -306
  6. package/browser/index.js +13 -14
  7. package/browser/package.json +1 -0
  8. package/browser/pathseg.js +1 -1
  9. package/browser/utils.js +3 -5
  10. package/cjs/Options/Classes/PolygonMask.js +9 -15
  11. package/cjs/Options/Classes/PolygonMaskDraw.js +3 -20
  12. package/cjs/Options/Classes/PolygonMaskDrawStroke.js +2 -3
  13. package/cjs/PolygonMaskInstance.js +311 -334
  14. package/cjs/index.js +15 -27
  15. package/cjs/package.json +1 -0
  16. package/cjs/pathseg.js +1 -1
  17. package/cjs/utils.js +4 -6
  18. package/esm/Options/Classes/PolygonMask.js +6 -12
  19. package/esm/Options/Classes/PolygonMaskDraw.js +2 -19
  20. package/esm/Options/Classes/PolygonMaskDrawStroke.js +3 -4
  21. package/esm/PolygonMaskInstance.js +298 -306
  22. package/esm/index.js +13 -14
  23. package/esm/package.json +1 -0
  24. package/esm/pathseg.js +1 -1
  25. package/esm/utils.js +3 -5
  26. package/package.json +21 -6
  27. package/report.html +4 -4
  28. package/tsparticles.plugin.polygon-mask.js +336 -362
  29. package/tsparticles.plugin.polygon-mask.min.js +1 -1
  30. package/tsparticles.plugin.polygon-mask.min.js.LICENSE.txt +1 -8
  31. package/types/Interfaces/ISvgPath.d.ts +1 -1
  32. package/types/Options/Classes/PolygonMask.d.ts +7 -10
  33. package/types/Options/Classes/PolygonMaskDraw.d.ts +3 -8
  34. package/types/Options/Classes/PolygonMaskDrawStroke.d.ts +2 -3
  35. package/types/Options/Classes/PolygonMaskInline.d.ts +3 -3
  36. package/types/Options/Classes/PolygonMaskLocalSvg.d.ts +1 -1
  37. package/types/Options/Classes/PolygonMaskMove.d.ts +2 -2
  38. package/types/Options/Interfaces/IPolygonMask.d.ts +5 -5
  39. package/types/Options/Interfaces/IPolygonMaskDraw.d.ts +1 -4
  40. package/types/Options/Interfaces/IPolygonMaskInline.d.ts +1 -1
  41. package/types/Options/Interfaces/IPolygonMaskMove.d.ts +1 -1
  42. package/types/PolygonMaskInstance.d.ts +15 -17
  43. package/types/index.d.ts +5 -5
  44. package/types/types.d.ts +3 -3
  45. package/types/utils.d.ts +3 -4
  46. package/umd/Options/Classes/PolygonMask.js +10 -16
  47. package/umd/Options/Classes/PolygonMaskDraw.js +4 -21
  48. package/umd/Options/Classes/PolygonMaskDrawStroke.js +2 -3
  49. package/umd/PolygonMaskInstance.js +300 -308
  50. package/umd/index.js +16 -17
  51. package/umd/pathseg.js +1 -1
  52. package/umd/utils.js +3 -5
package/umd/index.js CHANGED
@@ -18,44 +18,43 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
18
  if (v !== undefined) module.exports = v;
19
19
  }
20
20
  else if (typeof define === "function" && define.amd) {
21
- define(["require", "exports", "./pathseg", "./Options/Classes/PolygonMask", "./PolygonMaskInstance", "./Enums/PolygonMaskInlineArrangement", "./Enums/PolygonMaskMoveType", "./Enums/PolygonMaskType"], factory);
21
+ define(["require", "exports", "./pathseg.js", "./Options/Classes/PolygonMask.js", "./PolygonMaskInstance.js", "./Enums/PolygonMaskInlineArrangement.js", "./Enums/PolygonMaskMoveType.js", "./Enums/PolygonMaskType.js"], factory);
22
22
  }
23
23
  })(function (require, exports) {
24
24
  "use strict";
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.loadPolygonMaskPlugin = void 0;
27
- require("./pathseg");
28
- const PolygonMask_1 = require("./Options/Classes/PolygonMask");
29
- const PolygonMaskInstance_1 = require("./PolygonMaskInstance");
27
+ require("./pathseg.js");
28
+ const PolygonMask_js_1 = require("./Options/Classes/PolygonMask.js");
29
+ const PolygonMaskInstance_js_1 = require("./PolygonMaskInstance.js");
30
30
  class PolygonMaskPlugin {
31
31
  constructor(engine) {
32
32
  this.id = "polygonMask";
33
33
  this._engine = engine;
34
34
  }
35
35
  getPlugin(container) {
36
- return new PolygonMaskInstance_1.PolygonMaskInstance(container, this._engine);
36
+ return new PolygonMaskInstance_js_1.PolygonMaskInstance(container, this._engine);
37
37
  }
38
38
  loadOptions(options, source) {
39
- if (!this.needsPlugin(source)) {
39
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
40
40
  return;
41
41
  }
42
42
  let polygonOptions = options.polygon;
43
- if ((polygonOptions === null || polygonOptions === void 0 ? void 0 : polygonOptions.load) === undefined) {
44
- options.polygon = polygonOptions = new PolygonMask_1.PolygonMask();
43
+ if (polygonOptions?.load === undefined) {
44
+ options.polygon = polygonOptions = new PolygonMask_js_1.PolygonMask();
45
45
  }
46
- polygonOptions.load(source === null || source === void 0 ? void 0 : source.polygon);
46
+ polygonOptions.load(source?.polygon);
47
47
  }
48
48
  needsPlugin(options) {
49
- var _a, _b, _c;
50
- return ((_b = (_a = options === null || options === void 0 ? void 0 : options.polygon) === null || _a === void 0 ? void 0 : _a.enable) !== null && _b !== void 0 ? _b : (((_c = options === null || options === void 0 ? void 0 : options.polygon) === null || _c === void 0 ? void 0 : _c.type) !== undefined && options.polygon.type !== "none"));
49
+ return (options?.polygon?.enable ??
50
+ (options?.polygon?.type !== undefined && options.polygon.type !== "none"));
51
51
  }
52
52
  }
53
- async function loadPolygonMaskPlugin(engine) {
54
- const plugin = new PolygonMaskPlugin(engine);
55
- await engine.addPlugin(plugin);
53
+ async function loadPolygonMaskPlugin(engine, refresh = true) {
54
+ await engine.addPlugin(new PolygonMaskPlugin(engine), refresh);
56
55
  }
57
56
  exports.loadPolygonMaskPlugin = loadPolygonMaskPlugin;
58
- __exportStar(require("./Enums/PolygonMaskInlineArrangement"), exports);
59
- __exportStar(require("./Enums/PolygonMaskMoveType"), exports);
60
- __exportStar(require("./Enums/PolygonMaskType"), exports);
57
+ __exportStar(require("./Enums/PolygonMaskInlineArrangement.js"), exports);
58
+ __exportStar(require("./Enums/PolygonMaskMoveType.js"), exports);
59
+ __exportStar(require("./Enums/PolygonMaskType.js"), exports);
61
60
  });
package/umd/pathseg.js CHANGED
@@ -1064,7 +1064,7 @@
1064
1064
  this._pathElement.setAttribute("d", window.SVGPathSegList._pathSegArrayAsString(this._list));
1065
1065
  this._pathElementMutationObserver.observe(this._pathElement, this._mutationObserverConfig);
1066
1066
  };
1067
- window.SVGPathSegList.prototype.segmentChanged = function (pathSeg) {
1067
+ window.SVGPathSegList.prototype.segmentChanged = function () {
1068
1068
  this._writeListToPath();
1069
1069
  };
1070
1070
  window.SVGPathSegList.prototype.clear = function () {
package/umd/utils.js CHANGED
@@ -40,17 +40,15 @@
40
40
  }
41
41
  exports.drawPolygonMaskPath = drawPolygonMaskPath;
42
42
  function parsePaths(paths, scale, offset) {
43
- var _a;
44
43
  const res = [];
45
44
  for (const path of paths) {
46
- const segments = path.element.pathSegList, len = (_a = segments === null || segments === void 0 ? void 0 : segments.numberOfItems) !== null && _a !== void 0 ? _a : 0, p = {
45
+ const segments = path.element.pathSegList, len = segments?.numberOfItems ?? 0, p = {
47
46
  x: 0,
48
47
  y: 0,
49
48
  };
50
49
  for (let i = 0; i < len; i++) {
51
- const segment = segments === null || segments === void 0 ? void 0 : segments.getItem(i);
52
- const svgPathSeg = window.SVGPathSeg;
53
- switch (segment === null || segment === void 0 ? void 0 : segment.pathSegType) {
50
+ const segment = segments?.getItem(i), svgPathSeg = window.SVGPathSeg;
51
+ switch (segment?.pathSegType) {
54
52
  case svgPathSeg.PATHSEG_MOVETO_ABS:
55
53
  case svgPathSeg.PATHSEG_LINETO_ABS:
56
54
  case svgPathSeg.PATHSEG_CURVETO_CUBIC_ABS: