@dicebear/core 5.0.0-alpha.16 → 5.0.0-alpha.21
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/LICENSE +1 -1
- package/lib/core.d.ts +2 -3
- package/lib/core.js +17 -38
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/schema.js +0 -5
- package/lib/types.d.ts +16 -20
- package/lib/utils/escape.d.ts +2 -1
- package/lib/utils/escape.js +6 -2
- package/lib/utils/license.d.ts +3 -0
- package/lib/utils/license.js +51 -0
- package/lib/utils/options.d.ts +2 -2
- package/lib/utils/svg.d.ts +1 -17
- package/lib/utils/svg.js +1 -122
- package/package.json +7 -7
package/LICENSE
CHANGED
package/lib/core.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type { Style, StyleOptions } from './types.js';
|
|
2
|
-
export declare function createAvatar<O extends {}>(style: Style<O>, options?: StyleOptions<O>):
|
|
3
|
-
export declare function createPreview<O extends {}>(style: Style<O>, options: StyleOptions<O>, property: keyof StyleOptions<O>): string | undefined;
|
|
1
|
+
import type { Result, Style, StyleOptions } from './types.js';
|
|
2
|
+
export declare function createAvatar<O extends {}>(style: Style<O>, options?: StyleOptions<O>): Result;
|
package/lib/core.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as svgUtils from './utils/svg.js';
|
|
2
2
|
import { merge as mergeOptions } from './utils/options.js';
|
|
3
3
|
import { create as createPrng } from './utils/prng.js';
|
|
4
|
-
import
|
|
4
|
+
import * as license from './utils/license.js';
|
|
5
|
+
import { toFormat } from '@dicebear/converter';
|
|
5
6
|
export function createAvatar(style, options = {}) {
|
|
6
7
|
var _a, _b;
|
|
7
8
|
options = mergeOptions(style, options);
|
|
@@ -30,41 +31,19 @@ export function createAvatar(style, options = {}) {
|
|
|
30
31
|
if (options.radius || options.clip) {
|
|
31
32
|
result.body = svgUtils.addViewboxMask(result, (_b = options.radius) !== null && _b !== void 0 ? _b : 0);
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (hasBackgroundColor && isBackgroundVisible) {
|
|
49
|
-
result = {
|
|
50
|
-
attributes: {
|
|
51
|
-
viewBox: `0 0 1 1`,
|
|
52
|
-
fill: 'none',
|
|
53
|
-
'shape-rendering': 'auto',
|
|
54
|
-
},
|
|
55
|
-
body: ``,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
if (hasBackgroundColor && isBackgroundVisible) {
|
|
63
|
-
result.body = svgUtils.addBackgroundColor(result, backgroundColor);
|
|
64
|
-
}
|
|
65
|
-
let avatar = `<svg ${svgUtils.createAttrString(result.attributes)}>` +
|
|
66
|
-
`${svgUtils.getMetadata(style)}` +
|
|
67
|
-
`${result.body}` +
|
|
68
|
-
`</svg>`;
|
|
69
|
-
return options.dataUri ? convertToDataUri(avatar) : avatar;
|
|
34
|
+
const attributes = svgUtils.createAttrString(result.attributes);
|
|
35
|
+
const description = '<desc>Created with dicebear.com</desc>';
|
|
36
|
+
const metadata = license.xml(style);
|
|
37
|
+
const exif = license.exif(style);
|
|
38
|
+
const avatar = `<svg ${attributes}>${description}${metadata}${result.body}</svg>`;
|
|
39
|
+
return {
|
|
40
|
+
toString: () => avatar,
|
|
41
|
+
...toFormat(avatar, 'svg'),
|
|
42
|
+
png: ({ includeExif = false }) => {
|
|
43
|
+
return toFormat(avatar, 'png', includeExif ? exif : undefined);
|
|
44
|
+
},
|
|
45
|
+
jpeg: ({ includeExif = false }) => {
|
|
46
|
+
return toFormat(avatar, 'jpeg', includeExif ? exif : undefined);
|
|
47
|
+
},
|
|
48
|
+
};
|
|
70
49
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* DiceBear (@dicebear/core)
|
|
3
3
|
*
|
|
4
4
|
* Code licensed under MIT (https://github.com/dicebear/dicebear/blob/main/LICENSE)
|
|
5
|
-
* Copyright (c)
|
|
5
|
+
* Copyright (c) 2022 Florian Körner
|
|
6
6
|
*/
|
|
7
7
|
export * from './core.js';
|
|
8
8
|
export * from './schema.js';
|
|
9
|
+
export * as license from './utils/license.js';
|
|
9
10
|
export * from './types.js';
|
package/lib/index.js
CHANGED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* DiceBear (@dicebear/core)
|
|
3
3
|
*
|
|
4
4
|
* Code licensed under MIT (https://github.com/dicebear/dicebear/blob/main/LICENSE)
|
|
5
|
-
* Copyright (c)
|
|
5
|
+
* Copyright (c) 2022 Florian Körner
|
|
6
6
|
*/
|
|
7
7
|
export * from './core.js';
|
|
8
8
|
export * from './schema.js';
|
|
9
|
+
export * as license from './utils/license.js';
|
|
9
10
|
export * from './types.js';
|
package/lib/schema.js
CHANGED
package/lib/types.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { JSONSchema7 } from 'json-schema';
|
|
1
|
+
import type { JSONSchema7 } from 'json-schema';
|
|
2
|
+
import type { Result as ConverterResult } from '@dicebear/converter';
|
|
3
|
+
export interface ResultConvertOptions {
|
|
4
|
+
includeExif?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface Result extends ConverterResult {
|
|
7
|
+
png(options?: ResultConvertOptions): ConverterResult;
|
|
8
|
+
jpeg(options?: ResultConvertOptions): ConverterResult;
|
|
9
|
+
toString(): string;
|
|
10
|
+
}
|
|
2
11
|
export interface Options {
|
|
3
12
|
seed?: string;
|
|
4
|
-
dataUri?: boolean;
|
|
5
13
|
flip?: boolean;
|
|
6
14
|
rotate?: number;
|
|
7
15
|
scale?: number;
|
|
@@ -12,6 +20,10 @@ export interface Options {
|
|
|
12
20
|
translateY?: number;
|
|
13
21
|
clip?: boolean;
|
|
14
22
|
}
|
|
23
|
+
export interface Exif {
|
|
24
|
+
[key: string]: string;
|
|
25
|
+
}
|
|
26
|
+
export declare type SchemaDefaults = Record<string, unknown>;
|
|
15
27
|
export interface Prng {
|
|
16
28
|
seed: string;
|
|
17
29
|
bool(likelihood?: number): boolean;
|
|
@@ -33,34 +45,18 @@ export interface StyleCreateResult {
|
|
|
33
45
|
attributes: StyleCreateResultAttributes;
|
|
34
46
|
body: string;
|
|
35
47
|
}
|
|
36
|
-
export interface StylePreviewProps<O> {
|
|
37
|
-
prng: Prng;
|
|
38
|
-
options: StyleOptions<O>;
|
|
39
|
-
property: keyof StyleOptions<O>;
|
|
40
|
-
}
|
|
41
|
-
export declare type StylePreview<O extends {}> = (props: StylePreviewProps<O>) => StylePreviewResult;
|
|
42
|
-
export interface StylePreviewResultAttributes {
|
|
43
|
-
viewBox: string;
|
|
44
|
-
[key: string]: string;
|
|
45
|
-
}
|
|
46
|
-
export declare type StylePreviewResult = undefined | {
|
|
47
|
-
attributes: StyleCreateResultAttributes;
|
|
48
|
-
head?: string;
|
|
49
|
-
body: string;
|
|
50
|
-
};
|
|
51
48
|
export interface StyleMeta {
|
|
52
49
|
title?: string;
|
|
53
|
-
creator?: string | string[];
|
|
54
50
|
source?: string;
|
|
51
|
+
creator?: string;
|
|
52
|
+
homepage?: string;
|
|
55
53
|
license?: {
|
|
56
54
|
name: string;
|
|
57
55
|
url: string;
|
|
58
56
|
};
|
|
59
|
-
contributor?: string | string[];
|
|
60
57
|
}
|
|
61
58
|
export interface Style<O extends {}> {
|
|
62
59
|
meta: StyleMeta;
|
|
63
60
|
schema: StyleSchema;
|
|
64
61
|
create: StyleCreate<O>;
|
|
65
|
-
preview?: StylePreview<O>;
|
|
66
62
|
}
|
package/lib/utils/escape.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare function xml(
|
|
1
|
+
export declare function xml(content: string): string;
|
|
2
|
+
export declare function md(content: string): string;
|
package/lib/utils/escape.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
export function xml(
|
|
2
|
-
return
|
|
1
|
+
export function xml(content) {
|
|
2
|
+
return content
|
|
3
3
|
.replace(/&/g, '&')
|
|
4
4
|
.replace(/'/g, ''')
|
|
5
5
|
.replace(/"/g, '"')
|
|
6
6
|
.replace(/</g, '<')
|
|
7
7
|
.replace(/>/g, '>');
|
|
8
8
|
}
|
|
9
|
+
export function md(content) {
|
|
10
|
+
const result = content.replace(/([\\`*_{}[\]()#+-.!])/g, '\\$1');
|
|
11
|
+
return xml(result);
|
|
12
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as _ from './escape.js';
|
|
2
|
+
export function xml(style) {
|
|
3
|
+
var _a, _b, _c, _d;
|
|
4
|
+
const xmlTitle = `<dc:title>${_.xml((_a = style.meta.title) !== null && _a !== void 0 ? _a : 'Unnamed')}</dc:title>`;
|
|
5
|
+
const xmlCreator = '<dc:creator>' +
|
|
6
|
+
`<cc:Agent rdf:about="${_.xml((_b = style.meta.homepage) !== null && _b !== void 0 ? _b : '')}">` +
|
|
7
|
+
`<dc:title>${_.xml((_c = style.meta.creator) !== null && _c !== void 0 ? _c : 'Unknown')}</dc:title>` +
|
|
8
|
+
'</cc:Agent>' +
|
|
9
|
+
'</dc:creator>';
|
|
10
|
+
const xmlSource = style.meta.source
|
|
11
|
+
? `<dc:source>${_.xml(style.meta.source)}</dc:source>`
|
|
12
|
+
: '';
|
|
13
|
+
const xmlLicense = ((_d = style.meta.license) === null || _d === void 0 ? void 0 : _d.url)
|
|
14
|
+
? `<cc:license rdf:resource="${_.xml(style.meta.license.url)}" />`
|
|
15
|
+
: '';
|
|
16
|
+
return ('<metadata' +
|
|
17
|
+
' id="license"' +
|
|
18
|
+
' xmlns:dc="http://purl.org/dc/elements/1.1/"' +
|
|
19
|
+
' xmlns:cc="http://creativecommons.org/ns#"' +
|
|
20
|
+
' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' +
|
|
21
|
+
'<rdf:RDF>' +
|
|
22
|
+
'<cc:Work>' +
|
|
23
|
+
xmlTitle +
|
|
24
|
+
xmlCreator +
|
|
25
|
+
xmlSource +
|
|
26
|
+
xmlLicense +
|
|
27
|
+
'</cc:Work>' +
|
|
28
|
+
'</rdf:RDF>' +
|
|
29
|
+
'</metadata>');
|
|
30
|
+
}
|
|
31
|
+
export function exif(style) {
|
|
32
|
+
var _a, _b, _c, _d;
|
|
33
|
+
const title = (_a = style.meta.title) !== null && _a !== void 0 ? _a : 'Unnamed';
|
|
34
|
+
const creator = (_b = style.meta.creator) !== null && _b !== void 0 ? _b : 'Unknown';
|
|
35
|
+
let copyright = `"${title}" by "${creator}"`;
|
|
36
|
+
if ((_c = style.meta.license) === null || _c === void 0 ? void 0 : _c.name) {
|
|
37
|
+
copyright += ` is licensed under "${style.meta.license.name}".`;
|
|
38
|
+
}
|
|
39
|
+
const exif = {
|
|
40
|
+
Copyright: copyright,
|
|
41
|
+
'XMP-dc:Title': title,
|
|
42
|
+
'XMP-dc:Creator': creator,
|
|
43
|
+
};
|
|
44
|
+
if (style.meta.source) {
|
|
45
|
+
exif['XMP-dc:Source'] = style.meta.source;
|
|
46
|
+
}
|
|
47
|
+
if ((_d = style.meta.license) === null || _d === void 0 ? void 0 : _d.url) {
|
|
48
|
+
exif['XMP-cc:License'] = style.meta.license.url;
|
|
49
|
+
}
|
|
50
|
+
return exif;
|
|
51
|
+
}
|
package/lib/utils/options.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Style, StyleOptions, StyleSchema } from '../types.js';
|
|
2
|
-
export declare function defaults(schema: StyleSchema):
|
|
1
|
+
import type { SchemaDefaults, Style, StyleOptions, StyleSchema } from '../types.js';
|
|
2
|
+
export declare function defaults(schema: StyleSchema): SchemaDefaults;
|
|
3
3
|
export declare function merge<O extends {}>(style: Style<O>, options: StyleOptions<O>): StyleOptions<O>;
|
package/lib/utils/svg.d.ts
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StyleCreateResult, StyleCreateResultAttributes } from '../types.js';
|
|
2
2
|
declare type CreateGroupProps = {
|
|
3
3
|
children: string;
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
6
6
|
};
|
|
7
7
|
export declare function createGroup({ children, x, y }: CreateGroupProps): string;
|
|
8
|
-
export declare function getXmlnsAttributes(): {
|
|
9
|
-
'xmlns:dc': string;
|
|
10
|
-
'xmlns:cc': string;
|
|
11
|
-
'xmlns:rdf': string;
|
|
12
|
-
'xmlns:svg': string;
|
|
13
|
-
xmlns: string;
|
|
14
|
-
};
|
|
15
|
-
export declare function getMetadata<O extends Options>(style: Style<O>): string;
|
|
16
|
-
export declare function getMetadataWorkTitle<O extends Options>(style: Style<O>): string;
|
|
17
|
-
export declare function getMetadataWorkCreator<O extends Options>(style: Style<O>): string;
|
|
18
|
-
export declare function getMetadataWorkSource<O extends Options>(style: Style<O>): string;
|
|
19
|
-
export declare function getMetadataWorkLicense<O extends Options>(style: Style<O>): string;
|
|
20
|
-
export declare function getMetadataWorkContributor<O extends Options>(style: Style<O>): string;
|
|
21
|
-
export declare function getMetadataWorkAgents(agents: string[]): string[];
|
|
22
|
-
export declare function getMetadataLicense<O extends Options>(style: Style<O>): string;
|
|
23
8
|
export declare function getViewBox(result: StyleCreateResult): {
|
|
24
9
|
x: number;
|
|
25
10
|
y: number;
|
|
@@ -33,5 +18,4 @@ export declare function addRotate(result: StyleCreateResult, rotate: number): st
|
|
|
33
18
|
export declare function addFlip(result: StyleCreateResult): string;
|
|
34
19
|
export declare function addViewboxMask(result: StyleCreateResult, radius: number): string;
|
|
35
20
|
export declare function createAttrString(attributes: StyleCreateResultAttributes): string;
|
|
36
|
-
export declare function convertToDataUri(svg: string): string;
|
|
37
21
|
export {};
|
package/lib/utils/svg.js
CHANGED
|
@@ -1,125 +1,7 @@
|
|
|
1
1
|
import * as escape from './escape.js';
|
|
2
|
-
const ccLicenses = {
|
|
3
|
-
by: {
|
|
4
|
-
permits: ['Reproduction', 'Distribution', 'DerivativeWorks'],
|
|
5
|
-
requires: ['Notice', 'Attribution'],
|
|
6
|
-
prohibits: [],
|
|
7
|
-
},
|
|
8
|
-
'by-sa': {
|
|
9
|
-
permits: ['Reproduction', 'Distribution', 'DerivativeWorks'],
|
|
10
|
-
requires: ['Notice', 'Attribution', 'ShareAlike'],
|
|
11
|
-
prohibits: [],
|
|
12
|
-
},
|
|
13
|
-
'by-nd': {
|
|
14
|
-
permits: ['Reproduction', 'Distribution'],
|
|
15
|
-
requires: ['Notice', 'Attribution'],
|
|
16
|
-
prohibits: [],
|
|
17
|
-
},
|
|
18
|
-
'by-nc': {
|
|
19
|
-
permits: ['Reproduction', 'Distribution', 'DerivativeWorks'],
|
|
20
|
-
requires: ['Notice', 'Attribution'],
|
|
21
|
-
prohibits: ['CommercialUse'],
|
|
22
|
-
},
|
|
23
|
-
'by-nc-sa': {
|
|
24
|
-
permits: ['Reproduction', 'Distribution', 'DerivativeWorks'],
|
|
25
|
-
requires: ['Notice', 'Attribution', 'ShareAlike'],
|
|
26
|
-
prohibits: ['CommercialUse'],
|
|
27
|
-
},
|
|
28
|
-
'by-nc-nd': {
|
|
29
|
-
permits: ['Reproduction', 'Distribution'],
|
|
30
|
-
requires: ['Notice', 'Attribution'],
|
|
31
|
-
prohibits: ['CommercialUse'],
|
|
32
|
-
},
|
|
33
|
-
zero: {
|
|
34
|
-
permits: ['Reproduction', 'Distribution', 'DerivativeWorks'],
|
|
35
|
-
requires: [],
|
|
36
|
-
prohibits: [],
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
2
|
export function createGroup({ children, x, y }) {
|
|
40
3
|
return `<g transform="translate(${x}, ${y})">${children}</g>`;
|
|
41
4
|
}
|
|
42
|
-
export function getXmlnsAttributes() {
|
|
43
|
-
return {
|
|
44
|
-
'xmlns:dc': 'http://purl.org/dc/elements/1.1/',
|
|
45
|
-
'xmlns:cc': 'http://creativecommons.org/ns#',
|
|
46
|
-
'xmlns:rdf': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
|
47
|
-
'xmlns:svg': 'http://www.w3.org/2000/svg',
|
|
48
|
-
xmlns: 'http://www.w3.org/2000/svg',
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
export function getMetadata(style) {
|
|
52
|
-
return (`<metadata>` +
|
|
53
|
-
`<rdf:RDF>` +
|
|
54
|
-
`<cc:Work>` +
|
|
55
|
-
`<dc:format>image/svg+xml</dc:format>` +
|
|
56
|
-
`<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />` +
|
|
57
|
-
`${getMetadataWorkTitle(style)}` +
|
|
58
|
-
`${getMetadataWorkCreator(style)}` +
|
|
59
|
-
`${getMetadataWorkSource(style)}` +
|
|
60
|
-
`${getMetadataWorkLicense(style)}` +
|
|
61
|
-
`${getMetadataWorkContributor(style)}` +
|
|
62
|
-
`</cc:Work>` +
|
|
63
|
-
`${getMetadataLicense(style)}` +
|
|
64
|
-
`</rdf:RDF>` +
|
|
65
|
-
`</metadata>`);
|
|
66
|
-
}
|
|
67
|
-
export function getMetadataWorkTitle(style) {
|
|
68
|
-
if (style.meta.title) {
|
|
69
|
-
return `<dc:title>${style.meta.title}</dc:title>`;
|
|
70
|
-
}
|
|
71
|
-
return '';
|
|
72
|
-
}
|
|
73
|
-
export function getMetadataWorkCreator(style) {
|
|
74
|
-
if (style.meta.creator) {
|
|
75
|
-
let creators = Array.isArray(style.meta.creator) ? style.meta.creator : [style.meta.creator];
|
|
76
|
-
return `<dc:creator>${getMetadataWorkAgents(creators)}</dc:creator>`;
|
|
77
|
-
}
|
|
78
|
-
return '';
|
|
79
|
-
}
|
|
80
|
-
export function getMetadataWorkSource(style) {
|
|
81
|
-
if (style.meta.source) {
|
|
82
|
-
return `<dc:source>${style.meta.source}</dc:source>`;
|
|
83
|
-
}
|
|
84
|
-
return '';
|
|
85
|
-
}
|
|
86
|
-
export function getMetadataWorkLicense(style) {
|
|
87
|
-
if (style.meta.license) {
|
|
88
|
-
return `<cc:license rdf:resource="${style.meta.license.url}" />`;
|
|
89
|
-
}
|
|
90
|
-
return '';
|
|
91
|
-
}
|
|
92
|
-
export function getMetadataWorkContributor(style) {
|
|
93
|
-
if (style.meta.contributor) {
|
|
94
|
-
let contributors = Array.isArray(style.meta.contributor) ? style.meta.contributor : [style.meta.contributor];
|
|
95
|
-
return `<dc:contributor>${getMetadataWorkAgents(contributors)}</dc:contributor>`;
|
|
96
|
-
}
|
|
97
|
-
return '';
|
|
98
|
-
}
|
|
99
|
-
export function getMetadataWorkAgents(agents) {
|
|
100
|
-
return agents.map((agent) => `<cc:Agent><dc:title>${agent}</dc:title></cc:Agent>`);
|
|
101
|
-
}
|
|
102
|
-
export function getMetadataLicense(style) {
|
|
103
|
-
var _a, _b;
|
|
104
|
-
let match = (_a = style.meta.license) === null || _a === void 0 ? void 0 : _a.url.match(/^https?:\/\/creativecommons.org\/(?:licenses|publicdomain)\/([a-z\-]+)\/\d.\d\//);
|
|
105
|
-
if (match) {
|
|
106
|
-
let license = ccLicenses[match[1]];
|
|
107
|
-
if (license) {
|
|
108
|
-
let result = ``;
|
|
109
|
-
license.permits.forEach((permits) => {
|
|
110
|
-
result += `<cc:permits rdf:resource="https://creativecommons.org/ns#${permits}" />`;
|
|
111
|
-
});
|
|
112
|
-
license.requires.forEach((requires) => {
|
|
113
|
-
result += `<cc:requires rdf:resource="https://creativecommons.org/ns#${requires}" />`;
|
|
114
|
-
});
|
|
115
|
-
license.prohibits.forEach((prohibits) => {
|
|
116
|
-
result += `<cc:prohibits rdf:resource="https://creativecommons.org/ns#${prohibits}" />`;
|
|
117
|
-
});
|
|
118
|
-
return `<cc:License rdf:about="${(_b = style.meta.license) === null || _b === void 0 ? void 0 : _b.url}">${result}</cc:License>`;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return '';
|
|
122
|
-
}
|
|
123
5
|
export function getViewBox(result) {
|
|
124
6
|
let viewBox = result.attributes['viewBox'].split(' ');
|
|
125
7
|
let x = parseInt(viewBox[0]);
|
|
@@ -168,11 +50,8 @@ export function addViewboxMask(result, radius) {
|
|
|
168
50
|
`<g mask="url(#viewboxMask)">${result.body}</g>`);
|
|
169
51
|
}
|
|
170
52
|
export function createAttrString(attributes) {
|
|
171
|
-
attributes = {
|
|
53
|
+
attributes = { xmlns: 'http://www.w3.org/2000/svg', ...attributes };
|
|
172
54
|
return Object.keys(attributes)
|
|
173
55
|
.map((attr) => `${escape.xml(attr)}="${escape.xml(attributes[attr])}"`)
|
|
174
56
|
.join(' ');
|
|
175
57
|
}
|
|
176
|
-
export function convertToDataUri(svg) {
|
|
177
|
-
return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
|
|
178
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dicebear/core",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.21",
|
|
4
4
|
"description": "An avatar library for designers and developers.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"avatar",
|
|
@@ -31,20 +31,20 @@
|
|
|
31
31
|
"test": "uvu tests"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
+
"@dicebear/converter": "^5.0.0-alpha.21",
|
|
34
35
|
"@types/json-schema": "^7.0.7"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
|
-
"@tsconfig/recommended": "^1.0.
|
|
38
|
-
"@types/jest": "^26.0.22",
|
|
38
|
+
"@tsconfig/recommended": "^1.0.1",
|
|
39
39
|
"del-cli": "^4.0.1",
|
|
40
|
-
"typescript": "^4.
|
|
41
|
-
"uvu": "^0.5.
|
|
40
|
+
"typescript": "^4.6.3",
|
|
41
|
+
"uvu": "^0.5.3"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
|
-
"node": "^
|
|
44
|
+
"node": "^14.13.1 || >=16.0.0"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "40b7190a19ba3c6c355178f1ae6c422229634e06"
|
|
50
50
|
}
|