@decocms/blocks 7.64.0 → 7.64.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/blocks",
3
- "version": "7.64.0",
3
+ "version": "7.64.2",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -26,7 +26,7 @@ export function encodeBase64(data: ArrayBuffer | Uint8Array | string): string {
26
26
  return btoa(bin);
27
27
  }
28
28
 
29
- export function decodeBase64(b64: string): Uint8Array {
29
+ export function decodeBase64(b64: string): Uint8Array<ArrayBuffer> {
30
30
  const bin = atob(b64);
31
31
  const out = new Uint8Array(bin.length);
32
32
  for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
@@ -34,10 +34,7 @@ export function decodeBase64(b64: string): Uint8Array {
34
34
  }
35
35
 
36
36
  export function encodeBase64Url(data: ArrayBuffer | Uint8Array | string): string {
37
- return encodeBase64(data)
38
- .replace(/\+/g, "-")
39
- .replace(/\//g, "_")
40
- .replace(/=+$/, "");
37
+ return encodeBase64(data).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
41
38
  }
42
39
 
43
40
  export function decodeBase64Url(b64url: string): Uint8Array {
@@ -1,4 +1,5 @@
1
1
  import type { CacheStorage } from "./cacheStorage";
2
+ import { decodeBase64 } from "./encoding";
2
3
 
3
4
  interface StoredResponse {
4
5
  status: number;
@@ -16,7 +17,9 @@ export function createResponseCache(storage: CacheStorage, scope: string) {
16
17
  if (raw === null) return undefined;
17
18
  try {
18
19
  const stored = JSON.parse(raw) as StoredResponse;
19
- const body = Uint8Array.from(atob(stored.body), (c) => c.charCodeAt(0));
20
+ // Uint8Array.from(string, mapper) creates a large temporary iterable array.
21
+ // Decode straight into the byte buffer to keep cache hits proportional to body size.
22
+ const body = decodeBase64(stored.body);
20
23
  return new Response([204, 205, 304].includes(stored.status) ? null : body, {
21
24
  status: stored.status,
22
25
  statusText: stored.statusText,