@akinon/next 2.0.22-beta.0 → 2.0.22
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 +2 -2
- package/lib/cache.ts +5 -25
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
-
## 2.0.22
|
|
3
|
+
## 2.0.22
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- 4ce6928: ZERO-4493: Revert URLSearchParams CacheKey normalization. The helper was shipped on the hypothesis that the PCardin product detail variant bug was caused by JSON.stringify on URLSearchParams collapsing every variant onto one cache entry, but bumping the brand to the helper version did not resolve the bug — the real root cause is elsewhere. Rolling back the change to keep the surface clean while the actual fix is investigated.
|
|
8
8
|
|
|
9
9
|
## 2.0.21
|
|
10
10
|
|
package/lib/cache.ts
CHANGED
|
@@ -77,29 +77,9 @@ const hashCacheKey = (object?: Record<string, string>) => {
|
|
|
77
77
|
|
|
78
78
|
return `_${encodeURIComponent(cacheKey)}`;
|
|
79
79
|
};
|
|
80
|
-
|
|
81
|
-
// JSON.stringify on a URLSearchParams instance always returns "{}" because its
|
|
82
|
-
// entries live on the prototype, not as own enumerable properties. withSegmentDefaults
|
|
83
|
-
// normalizes Next 16's plain searchParams object into a URLSearchParams instance for
|
|
84
|
-
// v1 brand compatibility, which means every CacheKey below that took JSON.stringify
|
|
85
|
-
// of searchParams was collapsing every variant of a route onto a single cache entry —
|
|
86
|
-
// product detail variant changes served stale data and the add-to-cart button stuck
|
|
87
|
-
// in its loading state. Convert URLSearchParams to a plain object before serializing
|
|
88
|
-
// so the resulting key reflects the actual params.
|
|
89
|
-
const stringifySearchParams = (searchParams?: SearchParams) => {
|
|
90
|
-
if (!searchParams) return JSON.stringify(searchParams);
|
|
91
|
-
if (
|
|
92
|
-
typeof URLSearchParams !== 'undefined' &&
|
|
93
|
-
searchParams instanceof URLSearchParams
|
|
94
|
-
) {
|
|
95
|
-
return JSON.stringify(Object.fromEntries(searchParams));
|
|
96
|
-
}
|
|
97
|
-
return JSON.stringify(searchParams);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
80
|
export const CacheKey = {
|
|
101
81
|
List: (searchParams: SearchParams, headers?: Record<string, string>) =>
|
|
102
|
-
`list_${encodeURIComponent(
|
|
82
|
+
`list_${encodeURIComponent(JSON.stringify(searchParams))}${hashCacheKey(
|
|
103
83
|
headers
|
|
104
84
|
)}`,
|
|
105
85
|
Category: (
|
|
@@ -108,7 +88,7 @@ export const CacheKey = {
|
|
|
108
88
|
headers?: Record<string, string>
|
|
109
89
|
) =>
|
|
110
90
|
`category_${pk}_${encodeURIComponent(
|
|
111
|
-
|
|
91
|
+
JSON.stringify(searchParams)
|
|
112
92
|
)}${hashCacheKey(headers)}`,
|
|
113
93
|
Basket: (namespace?: string) => `basket${namespace ? `_${namespace}` : ''}`,
|
|
114
94
|
AllBaskets: () => 'all_baskets',
|
|
@@ -119,12 +99,12 @@ export const CacheKey = {
|
|
|
119
99
|
headers?: Record<string, string>
|
|
120
100
|
) =>
|
|
121
101
|
`special_page_${pk}_${encodeURIComponent(
|
|
122
|
-
|
|
102
|
+
JSON.stringify(searchParams)
|
|
123
103
|
)}${hashCacheKey(headers)}`,
|
|
124
104
|
Product: (pk: number, searchParams: SearchParams) =>
|
|
125
|
-
`product_${pk}_${encodeURIComponent(
|
|
105
|
+
`product_${pk}_${encodeURIComponent(JSON.stringify(searchParams))}`,
|
|
126
106
|
GroupProduct: (pk: number, searchParams: SearchParams) =>
|
|
127
|
-
`group_product_${pk}_${encodeURIComponent(
|
|
107
|
+
`group_product_${pk}_${encodeURIComponent(JSON.stringify(searchParams))}`,
|
|
128
108
|
FlatPage: (pk: number) => `flat_page_${pk}`,
|
|
129
109
|
LandingPage: (pk: number) => `landing_page_${pk}`,
|
|
130
110
|
Widget: (slug: string) => `widget_${slug}`,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akinon/next",
|
|
3
3
|
"description": "Core package for Project Zero Next",
|
|
4
|
-
"version": "2.0.22
|
|
4
|
+
"version": "2.0.22",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"set-cookie-parser": "2.6.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@akinon/eslint-plugin-projectzero": "2.0.22
|
|
39
|
+
"@akinon/eslint-plugin-projectzero": "2.0.22",
|
|
40
40
|
"@babel/core": "7.26.10",
|
|
41
41
|
"@babel/preset-env": "7.26.9",
|
|
42
42
|
"@babel/preset-typescript": "7.27.0",
|