@dicebear/initials 5.0.0-alpha.8 → 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/initials/1.svg" width="124" /> <br />initials</h1>
1
+ <h1 align="center"><img src="https://api.dicebear.com/5.x/initials/svg?seed=initials" width="124" /> <br />initials</h1>
2
2
  <p align="center">
3
3
  <strong>Avatar Style for <a href="https://dicebear.com/">DiceBear</a>.</strong>
4
4
  </p>
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,33 @@
1
+ import { schema } from './schema.js';
2
+ import initials from 'initials';
3
+ export const style = {
4
+ meta: {
5
+ title: 'Initials',
6
+ creator: 'Florian Körner',
7
+ source: 'https://github.com/dicebear/dicebear',
8
+ license: {
9
+ name: 'CC0 1.0',
10
+ url: 'https://creativecommons.org/publicdomain/zero/1.0/',
11
+ },
12
+ },
13
+ schema: schema,
14
+ create: ({ prng, options }) => {
15
+ var _a, _b, _c, _d, _e;
16
+ const fontFamily = (_b = (_a = options.fontFamily) === null || _a === void 0 ? void 0 : _a.join(', ')) !== null && _b !== void 0 ? _b : 'Arial, sans-serif';
17
+ const fontSize = (_c = options.fontSize) !== null && _c !== void 0 ? _c : 50;
18
+ const fontWeight = (_d = options.fontWeight) !== null && _d !== void 0 ? _d : 400;
19
+ const seedInitials = initials(prng.seed.trim())
20
+ .toLocaleUpperCase()
21
+ .slice(0, (_e = options.chars) !== null && _e !== void 0 ? _e : 2);
22
+ // prettier-ignore
23
+ const svg = [
24
+ `<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>`,
25
+ ].join('');
26
+ return {
27
+ attributes: {
28
+ viewBox: '0 0 100 100',
29
+ },
30
+ body: svg,
31
+ };
32
+ },
33
+ };
package/lib/index.d.ts ADDED
@@ -0,0 +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) 2022 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) 2022 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,69 @@
1
+ export const schema = {
2
+ $schema: 'http://json-schema.org/draft-07/schema#',
3
+ properties: {
4
+ backgroundColor: {
5
+ type: 'array',
6
+ items: {
7
+ type: 'string',
8
+ pattern: '^[a-fA-F0-9]{6}$',
9
+ },
10
+ default: [
11
+ 'e53935',
12
+ 'd81b60',
13
+ '8e24aa',
14
+ '5e35b1',
15
+ '3949ab',
16
+ '1e88e5',
17
+ '039be5',
18
+ '00acc1',
19
+ '00897b',
20
+ '43a047',
21
+ '7cb342',
22
+ 'c0ca33',
23
+ 'fdd835',
24
+ 'ffb300',
25
+ 'fb8c00',
26
+ 'f4511e',
27
+ ],
28
+ },
29
+ fontFamily: {
30
+ type: 'array',
31
+ minItems: 1,
32
+ items: {
33
+ type: 'string',
34
+ enum: [
35
+ 'Arial',
36
+ 'Verdana',
37
+ 'Helvetica',
38
+ 'Tahoma',
39
+ 'Trebuchet MS',
40
+ 'Times New Roman',
41
+ 'Georgia',
42
+ 'Garamond',
43
+ 'Courier New',
44
+ 'Brush Script MT',
45
+ 'sans-serif',
46
+ 'serif',
47
+ ],
48
+ },
49
+ default: ['Arial', 'sans-serif'],
50
+ },
51
+ fontSize: {
52
+ type: 'integer',
53
+ minimum: 1,
54
+ maximum: 100,
55
+ default: 50,
56
+ },
57
+ chars: {
58
+ type: 'number',
59
+ minimum: 0,
60
+ maximum: 2,
61
+ default: 2,
62
+ },
63
+ fontWeight: {
64
+ type: 'number',
65
+ default: 400,
66
+ enum: [100, 200, 300, 400, 500, 600, 700, 800, 900],
67
+ },
68
+ },
69
+ };
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,67 +1,50 @@
1
1
  {
2
2
  "name": "@dicebear/initials",
3
- "version": "5.0.0-alpha.8",
3
+ "version": "5.0.0-beta.0",
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
- "browserslist": ">.25%, not IE > 0, not dead",
25
- "source": "src/index.ts",
26
- "main": "dist/index.js",
27
- "module": "dist/index.es.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": "npm-run-all build:*",
39
- "build:schema": "json2ts src/schema.json src/options.ts",
40
- "build:parcel": "parcel build"
28
+ "test": "uvu tests"
41
29
  },
42
30
  "dependencies": {
43
- "initials": "^3.0.1"
31
+ "initials": "^3.1.2"
44
32
  },
45
33
  "devDependencies": {
46
- "@dicebear/core": "^5.0.0-alpha.8",
47
- "@parcel/packager-ts": "^2.0.1",
48
- "@parcel/transformer-typescript-types": "^2.0.1",
49
- "@tsconfig/recommended": "^1.0.0",
50
- "@types/jest": "^26.0.22",
51
- "@types/node": "^10.11.6",
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",
56
- "shx": "^0.3.3",
57
- "ts-jest": "^26.5.4",
58
- "typescript": "^4.5.2"
34
+ "@dicebear/core": "^5.0.0-beta.0",
35
+ "@tsconfig/recommended": "^1.0.1",
36
+ "del-cli": "^4.0.1",
37
+ "typescript": "^4.6.3",
38
+ "uvu": "^0.5.3"
59
39
  },
60
40
  "peerDependencies": {
61
41
  "@dicebear/core": "^5.0.0-alpha.6"
62
42
  },
43
+ "engines": {
44
+ "node": "^14.13.1 || >=16.0.0"
45
+ },
63
46
  "publishConfig": {
64
47
  "access": "public"
65
48
  },
66
- "gitHead": "37e053cb23e90bc621d3457b7fcc8e39e32ca1ac"
49
+ "gitHead": "f939afabe6ade034e344b1983caa21de49873dda"
67
50
  }
package/dist/index.d.ts DELETED
@@ -1,18 +0,0 @@
1
- /**
2
- * This file was automatically generated by json-schema-to-typescript.
3
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
4
- * and run json-schema-to-typescript to regenerate this file.
5
- */
6
- 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
@@ -1 +0,0 @@
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 DELETED
@@ -1,71 +0,0 @@
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\",\"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
-
9
-
10
-
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)'
31
- };
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
- };
63
- }
64
- };
65
-
66
-
67
- let { create: $b0b19231ac7e7d5d$export$185802fd694ee1f5 , meta: $b0b19231ac7e7d5d$export$6990040ee07315 , schema: $b0b19231ac7e7d5d$export$4902baddc787debb } = $58963e1ca1f7f945$export$1d567c320f4763bc;
68
-
69
-
70
- export {$b0b19231ac7e7d5d$export$185802fd694ee1f5 as create, $b0b19231ac7e7d5d$export$6990040ee07315 as meta, $b0b19231ac7e7d5d$export$4902baddc787debb as schema};
71
- //# sourceMappingURL=index.es.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;AEAA,yBAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAq1B;;;;ADKj3B,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 \"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 DELETED
@@ -1,77 +0,0 @@
1
- var $7TJMm$initials = require("initials");
2
-
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
- }
9
-
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\",\"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}");
15
-
16
-
17
-
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)'
38
- };
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
- };
70
- }
71
- };
72
-
73
-
74
- let { create: $f0911555adfc5ab1$export$185802fd694ee1f5 , meta: $f0911555adfc5ab1$export$6990040ee07315 , schema: $f0911555adfc5ab1$export$4902baddc787debb } = $9a65309bfe9b611a$export$1d567c320f4763bc;
75
-
76
-
77
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;AEAA,yBAAc,GAAG,IAAI,CAAC,KAAK,CAAC,CAAq1B;;;;ADKj3B,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 \"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"}