@shopify/hydrogen 0.16.1 → 0.17.2
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 +110 -2
- package/dist/esnext/FileSessionStorage.d.ts +1 -0
- package/dist/esnext/FileSessionStorage.js +1 -0
- package/dist/esnext/client.d.ts +2 -2
- package/dist/esnext/client.js +2 -2
- package/dist/esnext/components/CartProvider/CartProvider.client.d.ts +1 -1
- package/dist/esnext/components/CartProvider/CartProvider.client.js +3 -3
- package/dist/esnext/components/ExternalVideo/ExternalVideo.d.ts +2 -2
- package/dist/esnext/components/ExternalVideo/ExternalVideo.js +1 -1
- package/dist/esnext/components/Image/Image.d.ts +2 -2
- package/dist/esnext/components/Image/Image.js +1 -1
- package/dist/esnext/components/Link/Link.client.d.ts +1 -1
- package/dist/esnext/components/Link/Link.client.js +3 -3
- package/dist/esnext/components/LocalizationProvider/LocalizationClientProvider.client.js +4 -4
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.d.ts +2 -2
- package/dist/esnext/components/LocalizationProvider/LocalizationProvider.server.js +2 -2
- package/dist/esnext/components/MediaFile/MediaFile.d.ts +2 -2
- package/dist/esnext/components/MediaFile/MediaFile.js +1 -1
- package/dist/esnext/components/Metafield/Metafield.client.d.ts +8 -4
- package/dist/esnext/components/Metafield/Metafield.client.js +6 -2
- package/dist/esnext/components/ModelViewer/ModelViewer.client.d.ts +4 -4
- package/dist/esnext/components/ModelViewer/ModelViewer.client.js +2 -2
- package/dist/esnext/components/Money/Money.client.d.ts +2 -2
- package/dist/esnext/components/Money/Money.client.js +1 -1
- package/dist/esnext/components/ProductDescription/ProductDescription.client.d.ts +1 -1
- package/dist/esnext/components/ProductDescription/ProductDescription.client.js +1 -1
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.d.ts +3 -3
- package/dist/esnext/components/ProductMetafield/ProductMetafield.client.js +1 -1
- package/dist/esnext/components/ProductPrice/ProductPrice.client.d.ts +1 -1
- package/dist/esnext/components/ProductPrice/ProductPrice.client.js +1 -1
- package/dist/esnext/components/ProductProvider/ProductProvider.client.d.ts +1 -1
- package/dist/esnext/components/ProductTitle/ProductTitle.client.d.ts +1 -1
- package/dist/esnext/components/ProductTitle/ProductTitle.client.js +1 -1
- package/dist/esnext/components/UnitPrice/UnitPrice.client.d.ts +4 -4
- package/dist/esnext/components/UnitPrice/UnitPrice.client.js +2 -2
- package/dist/esnext/components/Video/Video.d.ts +2 -2
- package/dist/esnext/components/Video/Video.js +1 -1
- package/dist/esnext/entry-client.js +4 -4
- package/dist/esnext/entry-server.d.ts +1 -1
- package/dist/esnext/entry-server.js +18 -13
- package/dist/esnext/foundation/Analytics/Analytics.server.js +4 -2
- package/dist/esnext/foundation/AnalyticsErrorBoundary.client.d.ts +4 -0
- package/dist/esnext/foundation/AnalyticsErrorBoundary.client.js +8 -0
- package/dist/esnext/foundation/Cookie/Cookie.d.ts +48 -0
- package/dist/esnext/foundation/Cookie/Cookie.js +66 -0
- package/dist/esnext/foundation/CookieSessionStorage/CookieSessionStorage.d.ts +5 -0
- package/dist/esnext/foundation/CookieSessionStorage/CookieSessionStorage.js +31 -0
- package/dist/esnext/foundation/FileRoutes/FileRoutes.server.js +2 -18
- package/dist/esnext/foundation/FileSessionStorage/FileSessionStorage.d.ts +6 -0
- package/dist/esnext/foundation/FileSessionStorage/FileSessionStorage.js +148 -0
- package/dist/esnext/foundation/MemorySessionStorage/MemorySessionStorage.d.ts +5 -0
- package/dist/esnext/foundation/MemorySessionStorage/MemorySessionStorage.js +53 -0
- package/dist/esnext/foundation/Router/BrowserRouter.client.js +31 -11
- package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +40 -0
- package/dist/esnext/foundation/ServerPropsProvider/ServerPropsProvider.js +65 -0
- package/dist/esnext/foundation/ServerPropsProvider/index.d.ts +2 -0
- package/dist/esnext/foundation/ServerPropsProvider/index.js +1 -0
- package/dist/esnext/foundation/index.d.ts +1 -1
- package/dist/esnext/foundation/index.js +1 -1
- package/dist/esnext/foundation/session/session.d.ts +27 -0
- package/dist/esnext/foundation/session/session.js +37 -0
- package/dist/esnext/foundation/useQuery/hooks.d.ts +3 -3
- package/dist/esnext/foundation/useQuery/hooks.js +1 -1
- package/dist/esnext/foundation/useServerProps/index.d.ts +1 -0
- package/dist/esnext/foundation/useServerProps/index.js +1 -0
- package/dist/esnext/foundation/useServerProps/use-server-props.d.ts +21 -0
- package/dist/esnext/foundation/useServerProps/use-server-props.js +35 -0
- package/dist/esnext/foundation/useSession/useSession.d.ts +2 -0
- package/dist/esnext/foundation/useSession/useSession.js +8 -0
- package/dist/esnext/framework/Hydration/ServerComponentRequest.server.d.ts +2 -0
- package/dist/esnext/framework/plugins/vite-plugin-hydrogen-config.js +26 -12
- package/dist/esnext/framework/plugins/vite-plugin-platform-entry.js +2 -2
- package/dist/esnext/hooks/useMoney/hooks.d.ts +1 -1
- package/dist/esnext/hooks/useMoney/hooks.js +1 -1
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.d.ts +2 -2
- package/dist/esnext/hooks/useParsedMetafields/useParsedMetafields.js +2 -2
- package/dist/esnext/hooks/useShopQuery/hooks.d.ts +2 -2
- package/dist/esnext/index.d.ts +4 -0
- package/dist/esnext/index.js +4 -0
- package/dist/esnext/storefront-api-types.d.ts +31 -13
- package/dist/esnext/storefront-api-types.js +14 -2
- package/dist/esnext/types.d.ts +2 -0
- package/dist/esnext/utilities/apiRoutes.d.ts +4 -1
- package/dist/esnext/utilities/apiRoutes.js +47 -19
- package/dist/esnext/utilities/bot-ua.js +3 -0
- package/dist/esnext/utilities/flattenConnection/flattenConnection.d.ts +1 -1
- package/dist/esnext/utilities/flattenConnection/flattenConnection.js +1 -1
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +1 -1
- package/dist/esnext/utilities/parseMetafieldValue/parseMetafieldValue.js +1 -1
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/node/entry-server.d.ts +1 -1
- package/dist/node/entry-server.js +18 -13
- package/dist/node/foundation/Analytics/Analytics.server.js +27 -2
- package/dist/node/foundation/AnalyticsErrorBoundary.client.d.ts +4 -0
- package/dist/node/foundation/AnalyticsErrorBoundary.client.js +14 -0
- package/dist/node/foundation/Router/BrowserRouter.client.js +31 -11
- package/dist/node/foundation/ServerPropsProvider/ServerPropsProvider.d.ts +40 -0
- package/dist/node/foundation/{ServerStateProvider/ServerStateProvider.js → ServerPropsProvider/ServerPropsProvider.js} +36 -23
- package/dist/node/foundation/ServerPropsProvider/index.d.ts +2 -0
- package/dist/node/foundation/ServerPropsProvider/index.js +6 -0
- package/dist/node/foundation/session/session.d.ts +27 -0
- package/dist/node/foundation/session/session.js +43 -0
- package/dist/node/foundation/useServerProps/use-server-props.d.ts +21 -0
- package/dist/node/foundation/useServerProps/use-server-props.js +40 -0
- package/dist/node/framework/Hydration/ServerComponentRequest.server.d.ts +2 -0
- package/dist/node/framework/plugins/vite-plugin-hydrogen-config.js +26 -12
- package/dist/node/framework/plugins/vite-plugin-platform-entry.js +2 -2
- package/dist/node/storefront-api-types.d.ts +31 -13
- package/dist/node/storefront-api-types.js +14 -2
- package/dist/node/types.d.ts +2 -0
- package/dist/node/utilities/apiRoutes.d.ts +4 -1
- package/dist/node/utilities/apiRoutes.js +49 -20
- package/dist/node/utilities/bot-ua.js +3 -0
- package/dist/node/utilities/flattenConnection/flattenConnection.d.ts +1 -1
- package/dist/node/utilities/flattenConnection/flattenConnection.js +1 -1
- package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.d.ts +1 -1
- package/dist/node/utilities/parseMetafieldValue/parseMetafieldValue.js +1 -1
- package/dist/node/version.d.ts +1 -1
- package/dist/node/version.js +1 -1
- package/package.json +5 -2
- package/dist/esnext/foundation/ServerStateProvider/index.d.ts +0 -2
- package/dist/esnext/foundation/ServerStateProvider/index.js +0 -1
- package/dist/esnext/foundation/useServerState/index.d.ts +0 -1
- package/dist/esnext/foundation/useServerState/index.js +0 -1
- package/dist/esnext/foundation/useServerState/use-server-state.d.ts +0 -16
- package/dist/esnext/foundation/useServerState/use-server-state.js +0 -20
- package/dist/node/foundation/ServerStateProvider/ServerStateProvider.d.ts +0 -30
- package/dist/node/foundation/ServerStateProvider/index.d.ts +0 -2
- package/dist/node/foundation/ServerStateProvider/index.js +0 -6
- package/dist/node/foundation/useServerState/index.d.ts +0 -1
- package/dist/node/foundation/useServerState/index.js +0 -5
- package/dist/node/foundation/useServerState/use-server-state.d.ts +0 -16
- package/dist/node/foundation/useServerState/use-server-state.js +0 -24
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GraphQLConnection } from '../../types';
|
|
2
2
|
import type { PartialDeep } from 'type-fest';
|
|
3
3
|
/**
|
|
4
|
-
* The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](/api/storefront/reference/products/product)) into a flat array of nodes.
|
|
4
|
+
* The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](https://shopify.dev/api/storefront/reference/products/product)) into a flat array of nodes.
|
|
5
5
|
*/
|
|
6
6
|
export declare function flattenConnection<T>(connection: PartialDeep<GraphQLConnection<T>>): PartialDeep<T>[];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.flattenConnection = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](/api/storefront/reference/products/product)) into a flat array of nodes.
|
|
5
|
+
* The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](https://shopify.dev/api/storefront/reference/products/product)) into a flat array of nodes.
|
|
6
6
|
*/
|
|
7
7
|
function flattenConnection(connection) {
|
|
8
8
|
return (connection.edges || []).map((edge) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Metafield } from '../../storefront-api-types';
|
|
2
2
|
import type { PartialDeep } from 'type-fest';
|
|
3
3
|
/**
|
|
4
|
-
* The `parseMetafieldValue` function parses a [Metafield](/api/storefront/reference/common-objects/metafield)'s `value` from a string into a sensible type corresponding to the [Metafield](/api/storefront/reference/common-objects/metafield)'s `type`.
|
|
4
|
+
* The `parseMetafieldValue` function parses a [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `value` from a string into a sensible type corresponding to the [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `type`.
|
|
5
5
|
*/
|
|
6
6
|
export declare function parseMetafieldValue(metafield: PartialDeep<Metafield>): any;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseMetafieldValue = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* The `parseMetafieldValue` function parses a [Metafield](/api/storefront/reference/common-objects/metafield)'s `value` from a string into a sensible type corresponding to the [Metafield](/api/storefront/reference/common-objects/metafield)'s `type`.
|
|
5
|
+
* The `parseMetafieldValue` function parses a [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `value` from a string into a sensible type corresponding to the [Metafield](https://shopify.dev/api/storefront/reference/common-objects/metafield)'s `type`.
|
|
6
6
|
*/
|
|
7
7
|
function parseMetafieldValue(metafield) {
|
|
8
8
|
if (metafield.value == null) {
|
package/dist/node/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "0.
|
|
1
|
+
export declare const LIB_VERSION = "0.17.2";
|
package/dist/node/version.js
CHANGED
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"engines": {
|
|
8
8
|
"node": ">=14"
|
|
9
9
|
},
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.17.2",
|
|
11
11
|
"description": "Modern custom Shopify storefronts",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"main": "dist/esnext/index.js",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"@types/react": "^17.0.3",
|
|
72
72
|
"@types/react-dom": "^17.0.3",
|
|
73
73
|
"@types/ws": "^8.2.0",
|
|
74
|
+
"@types/uuid": "^8.3.4",
|
|
74
75
|
"babel-loader": "^8.2.2",
|
|
75
76
|
"cpy-cli": "3.1.1",
|
|
76
77
|
"mkdirp": "^1.0.4",
|
|
@@ -80,7 +81,7 @@
|
|
|
80
81
|
"rimraf": "^3.0.2"
|
|
81
82
|
},
|
|
82
83
|
"peerDependencies": {
|
|
83
|
-
"body-parser": "^1.
|
|
84
|
+
"body-parser": "^1.20.0",
|
|
84
85
|
"compression": "^1.7.4",
|
|
85
86
|
"react": "0.0.0-experimental-2bf7c02f0-20220314",
|
|
86
87
|
"react-dom": "0.0.0-experimental-2bf7c02f0-20220314",
|
|
@@ -101,6 +102,8 @@
|
|
|
101
102
|
"dependencies": {
|
|
102
103
|
"@vitejs/plugin-react": "^1.3.0",
|
|
103
104
|
"abort-controller": "^3.0.0",
|
|
105
|
+
"worktop": "^0.7.3",
|
|
106
|
+
"uuid": "^8.3.2",
|
|
104
107
|
"body-parser": "^1.19.2",
|
|
105
108
|
"connect": "^3.7.0",
|
|
106
109
|
"es-module-lexer": "^0.10.0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { ServerStateProvider, ServerStateContext } from './ServerStateProvider';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useServerState } from './use-server-state';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useServerState } from './use-server-state';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ServerStateContextValue } from '../ServerStateProvider';
|
|
2
|
-
/**
|
|
3
|
-
* The `useServerState` hook allows you to [manage server state](/custom-storefronts/hydrogen/framework/server-state) when using Hydrogen as a React Server Component framework.
|
|
4
|
-
*
|
|
5
|
-
* ## Return value
|
|
6
|
-
*
|
|
7
|
-
* The `useServerState` hook returns an object with the following keys:
|
|
8
|
-
*
|
|
9
|
-
* | Key | Description |
|
|
10
|
-
* | -------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
11
|
-
* | `serverState` | The current server state. |
|
|
12
|
-
* | `setServerState` | A function used to modify server state. |
|
|
13
|
-
* | `pending` | Whether a [transition is pending](https://github.com/reactwg/react-18/discussions/41). |
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
export declare function useServerState(): ServerStateContextValue;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { useContext } from 'react';
|
|
2
|
-
import { ServerStateContext, } from '../ServerStateProvider';
|
|
3
|
-
/**
|
|
4
|
-
* The `useServerState` hook allows you to [manage server state](/custom-storefronts/hydrogen/framework/server-state) when using Hydrogen as a React Server Component framework.
|
|
5
|
-
*
|
|
6
|
-
* ## Return value
|
|
7
|
-
*
|
|
8
|
-
* The `useServerState` hook returns an object with the following keys:
|
|
9
|
-
*
|
|
10
|
-
* | Key | Description |
|
|
11
|
-
* | -------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
12
|
-
* | `serverState` | The current server state. |
|
|
13
|
-
* | `setServerState` | A function used to modify server state. |
|
|
14
|
-
* | `pending` | Whether a [transition is pending](https://github.com/reactwg/react-18/discussions/41). |
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
export function useServerState() {
|
|
18
|
-
var _a;
|
|
19
|
-
return ((_a = useContext(ServerStateContext)) !== null && _a !== void 0 ? _a : {});
|
|
20
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
declare global {
|
|
3
|
-
var __DEV__: boolean;
|
|
4
|
-
}
|
|
5
|
-
export interface ServerState {
|
|
6
|
-
pathname: string;
|
|
7
|
-
search: string;
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
}
|
|
10
|
-
declare type ServerStateSetterInput = ((prev: ServerState) => Partial<ServerState>) | Partial<ServerState> | string;
|
|
11
|
-
export interface ServerStateSetter {
|
|
12
|
-
(input: ServerStateSetterInput, propValue?: any): void;
|
|
13
|
-
}
|
|
14
|
-
interface ProposedServerStateSetter {
|
|
15
|
-
(input: ServerStateSetterInput, propValue?: any): ServerState;
|
|
16
|
-
}
|
|
17
|
-
export interface ServerStateContextValue {
|
|
18
|
-
pending: boolean;
|
|
19
|
-
serverState: ServerState;
|
|
20
|
-
setServerState: ServerStateSetter;
|
|
21
|
-
getProposedServerState: ProposedServerStateSetter;
|
|
22
|
-
}
|
|
23
|
-
export declare const ServerStateContext: React.Context<ServerStateContextValue>;
|
|
24
|
-
interface ServerStateProviderProps {
|
|
25
|
-
serverState: ServerState;
|
|
26
|
-
setServerState: React.Dispatch<React.SetStateAction<ServerState>>;
|
|
27
|
-
children: ReactNode;
|
|
28
|
-
}
|
|
29
|
-
export declare function ServerStateProvider({ serverState, setServerState, children, }: ServerStateProviderProps): JSX.Element;
|
|
30
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ServerStateContext = exports.ServerStateProvider = void 0;
|
|
4
|
-
var ServerStateProvider_1 = require("./ServerStateProvider");
|
|
5
|
-
Object.defineProperty(exports, "ServerStateProvider", { enumerable: true, get: function () { return ServerStateProvider_1.ServerStateProvider; } });
|
|
6
|
-
Object.defineProperty(exports, "ServerStateContext", { enumerable: true, get: function () { return ServerStateProvider_1.ServerStateContext; } });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useServerState } from './use-server-state';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useServerState = void 0;
|
|
4
|
-
var use_server_state_1 = require("./use-server-state");
|
|
5
|
-
Object.defineProperty(exports, "useServerState", { enumerable: true, get: function () { return use_server_state_1.useServerState; } });
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ServerStateContextValue } from '../ServerStateProvider';
|
|
2
|
-
/**
|
|
3
|
-
* The `useServerState` hook allows you to [manage server state](/custom-storefronts/hydrogen/framework/server-state) when using Hydrogen as a React Server Component framework.
|
|
4
|
-
*
|
|
5
|
-
* ## Return value
|
|
6
|
-
*
|
|
7
|
-
* The `useServerState` hook returns an object with the following keys:
|
|
8
|
-
*
|
|
9
|
-
* | Key | Description |
|
|
10
|
-
* | -------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
11
|
-
* | `serverState` | The current server state. |
|
|
12
|
-
* | `setServerState` | A function used to modify server state. |
|
|
13
|
-
* | `pending` | Whether a [transition is pending](https://github.com/reactwg/react-18/discussions/41). |
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
export declare function useServerState(): ServerStateContextValue;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useServerState = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const ServerStateProvider_1 = require("../ServerStateProvider");
|
|
6
|
-
/**
|
|
7
|
-
* The `useServerState` hook allows you to [manage server state](/custom-storefronts/hydrogen/framework/server-state) when using Hydrogen as a React Server Component framework.
|
|
8
|
-
*
|
|
9
|
-
* ## Return value
|
|
10
|
-
*
|
|
11
|
-
* The `useServerState` hook returns an object with the following keys:
|
|
12
|
-
*
|
|
13
|
-
* | Key | Description |
|
|
14
|
-
* | -------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
15
|
-
* | `serverState` | The current server state. |
|
|
16
|
-
* | `setServerState` | A function used to modify server state. |
|
|
17
|
-
* | `pending` | Whether a [transition is pending](https://github.com/reactwg/react-18/discussions/41). |
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
function useServerState() {
|
|
21
|
-
var _a;
|
|
22
|
-
return ((_a = (0, react_1.useContext)(ServerStateProvider_1.ServerStateContext)) !== null && _a !== void 0 ? _a : {});
|
|
23
|
-
}
|
|
24
|
-
exports.useServerState = useServerState;
|