@dicebear/core 5.0.0-alpha.0 → 5.0.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js DELETED
@@ -1,527 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var type = "object";
6
- var $schema = "http://json-schema.org/draft-07/schema#";
7
- var title = "Options";
8
- var properties$1 = {
9
- seed: {
10
- type: "string"
11
- },
12
- dataUri: {
13
- type: "boolean",
14
- "default": false
15
- },
16
- flip: {
17
- type: "boolean",
18
- "default": false
19
- },
20
- rotate: {
21
- type: "integer",
22
- minimum: 0,
23
- maximum: 360,
24
- "default": 0
25
- },
26
- scale: {
27
- type: "integer",
28
- minimum: 0,
29
- maximum: 200,
30
- "default": 100
31
- },
32
- radius: {
33
- type: "integer",
34
- minimum: 0,
35
- maximum: 50,
36
- "default": 0
37
- },
38
- size: {
39
- type: "integer",
40
- minimum: 1
41
- },
42
- backgroundColor: {
43
- type: "array",
44
- items: {
45
- anyOf: [
46
- {
47
- type: "string",
48
- pattern: "^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$"
49
- },
50
- {
51
- type: "string",
52
- pattern: "^[0-9a-zA-Z]+$"
53
- }
54
- ]
55
- }
56
- },
57
- translateX: {
58
- type: "integer",
59
- minimum: -100,
60
- maximum: 100,
61
- "default": 0
62
- },
63
- translateY: {
64
- type: "integer",
65
- minimum: -100,
66
- maximum: 100,
67
- "default": 0
68
- },
69
- clip: {
70
- type: "boolean",
71
- "default": true
72
- }
73
- };
74
- var additionalProperties = false;
75
- var untypedSchema = {
76
- type: type,
77
- $schema: $schema,
78
- title: title,
79
- properties: properties$1,
80
- additionalProperties: additionalProperties
81
- };
82
-
83
- function xml(attr) {
84
- return attr.replace(/&/g, '&amp;').replace(/'/g, '&apos;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
85
- }
86
-
87
- var _escape = /*#__PURE__*/Object.freeze({
88
- __proto__: null,
89
- xml: xml
90
- });
91
-
92
- function properties(schema) {
93
- var _schema$properties;
94
-
95
- return (_schema$properties = schema.properties) !== null && _schema$properties !== void 0 ? _schema$properties : {};
96
- }
97
- function defaults(schema) {
98
- let result = {};
99
- let props = properties(schema);
100
- Object.keys(props).forEach(key => {
101
- let val = props[key];
102
-
103
- if (typeof val === 'object' && undefined !== val.default) {
104
- result[key] = val.default;
105
- }
106
- });
107
- return result;
108
- }
109
-
110
- var schema$1 = /*#__PURE__*/Object.freeze({
111
- __proto__: null,
112
- properties: properties,
113
- defaults: defaults
114
- });
115
-
116
- function merge(style, options) {
117
- let result = { ...{
118
- seed: Math.random().toString()
119
- },
120
- ...defaults(untypedSchema),
121
- ...defaults(style.schema),
122
- ...options
123
- };
124
- return result;
125
- }
126
-
127
- var options = /*#__PURE__*/Object.freeze({
128
- __proto__: null,
129
- merge: merge
130
- });
131
-
132
- const MIN = -2147483648;
133
- const MAX = 2147483647;
134
-
135
- function xorshift(value) {
136
- value ^= value << 13;
137
- value ^= value >> 17;
138
- value ^= value << 5;
139
- return value;
140
- }
141
-
142
- function hashSeed(seed) {
143
- let hash = 0;
144
-
145
- for (let i = 0; i < seed.length; i++) {
146
- hash = (hash << 5) - hash + seed.charCodeAt(i) | 0;
147
- hash = xorshift(hash);
148
- }
149
-
150
- return hash;
151
- }
152
-
153
- function randomSeed() {
154
- return MIN + Math.floor((MAX - MIN) * Math.random()).toString();
155
- }
156
-
157
- function create(seed) {
158
- var _seed;
159
-
160
- seed = (_seed = seed) !== null && _seed !== void 0 ? _seed : randomSeed();
161
- let value = hashSeed(seed) || 1;
162
-
163
- const next = () => value = xorshift(value);
164
-
165
- const integer = (min, max) => {
166
- return Math.floor((next() - MIN) / (MAX - MIN) * (max + 1 - min) + min);
167
- };
168
-
169
- return {
170
- seed,
171
-
172
- bool(likelihood = 50) {
173
- return integer(0, 100) < likelihood;
174
- },
175
-
176
- integer(min, max) {
177
- return integer(min, max);
178
- },
179
-
180
- pick(arr) {
181
- return arr[integer(0, arr.length - 1)];
182
- }
183
-
184
- };
185
- }
186
-
187
- var prng = /*#__PURE__*/Object.freeze({
188
- __proto__: null,
189
- create: create
190
- });
191
-
192
- const ccLicenses = {
193
- by: {
194
- permits: ['Reproduction', 'Distribution', 'DerivativeWorks'],
195
- requires: ['Notice', 'Attribution'],
196
- prohibits: []
197
- },
198
- 'by-sa': {
199
- permits: ['Reproduction', 'Distribution', 'DerivativeWorks'],
200
- requires: ['Notice', 'Attribution', 'ShareAlike'],
201
- prohibits: []
202
- },
203
- 'by-nd': {
204
- permits: ['Reproduction', 'Distribution'],
205
- requires: ['Notice', 'Attribution'],
206
- prohibits: []
207
- },
208
- 'by-nc': {
209
- permits: ['Reproduction', 'Distribution', 'DerivativeWorks'],
210
- requires: ['Notice', 'Attribution'],
211
- prohibits: ['CommercialUse']
212
- },
213
- 'by-nc-sa': {
214
- permits: ['Reproduction', 'Distribution', 'DerivativeWorks'],
215
- requires: ['Notice', 'Attribution', 'ShareAlike'],
216
- prohibits: ['CommercialUse']
217
- },
218
- 'by-nc-nd': {
219
- permits: ['Reproduction', 'Distribution'],
220
- requires: ['Notice', 'Attribution'],
221
- prohibits: ['CommercialUse']
222
- },
223
- zero: {
224
- permits: ['Reproduction', 'Distribution', 'DerivativeWorks'],
225
- requires: [],
226
- prohibits: []
227
- }
228
- };
229
- function createGroup({
230
- children,
231
- x,
232
- y
233
- }) {
234
- return "<g transform=\"translate(".concat(x, ", ").concat(y, ")\">").concat(children, "</g>");
235
- }
236
- function getXmlnsAttributes() {
237
- return {
238
- 'xmlns:dc': 'http://purl.org/dc/elements/1.1/',
239
- 'xmlns:cc': 'http://creativecommons.org/ns#',
240
- 'xmlns:rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
241
- 'xmlns:svg': 'http://www.w3.org/2000/svg',
242
- xmlns: 'http://www.w3.org/2000/svg'
243
- };
244
- }
245
- function getMetadata(style) {
246
- return "\n<metadata>\n<rdf:RDF>\n<cc:Work>\n<dc:format>image/svg+xml</dc:format>\n<dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\" />\n".concat(getMetadataWorkTitle(style), "\n").concat(getMetadataWorkCreator(style), "\n").concat(getMetadataWorkSource(style), "\n").concat(getMetadataWorkLicense(style), "\n").concat(getMetadataWorkContributor(style), "\n</cc:Work>\n").concat(getMetadataLicense(style), "\n</rdf:RDF>\n</metadata>\n");
247
- }
248
- function getMetadataWorkTitle(style) {
249
- if (style.meta.title) {
250
- return "<dc:title>".concat(style.meta.title, "</dc:title>");
251
- }
252
-
253
- return '';
254
- }
255
- function getMetadataWorkCreator(style) {
256
- if (style.meta.creator) {
257
- let creators = Array.isArray(style.meta.creator) ? style.meta.creator : [style.meta.creator];
258
- return "\n<dc:creator>\n".concat(getMetadataWorkAgents(creators), "\n</dc:creator>\n");
259
- }
260
-
261
- return '';
262
- }
263
- function getMetadataWorkSource(style) {
264
- if (style.meta.source) {
265
- return "<dc:source>".concat(style.meta.source, "</dc:source>");
266
- }
267
-
268
- return '';
269
- }
270
- function getMetadataWorkLicense(style) {
271
- if (style.meta.license) {
272
- return "<cc:license rdf:resource=\"".concat(style.meta.license.url, "\" />");
273
- }
274
-
275
- return '';
276
- }
277
- function getMetadataWorkContributor(style) {
278
- if (style.meta.contributor) {
279
- let contributors = Array.isArray(style.meta.contributor) ? style.meta.contributor : [style.meta.contributor];
280
- return "\n<dc:contributor>\n".concat(getMetadataWorkAgents(contributors), "\n</dc:contributor>\n");
281
- }
282
-
283
- return '';
284
- }
285
- function getMetadataWorkAgents(agents) {
286
- return agents.map(agent => "\n<cc:Agent>\n<dc:title>".concat(agent, "</dc:title>\n</cc:Agent>\n"));
287
- }
288
- function getMetadataLicense(style) {
289
- var _style$meta$license;
290
-
291
- let match = (_style$meta$license = style.meta.license) === null || _style$meta$license === void 0 ? void 0 : _style$meta$license.url.match(/^https?:\/\/creativecommons.org\/(?:licenses|publicdomain)\/([a-z\-]+)\/\d.\d\//);
292
-
293
- if (match) {
294
- let license = ccLicenses[match[1]];
295
-
296
- if (license) {
297
- var _style$meta$license2;
298
-
299
- let result = "";
300
- license.permits.forEach(permits => {
301
- result += "<cc:permits rdf:resource=\"https://creativecommons.org/ns#".concat(permits, "\" />");
302
- });
303
- license.requires.forEach(requires => {
304
- result += "<cc:requires rdf:resource=\"https://creativecommons.org/ns#".concat(requires, "\" />");
305
- });
306
- license.prohibits.forEach(prohibits => {
307
- result += "<cc:prohibits rdf:resource=\"https://creativecommons.org/ns#".concat(prohibits, "\" />");
308
- });
309
- return "\n<cc:License rdf:about=\"".concat((_style$meta$license2 = style.meta.license) === null || _style$meta$license2 === void 0 ? void 0 : _style$meta$license2.url, "\">\n").concat(result, "\n</cc:License>\n");
310
- }
311
- }
312
-
313
- return '';
314
- }
315
- function getViewBox(result) {
316
- let viewBox = result.attributes['viewBox'].split(' ');
317
- let x = parseInt(viewBox[0]);
318
- let y = parseInt(viewBox[1]);
319
- let width = parseInt(viewBox[2]);
320
- let height = parseInt(viewBox[3]);
321
- return {
322
- x,
323
- y,
324
- width,
325
- height
326
- };
327
- }
328
- function addBackgroundColor(result, backgroundColor) {
329
- let {
330
- width,
331
- height,
332
- x,
333
- y
334
- } = getViewBox(result);
335
- return "\n<rect fill=\"".concat(backgroundColor, "\" width=\"").concat(width, "\" height=\"").concat(height, "\" x=\"").concat(x, "\" y=\"").concat(y, "\" />\n").concat(result.body, "\n");
336
- }
337
- function addScale(result, scale) {
338
- let {
339
- width,
340
- height,
341
- x,
342
- y
343
- } = getViewBox(result);
344
- let percent = scale ? (scale - 100) / 100 : 0;
345
- let translateX = (width / 2 + x) * percent * -1;
346
- let translateY = (height / 2 + y) * percent * -1;
347
- return "\n<g transform=\"translate(".concat(translateX, " ").concat(translateY, ") scale(").concat(scale / 100, ")\">\n").concat(result.body, "\n</g>\n");
348
- }
349
- function addTranslate(result, x, y) {
350
- let viewBox = getViewBox(result);
351
- let translateX = (viewBox.width + viewBox.x * 2) * ((x !== null && x !== void 0 ? x : 0) / 100);
352
- let translateY = (viewBox.height + viewBox.y * 2) * ((y !== null && y !== void 0 ? y : 0) / 100);
353
- return "\n<g transform=\"translate(".concat(translateX, " ").concat(translateY, ")\">\n").concat(result.body, "\n</g>\n");
354
- }
355
- function addRotate(result, rotate) {
356
- let {
357
- width,
358
- height,
359
- x,
360
- y
361
- } = getViewBox(result);
362
- return "\n<g transform=\"rotate(".concat(rotate, ", ").concat(width / 2 + x, ", ").concat(height / 2 + y, ")\">\n").concat(result.body, "\n</g>\n");
363
- }
364
- function addFlip(result) {
365
- let {
366
- width,
367
- x
368
- } = getViewBox(result);
369
- return "\n<g transform=\"scale(-1 1) translate(".concat(width * -1 - x * 2, " 0)\">\n").concat(result.body, "\n</g>\n");
370
- }
371
- function addViewboxMask(result, radius) {
372
- let {
373
- width,
374
- height,
375
- x,
376
- y
377
- } = getViewBox(result);
378
- let rx = radius ? width * radius / 100 : 0;
379
- let ry = radius ? height * radius / 100 : 0;
380
- return "\n<mask id=\"viewboxMask\">\n<rect width=\"".concat(width, "\" height=\"").concat(height, "\" rx=\"").concat(rx, "\" ry=\"").concat(ry, "\" x=\"").concat(x, "\" y=\"").concat(y, "\" fill=\"#fff\" />\n</mask>\n<g mask=\"url(#viewboxMask)\">").concat(result.body, "</g>\n");
381
- }
382
- function createAttrString(attributes) {
383
- attributes = { ...getXmlnsAttributes(),
384
- ...attributes
385
- };
386
- return Object.keys(attributes).map(attr => "".concat(xml(attr), "=\"").concat(xml(attributes[attr]), "\"")).join(' ');
387
- }
388
- function removeWhitespace(svg) {
389
- return svg // Remove spaces at both ends of the string
390
- .trim() // Remove breaking lines
391
- .replace(/\n/g, ' ') // Remove space between tags
392
- .replace(/>\s+</g, '><') // Reduce whitespace
393
- .replace(/\s{2,}/g, ' ') // Create self closing tags
394
- .replace(/<([^\/>]+)><\/[^>]+>/gi, '<$1/>') // Remove whitespace before tag close
395
- .replace(/\s(\/?>)/g, '$1');
396
- }
397
- function convertToDataUri(svg) {
398
- return "data:image/svg+xml;utf8,".concat(encodeURIComponent(svg));
399
- }
400
-
401
- var svg = /*#__PURE__*/Object.freeze({
402
- __proto__: null,
403
- createGroup: createGroup,
404
- getXmlnsAttributes: getXmlnsAttributes,
405
- getMetadata: getMetadata,
406
- getMetadataWorkTitle: getMetadataWorkTitle,
407
- getMetadataWorkCreator: getMetadataWorkCreator,
408
- getMetadataWorkSource: getMetadataWorkSource,
409
- getMetadataWorkLicense: getMetadataWorkLicense,
410
- getMetadataWorkContributor: getMetadataWorkContributor,
411
- getMetadataWorkAgents: getMetadataWorkAgents,
412
- getMetadataLicense: getMetadataLicense,
413
- getViewBox: getViewBox,
414
- addBackgroundColor: addBackgroundColor,
415
- addScale: addScale,
416
- addTranslate: addTranslate,
417
- addRotate: addRotate,
418
- addFlip: addFlip,
419
- addViewboxMask: addViewboxMask,
420
- createAttrString: createAttrString,
421
- removeWhitespace: removeWhitespace,
422
- convertToDataUri: convertToDataUri
423
- });
424
-
425
- var index = /*#__PURE__*/Object.freeze({
426
- __proto__: null,
427
- escape: _escape,
428
- options: options,
429
- prng: prng,
430
- svg: svg,
431
- schema: schema$1
432
- });
433
-
434
- function createAvatar(style, options = {}) {
435
- var _options$backgroundCo;
436
-
437
- options = merge(style, options);
438
- const prng = create(options.seed);
439
- const result = style.create({
440
- prng: prng,
441
- options
442
- });
443
- const backgroundColor = prng.pick((_options$backgroundCo = options.backgroundColor) !== null && _options$backgroundCo !== void 0 ? _options$backgroundCo : []);
444
-
445
- if (options.size) {
446
- result.attributes.width = options.size.toString();
447
- result.attributes.height = options.size.toString();
448
- }
449
-
450
- if (options.scale !== undefined && options.scale !== 100) {
451
- result.body = addScale(result, options.scale);
452
- }
453
-
454
- if (options.flip) {
455
- result.body = addFlip(result);
456
- }
457
-
458
- if (options.rotate) {
459
- result.body = addRotate(result, options.rotate);
460
- }
461
-
462
- if (options.translateX || options.translateY) {
463
- result.body = addTranslate(result, options.translateX, options.translateY);
464
- }
465
-
466
- if (backgroundColor && backgroundColor !== 'transparent') {
467
- result.body = addBackgroundColor(result, backgroundColor);
468
- }
469
-
470
- if (options.radius || options.clip) {
471
- var _options$radius;
472
-
473
- result.body = addViewboxMask(result, (_options$radius = options.radius) !== null && _options$radius !== void 0 ? _options$radius : 0);
474
- }
475
-
476
- let avatar = removeWhitespace("\n<svg ".concat(createAttrString(result.attributes), ">\n").concat(getMetadata(style), "\n").concat(result.body, "\n</svg>\n"));
477
- return options.dataUri ? convertToDataUri(avatar) : avatar;
478
- }
479
- function createPreview(style, options, property) {
480
- var _style$preview, _options$backgroundCo2;
481
-
482
- options = merge(style, options);
483
- const prng = create(options.seed);
484
- let result = (_style$preview = style.preview) === null || _style$preview === void 0 ? void 0 : _style$preview.call(style, {
485
- prng,
486
- options,
487
- property
488
- });
489
- const backgroundColor = prng.pick((_options$backgroundCo2 = options.backgroundColor) !== null && _options$backgroundCo2 !== void 0 ? _options$backgroundCo2 : []);
490
- const hasBackgroundColor = backgroundColor && backgroundColor !== 'transparent';
491
- const isBackgroundVisible = property === 'backgroundColor';
492
-
493
- if (undefined === result) {
494
- if (hasBackgroundColor && isBackgroundVisible) {
495
- result = {
496
- attributes: {
497
- viewBox: "0 0 1 1",
498
- fill: 'none',
499
- 'shape-rendering': 'auto'
500
- },
501
- body: ""
502
- };
503
- } else {
504
- return undefined;
505
- }
506
- }
507
-
508
- if (hasBackgroundColor && isBackgroundVisible) {
509
- result.body = addBackgroundColor(result, backgroundColor);
510
- }
511
-
512
- let avatar = removeWhitespace("\n<svg ".concat(createAttrString(result.attributes), ">\n").concat(getMetadata(style), "\n").concat(result.body, "\n</svg>\n"));
513
- return options.dataUri ? convertToDataUri(avatar) : avatar;
514
- }
515
-
516
- /*!
517
- * DiceBear (@dicebear/core)
518
- *
519
- * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/main/LICENSE)
520
- * Copyright (c) 2021 Florian Körner
521
- */
522
- const schema = untypedSchema;
523
-
524
- exports.createAvatar = createAvatar;
525
- exports.createPreview = createPreview;
526
- exports.schema = schema;
527
- exports.utils = index;
package/dist/index.umd.js DELETED
@@ -1,8 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).DiceBear={})}(this,(function(t){"use strict";var e={type:"object",$schema:"http://json-schema.org/draft-07/schema#",title:"Options",properties:{seed:{type:"string"},dataUri:{type:"boolean",default:!1},flip:{type:"boolean",default:!1},rotate:{type:"integer",minimum:0,maximum:360,default:0},scale:{type:"integer",minimum:0,maximum:200,default:100},radius:{type:"integer",minimum:0,maximum:50,default:0},size:{type:"integer",minimum:1},backgroundColor:{type:"array",items:{anyOf:[{type:"string",pattern:"^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$"},{type:"string",pattern:"^[0-9a-zA-Z]+$"}]}},translateX:{type:"integer",minimum:-100,maximum:100,default:0},translateY:{type:"integer",minimum:-100,maximum:100,default:0},clip:{type:"boolean",default:!0}},additionalProperties:!1};function r(t){return t.replace(/&/g,"&amp;").replace(/'/g,"&apos;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var n=Object.freeze({__proto__:null,xml:r});function o(t){var e;return null!==(e=t.properties)&&void 0!==e?e:{}}function c(t){let e={},r=o(t);return Object.keys(r).forEach((t=>{let n=r[t];"object"==typeof n&&void 0!==n.default&&(e[t]=n.default)})),e}var a=Object.freeze({__proto__:null,properties:o,defaults:c});function i(t,r){return{seed:Math.random().toString(),...c(e),...c(t.schema),...r}}var s=Object.freeze({__proto__:null,merge:i});const u=-2147483648,l=2147483647;function d(t){return t^=t<<13,t^=t>>17,t^=t<<5}function p(t){var e;let r=function(t){let e=0;for(let r=0;r<t.length;r++)e=(e<<5)-e+t.charCodeAt(r)|0,e=d(e);return e}(t=null!==(e=t)&&void 0!==e?e:u+Math.floor((l-u)*Math.random()).toString())||1;const n=(t,e)=>Math.floor(((r=d(r))-u)/(l-u)*(e+1-t)+t);return{seed:t,bool:(t=50)=>n(0,100)<t,integer:(t,e)=>n(t,e),pick:t=>t[n(0,t.length-1)]}}var m=Object.freeze({__proto__:null,create:p});const f={by:{permits:["Reproduction","Distribution","DerivativeWorks"],requires:["Notice","Attribution"],prohibits:[]},"by-sa":{permits:["Reproduction","Distribution","DerivativeWorks"],requires:["Notice","Attribution","ShareAlike"],prohibits:[]},"by-nd":{permits:["Reproduction","Distribution"],requires:["Notice","Attribution"],prohibits:[]},"by-nc":{permits:["Reproduction","Distribution","DerivativeWorks"],requires:["Notice","Attribution"],prohibits:["CommercialUse"]},"by-nc-sa":{permits:["Reproduction","Distribution","DerivativeWorks"],requires:["Notice","Attribution","ShareAlike"],prohibits:["CommercialUse"]},"by-nc-nd":{permits:["Reproduction","Distribution"],requires:["Notice","Attribution"],prohibits:["CommercialUse"]},zero:{permits:["Reproduction","Distribution","DerivativeWorks"],requires:[],prohibits:[]}};function g(){return{"xmlns:dc":"http://purl.org/dc/elements/1.1/","xmlns:cc":"http://creativecommons.org/ns#","xmlns:rdf":"http://www.w3.org/1999/02/22-rdf-syntax-ns#","xmlns:svg":"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/svg"}}function b(t){return'\n<metadata>\n<rdf:RDF>\n<cc:Work>\n<dc:format>image/svg+xml</dc:format>\n<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />\n'.concat(h(t),"\n").concat(v(t),"\n").concat(y(t),"\n").concat(w(t),"\n").concat(x(t),"\n</cc:Work>\n").concat(_(t),"\n</rdf:RDF>\n</metadata>\n")}function h(t){return t.meta.title?"<dc:title>".concat(t.meta.title,"</dc:title>"):""}function v(t){if(t.meta.creator){let e=Array.isArray(t.meta.creator)?t.meta.creator:[t.meta.creator];return"\n<dc:creator>\n".concat(k(e),"\n</dc:creator>\n")}return""}function y(t){return t.meta.source?"<dc:source>".concat(t.meta.source,"</dc:source>"):""}function w(t){return t.meta.license?'<cc:license rdf:resource="'.concat(t.meta.license.url,'" />'):""}function x(t){if(t.meta.contributor){let e=Array.isArray(t.meta.contributor)?t.meta.contributor:[t.meta.contributor];return"\n<dc:contributor>\n".concat(k(e),"\n</dc:contributor>\n")}return""}function k(t){return t.map((t=>"\n<cc:Agent>\n<dc:title>".concat(t,"</dc:title>\n</cc:Agent>\n")))}function _(t){var e;let r=null===(e=t.meta.license)||void 0===e?void 0:e.url.match(/^https?:\/\/creativecommons.org\/(?:licenses|publicdomain)\/([a-z\-]+)\/\d.\d\//);if(r){let e=f[r[1]];if(e){var n;let r="";return e.permits.forEach((t=>{r+='<cc:permits rdf:resource="https://creativecommons.org/ns#'.concat(t,'" />')})),e.requires.forEach((t=>{r+='<cc:requires rdf:resource="https://creativecommons.org/ns#'.concat(t,'" />')})),e.prohibits.forEach((t=>{r+='<cc:prohibits rdf:resource="https://creativecommons.org/ns#'.concat(t,'" />')})),'\n<cc:License rdf:about="'.concat(null===(n=t.meta.license)||void 0===n?void 0:n.url,'">\n').concat(r,"\n</cc:License>\n")}}return""}function A(t){let e=t.attributes.viewBox.split(" ");return{x:parseInt(e[0]),y:parseInt(e[1]),width:parseInt(e[2]),height:parseInt(e[3])}}function D(t,e){let{width:r,height:n,x:o,y:c}=A(t);return'\n<rect fill="'.concat(e,'" width="').concat(r,'" height="').concat(n,'" x="').concat(o,'" y="').concat(c,'" />\n').concat(t.body,"\n")}function M(t,e){let{width:r,height:n,x:o,y:c}=A(t),a=e?(e-100)/100:0,i=(n/2+c)*a*-1;return'\n<g transform="translate('.concat((r/2+o)*a*-1," ").concat(i,") scale(").concat(e/100,')">\n').concat(t.body,"\n</g>\n")}function j(t,e,r){let n=A(t),o=(n.width+2*n.x)*((null!=e?e:0)/100),c=(n.height+2*n.y)*((null!=r?r:0)/100);return'\n<g transform="translate('.concat(o," ").concat(c,')">\n').concat(t.body,"\n</g>\n")}function W(t,e){let{width:r,height:n,x:o,y:c}=A(t);return'\n<g transform="rotate('.concat(e,", ").concat(r/2+o,", ").concat(n/2+c,')">\n').concat(t.body,"\n</g>\n")}function z(t){let{width:e,x:r}=A(t);return'\n<g transform="scale(-1 1) translate('.concat(-1*e-2*r,' 0)">\n').concat(t.body,"\n</g>\n")}function C(t,e){let{width:r,height:n,x:o,y:c}=A(t),a=e?r*e/100:0,i=e?n*e/100:0;return'\n<mask id="viewboxMask">\n<rect width="'.concat(r,'" height="').concat(n,'" rx="').concat(a,'" ry="').concat(i,'" x="').concat(o,'" y="').concat(c,'" fill="#fff" />\n</mask>\n<g mask="url(#viewboxMask)">').concat(t.body,"</g>\n")}function O(t){return t={"xmlns:dc":"http://purl.org/dc/elements/1.1/","xmlns:cc":"http://creativecommons.org/ns#","xmlns:rdf":"http://www.w3.org/1999/02/22-rdf-syntax-ns#","xmlns:svg":"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/svg",...t},Object.keys(t).map((e=>"".concat(r(e),'="').concat(r(t[e]),'"'))).join(" ")}function R(t){return t.trim().replace(/\n/g," ").replace(/>\s+</g,"><").replace(/\s{2,}/g," ").replace(/<([^\/>]+)><\/[^>]+>/gi,"<$1/>").replace(/\s(\/?>)/g,"$1")}function q(t){return"data:image/svg+xml;utf8,".concat(encodeURIComponent(t))}var S=Object.freeze({__proto__:null,createGroup:function({children:t,x:e,y:r}){return'<g transform="translate('.concat(e,", ").concat(r,')">').concat(t,"</g>")},getXmlnsAttributes:g,getMetadata:b,getMetadataWorkTitle:h,getMetadataWorkCreator:v,getMetadataWorkSource:y,getMetadataWorkLicense:w,getMetadataWorkContributor:x,getMetadataWorkAgents:k,getMetadataLicense:_,getViewBox:A,addBackgroundColor:D,addScale:M,addTranslate:j,addRotate:W,addFlip:z,addViewboxMask:C,createAttrString:O,removeWhitespace:R,convertToDataUri:q}),U=Object.freeze({__proto__:null,escape:n,options:s,prng:m,svg:S,schema:a});
2
- /*!
3
- * DiceBear (@dicebear/core)
4
- *
5
- * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/main/LICENSE)
6
- * Copyright (c) 2021 Florian Körner
7
- */
8
- const F=e;t.createAvatar=function(t,e={}){var r;const n=p((e=i(t,e)).seed),o=t.create({prng:n,options:e}),c=n.pick(null!==(r=e.backgroundColor)&&void 0!==r?r:[]);var a;e.size&&(o.attributes.width=e.size.toString(),o.attributes.height=e.size.toString()),void 0!==e.scale&&100!==e.scale&&(o.body=M(o,e.scale)),e.flip&&(o.body=z(o)),e.rotate&&(o.body=W(o,e.rotate)),(e.translateX||e.translateY)&&(o.body=j(o,e.translateX,e.translateY)),c&&"transparent"!==c&&(o.body=D(o,c)),(e.radius||e.clip)&&(o.body=C(o,null!==(a=e.radius)&&void 0!==a?a:0));let s=R("\n<svg ".concat(O(o.attributes),">\n").concat(b(t),"\n").concat(o.body,"\n</svg>\n"));return e.dataUri?q(s):s},t.createPreview=function(t,e,r){var n,o;const c=p((e=i(t,e)).seed);let a=null===(n=t.preview)||void 0===n?void 0:n.call(t,{prng:c,options:e,property:r});const s=c.pick(null!==(o=e.backgroundColor)&&void 0!==o?o:[]),u=s&&"transparent"!==s,l="backgroundColor"===r;if(void 0===a){if(!u||!l)return;a={attributes:{viewBox:"0 0 1 1",fill:"none","shape-rendering":"auto"},body:""}}u&&l&&(a.body=D(a,s));let d=R("\n<svg ".concat(O(a.attributes),">\n").concat(b(t),"\n").concat(a.body,"\n</svg>\n"));return e.dataUri?q(d):d},t.schema=F,t.utils=U,Object.defineProperty(t,"__esModule",{value:!0})}));
package/dist/options.d.ts DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * This file was automatically generated by json-schema-to-typescript.
3
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
- * and run json-schema-to-typescript to regenerate this file.
5
- */
6
- export interface Options {
7
- seed?: string;
8
- dataUri?: boolean;
9
- flip?: boolean;
10
- rotate?: number;
11
- scale?: number;
12
- radius?: number;
13
- size?: number;
14
- backgroundColor?: (string | string)[];
15
- translateX?: number;
16
- translateY?: number;
17
- clip?: boolean;
18
- }
@@ -1,5 +0,0 @@
1
- export * as escape from './escape';
2
- export * as options from './options';
3
- export * as prng from './prng';
4
- export * as svg from './svg';
5
- export * as schema from './schema';
@@ -1,2 +0,0 @@
1
- import type { Style, StyleOptions } from '../types';
2
- export declare function merge<O extends {}>(style: Style<O>, options: StyleOptions<O>): StyleOptions<O>;
@@ -1,5 +0,0 @@
1
- import { StyleSchema } from '../types';
2
- export declare function properties(schema: StyleSchema): {
3
- [key: string]: import("json-schema").JSONSchema7Definition;
4
- };
5
- export declare function defaults(schema: StyleSchema): Record<string, unknown>;