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

@antv/g-plugin-image-loader

Package Overview
Dependencies
Maintainers
64
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-plugin-image-loader - npm Package Compare versions

Comparing version 1.3.19 to 1.3.20

4

dist/index.esm.js

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

import { __extends } from 'tslib';
import { __extends, __spreadArray, __read } from 'tslib';
import { isBrowser, parsedTransformToMat4, parseTransform, DisplayObject, GradientType, computeLinearGradient, computeRadialGradient, UnitType, ElementEvent, Shape, AbstractRendererPlugin } from '@antv/g-lite';

@@ -221,3 +221,3 @@ import { isString } from '@antv/util';

function Plugin() {
var _this = _super !== null && _super.apply(this, arguments) || this;
var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
_this.name = 'image-loader';

@@ -224,0 +224,0 @@ return _this;

@@ -223,3 +223,3 @@ 'use strict';

function Plugin() {
var _this = _super !== null && _super.apply(this, arguments) || this;
var _this = _super.apply(this, tslib.__spreadArray([], tslib.__read(arguments), false)) || this;
_this.name = 'image-loader';

@@ -226,0 +226,0 @@ return _this;

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

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.ImageLoader={}),t.window.G)}(this,(function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};var r="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var a={}.toString,i=function(t,e){return a.call(t)==="[object "+e+"]"},o=function(t){return i(t,"String")},c=function(){function t(t){this.canvasConfig=t,this.imageCache={},this.gradientCache={},this.patternCache={}}return t.prototype.getImageSync=function(t,e){return this.imageCache[t]?e&&e(this.imageCache[t]):this.getOrCreateImage(t).then((function(t){e&&e(t)})),this.imageCache[t]},t.prototype.getOrCreateImage=function(t){var n=this;if(this.imageCache[t])return Promise.resolve(this.imageCache[t]);var r=this.canvasConfig.createImage;return new Promise((function(a,i){var o;r?o=r(t):e.isBrowser&&(o=new window.Image),o&&(o.onload=function(){n.imageCache[t]=o,a(o)},o.onerror=function(t){i(t)},o.crossOrigin="Anonymous",o.src=t)}))},t.prototype.getOrCreatePatternSync=function(t,n,a,i,c){var u=this.generatePatternKey(t);if(u&&this.patternCache[u])return this.patternCache[u];var s,f=t.image,h=t.repetition,d=t.transform,p=!1;o(f)?s=this.getImageSync(f,c):a?(s=a,p=!0):s=f;var g,l=s&&n.createPattern(s,h);if(l){var y=void 0;y=d?e.parsedTransformToMat4(e.parseTransform(d),new e.DisplayObject({})):function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}((g=new r(16),r!=Float32Array&&(g[1]=0,g[2]=0,g[3]=0,g[4]=0,g[6]=0,g[7]=0,g[8]=0,g[9]=0,g[11]=0,g[12]=0,g[13]=0,g[14]=0),g[0]=1,g[5]=1,g[10]=1,g[15]=1,g)),p&&function(t,e,n){var r=n[0],a=n[1],i=n[2];t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*a,t[5]=e[5]*a,t[6]=e[6]*a,t[7]=e[7]*a,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]}(y,y,[1/i,1/i,1]),l.setTransform({a:y[0],b:y[1],c:y[4],d:y[5],e:y[12],f:y[13]})}return u&&l&&(this.patternCache[u]=l),l},t.prototype.getOrCreateGradient=function(t,n){var r=this.generateGradientKey(t),a=t.type,i=t.steps,o=t.width,c=t.height,u=t.cx,s=t.cy,f=t.size;if(this.gradientCache[r])return this.gradientCache[r];var h=null;if(a===e.GradientType.LinearGradient){var d=e.computeLinearGradient(o,c,t.angle);h=n.createLinearGradient(d.x1,d.y1,d.x2,d.y2)}else if(a===e.GradientType.RadialGradient){var p=e.computeRadialGradient(o,c,u,s,f),g=p.x,l=p.y;h=n.createRadialGradient(g,l,0,g,l,p.r)}return h&&(i.forEach((function(t){var n=t.offset;n.unit===e.UnitType.kPercentage&&(null==h||h.addColorStop(n.value/100,""+t.color))})),this.gradientCache[r]=h),this.gradientCache[r]},t.prototype.generateGradientKey=function(t){var e=t.width,n=t.height,r=t.steps,a=t.angle,i=t.cx,o=t.cy,c=t.size;return"gradient-".concat(t.type,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==i?void 0:""+i)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==c?void 0:""+c)||0,"-").concat(e,"-").concat(n,"-").concat(r.map((function(t){var e=t.color;return"".concat(t.offset).concat(e)})).join("-"))},t.prototype.generatePatternKey=function(t){var e=t.image,n=t.repetition;return o(e)?"pattern-".concat(e,"-").concat(n):"rect"===e.nodeName?"pattern-".concat(e.entity,"-").concat(n):void 0},t}(),u=function(){function t(){}return t.prototype.apply=function(n){var r=n.renderingService,a=n.imagePool,i=n.renderingContext.root.ownerDocument.defaultView,c=function(t,e,n){var r=t.parsedStyle,a=r.width,i=r.height;a&&!i?t.setAttribute("height",n/e*a):!a&&i&&t.setAttribute("width",e/n*i)},u=function(t){var n=t.target,i=n.attributes;if(n.nodeName===e.Shape.IMAGE){var u=i.img,s=i.keepAspectRatio;o(u)&&a.getImageSync(u,(function(t){s&&c(n,t.width,t.height),n.renderable.dirty=!0,r.dirtify()}))}},s=function(t){var n=t.target,i=t.newValue;n.nodeName===e.Shape.IMAGE&&"img"===t.attrName&&o(i)&&a.getOrCreateImage(i).then((function(t){n.attributes.keepAspectRatio&&c(n,t.width,t.height),n.renderable.dirty=!0,r.dirtify()}))};r.hooks.init.tap(t.tag,(function(){i.addEventListener(e.ElementEvent.MOUNTED,u),i.addEventListener(e.ElementEvent.ATTR_MODIFIED,s)})),r.hooks.destroy.tap(t.tag,(function(){i.removeEventListener(e.ElementEvent.MOUNTED,u),i.removeEventListener(e.ElementEvent.ATTR_MODIFIED,s)}))},t.tag="LoadImage",t}(),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.name="image-loader",e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+e+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.init=function(){this.context.imagePool=new c(this.context.config),this.addRenderingPlugin(new u)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(e.AbstractRendererPlugin);t.ImagePool=c,t.Plugin=s}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).G=t.G||{},t.G.ImageLoader={}),t.window.G)}(this,(function(t,e){"use strict";var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)};var r="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var a={}.toString,i=function(t,e){return a.call(t)==="[object "+e+"]"},o=function(t){return i(t,"String")},c=function(){function t(t){this.canvasConfig=t,this.imageCache={},this.gradientCache={},this.patternCache={}}return t.prototype.getImageSync=function(t,e){return this.imageCache[t]?e&&e(this.imageCache[t]):this.getOrCreateImage(t).then((function(t){e&&e(t)})),this.imageCache[t]},t.prototype.getOrCreateImage=function(t){var n=this;if(this.imageCache[t])return Promise.resolve(this.imageCache[t]);var r=this.canvasConfig.createImage;return new Promise((function(a,i){var o;r?o=r(t):e.isBrowser&&(o=new window.Image),o&&(o.onload=function(){n.imageCache[t]=o,a(o)},o.onerror=function(t){i(t)},o.crossOrigin="Anonymous",o.src=t)}))},t.prototype.getOrCreatePatternSync=function(t,n,a,i,c){var u=this.generatePatternKey(t);if(u&&this.patternCache[u])return this.patternCache[u];var s,f=t.image,l=t.repetition,h=t.transform,p=!1;o(f)?s=this.getImageSync(f,c):a?(s=a,p=!0):s=f;var d,g=s&&n.createPattern(s,l);if(g){var y=void 0;y=h?e.parsedTransformToMat4(e.parseTransform(h),new e.DisplayObject({})):function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}((d=new r(16),r!=Float32Array&&(d[1]=0,d[2]=0,d[3]=0,d[4]=0,d[6]=0,d[7]=0,d[8]=0,d[9]=0,d[11]=0,d[12]=0,d[13]=0,d[14]=0),d[0]=1,d[5]=1,d[10]=1,d[15]=1,d)),p&&function(t,e,n){var r=n[0],a=n[1],i=n[2];t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*a,t[5]=e[5]*a,t[6]=e[6]*a,t[7]=e[7]*a,t[8]=e[8]*i,t[9]=e[9]*i,t[10]=e[10]*i,t[11]=e[11]*i,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]}(y,y,[1/i,1/i,1]),g.setTransform({a:y[0],b:y[1],c:y[4],d:y[5],e:y[12],f:y[13]})}return u&&g&&(this.patternCache[u]=g),g},t.prototype.getOrCreateGradient=function(t,n){var r=this.generateGradientKey(t),a=t.type,i=t.steps,o=t.width,c=t.height,u=t.cx,s=t.cy,f=t.size;if(this.gradientCache[r])return this.gradientCache[r];var l=null;if(a===e.GradientType.LinearGradient){var h=e.computeLinearGradient(o,c,t.angle);l=n.createLinearGradient(h.x1,h.y1,h.x2,h.y2)}else if(a===e.GradientType.RadialGradient){var p=e.computeRadialGradient(o,c,u,s,f),d=p.x,g=p.y;l=n.createRadialGradient(d,g,0,d,g,p.r)}return l&&(i.forEach((function(t){var n=t.offset;n.unit===e.UnitType.kPercentage&&(null==l||l.addColorStop(n.value/100,""+t.color))})),this.gradientCache[r]=l),this.gradientCache[r]},t.prototype.generateGradientKey=function(t){var e=t.width,n=t.height,r=t.steps,a=t.angle,i=t.cx,o=t.cy,c=t.size;return"gradient-".concat(t.type,"-").concat((null==a?void 0:""+a)||0,"-").concat((null==i?void 0:""+i)||0,"-").concat((null==o?void 0:""+o)||0,"-").concat((null==c?void 0:""+c)||0,"-").concat(e,"-").concat(n,"-").concat(r.map((function(t){var e=t.color;return"".concat(t.offset).concat(e)})).join("-"))},t.prototype.generatePatternKey=function(t){var e=t.image,n=t.repetition;return o(e)?"pattern-".concat(e,"-").concat(n):"rect"===e.nodeName?"pattern-".concat(e.entity,"-").concat(n):void 0},t}(),u=function(){function t(){}return t.prototype.apply=function(n){var r=n.renderingService,a=n.imagePool,i=n.renderingContext.root.ownerDocument.defaultView,c=function(t,e,n){var r=t.parsedStyle,a=r.width,i=r.height;a&&!i?t.setAttribute("height",n/e*a):!a&&i&&t.setAttribute("width",e/n*i)},u=function(t){var n=t.target,i=n.attributes;if(n.nodeName===e.Shape.IMAGE){var u=i.img,s=i.keepAspectRatio;o(u)&&a.getImageSync(u,(function(t){s&&c(n,t.width,t.height),n.renderable.dirty=!0,r.dirtify()}))}},s=function(t){var n=t.target,i=t.newValue;n.nodeName===e.Shape.IMAGE&&"img"===t.attrName&&o(i)&&a.getOrCreateImage(i).then((function(t){n.attributes.keepAspectRatio&&c(n,t.width,t.height),n.renderable.dirty=!0,r.dirtify()}))};r.hooks.init.tap(t.tag,(function(){i.addEventListener(e.ElementEvent.MOUNTED,u),i.addEventListener(e.ElementEvent.ATTR_MODIFIED,s)})),r.hooks.destroy.tap(t.tag,(function(){i.removeEventListener(e.ElementEvent.MOUNTED,u),i.removeEventListener(e.ElementEvent.ATTR_MODIFIED,s)}))},t.tag="LoadImage",t}(),s=function(t){function e(){var e=t.apply(this,function(t,e,n){if(n||2===arguments.length)for(var r,a=0,i=e.length;i>a;a++)!r&&a in e||(r||(r=Array.prototype.slice.call(e,0,a)),r[a]=e[a]);return t.concat(r||Array.prototype.slice.call(e))}([],function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,a,i=n.call(t),o=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)o.push(r.value)}catch(t){a={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(a)throw a.error}}return o}(arguments),!1))||this;return e.name="image-loader",e}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+e+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e.prototype.init=function(){this.context.imagePool=new c(this.context.config),this.addRenderingPlugin(new u)},e.prototype.destroy=function(){this.removeAllRenderingPlugins()},e}(e.AbstractRendererPlugin);t.ImagePool=c,t.Plugin=s}));
//# sourceMappingURL=index.umd.min.js.map
{
"name": "@antv/g-plugin-image-loader",
"version": "1.3.19",
"version": "1.3.20",
"description": "A G plugin for loading image",

@@ -38,3 +38,3 @@ "keywords": [

"tslib": "^2.5.3",
"@antv/g-lite": "1.2.19"
"@antv/g-lite": "1.2.20"
},

@@ -41,0 +41,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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