@dicebear/core 8.0.1 → 9.0.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) 2023 Florian Körner
3
+ Copyright (c) 2024 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/lib/core.js CHANGED
@@ -2,7 +2,6 @@ import * as svgUtils from './utils/svg.js';
2
2
  import { merge as mergeOptions } from './utils/options.js';
3
3
  import { create as createPrng } from './utils/prng.js';
4
4
  import * as license from './utils/license.js';
5
- import { toFormat } from '@dicebear/converter';
6
5
  import { getBackgroundColors } from './utils/color.js';
7
6
  export function createAvatar(style, options = {}) {
8
7
  var _a, _b, _c, _d, _e;
@@ -11,7 +10,11 @@ export function createAvatar(style, options = {}) {
11
10
  const result = style.create({ prng: prng, options });
12
11
  const backgroundType = prng.pick((_a = options.backgroundType) !== null && _a !== void 0 ? _a : [], 'solid');
13
12
  const { primary: primaryBackgroundColor, secondary: secondaryBackgroundColor, } = getBackgroundColors(prng, (_b = options.backgroundColor) !== null && _b !== void 0 ? _b : [], backgroundType);
14
- const backgroundRotation = prng.integer(((_c = options.backgroundRotation) === null || _c === void 0 ? void 0 : _c.length) ? Math.min(...options.backgroundRotation) : 0, ((_d = options.backgroundRotation) === null || _d === void 0 ? void 0 : _d.length) ? Math.max(...options.backgroundRotation) : 0);
13
+ const backgroundRotation = prng.integer(((_c = options.backgroundRotation) === null || _c === void 0 ? void 0 : _c.length)
14
+ ? Math.min(...options.backgroundRotation)
15
+ : 0, ((_d = options.backgroundRotation) === null || _d === void 0 ? void 0 : _d.length)
16
+ ? Math.max(...options.backgroundRotation)
17
+ : 0);
15
18
  if (options.size) {
16
19
  result.attributes.width = options.size.toString();
17
20
  result.attributes.height = options.size.toString();
@@ -41,7 +44,6 @@ export function createAvatar(style, options = {}) {
41
44
  }
42
45
  const attributes = svgUtils.createAttrString(result);
43
46
  const metadata = license.xml(style);
44
- const exif = license.exif(style);
45
47
  const svg = `<svg ${attributes}>${metadata}${result.body}</svg>`;
46
48
  return {
47
49
  toString: () => svg,
@@ -58,15 +60,8 @@ export function createAvatar(style, options = {}) {
58
60
  },
59
61
  });
60
62
  },
61
- toDataUriSync: () => {
63
+ toDataUri: () => {
62
64
  return `data:image/svg+xml;utf8,${encodeURIComponent(svg)}`;
63
65
  },
64
- ...toFormat(svg, 'svg'),
65
- png: ({ includeExif = false } = {}) => {
66
- return toFormat(svg, 'png', includeExif ? exif : undefined);
67
- },
68
- jpeg: ({ includeExif = false } = {}) => {
69
- return toFormat(svg, 'jpeg', includeExif ? exif : undefined);
70
- },
71
66
  };
72
67
  }
package/lib/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * DiceBear (@dicebear/core)
3
3
  *
4
4
  * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/main/LICENSE)
5
- * Copyright (c) 2023 Florian Körner
5
+ * Copyright (c) 2024 Florian Körner
6
6
  */
7
7
  import * as license from './utils/license.js';
8
8
  import * as escape from './utils/escape.js';
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * DiceBear (@dicebear/core)
3
3
  *
4
4
  * Code licensed under MIT (https://github.com/dicebear/dicebear/blob/main/LICENSE)
5
- * Copyright (c) 2023 Florian Körner
5
+ * Copyright (c) 2024 Florian Körner
6
6
  */
7
7
  import * as license from './utils/license.js';
8
8
  import * as escape from './utils/escape.js';
package/lib/types.d.ts CHANGED
@@ -1,17 +1,14 @@
1
1
  import type { JSONSchema7 } from 'json-schema';
2
- import type { Result as ConverterResult } from '@dicebear/converter';
3
2
  export interface ResultConvertOptions {
4
3
  includeExif?: boolean;
5
4
  }
6
- export interface Result extends ConverterResult {
7
- png(options?: ResultConvertOptions): ConverterResult;
8
- jpeg(options?: ResultConvertOptions): ConverterResult;
5
+ export interface Result {
9
6
  toString(): string;
10
7
  toJson(): {
11
8
  svg: string;
12
9
  extra: Record<string, unknown>;
13
10
  };
14
- toDataUriSync(): string;
11
+ toDataUri(): string;
15
12
  }
16
13
  export type BackgroundType = 'solid' | 'gradientLinear';
17
14
  export interface Options {
@@ -1,4 +1,3 @@
1
- import { Exif, Style } from '../types.js';
1
+ import { Style } from '../types.js';
2
2
  export declare function xml(style: Style<any>): string;
3
3
  export declare function text(style: Style<any>): string;
4
- export declare function exif(style: Style<any>): Exif;
@@ -19,8 +19,12 @@ export function xml(style) {
19
19
  '<rdf:Description>' +
20
20
  (title ? `<dc:title>${_.xml(title)}</dc:title>` : '') +
21
21
  (creator ? `<dc:creator>${_.xml(creator)}</dc:creator>` : '') +
22
- (source ? `<dc:source xsi:type="dcterms:URI">${_.xml((_g = (_f = style.meta) === null || _f === void 0 ? void 0 : _f.source) !== null && _g !== void 0 ? _g : '')}</dc:source>` : '') +
23
- (license ? `<dcterms:license xsi:type="dcterms:URI">${_.xml(license)}</dcterms:license>` : '') +
22
+ (source
23
+ ? `<dc:source xsi:type="dcterms:URI">${_.xml((_g = (_f = style.meta) === null || _f === void 0 ? void 0 : _f.source) !== null && _g !== void 0 ? _g : '')}</dc:source>`
24
+ : '') +
25
+ (license
26
+ ? `<dcterms:license xsi:type="dcterms:URI">${_.xml(license)}</dcterms:license>`
27
+ : '') +
24
28
  (rights ? `<dc:rights>${_.xml(rights)}</dc:rights>` : '') +
25
29
  '</rdf:Description>' +
26
30
  '</rdf:RDF>' +
@@ -34,7 +38,9 @@ export function text(style) {
34
38
  title += ` (${style.meta.source})`;
35
39
  }
36
40
  let result = '';
37
- if (((_g = (_f = style.meta) === null || _f === void 0 ? void 0 : _f.license) === null || _g === void 0 ? void 0 : _g.name) !== 'MIT' && ((_h = style.meta) === null || _h === void 0 ? void 0 : _h.creator) !== 'DiceBear' && ((_j = style.meta) === null || _j === void 0 ? void 0 : _j.title)) {
41
+ if (((_g = (_f = style.meta) === null || _f === void 0 ? void 0 : _f.license) === null || _g === void 0 ? void 0 : _g.name) !== 'MIT' &&
42
+ ((_h = style.meta) === null || _h === void 0 ? void 0 : _h.creator) !== 'DiceBear' &&
43
+ ((_j = style.meta) === null || _j === void 0 ? void 0 : _j.title)) {
38
44
  result += 'Remix of ';
39
45
  }
40
46
  result += `${title} by ${creator}`;
@@ -46,27 +52,3 @@ export function text(style) {
46
52
  }
47
53
  return result;
48
54
  }
49
- export function exif(style) {
50
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
51
- const copyright = text(style);
52
- // https://www.iptc.org/std/photometadata/specification/IPTC-PhotoMetadata
53
- // https://developers.google.com/search/docs/appearance/structured-data/image-license-metadata
54
- return {
55
- // Title
56
- 'IPTC:ObjectName': (_a = style.meta) === null || _a === void 0 ? void 0 : _a.title,
57
- 'XMP-dc:Title': (_b = style.meta) === null || _b === void 0 ? void 0 : _b.title,
58
- // Copyright
59
- 'IPTC:CopyrightNotice': copyright,
60
- 'XMP-dc:Rights': copyright,
61
- // Creator
62
- 'IPTC:By-line': (_c = style.meta) === null || _c === void 0 ? void 0 : _c.creator,
63
- 'XMP-dc:Creator': (_d = style.meta) === null || _d === void 0 ? void 0 : _d.creator,
64
- // Credit
65
- 'IPTC:Credit': (_e = style.meta) === null || _e === void 0 ? void 0 : _e.creator,
66
- 'XMP-photoshop:Credit': (_f = style.meta) === null || _f === void 0 ? void 0 : _f.creator,
67
- // Licensor
68
- 'XMP-plus:LicensorURL': (_g = style.meta) === null || _g === void 0 ? void 0 : _g.source,
69
- // Rights
70
- 'XMP-xmpRights:WebStatement': (_j = (_h = style.meta) === null || _h === void 0 ? void 0 : _h.license) === null || _j === void 0 ? void 0 : _j.url,
71
- };
72
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dicebear/core",
3
- "version": "8.0.1",
3
+ "version": "9.0.0",
4
4
  "description": "An avatar library for designers and developers.",
5
5
  "keywords": [
6
6
  "avatar",
@@ -32,7 +32,6 @@
32
32
  "test": "uvu tests"
33
33
  },
34
34
  "dependencies": {
35
- "@dicebear/converter": "8.0.1",
36
35
  "@types/json-schema": "^7.0.11"
37
36
  },
38
37
  "devDependencies": {
@@ -42,10 +41,10 @@
42
41
  "uvu": "^0.5.6"
43
42
  },
44
43
  "engines": {
45
- "node": ">=16.0.0"
44
+ "node": ">=18.0.0"
46
45
  },
47
46
  "publishConfig": {
48
47
  "access": "public"
49
48
  },
50
- "gitHead": "dc11ff0fa0328c521e5769fde4414ad5a6dc7d2d"
49
+ "gitHead": "c9e66450840d4f29faee6362249348bb3d18798b"
51
50
  }