@graphcommerce/image 3.1.4 → 3.1.7
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/CHANGELOG.md +25 -0
- package/components/Image.tsx +13 -14
- package/package.json +9 -9
- package/types.d.ts +0 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 3.1.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1490](https://github.com/graphcommerce-org/graphcommerce/pull/1490) [`d311ef48b`](https://github.com/graphcommerce-org/graphcommerce/commit/d311ef48bb3e97806d992af5516d6b7f183ec9cb) Thanks [@paales](https://github.com/paales)! - upgraded packages
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`d311ef48b`](https://github.com/graphcommerce-org/graphcommerce/commit/d311ef48bb3e97806d992af5516d6b7f183ec9cb)]:
|
|
10
|
+
- @graphcommerce/framer-utils@3.1.4
|
|
11
|
+
|
|
12
|
+
## 3.1.6
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [[`f167f9963`](https://github.com/graphcommerce-org/graphcommerce/commit/f167f99630966a7de43717937d43669e66132494)]:
|
|
17
|
+
- @graphcommerce/framer-utils@3.1.3
|
|
18
|
+
|
|
19
|
+
## 3.1.5
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#1399](https://github.com/graphcommerce-org/graphcommerce/pull/1399) [`da0ae7d02`](https://github.com/graphcommerce-org/graphcommerce/commit/da0ae7d0236e4908ba0bf0fa16656be516e841d4) Thanks [@paales](https://github.com/paales)! - Updated dependencies
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`da0ae7d02`](https://github.com/graphcommerce-org/graphcommerce/commit/da0ae7d0236e4908ba0bf0fa16656be516e841d4)]:
|
|
26
|
+
- @graphcommerce/framer-utils@3.1.2
|
|
27
|
+
|
|
3
28
|
## 3.1.4
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/components/Image.tsx
CHANGED
|
@@ -27,11 +27,13 @@ import {
|
|
|
27
27
|
|
|
28
28
|
if (typeof window === 'undefined') {
|
|
29
29
|
// eslint-disable-next-line no-underscore-dangle
|
|
30
|
-
global.__NEXT_IMAGE_IMPORTED = true
|
|
30
|
+
;(global as any).__NEXT_IMAGE_IMPORTED = true
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export type { ImageLoaderProps, ImageLoader }
|
|
34
34
|
|
|
35
|
+
type ImageConfig = ImageConfigComplete & { allSizes: number[] }
|
|
36
|
+
|
|
35
37
|
const DEFAULT_SIZES: SizesRecord = { 0: '100vw', 1200: '50vw' }
|
|
36
38
|
|
|
37
39
|
const VALID_LOADING_VALUES = ['lazy', 'eager', undefined] as const
|
|
@@ -84,7 +86,7 @@ export function srcToString(src: StaticImport | string) {
|
|
|
84
86
|
// allSizes.sort((a, b) => a - b)
|
|
85
87
|
|
|
86
88
|
function getWidths(
|
|
87
|
-
config:
|
|
89
|
+
config: ImageConfig,
|
|
88
90
|
width: number | undefined,
|
|
89
91
|
layout: LayoutValue,
|
|
90
92
|
sizes = '',
|
|
@@ -138,7 +140,7 @@ type GenImgAttrsData = {
|
|
|
138
140
|
quality?: number
|
|
139
141
|
sizes: string
|
|
140
142
|
scale: number
|
|
141
|
-
config:
|
|
143
|
+
config: ImageConfig
|
|
142
144
|
}
|
|
143
145
|
|
|
144
146
|
function generateSrcSet(props: GenImgAttrsData): string {
|
|
@@ -148,7 +150,7 @@ function generateSrcSet(props: GenImgAttrsData): string {
|
|
|
148
150
|
return widths
|
|
149
151
|
.map(
|
|
150
152
|
(w, i) =>
|
|
151
|
-
`${loader({ src, quality, width: w
|
|
153
|
+
`${loader({ src, quality, width: w })} ${
|
|
152
154
|
kind === 'w' ? Math.round(w * scale) : i + 1
|
|
153
155
|
}${kind}`,
|
|
154
156
|
)
|
|
@@ -266,7 +268,7 @@ const Image = React.forwardRef<HTMLImageElement, ImageProps>(
|
|
|
266
268
|
const combinedRef = useForkRef(ref, forwardedRef)
|
|
267
269
|
|
|
268
270
|
const configContext = useContext(ImageConfigContext)
|
|
269
|
-
const config:
|
|
271
|
+
const config: ImageConfig = useMemo(() => {
|
|
270
272
|
const c = configEnv || configContext || imageConfigDefault
|
|
271
273
|
const allSizes = [...c.deviceSizes, ...c.imageSizes].sort((a, b) => a - b)
|
|
272
274
|
const deviceSizes = c.deviceSizes.sort((a, b) => a - b)
|
|
@@ -528,27 +530,24 @@ const Image = React.forwardRef<HTMLImageElement, ImageProps>(
|
|
|
528
530
|
rel='preload'
|
|
529
531
|
as='image'
|
|
530
532
|
media='(-webkit-min-device-pixel-ratio: 2.5)'
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
imagesizes={sizes}
|
|
533
|
+
imageSrcSet={srcSet3x}
|
|
534
|
+
imageSizes={sizes}
|
|
534
535
|
/>
|
|
535
536
|
<link
|
|
536
537
|
key={`img-${srcSet2x}${sizes}`}
|
|
537
538
|
rel='preload'
|
|
538
539
|
as='image'
|
|
539
540
|
media='(-webkit-min-device-pixel-ratio: 1.5) and (-webkit-max-device-pixel-ratio: 2.49)'
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
imagesizes={sizes}
|
|
541
|
+
imageSrcSet={srcSet2x}
|
|
542
|
+
imageSizes={sizes}
|
|
543
543
|
/>
|
|
544
544
|
<link
|
|
545
545
|
key={`img-${srcSet1x}${sizes}`}
|
|
546
546
|
rel='preload'
|
|
547
547
|
as='image'
|
|
548
548
|
media='(-webkit-max-device-pixel-ratio: 1.49)'
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
imagesizes={sizes}
|
|
549
|
+
imageSrcSet={srcSet1x}
|
|
550
|
+
imageSizes={sizes}
|
|
552
551
|
/>
|
|
553
552
|
</>
|
|
554
553
|
)}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/image",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "3.1.
|
|
5
|
+
"version": "3.1.7",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "tsc -W"
|
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@graphcommerce/framer-utils": "3.1.
|
|
18
|
+
"@graphcommerce/framer-utils": "3.1.4"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@graphcommerce/eslint-config-pwa": "^4.1.
|
|
22
|
-
"@graphcommerce/prettier-config-pwa": "^4.0.
|
|
21
|
+
"@graphcommerce/eslint-config-pwa": "^4.1.8",
|
|
22
|
+
"@graphcommerce/prettier-config-pwa": "^4.0.6",
|
|
23
23
|
"@graphcommerce/typescript-config-pwa": "^4.0.2",
|
|
24
|
-
"@playwright/test": "^1.
|
|
25
|
-
"type-fest": "2.12.
|
|
24
|
+
"@playwright/test": "^1.21.1",
|
|
25
|
+
"type-fest": "^2.12.2"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@mui/material": "5.5.3",
|
|
29
|
-
"next": "12.1.2",
|
|
30
|
-
"react": "^
|
|
31
|
-
"react-dom": "^
|
|
29
|
+
"next": "^12.1.2",
|
|
30
|
+
"react": "^18.0.0",
|
|
31
|
+
"react-dom": "^18.0.0"
|
|
32
32
|
}
|
|
33
33
|
}
|