@graphcommerce/framer-utils 11.0.0-canary.46 → 11.0.0-canary.48

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,23 @@
1
1
  # Change Log
2
2
 
3
+ ## 11.0.0-canary.48
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2679](https://github.com/graphcommerce-org/graphcommerce/pull/2679) [`4d0bb18`](https://github.com/graphcommerce-org/graphcommerce/commit/4d0bb1822241d919e2f57495f644afbd4ea3baf2) - Reduce Total Blocking Time by removing synchronous re-renders right after hydration and splitting up startup work:
8
+
9
+ - `usePrivateQuery` no longer uses `useIsSSR()`. Its `useSyncExternalStore` server/client mismatch forced a synchronous re-render of the whole page after hydration, even for guests. Without a private context the mask stays on, which is inert because it only hides content while the `private-query` CSS flag is set.
10
+ - `useCookie(name)` subscribes to a single cookie via `useSyncExternalStore` (server snapshot `null`), so it only re-renders after hydration when that cookie is actually set.
11
+ - `usePrivateQueryContext` (magento-customer plugin) subscribes to the derived `loggedIn` boolean on the Apollo cache instead of the full `CustomerToken` query result, so the page doesn't re-render when the query result object changes but `loggedIn` doesn't.
12
+ - `CssAndFramerMotionProvider` loads framer-motion features after hydration and applies them in `startTransition`, so the re-render of all `m` components is time-sliced and the features stay out of the startup bundle.
13
+ - Examples: `ThemeProvider` uses `noSsr`, avoiding MUI's color scheme provider re-rendering every styled component after hydration (`colorSchemeSelector: 'class'` already handles the color scheme in CSS before paint).
14
+ - Examples: added `patch-package` patches for `next@16.2.6` (Pages Router hydrates inside `startTransition`, like the App Router; the route loader yields between `_app` and page instantiation) and `react-hook-form@7.67.0` (only set `formState.isReady` when it is subscribed to; the unconditional update re-rendered every form synchronously after mount).
15
+ - `ListFormat` renders a single item directly instead of creating an `Intl.ListFormat`, which loads its locale data on first use. The store switcher in the header rendered one item on every page; this cut ~12–18% of TBT at 4× CPU throttling.
16
+ - `useElementScroll` no longer measures `scrollWidth` synchronously in its layout effect, which forced a style recalc and layout of the whole page during the hydration commit. It measures in framer-motion's read step instead; the ResizeObserver also delivers an initial observation.
17
+ - `framer-utils` uses framer-motion's `frame` instead of `framesync`, and `framer-scroller` loads `popmotion` on demand (only needed after user interaction). Together ~53 KB raw of JS out of the startup bundle. ([@paales](https://github.com/paales))
18
+
19
+ ## 11.0.0-canary.47
20
+
3
21
  ## 11.0.0-canary.46
4
22
 
5
23
  ## 11.0.0-canary.45
@@ -1,6 +1,5 @@
1
1
  import type { MotionValue } from 'framer-motion'
2
- import { useMotionValue, useTransform } from 'framer-motion'
3
- import sync from 'framesync'
2
+ import { frame, useMotionValue, useTransform } from 'framer-motion'
4
3
  import type { RefObject } from 'react'
5
4
  import { useConstant } from './useConstant'
6
5
  import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
@@ -45,9 +44,11 @@ export function useElementScroll(ref?: RefObject<HTMLElement | null>): ScrollMot
45
44
  if (!animating.get()) y.set(element.scrollTop)
46
45
  if (!animating.get()) x.set(element.scrollLeft)
47
46
  }
48
- updater()
49
-
50
- const updaterTimed = () => sync.read(updater)
47
+ // Measure in framer-motion's read step instead of synchronously in this layout effect: reading
48
+ // scrollWidth here forces a style recalc and layout of the whole page during the (hydration)
49
+ // commit. The ResizeObserver below also delivers an initial observation.
50
+ const updaterTimed = () => frame.read(updater)
51
+ updaterTimed()
51
52
  element.addEventListener('scroll', updaterTimed, { passive: true })
52
53
  const ro = new ResizeObserver(updaterTimed)
53
54
  ro.observe(element)
@@ -1,5 +1,5 @@
1
1
  import type { MotionValue } from 'framer-motion'
2
- import sync from 'framesync'
2
+ import { frame } from 'framer-motion'
3
3
  import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
4
4
 
5
5
  export type UseClientSizeReturn = { x: MotionValue<string>; y: MotionValue<string> }
@@ -32,7 +32,7 @@ export function useMeasureDynamicViewportSize() {
32
32
  document.body.style.setProperty('--client-size-x', `${global.window?.innerWidth ?? 0}px`)
33
33
  document.body.style.setProperty('--client-size-y', `${global.window?.innerHeight ?? 0}px`)
34
34
  }
35
- const recalcSynced = () => sync.read(recalc)
35
+ const recalcSynced = () => frame.read(recalc)
36
36
 
37
37
  window.addEventListener('resize', recalcSynced)
38
38
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/framer-utils",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "11.0.0-canary.46",
5
+ "version": "11.0.0-canary.48",
6
6
  "sideEffects": false,
7
7
  "scripts": {
8
8
  "dev": "tsc -W"
@@ -18,14 +18,11 @@
18
18
  }
19
19
  },
20
20
  "peerDependencies": {
21
- "@graphcommerce/eslint-config-pwa": "^11.0.0-canary.46",
22
- "@graphcommerce/prettier-config-pwa": "^11.0.0-canary.46",
23
- "@graphcommerce/typescript-config-pwa": "^11.0.0-canary.46",
21
+ "@graphcommerce/eslint-config-pwa": "^11.0.0-canary.48",
22
+ "@graphcommerce/prettier-config-pwa": "^11.0.0-canary.48",
23
+ "@graphcommerce/typescript-config-pwa": "^11.0.0-canary.48",
24
24
  "framer-motion": "^11.0.0",
25
25
  "react": "^19.2.0",
26
26
  "react-dom": "^19.2.0"
27
- },
28
- "dependencies": {
29
- "framesync": "^6.1.2"
30
27
  }
31
28
  }
@@ -1,6 +1,5 @@
1
1
  import type { MotionValue } from 'framer-motion'
2
- import { motionValue } from 'framer-motion'
3
- import sync from 'framesync'
2
+ import { frame, motionValue } from 'framer-motion'
4
3
 
5
4
  export type ClientSize = {
6
5
  x: MotionValue<number>
@@ -17,7 +16,7 @@ export const clientSize: ClientSize = {
17
16
 
18
17
  if (typeof window !== 'undefined') {
19
18
  window.addEventListener('resize', () => {
20
- sync.read(() => {
19
+ frame.read(() => {
21
20
  clientSize.x.set(x())
22
21
  clientSize.y.set(y())
23
22
  })