@faststore/core 3.0.137 → 3.0.140

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.
Files changed (42) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +15 -15
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/config.json +3 -3
  5. package/.next/cache/eslint/.cache_1gneedd +1 -1
  6. package/.next/cache/webpack/client-production/0.pack +0 -0
  7. package/.next/cache/webpack/client-production/index.pack +0 -0
  8. package/.next/cache/webpack/server-production/0.pack +0 -0
  9. package/.next/cache/webpack/server-production/index.pack +0 -0
  10. package/.next/next-minimal-server.js.nft.json +1 -1
  11. package/.next/next-server.js.nft.json +1 -1
  12. package/.next/prerender-manifest.js +1 -1
  13. package/.next/prerender-manifest.json +1 -1
  14. package/.next/routes-manifest.json +1 -1
  15. package/.next/server/chunks/158.js +1 -1
  16. package/.next/server/chunks/350.js +1 -1
  17. package/.next/server/chunks/646.js +3 -3
  18. package/.next/server/middleware-build-manifest.js +1 -1
  19. package/.next/server/pages/[...slug].js +1 -1
  20. package/.next/server/pages/[slug]/p.js +1 -1
  21. package/.next/server/pages/api/graphql.js +1 -1
  22. package/.next/server/pages/en-US/404.html +1 -1
  23. package/.next/server/pages/en-US/500.html +1 -1
  24. package/.next/server/pages/en-US/account.html +1 -1
  25. package/.next/server/pages/en-US/checkout.html +1 -1
  26. package/.next/server/pages/en-US/login.html +1 -1
  27. package/.next/server/pages/en-US/s.html +1 -1
  28. package/.next/server/pages/en-US.html +2 -2
  29. package/.next/server/pages/index.js +1 -1
  30. package/.next/server/pages/s.js +1 -1
  31. package/.next/server/pages-manifest.json +1 -1
  32. package/.next/static/chunks/{668-50bdc7af64fc8d68.js → 668-2ab3a222082fc6d1.js} +1 -1
  33. package/.next/static/chunks/{721-817282c255893c43.js → 721-114d84068d259f8a.js} +1 -1
  34. package/.next/static/{kiNt2PnuKcqjGEhJKNeTr → iw6ZYsdLfGyQ6vZX3GbUK}/_buildManifest.js +1 -1
  35. package/.next/trace +99 -99
  36. package/.turbo/turbo-build.log +1 -1
  37. package/.turbo/turbo-lint.log +1 -1
  38. package/.turbo/turbo-test.log +5 -5
  39. package/package.json +3 -3
  40. package/src/components/cms/RenderSections.tsx +47 -3
  41. package/src/components/sections/Hero/Hero.tsx +1 -0
  42. /package/.next/static/{kiNt2PnuKcqjGEhJKNeTr → iw6ZYsdLfGyQ6vZX3GbUK}/_ssgManifest.js +0 -0
@@ -74,4 +74,4 @@ Route (pages) Size First Load JS
74
74
  ○ (Static) automatically rendered as static HTML (uses no initial props)
75
75
  ● (SSG) automatically generated as static HTML + JSON (uses getStaticProps)
76
76
 
77
- Done in 73.66s.
77
+ Done in 72.00s.
@@ -1,4 +1,4 @@
1
1
  yarn run v1.22.22
2
2
  $ next lint
3
3
  ✔ No ESLint warnings or errors
4
- Done in 6.25s.
4
+ Done in 5.89s.
@@ -1,12 +1,12 @@
1
1
  yarn run v1.22.22
2
2
  $ jest
3
- PASS test/utils/multipleTemplates.test.ts (34.663 s)
4
- PASS test/server/cms/index.test.ts (35.118 s)
5
- PASS test/server/index.test.ts (38.936 s)
3
+ PASS test/server/cms/index.test.ts (34.914 s)
4
+ PASS test/utils/multipleTemplates.test.ts (35.634 s)
5
+ PASS test/server/index.test.ts (38.535 s)
6
6
 
7
7
  Test Suites: 3 passed, 3 total
8
8
  Tests: 19 passed, 19 total
9
9
  Snapshots: 0 total
10
- Time: 40.148 s
10
+ Time: 39.603 s
11
11
  Ran all test suites.
12
- Done in 42.20s.
12
+ Done in 41.17s.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "3.0.137",
3
+ "version": "3.0.140",
4
4
  "license": "MIT",
5
5
  "repository": "vtex/faststore",
6
6
  "browserslist": "supports es6-module and not dead",
@@ -43,7 +43,7 @@
43
43
  "@envelop/graphql-jit": "^8.0.3",
44
44
  "@envelop/parser-cache": "^6.0.2",
45
45
  "@envelop/validation-cache": "^6.0.2",
46
- "@faststore/api": "^3.0.135",
46
+ "@faststore/api": "^3.0.140",
47
47
  "@faststore/components": "^3.0.135",
48
48
  "@faststore/graphql-utils": "^3.0.135",
49
49
  "@faststore/lighthouse": "^3.0.135",
@@ -128,5 +128,5 @@
128
128
  "node": "18.19.0",
129
129
  "yarn": "1.19.1"
130
130
  },
131
- "gitHead": "180d1b1e75b27d193341288397f795088f12bd8d"
131
+ "gitHead": "5d08521fda57ec355d8a9943235c7f4e7121ed24"
132
132
  }
@@ -1,13 +1,24 @@
1
- import { ComponentType, PropsWithChildren, memo, useMemo } from 'react'
1
+ import {
2
+ ComponentType,
3
+ PropsWithChildren,
4
+ ReactNode,
5
+ memo,
6
+ useMemo,
7
+ } from 'react'
2
8
 
3
- import SectionBoundary from './SectionBoundary'
4
9
  import { Section } from '@vtex/client-cms'
10
+ import SectionBoundary from './SectionBoundary'
11
+ import ViewportObserver from './ViewportObserver'
12
+
13
+ import { useUI } from '@faststore/ui'
5
14
 
6
15
  interface Props {
7
16
  components: Record<string, ComponentType<any>>
8
17
  sections: Array<{ name: string; data: any }>
9
18
  }
10
19
 
20
+ const SECTIONS_OUT_OF_VIEWPORT = ['CartSidebar', 'RegionModal']
21
+
11
22
  const useDividedSections = (sections: Section[]) => {
12
23
  return useMemo(() => {
13
24
  const indexChildren = sections.findIndex(({ name }) => name === 'Children')
@@ -21,6 +32,39 @@ const useDividedSections = (sections: Section[]) => {
21
32
  }, [sections])
22
33
  }
23
34
 
35
+ /**
36
+ * This component is responsible for lazy loading Sections that are out of the viewport.
37
+ * It achieves this by:
38
+ * 1. Using the IntersectionObserver API for Sections below the fold.
39
+ * 2. Checking the UI context for Sections that are not in the viewport, such as the CartSidebar and RegionModal.
40
+ *
41
+ * @param sectionName
42
+ * @returns
43
+ */
44
+ export const LazyLoadingSection = ({
45
+ sectionName,
46
+ children,
47
+ }: {
48
+ sectionName: string
49
+ children: ReactNode
50
+ }) => {
51
+ const { cart: displayCart, modal: displayModal } = useUI()
52
+
53
+ if (SECTIONS_OUT_OF_VIEWPORT.includes(sectionName)) {
54
+ const shouldLoad =
55
+ (sectionName === 'CartSidebar' && displayCart) ||
56
+ (sectionName === 'RegionModal' && displayModal)
57
+ if (!shouldLoad) {
58
+ return null
59
+ }
60
+
61
+ return children
62
+ }
63
+ return (
64
+ <ViewportObserver sectionName={sectionName}>{children}</ViewportObserver>
65
+ )
66
+ }
67
+
24
68
  const RenderSectionsBase = ({ sections = [], components }: Props) => {
25
69
  return (
26
70
  <>
@@ -37,7 +81,7 @@ const RenderSectionsBase = ({ sections = [], components }: Props) => {
37
81
  }
38
82
 
39
83
  return (
40
- <SectionBoundary key={`cms-section-${index}`} name={name}>
84
+ <SectionBoundary key={`cms-section-${name}-${index}`} name={name}>
41
85
  <Component {...data} />
42
86
  </SectionBoundary>
43
87
  )
@@ -60,6 +60,7 @@ const Hero = ({
60
60
  width={360}
61
61
  height={240}
62
62
  sizes="(max-width: 412px) 40vw, (max-width: 768px) 90vw, 50vw"
63
+ priority={true}
63
64
  />
64
65
  </HeroImage.Component>
65
66
  <HeroHeader.Component