@faststore/core 3.98.0-dev.5 → 3.98.0-dev.7
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 +41 -41
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- 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/prerender-manifest.js +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/react-loadable-manifest.json +31 -27
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/2336.js +6 -0
- package/.next/server/chunks/3890.js +11 -11
- package/.next/server/chunks/7098.js +1 -1
- package/.next/server/chunks/948.js +2 -2
- package/.next/server/functions-config-manifest.json +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.js +1 -1
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.js +1 -1
- package/.next/server/pages/500.js.nft.json +1 -1
- package/.next/server/pages/[...slug].js +1 -1
- package/.next/server/pages/[...slug].js.nft.json +1 -1
- package/.next/server/pages/[slug]/p.js +1 -1
- package/.next/server/pages/[slug]/p.js.nft.json +1 -1
- package/.next/server/pages/_app.js +1 -1
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_document.js.nft.json +1 -1
- package/.next/server/pages/_error.js +1 -1
- package/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/server/pages/api/fs/logout.js.nft.json +1 -1
- package/.next/server/pages/api/graphql.js.nft.json +1 -1
- package/.next/server/pages/api/health/live.js.nft.json +1 -1
- package/.next/server/pages/api/health/ready.js.nft.json +1 -1
- package/.next/server/pages/api/preview.js.nft.json +1 -1
- package/.next/server/pages/checkout.js +1 -1
- package/.next/server/pages/checkout.js.nft.json +1 -1
- package/.next/server/pages/en-US/404.html +2 -2
- package/.next/server/pages/en-US/404.json +1 -1
- package/.next/server/pages/en-US/500.html +2 -2
- package/.next/server/pages/en-US/500.json +1 -1
- package/.next/server/pages/en-US/checkout.html +2 -2
- package/.next/server/pages/en-US/checkout.json +1 -1
- package/.next/server/pages/en-US/login.html +2 -2
- package/.next/server/pages/en-US/login.json +1 -1
- package/.next/server/pages/en-US/s.html +2 -2
- package/.next/server/pages/en-US/s.json +1 -1
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/en-US.json +1 -1
- package/.next/server/pages/index.js +1 -1
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/login.js +1 -1
- package/.next/server/pages/login.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/403.js +1 -1
- package/.next/server/pages/pvt/account/403.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/404.js +1 -1
- package/.next/server/pages/pvt/account/404.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/[...unknown].js +1 -1
- package/.next/server/pages/pvt/account/[...unknown].js.nft.json +1 -1
- package/.next/server/pages/pvt/account/orders/[id].js +1 -1
- package/.next/server/pages/pvt/account/orders/[id].js.nft.json +1 -1
- package/.next/server/pages/pvt/account/orders.js +1 -1
- package/.next/server/pages/pvt/account/orders.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/profile.js +1 -1
- package/.next/server/pages/pvt/account/profile.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/security.js +1 -1
- package/.next/server/pages/pvt/account/security.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/user-details.js +1 -1
- package/.next/server/pages/pvt/account/user-details.js.nft.json +1 -1
- package/.next/server/pages/pvt/account.js +1 -1
- package/.next/server/pages/pvt/account.js.nft.json +1 -1
- package/.next/server/pages/s.js +1 -1
- package/.next/server/pages/s.js.nft.json +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/server/webpack-runtime.js +1 -1
- package/.next/static/{_z3BqQGl9pxQ05QAjq4G2 → 3YyETsM_ICzJh8iCbl24o}/_buildManifest.js +1 -1
- package/.next/static/chunks/{1841.a1b15f2c88e02d32.js → 1841.b3a98a2a1886b09c.js} +1 -1
- package/.next/static/chunks/{2927.23bae2c79f0ac0f3.js → 2927.5a79877943a6bf7c.js} +1 -1
- package/.next/static/chunks/{6393.e4b26fee060438d6.js → 6393.fc3a7002110b07a9.js} +1 -1
- package/.next/static/chunks/{7191-4bf7ddfc2bd0f3a9.js → 7191-91a7e2902cbb78eb.js} +1 -1
- package/.next/static/chunks/9173-004874438ae65e64.js +1 -0
- package/.next/static/chunks/{9399.48251a278809f7d3.js → 9399.eb5fc80e2649be72.js} +1 -1
- package/.next/static/chunks/ShoppingAssistant.ba191eb4dbed67e5.js +1 -0
- package/.next/static/chunks/{UIToast.de15325248043ce5.js → UIToast.19a8664c01a00d3a.js} +1 -1
- package/.next/static/chunks/pages/[slug]/{p-0901bccd311c7775.js → p-15e4c70dcf969e68.js} +1 -1
- package/.next/static/chunks/pages/_app-9709623009fd94a5.js +1 -0
- package/.next/static/chunks/pages/pvt/account/orders/{[id]-e03ebb0393ac92a2.js → [id]-46c461739ff3b436.js} +1 -1
- package/.next/static/chunks/webpack-c56d30359092c45c.js +1 -0
- package/.next/static/css/f16438bcf4508fb3.css +1 -0
- package/.next/trace +141 -140
- package/.turbo/turbo-build.log +26 -26
- package/.turbo/turbo-test.log +6 -6
- package/CHANGELOG.md +10 -0
- package/cms/faststore/sections.json +3 -3
- package/package.json +3 -2
- package/src/components/ThirdPartyScripts/index.ts +1 -1
- package/src/components/ThirdPartyScripts/{useWebchatScript.tsx → useShoppingAssistant.tsx} +5 -5
- package/src/components/account/MyAccountDrawer/OrganizationDrawer/OrganizationDrawer.tsx +27 -18
- package/src/components/account/MyAccountDrawer/OrganizationDrawer/useReloadAfterLogoutReturn.ts +75 -0
- package/src/components/cms/global/Components.ts +5 -3
- package/src/components/sections/ShoppingAssistant/ShoppingAssistant.tsx +24 -0
- package/src/components/sections/ShoppingAssistant/index.ts +1 -0
- package/src/pages/_app.tsx +2 -0
- package/src/sdk/graphql/request.ts +1 -1
- package/src/sdk/graphql/useQuery.ts +23 -6
- package/src/utils/cookieCacheBusting.ts +35 -41
- package/test/utils/cookieCacheBusting.test.ts +54 -47
- package/.next/server/chunks/772.js +0 -6
- package/.next/static/chunks/9173-03cb4807f10c57e8.js +0 -1
- package/.next/static/chunks/Webchat.e410860c49bcba26.js +0 -1
- package/.next/static/chunks/pages/_app-eae02e7ad5c9db46.js +0 -1
- package/.next/static/chunks/webpack-f021535669f6ed5e.js +0 -1
- package/.next/static/css/bdff52aea05613d4.css +0 -1
- package/src/components/sections/Webchat/Webchat.tsx +0 -22
- package/src/components/sections/Webchat/index.ts +0 -1
- /package/.next/static/{_z3BqQGl9pxQ05QAjq4G2 → 3YyETsM_ICzJh8iCbl24o}/_ssgManifest.js +0 -0
- /package/src/components/sections/{Webchat → ShoppingAssistant}/section.module.scss +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @faststore/core@3.98.0-dev.
|
|
2
|
+
> @faststore/core@3.98.0-dev.6 prebuild /home/runner/work/faststore/faststore/packages/core
|
|
3
3
|
> na run partytown && na run generate
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @faststore/core@3.98.0-dev.
|
|
6
|
+
> @faststore/core@3.98.0-dev.6 partytown /home/runner/work/faststore/faststore/packages/core
|
|
7
7
|
> partytown copylib ./public/~partytown
|
|
8
8
|
|
|
9
9
|
Partytown lib copied to: /home/runner/work/faststore/faststore/packages/core/public/~partytown
|
|
10
10
|
|
|
11
|
-
> @faststore/core@3.98.0-dev.
|
|
11
|
+
> @faststore/core@3.98.0-dev.6 generate /home/runner/work/faststore/faststore/packages/core
|
|
12
12
|
> na run generate:schema && na run generate:codegen && na run format:generated
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
> @faststore/core@3.98.0-dev.
|
|
15
|
+
> @faststore/core@3.98.0-dev.6 generate:schema /home/runner/work/faststore/faststore/packages/core
|
|
16
16
|
> tsx src/server/generator/generateGraphQLSchemaFile.ts
|
|
17
17
|
|
|
18
18
|
Schema GraphQL file generated successfully
|
|
19
19
|
|
|
20
|
-
> @faststore/core@3.98.0-dev.
|
|
20
|
+
> @faststore/core@3.98.0-dev.6 generate:codegen /home/runner/work/faststore/faststore/packages/core
|
|
21
21
|
> graphql-codegen
|
|
22
22
|
|
|
23
23
|
[STARTED] Parse Configuration
|
|
@@ -37,11 +37,11 @@ Running lifecycle hook "afterStart" scripts...
|
|
|
37
37
|
[CLI] Loading Documents
|
|
38
38
|
[CLI] Generating output
|
|
39
39
|
|
|
40
|
-
> @faststore/core@3.98.0-dev.
|
|
40
|
+
> @faststore/core@3.98.0-dev.6 format:generated /home/runner/work/faststore/faststore/packages/core
|
|
41
41
|
> prettier --write "@generated/**/*.{ts,js,tsx,jsx,json}" --loglevel error
|
|
42
42
|
|
|
43
43
|
|
|
44
|
-
> @faststore/core@3.98.0-dev.
|
|
44
|
+
> @faststore/core@3.98.0-dev.6 build /home/runner/work/faststore/faststore/packages/core
|
|
45
45
|
> next build
|
|
46
46
|
|
|
47
47
|
⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
|
|
@@ -79,8 +79,8 @@ Import trace for requested module:
|
|
|
79
79
|
|
|
80
80
|
Collecting page data ...
|
|
81
81
|
Generating static pages (0/6) ...
|
|
82
|
-
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.
|
|
83
82
|
|
|
84
83
|
Generating static pages (1/6)
|
|
84
|
+
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.
|
|
85
85
|
|
|
86
86
|
Generating static pages (2/6)
|
|
87
87
|
|
|
88
88
|
Generating static pages (4/6)
|
|
89
89
|
|
|
90
90
|
✓ Generating static pages (6/6)
|
|
@@ -88,43 +88,43 @@ Warning: Dynamic Content not found for the page: home. Refer to the Dynamic Cont
|
|
|
88
88
|
Collecting build traces ...
|
|
89
89
|
|
|
90
90
|
Route (pages) Size First Load JS
|
|
91
|
-
┌ ● / 7.39 kB
|
|
91
|
+
┌ ● / 7.39 kB 148 kB
|
|
92
92
|
├ └ css/02259c549b2179f2.css 3.1 kB
|
|
93
93
|
├ /_app 0 B 108 kB
|
|
94
|
-
├ ● /[...slug] 2.56 kB
|
|
94
|
+
├ ● /[...slug] 2.56 kB 158 kB
|
|
95
95
|
├ ● /[slug]/p 98.2 kB 238 kB
|
|
96
96
|
├ └ css/a6a4ebbe01adbbad.css 22.2 kB
|
|
97
|
-
├ ○ /404 1.57 kB
|
|
98
|
-
├ ● /500 1.57 kB
|
|
97
|
+
├ ○ /404 1.57 kB 142 kB
|
|
98
|
+
├ ● /500 1.57 kB 142 kB
|
|
99
99
|
├ λ /api/fs/logout 0 B 108 kB
|
|
100
100
|
├ λ /api/graphql 0 B 108 kB
|
|
101
101
|
├ λ /api/health/live 0 B 108 kB
|
|
102
102
|
├ λ /api/health/ready 0 B 108 kB
|
|
103
103
|
├ λ /api/preview 0 B 108 kB
|
|
104
|
-
├ ● /checkout 749 B
|
|
105
|
-
├ ● /login 1.7 kB
|
|
106
|
-
├ λ /pvt/account 247 B
|
|
107
|
-
├ ● /pvt/account/[...unknown] 287 B
|
|
108
|
-
├ λ /pvt/account/403 2.98 kB
|
|
104
|
+
├ ● /checkout 749 B 141 kB
|
|
105
|
+
├ ● /login 1.7 kB 142 kB
|
|
106
|
+
├ λ /pvt/account 247 B 109 kB
|
|
107
|
+
├ ● /pvt/account/[...unknown] 287 B 109 kB
|
|
108
|
+
├ λ /pvt/account/403 2.98 kB 143 kB
|
|
109
109
|
├ └ css/0fae3d432331aae9.css 4.68 kB
|
|
110
110
|
├ λ /pvt/account/404 2.18 kB 142 kB
|
|
111
111
|
├ └ css/0fc6b2ff69142c6a.css 4.74 kB
|
|
112
|
-
├ λ /pvt/account/orders 9.78 kB
|
|
112
|
+
├ λ /pvt/account/orders 9.78 kB 150 kB
|
|
113
113
|
├ └ css/40a294d0a24ad01d.css 14.1 kB
|
|
114
|
-
├ λ /pvt/account/orders/[id] 13.7 kB
|
|
114
|
+
├ λ /pvt/account/orders/[id] 13.7 kB 154 kB
|
|
115
115
|
├ └ css/08d03445f1797608.css 13.8 kB
|
|
116
|
-
├ λ /pvt/account/profile 1.98 kB
|
|
116
|
+
├ λ /pvt/account/profile 1.98 kB 142 kB
|
|
117
117
|
├ └ css/47f1b4e8de15d314.css 4.42 kB
|
|
118
|
-
├ λ /pvt/account/security 3.96 kB
|
|
118
|
+
├ λ /pvt/account/security 3.96 kB 144 kB
|
|
119
119
|
├ └ css/973dd40d4773e8cd.css 5.74 kB
|
|
120
|
-
├ λ /pvt/account/user-details 1.91 kB
|
|
120
|
+
├ λ /pvt/account/user-details 1.91 kB 142 kB
|
|
121
121
|
├ └ css/05c399956ff24b77.css 4.54 kB
|
|
122
|
-
└ ● /s 3.36 kB
|
|
123
|
-
+ First Load JS shared by all
|
|
122
|
+
└ ● /s 3.36 kB 159 kB
|
|
123
|
+
+ First Load JS shared by all 112 kB
|
|
124
124
|
├ chunks/framework-d514426edf885c68.js 45.4 kB
|
|
125
125
|
├ chunks/main-ec03882c4375091d.js 33.2 kB
|
|
126
|
-
├ chunks/pages/_app-
|
|
127
|
-
├ chunks/webpack-
|
|
126
|
+
├ chunks/pages/_app-9709623009fd94a5.js 25.8 kB
|
|
127
|
+
├ chunks/webpack-c56d30359092c45c.js 3.9 kB
|
|
128
128
|
└ css/0f070d03aacd9cc5.css 3.57 kB
|
|
129
129
|
|
|
130
130
|
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
> @faststore/core@3.98.0-dev.
|
|
2
|
+
> @faststore/core@3.98.0-dev.6 test /home/runner/work/faststore/faststore/packages/core
|
|
3
3
|
> jest
|
|
4
4
|
|
|
5
|
-
PASS test/utils/multipleTemplates.test.ts (
|
|
6
|
-
PASS test/utils/clearCookies.test.ts (
|
|
7
|
-
PASS test/server/cms/global.test.ts
|
|
5
|
+
PASS test/utils/multipleTemplates.test.ts (27.088 s)
|
|
6
|
+
PASS test/utils/clearCookies.test.ts (27.484 s)
|
|
8
7
|
PASS test/utils/cookieCacheBusting.test.ts
|
|
8
|
+
PASS test/server/cms/global.test.ts
|
|
9
9
|
PASS test/server/cms/index.test.ts
|
|
10
|
-
PASS test/server/index.test.ts (
|
|
10
|
+
PASS test/server/index.test.ts (31.032 s)
|
|
11
11
|
|
|
12
12
|
Test Suites: 6 passed, 6 total
|
|
13
13
|
Tests: 47 passed, 47 total
|
|
14
14
|
Snapshots: 0 total
|
|
15
|
-
Time:
|
|
15
|
+
Time: 32.089 s
|
|
16
16
|
Ran all test suites.
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
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.98.0-dev.7](https://github.com/vtex/faststore/compare/v3.98.0-dev.6...v3.98.0-dev.7) (2026-03-26)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @faststore/core
|
|
9
|
+
|
|
10
|
+
# [3.98.0-dev.6](https://github.com/vtex/faststore/compare/v3.98.0-dev.5...v3.98.0-dev.6) (2026-03-24)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- enhance cache key management in useQuery ([#3230](https://github.com/vtex/faststore/issues/3230)) ([3f28502](https://github.com/vtex/faststore/commit/3f28502a8d381e476728661ea1150d0777ba87d1))
|
|
15
|
+
|
|
6
16
|
# [3.98.0-dev.5](https://github.com/vtex/faststore/compare/v3.98.0-dev.4...v3.98.0-dev.5) (2026-03-24)
|
|
7
17
|
|
|
8
18
|
### Features
|
|
@@ -2548,11 +2548,11 @@
|
|
|
2548
2548
|
}
|
|
2549
2549
|
},
|
|
2550
2550
|
{
|
|
2551
|
-
"name": "
|
|
2551
|
+
"name": "ShoppingAssistant",
|
|
2552
2552
|
"requiredScopes": [],
|
|
2553
2553
|
"schema": {
|
|
2554
|
-
"title": "
|
|
2555
|
-
"description": "
|
|
2554
|
+
"title": "Shopping Assistant",
|
|
2555
|
+
"description": "To enable Shopping Assistant, make sure you have finished the setup at Agentic CX > Dashboard.",
|
|
2556
2556
|
"type": "object",
|
|
2557
2557
|
"properties": {}
|
|
2558
2558
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "3.98.0-dev.
|
|
3
|
+
"version": "3.98.0-dev.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"fast-deep-equal": "^3.1.3",
|
|
86
86
|
"fs-extra": "^10.1.0",
|
|
87
87
|
"graphql": "^15.6.0",
|
|
88
|
+
"idb-keyval": "^5.1.3",
|
|
88
89
|
"include-media": "^1.4.10",
|
|
89
90
|
"isomorphic-unfetch": "^3.1.0",
|
|
90
91
|
"lexical": "^0.34.0",
|
|
@@ -123,5 +124,5 @@
|
|
|
123
124
|
"ts-jest": "29.1.1",
|
|
124
125
|
"typescript": "5.3.2"
|
|
125
126
|
},
|
|
126
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "e1ba23ab797254f3d2676d75db84b82649dcce87"
|
|
127
128
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default } from './ThirdPartyScripts'
|
|
2
|
-
export {
|
|
2
|
+
export { useShoppingAssistant } from './useShoppingAssistant'
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { RefObject } from 'react'
|
|
2
2
|
import { useEffect } from 'react'
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const SHOPPING_ASSISTANT_SCRIPT_URL = 'https://cdn.cloud.weni.ai/agentic-cx.js'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Injects the
|
|
8
|
-
* @param containerRef - Optional ref to an HTMLElement. When provided, the script is appended inside this container (e.g. inside the
|
|
7
|
+
* Injects the Shopping Assistant script when the hook runs, unless third-party scripts are disabled.
|
|
8
|
+
* @param containerRef - Optional ref to an HTMLElement. When provided, the script is appended inside this container (e.g. inside the ShoppingAssistant section). Otherwise the script is appended to document.head.
|
|
9
9
|
* Must be used in a component rendered in the body (not inside Next.js Head) so that useEffect runs on the client.
|
|
10
10
|
*/
|
|
11
|
-
export function
|
|
11
|
+
export function useShoppingAssistant(
|
|
12
12
|
containerRef?: RefObject<HTMLElement | null>
|
|
13
13
|
): void {
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
if (process.env.DISABLE_3P_SCRIPTS) return
|
|
16
16
|
|
|
17
17
|
const script = document.createElement('script')
|
|
18
|
-
script.src =
|
|
18
|
+
script.src = SHOPPING_ASSISTANT_SCRIPT_URL
|
|
19
19
|
const container = containerRef?.current
|
|
20
20
|
if (container) {
|
|
21
21
|
container.appendChild(script)
|
|
@@ -11,6 +11,7 @@ import storeConfig from '../../../../../discovery.config'
|
|
|
11
11
|
import { ProfileSummary } from '../ProfileSummary/ProfileSummary'
|
|
12
12
|
import { OrganizationDrawerBody } from './OrganizationDrawerBody'
|
|
13
13
|
import { OrganizationDrawerHeader } from './OrganizationDrawerHeader'
|
|
14
|
+
import { setReloadAfterLogoutReturn } from './useReloadAfterLogoutReturn'
|
|
14
15
|
import styles from './section.module.scss'
|
|
15
16
|
|
|
16
17
|
type OrganizationDrawerProps = {
|
|
@@ -27,6 +28,7 @@ const clearBrowserStorageForCurrentDomain = async () => {
|
|
|
27
28
|
const sessionStorageKeys = [
|
|
28
29
|
'faststore_session_ready',
|
|
29
30
|
'faststore_auth_cookie_value',
|
|
31
|
+
'faststore_person_id',
|
|
30
32
|
'faststore_cache_bust_last_value',
|
|
31
33
|
]
|
|
32
34
|
|
|
@@ -53,6 +55,25 @@ const clearBrowserStorageForCurrentDomain = async () => {
|
|
|
53
55
|
} catch {}
|
|
54
56
|
} catch {}
|
|
55
57
|
|
|
58
|
+
// Clear IndexedDB: remove session key first (avoids blocked when DB has open connections),
|
|
59
|
+
// then delete the whole keyval-store
|
|
60
|
+
try {
|
|
61
|
+
if ('indexedDB' in window) {
|
|
62
|
+
const { del } = await import('idb-keyval')
|
|
63
|
+
await del('fs::session').catch(() => {})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const idb = window.indexedDB
|
|
67
|
+
if (idb) {
|
|
68
|
+
await new Promise<void>((resolve) => {
|
|
69
|
+
const req = idb.deleteDatabase('keyval-store')
|
|
70
|
+
req.onsuccess = () => resolve()
|
|
71
|
+
req.onerror = () => resolve()
|
|
72
|
+
req.onblocked = () => resolve()
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
} catch {}
|
|
76
|
+
|
|
56
77
|
// Clear all cookies containing 'vtex' in the name (case-insensitive)
|
|
57
78
|
try {
|
|
58
79
|
const hostname = window.location.hostname
|
|
@@ -80,21 +101,6 @@ const clearBrowserStorageForCurrentDomain = async () => {
|
|
|
80
101
|
}
|
|
81
102
|
}
|
|
82
103
|
} catch {}
|
|
83
|
-
|
|
84
|
-
// Clear IndexedDB (keyval-store)
|
|
85
|
-
try {
|
|
86
|
-
if (!('indexedDB' in window)) return
|
|
87
|
-
|
|
88
|
-
const idb = window.indexedDB
|
|
89
|
-
if (!idb) return
|
|
90
|
-
|
|
91
|
-
await new Promise<void>((resolve) => {
|
|
92
|
-
const req = idb.deleteDatabase('keyval-store')
|
|
93
|
-
req.onsuccess = () => resolve()
|
|
94
|
-
req.onerror = () => resolve()
|
|
95
|
-
req.onblocked = () => resolve()
|
|
96
|
-
})
|
|
97
|
-
} catch {}
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
export const doLogout = async (_event?: unknown) => {
|
|
@@ -104,16 +110,19 @@ export const doLogout = async (_event?: unknown) => {
|
|
|
104
110
|
// Clear client-side storage (sessionStorage, localStorage, IndexedDB, non-HttpOnly cookies)
|
|
105
111
|
await clearBrowserStorageForCurrentDomain()
|
|
106
112
|
|
|
107
|
-
// Clear HttpOnly cookies via API endpoint (server-side)
|
|
113
|
+
// Clear HttpOnly cookies via API endpoint (server-side).
|
|
114
|
+
// Must await and consume the response so Set-Cookie headers are fully processed before redirect.
|
|
108
115
|
try {
|
|
109
|
-
await fetch('/api/fs/logout', {
|
|
116
|
+
const res = await fetch('/api/fs/logout', {
|
|
110
117
|
method: 'POST',
|
|
111
118
|
credentials: 'include',
|
|
112
119
|
})
|
|
120
|
+
await res.json().catch((): null => null)
|
|
113
121
|
} catch {
|
|
114
|
-
// Continue even if API call fails
|
|
122
|
+
// Continue even if API call fails (e.g. network error)
|
|
115
123
|
}
|
|
116
124
|
} finally {
|
|
125
|
+
setReloadAfterLogoutReturn()
|
|
117
126
|
window.location.assign(
|
|
118
127
|
`${storeConfig.secureSubdomain}/api/vtexid/pub/logout?scope=${storeConfig.api.storeId}&returnUrl=${storeConfig.storeUrl}`
|
|
119
128
|
)
|
package/src/components/account/MyAccountDrawer/OrganizationDrawer/useReloadAfterLogoutReturn.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* When the user logs out from the OrganizationDrawer, we redirect to VTEX ID logout
|
|
5
|
+
* and then return to the store. We need to reload so session-dependent data
|
|
6
|
+
* (e.g. ProductShelf) and caches are fresh. This module ties that reload to the drawer flow.
|
|
7
|
+
*
|
|
8
|
+
* The return can happen in two ways:
|
|
9
|
+
* 1) bfcache restore: user hits Back or browser restores from cache → pageshow with persisted=true
|
|
10
|
+
* 2) Fresh load: VTEX ID redirects back → new navigation, persisted=false
|
|
11
|
+
*
|
|
12
|
+
* We handle both: check the flag on mount (fresh load) and on pageshow (bfcache).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const RELOAD_AFTER_LOGOUT_KEY = 'faststore_reload_after_logout_return'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Call before redirecting to logout. When the user returns to the store, the app
|
|
19
|
+
* will reload once so session state and caches are fresh.
|
|
20
|
+
*/
|
|
21
|
+
export const setReloadAfterLogoutReturn = (): void => {
|
|
22
|
+
if (typeof sessionStorage === 'undefined') return
|
|
23
|
+
try {
|
|
24
|
+
sessionStorage.setItem(RELOAD_AFTER_LOGOUT_KEY, '1')
|
|
25
|
+
} catch {
|
|
26
|
+
// Ignore
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const RELOAD_DELAY_MS = 1000
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Forces a full navigation with cache-busting param instead of reload().
|
|
34
|
+
* Bypasses disk cache by changing the URL, ensuring fresh HTML and API responses.
|
|
35
|
+
*/
|
|
36
|
+
const forceRefreshWithoutCache = (): void => {
|
|
37
|
+
const url = new URL(window.location.href)
|
|
38
|
+
url.searchParams.set('_', Date.now().toString())
|
|
39
|
+
window.location.replace(url.toString())
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const checkAndReloadIfReturnedFromLogout = (): void => {
|
|
43
|
+
try {
|
|
44
|
+
if (sessionStorage.getItem(RELOAD_AFTER_LOGOUT_KEY)) {
|
|
45
|
+
sessionStorage.removeItem(RELOAD_AFTER_LOGOUT_KEY)
|
|
46
|
+
setTimeout(forceRefreshWithoutCache, RELOAD_DELAY_MS)
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
// Ignore.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Hook to use in _app. Ensures a full reload when the user returns from logout
|
|
55
|
+
* (either via bfcache or fresh redirect), so data matches the new session.
|
|
56
|
+
*/
|
|
57
|
+
export const useReloadAfterLogoutReturn = (): void => {
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (typeof window === 'undefined') return
|
|
60
|
+
|
|
61
|
+
// 1) On mount: handles fresh load return (VTEX ID redirect). pageshow with persisted=false
|
|
62
|
+
// means we never get the event for that case, so we must check here.
|
|
63
|
+
checkAndReloadIfReturnedFromLogout()
|
|
64
|
+
|
|
65
|
+
// 2) On pageshow with persisted: handles bfcache restore
|
|
66
|
+
const onPageShow = (event: PageTransitionEvent) => {
|
|
67
|
+
if (event.persisted) {
|
|
68
|
+
checkAndReloadIfReturnedFromLogout()
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
window.addEventListener('pageshow', onPageShow)
|
|
73
|
+
return () => window.removeEventListener('pageshow', onPageShow)
|
|
74
|
+
}, [])
|
|
75
|
+
}
|
|
@@ -36,9 +36,11 @@ const RegionSlider = dynamic(
|
|
|
36
36
|
),
|
|
37
37
|
{ ssr: false }
|
|
38
38
|
)
|
|
39
|
-
const
|
|
39
|
+
const ShoppingAssistant = dynamic(
|
|
40
40
|
() =>
|
|
41
|
-
import(
|
|
41
|
+
import(
|
|
42
|
+
/* webpackChunkName: "ShoppingAssistant" */ 'src/components/sections/ShoppingAssistant'
|
|
43
|
+
),
|
|
42
44
|
{ ssr: false }
|
|
43
45
|
)
|
|
44
46
|
|
|
@@ -51,7 +53,7 @@ const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
|
51
53
|
[getComponentKey(RegionModal, 'RegionModal')]: RegionModal, // out of viewport
|
|
52
54
|
[getComponentKey(RegionSlider, 'RegionSlider')]: RegionSlider, // out of viewport
|
|
53
55
|
[getComponentKey(Footer, 'Footer')]: Footer, // out of viewport
|
|
54
|
-
[getComponentKey(
|
|
56
|
+
[getComponentKey(ShoppingAssistant, 'ShoppingAssistant')]: ShoppingAssistant,
|
|
55
57
|
...PLUGINS_COMPONENTS,
|
|
56
58
|
...CUSTOM_COMPONENTS,
|
|
57
59
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { useShoppingAssistant } from 'src/components/ThirdPartyScripts'
|
|
4
|
+
|
|
5
|
+
import Section from '../Section'
|
|
6
|
+
|
|
7
|
+
import styles from './section.module.scss'
|
|
8
|
+
|
|
9
|
+
const ShoppingAssistant = () => {
|
|
10
|
+
const scriptContainerRef = useRef<HTMLDivElement>(null)
|
|
11
|
+
useShoppingAssistant(scriptContainerRef)
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Section
|
|
15
|
+
className={`${styles.section} section-shopping-assistant layout__section`}
|
|
16
|
+
>
|
|
17
|
+
<div ref={scriptContainerRef} aria-hidden="true" hidden />
|
|
18
|
+
</Section>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
ShoppingAssistant.$componentKey = 'ShoppingAssistant'
|
|
23
|
+
|
|
24
|
+
export default ShoppingAssistant
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ShoppingAssistant'
|
package/src/pages/_app.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import { useRouter } from 'next/router'
|
|
|
6
6
|
import { useSearch } from '@faststore/sdk'
|
|
7
7
|
import { UIProvider } from '@faststore/ui'
|
|
8
8
|
|
|
9
|
+
import { useReloadAfterLogoutReturn } from 'src/components/account/MyAccountDrawer/OrganizationDrawer/useReloadAfterLogoutReturn'
|
|
9
10
|
import ThirdPartyScripts from 'src/components/ThirdPartyScripts'
|
|
10
11
|
import Layout from 'src/Layout'
|
|
11
12
|
import AnalyticsHandler from 'src/sdk/analytics'
|
|
@@ -24,6 +25,7 @@ import { ITEMS_PER_PAGE } from 'src/constants'
|
|
|
24
25
|
|
|
25
26
|
function App({ Component, pageProps }: AppProps) {
|
|
26
27
|
useGeolocation()
|
|
28
|
+
useReloadAfterLogoutReturn()
|
|
27
29
|
storeConfig.experimental?.scrollRestoration && useScrollRestoration()
|
|
28
30
|
const router = useRouter()
|
|
29
31
|
const { start: startGlobalSearchState } = useSearch()
|
|
@@ -29,7 +29,7 @@ export const request = async <Query = unknown, Variables = unknown>(
|
|
|
29
29
|
variables: Variables,
|
|
30
30
|
options?: RequestOptions
|
|
31
31
|
) => {
|
|
32
|
-
// Get cache busting value based
|
|
32
|
+
// Get cache busting value based person?.id from session
|
|
33
33
|
const value = getClientCacheBustingValue()
|
|
34
34
|
|
|
35
35
|
const { data, errors } = await baseRequest<Variables, Query>('/api/graphql', {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import useSWR from 'swr'
|
|
2
1
|
import type { SWRConfiguration } from 'swr'
|
|
2
|
+
import useSWR from 'swr'
|
|
3
|
+
|
|
4
|
+
import { getClientCacheBustingValue } from 'src/utils/cookieCacheBusting'
|
|
3
5
|
|
|
4
|
-
import { request } from './request'
|
|
5
6
|
import type { Operation, RequestOptions } from './request'
|
|
7
|
+
import { request } from './request'
|
|
6
8
|
|
|
7
9
|
export type QueryOptions = SWRConfiguration &
|
|
8
10
|
RequestOptions & { doNotRun?: boolean }
|
|
@@ -12,6 +14,19 @@ export const getKey = <Variables>(
|
|
|
12
14
|
variables: Variables
|
|
13
15
|
) => `${operationName}::${JSON.stringify(variables)}`
|
|
14
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Returns a suffix for the cache key based on auth state (logged-in vs anonymous).
|
|
19
|
+
* This ensures SWR keeps separate cache entries for logged-in and logged-out users,
|
|
20
|
+
* avoiding stale product data (e.g. prices, availability) when switching session state.
|
|
21
|
+
*/
|
|
22
|
+
const getSessionCacheKeySuffix = (): string => {
|
|
23
|
+
if (typeof window === 'undefined') {
|
|
24
|
+
return ''
|
|
25
|
+
}
|
|
26
|
+
const value = getClientCacheBustingValue()
|
|
27
|
+
return value ?? ''
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
export const DEFAULT_OPTIONS = {
|
|
16
31
|
errorRetryCount: 3,
|
|
17
32
|
refreshWhenHidden: false,
|
|
@@ -27,10 +42,12 @@ export const useQuery = <Data, Variables = Record<string, unknown>>(
|
|
|
27
42
|
options?: QueryOptions
|
|
28
43
|
) =>
|
|
29
44
|
useSWR<Data>(
|
|
30
|
-
() =>
|
|
31
|
-
options?.doNotRun
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
() => {
|
|
46
|
+
if (options?.doNotRun) return null
|
|
47
|
+
const baseKey = getKey(operation['__meta__']['operationName'], variables)
|
|
48
|
+
const sessionSuffix = getSessionCacheKeySuffix()
|
|
49
|
+
return `${baseKey}::${sessionSuffix}`
|
|
50
|
+
},
|
|
34
51
|
{
|
|
35
52
|
fetcher: () => {
|
|
36
53
|
return new Promise((resolve) => {
|