@fullstackunicorn/websites 1.0.2 → 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.
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/modules/images.js CHANGED
@@ -25,20 +25,20 @@ class Images {
25
25
  }
26
26
 
27
27
  getPicture = async ({ file, asset }) => {
28
+
28
29
  const picture = {}
29
30
  const pathParsed = path.parse(file.path)
30
- if (!pathParsed.dir) F3.throw('no-picture-dir', file.path)
31
31
 
32
- picture.dir = pathParsed.dir || ''
32
+ picture.dir = pathParsed.dir ? `${pathParsed.dir}/` : ''
33
+
33
34
  picture.original = pathParsed.base
34
35
  picture.ext = this.getExtension(pathParsed)
35
36
  picture.base = sharp(file.buffer)
36
37
  picture.name = pathParsed.name
38
+ picture.src = `${asset}/${picture.dir}TS/${picture.name}${picture.ext}`
37
39
 
38
- picture.src = `${asset}/${picture.dir}/TS/${picture.name}${picture.ext}`
39
-
40
- picture.pathJson = `${picture.dir}/${picture.name}.json`.replace(/^\/+/, '')
41
- picture.pathImg = `${picture.dir}/${picture.name}${picture.ext}`.replace(/^\/+/, '')
40
+ picture.pathJson = `${picture.dir}${picture.name}.json`.replace(/^\/+/, '')
41
+ picture.pathImg = `${picture.dir}${picture.name}${picture.ext}`.replace(/^\/+/, '')
42
42
 
43
43
  return picture
44
44
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.2",
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",