@tsparticles/interaction-particles-links 3.2.2 → 3.4.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 (54) hide show
  1. package/browser/LinkInstance.js +6 -7
  2. package/browser/Linker.js +5 -5
  3. package/browser/LinksPlugin.js +3 -3
  4. package/browser/Utils.js +1 -1
  5. package/browser/index.js +2 -1
  6. package/browser/interaction.js +2 -2
  7. package/browser/plugin.js +2 -1
  8. package/cjs/LinkInstance.js +6 -7
  9. package/cjs/Linker.js +6 -29
  10. package/cjs/LinksPlugin.js +3 -26
  11. package/cjs/Utils.js +1 -1
  12. package/cjs/index.js +4 -15
  13. package/cjs/interaction.js +2 -25
  14. package/cjs/plugin.js +2 -24
  15. package/esm/LinkInstance.js +6 -7
  16. package/esm/Linker.js +5 -5
  17. package/esm/LinksPlugin.js +3 -3
  18. package/esm/Utils.js +1 -1
  19. package/esm/index.js +2 -1
  20. package/esm/interaction.js +2 -2
  21. package/esm/plugin.js +2 -1
  22. package/package.json +2 -2
  23. package/report.html +1 -1
  24. package/tsparticles.interaction.particles.links.js +72 -200
  25. package/tsparticles.interaction.particles.links.min.js +1 -1
  26. package/tsparticles.interaction.particles.links.min.js.LICENSE.txt +1 -1
  27. package/types/LinkInstance.d.ts +1 -1
  28. package/types/Linker.d.ts +1 -1
  29. package/types/LinksPlugin.d.ts +1 -1
  30. package/umd/LinkInstance.js +6 -7
  31. package/umd/Linker.js +7 -31
  32. package/umd/LinksPlugin.js +4 -28
  33. package/umd/Utils.js +1 -1
  34. package/umd/index.js +5 -17
  35. package/umd/interaction.js +3 -27
  36. package/umd/plugin.js +3 -26
  37. package/292.min.js +0 -2
  38. package/292.min.js.LICENSE.txt +0 -1
  39. package/356.min.js +0 -2
  40. package/356.min.js.LICENSE.txt +0 -1
  41. package/45.min.js +0 -2
  42. package/45.min.js.LICENSE.txt +0 -1
  43. package/806.min.js +0 -2
  44. package/806.min.js.LICENSE.txt +0 -1
  45. package/838.min.js +0 -2
  46. package/838.min.js.LICENSE.txt +0 -1
  47. package/97.min.js +0 -2
  48. package/97.min.js.LICENSE.txt +0 -1
  49. package/dist_browser_CircleWarp_js.js +0 -30
  50. package/dist_browser_LinkInstance_js.js +0 -40
  51. package/dist_browser_Linker_js.js +0 -30
  52. package/dist_browser_LinksPlugin_js.js +0 -30
  53. package/dist_browser_interaction_js.js +0 -30
  54. package/dist_browser_plugin_js.js +0 -30
@@ -11,7 +11,7 @@ export class LinkInstance {
11
11
  }
12
12
  const container = this.container, options = container.actualOptions, p2 = link.destination, pos1 = p1.getPosition(), pos2 = p2.getPosition();
13
13
  let opacity = link.opacity;
14
- container.canvas.draw((ctx) => {
14
+ container.canvas.draw(ctx => {
15
15
  let colorLine;
16
16
  const twinkle = p1.options.twinkle?.lines;
17
17
  if (twinkle?.enable) {
@@ -58,7 +58,7 @@ export class LinkInstance {
58
58
  if (opacityTriangle <= minOpacity) {
59
59
  return;
60
60
  }
61
- container.canvas.draw((ctx) => {
61
+ container.canvas.draw(ctx => {
62
62
  const pos1 = p1.getPosition(), pos2 = p2.getPosition(), pos3 = p3.getPosition(), linksDistance = p1.retina.linksDistance ?? minDistance;
63
63
  if (getDistance(pos1, pos2) > linksDistance ||
64
64
  getDistance(pos3, pos2) > linksDistance ||
@@ -91,11 +91,11 @@ export class LinkInstance {
91
91
  if (!(options.links?.triangles.enable && p2.options.links?.triangles.enable)) {
92
92
  return;
93
93
  }
94
- const vertices = p2.links?.filter((t) => {
94
+ const vertices = p2.links?.filter(t => {
95
95
  const linkFreq = this._getLinkFrequency(p2, t.destination), minCount = 0;
96
96
  return (p2.options.links &&
97
97
  linkFreq <= p2.options.links.frequency &&
98
- p1Links.findIndex((l) => l.destination === t.destination) >= minCount);
98
+ p1Links.findIndex(l => l.destination === t.destination) >= minCount);
99
99
  });
100
100
  if (!vertices?.length) {
101
101
  return;
@@ -119,12 +119,12 @@ export class LinkInstance {
119
119
  triangles: new Map(),
120
120
  };
121
121
  }
122
- async drawParticle(context, particle) {
122
+ drawParticle(context, particle) {
123
123
  const { links, options } = particle;
124
124
  if (!links?.length) {
125
125
  return;
126
126
  }
127
- const p1Links = links.filter((l) => options.links &&
127
+ const p1Links = links.filter(l => options.links &&
128
128
  (options.links.frequency >= maxFrequency ||
129
129
  this._getLinkFrequency(particle, l.destination) <= options.links.frequency));
130
130
  for (const link of p1Links) {
@@ -133,7 +133,6 @@ export class LinkInstance {
133
133
  this._drawLinkLine(particle, link);
134
134
  }
135
135
  }
136
- await Promise.resolve();
137
136
  }
138
137
  async init() {
139
138
  this._freqs.links = new Map();
package/browser/Linker.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Circle, ParticlesInteractorBase, getDistances, getLinkRandomColor, } from "@tsparticles/engine";
2
+ import { CircleWarp } from "./CircleWarp.js";
2
3
  import { Links } from "./Options/Classes/Links.js";
3
4
  const squarePower = 2, opacityOffset = 1, origin = {
4
5
  x: 0,
@@ -21,7 +22,7 @@ function getLinkDistance(pos1, pos2, optDistance, canvasSize, warp) {
21
22
  export class Linker extends ParticlesInteractorBase {
22
23
  constructor(container) {
23
24
  super(container);
24
- this._setColor = (p1) => {
25
+ this._setColor = p1 => {
25
26
  if (!p1.options.links) {
26
27
  return;
27
28
  }
@@ -49,7 +50,7 @@ export class Linker extends ParticlesInteractorBase {
49
50
  this.linkContainer.particles.linksColor = undefined;
50
51
  this.linkContainer.particles.linksColors = new Map();
51
52
  }
52
- async interact(p1) {
53
+ interact(p1) {
53
54
  if (!p1.options.links) {
54
55
  return;
55
56
  }
@@ -61,7 +62,6 @@ export class Linker extends ParticlesInteractorBase {
61
62
  const linkOpt1 = p1.options.links, optOpacity = linkOpt1.opacity, optDistance = p1.retina.linksDistance ?? minDistance, warp = linkOpt1.warp;
62
63
  let range;
63
64
  if (warp) {
64
- const { CircleWarp } = await import("./CircleWarp.js");
65
65
  range = new CircleWarp(pos1.x, pos1.y, optDistance, canvasSize);
66
66
  }
67
67
  else {
@@ -76,8 +76,8 @@ export class Linker extends ParticlesInteractorBase {
76
76
  p2.spawning ||
77
77
  p2.destroyed ||
78
78
  !p2.links ||
79
- p1.links.some((t) => t.destination === p2) ||
80
- p2.links.some((t) => t.destination === p1)) {
79
+ p1.links.some(t => t.destination === p2) ||
80
+ p2.links.some(t => t.destination === p1)) {
81
81
  continue;
82
82
  }
83
83
  const pos2 = p2.getPosition();
@@ -1,10 +1,10 @@
1
+ import { LinkInstance } from "./LinkInstance.js";
1
2
  export class LinksPlugin {
2
3
  constructor() {
3
4
  this.id = "links";
4
5
  }
5
- async getPlugin(container) {
6
- const { LinkInstance } = await import("./LinkInstance.js");
7
- return new LinkInstance(container);
6
+ getPlugin(container) {
7
+ return Promise.resolve(new LinkInstance(container));
8
8
  }
9
9
  loadOptions() {
10
10
  }
package/browser/Utils.js CHANGED
@@ -90,7 +90,7 @@ export function getLinkKey(ids) {
90
90
  return ids.join("_");
91
91
  }
92
92
  export function setLinkFrequency(particles, dictionary) {
93
- const key = getLinkKey(particles.map((t) => t.id));
93
+ const key = getLinkKey(particles.map(t => t.id));
94
94
  let res = dictionary.get(key);
95
95
  if (res === undefined) {
96
96
  res = getRandom();
package/browser/index.js CHANGED
@@ -1,5 +1,6 @@
1
+ import { loadLinksInteraction } from "./interaction.js";
2
+ import { loadLinksPlugin } from "./plugin.js";
1
3
  export async function loadParticlesLinksInteraction(engine, refresh = true) {
2
- const { loadLinksInteraction } = await import("./interaction.js"), { loadLinksPlugin } = await import("./plugin.js");
3
4
  await loadLinksInteraction(engine, refresh);
4
5
  await loadLinksPlugin(engine, refresh);
5
6
  }
@@ -1,6 +1,6 @@
1
+ import { Linker } from "./Linker.js";
1
2
  export async function loadLinksInteraction(engine, refresh = true) {
2
3
  await engine.addInteractor("particlesLinks", async (container) => {
3
- const { Linker } = await import("./Linker.js");
4
- return new Linker(container);
4
+ return Promise.resolve(new Linker(container));
5
5
  }, refresh);
6
6
  }
package/browser/plugin.js CHANGED
@@ -1,4 +1,5 @@
1
+ import { LinksPlugin } from "./LinksPlugin.js";
1
2
  export async function loadLinksPlugin(engine, refresh = true) {
2
- const { LinksPlugin } = await import("./LinksPlugin.js"), plugin = new LinksPlugin();
3
+ const plugin = new LinksPlugin();
3
4
  await engine.addPlugin(plugin, refresh);
4
5
  }
@@ -14,7 +14,7 @@ class LinkInstance {
14
14
  }
15
15
  const container = this.container, options = container.actualOptions, p2 = link.destination, pos1 = p1.getPosition(), pos2 = p2.getPosition();
16
16
  let opacity = link.opacity;
17
- container.canvas.draw((ctx) => {
17
+ container.canvas.draw(ctx => {
18
18
  let colorLine;
19
19
  const twinkle = p1.options.twinkle?.lines;
20
20
  if (twinkle?.enable) {
@@ -61,7 +61,7 @@ class LinkInstance {
61
61
  if (opacityTriangle <= minOpacity) {
62
62
  return;
63
63
  }
64
- container.canvas.draw((ctx) => {
64
+ container.canvas.draw(ctx => {
65
65
  const pos1 = p1.getPosition(), pos2 = p2.getPosition(), pos3 = p3.getPosition(), linksDistance = p1.retina.linksDistance ?? minDistance;
66
66
  if ((0, engine_1.getDistance)(pos1, pos2) > linksDistance ||
67
67
  (0, engine_1.getDistance)(pos3, pos2) > linksDistance ||
@@ -94,11 +94,11 @@ class LinkInstance {
94
94
  if (!(options.links?.triangles.enable && p2.options.links?.triangles.enable)) {
95
95
  return;
96
96
  }
97
- const vertices = p2.links?.filter((t) => {
97
+ const vertices = p2.links?.filter(t => {
98
98
  const linkFreq = this._getLinkFrequency(p2, t.destination), minCount = 0;
99
99
  return (p2.options.links &&
100
100
  linkFreq <= p2.options.links.frequency &&
101
- p1Links.findIndex((l) => l.destination === t.destination) >= minCount);
101
+ p1Links.findIndex(l => l.destination === t.destination) >= minCount);
102
102
  });
103
103
  if (!vertices?.length) {
104
104
  return;
@@ -122,12 +122,12 @@ class LinkInstance {
122
122
  triangles: new Map(),
123
123
  };
124
124
  }
125
- async drawParticle(context, particle) {
125
+ drawParticle(context, particle) {
126
126
  const { links, options } = particle;
127
127
  if (!links?.length) {
128
128
  return;
129
129
  }
130
- const p1Links = links.filter((l) => options.links &&
130
+ const p1Links = links.filter(l => options.links &&
131
131
  (options.links.frequency >= maxFrequency ||
132
132
  this._getLinkFrequency(particle, l.destination) <= options.links.frequency));
133
133
  for (const link of p1Links) {
@@ -136,7 +136,6 @@ class LinkInstance {
136
136
  this._drawLinkLine(particle, link);
137
137
  }
138
138
  }
139
- await Promise.resolve();
140
139
  }
141
140
  async init() {
142
141
  this._freqs.links = new Map();
package/cjs/Linker.js CHANGED
@@ -1,30 +1,8 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.Linker = void 0;
27
4
  const engine_1 = require("@tsparticles/engine");
5
+ const CircleWarp_js_1 = require("./CircleWarp.js");
28
6
  const Links_js_1 = require("./Options/Classes/Links.js");
29
7
  const squarePower = 2, opacityOffset = 1, origin = {
30
8
  x: 0,
@@ -47,7 +25,7 @@ function getLinkDistance(pos1, pos2, optDistance, canvasSize, warp) {
47
25
  class Linker extends engine_1.ParticlesInteractorBase {
48
26
  constructor(container) {
49
27
  super(container);
50
- this._setColor = (p1) => {
28
+ this._setColor = p1 => {
51
29
  if (!p1.options.links) {
52
30
  return;
53
31
  }
@@ -75,7 +53,7 @@ class Linker extends engine_1.ParticlesInteractorBase {
75
53
  this.linkContainer.particles.linksColor = undefined;
76
54
  this.linkContainer.particles.linksColors = new Map();
77
55
  }
78
- async interact(p1) {
56
+ interact(p1) {
79
57
  if (!p1.options.links) {
80
58
  return;
81
59
  }
@@ -87,8 +65,7 @@ class Linker extends engine_1.ParticlesInteractorBase {
87
65
  const linkOpt1 = p1.options.links, optOpacity = linkOpt1.opacity, optDistance = p1.retina.linksDistance ?? minDistance, warp = linkOpt1.warp;
88
66
  let range;
89
67
  if (warp) {
90
- const { CircleWarp } = await Promise.resolve().then(() => __importStar(require("./CircleWarp.js")));
91
- range = new CircleWarp(pos1.x, pos1.y, optDistance, canvasSize);
68
+ range = new CircleWarp_js_1.CircleWarp(pos1.x, pos1.y, optDistance, canvasSize);
92
69
  }
93
70
  else {
94
71
  range = new engine_1.Circle(pos1.x, pos1.y, optDistance);
@@ -102,8 +79,8 @@ class Linker extends engine_1.ParticlesInteractorBase {
102
79
  p2.spawning ||
103
80
  p2.destroyed ||
104
81
  !p2.links ||
105
- p1.links.some((t) => t.destination === p2) ||
106
- p2.links.some((t) => t.destination === p1)) {
82
+ p1.links.some(t => t.destination === p2) ||
83
+ p2.links.some(t => t.destination === p1)) {
107
84
  continue;
108
85
  }
109
86
  const pos2 = p2.getPosition();
@@ -1,36 +1,13 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.LinksPlugin = void 0;
4
+ const LinkInstance_js_1 = require("./LinkInstance.js");
27
5
  class LinksPlugin {
28
6
  constructor() {
29
7
  this.id = "links";
30
8
  }
31
- async getPlugin(container) {
32
- const { LinkInstance } = await Promise.resolve().then(() => __importStar(require("./LinkInstance.js")));
33
- return new LinkInstance(container);
9
+ getPlugin(container) {
10
+ return Promise.resolve(new LinkInstance_js_1.LinkInstance(container));
34
11
  }
35
12
  loadOptions() {
36
13
  }
package/cjs/Utils.js CHANGED
@@ -97,7 +97,7 @@ function getLinkKey(ids) {
97
97
  }
98
98
  exports.getLinkKey = getLinkKey;
99
99
  function setLinkFrequency(particles, dictionary) {
100
- const key = getLinkKey(particles.map((t) => t.id));
100
+ const key = getLinkKey(particles.map(t => t.id));
101
101
  let res = dictionary.get(key);
102
102
  if (res === undefined) {
103
103
  res = (0, engine_1.getRandom)();
package/cjs/index.js CHANGED
@@ -10,27 +10,16 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
10
10
  if (k2 === undefined) k2 = k;
11
11
  o[k2] = m[k];
12
12
  }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
15
  };
28
16
  Object.defineProperty(exports, "__esModule", { value: true });
29
17
  exports.loadParticlesLinksInteraction = void 0;
18
+ const interaction_js_1 = require("./interaction.js");
19
+ const plugin_js_1 = require("./plugin.js");
30
20
  async function loadParticlesLinksInteraction(engine, refresh = true) {
31
- const { loadLinksInteraction } = await Promise.resolve().then(() => __importStar(require("./interaction.js"))), { loadLinksPlugin } = await Promise.resolve().then(() => __importStar(require("./plugin.js")));
32
- await loadLinksInteraction(engine, refresh);
33
- await loadLinksPlugin(engine, refresh);
21
+ await (0, interaction_js_1.loadLinksInteraction)(engine, refresh);
22
+ await (0, plugin_js_1.loadLinksPlugin)(engine, refresh);
34
23
  }
35
24
  exports.loadParticlesLinksInteraction = loadParticlesLinksInteraction;
36
25
  __exportStar(require("./Options/Classes/Links.js"), exports);
@@ -1,33 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.loadLinksInteraction = void 0;
4
+ const Linker_js_1 = require("./Linker.js");
27
5
  async function loadLinksInteraction(engine, refresh = true) {
28
6
  await engine.addInteractor("particlesLinks", async (container) => {
29
- const { Linker } = await Promise.resolve().then(() => __importStar(require("./Linker.js")));
30
- return new Linker(container);
7
+ return Promise.resolve(new Linker_js_1.Linker(container));
31
8
  }, refresh);
32
9
  }
33
10
  exports.loadLinksInteraction = loadLinksInteraction;
package/cjs/plugin.js CHANGED
@@ -1,31 +1,9 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.loadLinksPlugin = void 0;
4
+ const LinksPlugin_js_1 = require("./LinksPlugin.js");
27
5
  async function loadLinksPlugin(engine, refresh = true) {
28
- const { LinksPlugin } = await Promise.resolve().then(() => __importStar(require("./LinksPlugin.js"))), plugin = new LinksPlugin();
6
+ const plugin = new LinksPlugin_js_1.LinksPlugin();
29
7
  await engine.addPlugin(plugin, refresh);
30
8
  }
31
9
  exports.loadLinksPlugin = loadLinksPlugin;
@@ -11,7 +11,7 @@ export class LinkInstance {
11
11
  }
12
12
  const container = this.container, options = container.actualOptions, p2 = link.destination, pos1 = p1.getPosition(), pos2 = p2.getPosition();
13
13
  let opacity = link.opacity;
14
- container.canvas.draw((ctx) => {
14
+ container.canvas.draw(ctx => {
15
15
  let colorLine;
16
16
  const twinkle = p1.options.twinkle?.lines;
17
17
  if (twinkle?.enable) {
@@ -58,7 +58,7 @@ export class LinkInstance {
58
58
  if (opacityTriangle <= minOpacity) {
59
59
  return;
60
60
  }
61
- container.canvas.draw((ctx) => {
61
+ container.canvas.draw(ctx => {
62
62
  const pos1 = p1.getPosition(), pos2 = p2.getPosition(), pos3 = p3.getPosition(), linksDistance = p1.retina.linksDistance ?? minDistance;
63
63
  if (getDistance(pos1, pos2) > linksDistance ||
64
64
  getDistance(pos3, pos2) > linksDistance ||
@@ -91,11 +91,11 @@ export class LinkInstance {
91
91
  if (!(options.links?.triangles.enable && p2.options.links?.triangles.enable)) {
92
92
  return;
93
93
  }
94
- const vertices = p2.links?.filter((t) => {
94
+ const vertices = p2.links?.filter(t => {
95
95
  const linkFreq = this._getLinkFrequency(p2, t.destination), minCount = 0;
96
96
  return (p2.options.links &&
97
97
  linkFreq <= p2.options.links.frequency &&
98
- p1Links.findIndex((l) => l.destination === t.destination) >= minCount);
98
+ p1Links.findIndex(l => l.destination === t.destination) >= minCount);
99
99
  });
100
100
  if (!vertices?.length) {
101
101
  return;
@@ -119,12 +119,12 @@ export class LinkInstance {
119
119
  triangles: new Map(),
120
120
  };
121
121
  }
122
- async drawParticle(context, particle) {
122
+ drawParticle(context, particle) {
123
123
  const { links, options } = particle;
124
124
  if (!links?.length) {
125
125
  return;
126
126
  }
127
- const p1Links = links.filter((l) => options.links &&
127
+ const p1Links = links.filter(l => options.links &&
128
128
  (options.links.frequency >= maxFrequency ||
129
129
  this._getLinkFrequency(particle, l.destination) <= options.links.frequency));
130
130
  for (const link of p1Links) {
@@ -133,7 +133,6 @@ export class LinkInstance {
133
133
  this._drawLinkLine(particle, link);
134
134
  }
135
135
  }
136
- await Promise.resolve();
137
136
  }
138
137
  async init() {
139
138
  this._freqs.links = new Map();
package/esm/Linker.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Circle, ParticlesInteractorBase, getDistances, getLinkRandomColor, } from "@tsparticles/engine";
2
+ import { CircleWarp } from "./CircleWarp.js";
2
3
  import { Links } from "./Options/Classes/Links.js";
3
4
  const squarePower = 2, opacityOffset = 1, origin = {
4
5
  x: 0,
@@ -21,7 +22,7 @@ function getLinkDistance(pos1, pos2, optDistance, canvasSize, warp) {
21
22
  export class Linker extends ParticlesInteractorBase {
22
23
  constructor(container) {
23
24
  super(container);
24
- this._setColor = (p1) => {
25
+ this._setColor = p1 => {
25
26
  if (!p1.options.links) {
26
27
  return;
27
28
  }
@@ -49,7 +50,7 @@ export class Linker extends ParticlesInteractorBase {
49
50
  this.linkContainer.particles.linksColor = undefined;
50
51
  this.linkContainer.particles.linksColors = new Map();
51
52
  }
52
- async interact(p1) {
53
+ interact(p1) {
53
54
  if (!p1.options.links) {
54
55
  return;
55
56
  }
@@ -61,7 +62,6 @@ export class Linker extends ParticlesInteractorBase {
61
62
  const linkOpt1 = p1.options.links, optOpacity = linkOpt1.opacity, optDistance = p1.retina.linksDistance ?? minDistance, warp = linkOpt1.warp;
62
63
  let range;
63
64
  if (warp) {
64
- const { CircleWarp } = await import("./CircleWarp.js");
65
65
  range = new CircleWarp(pos1.x, pos1.y, optDistance, canvasSize);
66
66
  }
67
67
  else {
@@ -76,8 +76,8 @@ export class Linker extends ParticlesInteractorBase {
76
76
  p2.spawning ||
77
77
  p2.destroyed ||
78
78
  !p2.links ||
79
- p1.links.some((t) => t.destination === p2) ||
80
- p2.links.some((t) => t.destination === p1)) {
79
+ p1.links.some(t => t.destination === p2) ||
80
+ p2.links.some(t => t.destination === p1)) {
81
81
  continue;
82
82
  }
83
83
  const pos2 = p2.getPosition();
@@ -1,10 +1,10 @@
1
+ import { LinkInstance } from "./LinkInstance.js";
1
2
  export class LinksPlugin {
2
3
  constructor() {
3
4
  this.id = "links";
4
5
  }
5
- async getPlugin(container) {
6
- const { LinkInstance } = await import("./LinkInstance.js");
7
- return new LinkInstance(container);
6
+ getPlugin(container) {
7
+ return Promise.resolve(new LinkInstance(container));
8
8
  }
9
9
  loadOptions() {
10
10
  }
package/esm/Utils.js CHANGED
@@ -90,7 +90,7 @@ export function getLinkKey(ids) {
90
90
  return ids.join("_");
91
91
  }
92
92
  export function setLinkFrequency(particles, dictionary) {
93
- const key = getLinkKey(particles.map((t) => t.id));
93
+ const key = getLinkKey(particles.map(t => t.id));
94
94
  let res = dictionary.get(key);
95
95
  if (res === undefined) {
96
96
  res = getRandom();
package/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
+ import { loadLinksInteraction } from "./interaction.js";
2
+ import { loadLinksPlugin } from "./plugin.js";
1
3
  export async function loadParticlesLinksInteraction(engine, refresh = true) {
2
- const { loadLinksInteraction } = await import("./interaction.js"), { loadLinksPlugin } = await import("./plugin.js");
3
4
  await loadLinksInteraction(engine, refresh);
4
5
  await loadLinksPlugin(engine, refresh);
5
6
  }
@@ -1,6 +1,6 @@
1
+ import { Linker } from "./Linker.js";
1
2
  export async function loadLinksInteraction(engine, refresh = true) {
2
3
  await engine.addInteractor("particlesLinks", async (container) => {
3
- const { Linker } = await import("./Linker.js");
4
- return new Linker(container);
4
+ return Promise.resolve(new Linker(container));
5
5
  }, refresh);
6
6
  }
package/esm/plugin.js CHANGED
@@ -1,4 +1,5 @@
1
+ import { LinksPlugin } from "./LinksPlugin.js";
1
2
  export async function loadLinksPlugin(engine, refresh = true) {
2
- const { LinksPlugin } = await import("./LinksPlugin.js"), plugin = new LinksPlugin();
3
+ const plugin = new LinksPlugin();
3
4
  await engine.addPlugin(plugin, refresh);
4
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/interaction-particles-links",
3
- "version": "3.2.2",
3
+ "version": "3.4.0",
4
4
  "description": "tsParticles links particles interaction",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -87,7 +87,7 @@
87
87
  "./package.json": "./package.json"
88
88
  },
89
89
  "dependencies": {
90
- "@tsparticles/engine": "^3.2.2"
90
+ "@tsparticles/engine": "^3.4.0"
91
91
  },
92
92
  "publishConfig": {
93
93
  "access": "public"
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@tsparticles/interaction-particles-links [20 Feb 2024 at 01:33]</title>
6
+ <title>@tsparticles/interaction-particles-links [13 May 2024 at 00:08]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQ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