@usequeek/theme-kit 0.5.4 → 0.5.6

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/index.ts CHANGED
@@ -34,6 +34,8 @@ export * from './types/order';
34
34
  export * from './types/page';
35
35
  export * from './types/menu';
36
36
  export * from './types/media';
37
+ // Which image tier a surface renders (`resolveImageSources`) and a store logo's url (`logoSrc`): pure, server-safe.
38
+ export * from './utils/image-srcset';
37
39
  export * from './utils/format';
38
40
  export * from './utils/markdown';
39
41
  export * from './utils/menu-link';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usequeek/theme-kit",
3
- "version": "0.5.4",
3
+ "version": "0.5.6",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "The runtime a Queek storefront theme is built on: hooks, stores, page renderer, navigation, shared blocks and locale strings.",
@@ -201,12 +201,19 @@ export function resolveImageSources(
201
201
  * (a 2048 px JPG of 139 KB is a 38 KB WebP). Never a smaller tier: a wide wordmark
202
202
  * on a 3x phone would come out softer than the upload it replaces. The raw `url`
203
203
  * when there is no `view` copy, no copies at all (an SVG, an off-host file) or
204
- * copies of a different file.
204
+ * copies of a different file, and when the upload is already a WebP no wider than
205
+ * `view`: the copy is then the same picture re-encoded, and often heavier (an 8 KB
206
+ * wordmark's `view` is 9.6 KB).
205
207
  */
206
208
  export function logoSrc(url: string | null | undefined, variants: ImageVariants | null | undefined): string | null {
207
209
  if (!url) {
208
210
  return null;
209
211
  }
210
- const view = variants && variants.original?.url === url ? variants.view : null;
211
- return usableTier(view) ? view.url : url;
212
+ const original = variants?.original;
213
+ const view = variants && original?.url === url ? variants.view : null;
214
+ if (!usableTier(view)) {
215
+ return url;
216
+ }
217
+ const samePixels = typeof view.w === 'number' && typeof original?.w === 'number' && view.w >= original.w;
218
+ return samePixels && /\.webp(?:[?#]|$)/i.test(url) ? url : view.url;
212
219
  }