@shopify/hydrogen 0.21.0 → 0.22.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 (110) hide show
  1. package/CHANGELOG.md +91 -0
  2. package/dist/esnext/client.d.ts +1 -0
  3. package/dist/esnext/client.js +1 -0
  4. package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +7 -4
  5. package/dist/esnext/components/CartProvider/CartProvider.client.js +22 -12
  6. package/dist/esnext/components/Image/Image.d.ts +3 -3
  7. package/dist/esnext/components/Image/Image.js +12 -9
  8. package/dist/esnext/components/MediaFile/MediaFile.js +3 -2
  9. package/dist/esnext/components/Seo/NoIndexSeo.client.d.ts +3 -0
  10. package/dist/esnext/components/Seo/NoIndexSeo.client.js +10 -0
  11. package/dist/esnext/components/Seo/Seo.client.d.ts +4 -0
  12. package/dist/esnext/components/Seo/Seo.client.js +3 -0
  13. package/dist/esnext/config.d.ts +3 -3
  14. package/dist/esnext/entry-client.js +0 -3
  15. package/dist/esnext/entry-server.d.ts +2 -2
  16. package/dist/esnext/entry-server.js +70 -44
  17. package/dist/esnext/foundation/Analytics/Analytics.client.js +1 -1
  18. package/dist/esnext/foundation/Analytics/ClientAnalytics.js +2 -2
  19. package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.js +2 -2
  20. package/dist/esnext/foundation/Analytics/index.d.ts +0 -1
  21. package/dist/esnext/foundation/Analytics/index.js +0 -1
  22. package/dist/esnext/foundation/FileRoutes/FileRoutes.server.js +5 -10
  23. package/dist/esnext/foundation/Router/BrowserRouter.client.d.ts +2 -1
  24. package/dist/esnext/foundation/Router/BrowserRouter.client.js +1 -1
  25. package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +0 -2
  26. package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +0 -1
  27. package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.d.ts +2 -1
  28. package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.js +1 -1
  29. package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +2 -2
  30. package/dist/esnext/framework/Hydration/ServerComponentResponse.server.d.ts +0 -9
  31. package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +0 -19
  32. package/dist/esnext/framework/Hydration/rsc.js +2 -2
  33. package/dist/esnext/framework/middleware.js +1 -15
  34. package/dist/esnext/framework/plugin.js +2 -0
  35. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +1 -1
  36. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +1 -1
  37. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +6 -47
  38. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.js +6 -11
  39. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +7 -0
  40. package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.js +99 -0
  41. package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +4 -4
  42. package/dist/esnext/framework/viteception.d.ts +4 -0
  43. package/dist/esnext/framework/viteception.js +15 -0
  44. package/dist/esnext/hooks/useShopQuery/hooks.d.ts +1 -2
  45. package/dist/esnext/hooks/useShopQuery/hooks.js +0 -1
  46. package/dist/esnext/index.d.ts +24 -13
  47. package/dist/esnext/index.js +24 -17
  48. package/dist/esnext/storefront-api-types.d.ts +1 -1
  49. package/dist/esnext/streaming.server.d.ts +3 -1
  50. package/dist/esnext/types.d.ts +12 -5
  51. package/dist/esnext/utilities/apiRoutes.d.ts +4 -5
  52. package/dist/esnext/utilities/apiRoutes.js +2 -8
  53. package/dist/esnext/utilities/fetch.d.ts +1 -2
  54. package/dist/esnext/utilities/fetch.js +1 -3
  55. package/dist/esnext/utilities/graphql-tag.d.ts +1 -0
  56. package/dist/esnext/utilities/graphql-tag.js +6 -0
  57. package/dist/esnext/utilities/graphql-tracker.d.ts +1 -1
  58. package/dist/esnext/utilities/graphql-tracker.js +4 -0
  59. package/dist/esnext/utilities/html-encoding.d.ts +0 -1
  60. package/dist/esnext/utilities/html-encoding.js +0 -8
  61. package/dist/esnext/utilities/index.d.ts +1 -1
  62. package/dist/esnext/utilities/index.js +1 -1
  63. package/dist/esnext/version.d.ts +1 -1
  64. package/dist/esnext/version.js +1 -1
  65. package/dist/node/components/Image/Image.d.ts +3 -3
  66. package/dist/node/components/Image/Image.js +12 -9
  67. package/dist/node/entry-server.d.ts +2 -2
  68. package/dist/node/entry-server.js +70 -44
  69. package/dist/node/foundation/Analytics/Analytics.client.js +6 -6
  70. package/dist/node/foundation/Analytics/ClientAnalytics.js +2 -2
  71. package/dist/node/foundation/Router/BrowserRouter.client.d.ts +2 -1
  72. package/dist/node/foundation/Router/BrowserRouter.client.js +1 -1
  73. package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.js +0 -2
  74. package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +2 -2
  75. package/dist/node/framework/Hydration/ServerComponentResponse.server.d.ts +0 -9
  76. package/dist/node/framework/Hydration/ServerComponentResponse.server.js +0 -19
  77. package/dist/node/framework/Hydration/rsc.js +2 -2
  78. package/dist/node/framework/middleware.js +1 -15
  79. package/dist/node/framework/plugin.js +2 -0
  80. package/dist/node/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +1 -1
  81. package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +1 -1
  82. package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +5 -46
  83. package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.js +6 -11
  84. package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +7 -0
  85. package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.js +105 -0
  86. package/dist/node/framework/plugins/vite-plugin-platform-entry.js +4 -4
  87. package/dist/node/framework/viteception.d.ts +4 -0
  88. package/dist/node/framework/viteception.js +19 -0
  89. package/dist/node/storefront-api-types.d.ts +1 -1
  90. package/dist/node/streaming.server.d.ts +3 -1
  91. package/dist/node/types.d.ts +12 -5
  92. package/dist/node/utilities/apiRoutes.d.ts +4 -5
  93. package/dist/node/utilities/apiRoutes.js +2 -8
  94. package/dist/node/utilities/fetch.d.ts +1 -2
  95. package/dist/node/utilities/fetch.js +1 -3
  96. package/dist/node/utilities/html-encoding.d.ts +0 -1
  97. package/dist/node/utilities/html-encoding.js +1 -10
  98. package/dist/node/utilities/index.d.ts +1 -1
  99. package/dist/node/utilities/index.js +1 -2
  100. package/dist/node/version.d.ts +1 -1
  101. package/dist/node/version.js +1 -1
  102. package/package.json +4 -3
  103. package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +19 -2
  104. package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +19 -2
  105. package/dist/esnext/utilities/findRoutePrefix.d.ts +0 -1
  106. package/dist/esnext/utilities/findRoutePrefix.js +0 -17
  107. package/dist/node/foundation/Analytics/index.d.ts +0 -2
  108. package/dist/node/foundation/Analytics/index.js +0 -7
  109. package/dist/node/utilities/findRoutePrefix.d.ts +0 -1
  110. package/dist/node/utilities/findRoutePrefix.js +0 -21
package/CHANGELOG.md CHANGED
@@ -1,5 +1,96 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.22.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#930](https://github.com/Shopify/hydrogen/pull/930) [`750baf8f`](https://github.com/Shopify/hydrogen/commit/750baf8ff069d0e06fb92e78a142049a1ce2b1ae) Thanks [@michenly](https://github.com/michenly)! - With the introduction of authenticated pages, we also now provide the ability to prevent pages from being indexed by bots. You can do so by passing `noindex` to the `Seo` component:
8
+
9
+ ```jsx
10
+ <Seo type="noindex" data={{title: 'Login'}} />
11
+ ```
12
+
13
+ * [#1313](https://github.com/Shopify/hydrogen/pull/1313) [`ed1933e3`](https://github.com/Shopify/hydrogen/commit/ed1933e339927322d8008034982b05ff4590e6d8) Thanks [@frandiox](https://github.com/frandiox)! - **Breaking change**: The `routes` property in `hydrogen.config.js` file has been simplified. It is now a string that represents the path to the routes from the project root:
14
+
15
+ ```diff
16
+ // hydrogen.config.js
17
+
18
+ export default defineConfig({
19
+ - routes: import('./src/routes/**/*.server.[jt](s|sx)'),
20
+ + routes: '/src/routes',
21
+ });
22
+ ```
23
+
24
+ Its default value is `/src/routes` so this property can be removed when using this directory.
25
+
26
+ In the object syntax version, `dirPrefix` is removed and `files` becomes a string:
27
+
28
+ ```diff
29
+ // hydrogen.config.js
30
+
31
+ export default defineConfig({
32
+ routes: {
33
+ - files: import('./src/routes/**/*.server.[jt](s|sx)'),
34
+ - dirPrefix: './src/routes',
35
+ + files: '/src/routes',
36
+ basePath: '/',
37
+ },
38
+ });
39
+ ```
40
+
41
+ - [#1332](https://github.com/Shopify/hydrogen/pull/1332) [`5ec1bc62`](https://github.com/Shopify/hydrogen/commit/5ec1bc62cf9e4348aa389d4154f8c80dccfb96bb) Thanks [@frandiox](https://github.com/frandiox)! - A new `gql` utility is exported from `@shopify/hydrogen` that replaces `graphql-tag` dependency when using `useShopQuery`. It helps reducing bundle size in production when compared to the original `graphql-tag`.
42
+
43
+ Before:
44
+
45
+ ```js
46
+ import gql from 'graphql-tag';
47
+
48
+ // ...
49
+
50
+ useShopQuery({
51
+ query: gql`...`,
52
+ // ...
53
+ });
54
+ ```
55
+
56
+ After:
57
+
58
+ ```js
59
+ import {gql} from '@shopify/hydrogen';
60
+
61
+ // ...
62
+
63
+ useShopQuery({
64
+ query: gql`...`,
65
+ // ...
66
+ });
67
+ ```
68
+
69
+ * [#1340](https://github.com/Shopify/hydrogen/pull/1340) [`631832ec`](https://github.com/Shopify/hydrogen/commit/631832ecaef26b918e774515ada6b80668ec5e4e) Thanks [@jplhomer](https://github.com/jplhomer)! - **Breaking change**: The `response.send()` function has been removed. Use `export async function api()` to send custom responses instead.
70
+
71
+ ### Patch Changes
72
+
73
+ - [#1371](https://github.com/Shopify/hydrogen/pull/1371) [`84a2fd09`](https://github.com/Shopify/hydrogen/commit/84a2fd09b7150b1d5e1f92b786f4a6af09e18739) Thanks [@frehner](https://github.com/frehner)! - Made updates to `<Image/>`:
74
+
75
+ - Fixed some TypeScript type issues with Image.
76
+ - `data.url` and `alt` are now required props in Typescript, but won't break the actual component if you don't pass them.
77
+
78
+ * [#1348](https://github.com/Shopify/hydrogen/pull/1348) [`211093e5`](https://github.com/Shopify/hydrogen/commit/211093e5f1a9e2ad115eb667746bfa2c6dd05b82) Thanks [@developit](https://github.com/developit)! - Fix HTML double-decoding in flight response
79
+
80
+ - [#1345](https://github.com/Shopify/hydrogen/pull/1345) [`331ff3c0`](https://github.com/Shopify/hydrogen/commit/331ff3c0f58143df3e7c542116f9a94838710352) Thanks [@frandiox](https://github.com/frandiox)! - Reduce the amount of user app files downloaded in the browser.
81
+
82
+ * [#1322](https://github.com/Shopify/hydrogen/pull/1322) [`36bd77c4`](https://github.com/Shopify/hydrogen/commit/36bd77c4619ec071ea11b764bb16b5670b0afa6b) Thanks [@frandiox](https://github.com/frandiox)! - Fix server hanging in Node.js environment when not using Hydrogen Middleware.
83
+
84
+ - [#1360](https://github.com/Shopify/hydrogen/pull/1360) [`d9b0d03b`](https://github.com/Shopify/hydrogen/commit/d9b0d03b64d2207b314d15fc0acf6a5143610b92) Thanks [@blittle](https://github.com/blittle)! - Fix a problem where encoded html content props passed from server to client components would get double decoded, and break hydration on app load.
85
+
86
+ * [#1355](https://github.com/Shopify/hydrogen/pull/1355) [`c45a45e8`](https://github.com/Shopify/hydrogen/commit/c45a45e895b8407da04c6b4608e7f16170452c24) Thanks [@jplhomer](https://github.com/jplhomer)! - Ensure all Hydrogen components are exported properly
87
+
88
+ - [#1339](https://github.com/Shopify/hydrogen/pull/1339) [`fef4cb84`](https://github.com/Shopify/hydrogen/commit/fef4cb8496d985d37b6113865ac1252f78058aaa) Thanks [@jplhomer](https://github.com/jplhomer)! - Use `import.meta.env.DEV` instead of `process.env.LOCAL_DEV` to hash asset filenames and show performance metrics debugging
89
+
90
+ * [#1320](https://github.com/Shopify/hydrogen/pull/1320) [`7e9df897`](https://github.com/Shopify/hydrogen/commit/7e9df897465012cd0cf374a1a35deb2ca8a16fc3) Thanks [@jplhomer](https://github.com/jplhomer)! - Properly log errors during flight responses
91
+
92
+ - [#1363](https://github.com/Shopify/hydrogen/pull/1363) [`0941d3be`](https://github.com/Shopify/hydrogen/commit/0941d3be12b52edc045b898864435f591fc2c42e) Thanks [@frandiox](https://github.com/frandiox)! - Remove some server utilities from client build.
93
+
3
94
  ## 0.21.0
4
95
 
5
96
  ### Minor Changes
@@ -6,6 +6,7 @@ export * from './foundation/ServerPropsProvider';
6
6
  export * from './foundation/useUrl';
7
7
  export { Head } from './foundation/Head';
8
8
  export * from './utilities';
9
+ export { gql } from './utilities/graphql-tag';
9
10
  export { ClientAnalytics } from './foundation/Analytics';
10
11
  export { useRouteParams } from './foundation/useRouteParams/useRouteParams';
11
12
  export { useNavigate } from './foundation/useNavigate/useNavigate';
@@ -6,6 +6,7 @@ export * from './foundation/ServerPropsProvider';
6
6
  export * from './foundation/useUrl';
7
7
  export { Head } from './foundation/Head';
8
8
  export * from './utilities';
9
+ export { gql } from './utilities/graphql-tag';
9
10
  export { ClientAnalytics } from './foundation/Analytics';
10
11
  export { useRouteParams } from './foundation/useRouteParams/useRouteParams';
11
12
  export { useNavigate } from './foundation/useNavigate/useNavigate';
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { CartBuyerIdentityInput, CountryCode } from '../../storefront-api-types';
2
3
  import { CartFragmentFragment } from './graphql/CartFragment';
3
4
  /**
4
5
  * The `CartProvider` component creates a context for using a cart. It creates a cart object and callbacks
@@ -9,7 +10,7 @@ import { CartFragmentFragment } from './graphql/CartFragment';
9
10
  * The `CartProvider` component must be a descendent of the `ShopifyProvider` component.
10
11
  * You must use this component if you want to use the `useCart` hook or related hooks, or if you would like to use the `AddToCartButton` component.
11
12
  */
12
- export declare function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, cartFragment, }: {
13
+ export declare function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, cartFragment, customerAccessToken, countryCode, }: {
13
14
  /** Any `ReactNode` elements. */
14
15
  children: React.ReactNode;
15
16
  numCartLines?: number;
@@ -29,10 +30,12 @@ export declare function CartProvider({ children, numCartLines, onCreate, onLineA
29
30
  onAttributesUpdate?: () => void;
30
31
  /** A callback that is invoked when the process to update the cart discount codes begins, but before the discount codes are updated in the Storefront API. */
31
32
  onDiscountCodesUpdate?: () => void;
32
- /**
33
- * An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart).
34
- */
33
+ /** An object with fields that correspond to the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart). */
35
34
  data?: CartFragmentFragment;
36
35
  /** A fragment used to query the Storefront API's [Cart object](https://shopify.dev/api/storefront/latest/objects/cart) for all queries and mutations. A default value is used if no argument is provided. */
37
36
  cartFragment?: string;
37
+ /** A customer access token that's accessible on the server if there's a customer login. */
38
+ customerAccessToken?: CartBuyerIdentityInput['customerAccessToken'];
39
+ /** The ISO country code for i18n. */
40
+ countryCode?: CountryCode;
38
41
  }): JSX.Element;
@@ -1,11 +1,11 @@
1
1
  import React, { useEffect, useCallback, useReducer, useMemo, useRef, } from 'react';
2
- import { flattenConnection } from '../../utilities';
2
+ import { flattenConnection } from '../../utilities/flattenConnection';
3
3
  import { CartLineAdd, CartCreate, CartLineRemove, CartLineUpdate, CartNoteUpdate, CartBuyerIdentityUpdate, CartAttributesUpdate, CartDiscountCodesUpdate, CartQuery, defaultCartFragment, } from './cart-queries';
4
+ import { CountryCode, } from '../../storefront-api-types';
4
5
  import { useCartFetch } from './hooks.client';
5
6
  import { CartContext } from './context';
6
7
  import { CART_ID_STORAGE_KEY } from './constants';
7
- import { useServerProps } from '../../foundation/useServerProps';
8
- import { ClientAnalytics } from '../../foundation/Analytics';
8
+ import { ClientAnalytics } from '../../foundation/Analytics/ClientAnalytics';
9
9
  function cartReducer(state, action) {
10
10
  switch (action.type) {
11
11
  case 'cartFetch': {
@@ -150,10 +150,7 @@ function cartReducer(state, action) {
150
150
  * The `CartProvider` component must be a descendent of the `ShopifyProvider` component.
151
151
  * You must use this component if you want to use the `useCart` hook or related hooks, or if you would like to use the `AddToCartButton` component.
152
152
  */
153
- export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, cartFragment = defaultCartFragment, }) {
154
- var _a;
155
- const { serverProps } = useServerProps();
156
- const countryCode = (_a = serverProps === null || serverProps === void 0 ? void 0 : serverProps.country) === null || _a === void 0 ? void 0 : _a.isoCode;
153
+ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, data: cart, cartFragment = defaultCartFragment, customerAccessToken, countryCode = CountryCode.Us, }) {
157
154
  const initialStatus = cart
158
155
  ? { status: 'idle', cart: cartFromGraphQL(cart) }
159
156
  : { status: 'uninitialized' };
@@ -177,7 +174,7 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
177
174
  dispatch({ type: 'resolve', cart: cartFromGraphQL(data.cart) });
178
175
  }, [fetchCart, cartFragment, numCartLines, countryCode]);
179
176
  const cartCreate = useCallback(async (cart) => {
180
- var _a, _b;
177
+ var _a, _b, _c;
181
178
  dispatch({ type: 'cartCreate' });
182
179
  onCreate === null || onCreate === void 0 ? void 0 : onCreate();
183
180
  if (countryCode && !((_a = cart.buyerIdentity) === null || _a === void 0 ? void 0 : _a.countryCode)) {
@@ -186,6 +183,12 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
186
183
  }
187
184
  cart.buyerIdentity.countryCode = countryCode;
188
185
  }
186
+ if (customerAccessToken && !((_b = cart.buyerIdentity) === null || _b === void 0 ? void 0 : _b.customerAccessToken)) {
187
+ if (cart.buyerIdentity == null) {
188
+ cart.buyerIdentity = {};
189
+ }
190
+ cart.buyerIdentity.customerAccessToken = customerAccessToken;
191
+ }
189
192
  const { data, error } = await fetchCart({
190
193
  query: CartCreate(cartFragment),
191
194
  variables: {
@@ -200,7 +203,7 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
200
203
  error,
201
204
  });
202
205
  }
203
- if ((_b = data === null || data === void 0 ? void 0 : data.cartCreate) === null || _b === void 0 ? void 0 : _b.cart) {
206
+ if ((_c = data === null || data === void 0 ? void 0 : data.cartCreate) === null || _c === void 0 ? void 0 : _c.cart) {
204
207
  if (cart.lines) {
205
208
  ClientAnalytics.publish(ClientAnalytics.eventNames.ADD_TO_CART, true, {
206
209
  addedCartLines: cart.lines,
@@ -213,7 +216,14 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
213
216
  });
214
217
  window.localStorage.setItem(CART_ID_STORAGE_KEY, data.cartCreate.cart.id);
215
218
  }
216
- }, [onCreate, countryCode, fetchCart, cartFragment, numCartLines]);
219
+ }, [
220
+ onCreate,
221
+ countryCode,
222
+ fetchCart,
223
+ cartFragment,
224
+ numCartLines,
225
+ customerAccessToken,
226
+ ]);
217
227
  const addLineItem = useCallback(async (lines, state) => {
218
228
  var _a;
219
229
  if (state.status === 'idle') {
@@ -439,9 +449,9 @@ export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLi
439
449
  if (state.status !== 'idle') {
440
450
  return;
441
451
  }
442
- buyerIdentityUpdate({ countryCode }, state);
452
+ buyerIdentityUpdate({ countryCode, customerAccessToken }, state);
443
453
  // eslint-disable-next-line react-hooks/exhaustive-deps
444
- }, [countryCode]);
454
+ }, [countryCode, customerAccessToken]);
445
455
  const cartContextValue = useMemo(() => {
446
456
  return {
447
457
  ...('cart' in state
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  import type { Image as ImageType } from '../../storefront-api-types';
3
3
  import type { PartialDeep, Simplify, SetRequired } from 'type-fest';
4
4
  declare type HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
5
- declare type ImageProps<GenericLoaderOpts> = Simplify<ShopifyImageProps | ExternalImageProps<GenericLoaderOpts>>;
5
+ declare type ImageProps<GenericLoaderOpts> = ShopifyImageProps | ExternalImageProps<GenericLoaderOpts>;
6
6
  export declare function Image<GenericLoaderOpts>(props: ImageProps<GenericLoaderOpts>): JSX.Element;
7
7
  export declare type ShopifyLoaderOptions = {
8
8
  crop?: 'top' | 'bottom' | 'left' | 'right' | 'center';
@@ -19,7 +19,7 @@ export declare type ShopifyImageProps = Omit<HtmlImageProps, 'src'> & {
19
19
  * The `data` prop is required if `src` isn't used, but both props shouldn't be used
20
20
  * at the same time. If both `src` and `data` are passed, then `data` takes priority.
21
21
  */
22
- data: PartialDeep<ImageType>;
22
+ data: SetRequired<PartialDeep<ImageType>, 'url'>;
23
23
  /** A custom function that generates the image URL. Parameters passed in
24
24
  * are either `ShopifyLoaderParams` if using the `data` prop, or the
25
25
  * `LoaderOptions` object that you pass to `loaderOptions`.
@@ -62,7 +62,7 @@ declare type LoaderProps<GenericLoaderOpts> = {
62
62
  */
63
63
  loaderOptions?: GenericLoaderOpts;
64
64
  };
65
- declare type ExternalImageProps<GenericLoaderOpts> = SetRequired<HtmlImageProps, 'src' | 'width' | 'height'> & {
65
+ declare type ExternalImageProps<GenericLoaderOpts> = SetRequired<HtmlImageProps, 'src' | 'width' | 'height' | 'alt'> & {
66
66
  /** A custom function that generates the image URL. Parameters passed in
67
67
  * are either `ShopifyLoaderParams` if using the `data` prop, or the
68
68
  * `LoaderOptions` object that you pass to `loaderOptions`.
@@ -4,7 +4,7 @@ export function Image(props) {
4
4
  if (!props.data && !props.src) {
5
5
  throw new Error(`<Image/>: requires either a 'data' or 'src' prop.`);
6
6
  }
7
- if (props.data && props.src) {
7
+ if (__DEV__ && props.data && props.src) {
8
8
  console.warn(`<Image/>: using both 'data' and 'src' props is not supported; using the 'data' prop by default`);
9
9
  }
10
10
  if (props.data) {
@@ -15,16 +15,16 @@ export function Image(props) {
15
15
  }
16
16
  }
17
17
  function ShopifyImage({ data, width, height, loading, loader = shopifyImageLoader, loaderOptions, ...rest }) {
18
- var _a, _b, _c;
18
+ var _a, _b, _c, _d, _e, _f;
19
19
  if (!data.url) {
20
20
  throw new Error(`<Image/>: the 'data' prop requires the 'url' property`);
21
21
  }
22
- if (!data.altText && !rest.alt) {
23
- console.warn(`<Image/>: the 'data' prop should have the 'altText' property, or the 'alt' prop, and one of them should not be empty. ${data.id ? `Image ID: ${data.id}` : ''}`);
22
+ if (__DEV__ && !data.altText && !rest.alt) {
23
+ console.warn(`<Image/>: the 'data' prop should have the 'altText' property, or the 'alt' prop, and one of them should not be empty. ${`Image: ${(_a = data.id) !== null && _a !== void 0 ? _a : data.url}`}`);
24
24
  }
25
25
  const { width: finalWidth, height: finalHeight } = getShopifyImageDimensions(data, loaderOptions);
26
- if (!finalWidth || !finalHeight) {
27
- console.warn(`<Image/>: the 'data' prop requires either 'width' or 'data.width', and 'height' or 'data.height' properties`);
26
+ if ((__DEV__ && !finalWidth) || !finalHeight) {
27
+ console.warn(`<Image/>: the 'data' prop requires either 'width' or 'data.width', and 'height' or 'data.height' properties. ${`Image: ${(_b = data.id) !== null && _b !== void 0 ? _b : data.url}`}`);
28
28
  }
29
29
  let finalSrc = data.url;
30
30
  if (loader) {
@@ -34,17 +34,20 @@ function ShopifyImage({ data, width, height, loading, loader = shopifyImageLoade
34
34
  width: finalWidth,
35
35
  height: finalHeight,
36
36
  });
37
+ if (typeof finalSrc !== 'string' || !finalSrc) {
38
+ throw new Error(`<Image/>: 'loader' did not return a valid string. ${`Image: ${(_c = data.id) !== null && _c !== void 0 ? _c : data.url}`}`);
39
+ }
37
40
  }
38
41
  /* eslint-disable hydrogen/prefer-image-component */
39
- return (React.createElement("img", { id: (_a = data.id) !== null && _a !== void 0 ? _a : '', alt: (_c = (_b = data.altText) !== null && _b !== void 0 ? _b : rest.alt) !== null && _c !== void 0 ? _c : '', loading: loading !== null && loading !== void 0 ? loading : 'lazy', ...rest, src: finalSrc, width: finalWidth !== null && finalWidth !== void 0 ? finalWidth : undefined, height: finalHeight !== null && finalHeight !== void 0 ? finalHeight : undefined }));
42
+ return (React.createElement("img", { id: (_d = data.id) !== null && _d !== void 0 ? _d : '', alt: (_f = (_e = data.altText) !== null && _e !== void 0 ? _e : rest.alt) !== null && _f !== void 0 ? _f : '', loading: loading !== null && loading !== void 0 ? loading : 'lazy', ...rest, src: finalSrc, width: finalWidth !== null && finalWidth !== void 0 ? finalWidth : undefined, height: finalHeight !== null && finalHeight !== void 0 ? finalHeight : undefined }));
40
43
  /* eslint-enable hydrogen/prefer-image-component */
41
44
  }
42
45
  function ExternalImage({ src, width, height, alt, loader, loaderOptions, loading, ...rest }) {
43
46
  if (!width || !height) {
44
47
  throw new Error(`<Image/>: when 'src' is provided, 'width' and 'height' are required and need to be valid values (i.e. greater than zero). Provided values: 'src': ${src}, 'width': ${width}, 'height': ${height}`);
45
48
  }
46
- if (!alt) {
47
- console.warn(`<Image/>: when 'src' is provided, 'alt' should also be provided`);
49
+ if (__DEV__ && !alt) {
50
+ console.warn(`<Image/>: when 'src' is provided, 'alt' should also be provided. ${`Image: ${src}`}`);
48
51
  }
49
52
  let finalSrc = src;
50
53
  if (loader) {
@@ -12,8 +12,9 @@ import { ModelViewer } from '../ModelViewer';
12
12
  export function MediaFile({ data, options, ...passthroughProps }) {
13
13
  switch (data.mediaContentType) {
14
14
  case 'IMAGE': {
15
- const dataImage = data.image;
16
- if (!dataImage) {
15
+ const dataImage = data
16
+ .image;
17
+ if (!dataImage || !dataImage.url) {
17
18
  console.warn(`No "image" property was found on the "data" prop for <MediaFile/>, for the "type='image'"`);
18
19
  return null;
19
20
  }
@@ -0,0 +1,3 @@
1
+ import type { DefaultPage } from './seo-types';
2
+ import type { PartialDeep } from 'type-fest';
3
+ export declare function NoIndexPageSeo({ title, titleTemplate, lang, }: PartialDeep<DefaultPage>): JSX.Element;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { useShop } from '../../foundation';
3
+ import { Head } from '../../client';
4
+ export function NoIndexPageSeo({ title, titleTemplate, lang, }) {
5
+ const { languageCode: fallBacklang } = useShop();
6
+ return (React.createElement(React.Fragment, null,
7
+ React.createElement(Head, { defaultTitle: title !== null && title !== void 0 ? title : '', titleTemplate: titleTemplate !== null && titleTemplate !== void 0 ? titleTemplate : `%s - ${title}` },
8
+ React.createElement("html", { lang: lang !== null && lang !== void 0 ? lang : fallBacklang }),
9
+ React.createElement("meta", { name: "robots", content: "noindex" }))));
10
+ }
@@ -2,6 +2,7 @@ import { type ComponentProps } from 'react';
2
2
  import { ProductSeo } from './ProductSeo.client';
3
3
  import { CollectionSeo } from './CollectionSeo.client';
4
4
  import { PageSeo } from './PageSeo.client';
5
+ import { NoIndexPageSeo } from './NoIndexSeo.client';
5
6
  import type { DefaultPage as DefaultPageType, HomePage as HomePageType } from './seo-types';
6
7
  declare type Props = {
7
8
  type: 'defaultSeo';
@@ -18,6 +19,9 @@ declare type Props = {
18
19
  } | {
19
20
  type: 'page';
20
21
  data: ComponentProps<typeof PageSeo>;
22
+ } | {
23
+ type: 'noindex';
24
+ data: ComponentProps<typeof NoIndexPageSeo>;
21
25
  };
22
26
  /**
23
27
  * The `Seo` component renders SEO information on a webpage.
@@ -5,6 +5,7 @@ import { HomePageSeo } from './HomePageSeo.client';
5
5
  import { ProductSeo } from './ProductSeo.client';
6
6
  import { CollectionSeo } from './CollectionSeo.client';
7
7
  import { PageSeo } from './PageSeo.client';
8
+ import { NoIndexPageSeo } from './NoIndexSeo.client';
8
9
  /**
9
10
  * The `Seo` component renders SEO information on a webpage.
10
11
  */
@@ -21,6 +22,8 @@ export function Seo(props) {
21
22
  return React.createElement(CollectionSeo, { ...props.data });
22
23
  case 'page':
23
24
  return React.createElement(PageSeo, { ...props.data });
25
+ case 'noindex':
26
+ return React.createElement(NoIndexPageSeo, { ...props.data });
24
27
  default:
25
28
  console.warn('The <Seo/> only accepts type prop with values of defaultSeo, homepage, product, collection, or page.');
26
29
  return null;
@@ -1,3 +1,3 @@
1
- import type { HydrogenConfig } from './types';
2
- export declare const defineConfig: (params: HydrogenConfig) => HydrogenConfig;
3
- export type { HydrogenConfig };
1
+ import type { InlineHydrogenConfig } from './types';
2
+ export declare const defineConfig: (params: InlineHydrogenConfig) => InlineHydrogenConfig;
3
+ export type { InlineHydrogenConfig as HydrogenConfig };
@@ -1,6 +1,4 @@
1
- /* eslint-disable hydrogen/no-state-in-server-components */
2
1
  import React, { Suspense, useState, StrictMode, Fragment, } from 'react';
3
- // @ts-expect-error hydrateRoot isn't on the TS types yet, but we're using React 18 so it exists
4
2
  import { hydrateRoot } from 'react-dom/client';
5
3
  import { ErrorBoundary } from 'react-error-boundary';
6
4
  import { useServerResponse } from './framework/Hydration/rsc';
@@ -70,4 +68,3 @@ function Error({ error }) {
70
68
  React.createElement("a", { href: "/", style: { textDecoration: 'underline' } }, "home page"),
71
69
  "."))));
72
70
  }
73
- /* eslint-enable hydrogen/no-state-in-server-components */
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { Logger } from './utilities/log';
3
- import type { HydrogenConfig, ImportGlobEagerOutput } from './types';
3
+ import type { ImportGlobEagerOutput } from './types';
4
4
  import { ServerComponentResponse } from './framework/Hydration/ServerComponentResponse.server';
5
5
  import { ServerComponentRequest } from './framework/Hydration/ServerComponentRequest.server';
6
6
  import type { ServerResponse, IncomingMessage } from 'http';
@@ -22,7 +22,7 @@ interface RequestHandlerOptions {
22
22
  export interface RequestHandler {
23
23
  (request: Request | IncomingMessage, options: RequestHandlerOptions): Promise<Response | undefined>;
24
24
  }
25
- export declare const renderHydrogen: (App: any, hydrogenConfig?: HydrogenConfig | undefined) => RequestHandler;
25
+ export declare const renderHydrogen: (App: any) => RequestHandler;
26
26
  declare type SharedServerProps = {
27
27
  state?: object | null;
28
28
  request: ServerComponentRequest;