Socket
Socket
Sign inDemoInstall

tsparticles-shape-image

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tsparticles-shape-image - npm Package Compare versions

Comparing version 2.0.0-beta.1 to 2.0.0-beta.2

4

package.json
{
"name": "tsparticles-shape-image",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"description": "tsParticles image shape",

@@ -48,4 +48,4 @@ "homepage": "https://particles.js.org/",

"dependencies": {
"tsparticles-engine": "^2.0.0-beta.0"
"tsparticles-engine": "^2.0.0-beta.1"
}
}

@@ -7,3 +7,3 @@ /*!

* How to use? : Check the GitHub README
* v2.0.0-beta.1
* v2.0.0-beta.2
*/

@@ -10,0 +10,0 @@ (function webpackUniversalModuleDefinition(root, factory) {

@@ -1,2 +0,2 @@

/*! tsParticles Image Shape v2.0.0-beta.1 by Matteo Bruni */
/*! tsParticles Image Shape v2.0.0-beta.2 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 i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(this,(function(e){return(()=>{"use strict";var t={818:t=>{t.exports=e}},o={};function i(e){var r=o[e];if(void 0!==r)return r.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,i),n.exports}i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{i.r(r),i.d(r,{loadImageShape:()=>u});var e=i(818),t=function(e,t,o,i){return new(o||(o=Promise))((function(r,n){function a(e){try{l(i.next(e))}catch(e){n(e)}}function s(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}l((i=i.apply(e,t||[])).next())}))};function o(e){return new Promise(((t,o)=>{if(!e)return void o("Error tsParticles - No image.src");const i={source:e,type:e.substr(e.length-3)},r=new Image;r.addEventListener("load",(()=>{i.element=r,t(i)})),r.addEventListener("error",(()=>{o(`Error tsParticles - loading image: ${e}`)})),r.src=e}))}function n(e){return t(this,void 0,void 0,(function*(){if(!e)throw new Error("Error tsParticles - No image.src");const t={source:e,type:e.substr(e.length-3)};if("svg"!==t.type)return o(e);const i=yield fetch(t.source);if(!i.ok)throw new Error("Error tsParticles - Image not found");return t.svgData=yield i.text(),t}))}var a,s=function(e,t,o,i){return new(o||(o=Promise))((function(r,n){function a(e){try{l(i.next(e))}catch(e){n(e)}}function s(e){try{l(i.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(a,s)}l((i=i.apply(e,t||[])).next())}))},l=function(e,t,o,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,o):r?r.value=o:t.set(e,o),o},c=function(e,t,o,i){if("a"===o&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===o?i:"a"===o?i.call(e):i?i.value:t.get(e)};class d{constructor(){a.set(this,void 0),l(this,a,[],"f")}getSidesCount(){return 12}getImages(e){const t=c(this,a,"f").find((t=>t.id===e.id));return t||(c(this,a,"f").push({id:e.id,images:[]}),this.getImages(e))}addImage(e,t){const o=this.getImages(e);null==o||o.images.push(t)}init(e){return s(this,void 0,void 0,(function*(){yield this.loadImagesFromParticlesOptions(e,e.actualOptions.particles),yield this.loadImagesFromParticlesOptions(e,e.actualOptions.interactivity.modes.trail.particles);for(const t of e.actualOptions.manualParticles)yield this.loadImagesFromParticlesOptions(e,t.options);const t=e.actualOptions;if(t.emitters)if(t.emitters instanceof Array)for(const o of t.emitters)yield this.loadImagesFromParticlesOptions(e,o.particles);else yield this.loadImagesFromParticlesOptions(e,t.emitters.particles);const o=t.interactivity.modes.emitters;if(o)if(o instanceof Array)for(const t of o)yield this.loadImagesFromParticlesOptions(e,t.particles);else yield this.loadImagesFromParticlesOptions(e,o.particles)}))}destroy(){l(this,a,[],"f")}loadImagesFromParticlesOptions(t,o){var i,r,n;return s(this,void 0,void 0,(function*(){const s=null==o?void 0:o.shape;if(!(null==s?void 0:s.type)||!s.options||!(0,e.isInArray)(e.ShapeType.image,s.type)&&!(0,e.isInArray)(e.ShapeType.images,s.type))return;const l=c(this,a,"f").findIndex((e=>e.id===t.id));l>=0&&c(this,a,"f").splice(l,1);const d=null!==(i=s.options[e.ShapeType.images])&&void 0!==i?i:s.options[e.ShapeType.image];if(d instanceof Array)for(const e of d)yield this.loadImageShape(t,e);else yield this.loadImageShape(t,d);if(null==o?void 0:o.groups)for(const e in o.groups){const i=o.groups[e];yield this.loadImagesFromParticlesOptions(t,i)}(null===(n=null===(r=null==o?void 0:o.destroy)||void 0===r?void 0:r.split)||void 0===n?void 0:n.particles)&&(yield this.loadImagesFromParticlesOptions(t,null==o?void 0:o.destroy.split.particles))}))}loadImageShape(e,t){return s(this,void 0,void 0,(function*(){try{const i=t.replaceColor?n:o,r=yield i(t.src);r&&this.addImage(e,r)}catch(e){console.warn(`tsParticles error - ${t.src} not found`)}}))}draw(e,t,o,i){var r,n;if(!e)return;const a=t.image,s=null===(r=null==a?void 0:a.data)||void 0===r?void 0:r.element;if(!s)return;const l=null!==(n=null==a?void 0:a.ratio)&&void 0!==n?n:1,c={x:-o,y:-o};(null==a?void 0:a.data.svgData)&&(null==a?void 0:a.replaceColor)||(e.globalAlpha=i),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(t){var i,r,n,a,s,l,c;if("image"!==t.shape&&"images"!==t.shape)return;const d=this.getImages(t.container).images,u=t.shapeData,p=null!==(i=d.find((e=>e.source===u.src)))&&void 0!==i?i:d[0],f=t.getFillColor();let m;if(!p)return;if(void 0!==p.svgData&&u.replaceColor&&f){const i=function(t,o,i){const{svgData:r}=t;if(!r)return"";if(r.includes("fill")){const t=/(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d.]+%?\))|currentcolor/gi;return r.replace(t,(()=>(0,e.getStyleFromHsl)(o,i)))}const n=r.indexOf(">");return`${r.substring(0,n)} fill="${(0,e.getStyleFromHsl)(o,i)}"${r.substring(n)}`}(p,f,null!==(n=null===(r=t.opacity)||void 0===r?void 0:r.value)&&void 0!==n?n:1),s=new Blob([i],{type:"image/svg+xml"}),l=URL||window.URL||window.webkitURL||window,c=l.createObjectURL(s),d=new Image;m={data:Object.assign(Object.assign({},p),{svgData:i}),ratio:u.width/u.height,replaceColor:null!==(a=u.replaceColor)&&void 0!==a?a:u.replace_color,source:u.src},d.addEventListener("load",(()=>{const e=t.image;e&&(e.loaded=!0,p.element=d),l.revokeObjectURL(c)})),d.addEventListener("error",(()=>{l.revokeObjectURL(c),o(u.src).then((e=>{const o=t.image;o&&(p.element=null==e?void 0:e.element,o.loaded=!0)}))})),d.src=c}else m={data:p,loaded:!0,ratio:u.width/u.height,replaceColor:null!==(s=u.replaceColor)&&void 0!==s?s:u.replace_color,source:u.src};m.ratio||(m.ratio=1);const g={image:m,fill:null!==(l=u.fill)&&void 0!==l?l:t.fill,close:null!==(c=u.close)&&void 0!==c?c:t.close};t.image=g.image,t.fill=g.fill,t.close=g.close}}function u(e){const t=new d;e.addShape("image",t),e.addShape("images",t)}a=new WeakMap})(),r})()}));

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc