@shopify/hydrogen 0.17.0 → 0.17.1

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.17.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1145](https://github.com/Shopify/hydrogen/pull/1145) [`865b66e9`](https://github.com/Shopify/hydrogen/commit/865b66e95d67965543bcb92f0f9f15b5742f3596) Thanks [@jplhomer](https://github.com/jplhomer)! - Fix search params on navigation
8
+
9
+ * [#1139](https://github.com/Shopify/hydrogen/pull/1139) [`93525637`](https://github.com/Shopify/hydrogen/commit/9352563761c0405f2e2b39cb6b8b8f577f2522b9) Thanks [@blittle](https://github.com/blittle)! - Fix the scroll restoration on page transitions
10
+
11
+ - [#1144](https://github.com/Shopify/hydrogen/pull/1144) [`dec5eb8e`](https://github.com/Shopify/hydrogen/commit/dec5eb8e34e75c806aa1cfea935814d228ab29d6) Thanks [@wizardlyhel](https://github.com/wizardlyhel)! - fix 0.17 build
12
+
3
13
  ## 0.17.0
4
14
 
5
15
  ### Minor Changes
@@ -14,7 +14,7 @@ export declare type CookieOptions = {
14
14
  * within the [defined path](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#path_attribute).
15
15
  */
16
16
  path?: string;
17
- /** [A date in which the cookie will expire](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#define_the_lifetime_of_a_cookie).
17
+ /** [A date on which the cookie will expire](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#define_the_lifetime_of_a_cookie).
18
18
  * If the date is in the past, then the browser will remove the cookie.
19
19
  */
20
20
  expires?: Date;
@@ -29,7 +29,7 @@ async function startFileLock(promise) {
29
29
  export const FileSessionStorage = function (
30
30
  /** The name of the cookie stored in the browser. */
31
31
  name,
32
- /** A directory to store the session files within. Each session is stored in a separate file on the file system. */
32
+ /** A directory to store the session files in. Each session is stored in a separate file on the file system. */
33
33
  dir,
34
34
  /** An optional object to configure [how the cookie is persisted in the browser](https://shopify.dev/api/hydrogen/components/framework/cookie#cookie-options). */
35
35
  cookieOptions) {
@@ -17,7 +17,7 @@ export const BrowserRouter = ({ history: pHistory, children, }) => {
17
17
  positions[location.key] = window.scrollY;
18
18
  setLocationServerProps({
19
19
  pathname: newLocation.pathname,
20
- search: location.search,
20
+ search: newLocation.search,
21
21
  });
22
22
  setLocation(newLocation);
23
23
  });
@@ -1,6 +1,6 @@
1
1
  import React, { createContext, useMemo, useCallback,
2
2
  // @ts-ignore
3
- useTransition, useState, useEffect, } from 'react';
3
+ useTransition, useState, } from 'react';
4
4
  const PRIVATE_PROPS = ['request', 'response'];
5
5
  export const ServerPropsContext = createContext(null);
6
6
  export function ServerPropsProvider({ initialServerProps, setServerPropsForRsc, children, }) {
@@ -8,12 +8,18 @@ export function ServerPropsProvider({ initialServerProps, setServerPropsForRsc,
8
8
  const [serverProps, setServerProps] = useState({});
9
9
  const [pending, startTransition] = useTransition();
10
10
  const setServerPropsCallback = useCallback((input, propValue) => {
11
- setServerProps((prev) => getNewValue(prev, input, propValue));
11
+ startTransition(() => {
12
+ setServerProps((prev) => getNewValue(prev, input, propValue));
13
+ setServerPropsForRsc((prev) => getNewValue(prev, input, propValue));
14
+ });
12
15
  }, []);
13
16
  const setLocationServerPropsCallback = useCallback((input, propValue) => {
14
17
  // Flush the existing user server state when location changes, leaving only the persisted state
15
- setServerProps({});
16
- setLocationServerProps((prev) => getNewValue(prev, input, propValue));
18
+ startTransition(() => {
19
+ setServerPropsForRsc((prev) => getNewValue(prev, input, propValue));
20
+ setServerProps({});
21
+ setLocationServerProps((prev) => getNewValue(prev, input, propValue));
22
+ });
17
23
  }, []);
18
24
  const getProposedLocationServerPropsCallback = useCallback((input, propValue) => {
19
25
  return getNewValue(locationServerProps, input, propValue);
@@ -40,34 +46,17 @@ export function ServerPropsProvider({ initialServerProps, setServerPropsForRsc,
40
46
  ...newValue,
41
47
  };
42
48
  }
43
- const resolvedServerPropsForRsc = useMemo(() => {
44
- return {
45
- ...serverProps,
46
- ...locationServerProps,
47
- };
48
- }, [serverProps, locationServerProps]);
49
- const resolvedServerProps = useMemo(() => {
50
- return {
51
- ...serverProps,
52
- };
53
- }, [serverProps]);
54
- useEffect(() => {
55
- startTransition(() => {
56
- setServerPropsForRsc(resolvedServerPropsForRsc);
57
- });
58
- return () => { };
59
- }, [resolvedServerPropsForRsc]);
60
49
  const value = useMemo(() => ({
61
50
  pending,
62
51
  locationServerProps: locationServerProps,
63
- serverProps: resolvedServerProps,
52
+ serverProps,
64
53
  setServerProps: setServerPropsCallback,
65
54
  setLocationServerProps: setLocationServerPropsCallback,
66
55
  getProposedLocationServerProps: getProposedLocationServerPropsCallback,
67
56
  }), [
68
57
  pending,
69
58
  locationServerProps,
70
- resolvedServerProps,
59
+ serverProps,
71
60
  setServerPropsCallback,
72
61
  setLocationServerPropsCallback,
73
62
  getProposedLocationServerPropsCallback,
@@ -17,6 +17,7 @@ export default () => {
17
17
  * certain files due to how it is named.
18
18
  */
19
19
  rollupOptions.output = {
20
+ ...rollupOptions.output,
20
21
  chunkFileNames: '[hash].js',
21
22
  };
22
23
  }
@@ -1 +1 @@
1
- export declare const LIB_VERSION = "0.17.0";
1
+ export declare const LIB_VERSION = "0.17.1";
@@ -1 +1 @@
1
- export const LIB_VERSION = '0.17.0';
1
+ export const LIB_VERSION = '0.17.1';
@@ -43,7 +43,7 @@ const BrowserRouter = ({ history: pHistory, children, }) => {
43
43
  positions[location.key] = window.scrollY;
44
44
  setLocationServerProps({
45
45
  pathname: newLocation.pathname,
46
- search: location.search,
46
+ search: newLocation.search,
47
47
  });
48
48
  setLocation(newLocation);
49
49
  });
@@ -32,12 +32,18 @@ function ServerPropsProvider({ initialServerProps, setServerPropsForRsc, childre
32
32
  const [serverProps, setServerProps] = (0, react_1.useState)({});
33
33
  const [pending, startTransition] = (0, react_1.useTransition)();
34
34
  const setServerPropsCallback = (0, react_1.useCallback)((input, propValue) => {
35
- setServerProps((prev) => getNewValue(prev, input, propValue));
35
+ startTransition(() => {
36
+ setServerProps((prev) => getNewValue(prev, input, propValue));
37
+ setServerPropsForRsc((prev) => getNewValue(prev, input, propValue));
38
+ });
36
39
  }, []);
37
40
  const setLocationServerPropsCallback = (0, react_1.useCallback)((input, propValue) => {
38
41
  // Flush the existing user server state when location changes, leaving only the persisted state
39
- setServerProps({});
40
- setLocationServerProps((prev) => getNewValue(prev, input, propValue));
42
+ startTransition(() => {
43
+ setServerPropsForRsc((prev) => getNewValue(prev, input, propValue));
44
+ setServerProps({});
45
+ setLocationServerProps((prev) => getNewValue(prev, input, propValue));
46
+ });
41
47
  }, []);
42
48
  const getProposedLocationServerPropsCallback = (0, react_1.useCallback)((input, propValue) => {
43
49
  return getNewValue(locationServerProps, input, propValue);
@@ -64,34 +70,17 @@ function ServerPropsProvider({ initialServerProps, setServerPropsForRsc, childre
64
70
  ...newValue,
65
71
  };
66
72
  }
67
- const resolvedServerPropsForRsc = (0, react_1.useMemo)(() => {
68
- return {
69
- ...serverProps,
70
- ...locationServerProps,
71
- };
72
- }, [serverProps, locationServerProps]);
73
- const resolvedServerProps = (0, react_1.useMemo)(() => {
74
- return {
75
- ...serverProps,
76
- };
77
- }, [serverProps]);
78
- (0, react_1.useEffect)(() => {
79
- startTransition(() => {
80
- setServerPropsForRsc(resolvedServerPropsForRsc);
81
- });
82
- return () => { };
83
- }, [resolvedServerPropsForRsc]);
84
73
  const value = (0, react_1.useMemo)(() => ({
85
74
  pending,
86
75
  locationServerProps: locationServerProps,
87
- serverProps: resolvedServerProps,
76
+ serverProps,
88
77
  setServerProps: setServerPropsCallback,
89
78
  setLocationServerProps: setLocationServerPropsCallback,
90
79
  getProposedLocationServerProps: getProposedLocationServerPropsCallback,
91
80
  }), [
92
81
  pending,
93
82
  locationServerProps,
94
- resolvedServerProps,
83
+ serverProps,
95
84
  setServerPropsCallback,
96
85
  setLocationServerPropsCallback,
97
86
  getProposedLocationServerPropsCallback,
@@ -19,6 +19,7 @@ exports.default = () => {
19
19
  * certain files due to how it is named.
20
20
  */
21
21
  rollupOptions.output = {
22
+ ...rollupOptions.output,
22
23
  chunkFileNames: '[hash].js',
23
24
  };
24
25
  }
@@ -1 +1 @@
1
- export declare const LIB_VERSION = "0.17.0";
1
+ export declare const LIB_VERSION = "0.17.1";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LIB_VERSION = void 0;
4
- exports.LIB_VERSION = '0.17.0';
4
+ exports.LIB_VERSION = '0.17.1';
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "engines": {
8
8
  "node": ">=14"
9
9
  },
10
- "version": "0.17.0",
10
+ "version": "0.17.1",
11
11
  "description": "Modern custom Shopify storefronts",
12
12
  "license": "MIT",
13
13
  "main": "dist/esnext/index.js",