tsparticles-shape-image
Advanced tools
Comparing version 2.0.5 to 2.0.6
{ | ||
"name": "tsparticles-shape-image", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "tsParticles image shape", | ||
@@ -41,11 +41,10 @@ "homepage": "https://particles.js.org/", | ||
}, | ||
"main": "index.js", | ||
"main": "cjs/index.js", | ||
"jsdelivr": "tsparticles.shape.image.min.js", | ||
"unpkg": "tsparticles.shape.image.min.js", | ||
"browser": "index.js", | ||
"module": "index.js", | ||
"types": "index.d.ts", | ||
"module": "esm/index.js", | ||
"types": "types/index.d.ts", | ||
"dependencies": { | ||
"tsparticles-engine": "^2.0.5" | ||
"tsparticles-engine": "^2.0.6" | ||
} | ||
} |
@@ -7,3 +7,3 @@ /*! | ||
* How to use? : Check the GitHub README | ||
* v2.0.5 | ||
* v2.0.6 | ||
*/ | ||
@@ -19,3 +19,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
} | ||
})(this, function(__WEBPACK_EXTERNAL_MODULE__818__) { | ||
})(this, (__WEBPACK_EXTERNAL_MODULE__818__) => { | ||
return /******/ (() => { // webpackBootstrap | ||
@@ -101,37 +101,16 @@ /******/ "use strict"; | ||
var external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_ = __webpack_require__(818); | ||
;// CONCATENATED MODULE: ./dist/Utils.js | ||
var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { | ||
return value instanceof P ? value : new P(function (resolve) { | ||
resolve(value); | ||
}); | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/Utils.js | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { | ||
try { | ||
step(generator.next(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
/** | ||
* The color regex for replacing values in SVG data | ||
*/ | ||
function rejected(value) { | ||
try { | ||
step(generator["throw"](value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function step(result) { | ||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
const currentColorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi; | ||
/** | ||
* Replaces the color in SVG files when replace color is set | ||
* @param imageShape the image used for replacing SVG data | ||
* @param color the replace color value | ||
* @param opacity the color opacity | ||
* @returns the new SVG data | ||
*/ | ||
@@ -148,2 +127,3 @@ function replaceColorSvg(imageShape, color, opacity) { | ||
const colorStyle = (0,external_commonjs_tsparticles_engine_commonjs2_tsparticles_engine_amd_tsparticles_engine_root_window_.getStyleFromHsl)(color, opacity); | ||
/* set color to svg element */ | ||
@@ -157,44 +137,58 @@ if (svgData.includes("fill")) { | ||
} | ||
/** | ||
* Loads the given image | ||
* @param image the image to load | ||
*/ | ||
function loadImage(image) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return new Promise(resolve => { | ||
image.loading = true; | ||
const img = new Image(); | ||
img.addEventListener("load", () => { | ||
image.element = img; | ||
image.loading = false; | ||
resolve(); | ||
}); | ||
img.addEventListener("error", () => { | ||
image.error = true; | ||
image.loading = false; | ||
console.error(`Error tsParticles - loading image: ${image.source}`); | ||
resolve(); | ||
}); | ||
img.src = image.source; | ||
async function loadImage(image) { | ||
return new Promise(resolve => { | ||
image.loading = true; | ||
const img = new Image(); | ||
img.addEventListener("load", () => { | ||
image.element = img; | ||
image.loading = false; | ||
resolve(); | ||
}); | ||
img.addEventListener("error", () => { | ||
image.error = true; | ||
image.loading = false; | ||
console.error(`Error tsParticles - loading image: ${image.source}`); | ||
resolve(); | ||
}); | ||
img.src = image.source; | ||
}); | ||
} | ||
function downloadSvgImage(image) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (image.type !== "svg") { | ||
yield loadImage(image); | ||
return; | ||
} | ||
/** | ||
* Downloads the SVG image data, using `fetch` | ||
* @param image the image to download | ||
*/ | ||
image.loading = true; | ||
const response = yield fetch(image.source); | ||
image.loading = false; | ||
async function downloadSvgImage(image) { | ||
if (image.type !== "svg") { | ||
await loadImage(image); | ||
return; | ||
} | ||
if (!response.ok) { | ||
console.error("Error tsParticles - Image not found"); | ||
image.error = true; | ||
} | ||
image.loading = true; | ||
const response = await fetch(image.source); | ||
image.loading = false; | ||
if (!image.error) { | ||
image.svgData = yield response.text(); | ||
} | ||
}); | ||
if (!response.ok) { | ||
console.error("Error tsParticles - Image not found"); | ||
image.error = true; | ||
} | ||
if (!image.error) { | ||
image.svgData = await response.text(); | ||
} | ||
} | ||
/** | ||
* Replaces the color in a SVG image | ||
* @param image the SVG image to replace | ||
* @param imageData the image shape data | ||
* @param color the replace color | ||
* @param particle the particle where the replaced data is going to be used | ||
*/ | ||
function replaceImageColor(image, imageData, color, particle) { | ||
@@ -204,2 +198,4 @@ var _a, _b, _c; | ||
const svgColoredData = replaceColorSvg(image, color, (_b = (_a = particle.opacity) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 1); | ||
/* prepare to create img with colored svg */ | ||
const svg = new Blob([svgColoredData], { | ||
@@ -210,2 +206,4 @@ type: "image/svg+xml" | ||
const url = domUrl.createObjectURL(svg); | ||
/* create particle img obj */ | ||
const img = new Image(); | ||
@@ -235,3 +233,4 @@ const imageRes = { | ||
loading: true | ||
}); | ||
}); // deepcode ignore PromiseNotCaughtGeneral: catch can be ignored | ||
loadImage(img2).then(() => { | ||
@@ -249,35 +248,3 @@ const pImage = particle.image; | ||
} | ||
;// CONCATENATED MODULE: ./dist/ImageDrawer.js | ||
var ImageDrawer_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { | ||
return value instanceof P ? value : new P(function (resolve) { | ||
resolve(value); | ||
}); | ||
} | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { | ||
try { | ||
step(generator.next(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function rejected(value) { | ||
try { | ||
step(generator["throw"](value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function step(result) { | ||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
;// CONCATENATED MODULE: ./dist/browser/ImageDrawer.js | ||
var __classPrivateFieldSet = undefined && undefined.__classPrivateFieldSet || function (receiver, state, value, kind, f) { | ||
@@ -299,4 +266,15 @@ if (kind === "m") throw new TypeError("Private method is not writable"); | ||
/** | ||
* @category Shape Drawers | ||
*/ | ||
class ImageDrawer { | ||
/** | ||
* Image drawer constructor, initializing the image set collection | ||
*/ | ||
constructor() { | ||
/** | ||
* The image set collection | ||
* @private | ||
*/ | ||
_ImageDrawer_images.set(this, void 0); | ||
@@ -306,7 +284,18 @@ | ||
} | ||
/** | ||
* Returning the side count for the image, defaults to 12 for using the inner circle as rendering | ||
* When using non-transparent images this can be an issue with shadows | ||
*/ | ||
getSidesCount() { | ||
return 12; | ||
} | ||
/** | ||
* Gets the image collection of the given container | ||
* @param container the container requesting the image collection | ||
* @returns the container image collection | ||
*/ | ||
getImages(container) { | ||
@@ -326,3 +315,9 @@ const containerImages = __classPrivateFieldGet(this, _ImageDrawer_images, "f").find(t => t.id === container.id); | ||
} | ||
/** | ||
* Adds an image to the given container | ||
* @param container the container where the image is going to be added | ||
* @param image the image to add to the container collection | ||
*/ | ||
addImage(container, image) { | ||
@@ -332,7 +327,19 @@ const containerImages = this.getImages(container); | ||
} | ||
/** | ||
* Resets the image general collection | ||
*/ | ||
destroy() { | ||
__classPrivateFieldSet(this, _ImageDrawer_images, [], "f"); | ||
} | ||
/** | ||
* The draw image method | ||
* @param context the context used for drawing | ||
* @param particle the particle to be drawn | ||
* @param radius the particle radius | ||
* @param opacity the particle opacity | ||
*/ | ||
draw(context, particle, radius, opacity) { | ||
@@ -364,3 +371,8 @@ var _a, _b; | ||
} | ||
/** | ||
* Loads the image shape to the given particle | ||
* @param particle the particle loading the image shape | ||
*/ | ||
loadShape(particle) { | ||
@@ -418,25 +430,30 @@ var _a, _b, _c; | ||
} | ||
/** | ||
* Loads the image shape | ||
* @param container the container used for searching images | ||
* @param imageShape the image shape to load | ||
* @private | ||
*/ | ||
loadImageShape(container, imageShape) { | ||
return ImageDrawer_awaiter(this, void 0, void 0, function* () { | ||
const source = imageShape.src; | ||
if (!source) { | ||
throw new Error("Error tsParticles - No image.src"); | ||
} | ||
async loadImageShape(container, imageShape) { | ||
const source = imageShape.src; | ||
try { | ||
const image = { | ||
source: source, | ||
type: source.substr(source.length - 3), | ||
error: false, | ||
loading: true | ||
}; | ||
this.addImage(container, image); | ||
const imageFunc = imageShape.replaceColor ? downloadSvgImage : loadImage; | ||
yield imageFunc(image); | ||
} catch (_a) { | ||
throw new Error(`tsParticles error - ${imageShape.src} not found`); | ||
} | ||
}); | ||
if (!source) { | ||
throw new Error("Error tsParticles - No image.src"); | ||
} | ||
try { | ||
const image = { | ||
source: source, | ||
type: source.substr(source.length - 3), | ||
error: false, | ||
loading: true | ||
}; | ||
this.addImage(container, image); | ||
const imageFunc = imageShape.replaceColor ? downloadSvgImage : loadImage; | ||
await imageFunc(image); | ||
} catch (_a) { | ||
throw new Error(`tsParticles error - ${imageShape.src} not found`); | ||
} | ||
} | ||
@@ -446,42 +463,13 @@ | ||
_ImageDrawer_images = new WeakMap(); | ||
;// CONCATENATED MODULE: ./dist/index.js | ||
var dist_awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { | ||
return value instanceof P ? value : new P(function (resolve) { | ||
resolve(value); | ||
}); | ||
} | ||
;// CONCATENATED MODULE: ./dist/browser/index.js | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { | ||
try { | ||
step(generator.next(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
/** | ||
* Loads the image shape in the given engine | ||
* @param engine the engine where the image shape is going to be added | ||
*/ | ||
function rejected(value) { | ||
try { | ||
step(generator["throw"](value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function step(result) { | ||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
function loadImageShape(engine) { | ||
return dist_awaiter(this, void 0, void 0, function* () { | ||
const imageDrawer = new ImageDrawer(); | ||
yield engine.addShape("image", imageDrawer); | ||
yield engine.addShape("images", imageDrawer); | ||
}); | ||
async function loadImageShape(engine) { | ||
const imageDrawer = new ImageDrawer(); | ||
await engine.addShape("image", imageDrawer); | ||
await engine.addShape("images", imageDrawer); | ||
} | ||
@@ -488,0 +476,0 @@ })(); |
@@ -1,2 +0,2 @@ | ||
/*! tsParticles Image Shape v2.0.5 by Matteo Bruni */ | ||
!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 o="object"==typeof exports?t(require("tsparticles-engine")):t(e.window);for(var r in o)("object"==typeof exports?exports:e)[r]=o[r]}}(this,(function(e){return(()=>{"use strict";var t={818:t=>{t.exports=e}},o={};function r(e){var n=o[e];if(void 0!==n)return n.exports;var i=o[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{loadImageShape:()=>v});var e=r(818),t=function(e,t,o,r){return new(o||(o=Promise))((function(n,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))};const o=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;function i(e){return t(this,void 0,void 0,(function*(){return new Promise((t=>{e.loading=!0;const o=new Image;o.addEventListener("load",(()=>{e.element=o,e.loading=!1,t()})),o.addEventListener("error",(()=>{e.error=!0,e.loading=!1,console.error(`Error tsParticles - loading image: ${e.source}`),t()})),o.src=e.source}))}))}function a(e){return t(this,void 0,void 0,(function*(){if("svg"!==e.type)return void(yield i(e));e.loading=!0;const t=yield fetch(e.source);e.loading=!1,t.ok||(console.error("Error tsParticles - Image not found"),e.error=!0),e.error||(e.svgData=yield t.text())}))}function s(t,r,n,a){var s,l,c;const d=function(t,r,n){const{svgData:i}=t;if(!i)return"";const a=(0,e.getStyleFromHsl)(r,n);if(i.includes("fill"))return i.replace(o,(()=>a));const s=i.indexOf(">");return`${i.substring(0,s)} fill="${a}"${i.substring(s)}`}(t,n,null!==(l=null===(s=a.opacity)||void 0===s?void 0:s.value)&&void 0!==l?l:1),u=new Blob([d],{type:"image/svg+xml"}),f=URL||window.URL||window.webkitURL||window,g=f.createObjectURL(u),v=new Image,p={data:Object.assign(Object.assign({},t),{svgData:d}),ratio:r.width/r.height,replaceColor:null!==(c=r.replaceColor)&&void 0!==c?c:r.replace_color,source:r.src};return v.addEventListener("load",(()=>{const e=a.image;e&&(e.loaded=!0,t.element=v),f.revokeObjectURL(g)})),v.addEventListener("error",(()=>{f.revokeObjectURL(g);const e=Object.assign(Object.assign({},t),{error:!1,loading:!0});i(e).then((()=>{const o=a.image;o&&(t.element=e.element,o.loaded=!0)}))})),v.src=g,p}var l,c=function(e,t,o,r){return new(o||(o=Promise))((function(n,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))},d=function(e,t,o,r,n){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===r?n.call(e,o):n?n.value=o:t.set(e,o),o},u=function(e,t,o,r){if("a"===o&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?r:"a"===o?r.call(e):r?r.value:t.get(e)};class f{constructor(){l.set(this,void 0),d(this,l,[],"f")}getSidesCount(){return 12}getImages(e){const t=u(this,l,"f").find((t=>t.id===e.id));return t||(u(this,l,"f").push({id:e.id,images:[]}),this.getImages(e))}addImage(e,t){const o=this.getImages(e);null==o||o.images.push(t)}destroy(){d(this,l,[],"f")}draw(e,t,o,r){var n,i;const a=t.image,s=null===(n=null==a?void 0:a.data)||void 0===n?void 0:n.element;if(!s)return;const l=null!==(i=null==a?void 0:a.ratio)&&void 0!==i?i:1,c={x:-o,y:-o};(null==a?void 0:a.data.svgData)&&(null==a?void 0:a.replaceColor)||(e.globalAlpha=r),e.drawImage(s,c.x,c.y,2*o,2*o/l),(null==a?void 0:a.data.svgData)&&(null==a?void 0:a.replaceColor)||(e.globalAlpha=1)}loadShape(e){var t,o,r;if("image"!==e.shape&&"images"!==e.shape)return;const n=this.getImages(e.container).images,i=e.shapeData,a=n.find((e=>e.source===i.src));let l;if(!a)return void this.loadImageShape(e.container,i).then((()=>{this.loadShape(e)}));if(a.error)return;const c=e.getFillColor();l=a.svgData&&i.replaceColor&&c?s(a,i,c,e):{data:a,loaded:!0,ratio:i.width/i.height,replaceColor:null!==(t=i.replaceColor)&&void 0!==t?t:i.replace_color,source:i.src},l.ratio||(l.ratio=1);const d={image:l,fill:null!==(o=i.fill)&&void 0!==o?o:e.fill,close:null!==(r=i.close)&&void 0!==r?r:e.close};e.image=d.image,e.fill=d.fill,e.close=d.close}loadImageShape(e,t){return c(this,void 0,void 0,(function*(){const o=t.src;if(!o)throw new Error("Error tsParticles - No image.src");try{const r={source:o,type:o.substr(o.length-3),error:!1,loading:!0};this.addImage(e,r);const n=t.replaceColor?a:i;yield n(r)}catch(e){throw new Error(`tsParticles error - ${t.src} not found`)}}))}}l=new WeakMap;var g=function(e,t,o,r){return new(o||(o=Promise))((function(n,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))};function v(e){return g(this,void 0,void 0,(function*(){const t=new f;yield e.addShape("image",t),yield e.addShape("images",t)}))}})(),n})()})); | ||
/*! tsParticles Image Shape v2.0.6 by Matteo Bruni */ | ||
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r(require("tsparticles-engine"));else if("function"==typeof define&&define.amd)define(["tsparticles-engine"],r);else{var t="object"==typeof exports?r(require("tsparticles-engine")):r(e.window);for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}(this,(e=>(()=>{"use strict";var r={818:r=>{r.exports=e}},t={};function o(e){var a=t[e];if(void 0!==a)return a.exports;var i=t[e]={exports:{}};return r[e](i,i.exports,o),i.exports}o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{o.r(a),o.d(a,{loadImageShape:()=>u});var e=o(818);const r=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;async function t(e){return new Promise((r=>{e.loading=!0;const t=new Image;t.addEventListener("load",(()=>{e.element=t,e.loading=!1,r()})),t.addEventListener("error",(()=>{e.error=!0,e.loading=!1,console.error(`Error tsParticles - loading image: ${e.source}`),r()})),t.src=e.source}))}async function i(e){if("svg"!==e.type)return void await t(e);e.loading=!0;const r=await fetch(e.source);e.loading=!1,r.ok||(console.error("Error tsParticles - Image not found"),e.error=!0),e.error||(e.svgData=await r.text())}function n(o,a,i,n){var s,l,c;const d=function(t,o,a){const{svgData:i}=t;if(!i)return"";const n=(0,e.getStyleFromHsl)(o,a);if(i.includes("fill"))return i.replace(r,(()=>n));const s=i.indexOf(">");return`${i.substring(0,s)} fill="${n}"${i.substring(s)}`}(o,i,null!==(l=null===(s=n.opacity)||void 0===s?void 0:s.value)&&void 0!==l?l:1),u=new Blob([d],{type:"image/svg+xml"}),g=URL||window.URL||window.webkitURL||window,f=g.createObjectURL(u),p=new Image,v={data:Object.assign(Object.assign({},o),{svgData:d}),ratio:a.width/a.height,replaceColor:null!==(c=a.replaceColor)&&void 0!==c?c:a.replace_color,source:a.src};return p.addEventListener("load",(()=>{const e=n.image;e&&(e.loaded=!0,o.element=p),g.revokeObjectURL(f)})),p.addEventListener("error",(()=>{g.revokeObjectURL(f);const e=Object.assign(Object.assign({},o),{error:!1,loading:!0});t(e).then((()=>{const r=n.image;r&&(o.element=e.element,r.loaded=!0)}))})),p.src=f,v}var s,l=function(e,r,t,o,a){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof r?e!==r||!a:!r.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?a.call(e,t):a?a.value=t:r.set(e,t),t},c=function(e,r,t,o){if("a"===t&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof r?e!==r||!o:!r.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===t?o:"a"===t?o.call(e):o?o.value:r.get(e)};class d{constructor(){s.set(this,void 0),l(this,s,[],"f")}getSidesCount(){return 12}getImages(e){const r=c(this,s,"f").find((r=>r.id===e.id));return r||(c(this,s,"f").push({id:e.id,images:[]}),this.getImages(e))}addImage(e,r){const t=this.getImages(e);null==t||t.images.push(r)}destroy(){l(this,s,[],"f")}draw(e,r,t,o){var a,i;const n=r.image,s=null===(a=null==n?void 0:n.data)||void 0===a?void 0:a.element;if(!s)return;const l=null!==(i=null==n?void 0:n.ratio)&&void 0!==i?i:1,c={x:-t,y:-t};(null==n?void 0:n.data.svgData)&&(null==n?void 0:n.replaceColor)||(e.globalAlpha=o),e.drawImage(s,c.x,c.y,2*t,2*t/l),(null==n?void 0:n.data.svgData)&&(null==n?void 0:n.replaceColor)||(e.globalAlpha=1)}loadShape(e){var r,t,o;if("image"!==e.shape&&"images"!==e.shape)return;const a=this.getImages(e.container).images,i=e.shapeData,s=a.find((e=>e.source===i.src));let l;if(!s)return void this.loadImageShape(e.container,i).then((()=>{this.loadShape(e)}));if(s.error)return;const c=e.getFillColor();l=s.svgData&&i.replaceColor&&c?n(s,i,c,e):{data:s,loaded:!0,ratio:i.width/i.height,replaceColor:null!==(r=i.replaceColor)&&void 0!==r?r:i.replace_color,source:i.src},l.ratio||(l.ratio=1);const d={image:l,fill:null!==(t=i.fill)&&void 0!==t?t:e.fill,close:null!==(o=i.close)&&void 0!==o?o:e.close};e.image=d.image,e.fill=d.fill,e.close=d.close}async loadImageShape(e,r){const o=r.src;if(!o)throw new Error("Error tsParticles - No image.src");try{const a={source:o,type:o.substr(o.length-3),error:!1,loading:!0};this.addImage(e,a);const n=r.replaceColor?i:t;await n(a)}catch(e){throw new Error(`tsParticles error - ${r.src} not found`)}}}async function u(e){const r=new d;await e.addShape("image",r),await e.addShape("images",r)}s=new WeakMap})(),a})())); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
342573
25
1470
7
Updatedtsparticles-engine@^2.0.6