@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/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import "./pathseg";
2
- import { PolygonMask } from "./Options/Classes/PolygonMask";
3
- import { PolygonMaskInstance } from "./PolygonMaskInstance";
1
+ import "./pathseg.js";
2
+ import { PolygonMask } from "./Options/Classes/PolygonMask.js";
3
+ import { PolygonMaskInstance } from "./PolygonMaskInstance.js";
4
4
  class PolygonMaskPlugin {
5
5
  constructor(engine) {
6
6
  this.id = "polygonMask";
@@ -10,24 +10,23 @@ class PolygonMaskPlugin {
10
10
  return new PolygonMaskInstance(container, this._engine);
11
11
  }
12
12
  loadOptions(options, source) {
13
- if (!this.needsPlugin(source)) {
13
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
14
14
  return;
15
15
  }
16
16
  let polygonOptions = options.polygon;
17
- if ((polygonOptions === null || polygonOptions === void 0 ? void 0 : polygonOptions.load) === undefined) {
17
+ if (polygonOptions?.load === undefined) {
18
18
  options.polygon = polygonOptions = new PolygonMask();
19
19
  }
20
- polygonOptions.load(source === null || source === void 0 ? void 0 : source.polygon);
20
+ polygonOptions.load(source?.polygon);
21
21
  }
22
22
  needsPlugin(options) {
23
- var _a, _b, _c;
24
- 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"));
23
+ return (options?.polygon?.enable ??
24
+ (options?.polygon?.type !== undefined && options.polygon.type !== "none"));
25
25
  }
26
26
  }
27
- export async function loadPolygonMaskPlugin(engine) {
28
- const plugin = new PolygonMaskPlugin(engine);
29
- await engine.addPlugin(plugin);
27
+ export async function loadPolygonMaskPlugin(engine, refresh = true) {
28
+ await engine.addPlugin(new PolygonMaskPlugin(engine), refresh);
30
29
  }
31
- export * from "./Enums/PolygonMaskInlineArrangement";
32
- export * from "./Enums/PolygonMaskMoveType";
33
- export * from "./Enums/PolygonMaskType";
30
+ export * from "./Enums/PolygonMaskInlineArrangement.js";
31
+ export * from "./Enums/PolygonMaskMoveType.js";
32
+ export * from "./Enums/PolygonMaskType.js";
@@ -0,0 +1 @@
1
+ { "type": "module" }
package/esm/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/esm/utils.js CHANGED
@@ -26,17 +26,15 @@ export function drawPolygonMaskPath(context, path, stroke, position) {
26
26
  context.setTransform(1, 0, 0, 1, 0, 0);
27
27
  }
28
28
  export function parsePaths(paths, scale, offset) {
29
- var _a;
30
29
  const res = [];
31
30
  for (const path of paths) {
32
- const segments = path.element.pathSegList, len = (_a = segments === null || segments === void 0 ? void 0 : segments.numberOfItems) !== null && _a !== void 0 ? _a : 0, p = {
31
+ const segments = path.element.pathSegList, len = segments?.numberOfItems ?? 0, p = {
33
32
  x: 0,
34
33
  y: 0,
35
34
  };
36
35
  for (let i = 0; i < len; i++) {
37
- const segment = segments === null || segments === void 0 ? void 0 : segments.getItem(i);
38
- const svgPathSeg = window.SVGPathSeg;
39
- switch (segment === null || segment === void 0 ? void 0 : segment.pathSegType) {
36
+ const segment = segments?.getItem(i), svgPathSeg = window.SVGPathSeg;
37
+ switch (segment?.pathSegType) {
40
38
  case svgPathSeg.PATHSEG_MOVETO_ABS:
41
39
  case svgPathSeg.PATHSEG_LINETO_ABS:
42
40
  case svgPathSeg.PATHSEG_CURVETO_CUBIC_ABS:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/plugin-polygon-mask",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-beta.1",
4
4
  "description": "tsParticles polygon mask plugin",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -67,15 +67,30 @@
67
67
  "bugs": {
68
68
  "url": "https://github.com/matteobruni/tsparticles/issues"
69
69
  },
70
- "main": "cjs/index.js",
70
+ "sideEffects": [
71
+ "./**/pathseg.js"
72
+ ],
71
73
  "jsdelivr": "tsparticles.plugin.polygon-mask.min.js",
72
74
  "unpkg": "tsparticles.plugin.polygon-mask.min.js",
75
+ "browser": "browser/index.js",
76
+ "main": "cjs/index.js",
73
77
  "module": "esm/index.js",
74
78
  "types": "types/index.d.ts",
75
- "publishConfig": {
76
- "access": "public"
79
+ "exports": {
80
+ ".": {
81
+ "types": "./types/index.d.ts",
82
+ "browser": "./browser/index.js",
83
+ "import": "./esm/index.js",
84
+ "require": "./cjs/index.js",
85
+ "umd": "./umd/index.js",
86
+ "default": "./cjs/index.js"
87
+ },
88
+ "./package.json": "./package.json"
77
89
  },
78
90
  "dependencies": {
79
- "@tsparticles/engine": "^3.0.0-alpha.1"
91
+ "@tsparticles/engine": "^3.0.0-beta.1"
92
+ },
93
+ "publishConfig": {
94
+ "access": "public"
80
95
  }
81
- }
96
+ }