@tsparticles/interaction-particles-links 3.9.1 → 4.0.0-alpha.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 (60) hide show
  1. package/418.min.js +2 -0
  2. package/418.min.js.LICENSE.txt +1 -0
  3. package/497.min.js +2 -0
  4. package/497.min.js.LICENSE.txt +1 -0
  5. package/711.min.js +2 -0
  6. package/711.min.js.LICENSE.txt +1 -0
  7. package/956.min.js +2 -0
  8. package/956.min.js.LICENSE.txt +1 -0
  9. package/browser/CircleWarp.js +2 -2
  10. package/browser/LinkInstance.js +7 -7
  11. package/browser/Linker.js +4 -7
  12. package/browser/Utils.js +5 -11
  13. package/browser/index.js +7 -9
  14. package/browser/interaction.js +7 -5
  15. package/browser/plugin.js +5 -4
  16. package/cjs/CircleWarp.js +6 -10
  17. package/cjs/Interfaces.js +1 -2
  18. package/cjs/LinkInstance.js +22 -26
  19. package/cjs/Linker.js +12 -19
  20. package/cjs/LinksPlugin.js +3 -7
  21. package/cjs/Options/Classes/Links.js +9 -13
  22. package/cjs/Options/Classes/LinksShadow.js +5 -9
  23. package/cjs/Options/Classes/LinksTriangle.js +4 -8
  24. package/cjs/Options/Interfaces/ILinks.js +1 -2
  25. package/cjs/Options/Interfaces/ILinksShadow.js +1 -2
  26. package/cjs/Options/Interfaces/ILinksTriangle.js +1 -2
  27. package/cjs/Types.js +1 -2
  28. package/cjs/Utils.js +20 -33
  29. package/cjs/index.js +10 -29
  30. package/cjs/interaction.js +7 -8
  31. package/cjs/plugin.js +5 -7
  32. package/dist_browser_Linker_js.js +40 -0
  33. package/dist_browser_LinksPlugin_js.js +50 -0
  34. package/dist_browser_interaction_js.js +30 -0
  35. package/dist_browser_plugin_js.js +30 -0
  36. package/esm/CircleWarp.js +2 -2
  37. package/esm/LinkInstance.js +7 -7
  38. package/esm/Linker.js +4 -7
  39. package/esm/Utils.js +5 -11
  40. package/esm/index.js +7 -9
  41. package/esm/interaction.js +7 -5
  42. package/esm/plugin.js +5 -4
  43. package/package.json +4 -3
  44. package/report.html +5 -4
  45. package/tsparticles.interaction.particles.links.js +221 -102
  46. package/tsparticles.interaction.particles.links.min.js +1 -1
  47. package/tsparticles.interaction.particles.links.min.js.LICENSE.txt +1 -1
  48. package/types/LinkInstance.d.ts +1 -1
  49. package/types/Linker.d.ts +1 -2
  50. package/types/Types.d.ts +3 -3
  51. package/types/index.d.ts +4 -4
  52. package/types/interaction.d.ts +1 -1
  53. package/types/plugin.d.ts +1 -1
  54. package/umd/CircleWarp.js +2 -2
  55. package/umd/LinkInstance.js +7 -7
  56. package/umd/Linker.js +4 -7
  57. package/umd/Utils.js +5 -11
  58. package/umd/index.js +31 -10
  59. package/umd/interaction.js +42 -6
  60. package/umd/plugin.js +40 -5
package/umd/CircleWarp.js CHANGED
@@ -33,11 +33,11 @@
33
33
  x: range.position.x - this.canvasSize.width,
34
34
  y: range.position.y - this.canvasSize.height,
35
35
  };
36
- if (circle.radius !== undefined) {
36
+ if (Object.hasOwn(circle, "radius")) {
37
37
  const biggerCircle = new engine_1.Circle(newPos.x, newPos.y, circle.radius * double);
38
38
  return super.intersects(biggerCircle);
39
39
  }
40
- else if (rect.size !== undefined) {
40
+ else if (Object.hasOwn(rect, "size")) {
41
41
  const rectSW = new engine_1.Rectangle(newPos.x, newPos.y, rect.size.width * double, rect.size.height * double);
42
42
  return super.intersects(rectSW);
43
43
  }
@@ -20,11 +20,11 @@
20
20
  if (!p1LinksOptions?.enable) {
21
21
  return;
22
22
  }
23
- const container = this._container, options = container.actualOptions, p2 = link.destination, pos1 = p1.getPosition(), pos2 = p2.getPosition();
23
+ const container = this._container, p2 = link.destination, pos1 = p1.getPosition(), pos2 = p2.getPosition();
24
24
  let opacity = link.opacity;
25
25
  container.canvas.draw(ctx => {
26
26
  let colorLine;
27
- const twinkle = p1.options.twinkle?.lines;
27
+ const twinkle = p1.options["twinkle"]?.lines;
28
28
  if (twinkle?.enable) {
29
29
  const twinkleFreq = twinkle.frequency, twinkleRgb = (0, engine_1.rangeColorToRgb)(this._engine, twinkle.color), twinkling = (0, engine_1.getRandom)() < twinkleFreq;
30
30
  if (twinkling && twinkleRgb) {
@@ -41,7 +41,7 @@
41
41
  if (!colorLine) {
42
42
  return;
43
43
  }
44
- const width = p1.retina.linksWidth ?? minWidth, maxDistance = p1.retina.linksDistance ?? minDistance, { backgroundMask } = options;
44
+ const width = p1.retina.linksWidth ?? minWidth, maxDistance = p1.retina.linksDistance ?? minDistance;
45
45
  (0, Utils_js_1.drawLinkLine)({
46
46
  context: ctx,
47
47
  width,
@@ -51,9 +51,9 @@
51
51
  maxDistance,
52
52
  canvasSize: container.canvas.size,
53
53
  links: p1LinksOptions,
54
- backgroundMask: backgroundMask,
55
54
  colorLine,
56
55
  opacity,
56
+ hdr: container.hdr,
57
57
  });
58
58
  });
59
59
  };
@@ -66,7 +66,7 @@
66
66
  if (!triangleOptions.enable) {
67
67
  return;
68
68
  }
69
- const container = this._container, options = container.actualOptions, p2 = link1.destination, p3 = link2.destination, opacityTriangle = triangleOptions.opacity ?? (link1.opacity + link2.opacity) * half;
69
+ const container = this._container, p2 = link1.destination, p3 = link2.destination, opacityTriangle = triangleOptions.opacity ?? (link1.opacity + link2.opacity) * half;
70
70
  if (opacityTriangle <= minOpacity) {
71
71
  return;
72
72
  }
@@ -92,9 +92,9 @@
92
92
  pos1,
93
93
  pos2,
94
94
  pos3,
95
- backgroundMask: options.backgroundMask,
96
95
  colorTriangle,
97
96
  opacityTriangle,
97
+ hdr: container.hdr,
98
98
  });
99
99
  });
100
100
  };
@@ -133,7 +133,7 @@
133
133
  triangles: new Map(),
134
134
  };
135
135
  }
136
- drawParticle(context, particle) {
136
+ drawParticle(_context, particle) {
137
137
  const { links, options } = particle;
138
138
  if (!links?.length) {
139
139
  return;
package/umd/Linker.js CHANGED
@@ -38,7 +38,7 @@
38
38
  if (!p1.options.links) {
39
39
  return;
40
40
  }
41
- const container = this._linkContainer, linksOptions = p1.options.links;
41
+ const container = this.container, linksOptions = p1.options.links;
42
42
  let linkColor = linksOptions.id === undefined
43
43
  ? container.particles.linksColor
44
44
  : container.particles.linksColors.get(linksOptions.id);
@@ -54,14 +54,13 @@
54
54
  container.particles.linksColors.set(linksOptions.id, linkColor);
55
55
  }
56
56
  };
57
- this._linkContainer = container;
58
57
  this._engine = engine;
59
58
  }
60
59
  clear() {
61
60
  }
62
61
  init() {
63
- this._linkContainer.particles.linksColor = undefined;
64
- this._linkContainer.particles.linksColors = new Map();
62
+ this.container.particles.linksColor = undefined;
63
+ this.container.particles.linksColors = new Map();
65
64
  }
66
65
  interact(p1) {
67
66
  if (!p1.options.links) {
@@ -113,9 +112,7 @@
113
112
  return !!particle.options.links?.enable;
114
113
  }
115
114
  loadParticlesOptions(options, ...sources) {
116
- if (!options.links) {
117
- options.links = new Links_js_1.Links();
118
- }
115
+ options.links ??= new Links_js_1.Links();
119
116
  for (const source of sources) {
120
117
  options.links.load(source?.links);
121
118
  }
package/umd/Utils.js CHANGED
@@ -24,7 +24,7 @@
24
24
  }
25
25
  function drawLinkLine(params) {
26
26
  let drawn = false;
27
- const { begin, end, engine, maxDistance, context, canvasSize, width, backgroundMask, colorLine, opacity, links } = params;
27
+ const { begin, end, engine, maxDistance, context, canvasSize, width, colorLine, opacity, links, hdr } = params;
28
28
  if ((0, engine_1.getDistance)(begin, end) <= maxDistance) {
29
29
  (0, engine_1.drawLine)(context, begin, end);
30
30
  drawn = true;
@@ -78,27 +78,21 @@
78
78
  return;
79
79
  }
80
80
  context.lineWidth = width;
81
- if (backgroundMask.enable) {
82
- context.globalCompositeOperation = backgroundMask.composite;
83
- }
84
- context.strokeStyle = (0, engine_1.getStyleFromRgb)(colorLine, opacity);
81
+ context.strokeStyle = (0, engine_1.getStyleFromRgb)(colorLine, hdr, opacity);
85
82
  const { shadow } = links;
86
83
  if (shadow.enable) {
87
84
  const shadowColor = (0, engine_1.rangeColorToRgb)(engine, shadow.color);
88
85
  if (shadowColor) {
89
86
  context.shadowBlur = shadow.blur;
90
- context.shadowColor = (0, engine_1.getStyleFromRgb)(shadowColor);
87
+ context.shadowColor = (0, engine_1.getStyleFromRgb)(shadowColor, hdr);
91
88
  }
92
89
  }
93
90
  context.stroke();
94
91
  }
95
92
  function drawLinkTriangle(params) {
96
- const { context, pos1, pos2, pos3, backgroundMask, colorTriangle, opacityTriangle } = params;
93
+ const { context, hdr, pos1, pos2, pos3, colorTriangle, opacityTriangle } = params;
97
94
  drawTriangle(context, pos1, pos2, pos3);
98
- if (backgroundMask.enable) {
99
- context.globalCompositeOperation = backgroundMask.composite;
100
- }
101
- context.fillStyle = (0, engine_1.getStyleFromRgb)(colorTriangle, opacityTriangle);
95
+ context.fillStyle = (0, engine_1.getStyleFromRgb)(colorTriangle, hdr, opacityTriangle);
102
96
  context.fill();
103
97
  }
104
98
  function getLinkKey(ids) {
package/umd/index.js CHANGED
@@ -9,6 +9,28 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
9
9
  if (k2 === undefined) k2 = k;
10
10
  o[k2] = m[k];
11
11
  }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || (function () {
18
+ var ownKeys = function(o) {
19
+ ownKeys = Object.getOwnPropertyNames || function (o) {
20
+ var ar = [];
21
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
22
+ return ar;
23
+ };
24
+ return ownKeys(o);
25
+ };
26
+ return function (mod) {
27
+ if (mod && mod.__esModule) return mod;
28
+ var result = {};
29
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
30
+ __setModuleDefault(result, mod);
31
+ return result;
32
+ };
33
+ })();
12
34
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
13
35
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
14
36
  };
@@ -18,23 +40,22 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
40
  if (v !== undefined) module.exports = v;
19
41
  }
20
42
  else if (typeof define === "function" && define.amd) {
21
- define(["require", "exports", "./interaction.js", "./plugin.js", "./Options/Classes/Links.js", "./Options/Classes/LinksShadow.js", "./Options/Classes/LinksTriangle.js", "./Options/Interfaces/ILinks.js", "./Options/Interfaces/ILinksShadow.js", "./Options/Interfaces/ILinksTriangle.js"], factory);
43
+ define(["require", "exports", "./Options/Classes/Links.js", "./Options/Classes/LinksShadow.js", "./Options/Classes/LinksTriangle.js"], factory);
22
44
  }
23
45
  })(function (require, exports) {
24
46
  "use strict";
47
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
25
48
  Object.defineProperty(exports, "__esModule", { value: true });
26
49
  exports.loadParticlesLinksInteraction = loadParticlesLinksInteraction;
27
- const interaction_js_1 = require("./interaction.js");
28
- const plugin_js_1 = require("./plugin.js");
29
- async function loadParticlesLinksInteraction(engine, refresh = true) {
30
- engine.checkVersion("3.9.1");
31
- await (0, interaction_js_1.loadLinksInteraction)(engine, refresh);
32
- await (0, plugin_js_1.loadLinksPlugin)(engine, refresh);
50
+ function loadParticlesLinksInteraction(engine) {
51
+ engine.checkVersion("4.0.0-alpha.1");
52
+ engine.register(async (e) => {
53
+ const { loadLinksInteraction } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./interaction.js"))) : new Promise((resolve_1, reject_1) => { require(["./interaction.js"], resolve_1, reject_1); }).then(__importStar)), { loadLinksPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./plugin.js"))) : new Promise((resolve_2, reject_2) => { require(["./plugin.js"], resolve_2, reject_2); }).then(__importStar));
54
+ loadLinksInteraction(e);
55
+ loadLinksPlugin(e);
56
+ });
33
57
  }
34
58
  __exportStar(require("./Options/Classes/Links.js"), exports);
35
59
  __exportStar(require("./Options/Classes/LinksShadow.js"), exports);
36
60
  __exportStar(require("./Options/Classes/LinksTriangle.js"), exports);
37
- __exportStar(require("./Options/Interfaces/ILinks.js"), exports);
38
- __exportStar(require("./Options/Interfaces/ILinksShadow.js"), exports);
39
- __exportStar(require("./Options/Interfaces/ILinksTriangle.js"), exports);
40
61
  });
@@ -1,19 +1,55 @@
1
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || (function () {
18
+ var ownKeys = function(o) {
19
+ ownKeys = Object.getOwnPropertyNames || function (o) {
20
+ var ar = [];
21
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
22
+ return ar;
23
+ };
24
+ return ownKeys(o);
25
+ };
26
+ return function (mod) {
27
+ if (mod && mod.__esModule) return mod;
28
+ var result = {};
29
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
30
+ __setModuleDefault(result, mod);
31
+ return result;
32
+ };
33
+ })();
1
34
  (function (factory) {
2
35
  if (typeof module === "object" && typeof module.exports === "object") {
3
36
  var v = factory(require, exports);
4
37
  if (v !== undefined) module.exports = v;
5
38
  }
6
39
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./Linker.js"], factory);
40
+ define(["require", "exports"], factory);
8
41
  }
9
42
  })(function (require, exports) {
10
43
  "use strict";
44
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
11
45
  Object.defineProperty(exports, "__esModule", { value: true });
12
46
  exports.loadLinksInteraction = loadLinksInteraction;
13
- const Linker_js_1 = require("./Linker.js");
14
- async function loadLinksInteraction(engine, refresh = true) {
15
- await engine.addInteractor("particlesLinks", async (container) => {
16
- return Promise.resolve(new Linker_js_1.Linker(container, engine));
17
- }, refresh);
47
+ function loadLinksInteraction(engine) {
48
+ engine.register(e => {
49
+ e.addInteractor("particlesLinks", async (container) => {
50
+ const { Linker } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Linker.js"))) : new Promise((resolve_1, reject_1) => { require(["./Linker.js"], resolve_1, reject_1); }).then(__importStar));
51
+ return new Linker(container, engine);
52
+ });
53
+ });
18
54
  }
19
55
  });
package/umd/plugin.js CHANGED
@@ -1,18 +1,53 @@
1
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
2
+ if (k2 === undefined) k2 = k;
3
+ var desc = Object.getOwnPropertyDescriptor(m, k);
4
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
5
+ desc = { enumerable: true, get: function() { return m[k]; } };
6
+ }
7
+ Object.defineProperty(o, k2, desc);
8
+ }) : (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ o[k2] = m[k];
11
+ }));
12
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
13
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
14
+ }) : function(o, v) {
15
+ o["default"] = v;
16
+ });
17
+ var __importStar = (this && this.__importStar) || (function () {
18
+ var ownKeys = function(o) {
19
+ ownKeys = Object.getOwnPropertyNames || function (o) {
20
+ var ar = [];
21
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
22
+ return ar;
23
+ };
24
+ return ownKeys(o);
25
+ };
26
+ return function (mod) {
27
+ if (mod && mod.__esModule) return mod;
28
+ var result = {};
29
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
30
+ __setModuleDefault(result, mod);
31
+ return result;
32
+ };
33
+ })();
1
34
  (function (factory) {
2
35
  if (typeof module === "object" && typeof module.exports === "object") {
3
36
  var v = factory(require, exports);
4
37
  if (v !== undefined) module.exports = v;
5
38
  }
6
39
  else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./LinksPlugin.js"], factory);
40
+ define(["require", "exports"], factory);
8
41
  }
9
42
  })(function (require, exports) {
10
43
  "use strict";
44
+ var __syncRequire = typeof module === "object" && typeof module.exports === "object";
11
45
  Object.defineProperty(exports, "__esModule", { value: true });
12
46
  exports.loadLinksPlugin = loadLinksPlugin;
13
- const LinksPlugin_js_1 = require("./LinksPlugin.js");
14
- async function loadLinksPlugin(engine, refresh = true) {
15
- const plugin = new LinksPlugin_js_1.LinksPlugin(engine);
16
- await engine.addPlugin(plugin, refresh);
47
+ function loadLinksPlugin(engine) {
48
+ engine.register(async (e) => {
49
+ const { LinksPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./LinksPlugin.js"))) : new Promise((resolve_1, reject_1) => { require(["./LinksPlugin.js"], resolve_1, reject_1); }).then(__importStar));
50
+ e.addPlugin(new LinksPlugin(e));
51
+ });
17
52
  }
18
53
  });