@dicebear/core 5.0.0-alpha.9 → 5.0.0-beta.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 Florian Körner
3
+ Copyright (c) 2022 Florian Körner
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <h1 align="center"><img src="https://dicebear.com/api/male/seed.svg?mood=happy" width="124" /> <br />DiceBear</h1>
1
+ <h1 align="center"><img src="https://avatars.githubusercontent.com/u/7983162?s=256&v=4" width="124" /> <br />DiceBear</h1>
2
2
  <p align="center">
3
3
  <strong>DiceBear is an avatar library for designers and developers.</strong>
4
4
  </p>
package/lib/core.d.ts ADDED
@@ -0,0 +1,2 @@
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 ADDED
@@ -0,0 +1,50 @@
1
+ import * as svgUtils from './utils/svg.js';
2
+ import { merge as mergeOptions } from './utils/options.js';
3
+ import { create as createPrng } from './utils/prng.js';
4
+ import * as license from './utils/license.js';
5
+ import { toFormat } from '@dicebear/converter';
6
+ export function createAvatar(style, options = {}) {
7
+ var _a, _b;
8
+ options = mergeOptions(style, options);
9
+ const prng = createPrng(options.seed);
10
+ const result = style.create({ prng: prng, options });
11
+ const backgroundColor = prng.pick((_a = options.backgroundColor) !== null && _a !== void 0 ? _a : []);
12
+ if (options.size) {
13
+ result.attributes.width = options.size.toString();
14
+ result.attributes.height = options.size.toString();
15
+ }
16
+ if (options.scale !== undefined && options.scale !== 100) {
17
+ result.body = svgUtils.addScale(result, options.scale);
18
+ }
19
+ if (options.flip) {
20
+ result.body = svgUtils.addFlip(result);
21
+ }
22
+ if (options.rotate) {
23
+ result.body = svgUtils.addRotate(result, options.rotate);
24
+ }
25
+ if (options.translateX || options.translateY) {
26
+ result.body = svgUtils.addTranslate(result, options.translateX, options.translateY);
27
+ }
28
+ if (backgroundColor && backgroundColor !== 'transparent') {
29
+ result.body = svgUtils.addBackgroundColor(result, backgroundColor);
30
+ }
31
+ if (options.radius || options.clip) {
32
+ result.body = svgUtils.addViewboxMask(result, (_b = options.radius) !== null && _b !== void 0 ? _b : 0);
33
+ }
34
+ // Reduces the occurrence of ID collisions when rendering multiple avatars on one HTML page.
35
+ result.body = svgUtils.randomizeIds(result, prng.seed);
36
+ const attributes = svgUtils.createAttrString(result);
37
+ const metadata = license.xml(style);
38
+ const exif = license.exif(style);
39
+ const avatar = `<svg ${attributes}>${metadata}${result.body}</svg>`;
40
+ return {
41
+ toString: () => avatar,
42
+ ...toFormat(avatar, 'svg'),
43
+ png: ({ includeExif = false } = {}) => {
44
+ return toFormat(avatar, 'png', includeExif ? exif : undefined);
45
+ },
46
+ jpeg: ({ includeExif = false } = {}) => {
47
+ return toFormat(avatar, 'jpeg', includeExif ? exif : undefined);
48
+ },
49
+ };
50
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * DiceBear (@dicebear/core)
3
+ *
4
+ * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/main/LICENSE)
5
+ * Copyright (c) 2022 Florian Körner
6
+ */
7
+ export * from './core.js';
8
+ export * from './schema.js';
9
+ export * as license from './utils/license.js';
10
+ export * as escape from './utils/escape.js';
11
+ export * from './types.js';
package/lib/index.js ADDED
@@ -0,0 +1,11 @@
1
+ /*!
2
+ * DiceBear (@dicebear/core)
3
+ *
4
+ * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/main/LICENSE)
5
+ * Copyright (c) 2022 Florian Körner
6
+ */
7
+ export * from './core.js';
8
+ export * from './schema.js';
9
+ export * as license from './utils/license.js';
10
+ export * as escape from './utils/escape.js';
11
+ export * from './types.js';
@@ -0,0 +1,2 @@
1
+ import { JSONSchema7 } from 'json-schema';
2
+ export declare const schema: JSONSchema7;
package/lib/schema.js ADDED
@@ -0,0 +1,58 @@
1
+ export const schema = {
2
+ type: 'object',
3
+ $schema: 'http://json-schema.org/draft-07/schema#',
4
+ properties: {
5
+ seed: {
6
+ type: 'string',
7
+ },
8
+ flip: {
9
+ type: 'boolean',
10
+ default: false,
11
+ },
12
+ rotate: {
13
+ type: 'integer',
14
+ minimum: 0,
15
+ maximum: 360,
16
+ default: 0,
17
+ },
18
+ scale: {
19
+ type: 'integer',
20
+ minimum: 0,
21
+ maximum: 200,
22
+ default: 100,
23
+ },
24
+ radius: {
25
+ type: 'integer',
26
+ minimum: 0,
27
+ maximum: 50,
28
+ default: 0,
29
+ },
30
+ size: {
31
+ type: 'integer',
32
+ minimum: 1,
33
+ },
34
+ backgroundColor: {
35
+ type: 'array',
36
+ items: {
37
+ type: 'string',
38
+ pattern: '^[a-fA-F0-9]{6}$',
39
+ },
40
+ },
41
+ translateX: {
42
+ type: 'integer',
43
+ minimum: -100,
44
+ maximum: 100,
45
+ default: 0,
46
+ },
47
+ translateY: {
48
+ type: 'integer',
49
+ minimum: -100,
50
+ maximum: 100,
51
+ default: 0,
52
+ },
53
+ clip: {
54
+ type: 'boolean',
55
+ default: true,
56
+ },
57
+ },
58
+ };
package/lib/types.d.ts ADDED
@@ -0,0 +1,63 @@
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
+ }
11
+ export interface Options {
12
+ seed?: string;
13
+ flip?: boolean;
14
+ rotate?: number;
15
+ scale?: number;
16
+ radius?: number;
17
+ size?: number;
18
+ backgroundColor?: string[];
19
+ translateX?: number;
20
+ translateY?: number;
21
+ clip?: boolean;
22
+ }
23
+ export interface Exif {
24
+ [key: string]: string;
25
+ }
26
+ export declare type SchemaDefaults = Record<string, unknown>;
27
+ export interface Prng {
28
+ seed: string;
29
+ bool(likelihood?: number): boolean;
30
+ integer(min: number, max: number): number;
31
+ pick<T>(arr: T[]): T | undefined;
32
+ string(length: number, characters?: string): string;
33
+ }
34
+ export declare type StyleSchema = JSONSchema7;
35
+ export declare type StyleOptions<O extends {}> = Partial<O & Options>;
36
+ export interface StyleCreateProps<O extends {}> {
37
+ prng: Prng;
38
+ options: StyleOptions<O>;
39
+ }
40
+ export declare type StyleCreate<O extends {}> = (props: StyleCreateProps<O>) => StyleCreateResult;
41
+ export interface StyleCreateResultAttributes {
42
+ viewBox: string;
43
+ [key: string]: string;
44
+ }
45
+ export interface StyleCreateResult {
46
+ attributes: StyleCreateResultAttributes;
47
+ body: string;
48
+ }
49
+ export interface StyleMeta {
50
+ title?: string;
51
+ source?: string;
52
+ creator?: string;
53
+ homepage?: string;
54
+ license?: {
55
+ name: string;
56
+ url: string;
57
+ };
58
+ }
59
+ export interface Style<O extends {}> {
60
+ meta: StyleMeta;
61
+ schema: StyleSchema;
62
+ create: StyleCreate<O>;
63
+ }
package/lib/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare function xml(content: string): string;
@@ -0,0 +1,8 @@
1
+ export function xml(content) {
2
+ return content
3
+ .replace(/&/g, '&amp;')
4
+ .replace(/'/g, '&apos;')
5
+ .replace(/"/g, '&quot;')
6
+ .replace(/</g, '&lt;')
7
+ .replace(/>/g, '&gt;');
8
+ }
@@ -0,0 +1,3 @@
1
+ import { Exif, Style } from '../types';
2
+ export declare function xml(style: Style<any>): string;
3
+ export declare function exif(style: Style<any>): Exif;
@@ -0,0 +1,60 @@
1
+ import * as _ from './escape.js';
2
+ export function xml(style) {
3
+ var _a, _b, _c, _d, _e;
4
+ const title = (_a = style.meta.title) !== null && _a !== void 0 ? _a : 'Unnamed';
5
+ const creator = (_b = style.meta.creator) !== null && _b !== void 0 ? _b : 'Unknown';
6
+ let description = `"${title}" by "${creator}"`;
7
+ if ((_c = style.meta.license) === null || _c === void 0 ? void 0 : _c.name) {
8
+ description += `, licensed under "${style.meta.license.name}".`;
9
+ }
10
+ description += ' / Remix of the original. - Created with dicebear.com';
11
+ const xmlTitle = `<dc:title>${_.xml(title)}</dc:title>`;
12
+ const xmlCreator = '<dc:creator>' +
13
+ `<cc:Agent rdf:about="${_.xml((_d = style.meta.homepage) !== null && _d !== void 0 ? _d : '')}">` +
14
+ `<dc:title>${_.xml(creator)}</dc:title>` +
15
+ '</cc:Agent>' +
16
+ '</dc:creator>';
17
+ const xmlSource = style.meta.source
18
+ ? `<dc:source>${_.xml(style.meta.source)}</dc:source>`
19
+ : '';
20
+ const xmlLicense = ((_e = style.meta.license) === null || _e === void 0 ? void 0 : _e.url)
21
+ ? `<cc:license rdf:resource="${_.xml(style.meta.license.url)}" />`
22
+ : '';
23
+ return (`<desc>${description}</desc>` +
24
+ '<metadata' +
25
+ ' xmlns:dc="http://purl.org/dc/elements/1.1/"' +
26
+ ' xmlns:cc="http://creativecommons.org/ns#"' +
27
+ ' xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">' +
28
+ '<rdf:RDF>' +
29
+ '<cc:Work>' +
30
+ xmlTitle +
31
+ xmlCreator +
32
+ xmlSource +
33
+ xmlLicense +
34
+ '</cc:Work>' +
35
+ '</rdf:RDF>' +
36
+ '</metadata>');
37
+ }
38
+ export function exif(style) {
39
+ var _a, _b, _c, _d;
40
+ const title = (_a = style.meta.title) !== null && _a !== void 0 ? _a : 'Unnamed';
41
+ const creator = (_b = style.meta.creator) !== null && _b !== void 0 ? _b : 'Unknown';
42
+ let copyright = `"${title}" by "${creator}"`;
43
+ if ((_c = style.meta.license) === null || _c === void 0 ? void 0 : _c.name) {
44
+ copyright += `, licensed under "${style.meta.license.name}".`;
45
+ }
46
+ copyright += ' / Remix of the original.';
47
+ const exif = {
48
+ ImageDescription: `${copyright} - Created with dicebear.com`,
49
+ Copyright: copyright,
50
+ 'XMP-dc:Title': title,
51
+ 'XMP-dc:Creator': creator,
52
+ };
53
+ if (style.meta.source) {
54
+ exif['XMP-dc:Source'] = style.meta.source;
55
+ }
56
+ if ((_d = style.meta.license) === null || _d === void 0 ? void 0 : _d.url) {
57
+ exif['XMP-cc:License'] = style.meta.license.url;
58
+ }
59
+ return exif;
60
+ }
@@ -0,0 +1,3 @@
1
+ import type { SchemaDefaults, Style, StyleOptions, StyleSchema } from '../types.js';
2
+ export declare function defaults(schema: StyleSchema): SchemaDefaults;
3
+ export declare function merge<O extends {}>(style: Style<O>, options: StyleOptions<O>): StyleOptions<O>;
@@ -0,0 +1,34 @@
1
+ import { schema } from '../schema.js';
2
+ export function defaults(schema) {
3
+ var _a;
4
+ let result = {};
5
+ let props = (_a = schema.properties) !== null && _a !== void 0 ? _a : {};
6
+ Object.keys(props).forEach((key) => {
7
+ let val = props[key];
8
+ if (typeof val === 'object' && undefined !== val.default) {
9
+ if (Array.isArray(val.default)) {
10
+ result[key] = [...val.default];
11
+ }
12
+ else if (typeof val.default === 'object') {
13
+ result[key] = { ...val.default };
14
+ }
15
+ else {
16
+ result[key] = val.default;
17
+ }
18
+ }
19
+ });
20
+ return result;
21
+ }
22
+ export function merge(style, options) {
23
+ let result = {
24
+ ...{
25
+ seed: Math.random().toString(),
26
+ },
27
+ ...defaults(schema),
28
+ ...defaults(style.schema),
29
+ ...options,
30
+ };
31
+ // Return a complete copy because the styles could partially customize the
32
+ // options and thus modify nested objects and arrays.
33
+ return JSON.parse(JSON.stringify(result));
34
+ }
@@ -0,0 +1,2 @@
1
+ import type { Prng } from '../types.js';
2
+ export declare function create(seed?: string): Prng;
@@ -0,0 +1,42 @@
1
+ const MIN = -2147483648;
2
+ const MAX = 2147483647;
3
+ function xorshift(value) {
4
+ value ^= value << 13;
5
+ value ^= value >> 17;
6
+ value ^= value << 5;
7
+ return value;
8
+ }
9
+ function hashSeed(seed) {
10
+ let hash = 0;
11
+ for (let i = 0; i < seed.length; i++) {
12
+ hash = ((hash << 5) - hash + seed.charCodeAt(i)) | 0;
13
+ hash = xorshift(hash);
14
+ }
15
+ return hash;
16
+ }
17
+ export function create(seed = '') {
18
+ let value = hashSeed(seed) || 1;
19
+ const next = () => (value = xorshift(value));
20
+ const integer = (min, max) => {
21
+ return Math.floor(((next() - MIN) / (MAX - MIN)) * (max + 1 - min) + min);
22
+ };
23
+ return {
24
+ seed,
25
+ bool(likelihood = 50) {
26
+ return integer(0, 100) <= likelihood;
27
+ },
28
+ integer(min, max) {
29
+ return integer(min, max);
30
+ },
31
+ pick(arr) {
32
+ return arr.length > 0 ? arr[integer(0, arr.length - 1)] : undefined;
33
+ },
34
+ string(length, characters = 'abcdefghijklmnopqrstuvwxyz1234567890') {
35
+ let str = '';
36
+ for (let i = 0; i < length; i++) {
37
+ str += characters[integer(0, characters.length - 1)];
38
+ }
39
+ return str;
40
+ },
41
+ };
42
+ }
@@ -0,0 +1,15 @@
1
+ import type { StyleCreateResult } from '../types.js';
2
+ export declare function getViewBox(result: StyleCreateResult): {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ };
8
+ export declare function addBackgroundColor(result: StyleCreateResult, backgroundColor: string): string;
9
+ export declare function addScale(result: StyleCreateResult, scale: number): string;
10
+ export declare function addTranslate(result: StyleCreateResult, x?: number, y?: number): string;
11
+ export declare function addRotate(result: StyleCreateResult, rotate: number): string;
12
+ export declare function addFlip(result: StyleCreateResult): string;
13
+ export declare function addViewboxMask(result: StyleCreateResult, radius: number): string;
14
+ export declare function createAttrString(result: StyleCreateResult): string;
15
+ export declare function randomizeIds(result: StyleCreateResult, seed: string): string;
@@ -0,0 +1,69 @@
1
+ import * as escape from './escape.js';
2
+ import { create as createPrng } from './prng.js';
3
+ export function getViewBox(result) {
4
+ let viewBox = result.attributes['viewBox'].split(' ');
5
+ let x = parseInt(viewBox[0]);
6
+ let y = parseInt(viewBox[1]);
7
+ let width = parseInt(viewBox[2]);
8
+ let height = parseInt(viewBox[3]);
9
+ return {
10
+ x,
11
+ y,
12
+ width,
13
+ height,
14
+ };
15
+ }
16
+ export function addBackgroundColor(result, backgroundColor) {
17
+ let { width, height, x, y } = getViewBox(result);
18
+ return `<rect fill="#${backgroundColor}" width="${width}" height="${height}" x="${x}" y="${y}" />${result.body}`;
19
+ }
20
+ export function addScale(result, scale) {
21
+ let { width, height, x, y } = getViewBox(result);
22
+ let percent = scale ? (scale - 100) / 100 : 0;
23
+ let translateX = (width / 2 + x) * percent * -1;
24
+ let translateY = (height / 2 + y) * percent * -1;
25
+ return `<g transform="translate(${translateX} ${translateY}) scale(${scale / 100})">${result.body}</g>`;
26
+ }
27
+ export function addTranslate(result, x, y) {
28
+ let viewBox = getViewBox(result);
29
+ let translateX = (viewBox.width + viewBox.x * 2) * ((x !== null && x !== void 0 ? x : 0) / 100);
30
+ let translateY = (viewBox.height + viewBox.y * 2) * ((y !== null && y !== void 0 ? y : 0) / 100);
31
+ return `<g transform="translate(${translateX} ${translateY})">${result.body}</g>`;
32
+ }
33
+ export function addRotate(result, rotate) {
34
+ let { width, height, x, y } = getViewBox(result);
35
+ return `<g transform="rotate(${rotate}, ${width / 2 + x}, ${height / 2 + y})">${result.body}</g>`;
36
+ }
37
+ export function addFlip(result) {
38
+ let { width, x } = getViewBox(result);
39
+ return `<g transform="scale(-1 1) translate(${width * -1 - x * 2} 0)">${result.body}</g>`;
40
+ }
41
+ export function addViewboxMask(result, radius) {
42
+ let { width, height, x, y } = getViewBox(result);
43
+ let rx = radius ? (width * radius) / 100 : 0;
44
+ let ry = radius ? (height * radius) / 100 : 0;
45
+ return (`<mask id="viewboxMask">` +
46
+ `<rect width="${width}" height="${height}" rx="${rx}" ry="${ry}" x="${x}" y="${y}" fill="#fff" />` +
47
+ `</mask>` +
48
+ `<g mask="url(#viewboxMask)">${result.body}</g>`);
49
+ }
50
+ export function createAttrString(result) {
51
+ const attributes = {
52
+ xmlns: 'http://www.w3.org/2000/svg',
53
+ ...result.attributes,
54
+ };
55
+ return Object.keys(attributes)
56
+ .map((attr) => `${escape.xml(attr)}="${escape.xml(attributes[attr])}"`)
57
+ .join(' ');
58
+ }
59
+ export function randomizeIds(result, seed) {
60
+ const prng = createPrng(JSON.stringify({
61
+ attributes: result.attributes,
62
+ seed,
63
+ }));
64
+ const ids = {};
65
+ return result.body.replace(/(id="|url\(#)([a-z0-9-_]+)([")])/gi, (match, m1, m2, m3) => {
66
+ ids[m2] = ids[m2] || prng.string(8);
67
+ return `${m1}${ids[m2]}${m3}`;
68
+ });
69
+ }
package/package.json CHANGED
@@ -1,58 +1,49 @@
1
1
  {
2
2
  "name": "@dicebear/core",
3
- "version": "5.0.0-alpha.9",
3
+ "version": "5.0.0-beta.0",
4
4
  "description": "An avatar library for designers and developers.",
5
5
  "keywords": [
6
6
  "avatar",
7
7
  "identicon"
8
8
  ],
9
- "homepage": "https://github.com/dicebear/dicebear/tree/master/packages/@dicebear/core",
9
+ "homepage": "https://dicebear.com",
10
10
  "bugs": {
11
11
  "url": "https://github.com/dicebear/dicebear/issues"
12
12
  },
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "git@github.com:dicebear/dicebear.git",
16
- "directory": "/packages/@dicebear/core"
15
+ "url": "git+https://github.com/dicebear/dicebear.git"
17
16
  },
18
17
  "license": "MIT",
19
18
  "author": "Florian Körner <contact@florian-koerner.com>",
20
- "browserslist": ">.25%, not IE > 0, not dead",
21
- "source": "src/index.ts",
22
- "main": "dist/index.js",
23
- "module": "dist/index.es.js",
24
- "types": "dist/index.d.ts",
19
+ "type": "module",
20
+ "exports": "./lib/index.js",
21
+ "types": "./lib/index.d.ts",
25
22
  "files": [
26
23
  "LICENSE",
27
- "dist",
24
+ "lib",
28
25
  "README.md"
29
26
  ],
30
27
  "scripts": {
31
- "test": "jest",
28
+ "prebuild": "del-cli lib",
29
+ "build": "tsc",
32
30
  "prepublishOnly": "npm run build",
33
- "prebuild": "shx rm -rf dist",
34
- "build": "npm-run-all build:*",
35
- "build:schema": "json2ts src/schema.json src/options.ts",
36
- "build:parcel": "parcel build"
31
+ "test": "uvu tests"
37
32
  },
38
33
  "dependencies": {
39
- "@types/json-schema": "^7.0.7"
34
+ "@dicebear/converter": "^5.0.0-beta.0"
40
35
  },
41
36
  "devDependencies": {
42
- "@parcel/packager-ts": "^2.0.1",
43
- "@parcel/transformer-typescript-types": "^2.0.1",
44
- "@tsconfig/recommended": "^1.0.0",
45
- "@types/jest": "^26.0.22",
46
- "jest": "^26.6.3",
47
- "json-schema-to-typescript": "^10.1.5",
48
- "npm-run-all": "^4.1.5",
49
- "parcel": "^2.0.1",
50
- "shx": "^0.3.3",
51
- "ts-jest": "^26.5.4",
52
- "typescript": "^4.5.2"
37
+ "@tsconfig/recommended": "^1.0.1",
38
+ "del-cli": "^4.0.1",
39
+ "typescript": "^4.6.3",
40
+ "uvu": "^0.5.3"
41
+ },
42
+ "engines": {
43
+ "node": "^14.13.1 || >=16.0.0"
53
44
  },
54
45
  "publishConfig": {
55
46
  "access": "public"
56
47
  },
57
- "gitHead": "d2861228315afd1fef06969d1eaf9655a027fbbb"
48
+ "gitHead": "f939afabe6ade034e344b1983caa21de49873dda"
58
49
  }
package/dist/index.d.ts DELETED
@@ -1,73 +0,0 @@
1
- import * as JSONSchema from "json-schema";
2
- /**
3
- * This file was automatically generated by json-schema-to-typescript.
4
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
- * and run json-schema-to-typescript to regenerate this file.
6
- */
7
- interface Options {
8
- seed?: string;
9
- dataUri?: boolean;
10
- flip?: boolean;
11
- rotate?: number;
12
- scale?: number;
13
- radius?: number;
14
- size?: number;
15
- backgroundColor?: (string | string)[];
16
- translateX?: number;
17
- translateY?: number;
18
- clip?: boolean;
19
- }
20
- export interface Prng {
21
- seed: string;
22
- bool(likelihood?: number): boolean;
23
- integer(min: number, max: number): number;
24
- pick<T>(arr: T[]): T;
25
- }
26
- export type StyleSchema = JSONSchema.JSONSchema7;
27
- export type StyleOptions<O extends {}> = Partial<O & Options>;
28
- interface StyleCreateProps<O> {
29
- prng: Prng;
30
- options: StyleOptions<O>;
31
- }
32
- type StyleCreate<O extends {}> = (props: StyleCreateProps<O>) => StyleCreateResult;
33
- interface StyleCreateResultAttributes {
34
- viewBox: string;
35
- [key: string]: string;
36
- }
37
- interface StyleCreateResult {
38
- attributes: StyleCreateResultAttributes;
39
- body: string;
40
- }
41
- interface StylePreviewProps<O> {
42
- prng: Prng;
43
- options: StyleOptions<O>;
44
- property: keyof StyleOptions<O>;
45
- }
46
- type StylePreview<O extends {}> = (props: StylePreviewProps<O>) => StylePreviewResult;
47
- type StylePreviewResult = undefined | {
48
- attributes: StyleCreateResultAttributes;
49
- head?: string;
50
- body: string;
51
- };
52
- interface StyleMeta {
53
- title?: string;
54
- creator?: string | string[];
55
- source?: string;
56
- license?: {
57
- name: string;
58
- url: string;
59
- };
60
- contributor?: string | string[];
61
- }
62
- export interface Style<O extends {}> {
63
- meta: StyleMeta;
64
- schema: StyleSchema;
65
- create: StyleCreate<O>;
66
- preview?: StylePreview<O>;
67
- }
68
- export function createPrng(seed?: string): Prng;
69
- export function createAvatar<O extends {}>(style: Style<O>, options?: StyleOptions<O>): string;
70
- export function createPreview<O extends {}>(style: Style<O>, options: StyleOptions<O>, property: keyof StyleOptions<O>): string | undefined;
71
- export const schema: JSONSchema.JSONSchema7;
72
-
73
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"mappings":"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","sources":["packages/@dicebear/core/src/src/options.ts","packages/@dicebear/core/src/src/types.ts","packages/@dicebear/core/src/src/utils/escape.ts","packages/@dicebear/core/src/src/utils/svg.ts","packages/@dicebear/core/src/src/utils/schema.ts","packages/@dicebear/core/src/src/utils/options.ts","packages/@dicebear/core/src/src/utils/prng.ts","packages/@dicebear/core/src/src/core.ts","packages/@dicebear/core/src/src/index.ts","packages/@dicebear/core/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,"/*!\n * DiceBear (@dicebear/core)\n *\n * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/main/LICENSE)\n * Copyright (c) 2021 Florian Körner\n */\n\n// parcel bug workaround\nimport type * as JSONSchema from 'json-schema';\n// import type { JSONSchema7 } from 'json-schema';\nimport untypedSchema from './schema.json';\n\nconst schema = untypedSchema as JSONSchema.JSONSchema7;\n\nexport { schema };\nexport { createAvatar, createPreview } from './core';\nexport { create as createPrng } from './utils/prng';\nexport type { Prng, Style, StyleOptions, StyleSchema } from './types';\n"],"names":[],"version":3,"file":"index.d.ts.map"}