@fullstackunicorn/websites 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/modules/icons.js +10 -34
  2. package/package.json +1 -1
package/modules/icons.js CHANGED
@@ -1,39 +1,15 @@
1
- class Icons {
2
-
3
- generate = async (files = {}) => {
4
-
5
- const result = {}
6
-
7
- const extFavicon = this.getExtension(files.favicon.name)
8
- const isFaviconSvg = extFavicon === 'svg'
9
- const isFaviconPng = extFavicon === 'png'
10
-
11
- const extIcon = this.getExtension(files.icon.name)
12
- const isIconSvg = extIcon === 'svg'
13
- const isIconPng = extIcon === 'png'
14
-
15
- if (extFaviconExpected !== extFavicon) F3.throw('favicon-extensions-not-matching')
16
-
17
- let pngIcoBlob
1
+ import { sharp } from '#@/index.dep.js'
18
2
 
19
- // generate the favicons
20
- if (isFaviconSvg) pngIcoBlob = await this.generateFaviconsFromSvg(result.icons, files.favicon.data)
21
- else if (isFaviconPng) pngIcoBlob = await this.generateFaviconsFromPng(result.icons, files.favicon.data)
22
- if (pngIcoBlob) await this.generateIco(result.favicon, pngIcoBlob)
23
-
24
- // generate the icons
25
- if (isIconSvg) await this.generateIconsFromSvg(result.icons, files.icon.data)
26
- else if (isIconPng) await this.generateIconsFromPng(result.icons, files.icon.data)
27
-
28
- return result
3
+ class Icons {
29
4
 
5
+ constructor () {
6
+ this.sizesIcon = [180, 192, 512]
7
+ this.sizeFavicon = 32
30
8
  }
31
9
 
32
10
  generate = async ({ favicon, icon }) => {
33
11
 
34
12
  const result = {}
35
- result.ico = {}
36
- result.icons = {}
37
13
 
38
14
  const extFavicon = this.getExtension(favicon.name)
39
15
  const isFaviconSvg = extFavicon === 'svg'
@@ -45,14 +21,14 @@ class Icons {
45
21
 
46
22
  let pngIcoBlob = null
47
23
 
48
- if (isFaviconSvg) pngIcoBlob = await this.generateFaviconsFromSvg(result.icons, favicon.buffer)
49
- else if (isFaviconPng) pngIcoBlob = await this.generateFaviconsFromPng(result.icons, favicon.buffer)
24
+ if (isFaviconSvg) pngIcoBlob = await this.generateFaviconsFromSvg(result, favicon.buffer)
25
+ else if (isFaviconPng) pngIcoBlob = await this.generateFaviconsFromPng(result, favicon.buffer)
50
26
  else F3.throw('favicon-extensions-not-matching')
51
27
 
52
- if (pngIcoBlob) await this.generateIco(result.ico, pngIcoBlob)
28
+ if (pngIcoBlob) await this.generateIco(result, pngIcoBlob)
53
29
 
54
- if (isIconSvg) await this.generateIconsFromSvg(result.icons, icon.buffer)
55
- else if (isIconPng) await this.generateIconsFromPng(result.icons, icon.buffer)
30
+ if (isIconSvg) await this.generateIconsFromSvg(result, icon.buffer)
31
+ else if (isIconPng) await this.generateIconsFromPng(result, icon.buffer)
56
32
  else F3.throw('icon-extensions-not-matching')
57
33
 
58
34
  return result
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.3",
2
+ "version": "1.0.4",
3
3
  "name": "@fullstackunicorn/websites",
4
4
  "author": "lucanigido (https://fullstackunicorn.dev/author/lucanigido)",
5
5
  "description": "A development utility for generating icons, favicons, thumbnails and all what is needed for websites",