@fullstackunicorn/websites 1.0.3 → 1.0.5

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
@@ -97,6 +97,7 @@ class Images {
97
97
  }
98
98
 
99
99
  generate = async ({ file, asset }) => {
100
+
100
101
  const picture = await this.getPicture({ file, asset })
101
102
  const pictureData = await this.getPictureData({ picture })
102
103
 
@@ -117,17 +118,20 @@ class Images {
117
118
 
118
119
  const created = []
119
120
  for (const entry of Object.entries(this.widths)) {
120
- if (pictureData.x <= entry[1]) continue
121
121
 
122
- const buffer = await this.getBuffer({ picture, entry })
122
+ const key = entry[0]
123
+ const w = entry[1]
124
+
125
+ if (pictureData.x < w) continue
126
+
123
127
  const thumbPath = this.getPathThumbnail({ picture, entry })
124
128
 
125
- // thumbnail
126
- this.appendFile(result, entry[0], {
127
- path: thumbPath,
128
- file: buffer
129
- })
130
- created.push(entry[0])
129
+ let buffer
130
+ if (pictureData.x === w) buffer = originalBuffer
131
+ else buffer = await this.getBuffer({ picture, entry })
132
+
133
+ this.appendFile(result, key, { path: thumbPath, file: buffer })
134
+ created.push(key)
131
135
  }
132
136
 
133
137
  F3.logs('✅ Created: ', created.join(' '))
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.3",
2
+ "version": "1.0.5",
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",