@dicebear/avatars-jdenticon-sprites
Advanced tools
Comparing version 4.10.3 to 4.10.4
@@ -10,4 +10,4 @@ /*! | ||
export { Options } from './options'; | ||
/** @deprecated will be removed in Version 5.0 */ | ||
declare const _default: import("@dicebear/avatars").SpriteCollection<import("./options").Options>; | ||
/** @deprecated will be removed in Version 5.0 */ | ||
export default _default; |
import { utils } from '@dicebear/avatars'; | ||
import jdenticon from 'jdenticon/dist/jdenticon'; | ||
const schema$1 = { | ||
var schema$1 = { | ||
"title": "Options", | ||
@@ -56,3 +56,3 @@ "$schema": "http://json-schema.org/draft-07/schema#", | ||
// @ts-ignore | ||
const style = { | ||
var style = { | ||
meta: { | ||
@@ -68,7 +68,5 @@ title: 'Jdenticon', | ||
schema: schema$1, | ||
create: _ref => { | ||
let { | ||
prng, | ||
options | ||
} = _ref; | ||
create: function create(_ref) { | ||
var prng = _ref.prng, | ||
options = _ref.options; | ||
jdenticon.config = { | ||
@@ -101,15 +99,13 @@ hues: options.hues, | ||
*/ | ||
let { | ||
create, | ||
meta, | ||
schema | ||
} = style; | ||
var create = style.create, | ||
meta = style.meta, | ||
schema = style.schema; | ||
/** @deprecated will be removed in Version 5.0 */ | ||
var index = utils.style.createLegacyWrapper({ | ||
create, | ||
meta, | ||
schema | ||
create: create, | ||
meta: meta, | ||
schema: schema | ||
}); | ||
export { create, index as default, meta, schema }; |
@@ -12,3 +12,3 @@ 'use strict'; | ||
const schema$1 = { | ||
var schema$1 = { | ||
"title": "Options", | ||
@@ -65,3 +65,3 @@ "$schema": "http://json-schema.org/draft-07/schema#", | ||
// @ts-ignore | ||
const style = { | ||
var style = { | ||
meta: { | ||
@@ -77,7 +77,5 @@ title: 'Jdenticon', | ||
schema: schema$1, | ||
create: _ref => { | ||
let { | ||
prng, | ||
options | ||
} = _ref; | ||
create: function create(_ref) { | ||
var prng = _ref.prng, | ||
options = _ref.options; | ||
jdenticon__default["default"].config = { | ||
@@ -110,13 +108,11 @@ hues: options.hues, | ||
*/ | ||
let { | ||
create, | ||
meta, | ||
schema | ||
} = style; | ||
var create = style.create, | ||
meta = style.meta, | ||
schema = style.schema; | ||
/** @deprecated will be removed in Version 5.0 */ | ||
var index = avatars.utils.style.createLegacyWrapper({ | ||
create, | ||
meta, | ||
schema | ||
create: create, | ||
meta: meta, | ||
schema: schema | ||
}); | ||
@@ -123,0 +119,0 @@ |
@@ -1,36 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@dicebear/avatars")):"function"==typeof define&&define.amd?define(["exports","@dicebear/avatars"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).DiceBear=t.DiceBear||{},t.DiceBear.Jdenticon={}),t.DiceBear)}(this,(function(t,e){"use strict";var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}; | ||
/** | ||
* Jdenticon 2.2.0 | ||
* http://jdenticon.com | ||
* | ||
* Built: 2019-07-13T13:16:31.615Z | ||
* | ||
* Copyright (c) 2014-2019 Daniel Mester Pirttijärvi | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
var i=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t){!function(e,n){var i=function(t,e){var n={name:"jdenticon",version:"2.2.0"};function i(t,e,n){for(var i=document.createElementNS("http://www.w3.org/2000/svg",e),r=2;r+1<arguments.length;r+=2)i.setAttribute(arguments[r],arguments[r+1]);t.appendChild(i)}function r(t){for(this.size=Math.min(Number(t.getAttribute("width"))||100,Number(t.getAttribute("height"))||100),this._el=t;t.firstChild;)t.removeChild(t.firstChild);t.setAttribute("viewBox","0 0 "+this.size+" "+this.size),t.setAttribute("preserveAspectRatio","xMidYMid meet")}function o(t){this.size=t,this._s='<svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+t+'" viewBox="0 0 '+t+" "+t+'" preserveAspectRatio="xMidYMid meet">'}r.prototype={setBackground:function(t,e){e&&i(this._el,"rect","width","100%","height","100%","fill",t,"opacity",e)},append:function(t,e){i(this._el,"path","fill",t,"d",e)}},o.prototype={setBackground:function(t,e){e&&(this._s+='<rect width="100%" height="100%" fill="'+t+'" opacity="'+e.toFixed(2)+'"/>')},append:function(t,e){this._s+='<path fill="'+t+'" d="'+e+'"/>'},toString:function(){return this._s+"</svg>"}};var a={ICON_TYPE_SVG:1,ICON_TYPE_CANVAS:2,HASH_ATTRIBUTE:"data-jdenticon-hash",VALUE_ATTRIBUTE:"data-jdenticon-value",supportsQuerySelectorAll:"undefined"!=typeof document&&"querySelectorAll"in document,getIdenticonType:s};function s(t){if(t){var e=t.tagName;if(/svg/i.test(e))return a.ICON_TYPE_SVG;if(/canvas/i.test(e)&&"getContext"in t)return a.ICON_TYPE_CANVAS}}function c(t){"undefined"!=typeof MutationObserver&&new MutationObserver((function(e){for(var n=0;n<e.length;n++){for(var i=e[n],r=i.addedNodes,o=0;r&&o<r.length;o++){var s=r[o];if(s.nodeType==Node.ELEMENT_NODE)if(a.getIdenticonType(s))t(s);else for(var c=s.querySelectorAll(a.ICON_SELECTOR),u=0;u<c.length;u++)t(c[u])}"attributes"==i.type&&a.getIdenticonType(i.target)&&t(i.target)}})).observe(document.body,{childList:!0,attributes:!0,attributeFilter:[a.VALUE_ATTRIBUTE,a.HASH_ATTRIBUTE,"width","height"],subtree:!0})}a.ICON_SELECTOR="["+a.HASH_ATTRIBUTE+"],["+a.VALUE_ATTRIBUTE+"]";var u={center:[function(t,e,n){var i=.42*e;t.addPolygon([0,0,e,0,e,e-2*i,e-i,e,0,e])},function(t,e,n){var i=0|.5*e,r=0|.8*e;t.addTriangle(e-i,0,i,r,2)},function(t,e,n){var i=0|e/3;t.addRectangle(i,i,e-i,e-i)},function(t,e,n){var i=.1*e,r=e<6?1:e<8?2:0|.25*e;i=i>1?0|i:i>.5?1:i,t.addRectangle(r,r,e-i-r,e-i-r)},function(t,e,n){var i=0|.15*e,r=0|.5*e;t.addCircle(e-r-i,e-r-i,r)},function(t,e,n){var i=.1*e,r=4*i;r>3&&(r|=0),t.addRectangle(0,0,e,e),t.addPolygon([r,r,e-i,r,r+(e-r-i)/2,e-i],!0)},function(t,e,n){t.addPolygon([0,0,e,0,e,.7*e,.4*e,.4*e,.7*e,e,0,e])},function(t,e,n){t.addTriangle(e/2,e/2,e/2,e/2,3)},function(t,e,n){t.addRectangle(0,0,e,e/2),t.addRectangle(0,e/2,e/2,e/2),t.addTriangle(e/2,e/2,e/2,e/2,1)},function(t,e,n){var i=.14*e,r=e<4?1:e<6?2:0|.35*e;i=e<8?i:0|i,t.addRectangle(0,0,e,e),t.addRectangle(r,r,e-r-i,e-r-i,!0)},function(t,e,n){var i=.12*e,r=3*i;t.addRectangle(0,0,e,e),t.addCircle(r,r,e-i-r,!0)},function(t,e,n){t.addTriangle(e/2,e/2,e/2,e/2,3)},function(t,e,n){var i=.25*e;t.addRectangle(0,0,e,e),t.addRhombus(i,i,e-i,e-i,!0)},function(t,e,n){var i=.4*e,r=1.2*e;n||t.addCircle(i,i,r)}],outer:[function(t,e,n){t.addTriangle(0,0,e,e,0)},function(t,e,n){t.addTriangle(0,e/2,e,e/2,0)},function(t,e,n){t.addRhombus(0,0,e,e)},function(t,e,n){var i=e/6;t.addCircle(i,i,e-2*i)}]};function l(t,e,n){return parseInt(t.substr(e,n),16)}function d(t){return(10*t+.5|0)/10}function f(){this.dataString=""}function h(t){this._pathsByColor={},this._target=t,this.size=t.size}function g(t,e){var n=t.canvas.width,i=t.canvas.height;t.save(),this._ctx=t,e?this.size=e:(this.size=Math.min(n,i),t.translate((n-this.size)/2|0,(i-this.size)/2|0)),t.clearRect(0,0,this.size,this.size)}function p(t){this._renderer=t,this._transform=C.noTransform}function v(t,e){return t=e.hue(t),[b.correctedHsl(t,e.grayscaleSaturation,e.grayscaleLightness(0)),b.correctedHsl(t,e.colorSaturation,e.colorLightness(.5)),b.correctedHsl(t,e.grayscaleSaturation,e.grayscaleLightness(1)),b.correctedHsl(t,e.colorSaturation,e.colorLightness(1)),b.correctedHsl(t,e.colorSaturation,e.colorLightness(0))]}function m(t){function e(t){for(var e=[],n=0;n<t.length;n++)for(var i=t[n],r=28;r>=0;r-=4){var o=i>>>r&15;e.push(o.toString(16))}return e.join("")}function n(t){var e,n,i=encodeURI(t),r=[],o=0,a=[],s=64,c=s>>>2,u=8;for(e=0;e<i.length;e++)"%"==i[e]?(n=l(i,e+1,2),e+=2):n=i.charCodeAt(e),r[o++]=n;function d(t,e){for(var n=[],i=-1,o=0;o<e;o++)n[i=o/4|0]=(n[i]||0)+(r[t+o]<<8*(3-(3&o)));for(;++i<c;)n[i]=0;return n}for(r[o++]=128,e=0;e+s<=o;e+=s)a.push(d(e,s));var f=o-e,h=d(e,f);f+u>s&&(a.push(h),h=d(0,0));var g=8*o-8;return h[c-1]=g,a.push(h),a}function i(t,e){return t<<e|t>>>32-e}function r(t){for(var e=1732584193,n=4023233417,r=2562383102,o=271733878,a=3285377520,s=[e,n,r,o,a],c=0;c<t.length;c++){for(var u=t[c],l=16;l<80;l++)u[l]=i(u[l-3]^u[l-8]^u[l-14]^u[l-16],1);for(l=0;l<80;l++){var d=l<20?1518500249+(n&r^~n&o):l<40?1859775393+(n^r^o):l<60?2400959708+(n&r^n&o^r&o):3395469782+(n^r^o),f=i(e,5)+d+a+u[l];a=o,o=r,r=i(n,30),n=e,e=0|f}s[0]=e=s[0]+e|0,s[1]=n=s[1]+n|0,s[2]=r=s[2]+r|0,s[3]=o=s[3]+o|0,s[4]=a=s[4]+a|0}return s}return e(r(n(t)))}f.prototype={addPolygon:function(t){for(var e="M"+d(t[0].x)+" "+d(t[0].y),n=1;n<t.length;n++)e+="L"+d(t[n].x)+" "+d(t[n].y);this.dataString+=e+"Z"},addCircle:function(t,e,n){var i=n?0:1,r=d(e/2),o=d(e);this.dataString+="M"+d(t.x)+" "+d(t.y+e/2)+"a"+r+","+r+" 0 1,"+i+" "+o+",0a"+r+","+r+" 0 1,"+i+" "+-o+",0"}},h.prototype={setBackground:function(t){var e=/^(#......)(..)?/.exec(t),n=e[2]?l(e[2],0)/255:1;this._target.setBackground(e[1],n)},beginShape:function(t){this._path=this._pathsByColor[t]||(this._pathsByColor[t]=new f)},endShape:function(){},addPolygon:function(t){this._path.addPolygon(t)},addCircle:function(t,e,n){this._path.addCircle(t,e,n)},finish:function(){for(var t in this._pathsByColor)this._target.append(t,this._pathsByColor[t].dataString)}},g.prototype={setBackground:function(t){var e=this._ctx,n=this.size;e.fillStyle=b.toCss3(t),e.fillRect(0,0,n,n)},beginShape:function(t){this._ctx.fillStyle=b.toCss3(t),this._ctx.beginPath()},endShape:function(){this._ctx.fill()},addPolygon:function(t){var e,n=this._ctx;for(n.moveTo(t[0].x,t[0].y),e=1;e<t.length;e++)n.lineTo(t[e].x,t[e].y);n.closePath()},addCircle:function(t,e,n){var i=this._ctx,r=e/2;i.moveTo(t.x+r,t.y+r),i.arc(t.x+r,t.y+r,r,0,2*Math.PI,n),i.closePath()},finish:function(){this._ctx.restore()}},p.prototype={addPolygon:function(t,e){var n,i=e?-2:2,r=this._transform,o=[];for(n=e?t.length-2:0;n<t.length&&n>=0;n+=i)o.push(r.transformPoint(t[n],t[n+1]));this._renderer.addPolygon(o)},addCircle:function(t,e,n,i){var r=this._transform.transformPoint(t,e,n,n);this._renderer.addCircle(r,n,i)},addRectangle:function(t,e,n,i,r){this.addPolygon([t,e,t+n,e,t+n,e+i,t,e+i],r)},addTriangle:function(t,e,n,i,r,o){var a=[t+n,e,t+n,e+i,t,e+i,t,e];a.splice((r||0)%4*2,2),this.addPolygon(a,o)},addRhombus:function(t,e,n,i,r){this.addPolygon([t+n/2,e,t+n,e+i/2,t+n/2,e+i,t,e+i/2],r)}};var y={validHash:function(t){return/^[0-9a-f]{11,}$/i.test(t)&&t},computeHash:function(t){return m(null==t?"":""+t)}};function _(t){return(t|=0)<0?"00":t<16?"0"+t.toString(16):t<256?t.toString(16):"ff"}function T(t,e,n){return _(255*((n=n<0?n+6:n>6?n-6:n)<1?t+(e-t)*n:n<3?e:n<4?t+(e-t)*(4-n):t))}var b={rgb:function(t,e,n){return"#"+_(t)+_(e)+_(n)},parse:function(t){if(/^#[0-9a-f]{3,8}$/i.test(t)){if(t.length<6){var e=t[1],n=t[2],i=t[3],r=t[4]||"";return"#"+e+e+n+n+i+i+r+r}if(7==t.length||t.length>8)return t}},toCss3:function(t){var e=l(t,7,2);return isNaN(e)?t:"rgba("+l(t,1,2)+","+l(t,3,2)+","+l(t,5,2)+","+(e/255).toFixed(2)+")"},hsl:function(t,e,n){if(0==e){var i=_(255*n);return"#"+i+i+i}var r=n<=.5?n*(e+1):n+e-n*e,o=2*n-r;return"#"+T(o,r,6*t+2)+T(o,r,6*t)+T(o,r,6*t-2)},correctedHsl:function(t,e,n){var i=[.55,.5,.5,.46,.6,.55,.55][6*t+.5|0];return n=n<.5?n*i*2:i+(n-.5)*(1-i)*2,b.hsl(t,e,n)}};function S(t,e,n,i){var r="object"==typeof n&&n||t.config||e.jdenticon_config||{},o=r.lightness||{},a=r.saturation||{},s="color"in a?a.color:a,c=a.grayscale,u=r.backColor,l=r.padding;function d(t,e){var n=o[t];return n&&n.length>1||(n=e),function(t){return(t=n[0]+t*(n[1]-n[0]))<0?0:t>1?1:t}}function f(t){var e,n=r.hues;return n&&n.length>0&&(e=n[0|.999*t*n.length]),"number"==typeof e?(e/360%1+1)%1:t}return{hue:f,colorSaturation:"number"==typeof s?s:.5,grayscaleSaturation:"number"==typeof c?c:0,colorLightness:d("color",[.4,.8]),grayscaleLightness:d("grayscale",[.3,.9]),backColor:b.parse(u),padding:"number"==typeof n?n:"number"==typeof l?l:i}}function x(t,e){this.x=t,this.y=e}function C(t,e,n,i){this._x=t,this._y=e,this._size=n,this._rotation=i}function A(t,e,n,i,r,o){o.backColor&&t.setBackground(o.backColor);var a=.5+r*o.padding|0;r-=2*a;var s=new p(t),c=0|r/4;function d(r,o,a,u,d){var f,p=u?l(e,u,1):0,v=o[l(e,a,1)%o.length];for(t.beginShape(h[g[r]]),f=0;f<d.length;f++)s._transform=new C(n+d[f][0]*c,i+d[f][1]*c,c,p++%4),v(s,c,f);t.endShape()}n+=0|a+r/2-2*c,i+=0|a+r/2-2*c;var f,h=v(l(e,-7)/268435455,o),g=[];function m(t){if(t.indexOf(f)>=0)for(var e=0;e<t.length;e++)if(g.indexOf(t[e])>=0)return!0}for(var y=0;y<3;y++)f=l(e,8+y,1)%h.length,(m([0,4])||m([2,3]))&&(f=1),g.push(f);d(0,u.outer,2,3,[[1,0],[2,0],[2,3],[1,3],[0,1],[3,1],[3,2],[0,2]]),d(1,u.outer,4,5,[[0,0],[3,0],[3,3],[0,3]]),d(2,u.center,1,null,[[1,1],[2,1],[2,2],[1,2]]),t.finish()}function w(e,n,i){if("string"!=typeof e){var o=a.getIdenticonType(e);if(o){var s=y.validHash(n)||null!=n&&y.computeHash(n)||y.validHash(e.getAttribute(a.HASH_ATTRIBUTE))||e.hasAttribute(a.VALUE_ATTRIBUTE)&&y.computeHash(e.getAttribute(a.VALUE_ATTRIBUTE));if(s){var c=o==a.ICON_TYPE_SVG?new h(new r(e)):new g(e.getContext("2d"));A(c,s,0,0,c.size,S(R,t,i,.08))}}}else if(a.supportsQuerySelectorAll)for(var u=document.querySelectorAll(e),l=0;l<u.length;l++)w(u[l],n,i)}function E(e,n,i,r){if(!e)throw new Error("No canvas specified.");A(new g(e,i),y.validHash(n)||y.computeHash(n),0,0,i,S(R,t,r,0))}function I(e,n,i){var r=new o(n);return A(new h(r),y.validHash(e)||y.computeHash(e),0,0,n,S(R,t,i,.08)),r.toString()}function R(){a.supportsQuerySelectorAll&&w(a.ICON_SELECTOR)}function B(){var e=(R.config||t.jdenticon_config||{}).replaceMode;"never"!=e&&(R(),"observe"==e&&c(w))}C.prototype={transformPoint:function(t,e,n,i){var r=this._x+this._size,o=this._y+this._size;return 1===this._rotation?new x(r-e-(i||0),this._y+t):2===this._rotation?new x(r-t-(n||0),o-e-(i||0)):3===this._rotation?new x(this._x+e,o-t-(n||0)):new x(this._x+t,this._y+e)}},C.noTransform=new C(0,0,0,0),R.drawIcon=E,R.toSvg=I,R.update=w,R.version=n.version,e&&(e.fn.jdenticon=function(t,e){return this.each((function(n,i){w(i,t,e)})),this});"function"==typeof setTimeout&&setTimeout(B,0);return R}(e,e&&e.jQuery);"exports"in t?t.exports=i:e.jdenticon=i}("undefined"!=typeof self?self:n)}));const r={meta:{title:"Jdenticon",creator:"Daniel Mester Pirttijärvi",source:"https://github.com/dmester/jdenticon",license:{name:"MIT",url:"https://github.com/dmester/jdenticon/blob/master/LICENSE"}},schema:{title:"Options",$schema:"http://json-schema.org/draft-07/schema#",properties:{hues:{title:"Hues",type:"array",items:{type:"integer",minimum:0,maximum:360}},colorLightness:{title:"Color Lightness",type:"array",minItems:2,maxItems:2,items:{type:"number",minimum:0,maximum:100}},grayscaleLightness:{title:"Grayscale Lightness",type:"array",minItems:2,maxItems:2,items:{type:"number",minimum:0,maximum:100}},colorSaturation:{title:"Color Saturation",type:"integer",minimum:0,maximum:100},grayscaleSaturation:{title:"Grayscale Saturation",type:"integer",minimum:0,maximum:100}},additionalProperties:!1},create:t=>{let{prng:e,options:n}=t;return i.config={hues:n.hues,lightness:{color:n.colorLightness,grayscale:n.grayscaleLightness},saturation:{color:n.colorSaturation,grayscale:n.grayscaleSaturation}},{attributes:{viewBox:"0 0 50 50",preserveAspectRatio:"xMidYMid meet"},body:i.toSvg(e.seed,50,0).replace(/<svg.*?>(.*)<\/svg>/,"$1")}}}; | ||
/*! | ||
* DiceBear Jdenticon (@dicebear/avatars-jdenticon-sprites) | ||
* | ||
* Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/avatars-jdenticon-sprites/LICENSE) | ||
* Copyright (c) 2021 Florian Körner | ||
*/ | ||
let{create:o,meta:a,schema:s}=r;var c=e.utils.style.createLegacyWrapper({create:o,meta:a,schema:s});t.create=o,t.default=c,t.meta=a,t.schema=s,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@dicebear/avatars")):"function"==typeof define&&define.amd?define(["exports","@dicebear/avatars"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).DiceBear=t.DiceBear||{},t.DiceBear.Jdenticon={}),t.DiceBear)}(this,(function(t,e){"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var r=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t){!function(e,i){var r=function(t,e){var i={name:"jdenticon",version:"2.2.0"};function r(t,e,n){for(var i=document.createElementNS("http://www.w3.org/2000/svg",e),r=2;r+1<arguments.length;r+=2)i.setAttribute(arguments[r],arguments[r+1]);t.appendChild(i)}function o(t){for(this.size=Math.min(Number(t.getAttribute("width"))||100,Number(t.getAttribute("height"))||100),this._el=t;t.firstChild;)t.removeChild(t.firstChild);t.setAttribute("viewBox","0 0 "+this.size+" "+this.size),t.setAttribute("preserveAspectRatio","xMidYMid meet")}function a(t){this.size=t,this._s='<svg xmlns="http://www.w3.org/2000/svg" width="'+t+'" height="'+t+'" viewBox="0 0 '+t+" "+t+'" preserveAspectRatio="xMidYMid meet">'}o.prototype={setBackground:function(t,e){e&&r(this._el,"rect","width","100%","height","100%","fill",t,"opacity",e)},append:function(t,e){r(this._el,"path","fill",t,"d",e)}},a.prototype={setBackground:function(t,e){e&&(this._s+='<rect width="100%" height="100%" fill="'+t+'" opacity="'+e.toFixed(2)+'"/>')},append:function(t,e){this._s+='<path fill="'+t+'" d="'+e+'"/>'},toString:function(){return this._s+"</svg>"}};var s={ICON_TYPE_SVG:1,ICON_TYPE_CANVAS:2,HASH_ATTRIBUTE:"data-jdenticon-hash",VALUE_ATTRIBUTE:"data-jdenticon-value",supportsQuerySelectorAll:"undefined"!=typeof document&&"querySelectorAll"in document,getIdenticonType:c};function c(t){if(t){var e=t.tagName;if(/svg/i.test(e))return s.ICON_TYPE_SVG;if(/canvas/i.test(e)&&"getContext"in t)return s.ICON_TYPE_CANVAS}}function u(t){"undefined"!=typeof MutationObserver&&new MutationObserver((function(e){for(var n=0;n<e.length;n++){for(var i=e[n],r=i.addedNodes,o=0;r&&o<r.length;o++){var a=r[o];if(a.nodeType==Node.ELEMENT_NODE)if(s.getIdenticonType(a))t(a);else for(var c=a.querySelectorAll(s.ICON_SELECTOR),u=0;u<c.length;u++)t(c[u])}"attributes"==i.type&&s.getIdenticonType(i.target)&&t(i.target)}})).observe(document.body,{childList:!0,attributes:!0,attributeFilter:[s.VALUE_ATTRIBUTE,s.HASH_ATTRIBUTE,"width","height"],subtree:!0})}s.ICON_SELECTOR="["+s.HASH_ATTRIBUTE+"],["+s.VALUE_ATTRIBUTE+"]";var l={center:[function(t,e,n){var i=.42*e;t.addPolygon([0,0,e,0,e,e-2*i,e-i,e,0,e])},function(t,e,n){var i=0|.5*e,r=0|.8*e;t.addTriangle(e-i,0,i,r,2)},function(t,e,n){var i=0|e/3;t.addRectangle(i,i,e-i,e-i)},function(t,e,n){var i=.1*e,r=e<6?1:e<8?2:0|.25*e;i=i>1?0|i:i>.5?1:i,t.addRectangle(r,r,e-i-r,e-i-r)},function(t,e,n){var i=0|.15*e,r=0|.5*e;t.addCircle(e-r-i,e-r-i,r)},function(t,e,n){var i=.1*e,r=4*i;r>3&&(r|=0),t.addRectangle(0,0,e,e),t.addPolygon([r,r,e-i,r,r+(e-r-i)/2,e-i],!0)},function(t,e,n){t.addPolygon([0,0,e,0,e,.7*e,.4*e,.4*e,.7*e,e,0,e])},function(t,e,n){t.addTriangle(e/2,e/2,e/2,e/2,3)},function(t,e,n){t.addRectangle(0,0,e,e/2),t.addRectangle(0,e/2,e/2,e/2),t.addTriangle(e/2,e/2,e/2,e/2,1)},function(t,e,n){var i=.14*e,r=e<4?1:e<6?2:0|.35*e;i=e<8?i:0|i,t.addRectangle(0,0,e,e),t.addRectangle(r,r,e-r-i,e-r-i,!0)},function(t,e,n){var i=.12*e,r=3*i;t.addRectangle(0,0,e,e),t.addCircle(r,r,e-i-r,!0)},function(t,e,n){t.addTriangle(e/2,e/2,e/2,e/2,3)},function(t,e,n){var i=.25*e;t.addRectangle(0,0,e,e),t.addRhombus(i,i,e-i,e-i,!0)},function(t,e,n){var i=.4*e,r=1.2*e;n||t.addCircle(i,i,r)}],outer:[function(t,e,n){t.addTriangle(0,0,e,e,0)},function(t,e,n){t.addTriangle(0,e/2,e,e/2,0)},function(t,e,n){t.addRhombus(0,0,e,e)},function(t,e,n){var i=e/6;t.addCircle(i,i,e-2*i)}]};function d(t,e,n){return parseInt(t.substr(e,n),16)}function f(t){return(10*t+.5|0)/10}function h(){this.dataString=""}function g(t){this._pathsByColor={},this._target=t,this.size=t.size}function p(t,e){var n=t.canvas.width,i=t.canvas.height;t.save(),this._ctx=t,e?this.size=e:(this.size=Math.min(n,i),t.translate((n-this.size)/2|0,(i-this.size)/2|0)),t.clearRect(0,0,this.size,this.size)}function y(t){this._renderer=t,this._transform=A.noTransform}function v(t,e){return t=e.hue(t),[S.correctedHsl(t,e.grayscaleSaturation,e.grayscaleLightness(0)),S.correctedHsl(t,e.colorSaturation,e.colorLightness(.5)),S.correctedHsl(t,e.grayscaleSaturation,e.grayscaleLightness(1)),S.correctedHsl(t,e.colorSaturation,e.colorLightness(1)),S.correctedHsl(t,e.colorSaturation,e.colorLightness(0))]}function m(t){function e(t){for(var e=[],n=0;n<t.length;n++)for(var i=t[n],r=28;r>=0;r-=4){var o=i>>>r&15;e.push(o.toString(16))}return e.join("")}function n(t){var e,n,i=encodeURI(t),r=[],o=0,a=[],s=64,c=s>>>2,u=8;for(e=0;e<i.length;e++)"%"==i[e]?(n=d(i,e+1,2),e+=2):n=i.charCodeAt(e),r[o++]=n;function l(t,e){for(var n=[],i=-1,o=0;o<e;o++)n[i=o/4|0]=(n[i]||0)+(r[t+o]<<8*(3-(3&o)));for(;++i<c;)n[i]=0;return n}for(r[o++]=128,e=0;e+s<=o;e+=s)a.push(l(e,s));var f=o-e,h=l(e,f);f+u>s&&(a.push(h),h=l(0,0));var g=8*o-8;return h[c-1]=g,a.push(h),a}function i(t,e){return t<<e|t>>>32-e}function r(t){for(var e=1732584193,n=4023233417,r=2562383102,o=271733878,a=3285377520,s=[e,n,r,o,a],c=0;c<t.length;c++){for(var u=t[c],l=16;l<80;l++)u[l]=i(u[l-3]^u[l-8]^u[l-14]^u[l-16],1);for(l=0;l<80;l++){var d=l<20?1518500249+(n&r^~n&o):l<40?1859775393+(n^r^o):l<60?2400959708+(n&r^n&o^r&o):3395469782+(n^r^o),f=i(e,5)+d+a+u[l];a=o,o=r,r=i(n,30),n=e,e=0|f}s[0]=e=s[0]+e|0,s[1]=n=s[1]+n|0,s[2]=r=s[2]+r|0,s[3]=o=s[3]+o|0,s[4]=a=s[4]+a|0}return s}return e(r(n(t)))}h.prototype={addPolygon:function(t){for(var e="M"+f(t[0].x)+" "+f(t[0].y),n=1;n<t.length;n++)e+="L"+f(t[n].x)+" "+f(t[n].y);this.dataString+=e+"Z"},addCircle:function(t,e,n){var i=n?0:1,r=f(e/2),o=f(e);this.dataString+="M"+f(t.x)+" "+f(t.y+e/2)+"a"+r+","+r+" 0 1,"+i+" "+o+",0a"+r+","+r+" 0 1,"+i+" "+-o+",0"}},g.prototype={setBackground:function(t){var e=/^(#......)(..)?/.exec(t),n=e[2]?d(e[2],0)/255:1;this._target.setBackground(e[1],n)},beginShape:function(t){this._path=this._pathsByColor[t]||(this._pathsByColor[t]=new h)},endShape:function(){},addPolygon:function(t){this._path.addPolygon(t)},addCircle:function(t,e,n){this._path.addCircle(t,e,n)},finish:function(){for(var t in this._pathsByColor)this._target.append(t,this._pathsByColor[t].dataString)}},p.prototype={setBackground:function(t){var e=this._ctx,n=this.size;e.fillStyle=S.toCss3(t),e.fillRect(0,0,n,n)},beginShape:function(t){this._ctx.fillStyle=S.toCss3(t),this._ctx.beginPath()},endShape:function(){this._ctx.fill()},addPolygon:function(t){var e,n=this._ctx;for(n.moveTo(t[0].x,t[0].y),e=1;e<t.length;e++)n.lineTo(t[e].x,t[e].y);n.closePath()},addCircle:function(t,e,n){var i=this._ctx,r=e/2;i.moveTo(t.x+r,t.y+r),i.arc(t.x+r,t.y+r,r,0,2*Math.PI,n),i.closePath()},finish:function(){this._ctx.restore()}},y.prototype={addPolygon:function(t,e){var n,i=e?-2:2,r=this._transform,o=[];for(n=e?t.length-2:0;n<t.length&&n>=0;n+=i)o.push(r.transformPoint(t[n],t[n+1]));this._renderer.addPolygon(o)},addCircle:function(t,e,n,i){var r=this._transform.transformPoint(t,e,n,n);this._renderer.addCircle(r,n,i)},addRectangle:function(t,e,n,i,r){this.addPolygon([t,e,t+n,e,t+n,e+i,t,e+i],r)},addTriangle:function(t,e,n,i,r,o){var a=[t+n,e,t+n,e+i,t,e+i,t,e];a.splice((r||0)%4*2,2),this.addPolygon(a,o)},addRhombus:function(t,e,n,i,r){this.addPolygon([t+n/2,e,t+n,e+i/2,t+n/2,e+i,t,e+i/2],r)}};var _={validHash:function(t){return/^[0-9a-f]{11,}$/i.test(t)&&t},computeHash:function(t){return m(null==t?"":""+t)}};function b(t){return(t|=0)<0?"00":t<16?"0"+t.toString(16):t<256?t.toString(16):"ff"}function T(t,e,n){return b(255*((n=n<0?n+6:n>6?n-6:n)<1?t+(e-t)*n:n<3?e:n<4?t+(e-t)*(4-n):t))}var S={rgb:function(t,e,n){return"#"+b(t)+b(e)+b(n)},parse:function(t){if(/^#[0-9a-f]{3,8}$/i.test(t)){if(t.length<6){var e=t[1],n=t[2],i=t[3],r=t[4]||"";return"#"+e+e+n+n+i+i+r+r}if(7==t.length||t.length>8)return t}},toCss3:function(t){var e=d(t,7,2);return isNaN(e)?t:"rgba("+d(t,1,2)+","+d(t,3,2)+","+d(t,5,2)+","+(e/255).toFixed(2)+")"},hsl:function(t,e,n){if(0==e){var i=b(255*n);return"#"+i+i+i}var r=n<=.5?n*(e+1):n+e-n*e,o=2*n-r;return"#"+T(o,r,6*t+2)+T(o,r,6*t)+T(o,r,6*t-2)},correctedHsl:function(t,e,n){var i=[.55,.5,.5,.46,.6,.55,.55][6*t+.5|0];return n=n<.5?n*i*2:i+(n-.5)*(1-i)*2,S.hsl(t,e,n)}};function x(t,e,i,r){var o="object"==n(i)&&i||t.config||e.jdenticon_config||{},a=o.lightness||{},s=o.saturation||{},c="color"in s?s.color:s,u=s.grayscale,l=o.backColor,d=o.padding;function f(t,e){var n=a[t];return n&&n.length>1||(n=e),function(t){return(t=n[0]+t*(n[1]-n[0]))<0?0:t>1?1:t}}function h(t){var e,n=o.hues;return n&&n.length>0&&(e=n[0|.999*t*n.length]),"number"==typeof e?(e/360%1+1)%1:t}return{hue:h,colorSaturation:"number"==typeof c?c:.5,grayscaleSaturation:"number"==typeof u?u:0,colorLightness:f("color",[.4,.8]),grayscaleLightness:f("grayscale",[.3,.9]),backColor:S.parse(l),padding:"number"==typeof i?i:"number"==typeof d?d:r}}function C(t,e){this.x=t,this.y=e}function A(t,e,n,i){this._x=t,this._y=e,this._size=n,this._rotation=i}function w(t,e,n,i,r,o){o.backColor&&t.setBackground(o.backColor);var a=.5+r*o.padding|0;r-=2*a;var s=new y(t),c=0|r/4;function u(r,o,a,u,l){var f,p=u?d(e,u,1):0,y=o[d(e,a,1)%o.length];for(t.beginShape(h[g[r]]),f=0;f<l.length;f++)s._transform=new A(n+l[f][0]*c,i+l[f][1]*c,c,p++%4),y(s,c,f);t.endShape()}n+=0|a+r/2-2*c,i+=0|a+r/2-2*c;var f,h=v(d(e,-7)/268435455,o),g=[];function p(t){if(t.indexOf(f)>=0)for(var e=0;e<t.length;e++)if(g.indexOf(t[e])>=0)return!0}for(var m=0;m<3;m++)f=d(e,8+m,1)%h.length,(p([0,4])||p([2,3]))&&(f=1),g.push(f);u(0,l.outer,2,3,[[1,0],[2,0],[2,3],[1,3],[0,1],[3,1],[3,2],[0,2]]),u(1,l.outer,4,5,[[0,0],[3,0],[3,3],[0,3]]),u(2,l.center,1,null,[[1,1],[2,1],[2,2],[1,2]]),t.finish()}function E(e,n,i){if("string"!=typeof e){var r=s.getIdenticonType(e);if(r){var a=_.validHash(n)||null!=n&&_.computeHash(n)||_.validHash(e.getAttribute(s.HASH_ATTRIBUTE))||e.hasAttribute(s.VALUE_ATTRIBUTE)&&_.computeHash(e.getAttribute(s.VALUE_ATTRIBUTE));if(a){var c=r==s.ICON_TYPE_SVG?new g(new o(e)):new p(e.getContext("2d"));w(c,a,0,0,c.size,x(B,t,i,.08))}}}else if(s.supportsQuerySelectorAll)for(var u=document.querySelectorAll(e),l=0;l<u.length;l++)E(u[l],n,i)}function I(e,n,i,r){if(!e)throw new Error("No canvas specified.");w(new p(e,i),_.validHash(n)||_.computeHash(n),0,0,i,x(B,t,r,0))}function R(e,n,i){var r=new a(n);return w(new g(r),_.validHash(e)||_.computeHash(e),0,0,n,x(B,t,i,.08)),r.toString()}function B(){s.supportsQuerySelectorAll&&E(s.ICON_SELECTOR)}function P(){var e=(B.config||t.jdenticon_config||{}).replaceMode;"never"!=e&&(B(),"observe"==e&&u(E))}A.prototype={transformPoint:function(t,e,n,i){var r=this._x+this._size,o=this._y+this._size;return 1===this._rotation?new C(r-e-(i||0),this._y+t):2===this._rotation?new C(r-t-(n||0),o-e-(i||0)):3===this._rotation?new C(this._x+e,o-t-(n||0)):new C(this._x+t,this._y+e)}},A.noTransform=new A(0,0,0,0),B.drawIcon=I,B.toSvg=R,B.update=E,B.version=i.version,e&&(e.fn.jdenticon=function(t,e){return this.each((function(n,i){E(i,t,e)})),this});"function"==typeof setTimeout&&setTimeout(P,0);return B}(e,e&&e.jQuery);"exports"in t?t.exports=r:e.jdenticon=r}("undefined"!=typeof self?self:i)})),o=function(t){var e=t.prng,n=t.options;return r.config={hues:n.hues,lightness:{color:n.colorLightness,grayscale:n.grayscaleLightness},saturation:{color:n.colorSaturation,grayscale:n.grayscaleSaturation}},{attributes:{viewBox:"0 0 50 50",preserveAspectRatio:"xMidYMid meet"},body:r.toSvg(e.seed,50,0).replace(/<svg.*?>(.*)<\/svg>/,"$1")}},a={title:"Jdenticon",creator:"Daniel Mester Pirttijärvi",source:"https://github.com/dmester/jdenticon",license:{name:"MIT",url:"https://github.com/dmester/jdenticon/blob/master/LICENSE"}},s={title:"Options",$schema:"http://json-schema.org/draft-07/schema#",properties:{hues:{title:"Hues",type:"array",items:{type:"integer",minimum:0,maximum:360}},colorLightness:{title:"Color Lightness",type:"array",minItems:2,maxItems:2,items:{type:"number",minimum:0,maximum:100}},grayscaleLightness:{title:"Grayscale Lightness",type:"array",minItems:2,maxItems:2,items:{type:"number",minimum:0,maximum:100}},colorSaturation:{title:"Color Saturation",type:"integer",minimum:0,maximum:100},grayscaleSaturation:{title:"Grayscale Saturation",type:"integer",minimum:0,maximum:100}},additionalProperties:!1},c=e.utils.style.createLegacyWrapper({create:o,meta:a,schema:s});t.create=o,t.default=c,t.meta=a,t.schema=s,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "@dicebear/avatars-jdenticon-sprites", | ||
"version": "4.10.3", | ||
"version": "4.10.4", | ||
"description": "Jdenticon avatar style for DiceBear Avatars", | ||
@@ -43,7 +43,7 @@ "keywords": [ | ||
"devDependencies": { | ||
"@dicebear/avatars": "^4.10.3", | ||
"@dicebear/avatars": "^4.10.4", | ||
"@tsconfig/recommended": "^1.0.0", | ||
"@types/jest": "^26.0.22", | ||
"@types/node": "^10.11.6", | ||
"dicebear-project": "^4.10.3", | ||
"dicebear-project": "^4.10.4", | ||
"jdenticon": "^2.1.1", | ||
@@ -61,3 +61,3 @@ "jest": "^26.6.3", | ||
}, | ||
"gitHead": "22ca3bd3718c2f44f4038bfa8f2dcbec6c7ebd10" | ||
"gitHead": "579a3f403a91f5e4909d8bc2c5b26792220ee58f" | ||
} |
23064
297