Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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-alpha.6 to 2.0.0-alpha.7

4

package.json
{
"name": "tsparticles-shape-image",
"version": "2.0.0-alpha.6",
"version": "2.0.0-alpha.7",
"description": "tsParticles Image shape",

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

"dependencies": {
"tsparticles-engine": "^2.0.0-alpha.6"
"tsparticles-engine": "^2.0.0-alpha.7"
}
}

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

* How to use? : Check the GitHub README
* v2.0.0-alpha.6
* v2.0.0-alpha.7
*/

@@ -24,5 +24,68 @@ (function webpackUniversalModuleDefinition(root, factory) {

/***/ 731:
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
/***/ 414:
/***/ ((module) => {
module.exports = __WEBPACK_EXTERNAL_MODULE__414__;
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
// ESM COMPAT FLAG

@@ -33,3 +96,3 @@ __webpack_require__.r(__webpack_exports__);

__webpack_require__.d(__webpack_exports__, {
"loadImageShape": () => /* binding */ loadImageShape
"loadImageShape": () => (/* binding */ loadImageShape)
});

@@ -378,73 +441,7 @@

}
})();
/***/ }),
/***/ 414:
/***/ ((module) => {
module.exports = __WEBPACK_EXTERNAL_MODULE__414__;
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(__webpack_module_cache__[moduleId]) {
/******/ return __webpack_module_cache__[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop)
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/************************************************************************/
/******/ // module exports must be returned from runtime so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
/******/ return __webpack_require__(731);
/******/ return __webpack_exports__;
/******/ })()
;
});

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

/*! tsParticles Image Shape v2.0.0-alpha.6 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={731:(e,t,o)=>{o.r(t),o.d(t,{loadImageShape:()=>p});var r=o(414),n=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 i(e){return new Promise(((t,o)=>{if(!e)return void o("Error tsParticles - No image.src");const r={source:e,type:e.substr(e.length-3)},n=new Image;n.addEventListener("load",(()=>{r.element=n,t(r)})),n.addEventListener("error",(()=>{o("Error tsParticles - loading image: "+e)})),n.src=e}))}function a(e){return n(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 i(e);const o=yield fetch(t.source);if(!o.ok)throw new Error("Error tsParticles - Image not found");return t.svgData=yield o.text(),t}))}var s,l=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())}))},c=function(e,t,o){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,o),o},d=function(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)};class u{constructor(){s.set(this,void 0),c(this,s,[])}getSidesCount(){return 12}getImages(e){const t=d(this,s).find((t=>t.id===e.id));return t||(d(this,s).push({id:e.id,images:[]}),this.getImages(e))}addImage(e,t){const o=this.getImages(e);null==o||o.images.push(t)}init(e){const t=e.actualOptions.particles.shape;return this.initShape(e,t)}destroy(){c(this,s,[])}initShape(e,t){var o;return l(this,void 0,void 0,(function*(){const r=null!==(o=t.options.image)&&void 0!==o?o:t.options.images;if(r instanceof Array){const t=[];for(const o of r)t.push(this.loadImageShape(e,o));yield Promise.allSettled(t)}else yield this.loadImageShape(e,r)}))}loadImageShape(e,t){return l(this,void 0,void 0,(function*(){try{const o=t.replaceColor?a:i,r=yield o(t.src);r&&this.addImage(e,r)}catch(e){console.warn(`tsParticles error - ${t.src} not found`)}}))}draw(e,t,o,r){var n,i;if(!e)return;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,n,a,s;if("image"!==e.shape&&"images"!==e.shape)return;const l=e.container,c=this.getImages(l).images,d=e.shapeData,u=null!==(t=c.find((e=>e.source===d.src)))&&void 0!==t?t:c[0],p=e.getFillColor();let f;if(!u)return;if(void 0!==u.svgData&&d.replaceColor&&p){const t=function(e,t,o){return e.svgData?e.svgData.replace(/#([0-9A-F]{3,6})/gi,(()=>(0,r.getStyleFromHsl)(t,o))):""}(u,p,e.opacity.value),n=new Blob([t],{type:"image/svg+xml"}),a=URL||window.URL||window.webkitURL||window,s=a.createObjectURL(n),l=new Image;f={data:u,ratio:d.width/d.height,replaceColor:null!==(o=d.replaceColor)&&void 0!==o?o:d.replace_color,source:d.src},l.addEventListener("load",(()=>{const t=e.image;t&&(t.loaded=!0,u.element=l),a.revokeObjectURL(s)})),l.addEventListener("error",(()=>{a.revokeObjectURL(s),i(d.src).then((t=>{const o=e.image;o&&(u.element=null==t?void 0:t.element,o.loaded=!0)}))})),l.src=s}else f={data:u,loaded:!0,ratio:d.width/d.height,replaceColor:null!==(n=d.replaceColor)&&void 0!==n?n:d.replace_color,source:d.src};f.ratio||(f.ratio=1);const g={image:f,fill:null!==(a=d.fill)&&void 0!==a?a:e.fill,close:null!==(s=d.close)&&void 0!==s?s:e.close};e.image=g.image,e.fill=g.fill,e.close=g.close}}function p(e){const t=new u;e.addShape("image",t),e.addShape("images",t)}s=new WeakMap},414:t=>{t.exports=e}},o={};function r(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return t[e](n,n.exports,r),n.exports}return 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})},r(731)})()}));
/*! tsParticles Image Shape v2.0.0-alpha.7 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={414: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:()=>u});var e=r(414),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())}))};function o(e){return new Promise(((t,o)=>{if(!e)return void o("Error tsParticles - No image.src");const r={source:e,type:e.substr(e.length-3)},n=new Image;n.addEventListener("load",(()=>{r.element=n,t(r)})),n.addEventListener("error",(()=>{o(`Error tsParticles - loading image: ${e}`)})),n.src=e}))}function i(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 r=yield fetch(t.source);if(!r.ok)throw new Error("Error tsParticles - Image not found");return t.svgData=yield r.text(),t}))}var a,s=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())}))},l=function(e,t,o){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,o),o},c=function(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)};class d{constructor(){a.set(this,void 0),l(this,a,[])}getSidesCount(){return 12}getImages(e){const t=c(this,a).find((t=>t.id===e.id));return t||(c(this,a).push({id:e.id,images:[]}),this.getImages(e))}addImage(e,t){const o=this.getImages(e);null==o||o.images.push(t)}init(e){const t=e.actualOptions.particles.shape;return this.initShape(e,t)}destroy(){l(this,a,[])}initShape(e,t){var o;return s(this,void 0,void 0,(function*(){const r=null!==(o=t.options.image)&&void 0!==o?o:t.options.images;if(r instanceof Array){const t=[];for(const o of r)t.push(this.loadImageShape(e,o));yield Promise.allSettled(t)}else yield this.loadImageShape(e,r)}))}loadImageShape(e,t){return s(this,void 0,void 0,(function*(){try{const r=t.replaceColor?i:o,n=yield r(t.src);n&&this.addImage(e,n)}catch(e){console.warn(`tsParticles error - ${t.src} not found`)}}))}draw(e,t,o,r){var n,i;if(!e)return;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(t){var r,n,i,a,s;if("image"!==t.shape&&"images"!==t.shape)return;const l=t.container,c=this.getImages(l).images,d=t.shapeData,u=null!==(r=c.find((e=>e.source===d.src)))&&void 0!==r?r:c[0],p=t.getFillColor();let f;if(!u)return;if(void 0!==u.svgData&&d.replaceColor&&p){const r=function(t,o,r){return t.svgData?t.svgData.replace(/#([0-9A-F]{3,6})/gi,(()=>(0,e.getStyleFromHsl)(o,r))):""}(u,p,t.opacity.value),i=new Blob([r],{type:"image/svg+xml"}),a=URL||window.URL||window.webkitURL||window,s=a.createObjectURL(i),l=new Image;f={data:u,ratio:d.width/d.height,replaceColor:null!==(n=d.replaceColor)&&void 0!==n?n:d.replace_color,source:d.src},l.addEventListener("load",(()=>{const e=t.image;e&&(e.loaded=!0,u.element=l),a.revokeObjectURL(s)})),l.addEventListener("error",(()=>{a.revokeObjectURL(s),o(d.src).then((e=>{const o=t.image;o&&(u.element=null==e?void 0:e.element,o.loaded=!0)}))})),l.src=s}else f={data:u,loaded:!0,ratio:d.width/d.height,replaceColor:null!==(i=d.replaceColor)&&void 0!==i?i:d.replace_color,source:d.src};f.ratio||(f.ratio=1);const g={image:f,fill:null!==(a=d.fill)&&void 0!==a?a:t.fill,close:null!==(s=d.close)&&void 0!==s?s: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})(),n})()}));

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