@shopify/hydrogen 2022.1.0-alpha.1 → 2023.1.0-alpha.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/dist/development/index.cjs +68 -31
- package/dist/development/index.cjs.map +1 -1
- package/dist/development/index.js +49 -14
- package/dist/development/index.js.map +1 -1
- package/dist/production/index.cjs +33 -31
- package/dist/production/index.cjs.map +1 -1
- package/dist/production/index.d.ts +130 -122
- package/dist/production/index.js +9 -9
- package/dist/production/index.js.map +1 -1
- package/dist/storefront-api-types.d.ts +121 -2
- package/dist/storefront.schema.json +1 -1
- package/package.json +4 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var hydrogenReact = require('@shopify/hydrogen-react');
|
|
4
4
|
var serverRuntime = require('@remix-run/server-runtime');
|
|
5
5
|
var react = require('@remix-run/react');
|
|
6
6
|
|
|
@@ -2201,11 +2201,12 @@ var isMutationRE = /(^|}\s)mutation[\s({]/im;
|
|
|
2201
2201
|
function minifyQuery(string) {
|
|
2202
2202
|
return string.replace(/\s*#.*$/gm, "").replace(/\s+/gm, " ").trim();
|
|
2203
2203
|
}
|
|
2204
|
+
var defaultI18n = { language: "EN", country: "US" };
|
|
2204
2205
|
function createStorefrontClient({
|
|
2205
2206
|
cache,
|
|
2206
2207
|
waitUntil,
|
|
2207
2208
|
buyerIp,
|
|
2208
|
-
i18n
|
|
2209
|
+
i18n,
|
|
2209
2210
|
requestGroupId = generateUUID(),
|
|
2210
2211
|
...clientOptions
|
|
2211
2212
|
}) {
|
|
@@ -2219,7 +2220,7 @@ function createStorefrontClient({
|
|
|
2219
2220
|
getPrivateTokenHeaders,
|
|
2220
2221
|
getStorefrontApiUrl,
|
|
2221
2222
|
getShopifyDomain
|
|
2222
|
-
} =
|
|
2223
|
+
} = hydrogenReact.createStorefrontClient(clientOptions);
|
|
2223
2224
|
const getHeaders = clientOptions.privateStorefrontToken ? getPrivateTokenHeaders : getPublicTokenHeaders;
|
|
2224
2225
|
const defaultHeaders = getHeaders({ contentType: "json" });
|
|
2225
2226
|
defaultHeaders[STOREFRONT_REQUEST_GROUP_ID_HEADER] = requestGroupId;
|
|
@@ -2298,7 +2299,7 @@ function createStorefrontClient({
|
|
|
2298
2299
|
getShopifyDomain,
|
|
2299
2300
|
getApiUrl: getStorefrontApiUrl,
|
|
2300
2301
|
isApiError: isStorefrontApiError,
|
|
2301
|
-
i18n:
|
|
2302
|
+
i18n: i18n ?? defaultI18n
|
|
2302
2303
|
}
|
|
2303
2304
|
};
|
|
2304
2305
|
}
|
|
@@ -2520,9 +2521,43 @@ function graphiqlLoader({ context } = {}) {
|
|
|
2520
2521
|
{ status: 200, headers: { "content-type": "text/html" } }
|
|
2521
2522
|
);
|
|
2522
2523
|
}
|
|
2524
|
+
function useDataFromMatches(dataKey) {
|
|
2525
|
+
const matches = react.useMatches();
|
|
2526
|
+
const data = {};
|
|
2527
|
+
matches.forEach((event) => {
|
|
2528
|
+
const eventData = event?.data;
|
|
2529
|
+
if (eventData && eventData[dataKey]) {
|
|
2530
|
+
Object.assign(data, eventData[dataKey]);
|
|
2531
|
+
}
|
|
2532
|
+
});
|
|
2533
|
+
return data;
|
|
2534
|
+
}
|
|
2535
|
+
function useDataFromFetchers({
|
|
2536
|
+
formDataKey,
|
|
2537
|
+
formDataValue,
|
|
2538
|
+
dataKey
|
|
2539
|
+
}) {
|
|
2540
|
+
const fetchers = react.useFetchers();
|
|
2541
|
+
const data = {};
|
|
2542
|
+
for (const fetcher of fetchers) {
|
|
2543
|
+
const formData = fetcher.submission?.formData;
|
|
2544
|
+
const fetcherData = fetcher.data;
|
|
2545
|
+
if (formData && formData.get(formDataKey) === formDataValue && fetcherData && fetcherData[dataKey]) {
|
|
2546
|
+
Object.assign(data, fetcherData[dataKey]);
|
|
2547
|
+
try {
|
|
2548
|
+
if (formData.get(dataKey)) {
|
|
2549
|
+
const dataInForm = JSON.parse(String(formData.get(dataKey)));
|
|
2550
|
+
Object.assign(data, dataInForm);
|
|
2551
|
+
}
|
|
2552
|
+
} catch {
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
return Object.keys(data).length ? data : void 0;
|
|
2557
|
+
}
|
|
2523
2558
|
|
|
2524
2559
|
// src/seo/seo.ts
|
|
2525
|
-
var
|
|
2560
|
+
var import_react2 = __toESM(require_react(), 1);
|
|
2526
2561
|
|
|
2527
2562
|
// src/seo/generate-seo-tags.ts
|
|
2528
2563
|
function generateSeoTags(input) {
|
|
@@ -2766,7 +2801,7 @@ function inferSchemaType(url) {
|
|
|
2766
2801
|
|
|
2767
2802
|
// src/seo/seo.ts
|
|
2768
2803
|
init_log_seo_tags();
|
|
2769
|
-
var SeoLogger =
|
|
2804
|
+
var SeoLogger = import_react2.default.lazy(() => Promise.resolve().then(() => (init_log_seo_tags(), log_seo_tags_exports)));
|
|
2770
2805
|
function Seo({ debug }) {
|
|
2771
2806
|
const matches = react.useMatches();
|
|
2772
2807
|
const location = react.useLocation();
|
|
@@ -2788,24 +2823,24 @@ function Seo({ debug }) {
|
|
|
2788
2823
|
logSeoTags(headTags);
|
|
2789
2824
|
const html = headTags.map((tag) => {
|
|
2790
2825
|
if (tag.tag === "script") {
|
|
2791
|
-
return
|
|
2826
|
+
return import_react2.default.createElement(tag.tag, {
|
|
2792
2827
|
...tag.props,
|
|
2793
2828
|
key: tag.key,
|
|
2794
2829
|
dangerouslySetInnerHTML: { __html: tag.children }
|
|
2795
2830
|
});
|
|
2796
2831
|
}
|
|
2797
|
-
return
|
|
2832
|
+
return import_react2.default.createElement(
|
|
2798
2833
|
tag.tag,
|
|
2799
2834
|
{ ...tag.props, key: tag.key },
|
|
2800
2835
|
tag.children
|
|
2801
2836
|
);
|
|
2802
2837
|
});
|
|
2803
|
-
const loggerMarkup =
|
|
2804
|
-
|
|
2838
|
+
const loggerMarkup = import_react2.default.createElement(
|
|
2839
|
+
import_react2.default.Suspense,
|
|
2805
2840
|
{ fallback: null },
|
|
2806
|
-
|
|
2841
|
+
import_react2.default.createElement(SeoLogger, { headTags })
|
|
2807
2842
|
);
|
|
2808
|
-
return
|
|
2843
|
+
return import_react2.default.createElement(import_react2.default.Fragment, null, html, debug && loggerMarkup);
|
|
2809
2844
|
}
|
|
2810
2845
|
function recursivelyInvokeOrReturn(value, ...rest) {
|
|
2811
2846
|
if (value instanceof Function) {
|
|
@@ -2839,75 +2874,75 @@ function recursivelyInvokeOrReturn(value, ...rest) {
|
|
|
2839
2874
|
|
|
2840
2875
|
Object.defineProperty(exports, 'AnalyticsEventName', {
|
|
2841
2876
|
enumerable: true,
|
|
2842
|
-
get: function () { return
|
|
2877
|
+
get: function () { return hydrogenReact.AnalyticsEventName; }
|
|
2843
2878
|
});
|
|
2844
2879
|
Object.defineProperty(exports, 'AnalyticsPageType', {
|
|
2845
2880
|
enumerable: true,
|
|
2846
|
-
get: function () { return
|
|
2881
|
+
get: function () { return hydrogenReact.AnalyticsPageType; }
|
|
2847
2882
|
});
|
|
2848
2883
|
Object.defineProperty(exports, 'ExternalVideo', {
|
|
2849
2884
|
enumerable: true,
|
|
2850
|
-
get: function () { return
|
|
2885
|
+
get: function () { return hydrogenReact.ExternalVideo; }
|
|
2851
2886
|
});
|
|
2852
2887
|
Object.defineProperty(exports, 'Image', {
|
|
2853
2888
|
enumerable: true,
|
|
2854
|
-
get: function () { return
|
|
2889
|
+
get: function () { return hydrogenReact.Image; }
|
|
2855
2890
|
});
|
|
2856
2891
|
Object.defineProperty(exports, 'MediaFile', {
|
|
2857
2892
|
enumerable: true,
|
|
2858
|
-
get: function () { return
|
|
2893
|
+
get: function () { return hydrogenReact.MediaFile; }
|
|
2859
2894
|
});
|
|
2860
2895
|
Object.defineProperty(exports, 'ModelViewer', {
|
|
2861
2896
|
enumerable: true,
|
|
2862
|
-
get: function () { return
|
|
2897
|
+
get: function () { return hydrogenReact.ModelViewer; }
|
|
2863
2898
|
});
|
|
2864
2899
|
Object.defineProperty(exports, 'Money', {
|
|
2865
2900
|
enumerable: true,
|
|
2866
|
-
get: function () { return
|
|
2901
|
+
get: function () { return hydrogenReact.Money; }
|
|
2867
2902
|
});
|
|
2868
2903
|
Object.defineProperty(exports, 'ShopPayButton', {
|
|
2869
2904
|
enumerable: true,
|
|
2870
|
-
get: function () { return
|
|
2905
|
+
get: function () { return hydrogenReact.ShopPayButton; }
|
|
2871
2906
|
});
|
|
2872
|
-
Object.defineProperty(exports, '
|
|
2907
|
+
Object.defineProperty(exports, 'ShopifySalesChannel', {
|
|
2873
2908
|
enumerable: true,
|
|
2874
|
-
get: function () { return
|
|
2909
|
+
get: function () { return hydrogenReact.ShopifySalesChannel; }
|
|
2875
2910
|
});
|
|
2876
2911
|
Object.defineProperty(exports, 'Video', {
|
|
2877
2912
|
enumerable: true,
|
|
2878
|
-
get: function () { return
|
|
2913
|
+
get: function () { return hydrogenReact.Video; }
|
|
2879
2914
|
});
|
|
2880
2915
|
Object.defineProperty(exports, 'flattenConnection', {
|
|
2881
2916
|
enumerable: true,
|
|
2882
|
-
get: function () { return
|
|
2917
|
+
get: function () { return hydrogenReact.flattenConnection; }
|
|
2883
2918
|
});
|
|
2884
2919
|
Object.defineProperty(exports, 'getClientBrowserParameters', {
|
|
2885
2920
|
enumerable: true,
|
|
2886
|
-
get: function () { return
|
|
2921
|
+
get: function () { return hydrogenReact.getClientBrowserParameters; }
|
|
2887
2922
|
});
|
|
2888
2923
|
Object.defineProperty(exports, 'getShopifyCookies', {
|
|
2889
2924
|
enumerable: true,
|
|
2890
|
-
get: function () { return
|
|
2925
|
+
get: function () { return hydrogenReact.getShopifyCookies; }
|
|
2891
2926
|
});
|
|
2892
2927
|
Object.defineProperty(exports, 'parseMetafield', {
|
|
2893
2928
|
enumerable: true,
|
|
2894
|
-
get: function () { return
|
|
2929
|
+
get: function () { return hydrogenReact.parseMetafield; }
|
|
2895
2930
|
});
|
|
2896
2931
|
Object.defineProperty(exports, 'sendShopifyAnalytics', {
|
|
2897
2932
|
enumerable: true,
|
|
2898
|
-
get: function () { return
|
|
2933
|
+
get: function () { return hydrogenReact.sendShopifyAnalytics; }
|
|
2899
2934
|
});
|
|
2900
2935
|
Object.defineProperty(exports, 'storefrontApiCustomScalars', {
|
|
2901
2936
|
enumerable: true,
|
|
2902
|
-
get: function () { return
|
|
2937
|
+
get: function () { return hydrogenReact.storefrontApiCustomScalars; }
|
|
2903
2938
|
});
|
|
2904
2939
|
Object.defineProperty(exports, 'useMoney', {
|
|
2905
2940
|
enumerable: true,
|
|
2906
|
-
get: function () { return
|
|
2941
|
+
get: function () { return hydrogenReact.useMoney; }
|
|
2907
2942
|
});
|
|
2908
2943
|
Object.defineProperty(exports, 'useShopifyCookies', {
|
|
2909
2944
|
enumerable: true,
|
|
2910
|
-
get: function () { return
|
|
2945
|
+
get: function () { return hydrogenReact.useShopifyCookies; }
|
|
2911
2946
|
});
|
|
2912
2947
|
exports.CacheCustom = CacheCustom;
|
|
2913
2948
|
exports.CacheLong = CacheLong;
|
|
@@ -2920,5 +2955,7 @@ exports.generateCacheControlHeader = generateCacheControlHeader;
|
|
|
2920
2955
|
exports.graphiqlLoader = graphiqlLoader;
|
|
2921
2956
|
exports.isStorefrontApiError = isStorefrontApiError;
|
|
2922
2957
|
exports.storefrontRedirect = storefrontRedirect;
|
|
2958
|
+
exports.useDataFromFetchers = useDataFromFetchers;
|
|
2959
|
+
exports.useDataFromMatches = useDataFromMatches;
|
|
2923
2960
|
//# sourceMappingURL=out.js.map
|
|
2924
2961
|
//# sourceMappingURL=index.cjs.map
|