@graphcommerce/image 9.1.0-canary.53 → 9.1.0-canary.55

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.1.0-canary.55
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2539](https://github.com/graphcommerce-org/graphcommerce/pull/2539) [`76adc6f`](https://github.com/graphcommerce-org/graphcommerce/commit/76adc6f6a5f76eb58998cef36f11a6a899a5e6ac) - Export generateSrcSet from Image component so it can be used for the avatar srcSet directly ([@paales](https://github.com/paales))
8
+
9
+ ## 9.1.0-canary.54
10
+
3
11
  ## 9.1.0-canary.53
4
12
 
5
13
  ## 9.1.0-canary.52
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-use-before-define */
1
2
  /* eslint-disable @typescript-eslint/no-restricted-imports */
2
3
 
3
4
  /* eslint-disable prefer-const */
@@ -142,16 +143,31 @@ function getWidths(
142
143
  type GenImgAttrsData = {
143
144
  src: string
144
145
  layout: LayoutValue
145
- loader: ImageLoaderWithConfig
146
+ loader?: ImageLoaderWithConfig
146
147
  width?: number
147
148
  quality?: number
148
149
  sizes: string
149
150
  scale: number
150
- config: ImageConfig
151
+ config?: ImageConfig
151
152
  }
152
153
 
153
- function generateSrcSet(props: GenImgAttrsData): string {
154
- const { src, layout, width, quality = 52, sizes, loader, scale, config } = props
154
+ export function generateSrcSet(props: GenImgAttrsData): string {
155
+ const defaultConfig = {
156
+ ...imageConfigEnv,
157
+ allSizes: [...imageConfigEnv.deviceSizes, ...imageConfigEnv.imageSizes].sort((a, b) => a - b),
158
+ deviceSizes: imageConfigEnv.deviceSizes.sort((a, b) => a - b),
159
+ }
160
+ const {
161
+ src,
162
+ layout,
163
+ width,
164
+ quality = 52,
165
+ sizes,
166
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
167
+ loader = defaultImageLoader,
168
+ scale,
169
+ config = defaultConfig,
170
+ } = props
155
171
  const { widths, kind } = getWidths(config, width, layout, sizes)
156
172
 
157
173
  return `${widths
@@ -249,7 +265,7 @@ const Img = styled('img')({})
249
265
  const Picture = styled('picture')({})
250
266
 
251
267
  // eslint-disable-next-line no-underscore-dangle
252
- const configEnv = process.env.__NEXT_IMAGE_OPTS as unknown as ImageConfigComplete
268
+ export const imageConfigEnv = process.env.__NEXT_IMAGE_OPTS as unknown as ImageConfigComplete
253
269
 
254
270
  const Image = React.forwardRef<HTMLImageElement, ImageProps>(
255
271
  (
@@ -278,7 +294,7 @@ const Image = React.forwardRef<HTMLImageElement, ImageProps>(
278
294
 
279
295
  const configContext = useContext(ImageConfigContext)
280
296
  const config: ImageConfig = useMemo(() => {
281
- const c = configEnv || configContext || imageConfigDefault
297
+ const c = imageConfigEnv || configContext || imageConfigDefault
282
298
  const allSizes = [...c.deviceSizes, ...c.imageSizes].sort((a, b) => a - b)
283
299
  const deviceSizes = c.deviceSizes.sort((a, b) => a - b)
284
300
  return { ...c, allSizes, deviceSizes }
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": "9.1.0-canary.53",
5
+ "version": "9.1.0-canary.55",
6
6
  "sideEffects": false,
7
7
  "scripts": {
8
8
  "dev": "tsc -W"
@@ -15,10 +15,10 @@
15
15
  }
16
16
  },
17
17
  "peerDependencies": {
18
- "@graphcommerce/eslint-config-pwa": "^9.1.0-canary.53",
19
- "@graphcommerce/framer-utils": "^9.1.0-canary.53",
20
- "@graphcommerce/prettier-config-pwa": "^9.1.0-canary.53",
21
- "@graphcommerce/typescript-config-pwa": "^9.1.0-canary.53",
18
+ "@graphcommerce/eslint-config-pwa": "^9.1.0-canary.55",
19
+ "@graphcommerce/framer-utils": "^9.1.0-canary.55",
20
+ "@graphcommerce/prettier-config-pwa": "^9.1.0-canary.55",
21
+ "@graphcommerce/typescript-config-pwa": "^9.1.0-canary.55",
22
22
  "@mui/material": "^5.10.16",
23
23
  "next": "*",
24
24
  "react": "^18.2.0",