@dicebear/initials 5.0.0-alpha.0 → 5.0.0-alpha.12

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/lib/core.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { Style } from '@dicebear/core';
2
+ import type { Options } from './types.js';
3
+ export declare const style: Style<Options>;
package/lib/core.js ADDED
@@ -0,0 +1,55 @@
1
+ import { schema } from './schema.js';
2
+ import initials from 'initials';
3
+ const colors = {
4
+ amber: 'rgba(255, 179, 0, 1)',
5
+ blue: 'rgba(30, 136, 229, 1)',
6
+ blueGrey: 'rgba(84, 110, 122, 1)',
7
+ brown: 'rgba(109, 76, 65, 1)',
8
+ cyan: 'rgba(0, 172, 193, 1)',
9
+ deepOrange: 'rgba(244, 81, 30, 1)',
10
+ deepPurple: 'rgba(94, 53, 177, 1)',
11
+ green: 'rgba(67, 160, 71, 1)',
12
+ grey: 'rgba(117, 117, 117, 1)',
13
+ indigo: 'rgba(57, 73, 171, 1)',
14
+ lightBlue: 'rgba(3, 155, 229, 1)',
15
+ lightGreen: 'rgba(124, 179, 66, 1)',
16
+ lime: 'rgba(192, 202, 51, 1)',
17
+ orange: 'rgba(251, 140, 0, 1)',
18
+ pink: 'rgba(216, 27, 96, 1)',
19
+ purple: 'rgba(142, 36, 170, 1)',
20
+ red: 'rgba(229, 57, 53, 1)',
21
+ teal: 'rgba(0, 137, 123, 1)',
22
+ yellow: 'rgba(253, 216, 53, 1)',
23
+ };
24
+ export const style = {
25
+ meta: {
26
+ title: 'Initials',
27
+ creator: 'Florian Körner',
28
+ source: 'https://github.com/dicebear/dicebear',
29
+ license: {
30
+ name: 'CC0 1.0',
31
+ url: 'https://creativecommons.org/publicdomain/zero/1.0/',
32
+ },
33
+ },
34
+ schema: schema,
35
+ create: ({ prng, options }) => {
36
+ var _a, _b, _c, _d, _e, _f;
37
+ options.backgroundColor = (_a = options.backgroundColor) === null || _a === void 0 ? void 0 : _a.map((val) => { var _a; return (_a = colors[val]) !== null && _a !== void 0 ? _a : val; });
38
+ const fontFamily = (_c = (_b = options.fontFamily) === null || _b === void 0 ? void 0 : _b.join(', ')) !== null && _c !== void 0 ? _c : 'Arial, sans-serif';
39
+ const fontSize = (_d = options.fontSize) !== null && _d !== void 0 ? _d : 50;
40
+ const fontWeight = (_e = options.fontWeight) !== null && _e !== void 0 ? _e : 400;
41
+ const seedInitials = initials(prng.seed.trim())
42
+ .toLocaleUpperCase()
43
+ .slice(0, (_f = options.chars) !== null && _f !== void 0 ? _f : 2);
44
+ // prettier-ignore
45
+ const svg = [
46
+ `<text x="50%" y="50%" font-family="${fontFamily}" font-size="${fontSize}" fontWeight="${fontWeight}" fill="#FFF" text-anchor="middle" dy="${(fontSize * .356).toFixed(3)}">${seedInitials}</text>`,
47
+ ].join('');
48
+ return {
49
+ attributes: {
50
+ viewBox: '0 0 100 100',
51
+ },
52
+ body: svg,
53
+ };
54
+ },
55
+ };
@@ -1,9 +1,9 @@
1
- /*!
2
- * DiceBear Initials (@dicebear/initials)
3
- *
4
- * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
5
- * Copyright (c) 2021 Florian Körner
6
- */
7
- declare let create: import("@dicebear/core").StyleCreate<import("./options").Options>, meta: import("@dicebear/core").StyleMeta, schema: import("json-schema").JSONSchema7;
8
- export { create, meta, schema };
9
- export { Options } from './options';
1
+ /*!
2
+ * DiceBear Initials (@dicebear/initials)
3
+ *
4
+ * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
5
+ * Copyright (c) 2021 Florian Körner
6
+ */
7
+ declare let create: import("@dicebear/core").StyleCreate<import("./types.js").Options>, meta: import("@dicebear/core").StyleMeta, schema: import("json-schema").JSONSchema7;
8
+ export { create, meta, schema };
9
+ export * from './types.js';
package/lib/index.js ADDED
@@ -0,0 +1,10 @@
1
+ /*!
2
+ * DiceBear Initials (@dicebear/initials)
3
+ *
4
+ * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
5
+ * Copyright (c) 2021 Florian Körner
6
+ */
7
+ import { style } from './core.js';
8
+ let { create, meta, schema } = style;
9
+ export { create, meta, schema };
10
+ export * from './types.js';
@@ -0,0 +1,2 @@
1
+ import type { StyleSchema } from '@dicebear/core';
2
+ export declare const schema: StyleSchema;
package/lib/schema.js ADDED
@@ -0,0 +1,100 @@
1
+ export const schema = {
2
+ title: 'Options',
3
+ $schema: 'http://json-schema.org/draft-07/schema#',
4
+ properties: {
5
+ backgroundColor: {
6
+ type: 'array',
7
+ items: {
8
+ type: 'string',
9
+ pattern: '^([0-9a-zA-Z]+|#[a-fA-F0-9]{3}|#[a-fA-F0-9]{4}|#[a-fA-F0-9]{6}|#[a-fA-F0-9]{8})$',
10
+ },
11
+ default: [
12
+ 'amber',
13
+ 'blue',
14
+ 'blueGrey',
15
+ 'brown',
16
+ 'cyan',
17
+ 'deepOrange',
18
+ 'deepPurple',
19
+ 'green',
20
+ 'grey',
21
+ 'indigo',
22
+ 'lightBlue',
23
+ 'lightGreen',
24
+ 'lime',
25
+ 'orange',
26
+ 'pink',
27
+ 'purple',
28
+ 'red',
29
+ 'teal',
30
+ 'yellow',
31
+ ],
32
+ examples: [
33
+ ['amber'],
34
+ ['blue'],
35
+ ['blueGrey'],
36
+ ['brown'],
37
+ ['cyan'],
38
+ ['deepOrange'],
39
+ ['deepPurple'],
40
+ ['green'],
41
+ ['grey'],
42
+ ['indigo'],
43
+ ['lightBlue'],
44
+ ['lightGreen'],
45
+ ['lime'],
46
+ ['orange'],
47
+ ['pink'],
48
+ ['purple'],
49
+ ['red'],
50
+ ['teal'],
51
+ ['yellow'],
52
+ ],
53
+ },
54
+ fontFamily: {
55
+ type: 'array',
56
+ uniqueItems: true,
57
+ minItems: 1,
58
+ items: {
59
+ type: 'string',
60
+ pattern: '^[a-zA-Z0-9\\-\\s]+$',
61
+ },
62
+ default: ['Arial', 'sans-serif'],
63
+ examples: [
64
+ ['Arial'],
65
+ ['Verdana'],
66
+ ['Helvetica'],
67
+ ['Tahoma'],
68
+ ['Trebuchet MS'],
69
+ ['Times New Roman'],
70
+ ['Georgia'],
71
+ ['Garamond'],
72
+ ['Courier New'],
73
+ ['Brush Script MT'],
74
+ ['sans-serif'],
75
+ ['serif'],
76
+ ],
77
+ },
78
+ fontSize: {
79
+ type: 'integer',
80
+ minimum: 1,
81
+ maximum: 100,
82
+ default: 50,
83
+ examples: [25, 50, 75, 100],
84
+ },
85
+ chars: {
86
+ type: 'number',
87
+ minimum: 0,
88
+ maximum: 2,
89
+ default: 2,
90
+ examples: [1, 2],
91
+ },
92
+ fontWeight: {
93
+ type: 'number',
94
+ default: 400,
95
+ enum: [100, 200, 300, 400, 500, 600, 700, 800, 900],
96
+ examples: [100, 200, 300, 400, 500, 600, 700, 800, 900],
97
+ },
98
+ },
99
+ additionalProperties: false,
100
+ };
package/lib/types.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export interface Options {
2
+ backgroundColor?: string[];
3
+ fontFamily?: string[];
4
+ fontSize?: number;
5
+ chars?: number;
6
+ fontWeight?: number;
7
+ }
package/lib/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,61 +1,51 @@
1
1
  {
2
2
  "name": "@dicebear/initials",
3
- "version": "5.0.0-alpha.0",
3
+ "version": "5.0.0-alpha.12",
4
4
  "description": "Initials avatar style for DiceBear",
5
5
  "keywords": [
6
- "dicebear",
7
- "avatar",
8
- "identicon",
9
- "svg",
10
- "sprites",
11
- "initials"
6
+ "dicebear"
12
7
  ],
13
- "homepage": "https://github.com/dicebear/dicebear/tree/master/packages/@dicebear/initials",
14
8
  "bugs": {
15
9
  "url": "https://github.com/dicebear/dicebear/issues"
16
10
  },
17
11
  "repository": {
18
12
  "type": "git",
19
- "url": "git@github.com:dicebear/dicebear.git",
20
- "directory": "/packages/@dicebear/initials"
13
+ "url": "git+https://github.com/dicebear/dicebear.git"
21
14
  },
22
15
  "license": "MIT",
23
- "author": "Florian Körner <contact@florian-koerner.com>",
24
- "source": "src/index.ts",
25
- "main": "dist/index.js",
26
- "module": "dist/index.es.js",
27
- "browser": "dist/index.umd.js",
28
- "types": "dist/index.d.ts",
16
+ "type": "module",
17
+ "exports": "./lib/index.js",
18
+ "types": "./lib/index.d.ts",
29
19
  "files": [
30
20
  "LICENSE",
31
- "README.md",
32
- "dist"
21
+ "lib",
22
+ "README.md"
33
23
  ],
34
24
  "scripts": {
35
- "test": "jest",
25
+ "prebuild": "del-cli lib",
26
+ "build": "tsc",
36
27
  "prepublishOnly": "npm run build",
37
- "prebuild": "shx rm -rf dist",
38
- "build": "dicebear-project build DiceBear.Initials"
28
+ "test": "uvu tests"
39
29
  },
40
30
  "dependencies": {
41
31
  "initials": "^3.0.1"
42
32
  },
43
33
  "devDependencies": {
44
- "@dicebear/core": "^5.0.0-alpha.0",
34
+ "@dicebear/core": "^5.0.0-alpha.12",
45
35
  "@tsconfig/recommended": "^1.0.0",
46
36
  "@types/jest": "^26.0.22",
47
- "@types/node": "^10.11.6",
48
- "dicebear-project": "^5.0.0-alpha.0",
49
- "jest": "^26.6.3",
50
- "shx": "^0.3.3",
51
- "ts-jest": "^26.5.4",
52
- "typescript": "^4.2.3"
37
+ "del-cli": "^4.0.1",
38
+ "typescript": "^4.5.2",
39
+ "uvu": "^0.5.2"
53
40
  },
54
41
  "peerDependencies": {
55
- "@dicebear/core": "^4.6.0"
42
+ "@dicebear/core": "^5.0.0-alpha.6"
43
+ },
44
+ "engines": {
45
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
56
46
  },
57
47
  "publishConfig": {
58
48
  "access": "public"
59
49
  },
60
- "gitHead": "842f2a824d473dc87a637100f3375cc94db2787d"
50
+ "gitHead": "baa9eec32902faa13b4727237a99dbdba1f382c8"
61
51
  }
package/dist/core.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { Style } from '@dicebear/core';
2
- import { Options } from './options';
3
- export declare const style: Style<Options>;
package/dist/index.es.js DELETED
@@ -1,141 +0,0 @@
1
- import { utils } from '@dicebear/core';
2
- import initials from 'initials';
3
-
4
- var title = "Options";
5
- var $schema = "http://json-schema.org/draft-07/schema#";
6
- var properties = {
7
- backgroundColor: {
8
- title: "Background Color",
9
- type: "array",
10
- items: {
11
- anyOf: [
12
- {
13
- type: "string",
14
- pattern: "^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$"
15
- },
16
- {
17
- type: "string",
18
- pattern: "^[0-9a-zA-Z]+$"
19
- }
20
- ]
21
- },
22
- "default": [
23
- "amber",
24
- "blue",
25
- "blueGrey",
26
- "brown",
27
- "cyan",
28
- "deepOrange",
29
- "deepPurple",
30
- "green",
31
- "grey",
32
- "indigo",
33
- "lightBlue",
34
- "lightGreen",
35
- "lime",
36
- "orange",
37
- "pink",
38
- "purple",
39
- "red",
40
- "teal",
41
- "yellow"
42
- ]
43
- },
44
- fontSize: {
45
- title: "Font Size",
46
- type: "integer",
47
- minimum: 1,
48
- maximum: 100,
49
- "default": 50
50
- },
51
- chars: {
52
- title: "Chars",
53
- type: "number",
54
- minimum: 0,
55
- maximum: 2,
56
- "default": 2
57
- },
58
- bold: {
59
- title: "Bold",
60
- type: "boolean"
61
- }
62
- };
63
- var additionalProperties = false;
64
- var schema$1 = {
65
- title: title,
66
- $schema: $schema,
67
- properties: properties,
68
- additionalProperties: additionalProperties
69
- };
70
-
71
- const colors = {
72
- amber: 'rgba(255, 179, 0, 1)',
73
- blue: 'rgba(30, 136, 229, 1)',
74
- blueGrey: 'rgba(84, 110, 122, 1)',
75
- brown: 'rgba(109, 76, 65, 1)',
76
- cyan: 'rgba(0, 172, 193, 1)',
77
- deepOrange: 'rgba(244, 81, 30, 1)',
78
- deepPurple: 'rgba(94, 53, 177, 1)',
79
- green: 'rgba(67, 160, 71, 1)',
80
- grey: 'rgba(117, 117, 117, 1)',
81
- indigo: 'rgba(57, 73, 171, 1)',
82
- lightBlue: 'rgba(3, 155, 229, 1)',
83
- lightGreen: 'rgba(124, 179, 66, 1)',
84
- lime: 'rgba(192, 202, 51, 1)',
85
- orange: 'rgba(251, 140, 0, 1)',
86
- pink: 'rgba(216, 27, 96, 1)',
87
- purple: 'rgba(142, 36, 170, 1)',
88
- red: 'rgba(229, 57, 53, 1)',
89
- teal: 'rgba(0, 137, 123, 1)',
90
- yellow: 'rgba(253, 216, 53, 1)'
91
- };
92
- const style = {
93
- meta: {
94
- title: 'Initials',
95
- creator: 'Florian Körner',
96
- source: 'https://github.com/dicebear/dicebear',
97
- license: {
98
- name: 'CC0 1.0',
99
- url: 'https://creativecommons.org/publicdomain/zero/1.0/'
100
- }
101
- },
102
- schema: schema$1,
103
- create: ({
104
- prng,
105
- options
106
- }) => {
107
- var _options$backgroundCo, _options$fontSize, _options$chars;
108
-
109
- let defaults = utils.schema.defaults(schema$1);
110
- options.backgroundColor = (_options$backgroundCo = options.backgroundColor) === null || _options$backgroundCo === void 0 ? void 0 : _options$backgroundCo.map(val => {
111
- var _colors$val;
112
-
113
- return (_colors$val = colors[val]) !== null && _colors$val !== void 0 ? _colors$val : val;
114
- });
115
- let fontFamily = 'Arial,sans-serif';
116
- let fontSize = ((_options$fontSize = options.fontSize) !== null && _options$fontSize !== void 0 ? _options$fontSize : defaults.fontSize) / 100;
117
- let seedInitials = initials(prng.seed.trim()).toLocaleUpperCase().slice(0, (_options$chars = options.chars) !== null && _options$chars !== void 0 ? _options$chars : defaults.chars); // prettier-ignore
118
-
119
- let svg = ["<text x=\"50%\" y=\"50%\" style=\"".concat(options.bold ? 'font-weight: bold;' : '', " font-family: ").concat(fontFamily, "; font-size: ").concat(fontSize, "px\" fill=\"#FFF\" text-anchor=\"middle\" dy=\"").concat((fontSize * .356).toFixed(3), "\">").concat(seedInitials, "</text>")].join('');
120
- return {
121
- attributes: {
122
- viewBox: '0 0 1 1'
123
- },
124
- body: svg
125
- };
126
- }
127
- };
128
-
129
- /*!
130
- * DiceBear Initials (@dicebear/initials)
131
- *
132
- * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
133
- * Copyright (c) 2021 Florian Körner
134
- */
135
- let {
136
- create,
137
- meta,
138
- schema
139
- } = style;
140
-
141
- export { create, meta, schema };
package/dist/index.js DELETED
@@ -1,151 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var core = require('@dicebear/core');
6
- var initials = require('initials');
7
-
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
-
10
- var initials__default = /*#__PURE__*/_interopDefaultLegacy(initials);
11
-
12
- var title = "Options";
13
- var $schema = "http://json-schema.org/draft-07/schema#";
14
- var properties = {
15
- backgroundColor: {
16
- title: "Background Color",
17
- type: "array",
18
- items: {
19
- anyOf: [
20
- {
21
- type: "string",
22
- pattern: "^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$"
23
- },
24
- {
25
- type: "string",
26
- pattern: "^[0-9a-zA-Z]+$"
27
- }
28
- ]
29
- },
30
- "default": [
31
- "amber",
32
- "blue",
33
- "blueGrey",
34
- "brown",
35
- "cyan",
36
- "deepOrange",
37
- "deepPurple",
38
- "green",
39
- "grey",
40
- "indigo",
41
- "lightBlue",
42
- "lightGreen",
43
- "lime",
44
- "orange",
45
- "pink",
46
- "purple",
47
- "red",
48
- "teal",
49
- "yellow"
50
- ]
51
- },
52
- fontSize: {
53
- title: "Font Size",
54
- type: "integer",
55
- minimum: 1,
56
- maximum: 100,
57
- "default": 50
58
- },
59
- chars: {
60
- title: "Chars",
61
- type: "number",
62
- minimum: 0,
63
- maximum: 2,
64
- "default": 2
65
- },
66
- bold: {
67
- title: "Bold",
68
- type: "boolean"
69
- }
70
- };
71
- var additionalProperties = false;
72
- var schema$1 = {
73
- title: title,
74
- $schema: $schema,
75
- properties: properties,
76
- additionalProperties: additionalProperties
77
- };
78
-
79
- const colors = {
80
- amber: 'rgba(255, 179, 0, 1)',
81
- blue: 'rgba(30, 136, 229, 1)',
82
- blueGrey: 'rgba(84, 110, 122, 1)',
83
- brown: 'rgba(109, 76, 65, 1)',
84
- cyan: 'rgba(0, 172, 193, 1)',
85
- deepOrange: 'rgba(244, 81, 30, 1)',
86
- deepPurple: 'rgba(94, 53, 177, 1)',
87
- green: 'rgba(67, 160, 71, 1)',
88
- grey: 'rgba(117, 117, 117, 1)',
89
- indigo: 'rgba(57, 73, 171, 1)',
90
- lightBlue: 'rgba(3, 155, 229, 1)',
91
- lightGreen: 'rgba(124, 179, 66, 1)',
92
- lime: 'rgba(192, 202, 51, 1)',
93
- orange: 'rgba(251, 140, 0, 1)',
94
- pink: 'rgba(216, 27, 96, 1)',
95
- purple: 'rgba(142, 36, 170, 1)',
96
- red: 'rgba(229, 57, 53, 1)',
97
- teal: 'rgba(0, 137, 123, 1)',
98
- yellow: 'rgba(253, 216, 53, 1)'
99
- };
100
- const style = {
101
- meta: {
102
- title: 'Initials',
103
- creator: 'Florian Körner',
104
- source: 'https://github.com/dicebear/dicebear',
105
- license: {
106
- name: 'CC0 1.0',
107
- url: 'https://creativecommons.org/publicdomain/zero/1.0/'
108
- }
109
- },
110
- schema: schema$1,
111
- create: ({
112
- prng,
113
- options
114
- }) => {
115
- var _options$backgroundCo, _options$fontSize, _options$chars;
116
-
117
- let defaults = core.utils.schema.defaults(schema$1);
118
- options.backgroundColor = (_options$backgroundCo = options.backgroundColor) === null || _options$backgroundCo === void 0 ? void 0 : _options$backgroundCo.map(val => {
119
- var _colors$val;
120
-
121
- return (_colors$val = colors[val]) !== null && _colors$val !== void 0 ? _colors$val : val;
122
- });
123
- let fontFamily = 'Arial,sans-serif';
124
- let fontSize = ((_options$fontSize = options.fontSize) !== null && _options$fontSize !== void 0 ? _options$fontSize : defaults.fontSize) / 100;
125
- let seedInitials = initials__default["default"](prng.seed.trim()).toLocaleUpperCase().slice(0, (_options$chars = options.chars) !== null && _options$chars !== void 0 ? _options$chars : defaults.chars); // prettier-ignore
126
-
127
- let svg = ["<text x=\"50%\" y=\"50%\" style=\"".concat(options.bold ? 'font-weight: bold;' : '', " font-family: ").concat(fontFamily, "; font-size: ").concat(fontSize, "px\" fill=\"#FFF\" text-anchor=\"middle\" dy=\"").concat((fontSize * .356).toFixed(3), "\">").concat(seedInitials, "</text>")].join('');
128
- return {
129
- attributes: {
130
- viewBox: '0 0 1 1'
131
- },
132
- body: svg
133
- };
134
- }
135
- };
136
-
137
- /*!
138
- * DiceBear Initials (@dicebear/initials)
139
- *
140
- * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
141
- * Copyright (c) 2021 Florian Körner
142
- */
143
- let {
144
- create,
145
- meta,
146
- schema
147
- } = style;
148
-
149
- exports.create = create;
150
- exports.meta = meta;
151
- exports.schema = schema;
package/dist/index.umd.js DELETED
@@ -1,8 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@dicebear/core")):"function"==typeof define&&define.amd?define(["exports","@dicebear/core"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).DiceBear=e.DiceBear||{},e.DiceBear.Initials={}),e.DiceBear)}(this,(function(e,t){"use strict";var n={title:"Options",$schema:"http://json-schema.org/draft-07/schema#",properties:{backgroundColor:{title:"Background Color",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]+$"}]},default:["amber","blue","blueGrey","brown","cyan","deepOrange","deepPurple","green","grey","indigo","lightBlue","lightGreen","lime","orange","pink","purple","red","teal","yellow"]},fontSize:{title:"Font Size",type:"integer",minimum:1,maximum:100,default:50},chars:{title:"Chars",type:"number",minimum:0,maximum:2,default:2},bold:{title:"Bold",type:"boolean"}},additionalProperties:!1},r=s;s.addTo=function(e,t){return e?"string"==typeof e?function(e,t){return b(h(e,t))}(e,C(t)):function(e,t){return d(e,t).map(b)}(e,C(t)):""},s.parse=function(e,t){return e?"string"==typeof e?h(e,C(t)):d(e,C(t)):{}},s.find=s;var i=" -\\/:-@\\[-`\\{-\\~",a=/^[A-Z]+$/,l=/\(([^)]+)\)/,o=/^[^\s]+@[^\s]+$/,u=/@[^\s]+/,c=/[\w._-]+@[\w.-]+[\w]/g,f=new RegExp("(^|["+i+"])[^"+i+"]","g"),g=new RegExp("["+i+"]","g");function s(e,t){return e?"string"==typeof e?p(e,C(t)):m(e,C(t)):""}function p(e,t){var n,r,i,a=t.length||2;if(i=v(e,t))return i;if(!(e=y(e)))return"";if((n=e.match(f).map((function(e){return e[e.length-1]}))).length<2)return e.length>a?e.substr(0,a):e;if((r=n.join("")).length>=a)return r;for(var l=w(e),o=0;o<l.length;o++)if(l[o].length>=a)return l[o]}function m(e,t){var n,r,i,a=[],l={},o={},u={},c=t.length||2;e.forEach((function(e){if(e||(e=""),!u[e])if(e.length<c)u[e]=[e];else{if(r=v(e,t))return l[r]=1,void(u[e]=[r]);i=w(e).filter((function(e){return e.length===c&&(l[e]&&(o[e]=1),l[e]=1,!0)})),u[e]=i}}));var f=[];for(var g in u)f.unshift(g);for(var s=f.length,p=0;p<s;p++){i=u[f[p]],a.push(i);for(var h=0;h<i.length;h++)o[i[h]]>0&&(o[i[h]]--,i.splice(h,1))}return n=a.map((function(e){return e.length})),0===n.length?e:0===Math.min.apply(null,n)?(t.length++,m(e,t)):e.map((function(e){return u[e][0]}))}function h(e,t){var n,r,i,o={};return e?((n=v(e,t))&&(e=(e=e.replace(a,"")).replace(l,"")),t.initials&&(n=t.initials),n||(n=p(e,t)),null!=(i=e.match(c))&&(r=i.pop()),r&&(e=e.replace(r,"")).trim()==="<"+r+">"&&(e="",n||(n=p(r,t))),(e=e.replace(g," ").trim())&&(o.name=e),n&&(o.initials=n),r&&(o.email=r),o):{}}function d(e,t){var n=m(e,t);return e.map((function(e,r){return t.existing[e]=n[r],h(e,t)}))}function b(e){return e.name||e.email?e.email?e.name?e.name+" ("+e.initials+") <"+e.email+">":e.email+" ("+e.initials+")":e.name+" ("+e.initials+")":e.initials}function y(e){return e=(e=o.test(e)?e.replace(u,""):e.replace(c,"")).replace(g," ").trim()}function v(e,t){var n;return t.existing[e]?t.existing[e]:a.test(e)?e:null!=(n=e.match(l))?n.pop():void 0}var x={};function w(e){var t,n=[];return e=y(e),x[e]?x[e].slice(0):(t=e.split(" ").map(B),n=(n=F(t)).sort((function(e,t){return e.length-t.length||n.indexOf(e)-n.indexOf(t)})),x[e]=n,n.slice(0))}function F(e){var t,n,r=e.shift();return e.length>0?(n=[],t=F(e),r.forEach((function(e){t.forEach((function(t){n.push(e+t)}))})),n):r}function B(e){for(var t=[];e.length;)t.unshift(e),e=e.substr(0,e.length-1);return t}function C(e){return e||(e={length:2}),"number"==typeof e&&(e={length:e}),e.length=Math.max(e.length||0,2),e.existing=e.existing||{},e}var z=r;const A={amber:"rgba(255, 179, 0, 1)",blue:"rgba(30, 136, 229, 1)",blueGrey:"rgba(84, 110, 122, 1)",brown:"rgba(109, 76, 65, 1)",cyan:"rgba(0, 172, 193, 1)",deepOrange:"rgba(244, 81, 30, 1)",deepPurple:"rgba(94, 53, 177, 1)",green:"rgba(67, 160, 71, 1)",grey:"rgba(117, 117, 117, 1)",indigo:"rgba(57, 73, 171, 1)",lightBlue:"rgba(3, 155, 229, 1)",lightGreen:"rgba(124, 179, 66, 1)",lime:"rgba(192, 202, 51, 1)",orange:"rgba(251, 140, 0, 1)",pink:"rgba(216, 27, 96, 1)",purple:"rgba(142, 36, 170, 1)",red:"rgba(229, 57, 53, 1)",teal:"rgba(0, 137, 123, 1)",yellow:"rgba(253, 216, 53, 1)"},O={meta:{title:"Initials",creator:"Florian Körner",source:"https://github.com/dicebear/dicebear",license:{name:"CC0 1.0",url:"https://creativecommons.org/publicdomain/zero/1.0/"}},schema:n,create:({prng:e,options:r})=>{var i,a,l;let o=t.utils.schema.defaults(n);r.backgroundColor=null===(i=r.backgroundColor)||void 0===i?void 0:i.map((e=>{var t;return null!==(t=A[e])&&void 0!==t?t:e}));let u=(null!==(a=r.fontSize)&&void 0!==a?a:o.fontSize)/100,c=z(e.seed.trim()).toLocaleUpperCase().slice(0,null!==(l=r.chars)&&void 0!==l?l:o.chars);return{attributes:{viewBox:"0 0 1 1"},body:['<text x="50%" y="50%" style="'.concat(r.bold?"font-weight: bold;":""," font-family: ").concat("Arial,sans-serif","; font-size: ").concat(u,'px" fill="#FFF" text-anchor="middle" dy="').concat((.356*u).toFixed(3),'">').concat(c,"</text>")].join("")}}};
2
- /*!
3
- * DiceBear Initials (@dicebear/initials)
4
- *
5
- * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
6
- * Copyright (c) 2021 Florian Körner
7
- */
8
- let{create:k,meta:j,schema:E}=O;e.create=k,e.meta=j,e.schema=E,Object.defineProperty(e,"__esModule",{value:!0})}));
package/dist/options.d.ts DELETED
@@ -1,15 +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 declare type BackgroundColor = (string | string)[];
7
- export declare type FontSize = number;
8
- export declare type Chars = number;
9
- export declare type Bold = boolean;
10
- export interface Options {
11
- backgroundColor?: BackgroundColor;
12
- fontSize?: FontSize;
13
- chars?: Chars;
14
- bold?: Bold;
15
- }