@akinon/next 1.95.0-snapshot-ZERO-3586-20250901132537 → 1.95.0-snapshot-ZERO-3586-20250901140025

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 CHANGED
@@ -1,10 +1,10 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.95.0-snapshot-ZERO-3586-20250901132537
3
+ ## 1.95.0-snapshot-ZERO-3586-20250901140025
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 5dfeea04a: ZERO-2801: Revert ZERO-2801
7
+ - 5dfeea04: ZERO-2801: Revert ZERO-2801
8
8
  - 823d82f9: ZERO-3393: Enhance error handling in checkout middleware to ensure errors are checked for existence before processing
9
9
  - 412f0e2: ZERO-3586: Enhance caching functionality by adding support for compressed data storage and retrieval, along with a new method for setting multiple key-value pairs.
10
10
  - 28c7ea79: ZERO-3427: Refactor redirect utility to handle undefined URL and improve locale handling
@@ -18,7 +18,7 @@
18
18
  - d8be48fb: ZERO-3422: Update fetch method to use dynamic request method in wallet complete redirection middleware
19
19
  - b55acb76: ZERO-2577: Fix pagination bug and update usePagination hook and ensure pagination controls rendering correctly
20
20
  - f49bb74f: ZERO-3097: Add setCookie to logging in payment redirection middlewares
21
- - 0ad91bb: ZERO-3489: Improve error handling in data fetching across multiple pages and server functions
21
+ - 0ad91bbd: ZERO-3489: Improve error handling in data fetching across multiple pages and server functions
22
22
  - 143be2b9: ZERO-3457: Crop styles are customizable and logic improved for rendering similar products modal
23
23
  - e9541a13d: ZERO-2816: Add headers to url
24
24
  - 9b7d0de6: ZERO-3393: Improve error handling in checkout middleware to support both object and array error formats
@@ -29,7 +29,7 @@
29
29
  - 64699d3ff: ZERO-2761: Fix invalid import for plugin module
30
30
  - 9f8cd3bc: ZERO-3449: AI Search Active Filters & Crop Style changes have been implemented
31
31
  - e974d8e8: ZERO-3406: Fix rc build
32
- - 89ce46f: ZERO-3493: return 404 status code for pz-not-found pages
32
+ - 89ce46fc: ZERO-3493: return 404 status code for pz-not-found pages
33
33
  - 8645d90: ZERO-3574:Refactor redirect tests: streamline mock setup, enhance locale handling, and improve URL path resolution logic
34
34
  - 7eb51ca9: ZERO-3424 :Update package versions
35
35
  - 7727ae55: ZERO-3073: Refactor basket page to use server-side data fetching and simplify component structure
@@ -43,7 +43,7 @@
43
43
  - 4920742c2: Disable getCachedTranslations
44
44
  - b6e5b624: ZERO-3257: Enhance locale middleware to redirect using existing or default locale and support 303 status for POST requests
45
45
  - 0de55738: ZERO-3418: Update remotePatterns hostname to allow all subdomains
46
- - 7e56d6b6b: ZERO-2841: Update api tagTypes
46
+ - 7e56d6b6: ZERO-2841: Update api tagTypes
47
47
  - d99a6a7d: ZERO-3457: Fixed the settings prop and made sure everything is customizable.
48
48
  - 9dc7298a: ZERO-3416: Refactor Accordion component to enhance props and improve styling flexibility
49
49
  - 33377cfd: ZERO-3267: Refactor import statement for ROUTES in error-page component
package/api/cache.ts CHANGED
@@ -38,7 +38,6 @@ async function handleRequest(...args) {
38
38
 
39
39
  try {
40
40
  if (req.method === 'POST') {
41
- // GET request - check if compressed flag is set
42
41
  if (compressed === 'true') {
43
42
  response = await Cache.getCompressed(key);
44
43
  } else {
@@ -64,7 +63,6 @@ async function handleRequest(...args) {
64
63
  );
65
64
  }
66
65
  } else {
67
- // SET request - check if compressed flag is set
68
66
  if (compressed === 'true') {
69
67
  response = await Cache.setCompressed(key, value, expire);
70
68
  } else {
@@ -180,7 +180,7 @@ export const getCategoryBySlugData = async ({
180
180
  getCategoryBySlugDataHandler(slug, locale, currency),
181
181
  {
182
182
  expire: 300,
183
- compressed: true // Compress category data for memory savings
183
+ compressed: true
184
184
  }
185
185
  );
186
186
  };
@@ -2,16 +2,30 @@ import { CacheHandler } from '@neshca/cache-handler';
2
2
  import createLruHandler from '@neshca/cache-handler/local-lru';
3
3
  import createRedisHandler from '@neshca/cache-handler/redis-strings';
4
4
  import { createClient } from 'redis';
5
- import * as zstdWasm from '@bokuweb/zstd-wasm';
6
5
 
7
6
  let zstd;
8
7
 
9
8
  (async () => {
10
9
  try {
11
- await zstdWasm.init();
12
- zstd = zstdWasm;
10
+ const { compress, decompress } = await import('@mongodb-js/zstd');
11
+ zstd = { compress, decompress, type: 'native' };
12
+ console.log(
13
+ '[Cache Handler] ✅ Native @mongodb-js/zstd loaded successfully'
14
+ );
13
15
  } catch (error) {
14
- zstd = false;
16
+ try {
17
+ const zstdWasm = await import('@bokuweb/zstd-wasm');
18
+ await zstdWasm.init();
19
+ zstd = { ...zstdWasm, type: 'wasm' };
20
+ console.log('[Cache Handler] ⚠️ Fallback to WASM @bokuweb/zstd-wasm');
21
+ } catch (wasmError) {
22
+ console.warn(
23
+ '[Cache Handler] ❌ Both native and WASM zstd failed to load:',
24
+ error.message,
25
+ wasmError.message
26
+ );
27
+ zstd = false;
28
+ }
15
29
  }
16
30
  })();
17
31
 
@@ -41,10 +55,22 @@ const compressValue = async (value) => {
41
55
  let compressed;
42
56
 
43
57
  if (zstdLib && zstdLib !== false) {
44
- compressed = zstdLib.compress(
45
- Buffer.from(serializedNestedValue, 'utf8'),
46
- 3
47
- );
58
+ const inputBuffer = Buffer.from(serializedNestedValue, 'utf8');
59
+
60
+ if (
61
+ typeof zstdLib.compress === 'function' &&
62
+ zstdLib.compress.constructor.name === 'AsyncFunction'
63
+ ) {
64
+ compressed = await zstdLib.compress(inputBuffer, 3);
65
+ console.log(
66
+ `[Cache Handler] 🚀 Compressed with native zstd: ${inputBuffer.length} → ${compressed.length} bytes`
67
+ );
68
+ } else {
69
+ compressed = zstdLib.compress(inputBuffer, 3);
70
+ console.log(
71
+ `[Cache Handler] 🌐 Compressed with WASM zstd: ${inputBuffer.length} → ${compressed.length} bytes`
72
+ );
73
+ }
48
74
  } else {
49
75
  return {
50
76
  ...value,
@@ -123,7 +149,22 @@ const compressValue = async (value) => {
123
149
  let compressed;
124
150
 
125
151
  if (zstdLib && zstdLib !== false) {
126
- compressed = zstdLib.compress(Buffer.from(serializedValue, 'utf8'), 3);
152
+ const inputBuffer = Buffer.from(serializedValue, 'utf8');
153
+
154
+ if (
155
+ typeof zstdLib.compress === 'function' &&
156
+ zstdLib.compress.constructor.name === 'AsyncFunction'
157
+ ) {
158
+ compressed = await zstdLib.compress(inputBuffer, 3);
159
+ console.log(
160
+ `[Cache Handler] 🚀 Compressed with native zstd: ${inputBuffer.length} → ${compressed.length} bytes`
161
+ );
162
+ } else {
163
+ compressed = zstdLib.compress(inputBuffer, 3);
164
+ console.log(
165
+ `[Cache Handler] 🌐 Compressed with WASM zstd: ${inputBuffer.length} → ${compressed.length} bytes`
166
+ );
167
+ }
127
168
  } else {
128
169
  if (
129
170
  value &&
@@ -186,14 +227,28 @@ const decompressValue = async (compressedData) => {
186
227
  if (compressedNestedValue.__method === 'zstd') {
187
228
  const zstdLib = getZstd();
188
229
  if (zstdLib && zstdLib !== false) {
189
- decompressed = zstdLib.decompress(compressedBuffer).toString('utf8');
230
+ if (
231
+ typeof zstdLib.decompress === 'function' &&
232
+ zstdLib.decompress.constructor.name === 'AsyncFunction'
233
+ ) {
234
+ const decompressedBuffer = await zstdLib.decompress(
235
+ compressedBuffer
236
+ );
237
+ decompressed = decompressedBuffer.toString('utf8');
238
+ console.log(
239
+ `[Cache Handler] 🚀 Decompressed with native zstd: ${compressedBuffer.length} → ${decompressedBuffer.length} bytes`
240
+ );
241
+ } else {
242
+ decompressed = zstdLib
243
+ .decompress(compressedBuffer)
244
+ .toString('utf8');
245
+ console.log(
246
+ `[Cache Handler] 🌐 Decompressed with WASM zstd: ${compressedBuffer.length} → ${decompressed.length} bytes`
247
+ );
248
+ }
190
249
  } else {
191
250
  throw new Error('zstd not available for decompression');
192
251
  }
193
- } else {
194
- throw new Error(
195
- 'gzip decompression no longer supported - please invalidate cache'
196
- );
197
252
  }
198
253
 
199
254
  return {
@@ -213,14 +268,28 @@ const decompressValue = async (compressedData) => {
213
268
  if (compressedData.__method === 'zstd') {
214
269
  const zstdLib = getZstd();
215
270
  if (zstdLib && zstdLib !== false) {
216
- decompressed = zstdLib.decompress(compressedBuffer).toString('utf8');
271
+ if (
272
+ typeof zstdLib.decompress === 'function' &&
273
+ zstdLib.decompress.constructor.name === 'AsyncFunction'
274
+ ) {
275
+ const decompressedBuffer = await zstdLib.decompress(
276
+ compressedBuffer
277
+ );
278
+ decompressed = decompressedBuffer.toString('utf8');
279
+ console.log(
280
+ `[Cache Handler] 🚀 Decompressed with native zstd: ${compressedBuffer.length} → ${decompressedBuffer.length} bytes`
281
+ );
282
+ } else {
283
+ decompressed = zstdLib
284
+ .decompress(compressedBuffer)
285
+ .toString('utf8');
286
+ console.log(
287
+ `[Cache Handler] 🌐 Decompressed with WASM zstd: ${compressedBuffer.length} → ${decompressed.length} bytes`
288
+ );
289
+ }
217
290
  } else {
218
291
  throw new Error('zstd not available for decompression');
219
292
  }
220
- } else {
221
- throw new Error(
222
- 'gzip decompression no longer supported - please invalidate cache'
223
- );
224
293
  }
225
294
 
226
295
  return JSON.parse(decompressed);
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": "1.95.0-snapshot-ZERO-3586-20250901132537",
4
+ "version": "1.95.0-snapshot-ZERO-3586-20250901140025",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -18,6 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@bokuweb/zstd-wasm": "^0.0.27",
21
+ "@mongodb-js/zstd": "^2.0.1",
21
22
  "@neshca/cache-handler": "1.9.0",
22
23
  "@opentelemetry/exporter-trace-otlp-http": "0.46.0",
23
24
  "@opentelemetry/resources": "1.19.0",
@@ -35,7 +36,7 @@
35
36
  "set-cookie-parser": "2.6.0"
36
37
  },
37
38
  "devDependencies": {
38
- "@akinon/eslint-plugin-projectzero": "1.95.0-snapshot-ZERO-3586-20250901132537",
39
+ "@akinon/eslint-plugin-projectzero": "1.95.0-snapshot-ZERO-3586-20250901140025",
39
40
  "@babel/core": "7.26.10",
40
41
  "@babel/preset-env": "7.26.9",
41
42
  "@babel/preset-typescript": "7.27.0",