@tsparticles/plugin-trail 4.0.0-beta.0 → 4.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.
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-beta.0
7
+ * v4.0.0-beta.1
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -44,7 +44,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
44
44
  \*******************************/
45
45
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
46
46
 
47
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadTrailPlugin: () => (/* binding */ loadTrailPlugin)\n/* harmony export */ });\nasync function loadTrailPlugin(engine) {\n engine.checkVersion(\"4.0.0-beta.0\");\n await engine.register(async (e)=>{\n const { TrailPlugin } = await __webpack_require__.e(/*! import() */ \"dist_browser_TrailPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./TrailPlugin.js */ \"./dist/browser/TrailPlugin.js\"));\n e.addPlugin(new TrailPlugin(engine));\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-trail/./dist/browser/index.js?\n}");
47
+ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadTrailPlugin: () => (/* binding */ loadTrailPlugin)\n/* harmony export */ });\nasync function loadTrailPlugin(engine) {\n engine.checkVersion(\"4.0.0-beta.1\");\n await engine.pluginManager.register(async (e)=>{\n const { TrailPlugin } = await __webpack_require__.e(/*! import() */ \"dist_browser_TrailPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./TrailPlugin.js */ \"./dist/browser/TrailPlugin.js\"));\n e.pluginManager.addPlugin(new TrailPlugin(e.pluginManager));\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-trail/./dist/browser/index.js?\n}");
48
48
 
49
49
  /***/ }
50
50
 
@@ -1,2 +1,2 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,e=>(()=>{"use strict";var t,r,o,i={303(t){t.exports=e}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return i[e](r,r.exports,a),r.exports}a.m=i,a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,r)=>(a.f[r](e,t),t),[])),a.u=e=>""+e+".min.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s={},a.l=(e,t,r,o)=>{if(s[e])return void s[e].push(t);if(void 0!==r)for(var i,n,l=document.getElementsByTagName("script"),c=0;c<l.length;c++){var p=l[c];if(p.getAttribute("src")==e||p.getAttribute("data-webpack")=="@tsparticles/plugin-trail:"+r){i=p;break}}i||(n=!0,(i=document.createElement("script")).charset="utf-8",a.nc&&i.setAttribute("nonce",a.nc),i.setAttribute("data-webpack","@tsparticles/plugin-trail:"+r),i.src=e),s[e]=[t];var u=(t,r)=>{i.onerror=i.onload=null,clearTimeout(d);var o=s[e];if(delete s[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach(e=>e(r)),t)return t(r)},d=setTimeout(u.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=u.bind(null,i.onerror),i.onload=u.bind(null,i.onload),n&&document.head.appendChild(i)},a.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.g.importScripts&&(l=a.g.location+"");var s,l,c=a.g.document;if(!l&&c&&(c.currentScript&&"SCRIPT"===c.currentScript.tagName.toUpperCase()&&(l=c.currentScript.src),!l)){var p=c.getElementsByTagName("script");if(p.length)for(var u=p.length-1;u>-1&&(!l||!/^http(s?):/.test(l));)l=p[u--].src}if(!l)throw Error("Automatic publicPath is not supported in this browser");a.p=l=l.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t={576:0},a.f.j=(e,r)=>{var o=a.o(t,e)?t[e]:void 0;if(0!==o)if(o)r.push(o[2]);else{var i=new Promise((r,i)=>o=t[e]=[r,i]);r.push(o[2]=i);var n=a.p+a.u(e),s=Error();a.l(n,r=>{if(a.o(t,e)&&(0!==(o=t[e])&&(t[e]=void 0),o)){var i=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;s.message="Loading chunk "+e+` failed.
2
- (`+i+": "+n+")",s.name="ChunkLoadError",s.type=i,s.request=n,o[1](s)}},"chunk-"+e,e)}},r=(e,r)=>{var o,i,[n,s,l]=r,c=0;if(n.some(e=>0!==t[e])){for(o in s)a.o(s,o)&&(a.m[o]=s[o]);l&&l(a)}for(e&&e(r);c<n.length;c++)i=n[c],a.o(t,i)&&t[i]&&t[i][0](),t[i]=0},(o=this.webpackChunk_tsparticles_plugin_trail=this.webpackChunk_tsparticles_plugin_trail||[]).forEach(r.bind(null,0)),o.push=r.bind(null,o.push.bind(o));var d={};async function f(e){e.checkVersion("4.0.0-beta.0"),await e.register(async t=>{let{TrailPlugin:r}=await a.e(408).then(a.bind(a,408));t.addPlugin(new r(e))})}return a.r(d),a.d(d,{loadTrailPlugin:()=>f}),d})());
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var r="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var i in r)("object"==typeof exports?exports:e)[i]=r[i]}}(this,e=>(()=>{"use strict";var t,r,i,o={303(t){t.exports=e}},n={};function a(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={exports:{}};return o[e](r,r.exports,a),r.exports}a.m=o,a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.f={},a.e=e=>Promise.all(Object.keys(a.f).reduce((t,r)=>(a.f[r](e,t),t),[])),a.u=e=>""+e+".min.js",a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),l={},a.l=(e,t,r,i)=>{if(l[e])return void l[e].push(t);if(void 0!==r)for(var o,n,s=document.getElementsByTagName("script"),p=0;p<s.length;p++){var c=s[p];if(c.getAttribute("src")==e||c.getAttribute("data-webpack")=="@tsparticles/plugin-trail:"+r){o=c;break}}o||(n=!0,(o=document.createElement("script")).charset="utf-8",a.nc&&o.setAttribute("nonce",a.nc),o.setAttribute("data-webpack","@tsparticles/plugin-trail:"+r),o.src=e),l[e]=[t];var u=(t,r)=>{o.onerror=o.onload=null,clearTimeout(d);var i=l[e];if(delete l[e],o.parentNode&&o.parentNode.removeChild(o),i&&i.forEach(e=>e(r)),t)return t(r)},d=setTimeout(u.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=u.bind(null,o.onerror),o.onload=u.bind(null,o.onload),n&&document.head.appendChild(o)},a.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.g.importScripts&&(s=a.g.location+"");var l,s,p=a.g.document;if(!s&&p&&(p.currentScript&&"SCRIPT"===p.currentScript.tagName.toUpperCase()&&(s=p.currentScript.src),!s)){var c=p.getElementsByTagName("script");if(c.length)for(var u=c.length-1;u>-1&&(!s||!/^http(s?):/.test(s));)s=c[u--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");a.p=s=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),t={576:0},a.f.j=(e,r)=>{var i=a.o(t,e)?t[e]:void 0;if(0!==i)if(i)r.push(i[2]);else{var o=new Promise((r,o)=>i=t[e]=[r,o]);r.push(i[2]=o);var n=a.p+a.u(e),l=Error();a.l(n,r=>{if(a.o(t,e)&&(0!==(i=t[e])&&(t[e]=void 0),i)){var o=r&&("load"===r.type?"missing":r.type),n=r&&r.target&&r.target.src;l.message="Loading chunk "+e+` failed.
2
+ (`+o+": "+n+")",l.name="ChunkLoadError",l.type=o,l.request=n,i[1](l)}},"chunk-"+e,e)}},r=(e,r)=>{var i,o,[n,l,s]=r,p=0;if(n.some(e=>0!==t[e])){for(i in l)a.o(l,i)&&(a.m[i]=l[i]);s&&s(a)}for(e&&e(r);p<n.length;p++)o=n[p],a.o(t,o)&&t[o]&&t[o][0](),t[o]=0},(i=this.webpackChunk_tsparticles_plugin_trail=this.webpackChunk_tsparticles_plugin_trail||[]).forEach(r.bind(null,0)),i.push=r.bind(null,i.push.bind(i));var d={};async function f(e){e.checkVersion("4.0.0-beta.1"),await e.pluginManager.register(async e=>{let{TrailPlugin:t}=await a.e(164).then(a.bind(a,164));e.pluginManager.addPlugin(new t(e.pluginManager))})}return a.r(d),a.d(d,{loadTrailPlugin:()=>f}),d})());
@@ -1,9 +1,9 @@
1
- import type { Container, Engine, IContainerPlugin, IPlugin, RecursivePartial } from "@tsparticles/engine";
1
+ import type { Container, IContainerPlugin, IPlugin, PluginManager, RecursivePartial } from "@tsparticles/engine";
2
2
  import type { ITrailOptions, TrailOptions } from "./types.js";
3
3
  export declare class TrailPlugin implements IPlugin {
4
4
  readonly id = "trail";
5
- private readonly _engine;
6
- constructor(engine: Engine);
5
+ private readonly _pluginManager;
6
+ constructor(pluginManager: PluginManager);
7
7
  getPlugin(container: Container): Promise<IContainerPlugin>;
8
8
  loadOptions(_container: Container, options: TrailOptions, source?: RecursivePartial<ITrailOptions>): void;
9
9
  needsPlugin(): boolean;
@@ -1,10 +1,10 @@
1
- import { type Engine, type IContainerPlugin } from "@tsparticles/engine";
1
+ import { type IContainerPlugin, type PluginManager } from "@tsparticles/engine";
2
2
  import type { TrailContainer } from "./types.js";
3
3
  export declare class TrailPluginInstance implements IContainerPlugin {
4
4
  private readonly _container;
5
- private readonly _engine;
5
+ private readonly _pluginManager;
6
6
  private _trailFill?;
7
- constructor(container: TrailContainer, engine: Engine);
7
+ constructor(pluginManager: PluginManager, container: TrailContainer);
8
8
  canvasClear(): boolean;
9
9
  init(): Promise<void>;
10
10
  private readonly _initTrail;
@@ -47,13 +47,13 @@ var __importStar = (this && this.__importStar) || (function () {
47
47
  const Trail_js_1 = require("./Options/Classes/Trail.js");
48
48
  class TrailPlugin {
49
49
  id = "trail";
50
- _engine;
51
- constructor(engine) {
52
- this._engine = engine;
50
+ _pluginManager;
51
+ constructor(pluginManager) {
52
+ this._pluginManager = pluginManager;
53
53
  }
54
54
  async getPlugin(container) {
55
55
  const { TrailPluginInstance } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./TrailPluginInstance.js"))) : new Promise((resolve_1, reject_1) => { require(["./TrailPluginInstance.js"], resolve_1, reject_1); }).then(__importStar));
56
- return new TrailPluginInstance(container, this._engine);
56
+ return new TrailPluginInstance(this._pluginManager, container);
57
57
  }
58
58
  loadOptions(_container, options, source) {
59
59
  if (!this.needsPlugin()) {
@@ -14,11 +14,11 @@
14
14
  const minimumLength = 0;
15
15
  class TrailPluginInstance {
16
16
  _container;
17
- _engine;
17
+ _pluginManager;
18
18
  _trailFill;
19
- constructor(container, engine) {
19
+ constructor(pluginManager, container) {
20
20
  this._container = container;
21
- this._engine = engine;
21
+ this._pluginManager = pluginManager;
22
22
  }
23
23
  canvasClear() {
24
24
  const container = this._container, trail = container.actualOptions.trail, trailFill = this._trailFill;
@@ -28,11 +28,11 @@
28
28
  let handled = false;
29
29
  const canvas = container.canvas;
30
30
  if (trailFill.color) {
31
- canvas.paintBase((0, engine_1.getStyleFromRgb)(trailFill.color, container.hdr, trailFill.opacity));
31
+ canvas.render.paintBase((0, engine_1.getStyleFromRgb)(trailFill.color, container.hdr, trailFill.opacity));
32
32
  handled = true;
33
33
  }
34
34
  else if (trailFill.image) {
35
- canvas.paintImage(trailFill.image, trailFill.opacity);
35
+ canvas.render.paintImage(trailFill.image, trailFill.opacity);
36
36
  handled = true;
37
37
  }
38
38
  return handled;
@@ -52,7 +52,7 @@
52
52
  }
53
53
  const trailFill = trail.fill, opacity = engine_1.inverseFactorNumerator / trail.length;
54
54
  if (trailFill.color) {
55
- const fillColor = (0, engine_1.rangeColorToRgb)(this._engine, trailFill.color);
55
+ const fillColor = (0, engine_1.rangeColorToRgb)(this._pluginManager, trailFill.color);
56
56
  if (!fillColor) {
57
57
  return;
58
58
  }
package/umd/index.js CHANGED
@@ -45,10 +45,10 @@ var __importStar = (this && this.__importStar) || (function () {
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
46
  exports.loadTrailPlugin = loadTrailPlugin;
47
47
  async function loadTrailPlugin(engine) {
48
- engine.checkVersion("4.0.0-beta.0");
49
- await engine.register(async (e) => {
48
+ engine.checkVersion("4.0.0-beta.1");
49
+ await engine.pluginManager.register(async (e) => {
50
50
  const { TrailPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./TrailPlugin.js"))) : new Promise((resolve_1, reject_1) => { require(["./TrailPlugin.js"], resolve_1, reject_1); }).then(__importStar));
51
- e.addPlugin(new TrailPlugin(engine));
51
+ e.pluginManager.addPlugin(new TrailPlugin(e.pluginManager));
52
52
  });
53
53
  }
54
54
  });
package/408.min.js DELETED
@@ -1 +0,0 @@
1
- "use strict";(this.webpackChunk_tsparticles_plugin_trail=this.webpackChunk_tsparticles_plugin_trail||[]).push([[408],{408(l,i,e){e.d(i,{TrailPlugin:()=>a});var t=e(303);class n{color;image;load(l){(0,t.isNull)(l)||(void 0!==l.color&&(this.color=t.OptionsColor.create(this.color,l.color)),void 0!==l.image&&(this.image=l.image))}}class s{enable;fill;length;constructor(){this.enable=!1,this.length=10,this.fill=new n}load(l){(0,t.isNull)(l)||(void 0!==l.enable&&(this.enable=l.enable),void 0!==l.fill&&this.fill.load(l.fill),void 0!==l.length&&(this.length=l.length))}}class a{id="trail";_engine;constructor(l){this._engine=l}async getPlugin(l){let{TrailPluginInstance:i}=await e.e(542).then(e.bind(e,542));return new i(l,this._engine)}loadOptions(l,i,e){if(!this.needsPlugin())return;let t=i.trail;t?.load||(i.trail=t=new s),t.load(e?.trail)}needsPlugin(){return!0}}}}]);
package/542.min.js DELETED
@@ -1 +0,0 @@
1
- "use strict";(this.webpackChunk_tsparticles_plugin_trail=this.webpackChunk_tsparticles_plugin_trail||[]).push([[542],{542(t,e,i){i.d(e,{TrailPluginInstance:()=>a});var r=i(303);class a{_container;_engine;_trailFill;constructor(t,e){this._container=t,this._engine=e}canvasClear(){let t=this._container,e=t.actualOptions.trail,i=this._trailFill;if(!e?.enable||!i||e.length<=0)return!1;let a=!1,n=t.canvas;return i.color?(n.paintBase((0,r.getStyleFromRgb)(i.color,t.hdr,i.opacity)),a=!0):i.image&&(n.paintImage(i.image,i.opacity),a=!0),a}async init(){try{await this._initTrail()}catch(t){(0,r.getLogger)().error(t)}}_initTrail=async()=>{let t=this._container.actualOptions.trail;if(!t?.enable)return;let e=t.fill,i=r.inverseFactorNumerator/t.length;if(e.color){let t=(0,r.rangeColorToRgb)(this._engine,e.color);if(!t)return;this._trailFill={color:{...t},opacity:i}}else await new Promise((t,a)=>{if(!e.image)return;let n=(0,r.safeDocument)().createElement("img");n.addEventListener("load",()=>{this._trailFill={image:n,opacity:i},t()}),n.addEventListener("error",t=>{(0,r.getLogger)().error(t),a(Error("Error loading image"))}),n.src=e.image})}}}}]);