@dicebear/initials 5.0.0-alpha.5 → 5.0.0-alpha.9

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.d.ts CHANGED
@@ -1,9 +1,18 @@
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
+ * 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
+ type BackgroundColor = (string | string)[];
7
+ type FontSize = number;
8
+ type Chars = number;
9
+ type Bold = boolean;
10
+ export interface Options {
11
+ backgroundColor?: BackgroundColor;
12
+ fontSize?: FontSize;
13
+ chars?: Chars;
14
+ bold?: Bold;
15
+ }
16
+ export let create: import("@dicebear/core").StyleCreate<import("options").Options>, meta: import("@dicebear/core").StyleMeta, schema: import("json-schema").JSONSchema7;
17
+
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"mappings":"AACA;;;;GAIG;AAEH,uBAA8B,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;AAClD,gBAAuB,MAAM,CAAC;AAC9B,aAAoB,MAAM,CAAC;AAC3B,YAAmB,OAAO,CAAC;AAE3B;IACE,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,IAAI,CAAC;CACb;AERD,OAAA,gKAAoC,CAAC","sources":["packages/@dicebear/initials/src/src/options.ts","packages/@dicebear/initials/src/src/core.ts","packages/@dicebear/initials/src/src/index.ts","packages/@dicebear/initials/src/index.ts"],"sourcesContent":[null,null,null,"/*!\n * DiceBear Initials (@dicebear/initials)\n *\n * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)\n * Copyright (c) 2021 Florian Körner\n */\n\nimport { style } from './core';\n\nlet { create, meta, schema } = style;\n\nexport { create, meta, schema };\nexport type { Options } from './options';\n"],"names":[],"version":3,"file":"index.d.ts.map"}
package/dist/index.es.js CHANGED
@@ -1,142 +1,71 @@
1
- import { utils } from '@dicebear/core';
2
- import initials from 'initials';
1
+ import $aK7WB$initials from "initials";
2
+
3
+ function $parcel$interopDefault(a) {
4
+ return a && a.__esModule ? a.default : a;
5
+ }
6
+ var $ca0dc25fd789c183$exports = {};
7
+ $ca0dc25fd789c183$exports = JSON.parse("{\"title\":\"Options\",\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"properties\":{\"backgroundColor\":{\"title\":\"Background Color\",\"type\":\"array\",\"uniqueItems\":true,\"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\":false}");
8
+
3
9
 
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
10
 
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)'
11
+ const $58963e1ca1f7f945$var$colors = {
12
+ amber: 'rgba(255, 179, 0, 1)',
13
+ blue: 'rgba(30, 136, 229, 1)',
14
+ blueGrey: 'rgba(84, 110, 122, 1)',
15
+ brown: 'rgba(109, 76, 65, 1)',
16
+ cyan: 'rgba(0, 172, 193, 1)',
17
+ deepOrange: 'rgba(244, 81, 30, 1)',
18
+ deepPurple: 'rgba(94, 53, 177, 1)',
19
+ green: 'rgba(67, 160, 71, 1)',
20
+ grey: 'rgba(117, 117, 117, 1)',
21
+ indigo: 'rgba(57, 73, 171, 1)',
22
+ lightBlue: 'rgba(3, 155, 229, 1)',
23
+ lightGreen: 'rgba(124, 179, 66, 1)',
24
+ lime: 'rgba(192, 202, 51, 1)',
25
+ orange: 'rgba(251, 140, 0, 1)',
26
+ pink: 'rgba(216, 27, 96, 1)',
27
+ purple: 'rgba(142, 36, 170, 1)',
28
+ red: 'rgba(229, 57, 53, 1)',
29
+ teal: 'rgba(0, 137, 123, 1)',
30
+ yellow: 'rgba(253, 216, 53, 1)'
91
31
  };
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/'
32
+ const $58963e1ca1f7f945$export$1d567c320f4763bc = {
33
+ meta: {
34
+ title: 'Initials',
35
+ creator: 'Florian Körner',
36
+ source: 'https://github.com/dicebear/dicebear',
37
+ license: {
38
+ name: 'CC0 1.0',
39
+ url: 'https://creativecommons.org/publicdomain/zero/1.0/'
40
+ }
41
+ },
42
+ schema: (/*@__PURE__*/$parcel$interopDefault($ca0dc25fd789c183$exports)),
43
+ create: ({ prng: prng , options: options })=>{
44
+ var ref;
45
+ var _val;
46
+ options.backgroundColor = (ref = options.backgroundColor) === null || ref === void 0 ? void 0 : ref.map((val)=>(_val = $58963e1ca1f7f945$var$colors[val]) !== null && _val !== void 0 ? _val : val
47
+ );
48
+ let fontFamily = 'Arial,sans-serif';
49
+ var _fontSize;
50
+ let fontSize = ((_fontSize = options.fontSize) !== null && _fontSize !== void 0 ? _fontSize : 50) / 100;
51
+ var _chars;
52
+ let seedInitials = $aK7WB$initials(prng.seed.trim()).toLocaleUpperCase().slice(0, (_chars = options.chars) !== null && _chars !== void 0 ? _chars : 2);
53
+ // prettier-ignore
54
+ let svg = [
55
+ `<text x="50%" y="50%" style="${options.bold ? 'font-weight: bold;' : ''} font-family: ${fontFamily}; font-size: ${fontSize}px" fill="#FFF" text-anchor="middle" dy="${(fontSize * 0.356).toFixed(3)}">${seedInitials}</text>`,
56
+ ].join('');
57
+ return {
58
+ attributes: {
59
+ viewBox: '0 0 1 1'
60
+ },
61
+ body: svg
62
+ };
100
63
  }
101
- },
102
- schema: schema$1,
103
- create: _ref => {
104
- var _options$backgroundCo, _options$fontSize, _options$chars;
105
-
106
- let {
107
- prng,
108
- options
109
- } = _ref;
110
- let defaults = utils.schema.defaults(schema$1);
111
- options.backgroundColor = (_options$backgroundCo = options.backgroundColor) === null || _options$backgroundCo === void 0 ? void 0 : _options$backgroundCo.map(val => {
112
- var _colors$val;
64
+ };
113
65
 
114
- return (_colors$val = colors[val]) !== null && _colors$val !== void 0 ? _colors$val : val;
115
- });
116
- let fontFamily = 'Arial,sans-serif';
117
- let fontSize = ((_options$fontSize = options.fontSize) !== null && _options$fontSize !== void 0 ? _options$fontSize : defaults.fontSize) / 100;
118
- let seedInitials = initials(prng.seed.trim()).toLocaleUpperCase().slice(0, (_options$chars = options.chars) !== null && _options$chars !== void 0 ? _options$chars : defaults.chars); // prettier-ignore
119
66
 
120
- 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('');
121
- return {
122
- attributes: {
123
- viewBox: '0 0 1 1'
124
- },
125
- body: svg
126
- };
127
- }
128
- };
67
+ let { create: $b0b19231ac7e7d5d$export$185802fd694ee1f5 , meta: $b0b19231ac7e7d5d$export$6990040ee07315 , schema: $b0b19231ac7e7d5d$export$4902baddc787debb } = $58963e1ca1f7f945$export$1d567c320f4763bc;
129
68
 
130
- /*!
131
- * DiceBear Initials (@dicebear/initials)
132
- *
133
- * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
134
- * Copyright (c) 2021 Florian Körner
135
- */
136
- let {
137
- create,
138
- meta,
139
- schema
140
- } = style;
141
69
 
142
- export { create, meta, schema };
70
+ export {$b0b19231ac7e7d5d$export$185802fd694ee1f5 as create, $b0b19231ac7e7d5d$export$6990040ee07315 as meta, $b0b19231ac7e7d5d$export$4902baddc787debb as schema};
71
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AEAA,yBAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAA02B;;;;ADKt4B,KAAK,CAAC,4BAAM,GAA2B,CAAC;IACtC,KAAK,EAAE,CAAsB;IAC7B,IAAI,EAAE,CAAuB;IAC7B,QAAQ,EAAE,CAAuB;IACjC,KAAK,EAAE,CAAsB;IAC7B,IAAI,EAAE,CAAsB;IAC5B,UAAU,EAAE,CAAsB;IAClC,UAAU,EAAE,CAAsB;IAClC,KAAK,EAAE,CAAsB;IAC7B,IAAI,EAAE,CAAwB;IAC9B,MAAM,EAAE,CAAsB;IAC9B,SAAS,EAAE,CAAsB;IACjC,UAAU,EAAE,CAAuB;IACnC,IAAI,EAAE,CAAuB;IAC7B,MAAM,EAAE,CAAsB;IAC9B,IAAI,EAAE,CAAsB;IAC5B,MAAM,EAAE,CAAuB;IAC/B,GAAG,EAAE,CAAsB;IAC3B,IAAI,EAAE,CAAsB;IAC5B,MAAM,EAAE,CAAuB;AACjC,CAAC;AAEM,KAAK,CAAC,yCAAK,GAAmB,CAAC;IACpC,IAAI,EAAE,CAAC;QACL,KAAK,EAAE,CAAU;QACjB,OAAO,EAAE,CAAgB;QACzB,MAAM,EAAE,CAAsC;QAC9C,OAAO,EAAE,CAAC;YACR,IAAI,EAAE,CAAS;YACf,GAAG,EAAE,CAAoD;QAC3D,CAAC;IACH,CAAC;IACD,MAAM,EAAE,gEAAM;IACd,MAAM,GAAG,CAAC,OAAC,IAAI,YAAE,OAAO,EAAC,CAAC,GAAK,CAAC;YACJ,GAAuB;YAAe,IAAW;QAA3E,OAAO,CAAC,eAAe,IAAG,GAAuB,GAAvB,OAAO,CAAC,eAAe,cAAvB,GAAuB,KAAvB,IAAI,CAAJ,CAA4B,GAA5B,IAAI,CAAJ,CAA4B,GAA5B,GAAuB,CAAE,GAAG,EAAE,GAAG,IAAK,IAAW,GAAX,4BAAM,CAAC,GAAG,eAAV,IAAW,cAAX,IAAW,GAAI,GAAG;;QAElF,GAAG,CAAC,UAAU,GAAG,CAAkB;YACnB,SAAgB;QAAhC,GAAG,CAAC,QAAQ,KAAI,SAAgB,GAAhB,OAAO,CAAC,QAAQ,cAAhB,SAAgB,cAAhB,SAAgB,GAAI,EAAE,IAAI,GAAG;YAGjC,MAAa;QAFzB,GAAG,CAAC,YAAY,GAAI,eAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IACxC,iBAAiB,GACjB,KAAK,CAAC,CAAC,GAAE,MAAa,GAAb,OAAO,CAAC,KAAK,cAAb,MAAa,cAAb,MAAa,GAAI,CAAC;QAE9B,EAAkB,AAAlB,gBAAkB;QAClB,GAAG,CAAC,GAAG,GAAG,CAAC;aACR,6BAA6B,EAAE,OAAO,CAAC,IAAI,GAAG,CAAoB,sBAAG,CAAE,EAAC,cAAc,EAAE,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC,yCAAyC,GAAG,QAAQ,GAAG,KAAI,EAAE,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,YAAY,CAAC,OAAO;QAC9N,CAAC,CAAC,IAAI,CAAC,CAAE;QAET,MAAM,CAAC,CAAC;YACN,UAAU,EAAE,CAAC;gBACX,OAAO,EAAE,CAAS;YACpB,CAAC;YACD,IAAI,EAAE,GAAG;QACX,CAAC;IACH,CAAC;AACH,CAAC;;;ADlDD,GAAG,CAAC,CAAC,SAAC,yCAAM,SAAE,uCAAI,WAAE,yCAAM,EAAC,CAAC,GAAG,yCAAK","sources":["packages/@dicebear/initials/src/index.ts","packages/@dicebear/initials/src/core.ts","packages/@dicebear/initials/src/schema.json"],"sourcesContent":["/*!\n * DiceBear Initials (@dicebear/initials)\n *\n * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)\n * Copyright (c) 2021 Florian Körner\n */\n\nimport { style } from './core';\n\nlet { create, meta, schema } = style;\n\nexport { create, meta, schema };\nexport type { Options } from './options';\n","import { Style, StyleSchema } from '@dicebear/core';\nimport { Options } from './options';\nimport schema from './schema.json';\nimport initials from 'initials';\n\nconst colors: Record<string, string> = {\n amber: 'rgba(255, 179, 0, 1)',\n blue: 'rgba(30, 136, 229, 1)',\n blueGrey: 'rgba(84, 110, 122, 1)',\n brown: 'rgba(109, 76, 65, 1)',\n cyan: 'rgba(0, 172, 193, 1)',\n deepOrange: 'rgba(244, 81, 30, 1)',\n deepPurple: 'rgba(94, 53, 177, 1)',\n green: 'rgba(67, 160, 71, 1)',\n grey: 'rgba(117, 117, 117, 1)',\n indigo: 'rgba(57, 73, 171, 1)',\n lightBlue: 'rgba(3, 155, 229, 1)',\n lightGreen: 'rgba(124, 179, 66, 1)',\n lime: 'rgba(192, 202, 51, 1)',\n orange: 'rgba(251, 140, 0, 1)',\n pink: 'rgba(216, 27, 96, 1)',\n purple: 'rgba(142, 36, 170, 1)',\n red: 'rgba(229, 57, 53, 1)',\n teal: 'rgba(0, 137, 123, 1)',\n yellow: 'rgba(253, 216, 53, 1)',\n};\n\nexport const style: Style<Options> = {\n meta: {\n title: 'Initials',\n creator: 'Florian Körner',\n source: 'https://github.com/dicebear/dicebear',\n license: {\n name: 'CC0 1.0',\n url: 'https://creativecommons.org/publicdomain/zero/1.0/',\n },\n },\n schema: schema as StyleSchema,\n create: ({ prng, options }) => {\n options.backgroundColor = options.backgroundColor?.map((val) => colors[val] ?? val);\n\n let fontFamily = 'Arial,sans-serif';\n let fontSize = (options.fontSize ?? 50) / 100;\n let seedInitials = (initials(prng.seed.trim()) as string)\n .toLocaleUpperCase()\n .slice(0, options.chars ?? 2);\n\n // prettier-ignore\n let svg = [\n `<text x=\"50%\" y=\"50%\" style=\"${options.bold ? 'font-weight: bold;' : ''} font-family: ${fontFamily}; font-size: ${fontSize}px\" fill=\"#FFF\" text-anchor=\"middle\" dy=\"${(fontSize * .356).toFixed(3)}\">${seedInitials}</text>`,\n ].join('');\n\n return {\n attributes: {\n viewBox: '0 0 1 1',\n },\n body: svg,\n };\n },\n};\n","{\n \"title\": \"Options\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"properties\": {\n \"backgroundColor\": {\n \"title\": \"Background Color\",\n \"type\": \"array\",\n \"uniqueItems\": true,\n \"items\": {\n \"anyOf\": [\n {\n \"type\": \"string\",\n \"pattern\": \"^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$\"\n },\n {\n \"type\": \"string\",\n \"pattern\": \"^[0-9a-zA-Z]+$\"\n }\n ]\n },\n \"default\": [\n \"amber\",\n \"blue\",\n \"blueGrey\",\n \"brown\",\n \"cyan\",\n \"deepOrange\",\n \"deepPurple\",\n \"green\",\n \"grey\",\n \"indigo\",\n \"lightBlue\",\n \"lightGreen\",\n \"lime\",\n \"orange\",\n \"pink\",\n \"purple\",\n \"red\",\n \"teal\",\n \"yellow\"\n ]\n },\n \"fontSize\": {\n \"title\": \"Font Size\",\n \"type\": \"integer\",\n \"minimum\": 1,\n \"maximum\": 100,\n \"default\": 50\n },\n \"chars\": {\n \"title\": \"Chars\",\n \"type\": \"number\",\n \"minimum\": 0,\n \"maximum\": 2,\n \"default\": 2\n },\n \"bold\": {\n \"title\": \"Bold\",\n \"type\": \"boolean\"\n }\n },\n \"additionalProperties\": false\n}\n"],"names":[],"version":3,"file":"index.es.js.map"}
package/dist/index.js CHANGED
@@ -1,152 +1,77 @@
1
- 'use strict';
1
+ var $7TJMm$initials = require("initials");
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
3
+ function $parcel$export(e, n, v, s) {
4
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
5
+ }
6
+ function $parcel$interopDefault(a) {
7
+ return a && a.__esModule ? a.default : a;
8
+ }
4
9
 
5
- var core = require('@dicebear/core');
6
- var initials = require('initials');
10
+ $parcel$export(module.exports, "create", function () { return $f0911555adfc5ab1$export$185802fd694ee1f5; });
11
+ $parcel$export(module.exports, "meta", function () { return $f0911555adfc5ab1$export$6990040ee07315; });
12
+ $parcel$export(module.exports, "schema", function () { return $f0911555adfc5ab1$export$4902baddc787debb; });
13
+ var $c29f7af1b68fd800$exports = {};
14
+ $c29f7af1b68fd800$exports = JSON.parse("{\"title\":\"Options\",\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"properties\":{\"backgroundColor\":{\"title\":\"Background Color\",\"type\":\"array\",\"uniqueItems\":true,\"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\":false}");
7
15
 
8
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
16
 
10
- var initials__default = /*#__PURE__*/_interopDefaultLegacy(initials);
11
17
 
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
- }
18
+ const $9a65309bfe9b611a$var$colors = {
19
+ amber: 'rgba(255, 179, 0, 1)',
20
+ blue: 'rgba(30, 136, 229, 1)',
21
+ blueGrey: 'rgba(84, 110, 122, 1)',
22
+ brown: 'rgba(109, 76, 65, 1)',
23
+ cyan: 'rgba(0, 172, 193, 1)',
24
+ deepOrange: 'rgba(244, 81, 30, 1)',
25
+ deepPurple: 'rgba(94, 53, 177, 1)',
26
+ green: 'rgba(67, 160, 71, 1)',
27
+ grey: 'rgba(117, 117, 117, 1)',
28
+ indigo: 'rgba(57, 73, 171, 1)',
29
+ lightBlue: 'rgba(3, 155, 229, 1)',
30
+ lightGreen: 'rgba(124, 179, 66, 1)',
31
+ lime: 'rgba(192, 202, 51, 1)',
32
+ orange: 'rgba(251, 140, 0, 1)',
33
+ pink: 'rgba(216, 27, 96, 1)',
34
+ purple: 'rgba(142, 36, 170, 1)',
35
+ red: 'rgba(229, 57, 53, 1)',
36
+ teal: 'rgba(0, 137, 123, 1)',
37
+ yellow: 'rgba(253, 216, 53, 1)'
70
38
  };
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/'
39
+ const $9a65309bfe9b611a$export$1d567c320f4763bc = {
40
+ meta: {
41
+ title: 'Initials',
42
+ creator: 'Florian Körner',
43
+ source: 'https://github.com/dicebear/dicebear',
44
+ license: {
45
+ name: 'CC0 1.0',
46
+ url: 'https://creativecommons.org/publicdomain/zero/1.0/'
47
+ }
48
+ },
49
+ schema: (/*@__PURE__*/$parcel$interopDefault($c29f7af1b68fd800$exports)),
50
+ create: ({ prng: prng , options: options })=>{
51
+ var ref;
52
+ var _val;
53
+ options.backgroundColor = (ref = options.backgroundColor) === null || ref === void 0 ? void 0 : ref.map((val)=>(_val = $9a65309bfe9b611a$var$colors[val]) !== null && _val !== void 0 ? _val : val
54
+ );
55
+ let fontFamily = 'Arial,sans-serif';
56
+ var _fontSize;
57
+ let fontSize = ((_fontSize = options.fontSize) !== null && _fontSize !== void 0 ? _fontSize : 50) / 100;
58
+ var _chars;
59
+ let seedInitials = ($parcel$interopDefault($7TJMm$initials))(prng.seed.trim()).toLocaleUpperCase().slice(0, (_chars = options.chars) !== null && _chars !== void 0 ? _chars : 2);
60
+ // prettier-ignore
61
+ let svg = [
62
+ `<text x="50%" y="50%" style="${options.bold ? 'font-weight: bold;' : ''} font-family: ${fontFamily}; font-size: ${fontSize}px" fill="#FFF" text-anchor="middle" dy="${(fontSize * 0.356).toFixed(3)}">${seedInitials}</text>`,
63
+ ].join('');
64
+ return {
65
+ attributes: {
66
+ viewBox: '0 0 1 1'
67
+ },
68
+ body: svg
69
+ };
108
70
  }
109
- },
110
- schema: schema$1,
111
- create: _ref => {
112
- var _options$backgroundCo, _options$fontSize, _options$chars;
113
-
114
- let {
115
- prng,
116
- options
117
- } = _ref;
118
- let defaults = core.utils.schema.defaults(schema$1);
119
- options.backgroundColor = (_options$backgroundCo = options.backgroundColor) === null || _options$backgroundCo === void 0 ? void 0 : _options$backgroundCo.map(val => {
120
- var _colors$val;
71
+ };
121
72
 
122
- return (_colors$val = colors[val]) !== null && _colors$val !== void 0 ? _colors$val : val;
123
- });
124
- let fontFamily = 'Arial,sans-serif';
125
- let fontSize = ((_options$fontSize = options.fontSize) !== null && _options$fontSize !== void 0 ? _options$fontSize : defaults.fontSize) / 100;
126
- 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
127
73
 
128
- 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('');
129
- return {
130
- attributes: {
131
- viewBox: '0 0 1 1'
132
- },
133
- body: svg
134
- };
135
- }
136
- };
74
+ let { create: $f0911555adfc5ab1$export$185802fd694ee1f5 , meta: $f0911555adfc5ab1$export$6990040ee07315 , schema: $f0911555adfc5ab1$export$4902baddc787debb } = $9a65309bfe9b611a$export$1d567c320f4763bc;
137
75
 
138
- /*!
139
- * DiceBear Initials (@dicebear/initials)
140
- *
141
- * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)
142
- * Copyright (c) 2021 Florian Körner
143
- */
144
- let {
145
- create,
146
- meta,
147
- schema
148
- } = style;
149
76
 
150
- exports.create = create;
151
- exports.meta = meta;
152
- exports.schema = schema;
77
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;AEAA,yBAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAA02B;;;;ADKt4B,KAAK,CAAC,4BAAM,GAA2B,CAAC;IACtC,KAAK,EAAE,CAAsB;IAC7B,IAAI,EAAE,CAAuB;IAC7B,QAAQ,EAAE,CAAuB;IACjC,KAAK,EAAE,CAAsB;IAC7B,IAAI,EAAE,CAAsB;IAC5B,UAAU,EAAE,CAAsB;IAClC,UAAU,EAAE,CAAsB;IAClC,KAAK,EAAE,CAAsB;IAC7B,IAAI,EAAE,CAAwB;IAC9B,MAAM,EAAE,CAAsB;IAC9B,SAAS,EAAE,CAAsB;IACjC,UAAU,EAAE,CAAuB;IACnC,IAAI,EAAE,CAAuB;IAC7B,MAAM,EAAE,CAAsB;IAC9B,IAAI,EAAE,CAAsB;IAC5B,MAAM,EAAE,CAAuB;IAC/B,GAAG,EAAE,CAAsB;IAC3B,IAAI,EAAE,CAAsB;IAC5B,MAAM,EAAE,CAAuB;AACjC,CAAC;AAEM,KAAK,CAAC,yCAAK,GAAmB,CAAC;IACpC,IAAI,EAAE,CAAC;QACL,KAAK,EAAE,CAAU;QACjB,OAAO,EAAE,CAAgB;QACzB,MAAM,EAAE,CAAsC;QAC9C,OAAO,EAAE,CAAC;YACR,IAAI,EAAE,CAAS;YACf,GAAG,EAAE,CAAoD;QAC3D,CAAC;IACH,CAAC;IACD,MAAM,EAAE,gEAAM;IACd,MAAM,GAAG,CAAC,OAAC,IAAI,YAAE,OAAO,EAAC,CAAC,GAAK,CAAC;YACJ,GAAuB;YAAe,IAAW;QAA3E,OAAO,CAAC,eAAe,IAAG,GAAuB,GAAvB,OAAO,CAAC,eAAe,cAAvB,GAAuB,KAAvB,IAAI,CAAJ,CAA4B,GAA5B,IAAI,CAAJ,CAA4B,GAA5B,GAAuB,CAAE,GAAG,EAAE,GAAG,IAAK,IAAW,GAAX,4BAAM,CAAC,GAAG,eAAV,IAAW,cAAX,IAAW,GAAI,GAAG;;QAElF,GAAG,CAAC,UAAU,GAAG,CAAkB;YACnB,SAAgB;QAAhC,GAAG,CAAC,QAAQ,KAAI,SAAgB,GAAhB,OAAO,CAAC,QAAQ,cAAhB,SAAgB,cAAhB,SAAgB,GAAI,EAAE,IAAI,GAAG;YAGjC,MAAa;QAFzB,GAAG,CAAC,YAAY,GAAI,yCAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IACxC,iBAAiB,GACjB,KAAK,CAAC,CAAC,GAAE,MAAa,GAAb,OAAO,CAAC,KAAK,cAAb,MAAa,cAAb,MAAa,GAAI,CAAC;QAE9B,EAAkB,AAAlB,gBAAkB;QAClB,GAAG,CAAC,GAAG,GAAG,CAAC;aACR,6BAA6B,EAAE,OAAO,CAAC,IAAI,GAAG,CAAoB,sBAAG,CAAE,EAAC,cAAc,EAAE,UAAU,CAAC,aAAa,EAAE,QAAQ,CAAC,yCAAyC,GAAG,QAAQ,GAAG,KAAI,EAAE,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,YAAY,CAAC,OAAO;QAC9N,CAAC,CAAC,IAAI,CAAC,CAAE;QAET,MAAM,CAAC,CAAC;YACN,UAAU,EAAE,CAAC;gBACX,OAAO,EAAE,CAAS;YACpB,CAAC;YACD,IAAI,EAAE,GAAG;QACX,CAAC;IACH,CAAC;AACH,CAAC;;;ADlDD,GAAG,CAAC,CAAC,SAAC,yCAAM,SAAE,uCAAI,WAAE,yCAAM,EAAC,CAAC,GAAG,yCAAK","sources":["packages/@dicebear/initials/src/index.ts","packages/@dicebear/initials/src/core.ts","packages/@dicebear/initials/src/schema.json"],"sourcesContent":["/*!\n * DiceBear Initials (@dicebear/initials)\n *\n * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/v4/packages/initials/LICENSE)\n * Copyright (c) 2021 Florian Körner\n */\n\nimport { style } from './core';\n\nlet { create, meta, schema } = style;\n\nexport { create, meta, schema };\nexport type { Options } from './options';\n","import { Style, StyleSchema } from '@dicebear/core';\nimport { Options } from './options';\nimport schema from './schema.json';\nimport initials from 'initials';\n\nconst colors: Record<string, string> = {\n amber: 'rgba(255, 179, 0, 1)',\n blue: 'rgba(30, 136, 229, 1)',\n blueGrey: 'rgba(84, 110, 122, 1)',\n brown: 'rgba(109, 76, 65, 1)',\n cyan: 'rgba(0, 172, 193, 1)',\n deepOrange: 'rgba(244, 81, 30, 1)',\n deepPurple: 'rgba(94, 53, 177, 1)',\n green: 'rgba(67, 160, 71, 1)',\n grey: 'rgba(117, 117, 117, 1)',\n indigo: 'rgba(57, 73, 171, 1)',\n lightBlue: 'rgba(3, 155, 229, 1)',\n lightGreen: 'rgba(124, 179, 66, 1)',\n lime: 'rgba(192, 202, 51, 1)',\n orange: 'rgba(251, 140, 0, 1)',\n pink: 'rgba(216, 27, 96, 1)',\n purple: 'rgba(142, 36, 170, 1)',\n red: 'rgba(229, 57, 53, 1)',\n teal: 'rgba(0, 137, 123, 1)',\n yellow: 'rgba(253, 216, 53, 1)',\n};\n\nexport const style: Style<Options> = {\n meta: {\n title: 'Initials',\n creator: 'Florian Körner',\n source: 'https://github.com/dicebear/dicebear',\n license: {\n name: 'CC0 1.0',\n url: 'https://creativecommons.org/publicdomain/zero/1.0/',\n },\n },\n schema: schema as StyleSchema,\n create: ({ prng, options }) => {\n options.backgroundColor = options.backgroundColor?.map((val) => colors[val] ?? val);\n\n let fontFamily = 'Arial,sans-serif';\n let fontSize = (options.fontSize ?? 50) / 100;\n let seedInitials = (initials(prng.seed.trim()) as string)\n .toLocaleUpperCase()\n .slice(0, options.chars ?? 2);\n\n // prettier-ignore\n let svg = [\n `<text x=\"50%\" y=\"50%\" style=\"${options.bold ? 'font-weight: bold;' : ''} font-family: ${fontFamily}; font-size: ${fontSize}px\" fill=\"#FFF\" text-anchor=\"middle\" dy=\"${(fontSize * .356).toFixed(3)}\">${seedInitials}</text>`,\n ].join('');\n\n return {\n attributes: {\n viewBox: '0 0 1 1',\n },\n body: svg,\n };\n },\n};\n","{\n \"title\": \"Options\",\n \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n \"properties\": {\n \"backgroundColor\": {\n \"title\": \"Background Color\",\n \"type\": \"array\",\n \"uniqueItems\": true,\n \"items\": {\n \"anyOf\": [\n {\n \"type\": \"string\",\n \"pattern\": \"^#([a-fA-F0-9]{3}|[a-fA-F0-9]{4}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8})$\"\n },\n {\n \"type\": \"string\",\n \"pattern\": \"^[0-9a-zA-Z]+$\"\n }\n ]\n },\n \"default\": [\n \"amber\",\n \"blue\",\n \"blueGrey\",\n \"brown\",\n \"cyan\",\n \"deepOrange\",\n \"deepPurple\",\n \"green\",\n \"grey\",\n \"indigo\",\n \"lightBlue\",\n \"lightGreen\",\n \"lime\",\n \"orange\",\n \"pink\",\n \"purple\",\n \"red\",\n \"teal\",\n \"yellow\"\n ]\n },\n \"fontSize\": {\n \"title\": \"Font Size\",\n \"type\": \"integer\",\n \"minimum\": 1,\n \"maximum\": 100,\n \"default\": 50\n },\n \"chars\": {\n \"title\": \"Chars\",\n \"type\": \"number\",\n \"minimum\": 0,\n \"maximum\": 2,\n \"default\": 2\n },\n \"bold\": {\n \"title\": \"Bold\",\n \"type\": \"boolean\"\n }\n },\n \"additionalProperties\": false\n}\n"],"names":[],"version":3,"file":"index.js.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dicebear/initials",
3
- "version": "5.0.0-alpha.5",
3
+ "version": "5.0.0-alpha.9",
4
4
  "description": "Initials avatar style for DiceBear",
5
5
  "keywords": [
6
6
  "dicebear",
@@ -21,10 +21,10 @@
21
21
  },
22
22
  "license": "MIT",
23
23
  "author": "Florian Körner <contact@florian-koerner.com>",
24
+ "browserslist": ">.25%, not IE > 0, not dead",
24
25
  "source": "src/index.ts",
25
26
  "main": "dist/index.js",
26
27
  "module": "dist/index.es.js",
27
- "browser": "dist/index.umd.js",
28
28
  "types": "dist/index.d.ts",
29
29
  "files": [
30
30
  "LICENSE",
@@ -35,27 +35,33 @@
35
35
  "test": "jest",
36
36
  "prepublishOnly": "npm run build",
37
37
  "prebuild": "shx rm -rf dist",
38
- "build": "dicebear-project build DiceBear.Initials"
38
+ "build": "npm-run-all build:*",
39
+ "build:schema": "json2ts src/schema.json src/options.ts",
40
+ "build:parcel": "parcel build"
39
41
  },
40
42
  "dependencies": {
41
43
  "initials": "^3.0.1"
42
44
  },
43
45
  "devDependencies": {
44
- "@dicebear/core": "^5.0.0-alpha.5",
46
+ "@dicebear/core": "^5.0.0-alpha.9",
47
+ "@parcel/packager-ts": "^2.0.1",
48
+ "@parcel/transformer-typescript-types": "^2.0.1",
45
49
  "@tsconfig/recommended": "^1.0.0",
46
50
  "@types/jest": "^26.0.22",
47
51
  "@types/node": "^10.11.6",
48
- "dicebear-project": "^5.0.0-alpha.5",
49
52
  "jest": "^26.6.3",
53
+ "json-schema-to-typescript": "^10.1.5",
54
+ "npm-run-all": "^4.1.5",
55
+ "parcel": "^2.0.1",
50
56
  "shx": "^0.3.3",
51
57
  "ts-jest": "^26.5.4",
52
- "typescript": "^4.2.3"
58
+ "typescript": "^4.5.2"
53
59
  },
54
60
  "peerDependencies": {
55
- "@dicebear/core": "^5.0.0-alpha.5"
61
+ "@dicebear/core": "^5.0.0-alpha.6"
56
62
  },
57
63
  "publishConfig": {
58
64
  "access": "public"
59
65
  },
60
- "gitHead": "f468a40150c4d5f913287f10b49eb034b180e4f0"
66
+ "gitHead": "d2861228315afd1fef06969d1eaf9655a027fbbb"
61
67
  }
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.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:e=>{var r,i,a;let{prng:l,options:o}=e,u=t.utils.schema.defaults(n);o.backgroundColor=null===(r=o.backgroundColor)||void 0===r?void 0:r.map((e=>{var t;return null!==(t=A[e])&&void 0!==t?t:e}));let c=(null!==(i=o.fontSize)&&void 0!==i?i:u.fontSize)/100,f=z(l.seed.trim()).toLocaleUpperCase().slice(0,null!==(a=o.chars)&&void 0!==a?a:u.chars);return{attributes:{viewBox:"0 0 1 1"},body:['<text x="50%" y="50%" style="'.concat(o.bold?"font-weight: bold;":""," font-family: ").concat("Arial,sans-serif","; font-size: ").concat(c,'px" fill="#FFF" text-anchor="middle" dy="').concat((.356*c).toFixed(3),'">').concat(f,"</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
- }