@shopify/hydrogen-react 2023.1.7 → 2023.4.0

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.
Files changed (261) hide show
  1. package/dist/browser-dev/CartProvider.mjs.map +1 -1
  2. package/dist/browser-dev/Image.mjs +336 -90
  3. package/dist/browser-dev/Image.mjs.map +1 -1
  4. package/dist/browser-dev/MediaFile.mjs.map +1 -1
  5. package/dist/browser-dev/ModelViewer.mjs.map +1 -1
  6. package/dist/browser-dev/Money.mjs.map +1 -1
  7. package/dist/browser-dev/ProductProvider.mjs +2 -2
  8. package/dist/browser-dev/ProductProvider.mjs.map +1 -1
  9. package/dist/browser-dev/Video.mjs +2 -2
  10. package/dist/browser-dev/Video.mjs.map +1 -1
  11. package/dist/browser-dev/analytics-utils.mjs +1 -1
  12. package/dist/browser-dev/analytics-utils.mjs.map +1 -1
  13. package/dist/browser-dev/index.mjs +2 -3
  14. package/dist/browser-dev/index.mjs.map +1 -1
  15. package/dist/browser-dev/node_modules/@xstate/react/es/useConstant.mjs +2 -2
  16. package/dist/browser-dev/node_modules/@xstate/react/es/useConstant.mjs.map +1 -1
  17. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +2 -2
  18. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +2 -2
  19. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  20. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +2 -2
  21. package/dist/browser-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +2 -2
  22. package/dist/browser-dev/storefront-api-constants.mjs +1 -1
  23. package/dist/browser-dev/storefront-api-constants.mjs.map +1 -1
  24. package/dist/browser-dev/useCartAPIStateMachine.mjs.map +1 -1
  25. package/dist/browser-dev/useCartActions.mjs.map +1 -1
  26. package/dist/browser-prod/CartProvider.mjs.map +1 -1
  27. package/dist/browser-prod/Image.mjs +302 -82
  28. package/dist/browser-prod/Image.mjs.map +1 -1
  29. package/dist/browser-prod/MediaFile.mjs.map +1 -1
  30. package/dist/browser-prod/ModelViewer.mjs.map +1 -1
  31. package/dist/browser-prod/Money.mjs.map +1 -1
  32. package/dist/browser-prod/ProductProvider.mjs +2 -2
  33. package/dist/browser-prod/ProductProvider.mjs.map +1 -1
  34. package/dist/browser-prod/Video.mjs +2 -2
  35. package/dist/browser-prod/Video.mjs.map +1 -1
  36. package/dist/browser-prod/analytics-utils.mjs +1 -1
  37. package/dist/browser-prod/analytics-utils.mjs.map +1 -1
  38. package/dist/browser-prod/index.mjs +2 -3
  39. package/dist/browser-prod/index.mjs.map +1 -1
  40. package/dist/browser-prod/node_modules/@xstate/react/es/useConstant.mjs +2 -2
  41. package/dist/browser-prod/node_modules/@xstate/react/es/useConstant.mjs.map +1 -1
  42. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +2 -2
  43. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +2 -2
  44. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  45. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +2 -2
  46. package/dist/browser-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +2 -2
  47. package/dist/browser-prod/storefront-api-constants.mjs +1 -1
  48. package/dist/browser-prod/storefront-api-constants.mjs.map +1 -1
  49. package/dist/browser-prod/useCartAPIStateMachine.mjs.map +1 -1
  50. package/dist/browser-prod/useCartActions.mjs.map +1 -1
  51. package/dist/node-dev/AddToCartButton.js +4 -4
  52. package/dist/node-dev/AddToCartButton.js.map +1 -1
  53. package/dist/node-dev/BaseButton.js +2 -2
  54. package/dist/node-dev/BaseButton.js.map +1 -1
  55. package/dist/node-dev/BuyNowButton.js +4 -4
  56. package/dist/node-dev/BuyNowButton.js.map +1 -1
  57. package/dist/node-dev/CartCheckoutButton.js +3 -3
  58. package/dist/node-dev/CartCheckoutButton.js.map +1 -1
  59. package/dist/node-dev/CartLineProvider.js +3 -3
  60. package/dist/node-dev/CartLineProvider.js.map +1 -1
  61. package/dist/node-dev/CartLineQuantityAdjustButton.js +2 -2
  62. package/dist/node-dev/CartLineQuantityAdjustButton.js.map +1 -1
  63. package/dist/node-dev/CartProvider.js +20 -20
  64. package/dist/node-dev/CartProvider.js.map +1 -1
  65. package/dist/node-dev/CartProvider.mjs.map +1 -1
  66. package/dist/node-dev/Image.js +350 -87
  67. package/dist/node-dev/Image.js.map +1 -1
  68. package/dist/node-dev/Image.mjs +336 -90
  69. package/dist/node-dev/Image.mjs.map +1 -1
  70. package/dist/node-dev/MediaFile.js.map +1 -1
  71. package/dist/node-dev/MediaFile.mjs.map +1 -1
  72. package/dist/node-dev/ModelViewer.js +4 -4
  73. package/dist/node-dev/ModelViewer.js.map +1 -1
  74. package/dist/node-dev/ModelViewer.mjs.map +1 -1
  75. package/dist/node-dev/Money.js.map +1 -1
  76. package/dist/node-dev/Money.mjs.map +1 -1
  77. package/dist/node-dev/ProductProvider.js +16 -16
  78. package/dist/node-dev/ProductProvider.js.map +1 -1
  79. package/dist/node-dev/ProductProvider.mjs +2 -2
  80. package/dist/node-dev/ProductProvider.mjs.map +1 -1
  81. package/dist/node-dev/ShopifyProvider.js +4 -4
  82. package/dist/node-dev/ShopifyProvider.js.map +1 -1
  83. package/dist/node-dev/Video.js +4 -4
  84. package/dist/node-dev/Video.js.map +1 -1
  85. package/dist/node-dev/Video.mjs +2 -2
  86. package/dist/node-dev/Video.mjs.map +1 -1
  87. package/dist/node-dev/analytics-utils.js +1 -1
  88. package/dist/node-dev/analytics-utils.js.map +1 -1
  89. package/dist/node-dev/analytics-utils.mjs +1 -1
  90. package/dist/node-dev/analytics-utils.mjs.map +1 -1
  91. package/dist/node-dev/cart-hooks.js +2 -2
  92. package/dist/node-dev/cart-hooks.js.map +1 -1
  93. package/dist/node-dev/index.js +1 -2
  94. package/dist/node-dev/index.js.map +1 -1
  95. package/dist/node-dev/index.mjs +2 -3
  96. package/dist/node-dev/index.mjs.map +1 -1
  97. package/dist/node-dev/load-script.js +3 -3
  98. package/dist/node-dev/load-script.js.map +1 -1
  99. package/dist/node-dev/node_modules/@xstate/react/es/fsm.js +6 -6
  100. package/dist/node-dev/node_modules/@xstate/react/es/fsm.js.map +1 -1
  101. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js +3 -3
  102. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  103. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.mjs +2 -2
  104. package/dist/node-dev/node_modules/@xstate/react/es/useConstant.mjs.map +1 -1
  105. package/dist/node-dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js +2 -2
  106. package/dist/node-dev/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js.map +1 -1
  107. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +3 -3
  108. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  109. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +2 -2
  110. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -2
  111. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
  112. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +2 -2
  113. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  114. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +6 -6
  115. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  116. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +2 -2
  117. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -2
  118. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  119. package/dist/node-dev/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +2 -2
  120. package/dist/node-dev/storefront-api-constants.js +1 -1
  121. package/dist/node-dev/storefront-api-constants.js.map +1 -1
  122. package/dist/node-dev/storefront-api-constants.mjs +1 -1
  123. package/dist/node-dev/storefront-api-constants.mjs.map +1 -1
  124. package/dist/node-dev/useCartAPIStateMachine.js +3 -3
  125. package/dist/node-dev/useCartAPIStateMachine.js.map +1 -1
  126. package/dist/node-dev/useCartAPIStateMachine.mjs.map +1 -1
  127. package/dist/node-dev/useCartActions.js +11 -11
  128. package/dist/node-dev/useCartActions.js.map +1 -1
  129. package/dist/node-dev/useCartActions.mjs.map +1 -1
  130. package/dist/node-dev/useMoney.js +5 -5
  131. package/dist/node-dev/useMoney.js.map +1 -1
  132. package/dist/node-dev/useShopifyCookies.js +2 -2
  133. package/dist/node-dev/useShopifyCookies.js.map +1 -1
  134. package/dist/node-prod/AddToCartButton.js +4 -4
  135. package/dist/node-prod/AddToCartButton.js.map +1 -1
  136. package/dist/node-prod/BaseButton.js +2 -2
  137. package/dist/node-prod/BaseButton.js.map +1 -1
  138. package/dist/node-prod/BuyNowButton.js +4 -4
  139. package/dist/node-prod/BuyNowButton.js.map +1 -1
  140. package/dist/node-prod/CartCheckoutButton.js +3 -3
  141. package/dist/node-prod/CartCheckoutButton.js.map +1 -1
  142. package/dist/node-prod/CartLineProvider.js +3 -3
  143. package/dist/node-prod/CartLineProvider.js.map +1 -1
  144. package/dist/node-prod/CartLineQuantityAdjustButton.js +2 -2
  145. package/dist/node-prod/CartLineQuantityAdjustButton.js.map +1 -1
  146. package/dist/node-prod/CartProvider.js +20 -20
  147. package/dist/node-prod/CartProvider.js.map +1 -1
  148. package/dist/node-prod/CartProvider.mjs.map +1 -1
  149. package/dist/node-prod/Image.js +317 -80
  150. package/dist/node-prod/Image.js.map +1 -1
  151. package/dist/node-prod/Image.mjs +302 -82
  152. package/dist/node-prod/Image.mjs.map +1 -1
  153. package/dist/node-prod/MediaFile.js.map +1 -1
  154. package/dist/node-prod/MediaFile.mjs.map +1 -1
  155. package/dist/node-prod/ModelViewer.js +4 -4
  156. package/dist/node-prod/ModelViewer.js.map +1 -1
  157. package/dist/node-prod/ModelViewer.mjs.map +1 -1
  158. package/dist/node-prod/Money.js.map +1 -1
  159. package/dist/node-prod/Money.mjs.map +1 -1
  160. package/dist/node-prod/ProductProvider.js +16 -16
  161. package/dist/node-prod/ProductProvider.js.map +1 -1
  162. package/dist/node-prod/ProductProvider.mjs +2 -2
  163. package/dist/node-prod/ProductProvider.mjs.map +1 -1
  164. package/dist/node-prod/ShopifyProvider.js +4 -4
  165. package/dist/node-prod/ShopifyProvider.js.map +1 -1
  166. package/dist/node-prod/Video.js +4 -4
  167. package/dist/node-prod/Video.js.map +1 -1
  168. package/dist/node-prod/Video.mjs +2 -2
  169. package/dist/node-prod/Video.mjs.map +1 -1
  170. package/dist/node-prod/analytics-utils.js +1 -1
  171. package/dist/node-prod/analytics-utils.js.map +1 -1
  172. package/dist/node-prod/analytics-utils.mjs +1 -1
  173. package/dist/node-prod/analytics-utils.mjs.map +1 -1
  174. package/dist/node-prod/cart-hooks.js +2 -2
  175. package/dist/node-prod/cart-hooks.js.map +1 -1
  176. package/dist/node-prod/index.js +1 -2
  177. package/dist/node-prod/index.js.map +1 -1
  178. package/dist/node-prod/index.mjs +2 -3
  179. package/dist/node-prod/index.mjs.map +1 -1
  180. package/dist/node-prod/load-script.js +3 -3
  181. package/dist/node-prod/load-script.js.map +1 -1
  182. package/dist/node-prod/node_modules/@xstate/react/es/fsm.js +6 -6
  183. package/dist/node-prod/node_modules/@xstate/react/es/fsm.js.map +1 -1
  184. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js +3 -3
  185. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.js.map +1 -1
  186. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.mjs +2 -2
  187. package/dist/node-prod/node_modules/@xstate/react/es/useConstant.mjs.map +1 -1
  188. package/dist/node-prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js +2 -2
  189. package/dist/node-prod/node_modules/use-isomorphic-layout-effect/dist/use-isomorphic-layout-effect.esm.js.map +1 -1
  190. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +3 -3
  191. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js.map +1 -1
  192. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.mjs +2 -2
  193. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js +2 -2
  194. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js.map +1 -1
  195. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs +2 -2
  196. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.mjs.map +1 -1
  197. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +6 -6
  198. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js.map +1 -1
  199. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.mjs +2 -2
  200. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js +2 -2
  201. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js.map +1 -1
  202. package/dist/node-prod/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.mjs +2 -2
  203. package/dist/node-prod/storefront-api-constants.js +1 -1
  204. package/dist/node-prod/storefront-api-constants.js.map +1 -1
  205. package/dist/node-prod/storefront-api-constants.mjs +1 -1
  206. package/dist/node-prod/storefront-api-constants.mjs.map +1 -1
  207. package/dist/node-prod/useCartAPIStateMachine.js +3 -3
  208. package/dist/node-prod/useCartAPIStateMachine.js.map +1 -1
  209. package/dist/node-prod/useCartAPIStateMachine.mjs.map +1 -1
  210. package/dist/node-prod/useCartActions.js +11 -11
  211. package/dist/node-prod/useCartActions.js.map +1 -1
  212. package/dist/node-prod/useCartActions.mjs.map +1 -1
  213. package/dist/node-prod/useMoney.js +5 -5
  214. package/dist/node-prod/useMoney.js.map +1 -1
  215. package/dist/node-prod/useShopifyCookies.js +2 -2
  216. package/dist/node-prod/useShopifyCookies.js.map +1 -1
  217. package/dist/types/CartProvider.d.ts +4 -2
  218. package/dist/types/Image.d.ts +235 -38
  219. package/dist/types/MediaFile.d.ts +2 -2
  220. package/dist/types/ModelViewer.d.ts +1 -1
  221. package/dist/types/Money.d.ts +1 -1
  222. package/dist/types/ProductProvider.d.ts +8 -4
  223. package/dist/types/Video.d.ts +3 -3
  224. package/dist/types/index.d.cts +1 -2
  225. package/dist/types/index.d.ts +1 -2
  226. package/dist/types/storefront-api-constants.d.ts +1 -1
  227. package/dist/types/storefront-api-types.d.ts +862 -118
  228. package/dist/types/useCartAPIStateMachine.d.ts +2 -2
  229. package/dist/types/useCartActions.d.ts +2 -2
  230. package/dist/umd/hydrogen-react.dev.js +334 -182
  231. package/dist/umd/hydrogen-react.dev.js.map +1 -1
  232. package/dist/umd/hydrogen-react.prod.js +22 -15
  233. package/dist/umd/hydrogen-react.prod.js.map +1 -1
  234. package/package.json +2 -2
  235. package/storefront.schema.json +1 -1
  236. package/dist/browser-dev/CartLinePrice.mjs +0 -21
  237. package/dist/browser-dev/CartLinePrice.mjs.map +0 -1
  238. package/dist/browser-dev/image-size.mjs +0 -80
  239. package/dist/browser-dev/image-size.mjs.map +0 -1
  240. package/dist/browser-prod/CartLinePrice.mjs +0 -18
  241. package/dist/browser-prod/CartLinePrice.mjs.map +0 -1
  242. package/dist/browser-prod/image-size.mjs +0 -80
  243. package/dist/browser-prod/image-size.mjs.map +0 -1
  244. package/dist/node-dev/CartLinePrice.js +0 -21
  245. package/dist/node-dev/CartLinePrice.js.map +0 -1
  246. package/dist/node-dev/CartLinePrice.mjs +0 -21
  247. package/dist/node-dev/CartLinePrice.mjs.map +0 -1
  248. package/dist/node-dev/image-size.js +0 -80
  249. package/dist/node-dev/image-size.js.map +0 -1
  250. package/dist/node-dev/image-size.mjs +0 -80
  251. package/dist/node-dev/image-size.mjs.map +0 -1
  252. package/dist/node-prod/CartLinePrice.js +0 -18
  253. package/dist/node-prod/CartLinePrice.js.map +0 -1
  254. package/dist/node-prod/CartLinePrice.mjs +0 -18
  255. package/dist/node-prod/CartLinePrice.mjs.map +0 -1
  256. package/dist/node-prod/image-size.js +0 -80
  257. package/dist/node-prod/image-size.js.map +0 -1
  258. package/dist/node-prod/image-size.mjs +0 -80
  259. package/dist/node-prod/image-size.mjs.map +0 -1
  260. package/dist/types/CartLinePrice.d.ts +0 -31
  261. package/dist/types/image-size.d.ts +0 -36
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const PRODUCTION_CDN_HOSTNAMES = [
4
- "cdn.shopify.com",
5
- "cdn.shopifycdn.net",
6
- "shopify-assets.shopifycdn.com",
7
- "shopify-assets.shopifycdn.net"
8
- ];
9
- const LOCAL_CDN_HOSTNAMES = ["spin.dev"];
10
- const ALL_CDN_HOSTNAMES = [...PRODUCTION_CDN_HOSTNAMES, ...LOCAL_CDN_HOSTNAMES];
11
- const IMG_SRC_SET_SIZES = [352, 832, 1200, 1920, 2560];
12
- function addImageSizeParametersToUrl({
13
- src,
14
- width,
15
- height,
16
- crop,
17
- scale
18
- }) {
19
- const newUrl = new URL(src);
20
- const multipliedScale = scale ?? 1;
21
- if (width) {
22
- let finalWidth;
23
- if (typeof width === "string") {
24
- finalWidth = (IMG_SRC_SET_SIZES[0] * multipliedScale).toString();
25
- } else {
26
- finalWidth = (Number(width) * multipliedScale).toString();
27
- }
28
- newUrl.searchParams.append("width", finalWidth);
29
- }
30
- if (height && typeof height === "number") {
31
- newUrl.searchParams.append("height", (height * multipliedScale).toString());
32
- }
33
- crop && newUrl.searchParams.append("crop", crop);
34
- return newUrl.toString();
35
- }
36
- function shopifyImageLoader(params) {
37
- const newSrc = new URL(params.src);
38
- const isShopifyServedImage = ALL_CDN_HOSTNAMES.some(
39
- (allowedHostname) => newSrc.hostname.endsWith(allowedHostname)
40
- );
41
- if (!isShopifyServedImage || !params.width && !params.height && !params.crop && !params.scale) {
42
- return params.src;
43
- }
44
- return addImageSizeParametersToUrl(params);
45
- }
46
- function getShopifyImageDimensions({
47
- data: sfapiImage,
48
- loaderOptions,
49
- elementProps
50
- }) {
51
- let aspectRatio = null;
52
- if ((sfapiImage == null ? void 0 : sfapiImage.width) && (sfapiImage == null ? void 0 : sfapiImage.height)) {
53
- aspectRatio = (sfapiImage == null ? void 0 : sfapiImage.width) / (sfapiImage == null ? void 0 : sfapiImage.height);
54
- }
55
- if ((loaderOptions == null ? void 0 : loaderOptions.width) || (loaderOptions == null ? void 0 : loaderOptions.height)) {
56
- return {
57
- width: (loaderOptions == null ? void 0 : loaderOptions.width) ?? (aspectRatio && typeof loaderOptions.height === "number" ? Math.round(aspectRatio * loaderOptions.height) : null),
58
- height: (loaderOptions == null ? void 0 : loaderOptions.height) ?? (aspectRatio && typeof loaderOptions.width === "number" ? Math.round(aspectRatio * loaderOptions.width) : null)
59
- };
60
- }
61
- if ((elementProps == null ? void 0 : elementProps.width) || (elementProps == null ? void 0 : elementProps.height)) {
62
- return {
63
- width: (elementProps == null ? void 0 : elementProps.width) ?? (aspectRatio && typeof elementProps.height === "number" ? Math.round(aspectRatio * elementProps.height) : null),
64
- height: (elementProps == null ? void 0 : elementProps.height) ?? (aspectRatio && typeof elementProps.width === "number" ? Math.round(aspectRatio * elementProps.width) : null)
65
- };
66
- }
67
- if ((sfapiImage == null ? void 0 : sfapiImage.width) || (sfapiImage == null ? void 0 : sfapiImage.height)) {
68
- return {
69
- // can't calculate the aspect ratio here
70
- width: (sfapiImage == null ? void 0 : sfapiImage.width) ?? null,
71
- height: (sfapiImage == null ? void 0 : sfapiImage.height) ?? null
72
- };
73
- }
74
- return { width: null, height: null };
75
- }
76
- exports.IMG_SRC_SET_SIZES = IMG_SRC_SET_SIZES;
77
- exports.addImageSizeParametersToUrl = addImageSizeParametersToUrl;
78
- exports.getShopifyImageDimensions = getShopifyImageDimensions;
79
- exports.shopifyImageLoader = shopifyImageLoader;
80
- //# sourceMappingURL=image-size.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image-size.js","sources":["../../src/image-size.ts"],"sourcesContent":["import type {Image as ImageType} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\nimport type {ShopifyLoaderOptions, ShopifyLoaderParams} from './Image.js';\n\n// TODO: Are there other CDNs missing from here?\nconst PRODUCTION_CDN_HOSTNAMES = [\n 'cdn.shopify.com',\n 'cdn.shopifycdn.net',\n 'shopify-assets.shopifycdn.com',\n 'shopify-assets.shopifycdn.net',\n];\nconst LOCAL_CDN_HOSTNAMES = ['spin.dev'];\nconst ALL_CDN_HOSTNAMES = [...PRODUCTION_CDN_HOSTNAMES, ...LOCAL_CDN_HOSTNAMES];\n\n// based on the default width sizes used by the Shopify liquid HTML tag img_tag plus a 2560 width to account for 2k resolutions\n// reference: https://shopify.dev/api/liquid/filters/html-filters#image_tag\nexport const IMG_SRC_SET_SIZES = [352, 832, 1200, 1920, 2560];\n\n/**\n * Adds image size parameters to an image URL hosted by Shopify's CDN\n */\nexport function addImageSizeParametersToUrl({\n src,\n width,\n height,\n crop,\n scale,\n}: ShopifyLoaderParams): string {\n const newUrl = new URL(src);\n\n const multipliedScale = scale ?? 1;\n\n if (width) {\n let finalWidth: string;\n\n if (typeof width === 'string') {\n finalWidth = (IMG_SRC_SET_SIZES[0] * multipliedScale).toString();\n } else {\n finalWidth = (Number(width) * multipliedScale).toString();\n }\n\n newUrl.searchParams.append('width', finalWidth);\n }\n\n if (height && typeof height === 'number') {\n newUrl.searchParams.append('height', (height * multipliedScale).toString());\n }\n\n crop && newUrl.searchParams.append('crop', crop);\n\n // for now we intentionally leave off the scale param, and instead multiple width & height by scale instead\n // scale && newUrl.searchParams.append('scale', scale.toString());\n\n return newUrl.toString();\n}\n\nexport function shopifyImageLoader(\n params: ShopifyLoaderParams,\n): ReturnType<typeof addImageSizeParametersToUrl> {\n const newSrc = new URL(params.src);\n const isShopifyServedImage = ALL_CDN_HOSTNAMES.some((allowedHostname) =>\n newSrc.hostname.endsWith(allowedHostname),\n );\n\n if (\n !isShopifyServedImage ||\n (!params.width && !params.height && !params.crop && !params.scale)\n ) {\n return params.src;\n }\n\n return addImageSizeParametersToUrl(params);\n}\n\ntype HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;\n\nexport type GetShopifyImageDimensionsProps = {\n data: Pick<\n PartialDeep<ImageType, {recurseIntoArrays: true}>,\n 'altText' | 'url' | 'id' | 'width' | 'height'\n >;\n loaderOptions?: ShopifyLoaderOptions;\n elementProps?: {\n width?: HtmlImageProps['width'];\n height?: HtmlImageProps['height'];\n };\n};\n\ntype GetShopifyImageDimensionsPropsReturn = {\n width: number | string | null;\n height: number | string | null;\n};\n\n/**\n * Width and height are determined using the followiing priority list:\n * 1. `loaderOptions`'s width/height\n * 2. `elementProps`'s width/height\n * 3. `data`'s width/height\n *\n * If only one of `width` or `height` are defined, then the other will attempt to be calculated based on the Image's aspect ratio,\n * provided that both `data.width` and `data.height` are available. If not, then the aspect ratio cannot be determined and the missing\n * value will reamin as `null`\n */\nexport function getShopifyImageDimensions({\n data: sfapiImage,\n loaderOptions,\n elementProps,\n}: GetShopifyImageDimensionsProps): GetShopifyImageDimensionsPropsReturn {\n let aspectRatio: number | null = null;\n\n if (sfapiImage?.width && sfapiImage?.height) {\n aspectRatio = sfapiImage?.width / sfapiImage?.height;\n }\n\n // * 1. `loaderOptions`'s width/height\n if (loaderOptions?.width || loaderOptions?.height) {\n return {\n width:\n loaderOptions?.width ??\n (aspectRatio && typeof loaderOptions.height === 'number'\n ? Math.round(aspectRatio * loaderOptions.height)\n : null),\n height:\n loaderOptions?.height ??\n (aspectRatio && typeof loaderOptions.width === 'number'\n ? Math.round(aspectRatio * loaderOptions.width)\n : null),\n };\n }\n\n // * 2. `elementProps`'s width/height\n if (elementProps?.width || elementProps?.height) {\n return {\n width:\n elementProps?.width ??\n (aspectRatio && typeof elementProps.height === 'number'\n ? Math.round(aspectRatio * elementProps.height)\n : null),\n height:\n elementProps?.height ??\n (aspectRatio && typeof elementProps.width === 'number'\n ? Math.round(aspectRatio * elementProps.width)\n : null),\n };\n }\n\n // * 3. `data`'s width/height\n if (sfapiImage?.width || sfapiImage?.height) {\n return {\n // can't calculate the aspect ratio here\n width: sfapiImage?.width ?? null,\n height: sfapiImage?.height ?? null,\n };\n }\n\n return {width: null, height: null};\n}\n"],"names":[],"mappings":";;AAKA,MAAM,2BAA2B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,sBAAsB,CAAC,UAAU;AACvC,MAAM,oBAAoB,CAAC,GAAG,0BAA0B,GAAG,mBAAmB;AAIvE,MAAM,oBAAoB,CAAC,KAAK,KAAK,MAAM,MAAM,IAAI;AAKrD,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAgC;AACxB,QAAA,SAAS,IAAI,IAAI,GAAG;AAE1B,QAAM,kBAAkB,SAAS;AAEjC,MAAI,OAAO;AACL,QAAA;AAEA,QAAA,OAAO,UAAU,UAAU;AAC7B,oBAAc,kBAAkB,CAAC,IAAI,iBAAiB,SAAS;AAAA,IAAA,OAC1D;AACL,oBAAc,OAAO,KAAK,IAAI,iBAAiB,SAAS;AAAA,IAC1D;AAEO,WAAA,aAAa,OAAO,SAAS,UAAU;AAAA,EAChD;AAEI,MAAA,UAAU,OAAO,WAAW,UAAU;AACxC,WAAO,aAAa,OAAO,WAAW,SAAS,iBAAiB,UAAU;AAAA,EAC5E;AAEA,UAAQ,OAAO,aAAa,OAAO,QAAQ,IAAI;AAK/C,SAAO,OAAO;AAChB;AAEO,SAAS,mBACd,QACgD;AAChD,QAAM,SAAS,IAAI,IAAI,OAAO,GAAG;AACjC,QAAM,uBAAuB,kBAAkB;AAAA,IAAK,CAAC,oBACnD,OAAO,SAAS,SAAS,eAAe;AAAA,EAAA;AAG1C,MACE,CAAC,wBACA,CAAC,OAAO,SAAS,CAAC,OAAO,UAAU,CAAC,OAAO,QAAQ,CAAC,OAAO,OAC5D;AACA,WAAO,OAAO;AAAA,EAChB;AAEA,SAAO,4BAA4B,MAAM;AAC3C;AA+BO,SAAS,0BAA0B;AAAA,EACxC,MAAM;AAAA,EACN;AAAA,EACA;AACF,GAAyE;AACvE,MAAI,cAA6B;AAE7B,OAAA,yCAAY,WAAS,yCAAY,SAAQ;AAC7B,mBAAA,yCAAY,UAAQ,yCAAY;AAAA,EAChD;AAGI,OAAA,+CAAe,WAAS,+CAAe,SAAQ;AAC1C,WAAA;AAAA,MACL,QACE,+CAAe,WACd,eAAe,OAAO,cAAc,WAAW,WAC5C,KAAK,MAAM,cAAc,cAAc,MAAM,IAC7C;AAAA,MACN,SACE,+CAAe,YACd,eAAe,OAAO,cAAc,UAAU,WAC3C,KAAK,MAAM,cAAc,cAAc,KAAK,IAC5C;AAAA,IAAA;AAAA,EAEV;AAGI,OAAA,6CAAc,WAAS,6CAAc,SAAQ;AACxC,WAAA;AAAA,MACL,QACE,6CAAc,WACb,eAAe,OAAO,aAAa,WAAW,WAC3C,KAAK,MAAM,cAAc,aAAa,MAAM,IAC5C;AAAA,MACN,SACE,6CAAc,YACb,eAAe,OAAO,aAAa,UAAU,WAC1C,KAAK,MAAM,cAAc,aAAa,KAAK,IAC3C;AAAA,IAAA;AAAA,EAEV;AAGI,OAAA,yCAAY,WAAS,yCAAY,SAAQ;AACpC,WAAA;AAAA;AAAA,MAEL,QAAO,yCAAY,UAAS;AAAA,MAC5B,SAAQ,yCAAY,WAAU;AAAA,IAAA;AAAA,EAElC;AAEA,SAAO,EAAC,OAAO,MAAM,QAAQ,KAAI;AACnC;;;;;"}
@@ -1,80 +0,0 @@
1
- const PRODUCTION_CDN_HOSTNAMES = [
2
- "cdn.shopify.com",
3
- "cdn.shopifycdn.net",
4
- "shopify-assets.shopifycdn.com",
5
- "shopify-assets.shopifycdn.net"
6
- ];
7
- const LOCAL_CDN_HOSTNAMES = ["spin.dev"];
8
- const ALL_CDN_HOSTNAMES = [...PRODUCTION_CDN_HOSTNAMES, ...LOCAL_CDN_HOSTNAMES];
9
- const IMG_SRC_SET_SIZES = [352, 832, 1200, 1920, 2560];
10
- function addImageSizeParametersToUrl({
11
- src,
12
- width,
13
- height,
14
- crop,
15
- scale
16
- }) {
17
- const newUrl = new URL(src);
18
- const multipliedScale = scale ?? 1;
19
- if (width) {
20
- let finalWidth;
21
- if (typeof width === "string") {
22
- finalWidth = (IMG_SRC_SET_SIZES[0] * multipliedScale).toString();
23
- } else {
24
- finalWidth = (Number(width) * multipliedScale).toString();
25
- }
26
- newUrl.searchParams.append("width", finalWidth);
27
- }
28
- if (height && typeof height === "number") {
29
- newUrl.searchParams.append("height", (height * multipliedScale).toString());
30
- }
31
- crop && newUrl.searchParams.append("crop", crop);
32
- return newUrl.toString();
33
- }
34
- function shopifyImageLoader(params) {
35
- const newSrc = new URL(params.src);
36
- const isShopifyServedImage = ALL_CDN_HOSTNAMES.some(
37
- (allowedHostname) => newSrc.hostname.endsWith(allowedHostname)
38
- );
39
- if (!isShopifyServedImage || !params.width && !params.height && !params.crop && !params.scale) {
40
- return params.src;
41
- }
42
- return addImageSizeParametersToUrl(params);
43
- }
44
- function getShopifyImageDimensions({
45
- data: sfapiImage,
46
- loaderOptions,
47
- elementProps
48
- }) {
49
- let aspectRatio = null;
50
- if ((sfapiImage == null ? void 0 : sfapiImage.width) && (sfapiImage == null ? void 0 : sfapiImage.height)) {
51
- aspectRatio = (sfapiImage == null ? void 0 : sfapiImage.width) / (sfapiImage == null ? void 0 : sfapiImage.height);
52
- }
53
- if ((loaderOptions == null ? void 0 : loaderOptions.width) || (loaderOptions == null ? void 0 : loaderOptions.height)) {
54
- return {
55
- width: (loaderOptions == null ? void 0 : loaderOptions.width) ?? (aspectRatio && typeof loaderOptions.height === "number" ? Math.round(aspectRatio * loaderOptions.height) : null),
56
- height: (loaderOptions == null ? void 0 : loaderOptions.height) ?? (aspectRatio && typeof loaderOptions.width === "number" ? Math.round(aspectRatio * loaderOptions.width) : null)
57
- };
58
- }
59
- if ((elementProps == null ? void 0 : elementProps.width) || (elementProps == null ? void 0 : elementProps.height)) {
60
- return {
61
- width: (elementProps == null ? void 0 : elementProps.width) ?? (aspectRatio && typeof elementProps.height === "number" ? Math.round(aspectRatio * elementProps.height) : null),
62
- height: (elementProps == null ? void 0 : elementProps.height) ?? (aspectRatio && typeof elementProps.width === "number" ? Math.round(aspectRatio * elementProps.width) : null)
63
- };
64
- }
65
- if ((sfapiImage == null ? void 0 : sfapiImage.width) || (sfapiImage == null ? void 0 : sfapiImage.height)) {
66
- return {
67
- // can't calculate the aspect ratio here
68
- width: (sfapiImage == null ? void 0 : sfapiImage.width) ?? null,
69
- height: (sfapiImage == null ? void 0 : sfapiImage.height) ?? null
70
- };
71
- }
72
- return { width: null, height: null };
73
- }
74
- export {
75
- IMG_SRC_SET_SIZES,
76
- addImageSizeParametersToUrl,
77
- getShopifyImageDimensions,
78
- shopifyImageLoader
79
- };
80
- //# sourceMappingURL=image-size.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"image-size.mjs","sources":["../../src/image-size.ts"],"sourcesContent":["import type {Image as ImageType} from './storefront-api-types.js';\nimport type {PartialDeep} from 'type-fest';\nimport type {ShopifyLoaderOptions, ShopifyLoaderParams} from './Image.js';\n\n// TODO: Are there other CDNs missing from here?\nconst PRODUCTION_CDN_HOSTNAMES = [\n 'cdn.shopify.com',\n 'cdn.shopifycdn.net',\n 'shopify-assets.shopifycdn.com',\n 'shopify-assets.shopifycdn.net',\n];\nconst LOCAL_CDN_HOSTNAMES = ['spin.dev'];\nconst ALL_CDN_HOSTNAMES = [...PRODUCTION_CDN_HOSTNAMES, ...LOCAL_CDN_HOSTNAMES];\n\n// based on the default width sizes used by the Shopify liquid HTML tag img_tag plus a 2560 width to account for 2k resolutions\n// reference: https://shopify.dev/api/liquid/filters/html-filters#image_tag\nexport const IMG_SRC_SET_SIZES = [352, 832, 1200, 1920, 2560];\n\n/**\n * Adds image size parameters to an image URL hosted by Shopify's CDN\n */\nexport function addImageSizeParametersToUrl({\n src,\n width,\n height,\n crop,\n scale,\n}: ShopifyLoaderParams): string {\n const newUrl = new URL(src);\n\n const multipliedScale = scale ?? 1;\n\n if (width) {\n let finalWidth: string;\n\n if (typeof width === 'string') {\n finalWidth = (IMG_SRC_SET_SIZES[0] * multipliedScale).toString();\n } else {\n finalWidth = (Number(width) * multipliedScale).toString();\n }\n\n newUrl.searchParams.append('width', finalWidth);\n }\n\n if (height && typeof height === 'number') {\n newUrl.searchParams.append('height', (height * multipliedScale).toString());\n }\n\n crop && newUrl.searchParams.append('crop', crop);\n\n // for now we intentionally leave off the scale param, and instead multiple width & height by scale instead\n // scale && newUrl.searchParams.append('scale', scale.toString());\n\n return newUrl.toString();\n}\n\nexport function shopifyImageLoader(\n params: ShopifyLoaderParams,\n): ReturnType<typeof addImageSizeParametersToUrl> {\n const newSrc = new URL(params.src);\n const isShopifyServedImage = ALL_CDN_HOSTNAMES.some((allowedHostname) =>\n newSrc.hostname.endsWith(allowedHostname),\n );\n\n if (\n !isShopifyServedImage ||\n (!params.width && !params.height && !params.crop && !params.scale)\n ) {\n return params.src;\n }\n\n return addImageSizeParametersToUrl(params);\n}\n\ntype HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;\n\nexport type GetShopifyImageDimensionsProps = {\n data: Pick<\n PartialDeep<ImageType, {recurseIntoArrays: true}>,\n 'altText' | 'url' | 'id' | 'width' | 'height'\n >;\n loaderOptions?: ShopifyLoaderOptions;\n elementProps?: {\n width?: HtmlImageProps['width'];\n height?: HtmlImageProps['height'];\n };\n};\n\ntype GetShopifyImageDimensionsPropsReturn = {\n width: number | string | null;\n height: number | string | null;\n};\n\n/**\n * Width and height are determined using the followiing priority list:\n * 1. `loaderOptions`'s width/height\n * 2. `elementProps`'s width/height\n * 3. `data`'s width/height\n *\n * If only one of `width` or `height` are defined, then the other will attempt to be calculated based on the Image's aspect ratio,\n * provided that both `data.width` and `data.height` are available. If not, then the aspect ratio cannot be determined and the missing\n * value will reamin as `null`\n */\nexport function getShopifyImageDimensions({\n data: sfapiImage,\n loaderOptions,\n elementProps,\n}: GetShopifyImageDimensionsProps): GetShopifyImageDimensionsPropsReturn {\n let aspectRatio: number | null = null;\n\n if (sfapiImage?.width && sfapiImage?.height) {\n aspectRatio = sfapiImage?.width / sfapiImage?.height;\n }\n\n // * 1. `loaderOptions`'s width/height\n if (loaderOptions?.width || loaderOptions?.height) {\n return {\n width:\n loaderOptions?.width ??\n (aspectRatio && typeof loaderOptions.height === 'number'\n ? Math.round(aspectRatio * loaderOptions.height)\n : null),\n height:\n loaderOptions?.height ??\n (aspectRatio && typeof loaderOptions.width === 'number'\n ? Math.round(aspectRatio * loaderOptions.width)\n : null),\n };\n }\n\n // * 2. `elementProps`'s width/height\n if (elementProps?.width || elementProps?.height) {\n return {\n width:\n elementProps?.width ??\n (aspectRatio && typeof elementProps.height === 'number'\n ? Math.round(aspectRatio * elementProps.height)\n : null),\n height:\n elementProps?.height ??\n (aspectRatio && typeof elementProps.width === 'number'\n ? Math.round(aspectRatio * elementProps.width)\n : null),\n };\n }\n\n // * 3. `data`'s width/height\n if (sfapiImage?.width || sfapiImage?.height) {\n return {\n // can't calculate the aspect ratio here\n width: sfapiImage?.width ?? null,\n height: sfapiImage?.height ?? null,\n };\n }\n\n return {width: null, height: null};\n}\n"],"names":[],"mappings":"AAKA,MAAM,2BAA2B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AACA,MAAM,sBAAsB,CAAC,UAAU;AACvC,MAAM,oBAAoB,CAAC,GAAG,0BAA0B,GAAG,mBAAmB;AAIvE,MAAM,oBAAoB,CAAC,KAAK,KAAK,MAAM,MAAM,IAAI;AAKrD,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAgC;AACxB,QAAA,SAAS,IAAI,IAAI,GAAG;AAE1B,QAAM,kBAAkB,SAAS;AAEjC,MAAI,OAAO;AACL,QAAA;AAEA,QAAA,OAAO,UAAU,UAAU;AAC7B,oBAAc,kBAAkB,CAAC,IAAI,iBAAiB,SAAS;AAAA,IAAA,OAC1D;AACL,oBAAc,OAAO,KAAK,IAAI,iBAAiB,SAAS;AAAA,IAC1D;AAEO,WAAA,aAAa,OAAO,SAAS,UAAU;AAAA,EAChD;AAEI,MAAA,UAAU,OAAO,WAAW,UAAU;AACxC,WAAO,aAAa,OAAO,WAAW,SAAS,iBAAiB,UAAU;AAAA,EAC5E;AAEA,UAAQ,OAAO,aAAa,OAAO,QAAQ,IAAI;AAK/C,SAAO,OAAO;AAChB;AAEO,SAAS,mBACd,QACgD;AAChD,QAAM,SAAS,IAAI,IAAI,OAAO,GAAG;AACjC,QAAM,uBAAuB,kBAAkB;AAAA,IAAK,CAAC,oBACnD,OAAO,SAAS,SAAS,eAAe;AAAA,EAAA;AAG1C,MACE,CAAC,wBACA,CAAC,OAAO,SAAS,CAAC,OAAO,UAAU,CAAC,OAAO,QAAQ,CAAC,OAAO,OAC5D;AACA,WAAO,OAAO;AAAA,EAChB;AAEA,SAAO,4BAA4B,MAAM;AAC3C;AA+BO,SAAS,0BAA0B;AAAA,EACxC,MAAM;AAAA,EACN;AAAA,EACA;AACF,GAAyE;AACvE,MAAI,cAA6B;AAE7B,OAAA,yCAAY,WAAS,yCAAY,SAAQ;AAC7B,mBAAA,yCAAY,UAAQ,yCAAY;AAAA,EAChD;AAGI,OAAA,+CAAe,WAAS,+CAAe,SAAQ;AAC1C,WAAA;AAAA,MACL,QACE,+CAAe,WACd,eAAe,OAAO,cAAc,WAAW,WAC5C,KAAK,MAAM,cAAc,cAAc,MAAM,IAC7C;AAAA,MACN,SACE,+CAAe,YACd,eAAe,OAAO,cAAc,UAAU,WAC3C,KAAK,MAAM,cAAc,cAAc,KAAK,IAC5C;AAAA,IAAA;AAAA,EAEV;AAGI,OAAA,6CAAc,WAAS,6CAAc,SAAQ;AACxC,WAAA;AAAA,MACL,QACE,6CAAc,WACb,eAAe,OAAO,aAAa,WAAW,WAC3C,KAAK,MAAM,cAAc,aAAa,MAAM,IAC5C;AAAA,MACN,SACE,6CAAc,YACb,eAAe,OAAO,aAAa,UAAU,WAC1C,KAAK,MAAM,cAAc,aAAa,KAAK,IAC3C;AAAA,IAAA;AAAA,EAEV;AAGI,OAAA,yCAAY,WAAS,yCAAY,SAAQ;AACpC,WAAA;AAAA;AAAA,MAEL,QAAO,yCAAY,UAAS;AAAA,MAC5B,SAAQ,yCAAY,WAAU;AAAA,IAAA;AAAA,EAElC;AAEA,SAAO,EAAC,OAAO,MAAM,QAAQ,KAAI;AACnC;"}
@@ -1,31 +0,0 @@
1
- import { Money, type MoneyPropsBase } from './Money.js';
2
- import { CartLine } from './storefront-api-types.js';
3
- import { PartialDeep } from 'type-fest';
4
- interface CartLinePricePropsBase {
5
- /** A [CartLine object](https://shopify.dev/api/storefront/reference/objects/CartLine). */
6
- data: PartialDeep<CartLine, {
7
- recurseIntoArrays: true;
8
- }>;
9
- /** The type of price. Valid values:`regular` (default) or `compareAt`. */
10
- priceType?: 'regular' | 'compareAt';
11
- }
12
- type CartLinePriceProps = Omit<React.ComponentProps<typeof Money>, 'data'> & CartLinePricePropsBase;
13
- /**
14
- * @deprecated Use `Money` instead. To migrate, use the `priceType` prop that matches the corresponding property on the `CartLine` object:
15
- * - `regular`: `cartLine.cost.totalAmount`
16
- * - `compareAt`: `cartLine.cost.compareAtAmountPerQuantity`
17
- *
18
- * For example:
19
- * ```
20
- * // before
21
- * <CartLinePrice data={cartLine} priceType="regular" />
22
- * // after
23
- * <Money data={cartLine.cost.totalAmount} />
24
- * ```
25
- *
26
- * The `CartLinePrice` component renders a `Money` component for the cart line merchandise's price or compare at price.
27
- */
28
- export declare function CartLinePrice(props: CartLinePriceProps): JSX.Element | null;
29
- export interface CartLinePricePropsForDocs<AsType extends React.ElementType = 'div'> extends Omit<MoneyPropsBase<AsType>, 'data'>, CartLinePricePropsBase {
30
- }
31
- export {};
@@ -1,36 +0,0 @@
1
- import type { Image as ImageType } from './storefront-api-types.js';
2
- import type { PartialDeep } from 'type-fest';
3
- import type { ShopifyLoaderOptions, ShopifyLoaderParams } from './Image.js';
4
- export declare const IMG_SRC_SET_SIZES: number[];
5
- /**
6
- * Adds image size parameters to an image URL hosted by Shopify's CDN
7
- */
8
- export declare function addImageSizeParametersToUrl({ src, width, height, crop, scale, }: ShopifyLoaderParams): string;
9
- export declare function shopifyImageLoader(params: ShopifyLoaderParams): ReturnType<typeof addImageSizeParametersToUrl>;
10
- type HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
11
- export type GetShopifyImageDimensionsProps = {
12
- data: Pick<PartialDeep<ImageType, {
13
- recurseIntoArrays: true;
14
- }>, 'altText' | 'url' | 'id' | 'width' | 'height'>;
15
- loaderOptions?: ShopifyLoaderOptions;
16
- elementProps?: {
17
- width?: HtmlImageProps['width'];
18
- height?: HtmlImageProps['height'];
19
- };
20
- };
21
- type GetShopifyImageDimensionsPropsReturn = {
22
- width: number | string | null;
23
- height: number | string | null;
24
- };
25
- /**
26
- * Width and height are determined using the followiing priority list:
27
- * 1. `loaderOptions`'s width/height
28
- * 2. `elementProps`'s width/height
29
- * 3. `data`'s width/height
30
- *
31
- * If only one of `width` or `height` are defined, then the other will attempt to be calculated based on the Image's aspect ratio,
32
- * provided that both `data.width` and `data.height` are available. If not, then the aspect ratio cannot be determined and the missing
33
- * value will reamin as `null`
34
- */
35
- export declare function getShopifyImageDimensions({ data: sfapiImage, loaderOptions, elementProps, }: GetShopifyImageDimensionsProps): GetShopifyImageDimensionsPropsReturn;
36
- export {};