@shopify/hydrogen 1.6.7 → 1.7.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/dist/esnext/components/CartProvider/CartProvider.client.js +4 -2
- package/dist/esnext/entry-server.js +3 -2
- package/dist/esnext/foundation/Cache/cache.js +4 -3
- package/dist/esnext/utilities/bot-ua.js +33 -31
- package/dist/esnext/utilities/hash.js +1 -1
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useRef, useState, useTransition, } from 'react';
|
|
2
|
-
import { CountryCode, } from '../../storefront-api-types.js';
|
|
3
2
|
import { defaultCartFragment } from './cart-queries.js';
|
|
4
3
|
import { CartContext } from './context.js';
|
|
5
4
|
import { useCartAPIStateMachine } from './useCartAPIStateMachine.client.js';
|
|
6
5
|
import { CART_ID_STORAGE_KEY } from './constants.js';
|
|
7
6
|
import { ClientAnalytics } from '../../foundation/Analytics/ClientAnalytics.js';
|
|
8
|
-
|
|
7
|
+
import { useLocalization } from '../../hooks/useLocalization/useLocalization.js';
|
|
8
|
+
export function CartProvider({ children, numCartLines, onCreate, onLineAdd, onLineRemove, onLineUpdate, onNoteUpdate, onBuyerIdentityUpdate, onAttributesUpdate, onDiscountCodesUpdate, onCreateComplete, onLineAddComplete, onLineRemoveComplete, onLineUpdateComplete, onNoteUpdateComplete, onBuyerIdentityUpdateComplete, onAttributesUpdateComplete, onDiscountCodesUpdateComplete, data: cart, cartFragment = defaultCartFragment, customerAccessToken, countryCode, }) {
|
|
9
|
+
const { country } = useLocalization();
|
|
10
|
+
countryCode = (countryCode ?? country.isoCode).toUpperCase();
|
|
9
11
|
if (countryCode)
|
|
10
12
|
countryCode = countryCode.toUpperCase();
|
|
11
13
|
const [prevCountryCode, setPrevCountryCode] = useState(countryCode);
|
|
@@ -71,7 +71,7 @@ export const renderHydrogen = (App) => {
|
|
|
71
71
|
}
|
|
72
72
|
if (hydrogenConfig.poweredByHeader ?? true) {
|
|
73
73
|
// If undefined in the config, then always show the header
|
|
74
|
-
response.headers.set('powered-by', 'Shopify
|
|
74
|
+
response.headers.set('powered-by', 'Shopify, Hydrogen');
|
|
75
75
|
}
|
|
76
76
|
sessionApi ??= hydrogenConfig.session?.(log);
|
|
77
77
|
request.ctx.session = getSyncSessionApi(request, response, log, sessionApi);
|
|
@@ -171,7 +171,8 @@ async function processRequest(handleRequest, App, url, request, sessionApi, opti
|
|
|
171
171
|
headers: response.headers,
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
|
-
if (
|
|
174
|
+
if (request.headers.get('oxygen-do-not-stream-response') === 'true' ||
|
|
175
|
+
isBotUA(url, request.headers.get('user-agent'))) {
|
|
175
176
|
response.doNotStream();
|
|
176
177
|
}
|
|
177
178
|
return runSSR({
|
|
@@ -81,13 +81,14 @@ export async function setItemInCache(request, response, userCacheOptions) {
|
|
|
81
81
|
*/
|
|
82
82
|
const cacheControl = getCacheControlSetting(userCacheOptions);
|
|
83
83
|
// The padded cache-control to mimic stale-while-revalidate
|
|
84
|
-
|
|
84
|
+
const paddedCacheControlString = generateDefaultCacheControlHeader(getCacheControlSetting(cacheControl, {
|
|
85
85
|
maxAge: (cacheControl.maxAge || 0) + (cacheControl.staleWhileRevalidate || 0),
|
|
86
|
-
}))
|
|
86
|
+
}));
|
|
87
87
|
// The cache-control we want to set on response
|
|
88
|
-
const cacheControlString = generateDefaultCacheControlHeader(
|
|
88
|
+
const cacheControlString = generateDefaultCacheControlHeader(cacheControl);
|
|
89
89
|
// CF will override cache-control, so we need to keep a
|
|
90
90
|
// non-modified real-cache-control
|
|
91
|
+
response.headers.set('cache-control', paddedCacheControlString);
|
|
91
92
|
response.headers.set('real-cache-control', cacheControlString);
|
|
92
93
|
response.headers.set('cache-put-date', new Date().toUTCString());
|
|
93
94
|
logCacheApiStatus('PUT', request.url);
|
|
@@ -4,54 +4,56 @@
|
|
|
4
4
|
* https://github.com/GoogleChrome/rendertron/blob/6f681688737846b28754fbfdf5db173846a826df/middleware/src/middleware.ts#L24-L41
|
|
5
5
|
*/
|
|
6
6
|
const botUserAgents = [
|
|
7
|
-
'
|
|
8
|
-
'
|
|
7
|
+
'360spider',
|
|
8
|
+
'adsbot-google',
|
|
9
|
+
'adsbot-google-mobile',
|
|
9
10
|
'applebot',
|
|
10
|
-
'Baiduspider',
|
|
11
11
|
'baiduspider',
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'PetalBot',
|
|
15
|
-
'Yisouspider',
|
|
12
|
+
'baiduspider',
|
|
13
|
+
'bingbot',
|
|
16
14
|
'bingbot',
|
|
17
|
-
'
|
|
18
|
-
'BingPreview',
|
|
15
|
+
'bingpreview',
|
|
19
16
|
'bitlybot',
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
17
|
+
'bytespider',
|
|
18
|
+
'discordbot',
|
|
19
|
+
'duckduckbot',
|
|
20
|
+
'embedly',
|
|
23
21
|
'facebookcatalog',
|
|
24
22
|
'facebookexternalhit',
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'
|
|
23
|
+
'google-inspectiontool',
|
|
24
|
+
'google-pagerenderer',
|
|
25
|
+
'googlebot',
|
|
26
|
+
'googlebot-image',
|
|
27
|
+
'googlebot-news',
|
|
28
|
+
'googlebot-video',
|
|
29
|
+
'googleother',
|
|
30
30
|
'googleweblight',
|
|
31
31
|
'ia_archive',
|
|
32
|
-
'
|
|
33
|
-
'
|
|
32
|
+
'ia_archiver',
|
|
33
|
+
'linkedinbot',
|
|
34
|
+
'mediapartners-google',
|
|
34
35
|
'outbrain',
|
|
36
|
+
'petalbot',
|
|
35
37
|
'pinterest',
|
|
36
38
|
'quora link preview',
|
|
37
39
|
'redditbot',
|
|
38
40
|
'rogerbot',
|
|
41
|
+
'seoradar',
|
|
39
42
|
'showyoubot',
|
|
40
|
-
'
|
|
41
|
-
'
|
|
42
|
-
'
|
|
43
|
+
'skypeuripreview',
|
|
44
|
+
'slackbot',
|
|
45
|
+
'slurp',
|
|
43
46
|
'sogou',
|
|
44
|
-
'
|
|
45
|
-
'
|
|
47
|
+
'storebot-google',
|
|
48
|
+
'telegrambot',
|
|
46
49
|
'tumblr',
|
|
47
|
-
'
|
|
48
|
-
'
|
|
49
|
-
'
|
|
50
|
-
'
|
|
50
|
+
'twitterbot',
|
|
51
|
+
'vkshare',
|
|
52
|
+
'w3c html2txt',
|
|
53
|
+
'w3c_validator',
|
|
54
|
+
'whatsapp',
|
|
51
55
|
'yandex',
|
|
52
|
-
|
|
53
|
-
'Seoradar',
|
|
54
|
-
'W3C html2txt',
|
|
56
|
+
'yisouspider',
|
|
55
57
|
];
|
|
56
58
|
/**
|
|
57
59
|
* Creates a regex based on the botUserAgents array
|
package/dist/esnext/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "1.
|
|
1
|
+
export declare const LIB_VERSION = "1.7.0";
|
package/dist/esnext/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const LIB_VERSION = '1.
|
|
1
|
+
export const LIB_VERSION = '1.7.0';
|