@shopify/hydrogen 0.11.0-experimental.1 → 0.11.1-experimental.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 +504 -0
- package/dist/esnext/client.d.ts +1 -1
- package/dist/esnext/client.js +1 -1
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.d.ts +1 -1
- package/dist/esnext/components/AddToCartButton/AddToCartButton.client.js +11 -2
- package/dist/esnext/components/CartEstimatedCost/CartEstimatedCost.client.js +1 -1
- package/dist/esnext/components/CartLineImage/CartLineImage.client.js +2 -2
- package/dist/esnext/components/CartLinePrice/CartLinePrice.client.d.ts +1 -1
- package/dist/esnext/components/CartLinePrice/CartLinePrice.client.js +1 -1
- package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +2 -2
- package/dist/esnext/components/CartProvider/CartProvider.client.js +1 -1
- package/dist/esnext/components/ExternalVideo/ExternalVideo.d.ts +1 -1
- package/dist/esnext/components/ExternalVideo/ExternalVideo.js +2 -2
- package/dist/esnext/components/Image/Image.d.ts +1 -1
- package/dist/esnext/components/Image/Image.js +9 -9
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.d.ts +13 -4
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +5 -3
- package/dist/esnext/components/MediaFile/MediaFile.d.ts +8 -6
- package/dist/esnext/components/MediaFile/MediaFile.js +6 -6
- package/dist/esnext/components/Metafield/Metafield.client.d.ts +1 -1
- package/dist/esnext/components/Metafield/Metafield.client.js +16 -16
- package/dist/esnext/components/ModelViewer/ModelViewer.client.d.ts +1 -1
- package/dist/esnext/components/ModelViewer/ModelViewer.client.js +1 -1
- package/dist/esnext/components/Money/Money.client.d.ts +1 -1
- package/dist/esnext/components/Money/Money.client.js +2 -2
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.d.ts +3 -1
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.js +21 -4
- package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +5 -3
- package/dist/esnext/components/ProductPrice/ProductPrice.client.js +30 -9
- package/dist/esnext/components/ProductProvider/ProductOptionsProvider.client.d.ts +8 -0
- package/dist/esnext/components/ProductProvider/ProductOptionsProvider.client.js +12 -0
- package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +8 -7
- package/dist/esnext/components/ProductProvider/ProductProvider.client.js +9 -35
- package/dist/esnext/components/ProductProvider/context.d.ts +10 -6
- package/dist/esnext/components/ProductProvider/context.js +1 -0
- package/dist/esnext/components/Seo/DefaultPageSeo.client.js +2 -2
- package/dist/esnext/components/Seo/DescriptionSeo.client.js +2 -2
- package/dist/esnext/components/Seo/HomePageSeo.client.js +2 -2
- package/dist/esnext/components/Seo/ImageSeo.client.js +2 -2
- package/dist/esnext/components/Seo/ProductSeo.client.js +5 -3
- package/dist/esnext/components/Seo/TitleSeo.client.js +2 -2
- package/dist/esnext/components/Seo/TwitterSeo.client.js +2 -2
- package/dist/esnext/components/Seo/types.d.ts +1 -1
- package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +2 -2
- package/dist/esnext/components/UnitPrice/UnitPrice.client.js +3 -3
- package/dist/esnext/components/Video/Video.d.ts +1 -1
- package/dist/esnext/components/Video/Video.js +3 -3
- package/dist/esnext/components/index.d.ts +0 -8
- package/dist/esnext/components/index.js +0 -8
- package/dist/esnext/entry-client.js +1 -1
- package/dist/esnext/entry-server.d.ts +18 -2
- package/dist/esnext/entry-server.js +347 -329
- package/dist/esnext/foundation/Head/Head.client.d.ts +5 -0
- package/dist/esnext/foundation/Head/Head.client.js +10 -0
- package/dist/esnext/foundation/Head/index.d.ts +1 -0
- package/dist/esnext/foundation/Head/index.js +1 -0
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +2 -1
- package/dist/esnext/foundation/ServerRequestProvider/ServerRequestProvider.js +43 -4
- package/dist/esnext/foundation/useQuery/hooks.d.ts +11 -3
- package/dist/esnext/foundation/useQuery/hooks.js +21 -5
- package/dist/esnext/framework/CachingStrategy/index.d.ts +10 -0
- package/dist/esnext/framework/CachingStrategy/index.js +96 -0
- package/dist/esnext/framework/Hydration/Html.js +5 -12
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +20 -2
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.js +51 -2
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.d.ts +2 -2
- package/dist/esnext/framework/Hydration/ServerComponentResponse.server.js +2 -11
- package/dist/esnext/framework/cache/in-memory.js +6 -5
- package/dist/esnext/framework/cache.d.ts +3 -3
- package/dist/esnext/framework/cache.js +4 -18
- package/dist/esnext/framework/middleware.d.ts +7 -7
- package/dist/esnext/framework/middleware.js +15 -43
- package/dist/esnext/framework/plugin.js +14 -3
- package/dist/esnext/framework/plugins/vite-plugin-hydration-auto-import.d.ts +3 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydration-auto-import.js +38 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +9 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-client-middleware.js +37 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +2 -1
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-middleware.js +3 -1
- package/dist/esnext/framework/plugins/vite-plugin-platform-entry.d.ts +3 -0
- package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +70 -0
- package/dist/esnext/hooks/useProduct/useProduct.d.ts +150 -1
- package/dist/esnext/hooks/useProduct/useProduct.js +36 -3
- package/dist/esnext/hooks/useProductOptions/types.d.ts +1 -1
- package/dist/esnext/hooks/useProductOptions/useProductOptions.d.ts +1 -1
- package/dist/esnext/hooks/useProductOptions/useProductOptions.js +6 -6
- package/dist/esnext/hooks/useShopQuery/hooks.d.ts +11 -4
- package/dist/esnext/hooks/useShopQuery/hooks.js +6 -3
- package/dist/esnext/index.d.ts +2 -1
- package/dist/esnext/index.js +2 -1
- package/dist/esnext/platforms/node.d.ts +10 -0
- package/dist/esnext/platforms/node.js +38 -0
- package/dist/esnext/platforms/worker-event.d.ts +9 -0
- package/dist/esnext/platforms/worker-event.js +24 -0
- package/dist/esnext/streaming.server.d.ts +17 -7
- package/dist/esnext/streaming.server.js +44 -0
- package/dist/esnext/types.d.ts +25 -25
- package/dist/esnext/utilities/apiRoutes.d.ts +1 -2
- package/dist/esnext/utilities/apiRoutes.js +4 -3
- package/dist/esnext/utilities/bot-ua.d.ts +4 -0
- package/dist/esnext/utilities/bot-ua.js +54 -0
- package/dist/esnext/utilities/fetch.js +1 -26
- package/dist/esnext/utilities/log/index.d.ts +4 -1
- package/dist/esnext/utilities/log/index.js +4 -1
- package/dist/esnext/utilities/log/log-cache-api-status.d.ts +1 -0
- package/dist/esnext/utilities/log/log-cache-api-status.js +9 -0
- package/dist/esnext/utilities/log/log-cache-header.d.ts +10 -0
- package/dist/esnext/utilities/log/log-cache-header.js +30 -0
- package/dist/esnext/utilities/log/log-query-timeline.d.ts +12 -0
- package/dist/esnext/utilities/log/log-query-timeline.js +83 -0
- package/dist/esnext/utilities/log/log.d.ts +11 -8
- package/dist/esnext/utilities/log/log.js +24 -35
- package/dist/esnext/utilities/log/utils.d.ts +3 -0
- package/dist/esnext/utilities/log/utils.js +13 -0
- package/dist/esnext/utilities/template.d.ts +9 -0
- package/dist/esnext/utilities/template.js +23 -0
- package/dist/{worker/foundation/ShopifyProvider/types.js → esnext/utilities/web-api-polyfill.d.ts} +0 -0
- package/dist/esnext/utilities/web-api-polyfill.js +19 -0
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/entry-server.d.ts +22 -0
- package/dist/node/entry-server.js +581 -0
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.d.ts +23 -0
- package/dist/node/foundation/ServerRequestProvider/ServerRequestProvider.js +132 -0
- package/dist/node/foundation/ServerRequestProvider/index.d.ts +1 -0
- package/dist/node/foundation/ServerRequestProvider/index.js +13 -0
- package/dist/node/foundation/ServerStateProvider/ServerStateProvider.client.d.ts +25 -0
- package/dist/node/foundation/ServerStateProvider/ServerStateProvider.client.js +68 -0
- package/dist/node/foundation/ServerStateProvider/index.d.ts +2 -0
- package/dist/node/foundation/ServerStateProvider/index.js +6 -0
- package/dist/node/framework/CachingStrategy/index.d.ts +10 -0
- package/dist/node/framework/CachingStrategy/index.js +108 -0
- package/dist/node/framework/Hydration/Html.js +5 -12
- package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +20 -2
- package/dist/node/framework/Hydration/ServerComponentRequest.server.js +50 -1
- package/dist/node/framework/Hydration/ServerComponentResponse.server.d.ts +2 -2
- package/dist/node/framework/Hydration/ServerComponentResponse.server.js +2 -11
- package/dist/node/framework/cache/in-memory.js +6 -5
- package/dist/node/framework/cache.d.ts +3 -3
- package/dist/node/framework/cache.js +6 -20
- package/dist/node/framework/middleware.d.ts +7 -7
- package/dist/node/framework/middleware.js +14 -46
- package/dist/node/framework/plugin.js +33 -3
- package/dist/node/framework/plugins/vite-plugin-hydration-auto-import.d.ts +3 -0
- package/dist/node/framework/plugins/vite-plugin-hydration-auto-import.js +43 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-client-middleware.d.ts +9 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-client-middleware.js +39 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.d.ts +2 -1
- package/dist/node/framework/plugins/vite-plugin-hydrogen-middleware.js +4 -1
- package/dist/node/framework/plugins/vite-plugin-platform-entry.d.ts +3 -0
- package/dist/node/framework/plugins/vite-plugin-platform-entry.js +75 -0
- package/dist/node/streaming.server.d.ts +21 -0
- package/dist/node/streaming.server.js +59 -0
- package/dist/node/types.d.ts +25 -25
- package/dist/node/utilities/apiRoutes.d.ts +1 -2
- package/dist/node/utilities/apiRoutes.js +4 -3
- package/dist/node/utilities/bot-ua.d.ts +4 -0
- package/dist/node/utilities/bot-ua.js +58 -0
- package/dist/node/utilities/defer.d.ts +6 -0
- package/dist/node/utilities/defer.js +18 -0
- package/dist/node/utilities/error.d.ts +1 -0
- package/dist/node/utilities/error.js +10 -0
- package/dist/node/utilities/log/index.d.ts +4 -0
- package/dist/node/utilities/log/index.js +18 -0
- package/dist/node/utilities/log/log-cache-api-status.d.ts +1 -0
- package/dist/node/utilities/log/log-cache-api-status.js +13 -0
- package/dist/node/utilities/log/log-cache-header.d.ts +10 -0
- package/dist/node/utilities/log/log-cache-header.js +35 -0
- package/dist/node/utilities/log/log-query-timeline.d.ts +12 -0
- package/dist/node/utilities/log/log-query-timeline.js +88 -0
- package/dist/node/utilities/log/log.d.ts +11 -8
- package/dist/node/utilities/log/log.js +27 -37
- package/dist/node/utilities/log/utils.d.ts +3 -0
- package/dist/node/utilities/log/utils.js +18 -0
- package/dist/node/utilities/template.d.ts +9 -0
- package/dist/node/utilities/template.js +27 -0
- package/dist/{worker/types.js → node/utilities/web-api-polyfill.d.ts} +0 -0
- package/dist/node/utilities/web-api-polyfill.js +43 -0
- package/package.json +20 -10
- package/web-polyfills.js +1 -0
- package/LICENSE.md +0 -7
- package/dist/esnext/components/CartLineAttributes/CartLineAttributes.client.d.ts +0 -22
- package/dist/esnext/components/CartLineAttributes/CartLineAttributes.client.js +0 -13
- package/dist/esnext/components/CartLineAttributes/index.d.ts +0 -1
- package/dist/esnext/components/CartLineAttributes/index.js +0 -1
- package/dist/esnext/components/CartLineSelectedOptions/CartLineSelectedOptions.client.d.ts +0 -21
- package/dist/esnext/components/CartLineSelectedOptions/CartLineSelectedOptions.client.js +0 -13
- package/dist/esnext/components/CartLineSelectedOptions/index.d.ts +0 -1
- package/dist/esnext/components/CartLineSelectedOptions/index.js +0 -1
- package/dist/esnext/components/SelectedVariantAddToCartButton/SelectedVariantAddToCartButton.client.d.ts +0 -11
- package/dist/esnext/components/SelectedVariantAddToCartButton/SelectedVariantAddToCartButton.client.js +0 -17
- package/dist/esnext/components/SelectedVariantAddToCartButton/index.d.ts +0 -1
- package/dist/esnext/components/SelectedVariantAddToCartButton/index.js +0 -1
- package/dist/esnext/components/SelectedVariantBuyNowButton/SelectedVariantBuyNowButton.d.ts +0 -9
- package/dist/esnext/components/SelectedVariantBuyNowButton/SelectedVariantBuyNowButton.js +0 -17
- package/dist/esnext/components/SelectedVariantBuyNowButton/index.d.ts +0 -1
- package/dist/esnext/components/SelectedVariantBuyNowButton/index.js +0 -1
- package/dist/esnext/components/SelectedVariantImage/SelectedVariantImage.client.d.ts +0 -10
- package/dist/esnext/components/SelectedVariantImage/SelectedVariantImage.client.js +0 -16
- package/dist/esnext/components/SelectedVariantImage/index.d.ts +0 -1
- package/dist/esnext/components/SelectedVariantImage/index.js +0 -1
- package/dist/esnext/components/SelectedVariantMetafield/SelectedVariantMetafield.client.d.ts +0 -15
- package/dist/esnext/components/SelectedVariantMetafield/SelectedVariantMetafield.client.js +0 -24
- package/dist/esnext/components/SelectedVariantMetafield/index.d.ts +0 -1
- package/dist/esnext/components/SelectedVariantMetafield/index.js +0 -1
- package/dist/esnext/components/SelectedVariantPrice/SelectedVariantPrice.client.d.ts +0 -12
- package/dist/esnext/components/SelectedVariantPrice/SelectedVariantPrice.client.js +0 -22
- package/dist/esnext/components/SelectedVariantPrice/index.d.ts +0 -1
- package/dist/esnext/components/SelectedVariantPrice/index.js +0 -1
- package/dist/esnext/components/SelectedVariantShopPayButton/SelectedVariantShopPayButton.client.d.ts +0 -8
- package/dist/esnext/components/SelectedVariantShopPayButton/SelectedVariantShopPayButton.client.js +0 -18
- package/dist/esnext/components/SelectedVariantShopPayButton/index.d.ts +0 -1
- package/dist/esnext/components/SelectedVariantShopPayButton/index.js +0 -1
- package/dist/esnext/components/SelectedVariantUnitPrice/SelectedVariantUnitPrice.client.d.ts +0 -7
- package/dist/esnext/components/SelectedVariantUnitPrice/SelectedVariantUnitPrice.client.js +0 -16
- package/dist/esnext/components/SelectedVariantUnitPrice/index.d.ts +0 -1
- package/dist/esnext/components/SelectedVariantUnitPrice/index.js +0 -1
- package/dist/esnext/foundation/Helmet/Helmet.client.d.ts +0 -10
- package/dist/esnext/foundation/Helmet/Helmet.client.js +0 -10
- package/dist/esnext/foundation/Helmet/index.d.ts +0 -1
- package/dist/esnext/foundation/Helmet/index.js +0 -1
- package/dist/esnext/handle-event.d.ts +0 -23
- package/dist/esnext/handle-event.js +0 -132
- package/dist/esnext/handle-worker-event.d.ts +0 -11
- package/dist/esnext/handle-worker-event.js +0 -14
- package/dist/node/foundation/Helmet/Helmet.client.d.ts +0 -10
- package/dist/node/foundation/Helmet/Helmet.client.js +0 -17
- package/dist/node/foundation/Helmet/index.d.ts +0 -1
- package/dist/node/foundation/Helmet/index.js +0 -5
- package/dist/node/foundation/ssr-interop.d.ts +0 -29
- package/dist/node/foundation/ssr-interop.js +0 -39
- package/dist/node/handle-event.d.ts +0 -23
- package/dist/node/handle-event.js +0 -135
- package/dist/worker/constants.d.ts +0 -1
- package/dist/worker/constants.js +0 -1
- package/dist/worker/foundation/Helmet/Helmet.client.d.ts +0 -10
- package/dist/worker/foundation/Helmet/Helmet.client.js +0 -10
- package/dist/worker/foundation/Helmet/index.d.ts +0 -1
- package/dist/worker/foundation/Helmet/index.js +0 -1
- package/dist/worker/foundation/ShopifyProvider/types.d.ts +0 -15
- package/dist/worker/foundation/ssr-interop.d.ts +0 -29
- package/dist/worker/foundation/ssr-interop.js +0 -35
- package/dist/worker/framework/Hydration/ServerComponentRequest.server.d.ts +0 -23
- package/dist/worker/framework/Hydration/ServerComponentRequest.server.js +0 -57
- package/dist/worker/framework/config.d.ts +0 -6
- package/dist/worker/framework/config.js +0 -6
- package/dist/worker/framework/runtime.d.ts +0 -13
- package/dist/worker/framework/runtime.js +0 -27
- package/dist/worker/graphql/types/types.d.ts +0 -5761
- package/dist/worker/graphql/types/types.js +0 -1436
- package/dist/worker/handle-event.d.ts +0 -23
- package/dist/worker/handle-event.js +0 -132
- package/dist/worker/handle-worker-event.d.ts +0 -11
- package/dist/worker/handle-worker-event.js +0 -14
- package/dist/worker/types.d.ts +0 -96
- package/dist/worker/utilities/apiRoutes.d.ts +0 -21
- package/dist/worker/utilities/apiRoutes.js +0 -87
- package/dist/worker/utilities/log/log.d.ts +0 -18
- package/dist/worker/utilities/log/log.js +0 -77
- package/dist/worker/utilities/matchPath.d.ts +0 -10
- package/dist/worker/utilities/matchPath.js +0 -54
- package/dist/worker/utilities/timing.d.ts +0 -7
- package/dist/worker/utilities/timing.js +0 -14
- package/worker.js +0 -1
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is used for compatibility between browser and server environments.
|
|
3
|
-
* The browser loads this file as is, without leaking server logic.
|
|
4
|
-
* In the server, this file is transformed by Vite to inject server logic.
|
|
5
|
-
* NOTE: Do not remove SSR-prefixed comments in this file.
|
|
6
|
-
*/
|
|
7
|
-
import type { ServerComponentRequest } from '../framework/Hydration/ServerComponentRequest.server';
|
|
8
|
-
export declare const META_ENV_SSR = false;
|
|
9
|
-
declare type ServerGetter<T> = (request: ServerComponentRequest) => T;
|
|
10
|
-
/**
|
|
11
|
-
* Isomorphic hook to access context data. It gives access to the current request
|
|
12
|
-
* when running on the server, and returns the provided client fallback in the browser.
|
|
13
|
-
* This can be used in server components (RSC) as a Context/Provider replacement. In client
|
|
14
|
-
* components, it uses the server getter in SSR and the client fallback in the browser.
|
|
15
|
-
* @param serverGetter - A function that gets the current server request and returns any
|
|
16
|
-
* desired request property. It only runs in the server (both in RSC and SSR).
|
|
17
|
-
* @param clientFallback - An optional raw value or a React.Context to be consumed that will be
|
|
18
|
-
* returned if the current environment is not the server. Note that, if this is a React.Context,
|
|
19
|
-
* there must be a React.Provider parent in the app tree.
|
|
20
|
-
* @returns A value retrieved from the current server request or a fallback value in the client.
|
|
21
|
-
* The returned type depends on what the server getter returns.
|
|
22
|
-
* @example
|
|
23
|
-
* ```js
|
|
24
|
-
* import {MyClientContext} from './my-client-react-context-provider';
|
|
25
|
-
* useEnvContext(req => req.ctx.myServerContext, MyClientContext)
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare function useEnvContext<T>(serverGetter: ServerGetter<T>, clientFallback?: any): T;
|
|
29
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* This file is used for compatibility between browser and server environments.
|
|
4
|
-
* The browser loads this file as is, without leaking server logic.
|
|
5
|
-
* In the server, this file is transformed by Vite to inject server logic.
|
|
6
|
-
* NOTE: Do not remove SSR-prefixed comments in this file.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.useEnvContext = exports.META_ENV_SSR = void 0;
|
|
10
|
-
const react_1 = require("react");
|
|
11
|
-
//@SSR import {useServerRequest} from './ServerRequestProvider';
|
|
12
|
-
// This is replaced by Vite to import.meta.env.SSR
|
|
13
|
-
exports.META_ENV_SSR = false;
|
|
14
|
-
const reactContextType = Symbol.for('react.context');
|
|
15
|
-
/**
|
|
16
|
-
* Isomorphic hook to access context data. It gives access to the current request
|
|
17
|
-
* when running on the server, and returns the provided client fallback in the browser.
|
|
18
|
-
* This can be used in server components (RSC) as a Context/Provider replacement. In client
|
|
19
|
-
* components, it uses the server getter in SSR and the client fallback in the browser.
|
|
20
|
-
* @param serverGetter - A function that gets the current server request and returns any
|
|
21
|
-
* desired request property. It only runs in the server (both in RSC and SSR).
|
|
22
|
-
* @param clientFallback - An optional raw value or a React.Context to be consumed that will be
|
|
23
|
-
* returned if the current environment is not the server. Note that, if this is a React.Context,
|
|
24
|
-
* there must be a React.Provider parent in the app tree.
|
|
25
|
-
* @returns A value retrieved from the current server request or a fallback value in the client.
|
|
26
|
-
* The returned type depends on what the server getter returns.
|
|
27
|
-
* @example
|
|
28
|
-
* ```js
|
|
29
|
-
* import {MyClientContext} from './my-client-react-context-provider';
|
|
30
|
-
* useEnvContext(req => req.ctx.myServerContext, MyClientContext)
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
function useEnvContext(serverGetter, clientFallback) {
|
|
34
|
-
//@SSR if (META_ENV_SSR) return serverGetter(useServerRequest());
|
|
35
|
-
return clientFallback && clientFallback.$$typeof === reactContextType
|
|
36
|
-
? (0, react_1.useContext)(clientFallback)
|
|
37
|
-
: clientFallback;
|
|
38
|
-
}
|
|
39
|
-
exports.useEnvContext = useEnvContext;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ServerResponse } from 'http';
|
|
3
|
-
import type { ServerComponentRequest } from './framework/Hydration/ServerComponentRequest.server';
|
|
4
|
-
import { RuntimeContext } from './framework/runtime';
|
|
5
|
-
interface HydrogenFetchEvent {
|
|
6
|
-
/**
|
|
7
|
-
* Hydrogen only cares about a single property, since we pass `request` as a separate option.
|
|
8
|
-
*/
|
|
9
|
-
waitUntil?: (callback: Promise<void>) => void;
|
|
10
|
-
}
|
|
11
|
-
export interface HandleEventOptions {
|
|
12
|
-
request: ServerComponentRequest;
|
|
13
|
-
entrypoint: any;
|
|
14
|
-
indexTemplate: string | ((url: string) => Promise<string>);
|
|
15
|
-
assetHandler?: (event: HydrogenFetchEvent, url: URL) => Promise<Response>;
|
|
16
|
-
cache?: Cache;
|
|
17
|
-
streamableResponse?: ServerResponse;
|
|
18
|
-
dev?: boolean;
|
|
19
|
-
context?: RuntimeContext;
|
|
20
|
-
nonce?: string;
|
|
21
|
-
}
|
|
22
|
-
export default function handleEvent(event: HydrogenFetchEvent, { request, entrypoint, indexTemplate, assetHandler, streamableResponse, dev, cache, context, nonce, }: HandleEventOptions): Promise<void | Response>;
|
|
23
|
-
export {};
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const runtime_1 = require("./framework/runtime");
|
|
4
|
-
const config_1 = require("./framework/config");
|
|
5
|
-
const apiRoutes_1 = require("./utilities/apiRoutes");
|
|
6
|
-
const constants_1 = require("./constants");
|
|
7
|
-
async function handleEvent(event, { request, entrypoint, indexTemplate, assetHandler, streamableResponse, dev, cache, context, nonce, }) {
|
|
8
|
-
const url = new URL(request.url);
|
|
9
|
-
/**
|
|
10
|
-
* Inject the cache & context into the module loader so we can pull it out for subrequests.
|
|
11
|
-
*/
|
|
12
|
-
(0, runtime_1.setCache)(cache);
|
|
13
|
-
(0, runtime_1.setContext)(context);
|
|
14
|
-
(0, config_1.setConfig)({ dev });
|
|
15
|
-
const isReactHydrationRequest = url.pathname === constants_1.RSC_PATHNAME;
|
|
16
|
-
const template = typeof indexTemplate === 'function'
|
|
17
|
-
? await indexTemplate(url.toString())
|
|
18
|
-
: indexTemplate;
|
|
19
|
-
/**
|
|
20
|
-
* If this is a request for an asset, and an asset handler is present, call it.
|
|
21
|
-
*/
|
|
22
|
-
if (/\.(png|jpe?g|gif|css|js|svg|ico|map)$/i.test(url.pathname) &&
|
|
23
|
-
assetHandler) {
|
|
24
|
-
return assetHandler(event, url);
|
|
25
|
-
}
|
|
26
|
-
const { render, hydrate, stream, getApiRoute, log } = entrypoint.default || entrypoint;
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
if (dev && !(render && hydrate && stream && getApiRoute)) {
|
|
29
|
-
throw new Error(`entry-server.jsx could not be loaded. This likely occurred because of a Vite compilation error.\n` +
|
|
30
|
-
`Please check your server logs for more information.`);
|
|
31
|
-
}
|
|
32
|
-
if (!isReactHydrationRequest) {
|
|
33
|
-
const apiRoute = getApiRoute(url);
|
|
34
|
-
// The API Route might have a default export, making it also a server component
|
|
35
|
-
// If it does, only render the API route if the request method is GET
|
|
36
|
-
if (apiRoute &&
|
|
37
|
-
(!apiRoute.hasServerComponent || request.method !== 'GET')) {
|
|
38
|
-
return (0, apiRoutes_1.renderApiRoute)(request, apiRoute, log);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
const isStreamable = !isBotUA(url, request.headers.get('user-agent')) &&
|
|
42
|
-
(!!streamableResponse || supportsReadableStream());
|
|
43
|
-
if (isReactHydrationRequest) {
|
|
44
|
-
return hydrate(url, {
|
|
45
|
-
request,
|
|
46
|
-
response: streamableResponse,
|
|
47
|
-
isStreamable,
|
|
48
|
-
dev,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Stream back real-user responses, but for bots/etc,
|
|
53
|
-
* use `render` instead. This is because we need to inject <head>
|
|
54
|
-
* things for SEO reasons.
|
|
55
|
-
*/
|
|
56
|
-
if (isStreamable) {
|
|
57
|
-
return stream(url, {
|
|
58
|
-
request,
|
|
59
|
-
response: streamableResponse,
|
|
60
|
-
template,
|
|
61
|
-
nonce,
|
|
62
|
-
dev,
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return render(url, {
|
|
66
|
-
request,
|
|
67
|
-
template,
|
|
68
|
-
nonce,
|
|
69
|
-
dev,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
exports.default = handleEvent;
|
|
73
|
-
/**
|
|
74
|
-
* Determines if the request is from a bot, using the URL and User Agent
|
|
75
|
-
*/
|
|
76
|
-
function isBotUA(url, userAgent) {
|
|
77
|
-
return (url.searchParams.has('_bot') || (!!userAgent && botUARegex.test(userAgent)));
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* An alphabetized list of User Agents of known bots, combined from lists found at:
|
|
81
|
-
* https://github.com/vercel/next.js/blob/d87dc2b5a0b3fdbc0f6806a47be72bad59564bd0/packages/next/server/utils.ts#L18-L22
|
|
82
|
-
* https://github.com/GoogleChrome/rendertron/blob/6f681688737846b28754fbfdf5db173846a826df/middleware/src/middleware.ts#L24-L41
|
|
83
|
-
*/
|
|
84
|
-
const botUserAgents = [
|
|
85
|
-
'AdsBot-Google',
|
|
86
|
-
'applebot',
|
|
87
|
-
'Baiduspider',
|
|
88
|
-
'baiduspider',
|
|
89
|
-
'bingbot',
|
|
90
|
-
'Bingbot',
|
|
91
|
-
'BingPreview',
|
|
92
|
-
'bitlybot',
|
|
93
|
-
'Discordbot',
|
|
94
|
-
'DuckDuckBot',
|
|
95
|
-
'Embedly',
|
|
96
|
-
'facebookcatalog',
|
|
97
|
-
'facebookexternalhit',
|
|
98
|
-
'Google-PageRenderer',
|
|
99
|
-
'Googlebot',
|
|
100
|
-
'googleweblight',
|
|
101
|
-
'ia_archive',
|
|
102
|
-
'LinkedInBot',
|
|
103
|
-
'Mediapartners-Google',
|
|
104
|
-
'outbrain',
|
|
105
|
-
'pinterest',
|
|
106
|
-
'quora link preview',
|
|
107
|
-
'redditbot',
|
|
108
|
-
'rogerbot',
|
|
109
|
-
'showyoubot',
|
|
110
|
-
'SkypeUriPreview',
|
|
111
|
-
'Slackbot',
|
|
112
|
-
'Slurp',
|
|
113
|
-
'sogou',
|
|
114
|
-
'Storebot-Google',
|
|
115
|
-
'TelegramBot',
|
|
116
|
-
'tumblr',
|
|
117
|
-
'Twitterbot',
|
|
118
|
-
'vkShare',
|
|
119
|
-
'W3C_Validator',
|
|
120
|
-
'WhatsApp',
|
|
121
|
-
'yandex',
|
|
122
|
-
];
|
|
123
|
-
/**
|
|
124
|
-
* Creates a regex based on the botUserAgents array
|
|
125
|
-
*/
|
|
126
|
-
const botUARegex = new RegExp(botUserAgents.join('|'), 'i');
|
|
127
|
-
function supportsReadableStream() {
|
|
128
|
-
try {
|
|
129
|
-
new ReadableStream();
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
catch (_) {
|
|
133
|
-
return false;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const RSC_PATHNAME = "/__rsc";
|
package/dist/worker/constants.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const RSC_PATHNAME = '/__rsc';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { HelmetProps, HelmetData } from 'react-helmet-async';
|
|
3
|
-
export declare type RealHelmetData = {
|
|
4
|
-
context: {
|
|
5
|
-
helmet: HelmetData;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export declare function Helmet({ children, ...props }: HelmetProps & {
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
}): JSX.Element;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Helmet as ActualHelmet, HelmetData, } from 'react-helmet-async';
|
|
3
|
-
import { useEnvContext } from '../ssr-interop';
|
|
4
|
-
const clientHelmetData = new HelmetData({});
|
|
5
|
-
export function Helmet({ children, ...props }) {
|
|
6
|
-
const helmetData = useEnvContext((req) => req.ctx.helmet, clientHelmetData);
|
|
7
|
-
return (
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
React.createElement(ActualHelmet, { ...props, helmetData: helmetData }, children));
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Helmet, RealHelmetData } from './Helmet.client';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Helmet } from './Helmet.client';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { ShopifyConfig } from '../../types';
|
|
3
|
-
export declare type ShopifyContextValue = {
|
|
4
|
-
locale: string;
|
|
5
|
-
storeDomain: ShopifyConfig['storeDomain'];
|
|
6
|
-
storefrontToken: ShopifyConfig['storefrontToken'];
|
|
7
|
-
storefrontApiVersion: string;
|
|
8
|
-
};
|
|
9
|
-
export declare type ShopifyProviderProps = {
|
|
10
|
-
/** The contents of the `shopify.config.js` file. */
|
|
11
|
-
shopifyConfig: ShopifyConfig;
|
|
12
|
-
/** Any `ReactNode` elements. */
|
|
13
|
-
children?: ReactNode;
|
|
14
|
-
manager?: any;
|
|
15
|
-
};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is used for compatibility between browser and server environments.
|
|
3
|
-
* The browser loads this file as is, without leaking server logic.
|
|
4
|
-
* In the server, this file is transformed by Vite to inject server logic.
|
|
5
|
-
* NOTE: Do not remove SSR-prefixed comments in this file.
|
|
6
|
-
*/
|
|
7
|
-
import type { ServerComponentRequest } from '../framework/Hydration/ServerComponentRequest.server';
|
|
8
|
-
export declare const META_ENV_SSR = false;
|
|
9
|
-
declare type ServerGetter<T> = (request: ServerComponentRequest) => T;
|
|
10
|
-
/**
|
|
11
|
-
* Isomorphic hook to access context data. It gives access to the current request
|
|
12
|
-
* when running on the server, and returns the provided client fallback in the browser.
|
|
13
|
-
* This can be used in server components (RSC) as a Context/Provider replacement. In client
|
|
14
|
-
* components, it uses the server getter in SSR and the client fallback in the browser.
|
|
15
|
-
* @param serverGetter - A function that gets the current server request and returns any
|
|
16
|
-
* desired request property. It only runs in the server (both in RSC and SSR).
|
|
17
|
-
* @param clientFallback - An optional raw value or a React.Context to be consumed that will be
|
|
18
|
-
* returned if the current environment is not the server. Note that, if this is a React.Context,
|
|
19
|
-
* there must be a React.Provider parent in the app tree.
|
|
20
|
-
* @returns A value retrieved from the current server request or a fallback value in the client.
|
|
21
|
-
* The returned type depends on what the server getter returns.
|
|
22
|
-
* @example
|
|
23
|
-
* ```js
|
|
24
|
-
* import {MyClientContext} from './my-client-react-context-provider';
|
|
25
|
-
* useEnvContext(req => req.ctx.myServerContext, MyClientContext)
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare function useEnvContext<T>(serverGetter: ServerGetter<T>, clientFallback?: any): T;
|
|
29
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is used for compatibility between browser and server environments.
|
|
3
|
-
* The browser loads this file as is, without leaking server logic.
|
|
4
|
-
* In the server, this file is transformed by Vite to inject server logic.
|
|
5
|
-
* NOTE: Do not remove SSR-prefixed comments in this file.
|
|
6
|
-
*/
|
|
7
|
-
import { useContext } from 'react';
|
|
8
|
-
//@SSR import {useServerRequest} from './ServerRequestProvider';
|
|
9
|
-
// This is replaced by Vite to import.meta.env.SSR
|
|
10
|
-
export const META_ENV_SSR = false;
|
|
11
|
-
const reactContextType = Symbol.for('react.context');
|
|
12
|
-
/**
|
|
13
|
-
* Isomorphic hook to access context data. It gives access to the current request
|
|
14
|
-
* when running on the server, and returns the provided client fallback in the browser.
|
|
15
|
-
* This can be used in server components (RSC) as a Context/Provider replacement. In client
|
|
16
|
-
* components, it uses the server getter in SSR and the client fallback in the browser.
|
|
17
|
-
* @param serverGetter - A function that gets the current server request and returns any
|
|
18
|
-
* desired request property. It only runs in the server (both in RSC and SSR).
|
|
19
|
-
* @param clientFallback - An optional raw value or a React.Context to be consumed that will be
|
|
20
|
-
* returned if the current environment is not the server. Note that, if this is a React.Context,
|
|
21
|
-
* there must be a React.Provider parent in the app tree.
|
|
22
|
-
* @returns A value retrieved from the current server request or a fallback value in the client.
|
|
23
|
-
* The returned type depends on what the server getter returns.
|
|
24
|
-
* @example
|
|
25
|
-
* ```js
|
|
26
|
-
* import {MyClientContext} from './my-client-react-context-provider';
|
|
27
|
-
* useEnvContext(req => req.ctx.myServerContext, MyClientContext)
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
export function useEnvContext(serverGetter, clientFallback) {
|
|
31
|
-
//@SSR if (META_ENV_SSR) return serverGetter(useServerRequest());
|
|
32
|
-
return clientFallback && clientFallback.$$typeof === reactContextType
|
|
33
|
-
? useContext(clientFallback)
|
|
34
|
-
: clientFallback;
|
|
35
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { ShopifyContextValue } from '../../foundation/ShopifyProvider/types';
|
|
2
|
-
import type { RealHelmetData } from '../../foundation/Helmet';
|
|
3
|
-
/**
|
|
4
|
-
* This augments the `Request` object from the Fetch API:
|
|
5
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Request
|
|
6
|
-
*
|
|
7
|
-
* - Adds a `cookies` map for easy access
|
|
8
|
-
* - Adds a static constructor to convert a Node.js `IncomingMessage` to a Request.
|
|
9
|
-
*/
|
|
10
|
-
export declare class ServerComponentRequest extends Request {
|
|
11
|
-
cookies: Map<string, string>;
|
|
12
|
-
id: string;
|
|
13
|
-
time: number;
|
|
14
|
-
ctx: {
|
|
15
|
-
cache: Map<string, any>;
|
|
16
|
-
helmet: RealHelmetData;
|
|
17
|
-
shopifyConfig?: ShopifyContextValue;
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
};
|
|
20
|
-
constructor(input: any);
|
|
21
|
-
constructor(input: RequestInfo, init?: RequestInit);
|
|
22
|
-
private parseCookies;
|
|
23
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { getTime } from '../../utilities/timing';
|
|
2
|
-
import { HelmetData } from 'react-helmet-async';
|
|
3
|
-
let reqCounter = 0; // For debugging
|
|
4
|
-
const generateId = typeof crypto !== 'undefined' &&
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
!!crypto.randomUUID
|
|
7
|
-
? // @ts-ignore
|
|
8
|
-
() => crypto.randomUUID()
|
|
9
|
-
: () => `req${++reqCounter}`;
|
|
10
|
-
/**
|
|
11
|
-
* This augments the `Request` object from the Fetch API:
|
|
12
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Request
|
|
13
|
-
*
|
|
14
|
-
* - Adds a `cookies` map for easy access
|
|
15
|
-
* - Adds a static constructor to convert a Node.js `IncomingMessage` to a Request.
|
|
16
|
-
*/
|
|
17
|
-
export class ServerComponentRequest extends Request {
|
|
18
|
-
constructor(input, init) {
|
|
19
|
-
if (input instanceof Request) {
|
|
20
|
-
super(input, init);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
super(getUrlFromNodeRequest(input), {
|
|
24
|
-
headers: new Headers(input.headers),
|
|
25
|
-
method: input.method,
|
|
26
|
-
body: input.method !== 'GET' && input.method !== 'HEAD'
|
|
27
|
-
? input.body
|
|
28
|
-
: undefined,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
this.time = getTime();
|
|
32
|
-
this.id = generateId();
|
|
33
|
-
this.ctx = {
|
|
34
|
-
cache: new Map(),
|
|
35
|
-
helmet: new HelmetData({}),
|
|
36
|
-
};
|
|
37
|
-
this.cookies = this.parseCookies();
|
|
38
|
-
}
|
|
39
|
-
parseCookies() {
|
|
40
|
-
const cookieString = this.headers.get('cookie') || '';
|
|
41
|
-
return new Map(cookieString
|
|
42
|
-
.split(';')
|
|
43
|
-
.map((chunk) => chunk.trim().split(/=(.+)/)));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* @see https://github.com/frandiox/vitedge/blob/17f3cd943e86d7c0c71a862985ddd6caa2899425/src/node/utils.js#L19-L24
|
|
48
|
-
*
|
|
49
|
-
* Note: Request can sometimes be an instance of Express request, where `originalUrl` is the true source of what the
|
|
50
|
-
* URL pathname is. We want to use that if it's present, so we union type this to `any`.
|
|
51
|
-
*/
|
|
52
|
-
function getUrlFromNodeRequest(request) {
|
|
53
|
-
var _a;
|
|
54
|
-
// TODO: Find out how to determine https from `request` object without forwarded proto
|
|
55
|
-
const secure = request.headers['x-forwarded-proto'] === 'https';
|
|
56
|
-
return new URL(`${secure ? 'https' : 'http'}://${request.headers.host + ((_a = request.originalUrl) !== null && _a !== void 0 ? _a : request.url)}`).toString();
|
|
57
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface RuntimeContext {
|
|
2
|
-
waitUntil: (fn: Promise<any>) => void;
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* Set a global runtime context for the current request.
|
|
6
|
-
* This is used to encapsulate things like:
|
|
7
|
-
* - `waitUntil()` to run promises after request has ended
|
|
8
|
-
*/
|
|
9
|
-
export declare function setContext(ctx?: RuntimeContext): void;
|
|
10
|
-
export declare function getContext(): RuntimeContext | undefined;
|
|
11
|
-
export declare function setCache(cache?: Cache): void;
|
|
12
|
-
export declare function getCache(): Cache | undefined;
|
|
13
|
-
export declare function runDelayedFunction(fn: () => Promise<any>): void | Promise<any>;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Set a global runtime context for the current request.
|
|
3
|
-
* This is used to encapsulate things like:
|
|
4
|
-
* - `waitUntil()` to run promises after request has ended
|
|
5
|
-
*/
|
|
6
|
-
export function setContext(ctx) {
|
|
7
|
-
globalThis.__ctx = ctx;
|
|
8
|
-
}
|
|
9
|
-
export function getContext() {
|
|
10
|
-
return globalThis.__ctx;
|
|
11
|
-
}
|
|
12
|
-
export function setCache(cache) {
|
|
13
|
-
globalThis.__cache = cache;
|
|
14
|
-
}
|
|
15
|
-
export function getCache() {
|
|
16
|
-
return globalThis.__cache;
|
|
17
|
-
}
|
|
18
|
-
export function runDelayedFunction(fn) {
|
|
19
|
-
const context = getContext();
|
|
20
|
-
/**
|
|
21
|
-
* Runtimes (Oxygen, Node.js) might not have this.
|
|
22
|
-
*/
|
|
23
|
-
if (!(context === null || context === void 0 ? void 0 : context.waitUntil)) {
|
|
24
|
-
return fn();
|
|
25
|
-
}
|
|
26
|
-
return context.waitUntil(fn());
|
|
27
|
-
}
|