@faststore/core 3.1.0 → 3.1.2

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 +14 -14
  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/react-loadable-manifest.json +1 -1
  15. package/.next/routes-manifest.json +1 -1
  16. package/.next/server/chunks/8096.js +1 -1
  17. package/.next/server/chunks/9844.js +1 -1
  18. package/.next/server/middleware-build-manifest.js +1 -1
  19. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  20. package/.next/server/pages/en-US/404.html +1 -1
  21. package/.next/server/pages/en-US/500.html +1 -1
  22. package/.next/server/pages/en-US/account.html +1 -1
  23. package/.next/server/pages/en-US/checkout.html +1 -1
  24. package/.next/server/pages/en-US/login.html +1 -1
  25. package/.next/server/pages/en-US/s.html +1 -1
  26. package/.next/server/pages/en-US.html +1 -1
  27. package/.next/server/pages-manifest.json +1 -1
  28. package/.next/static/chunks/{2032.a5d5d24fee696f7e.js → 2032.5cd9c0854edb6b16.js} +1 -1
  29. package/.next/static/chunks/pages/{_app-e419b2062065ccf0.js → _app-15d247b2153b1dc4.js} +1 -1
  30. package/.next/static/chunks/{webpack-c139db73ca37b6f3.js → webpack-5c2cbf0d104592ed.js} +1 -1
  31. package/.next/trace +97 -97
  32. package/.turbo/turbo-build.log +6 -6
  33. package/.turbo/turbo-lint.log +1 -1
  34. package/.turbo/turbo-test.log +5 -5
  35. package/CHANGELOG.md +12 -0
  36. package/package.json +2 -2
  37. package/src/components/product/ProductGrid/ProductGrid.tsx +5 -4
  38. package/src/components/ui/ProductGallery/ProductGalleryPage.tsx +7 -8
  39. package/src/sdk/analytics/hooks/usePageViewEvent.ts +1 -5
  40. package/src/sdk/search/Sentinel.tsx +15 -9
  41. /package/.next/static/{aVo0RZ1_279AVZSq19y5i → Joon-fzFpeM4APyIWUsdO}/_buildManifest.js +0 -0
  42. /package/.next/static/{aVo0RZ1_279AVZSq19y5i → Joon-fzFpeM4APyIWUsdO}/_ssgManifest.js +0 -0
@@ -38,8 +38,8 @@ https://nextjs.org/telemetry
38
38
  Collecting page data ...
39
39
  Generating static pages (0/7) ...
40
40
 
41
41
  Generating static pages (1/7)
42
- Warning: Dynamic Content not found for the page: home. Refer to the Dynamic Content documentation at https://developers.vtex.com/docs/guides/faststore/dynamic-content-overview for mapping the page and the corresponding data-fetching function.
43
42
 
44
43
  Generating static pages (3/7)
44
+ Warning: Dynamic Content not found for the page: home. Refer to the Dynamic Content documentation at https://developers.vtex.com/docs/guides/faststore/dynamic-content-overview for mapping the page and the corresponding data-fetching function.
45
45
 
46
46
  Generating static pages (5/7)
47
47
 
48
48
  ✓ Generating static pages (7/7)
49
49
  Finalizing page optimization ...
@@ -50,7 +50,7 @@ Route (pages) Size First Load JS
50
50
  ├ └ css/b1806cbafd0c1f81.css 3.06 kB
51
51
  ├ /_app 0 B 91.7 kB
52
52
  ├ ● /[...slug] 2 kB 137 kB
53
- ├ ● /[slug]/p 30.3 kB 149 kB
53
+ ├ ● /[slug]/p 30.3 kB 148 kB
54
54
  ├ ├ css/bf1560439df2c1a1.css 5.66 kB
55
55
  ├ ├ css/e3ff5d95518a5c79.css 6.01 kB
56
56
  ├ └ css/9718991cd57978e9.css 14.8 kB
@@ -64,15 +64,15 @@ Route (pages) Size First Load JS
64
64
  ├ ● /checkout 694 B 119 kB
65
65
  ├ ● /login 1.57 kB 120 kB
66
66
  └ ● /s 2.44 kB 137 kB
67
- + First Load JS shared by all 94.8 kB
67
+ + First Load JS shared by all 94.7 kB
68
68
  ├ chunks/framework-12a146e94cfcf7c4.js 45.4 kB
69
69
  ├ chunks/main-209ac4974b020af1.js 33.1 kB
70
- ├ chunks/pages/_app-e419b2062065ccf0.js 9.87 kB
71
- ├ chunks/webpack-c139db73ca37b6f3.js 3.39 kB
70
+ ├ chunks/pages/_app-15d247b2153b1dc4.js 9.84 kB
71
+ ├ chunks/webpack-5c2cbf0d104592ed.js 3.39 kB
72
72
  └ css/ee0556daedda6306.css 3.07 kB
73
73
 
74
74
  λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
75
75
  ○ (Static) automatically rendered as static HTML (uses no initial props)
76
76
  ● (SSG) automatically generated as static HTML + JSON (uses getStaticProps)
77
77
 
78
- Done in 70.90s.
78
+ Done in 69.45s.
@@ -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.11s.
4
+ Done in 5.91s.
@@ -1,12 +1,12 @@
1
1
  yarn run v1.22.22
2
2
  $ jest
3
- PASS test/server/cms/index.test.ts (35.248 s)
4
- PASS test/utils/multipleTemplates.test.ts (35.354 s)
5
- PASS test/server/index.test.ts (38.448 s)
3
+ PASS test/utils/multipleTemplates.test.ts (34.643 s)
4
+ PASS test/server/cms/index.test.ts (35.284 s)
5
+ PASS test/server/index.test.ts (38.49 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: 39.56 s
10
+ Time: 39.72 s
11
11
  Ran all test suites.
12
- Done in 41.68s.
12
+ Done in 40.95s.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.1.2](https://github.com/vtex/faststore/compare/v3.1.1...v3.1.2) (2024-12-11)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **sdk:** page view event trigger ([#2586](https://github.com/vtex/faststore/issues/2586)) ([3988760](https://github.com/vtex/faststore/commit/398876013a293302f9a802b93f0f0880cfe32acb))
11
+
12
+ ## [3.1.1](https://github.com/vtex/faststore/compare/v3.1.0...v3.1.1) (2024-12-09)
13
+
14
+ ### Bug Fixes
15
+
16
+ - `Sentinel` rendering and wrong PLP's pagination behavior ([#2585](https://github.com/vtex/faststore/issues/2585)) ([ea59e77](https://github.com/vtex/faststore/commit/ea59e77fccee7866bd4e44b73e855dd5cee4ba6e)), closes [vtex-sites/starter.store#630](https://github.com/vtex-sites/starter.store/issues/630)
17
+
6
18
  # [3.1.0](https://github.com/vtex/faststore/compare/v3.0.160...v3.1.0) (2024-12-09)
7
19
 
8
20
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "license": "MIT",
5
5
  "repository": "vtex/faststore",
6
6
  "browserslist": "supports es6-module and not dead",
@@ -128,5 +128,5 @@
128
128
  "node": "18.19.0",
129
129
  "yarn": "1.19.1"
130
130
  },
131
- "gitHead": "f3cbb155a5cd6ecf7b48bc2eb7b24e83f6125c7b"
131
+ "gitHead": "d2987773691eb3c5a958d59b769fc6ba2847909a"
132
132
  }
@@ -9,6 +9,7 @@ import { ProductCardProps } from '../ProductCard'
9
9
  import { memo } from 'react'
10
10
  import ViewportObserver from 'src/components/cms/ViewportObserver'
11
11
  import { useOverrideComponents } from 'src/sdk/overrides/OverrideContext'
12
+ import useScreenResize from 'src/sdk/ui/useScreenResize'
12
13
 
13
14
  interface Props {
14
15
  /**
@@ -45,12 +46,12 @@ function ProductGrid({
45
46
  } = {},
46
47
  firstPage,
47
48
  }: Props) {
49
+ const { isMobile } = useScreenResize()
48
50
  const { __experimentalProductCard: ProductCard } =
49
51
  useOverrideComponents<'ProductGallery'>()
50
- const aspectRatio = 1
51
52
 
52
- // TODO: Check if is also isMobile
53
- const isFirstPage = firstPage === page
53
+ const aspectRatio = 1
54
+ const isGridWithViewportObserver = isMobile && firstPage === page
54
55
 
55
56
  return (
56
57
  <ProductGridSkeleton
@@ -58,7 +59,7 @@ function ProductGrid({
58
59
  loading={products.length === 0}
59
60
  >
60
61
  <UIProductGrid>
61
- {isFirstPage ? (
62
+ {isGridWithViewportObserver ? (
62
63
  <>
63
64
  {products.slice(0, 2).map(({ node: product }, idx) => (
64
65
  <UIProductGridItem key={`${product.id}`}>
@@ -28,13 +28,12 @@ function ProductGalleryPage({
28
28
  const products = data?.search?.products?.edges ?? []
29
29
 
30
30
  return (
31
- <>
32
- <Sentinel
33
- products={products}
34
- page={page}
35
- pageSize={itemsPerPage}
36
- title={title}
37
- />
31
+ <Sentinel
32
+ products={products}
33
+ page={page}
34
+ pageSize={itemsPerPage}
35
+ title={title}
36
+ >
38
37
  <ProductGrid
39
38
  products={products}
40
39
  page={page}
@@ -42,7 +41,7 @@ function ProductGalleryPage({
42
41
  productCard={productCard}
43
42
  firstPage={firstPage}
44
43
  />
45
- </>
44
+ </Sentinel>
46
45
  )
47
46
  }
48
47
 
@@ -19,11 +19,7 @@ export const usePageViewEvent = () => {
19
19
  const router = useRouter()
20
20
 
21
21
  useEffect(() => {
22
- router.events.on('routeChangeComplete', sendPageViewEvent)
23
-
24
- return () => {
25
- router.events.off('routeChangeComplete', sendPageViewEvent)
26
- }
22
+ sendPageViewEvent()
27
23
  }, [router, sendPageViewEvent])
28
24
 
29
25
  return { sendPageViewEvent }
@@ -1,14 +1,15 @@
1
1
  import { useSearch } from '@faststore/sdk'
2
- import { useEffect, useRef } from 'react'
2
+ import { useEffect, useRef, type PropsWithChildren } from 'react'
3
3
  import { useInView } from 'react-intersection-observer'
4
4
  import type { NextRouter } from 'next/router'
5
5
  import { useRouter } from 'next/router'
6
6
 
7
7
  import type { ProductSummary_ProductFragment } from '@generated/graphql'
8
8
 
9
+ import useScreenResize from 'src/sdk/ui/useScreenResize'
9
10
  import { useViewItemListEvent } from '../analytics/hooks/useViewItemListEvent'
10
11
 
11
- interface Props {
12
+ interface SentinelProps {
12
13
  page: number
13
14
  pageSize: number
14
15
  title: string
@@ -38,19 +39,24 @@ const replacePagination = (page: string, router: NextRouter) => {
38
39
  * Also, this component's name is kind of curious. Wikipedia calls is Page Break(https://en.wikipedia.org/wiki/Page_break)
39
40
  * however all codes I've seen online use Sentinel
40
41
  */
41
- function Sentinel({ page, pageSize, products, title }: Props) {
42
- const viewedRef = useRef(false)
43
- const { ref, inView } = useInView()
44
- const { pages } = useSearch()
45
-
42
+ function Sentinel({
43
+ page,
44
+ pageSize,
45
+ products,
46
+ title,
47
+ children,
48
+ }: PropsWithChildren<SentinelProps>) {
46
49
  const router = useRouter()
47
-
50
+ const { pages } = useSearch()
51
+ const { isMobile } = useScreenResize()
52
+ const { ref, inView } = useInView({ threshold: isMobile ? 0.3 : 0.7 })
48
53
  const { sendViewItemListEvent } = useViewItemListEvent({
49
54
  products,
50
55
  title,
51
56
  page,
52
57
  pageSize,
53
58
  })
59
+ const viewedRef = useRef(false)
54
60
 
55
61
  useEffect(() => {
56
62
  // Only replace pagination state when infinite scroll
@@ -72,7 +78,7 @@ function Sentinel({ page, pageSize, products, title }: Props) {
72
78
  products.length,
73
79
  ])
74
80
 
75
- return <div ref={ref} />
81
+ return <div ref={ref}>{children}</div>
76
82
  }
77
83
 
78
84
  export default Sentinel