@shopify/hydrogen 0.19.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.
- package/CHANGELOG.md +203 -0
- package/config.d.ts +1 -0
- package/dist/esnext/client.d.ts +1 -0
- package/dist/esnext/client.js +1 -0
- package/dist/esnext/components/CartEstimatedCost/CartEstimatedCost.client.d.ts +1 -1
- package/dist/esnext/components/CartLineImage/CartLineImage.client.d.ts +4 -7
- package/dist/esnext/components/CartLineImage/CartLineImage.client.js +1 -2
- package/dist/esnext/components/CartLinePrice/CartLinePrice.client.d.ts +1 -1
- package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +9 -4
- package/dist/esnext/components/CartProvider/CartProvider.client.js +42 -30
- package/dist/esnext/components/CartProvider/cart-queries.d.ts +10 -9
- package/dist/esnext/components/CartProvider/cart-queries.js +58 -743
- package/dist/esnext/components/CartProvider/hooks.client.js +4 -2
- package/dist/esnext/components/CartProvider/types.d.ts +2 -0
- package/dist/esnext/components/Image/Image.d.ts +77 -39
- package/dist/esnext/components/Image/Image.js +57 -54
- package/dist/esnext/components/Image/index.d.ts +1 -0
- package/dist/esnext/components/MediaFile/MediaFile.d.ts +2 -2
- package/dist/esnext/components/MediaFile/MediaFile.js +5 -4
- package/dist/esnext/components/Money/Money.client.d.ts +11 -5
- package/dist/esnext/components/Money/Money.client.js +16 -3
- package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +1 -2
- package/dist/esnext/components/ProductPrice/ProductPrice.client.js +1 -2
- package/dist/esnext/components/Seo/NoIndexSeo.client.d.ts +3 -0
- package/dist/esnext/components/Seo/NoIndexSeo.client.js +10 -0
- package/dist/esnext/components/Seo/Seo.client.d.ts +4 -0
- package/dist/esnext/components/Seo/Seo.client.js +3 -0
- package/dist/esnext/components/Video/Video.d.ts +3 -3
- package/dist/esnext/components/Video/Video.js +7 -4
- package/dist/esnext/components/index.d.ts +0 -3
- package/dist/esnext/components/index.js +0 -3
- package/dist/esnext/config.d.ts +3 -3
- package/dist/esnext/entry-client.js +0 -3
- package/dist/esnext/entry-server.d.ts +14 -2
- package/dist/esnext/entry-server.js +97 -73
- package/dist/esnext/foundation/Analytics/Analytics.client.js +1 -1
- package/dist/esnext/foundation/Analytics/ClientAnalytics.js +2 -2
- package/dist/esnext/foundation/Analytics/connectors/PerformanceMetrics/PerformanceMetrics.client.js +2 -2
- package/dist/esnext/foundation/Analytics/index.d.ts +0 -1
- package/dist/esnext/foundation/Analytics/index.js +0 -1
- package/dist/esnext/foundation/FileRoutes/FileRoutes.server.js +5 -10
- package/dist/esnext/foundation/Router/BrowserRouter.client.d.ts +2 -1
- package/dist/esnext/foundation/Router/BrowserRouter.client.js +1 -1
- package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +0 -2
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +18 -3
- package/dist/esnext/foundation/ShopifyProvider/ShopifyProvider.server.js +0 -1
- package/dist/esnext/foundation/fetchSync/server/fetchSync.d.ts +1 -1
- package/dist/esnext/foundation/fetchSync/server/fetchSync.js +1 -1
- package/dist/esnext/foundation/useQuery/hooks.js +8 -9
- package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.d.ts +2 -1
- package/dist/esnext/foundation/useRouteParams/RouteParamsProvider.client.js +1 -1
- package/dist/esnext/framework/Hydration/Html.js +3 -1
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +2 -2
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.d.ts +1 -10
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +2 -20
- package/dist/esnext/framework/Hydration/rsc.js +55 -7
- package/dist/esnext/framework/cache/in-memory.js +0 -6
- package/dist/esnext/framework/cache-sub-request.d.ts +17 -0
- package/dist/esnext/framework/cache-sub-request.js +64 -0
- package/dist/esnext/framework/cache.d.ts +6 -6
- package/dist/esnext/framework/cache.js +36 -33
- package/dist/esnext/framework/middleware.js +1 -15
- package/dist/esnext/framework/plugin.js +7 -30
- package/dist/esnext/framework/plugins/vite-plugin-client-imports.d.ts +2 -0
- package/dist/esnext/framework/plugins/vite-plugin-client-imports.js +25 -0
- package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.d.ts +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-css-modules-rsc.js +73 -3
- package/dist/esnext/framework/plugins/vite-plugin-hydration-auto-import.js +1 -4
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +7 -5
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +8 -50
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.d.ts +1 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-rsc.js +30 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +7 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-virtual-files.js +99 -0
- package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +4 -4
- package/dist/esnext/framework/plugins/vite-plugin-ssr-interop.js +6 -3
- package/dist/esnext/framework/viteception.d.ts +4 -0
- package/dist/esnext/framework/viteception.js +15 -0
- package/dist/esnext/hooks/useShopQuery/hooks.d.ts +1 -2
- package/dist/esnext/hooks/useShopQuery/hooks.js +0 -1
- package/dist/esnext/index.d.ts +24 -9
- package/dist/esnext/index.js +24 -13
- package/dist/esnext/storefront-api-types.d.ts +6 -4
- package/dist/esnext/storefront-api-types.js +5 -3
- package/dist/esnext/streaming.server.d.ts +3 -1
- package/dist/esnext/types.d.ts +13 -5
- package/dist/esnext/utilities/apiRoutes.d.ts +4 -5
- package/dist/esnext/utilities/apiRoutes.js +2 -8
- package/dist/esnext/utilities/fetch.d.ts +1 -2
- package/dist/esnext/utilities/fetch.js +1 -3
- package/dist/esnext/utilities/graphql-tag.d.ts +1 -0
- package/dist/esnext/utilities/graphql-tag.js +6 -0
- package/dist/esnext/utilities/graphql-tracker.d.ts +1 -1
- package/dist/esnext/utilities/graphql-tracker.js +4 -0
- package/dist/esnext/utilities/html-encoding.d.ts +1 -0
- package/dist/esnext/utilities/html-encoding.js +8 -0
- package/dist/esnext/utilities/image_size.d.ts +4 -22
- package/dist/esnext/utilities/image_size.js +15 -33
- package/dist/esnext/utilities/index.d.ts +2 -1
- package/dist/esnext/utilities/index.js +2 -1
- package/dist/esnext/utilities/log/log-cache-api-status.js +5 -1
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/components/Image/Image.d.ts +84 -0
- package/dist/node/components/Image/Image.js +89 -0
- package/dist/node/components/Image/index.d.ts +2 -0
- package/dist/node/components/Image/index.js +5 -0
- package/dist/node/entry-server.d.ts +14 -2
- package/dist/node/entry-server.js +97 -73
- package/dist/node/foundation/Analytics/Analytics.client.js +6 -6
- package/dist/node/foundation/Analytics/ClientAnalytics.js +2 -2
- package/dist/node/foundation/Router/BrowserRouter.client.d.ts +2 -1
- package/dist/node/foundation/Router/BrowserRouter.client.js +1 -1
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.js +0 -2
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +18 -3
- package/dist/node/framework/Hydration/Html.js +3 -1
- package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +2 -2
- package/dist/node/framework/Hydration/ServerComponentResponse.server.d.ts +1 -10
- package/dist/node/framework/Hydration/ServerComponentResponse.server.js +2 -20
- package/dist/node/framework/Hydration/rsc.js +55 -7
- package/dist/node/framework/cache/in-memory.js +0 -6
- package/dist/node/framework/cache-sub-request.d.ts +17 -0
- package/dist/node/framework/cache-sub-request.js +95 -0
- package/dist/node/framework/cache.d.ts +6 -6
- package/dist/node/framework/cache.js +38 -35
- package/dist/node/framework/middleware.js +1 -15
- package/dist/node/framework/plugin.js +7 -53
- package/dist/node/framework/plugins/vite-plugin-client-imports.d.ts +2 -0
- package/dist/node/framework/plugins/vite-plugin-client-imports.js +28 -0
- package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.d.ts +1 -1
- package/dist/node/framework/plugins/vite-plugin-css-modules-rsc.js +76 -3
- package/dist/node/framework/plugins/vite-plugin-hydration-auto-import.js +1 -4
- package/dist/node/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +7 -5
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +1 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +7 -49
- package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.d.ts +1 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-rsc.js +36 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.d.ts +7 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-virtual-files.js +105 -0
- package/dist/node/framework/plugins/vite-plugin-platform-entry.js +4 -4
- package/dist/node/framework/plugins/vite-plugin-ssr-interop.js +6 -3
- package/dist/node/framework/viteception.d.ts +4 -0
- package/dist/node/framework/viteception.js +19 -0
- package/dist/node/storefront-api-types.d.ts +6 -4
- package/dist/node/storefront-api-types.js +5 -3
- package/dist/node/streaming.server.d.ts +3 -1
- package/dist/node/types.d.ts +13 -5
- package/dist/node/utilities/apiRoutes.d.ts +4 -5
- package/dist/node/utilities/apiRoutes.js +2 -8
- package/dist/node/utilities/fetch.d.ts +1 -2
- package/dist/node/utilities/fetch.js +1 -3
- package/dist/node/utilities/html-encoding.d.ts +1 -0
- package/dist/node/utilities/html-encoding.js +12 -0
- package/dist/node/utilities/image_size.d.ts +4 -22
- package/dist/node/utilities/image_size.js +16 -58
- package/dist/node/utilities/index.d.ts +2 -1
- package/dist/node/utilities/index.js +3 -2
- package/dist/node/utilities/log/log-cache-api-status.js +5 -1
- package/dist/node/version.d.ts +1 -1
- package/dist/node/version.js +1 -1
- package/entry-server.d.ts +1 -1
- package/package.json +6 -5
- package/vendor/react-server-dom-vite/cjs/react-server-dom-vite-plugin.js +214 -28
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-client-proxy.js +2 -0
- package/vendor/react-server-dom-vite/esm/react-server-dom-vite-plugin.js +214 -28
- package/vendor/react-server-dom-vite/package.json +2 -1
- package/dist/esnext/components/ProductDescription/ProductDescription.client.d.ts +0 -13
- package/dist/esnext/components/ProductDescription/ProductDescription.client.js +0 -16
- package/dist/esnext/components/ProductDescription/index.d.ts +0 -1
- package/dist/esnext/components/ProductDescription/index.js +0 -1
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.d.ts +0 -21
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.js +0 -42
- package/dist/esnext/components/ProductMetafield/index.d.ts +0 -2
- package/dist/esnext/components/ProductMetafield/index.js +0 -1
- package/dist/esnext/components/ProductTitle/ProductTitle.client.d.ts +0 -13
- package/dist/esnext/components/ProductTitle/ProductTitle.client.js +0 -16
- package/dist/esnext/components/ProductTitle/index.d.ts +0 -1
- package/dist/esnext/components/ProductTitle/index.js +0 -1
- package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +0 -15
- package/dist/esnext/components/UnitPrice/UnitPrice.client.js +0 -22
- package/dist/esnext/components/UnitPrice/index.d.ts +0 -1
- package/dist/esnext/components/UnitPrice/index.js +0 -1
- package/dist/esnext/utilities/findRoutePrefix.d.ts +0 -1
- package/dist/esnext/utilities/findRoutePrefix.js +0 -17
- package/dist/node/foundation/Analytics/index.d.ts +0 -2
- package/dist/node/foundation/Analytics/index.js +0 -7
- package/dist/node/utilities/findRoutePrefix.d.ts +0 -1
- package/dist/node/utilities/findRoutePrefix.js +0 -21
|
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import { useShop } from '../../foundation';
|
|
3
3
|
import { flattenConnection } from '../../utilities';
|
|
4
4
|
import { CartCreate } from './cart-queries';
|
|
5
|
+
import { useCart } from '../../hooks/useCart';
|
|
5
6
|
export function useCartFetch() {
|
|
6
7
|
const { storeDomain, storefrontApiVersion, storefrontToken } = useShop();
|
|
7
8
|
return React.useCallback(({ query, variables, }) => {
|
|
@@ -28,6 +29,7 @@ export function useCartFetch() {
|
|
|
28
29
|
}, [storeDomain, storefrontApiVersion, storefrontToken]);
|
|
29
30
|
}
|
|
30
31
|
export function useInstantCheckout() {
|
|
32
|
+
const { cartFragment } = useCart();
|
|
31
33
|
const [cart, updateCart] = useState();
|
|
32
34
|
const [checkoutUrl, updateCheckoutUrl] = useState();
|
|
33
35
|
const [error, updateError] = useState();
|
|
@@ -35,7 +37,7 @@ export function useInstantCheckout() {
|
|
|
35
37
|
const createInstantCheckout = React.useCallback(async (cartInput) => {
|
|
36
38
|
var _a, _b;
|
|
37
39
|
const { data, error } = await fetch({
|
|
38
|
-
query: CartCreate,
|
|
40
|
+
query: CartCreate(cartFragment),
|
|
39
41
|
variables: {
|
|
40
42
|
input: cartInput,
|
|
41
43
|
},
|
|
@@ -55,6 +57,6 @@ export function useInstantCheckout() {
|
|
|
55
57
|
});
|
|
56
58
|
updateCheckoutUrl(dataCart.checkoutUrl);
|
|
57
59
|
}
|
|
58
|
-
}, [fetch]);
|
|
60
|
+
}, [cartFragment, fetch]);
|
|
59
61
|
return { cart, checkoutUrl, error, createInstantCheckout };
|
|
60
62
|
}
|
|
@@ -42,6 +42,8 @@ export interface CartWithActions extends Cart {
|
|
|
42
42
|
discountCodesUpdate: (discountCodes: string[]) => void;
|
|
43
43
|
/** The total number of items in the cart, across all lines. If there are no lines, then the value is 0. */
|
|
44
44
|
totalQuantity: number;
|
|
45
|
+
/** The fragment used to query the cart object for all queries and mutations. */
|
|
46
|
+
cartFragment: string;
|
|
45
47
|
}
|
|
46
48
|
export declare type State =
|
|
47
49
|
/** A cart has not been created yet, or an error occurred when a cart was attempting to be created or fetched. */
|
|
@@ -1,46 +1,84 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ImageSizeOptions, ImageLoaderOptions } from '../../utilities';
|
|
1
|
+
import * as React from 'react';
|
|
3
2
|
import type { Image as ImageType } from '../../storefront-api-types';
|
|
4
|
-
import type { PartialDeep,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type { PartialDeep, Simplify, SetRequired } from 'type-fest';
|
|
4
|
+
declare type HtmlImageProps = React.ImgHTMLAttributes<HTMLImageElement>;
|
|
5
|
+
declare type ImageProps<GenericLoaderOpts> = ShopifyImageProps | ExternalImageProps<GenericLoaderOpts>;
|
|
6
|
+
export declare function Image<GenericLoaderOpts>(props: ImageProps<GenericLoaderOpts>): JSX.Element;
|
|
7
|
+
export declare type ShopifyLoaderOptions = {
|
|
8
|
+
crop?: 'top' | 'bottom' | 'left' | 'right' | 'center';
|
|
9
|
+
scale?: 2 | 3;
|
|
10
|
+
width?: HtmlImageProps['width'] | ImageType['width'];
|
|
11
|
+
height?: HtmlImageProps['height'] | ImageType['height'];
|
|
12
|
+
};
|
|
13
|
+
export declare type ShopifyLoaderParams = Simplify<ShopifyLoaderOptions & {
|
|
14
|
+
src: ImageType['url'];
|
|
15
|
+
}>;
|
|
16
|
+
export declare type ShopifyImageProps = Omit<HtmlImageProps, 'src'> & {
|
|
17
|
+
/** An object with fields that correspond to the Storefront API's
|
|
18
|
+
* [Image object](https://shopify.dev/api/storefront/reference/common-objects/image).
|
|
19
|
+
* The `data` prop is required if `src` isn't used, but both props shouldn't be used
|
|
20
|
+
* at the same time. If both `src` and `data` are passed, then `data` takes priority.
|
|
21
|
+
*/
|
|
22
|
+
data: SetRequired<PartialDeep<ImageType>, 'url'>;
|
|
23
|
+
/** A custom function that generates the image URL. Parameters passed in
|
|
24
|
+
* are either `ShopifyLoaderParams` if using the `data` prop, or the
|
|
25
|
+
* `LoaderOptions` object that you pass to `loaderOptions`.
|
|
8
26
|
*/
|
|
9
|
-
loader
|
|
10
|
-
/** An object of `loader` function options. For example, if the `loader` function
|
|
11
|
-
* then the value can be a property of the
|
|
27
|
+
loader?: (params: ShopifyLoaderParams) => string;
|
|
28
|
+
/** An object of `loader` function options. For example, if the `loader` function
|
|
29
|
+
* requires a `scale` option, then the value can be a property of the
|
|
30
|
+
* `loaderOptions` object (for example, `{scale: 2}`). When the `data` prop
|
|
31
|
+
* is used, the object shape will be `ShopifyLoaderOptions`. When the `src`
|
|
32
|
+
* prop is used, the data shape is whatever you define it to be, and this shape
|
|
33
|
+
* will be passed to `loader`.
|
|
12
34
|
*/
|
|
13
|
-
loaderOptions?:
|
|
35
|
+
loaderOptions?: ShopifyLoaderOptions;
|
|
14
36
|
/**
|
|
15
|
-
*
|
|
16
|
-
* the image is visible above the fold. For more information, refer to the
|
|
17
|
-
* [Image Embed element's loading attribute](https://developer.mozilla.org/enUS/docs/Web/HTML/Element/img#attr-loading).
|
|
37
|
+
* 'src' shouldn't be passed when 'data' is used.
|
|
18
38
|
*/
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
39
|
+
src?: never;
|
|
40
|
+
};
|
|
41
|
+
declare type LoaderProps<GenericLoaderOpts> = {
|
|
42
|
+
/** A URL string. This string can be an absolute path or a relative path depending
|
|
43
|
+
* on the `loader`. The `src` prop is required if `data` isn't used, but both
|
|
44
|
+
* props shouldn't be used at the same time. If both `src` and `data` are passed,
|
|
45
|
+
* then `data` takes priority.
|
|
46
|
+
*/
|
|
47
|
+
src: HtmlImageProps['src'];
|
|
48
|
+
/** The integer or string value for the width of the image. This is a required prop
|
|
49
|
+
* when `src` is present.
|
|
50
|
+
*/
|
|
51
|
+
width: HtmlImageProps['width'];
|
|
52
|
+
/** The integer or string value for the height of the image. This is a required prop
|
|
53
|
+
* when `src` is present.
|
|
54
|
+
*/
|
|
55
|
+
height: HtmlImageProps['height'];
|
|
56
|
+
/** An object of `loader` function options. For example, if the `loader` function
|
|
57
|
+
* requires a `scale` option, then the value can be a property of the
|
|
58
|
+
* `loaderOptions` object (for example, `{scale: 2}`). When the `data` prop
|
|
59
|
+
* is used, the object shape will be `ShopifyLoaderOptions`. When the `src`
|
|
60
|
+
* prop is used, the data shape is whatever you define it to be, and this shape
|
|
61
|
+
* will be passed to `loader`.
|
|
62
|
+
*/
|
|
63
|
+
loaderOptions?: GenericLoaderOpts;
|
|
64
|
+
};
|
|
65
|
+
declare type ExternalImageProps<GenericLoaderOpts> = SetRequired<HtmlImageProps, 'src' | 'width' | 'height' | 'alt'> & {
|
|
66
|
+
/** A custom function that generates the image URL. Parameters passed in
|
|
67
|
+
* are either `ShopifyLoaderParams` if using the `data` prop, or the
|
|
68
|
+
* `LoaderOptions` object that you pass to `loaderOptions`.
|
|
69
|
+
*/
|
|
70
|
+
loader?: (params: LoaderProps<GenericLoaderOpts>) => string;
|
|
71
|
+
/** An object of `loader` function options. For example, if the `loader` function
|
|
72
|
+
* requires a `scale` option, then the value can be a property of the
|
|
73
|
+
* `loaderOptions` object (for example, `{scale: 2}`). When the `data` prop
|
|
74
|
+
* is used, the object shape will be `ShopifyLoaderOptions`. When the `src`
|
|
75
|
+
* prop is used, the data shape is whatever you define it to be, and this shape
|
|
76
|
+
* will be passed to `loader`.
|
|
77
|
+
*/
|
|
78
|
+
loaderOptions?: GenericLoaderOpts;
|
|
79
|
+
/**
|
|
80
|
+
* 'data' shouldn't be passed when 'src' is used.
|
|
24
81
|
*/
|
|
25
|
-
data
|
|
26
|
-
|
|
27
|
-
options?: ImageSizeOptions;
|
|
28
|
-
}
|
|
29
|
-
interface ExternalImagePropsBase extends BaseImageProps {
|
|
30
|
-
/** A URL string. This string can be an absolute path or a relative path depending on the `loader`. */
|
|
31
|
-
src: string;
|
|
32
|
-
/** The integer value for the width of the image. This is a required prop when `src` is present. */
|
|
33
|
-
width: number;
|
|
34
|
-
/** The integer value for the height of the image. This is a required prop when `src` is present. */
|
|
35
|
-
height: number;
|
|
36
|
-
}
|
|
37
|
-
declare type BaseElementProps = React.ImgHTMLAttributes<HTMLImageElement>;
|
|
38
|
-
declare type MediaImageProps = Merge<BaseElementProps, MediaImagePropsBase>;
|
|
39
|
-
declare type ExternalImageProps = Merge<BaseElementProps, ExternalImagePropsBase>;
|
|
40
|
-
declare type ImageProps = MergeExclusive<MediaImageProps, ExternalImageProps>;
|
|
41
|
-
/**
|
|
42
|
-
* The `Image` component renders an image for the Storefront API's
|
|
43
|
-
* [Image object](https://shopify.dev/api/storefront/reference/common-objects/image).
|
|
44
|
-
*/
|
|
45
|
-
export declare function Image(props: ImageProps): JSX.Element;
|
|
82
|
+
data?: never;
|
|
83
|
+
};
|
|
46
84
|
export {};
|
|
@@ -1,59 +1,62 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
/**
|
|
4
|
-
* The `Image` component renders an image for the Storefront API's
|
|
5
|
-
* [Image object](https://shopify.dev/api/storefront/reference/common-objects/image).
|
|
6
|
-
*/
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getShopifyImageDimensions, shopifyImageLoader } from '../../utilities';
|
|
7
3
|
export function Image(props) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
4
|
+
if (!props.data && !props.src) {
|
|
5
|
+
throw new Error(`<Image/>: requires either a 'data' or 'src' prop.`);
|
|
6
|
+
}
|
|
7
|
+
if (__DEV__ && props.data && props.src) {
|
|
8
|
+
console.warn(`<Image/>: using both 'data' and 'src' props is not supported; using the 'data' prop by default`);
|
|
9
|
+
}
|
|
10
|
+
if (props.data) {
|
|
11
|
+
return React.createElement(ShopifyImage, { ...props });
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return React.createElement(ExternalImage, { ...props });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function ShopifyImage({ data, width, height, loading, loader = shopifyImageLoader, loaderOptions, ...rest }) {
|
|
18
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19
|
+
if (!data.url) {
|
|
20
|
+
throw new Error(`<Image/>: the 'data' prop requires the 'url' property`);
|
|
21
|
+
}
|
|
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
|
+
}
|
|
25
|
+
const { width: finalWidth, height: finalHeight } = getShopifyImageDimensions(data, loaderOptions);
|
|
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
|
+
}
|
|
29
|
+
let finalSrc = data.url;
|
|
30
|
+
if (loader) {
|
|
31
|
+
finalSrc = loader({
|
|
32
|
+
...loaderOptions,
|
|
33
|
+
src: data.url,
|
|
34
|
+
width: finalWidth,
|
|
35
|
+
height: finalHeight,
|
|
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
|
+
}
|
|
40
|
+
}
|
|
39
41
|
/* eslint-disable hydrogen/prefer-image-component */
|
|
40
|
-
return (React.createElement("img", { id: (
|
|
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 }));
|
|
41
43
|
/* eslint-enable hydrogen/prefer-image-component */
|
|
42
44
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
45
|
+
function ExternalImage({ src, width, height, alt, loader, loaderOptions, loading, ...rest }) {
|
|
46
|
+
if (!width || !height) {
|
|
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}`);
|
|
48
|
+
}
|
|
49
|
+
if (__DEV__ && !alt) {
|
|
50
|
+
console.warn(`<Image/>: when 'src' is provided, 'alt' should also be provided. ${`Image: ${src}`}`);
|
|
51
|
+
}
|
|
52
|
+
let finalSrc = src;
|
|
53
|
+
if (loader) {
|
|
54
|
+
finalSrc = loader({ src, width, height, ...loaderOptions });
|
|
55
|
+
if (typeof finalSrc !== 'string' || !finalSrc) {
|
|
56
|
+
throw new Error(`<Image/>: 'loader' did not return a valid string`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/* eslint-disable hydrogen/prefer-image-component */
|
|
60
|
+
return (React.createElement("img", { ...rest, src: finalSrc, width: width, height: height, alt: alt !== null && alt !== void 0 ? alt : '', loading: loading !== null && loading !== void 0 ? loading : 'lazy' }));
|
|
61
|
+
/* eslint-enable hydrogen/prefer-image-component */
|
|
59
62
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { type ShopifyImageProps } from '../Image';
|
|
3
3
|
import { Video } from '../Video';
|
|
4
4
|
import { ExternalVideo } from '../ExternalVideo';
|
|
5
5
|
import type { MediaEdge as MediaEdgeType } from '../../storefront-api-types';
|
|
@@ -8,7 +8,7 @@ export interface MediaFileProps {
|
|
|
8
8
|
/** An object with fields that correspond to the Storefront API's [Media object](https://shopify.dev/api/storefront/reference/products/media). */
|
|
9
9
|
data: PartialDeep<MediaEdgeType['node']>;
|
|
10
10
|
/** The options for the `Image`, `Video`, or `ExternalVideo` components. */
|
|
11
|
-
options?:
|
|
11
|
+
options?: ShopifyImageProps | React.ComponentProps<typeof Video>['previewImageOptions'] | React.ComponentProps<typeof ExternalVideo>['options'];
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* The `MediaFile` component renders the media for the Storefront API's
|
|
@@ -12,15 +12,16 @@ 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
|
|
16
|
-
|
|
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
|
}
|
|
20
|
-
return (React.createElement(Image, { ...passthroughProps, data: dataImage,
|
|
21
|
+
return (React.createElement(Image, { ...passthroughProps, data: dataImage, loaderOptions: options }));
|
|
21
22
|
}
|
|
22
23
|
case 'VIDEO':
|
|
23
|
-
return (React.createElement(Video, { ...passthroughProps, data: data,
|
|
24
|
+
return (React.createElement(Video, { ...passthroughProps, data: data, previewImageOptions: options }));
|
|
24
25
|
case 'EXTERNAL_VIDEO':
|
|
25
26
|
return (React.createElement(ExternalVideo, { ...passthroughProps, data: data, options: options }));
|
|
26
27
|
case 'MODEL_3D':
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
import type { MoneyV2, UnitPriceMeasurement } from '../../storefront-api-types';
|
|
2
3
|
import type { PartialDeep } from 'type-fest';
|
|
3
|
-
interface
|
|
4
|
-
/** An HTML tag to be rendered as the base element wrapper. The default is `div`. */
|
|
5
|
-
as?:
|
|
4
|
+
interface CustomProps<ComponentGeneric extends React.ElementType> {
|
|
5
|
+
/** An HTML tag or React Component to be rendered as the base element wrapper. The default is `div`. */
|
|
6
|
+
as?: ComponentGeneric;
|
|
6
7
|
/** An object with fields that correspond to the Storefront API's [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2). */
|
|
7
8
|
data: PartialDeep<MoneyV2>;
|
|
8
9
|
/** Whether to remove the currency symbol from the output. */
|
|
9
10
|
withoutCurrency?: boolean;
|
|
10
11
|
/** Whether to remove trailing zeros (fractional money) from the output. */
|
|
11
12
|
withoutTrailingZeros?: boolean;
|
|
13
|
+
/** A [UnitPriceMeasurement object](https://shopify.dev/api/storefront/latest/objects/unitpricemeasurement). */
|
|
14
|
+
measurement?: PartialDeep<UnitPriceMeasurement>;
|
|
15
|
+
/** Customizes the separator between the money output and the measurement output. Used with the `measurement` prop. Defaults to `'/'`. */
|
|
16
|
+
measurementSeparator?: ReactNode;
|
|
12
17
|
}
|
|
18
|
+
declare type MoneyProps<ComponentGeneric extends React.ElementType> = CustomProps<ComponentGeneric> & Omit<React.ComponentPropsWithoutRef<ComponentGeneric>, keyof CustomProps<ComponentGeneric>>;
|
|
13
19
|
/**
|
|
14
20
|
* The `Money` component renders a string of the Storefront API's
|
|
15
21
|
* [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) according to the
|
|
16
22
|
* `defaultLocale` in [the `hydrogen.config.js` file](https://shopify.dev/custom-storefronts/hydrogen/framework/hydrogen-config).
|
|
17
23
|
*/
|
|
18
|
-
export declare function Money<TTag extends
|
|
24
|
+
export declare function Money<TTag extends React.ElementType>({ data, as, withoutCurrency, withoutTrailingZeros, measurement, measurementSeparator, ...passthroughProps }: MoneyProps<TTag>): JSX.Element;
|
|
19
25
|
export {};
|
|
@@ -5,8 +5,10 @@ import { useMoney } from '../../hooks';
|
|
|
5
5
|
* [MoneyV2 object](https://shopify.dev/api/storefront/reference/common-objects/moneyv2) according to the
|
|
6
6
|
* `defaultLocale` in [the `hydrogen.config.js` file](https://shopify.dev/custom-storefronts/hydrogen/framework/hydrogen-config).
|
|
7
7
|
*/
|
|
8
|
-
export function Money(
|
|
9
|
-
|
|
8
|
+
export function Money({ data, as, withoutCurrency, withoutTrailingZeros, measurement, measurementSeparator = '/', ...passthroughProps }) {
|
|
9
|
+
if (!isMoney(data)) {
|
|
10
|
+
throw new Error(`<Money/> needs a valid 'data' prop that has 'amount' and 'currencyCode'`);
|
|
11
|
+
}
|
|
10
12
|
const moneyObject = useMoney(data);
|
|
11
13
|
const Wrapper = as !== null && as !== void 0 ? as : 'div';
|
|
12
14
|
let output = moneyObject.localizedString;
|
|
@@ -22,5 +24,16 @@ export function Money(props) {
|
|
|
22
24
|
output = moneyObject.withoutTrailingZerosAndCurrency;
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
|
-
return React.createElement(Wrapper, { ...passthroughProps },
|
|
27
|
+
return (React.createElement(Wrapper, { ...passthroughProps },
|
|
28
|
+
output,
|
|
29
|
+
measurement && measurement.referenceUnit && (React.createElement(React.Fragment, null,
|
|
30
|
+
measurementSeparator,
|
|
31
|
+
measurement.referenceUnit))));
|
|
32
|
+
}
|
|
33
|
+
// required in order to narrow the money object down and make TS happy
|
|
34
|
+
function isMoney(maybeMoney) {
|
|
35
|
+
return (typeof maybeMoney.amount === 'string' &&
|
|
36
|
+
!!maybeMoney.amount &&
|
|
37
|
+
typeof maybeMoney.currencyCode === 'string' &&
|
|
38
|
+
!!maybeMoney.currencyCode);
|
|
26
39
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Money } from '../Money';
|
|
3
|
-
import { UnitPrice } from '../UnitPrice';
|
|
4
3
|
export interface ProductPriceProps {
|
|
5
4
|
/** The type of price. Valid values: `regular` (default) or `compareAt`. */
|
|
6
5
|
priceType?: 'regular' | 'compareAt';
|
|
@@ -13,4 +12,4 @@ export interface ProductPriceProps {
|
|
|
13
12
|
* The `ProductPrice` component renders a `Money` component with the product
|
|
14
13
|
* [`priceRange`](https://shopify.dev/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range. It must be a descendent of the `ProductProvider` component.
|
|
15
14
|
*/
|
|
16
|
-
export declare function ProductPrice<TTag extends keyof JSX.IntrinsicElements>(props:
|
|
15
|
+
export declare function ProductPrice<TTag extends keyof JSX.IntrinsicElements>(props: Omit<React.ComponentProps<typeof Money>, 'data' | 'measurement'> & ProductPriceProps): JSX.Element | null;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Money } from '../Money';
|
|
3
3
|
import { useProduct } from '../ProductProvider';
|
|
4
|
-
import { UnitPrice } from '../UnitPrice';
|
|
5
4
|
/**
|
|
6
5
|
* The `ProductPrice` component renders a `Money` component with the product
|
|
7
6
|
* [`priceRange`](https://shopify.dev/api/storefront/reference/products/productpricerange)'s `maxVariantPrice` or `minVariantPrice`, for either the regular price or compare at price range. It must be a descendent of the `ProductProvider` component.
|
|
@@ -51,7 +50,7 @@ export function ProductPrice(props) {
|
|
|
51
50
|
return null;
|
|
52
51
|
}
|
|
53
52
|
if (measurement) {
|
|
54
|
-
return (React.createElement(
|
|
53
|
+
return (React.createElement(Money, { ...passthroughProps, data: price, measurement: measurement }));
|
|
55
54
|
}
|
|
56
55
|
return React.createElement(Money, { ...passthroughProps, data: price });
|
|
57
56
|
}
|
|
@@ -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,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { shopifyImageLoader } from '../../utilities';
|
|
2
2
|
import type { Video as VideoType } from '../../storefront-api-types';
|
|
3
3
|
import type { PartialDeep } from 'type-fest';
|
|
4
4
|
interface VideoProps {
|
|
5
5
|
/** An object with fields that correspond to the Storefront API's [Video object](https://shopify.dev/api/storefront/latest/objects/video). */
|
|
6
6
|
data: PartialDeep<VideoType>;
|
|
7
|
-
/** An object of image size options for the video's `previewImage`. */
|
|
8
|
-
|
|
7
|
+
/** An object of image size options for the video's `previewImage`. Uses `shopifyImageLoader` to generate the `poster` URL. */
|
|
8
|
+
previewImageOptions?: Parameters<typeof shopifyImageLoader>[0];
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* The `Video` component renders a `video` for the Storefront API's [Video object](https://shopify.dev/api/storefront/reference/products/video).
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { shopifyImageLoader } from '../../utilities';
|
|
3
3
|
/**
|
|
4
4
|
* The `Video` component renders a `video` for the Storefront API's [Video object](https://shopify.dev/api/storefront/reference/products/video).
|
|
5
5
|
*/
|
|
6
6
|
export function Video(props) {
|
|
7
|
-
var _a;
|
|
8
|
-
const { data,
|
|
9
|
-
const posterUrl =
|
|
7
|
+
var _a, _b;
|
|
8
|
+
const { data, previewImageOptions, id = data.id, playsInline = true, controls = true, ...passthroughProps } = props;
|
|
9
|
+
const posterUrl = shopifyImageLoader({
|
|
10
|
+
src: (_b = (_a = data.previewImage) === null || _a === void 0 ? void 0 : _a.url) !== null && _b !== void 0 ? _b : '',
|
|
11
|
+
...previewImageOptions,
|
|
12
|
+
});
|
|
10
13
|
if (!data.sources) {
|
|
11
14
|
throw new Error(`<Video/> requires a 'data.sources' array`);
|
|
12
15
|
}
|
|
@@ -21,10 +21,7 @@ export { CartEstimatedCost } from './CartEstimatedCost';
|
|
|
21
21
|
export { CartProvider, useCart, useInstantCheckout } from './CartProvider';
|
|
22
22
|
export type { State, Status, Cart, CartWithActions, CartAction, } from './CartProvider';
|
|
23
23
|
export { ProductProvider, useProduct } from './ProductProvider';
|
|
24
|
-
export { ProductDescription } from './ProductDescription';
|
|
25
|
-
export { ProductTitle } from './ProductTitle';
|
|
26
24
|
export { ProductPrice } from './ProductPrice';
|
|
27
|
-
export { ProductMetafield } from './ProductMetafield';
|
|
28
25
|
export { BuyNowButton } from './BuyNowButton';
|
|
29
26
|
export { ShopPayButton } from './ShopPayButton';
|
|
30
27
|
export { useCountry } from '../hooks/useCountry';
|
|
@@ -19,10 +19,7 @@ export { CartShopPayButton } from './CartShopPayButton';
|
|
|
19
19
|
export { CartEstimatedCost } from './CartEstimatedCost';
|
|
20
20
|
export { CartProvider, useCart, useInstantCheckout } from './CartProvider';
|
|
21
21
|
export { ProductProvider, useProduct } from './ProductProvider';
|
|
22
|
-
export { ProductDescription } from './ProductDescription';
|
|
23
|
-
export { ProductTitle } from './ProductTitle';
|
|
24
22
|
export { ProductPrice } from './ProductPrice';
|
|
25
|
-
export { ProductMetafield } from './ProductMetafield';
|
|
26
23
|
export { BuyNowButton } from './BuyNowButton';
|
|
27
24
|
export { ShopPayButton } from './ShopPayButton';
|
|
28
25
|
export { useCountry } from '../hooks/useCountry';
|
package/dist/esnext/config.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const defineConfig: (params:
|
|
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,5 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import
|
|
2
|
+
import { Logger } from './utilities/log';
|
|
3
|
+
import type { ImportGlobEagerOutput } from './types';
|
|
4
|
+
import { ServerComponentResponse } from './framework/Hydration/ServerComponentResponse.server';
|
|
5
|
+
import { ServerComponentRequest } from './framework/Hydration/ServerComponentRequest.server';
|
|
3
6
|
import type { ServerResponse, IncomingMessage } from 'http';
|
|
4
7
|
import { RuntimeContext } from './framework/runtime';
|
|
5
8
|
declare global {
|
|
@@ -19,5 +22,14 @@ interface RequestHandlerOptions {
|
|
|
19
22
|
export interface RequestHandler {
|
|
20
23
|
(request: Request | IncomingMessage, options: RequestHandlerOptions): Promise<Response | undefined>;
|
|
21
24
|
}
|
|
22
|
-
export declare const renderHydrogen: (App: any
|
|
25
|
+
export declare const renderHydrogen: (App: any) => RequestHandler;
|
|
26
|
+
declare type SharedServerProps = {
|
|
27
|
+
state?: object | null;
|
|
28
|
+
request: ServerComponentRequest;
|
|
29
|
+
response: ServerComponentResponse;
|
|
30
|
+
log: Logger;
|
|
31
|
+
};
|
|
32
|
+
export declare type AppProps = SharedServerProps & {
|
|
33
|
+
routes?: ImportGlobEagerOutput;
|
|
34
|
+
};
|
|
23
35
|
export default renderHydrogen;
|