@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.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +15 -15
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/eslint/.cache_1gneedd +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/next-minimal-server.js.nft.json +1 -1
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.js +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/158.js +1 -1
- package/.next/server/chunks/350.js +1 -1
- package/.next/server/chunks/646.js +3 -3
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/[...slug].js +1 -1
- package/.next/server/pages/[slug]/p.js +1 -1
- package/.next/server/pages/api/graphql.js +1 -1
- package/.next/server/pages/en-US/404.html +1 -1
- package/.next/server/pages/en-US/500.html +1 -1
- package/.next/server/pages/en-US/account.html +1 -1
- package/.next/server/pages/en-US/checkout.html +1 -1
- package/.next/server/pages/en-US/login.html +1 -1
- package/.next/server/pages/en-US/s.html +1 -1
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/index.js +1 -1
- package/.next/server/pages/s.js +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/static/chunks/{668-50bdc7af64fc8d68.js → 668-2ab3a222082fc6d1.js} +1 -1
- package/.next/static/chunks/{721-817282c255893c43.js → 721-114d84068d259f8a.js} +1 -1
- package/.next/static/{kiNt2PnuKcqjGEhJKNeTr → iw6ZYsdLfGyQ6vZX3GbUK}/_buildManifest.js +1 -1
- package/.next/trace +99 -99
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +5 -5
- package/package.json +3 -3
- package/src/components/cms/RenderSections.tsx +47 -3
- package/src/components/sections/Hero/Hero.tsx +1 -0
- /package/.next/static/{kiNt2PnuKcqjGEhJKNeTr → iw6ZYsdLfGyQ6vZX3GbUK}/_ssgManifest.js +0 -0
package/.turbo/turbo-build.log
CHANGED
package/.turbo/turbo-lint.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
yarn run v1.22.22
|
|
2
2
|
$ jest
|
|
3
|
-
PASS test/
|
|
4
|
-
PASS test/
|
|
5
|
-
PASS test/server/index.test.ts (38.
|
|
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:
|
|
10
|
+
Time: 39.603 s
|
|
11
11
|
Ran all test suites.
|
|
12
|
-
Done in
|
|
12
|
+
Done in 41.17s.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "3.0.
|
|
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.
|
|
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": "
|
|
131
|
+
"gitHead": "5d08521fda57ec355d8a9943235c7f4e7121ed24"
|
|
132
132
|
}
|
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import {
|
|
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
|
)
|
|
File without changes
|