@graphcommerce/next-ui 9.0.0-canary.73 → 9.0.0-canary.74

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,7 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 9.0.0-canary.74
4
+
3
5
  ## 9.0.0-canary.73
4
6
 
7
+ ### Patch Changes
8
+
9
+ - [`4c24225`](https://github.com/graphcommerce-org/graphcommerce/commit/4c24225f9f998cd40e71da06528eb9323e9b6752) - Created a new `memoDeep` function that is a deep compare variant of `React.memo`. Performance seems to be pretty good, but should only be used as a result of a profiling session. ([@paales](https://github.com/paales))
10
+
5
11
  ## 9.0.0-canary.72
6
12
 
7
13
  ## 9.0.0-canary.71
package/hooks/index.ts CHANGED
@@ -7,3 +7,4 @@ export * from './useStorefrontConfig'
7
7
  export * from './useUrlQuery'
8
8
  export * from './useIsSsr'
9
9
  export * from './useLocale'
10
+ export * from './memoDeep'
@@ -0,0 +1,38 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ import { equal } from '@wry/equality'
3
+ import { FunctionComponent, memo, NamedExoticComponent } from 'react'
4
+
5
+ /**
6
+ * This is a deep comparison version of React's `memo` function.
7
+ *
8
+ * This method isn't too expensive to run, but will be rerun every time a parent component is rendered.
9
+ *
10
+ * This should probably only be used as the result of a performance profiling session.
11
+ */
12
+ export function memoDeep<P extends object>(
13
+ Component: FunctionComponent<P>,
14
+ measure: boolean = false,
15
+ ): NamedExoticComponent<P> {
16
+ return memo(
17
+ Component,
18
+ process.env.NODE_ENV === 'development' && measure
19
+ ? (prevProps, nextProps) => {
20
+ const start = performance.now()
21
+ const result = equal(prevProps, nextProps)
22
+ const ms = performance.now() - start
23
+
24
+ if (ms < 0.2) return result
25
+
26
+ console.log(`memoDeep took more than 0.2ms`, {
27
+ result,
28
+ ms,
29
+ Component,
30
+ prevProps,
31
+ nextProps,
32
+ })
33
+
34
+ return result
35
+ }
36
+ : equal,
37
+ )
38
+ }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/next-ui",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "9.0.0-canary.73",
5
+ "version": "9.0.0-canary.74",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -26,13 +26,13 @@
26
26
  "typescript": "5.5.3"
27
27
  },
28
28
  "peerDependencies": {
29
- "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.73",
30
- "@graphcommerce/framer-next-pages": "^9.0.0-canary.73",
31
- "@graphcommerce/framer-scroller": "^9.0.0-canary.73",
32
- "@graphcommerce/framer-utils": "^9.0.0-canary.73",
33
- "@graphcommerce/image": "^9.0.0-canary.73",
34
- "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.73",
35
- "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.73",
29
+ "@graphcommerce/eslint-config-pwa": "^9.0.0-canary.74",
30
+ "@graphcommerce/framer-next-pages": "^9.0.0-canary.74",
31
+ "@graphcommerce/framer-scroller": "^9.0.0-canary.74",
32
+ "@graphcommerce/framer-utils": "^9.0.0-canary.74",
33
+ "@graphcommerce/image": "^9.0.0-canary.74",
34
+ "@graphcommerce/prettier-config-pwa": "^9.0.0-canary.74",
35
+ "@graphcommerce/typescript-config-pwa": "^9.0.0-canary.74",
36
36
  "@lingui/core": "^4.2.1",
37
37
  "@lingui/macro": "^4.2.1",
38
38
  "@lingui/react": "^4.2.1",
package/server.ts CHANGED
@@ -6,3 +6,4 @@ export * from './utils/sitemap'
6
6
  export * from './utils/storefrontConfig'
7
7
  export * from './PageMeta/canonicalize'
8
8
  export * from './Document'
9
+ export * from './utils/cookie'