@functionalcms/svelte-components 5.5.2 → 5.5.3

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.
@@ -1,18 +1,24 @@
1
1
  import {} from '@sveltejs/kit';
2
2
  import { loadCookie, saveCookie } from '../cookies';
3
+ import LZString from 'lz-string';
4
+ const storage = new Map();
3
5
  export const sessionStorageHandler = (secret, contentName) => {
4
6
  return async ({ event, resolve }) => {
5
- const item = event?.locals?.[contentName];
6
- event.locals[contentName] = {};
7
- if (!item) {
8
- let itemContent = await loadCookie(event.cookies, secret, contentName);
9
- if (itemContent && itemContent != '') {
10
- event.locals[contentName] = JSON.parse(itemContent);
11
- }
7
+ // const item = event?.locals?.[contentName];
8
+ // event.locals[contentName] = {};
9
+ // if (!item) {
10
+ const itemContent = await loadCookie(event.cookies, secret, contentName);
11
+ if (itemContent && itemContent != '') {
12
+ const decompressedContent = LZString.decompressFromEncodedURIComponent(itemContent);
13
+ const parsedContent = JSON.parse(decompressedContent);
14
+ event.locals[contentName] = parsedContent;
12
15
  }
16
+ // }
13
17
  const result = await resolve(event);
14
18
  if (event.locals[contentName]) {
15
- await saveCookie(result.headers, secret, contentName, JSON.stringify(event.locals[contentName]));
19
+ const content = JSON.stringify(event.locals[contentName]);
20
+ const serializedContent = LZString.compressToEncodedURIComponent(content);
21
+ await saveCookie(result.headers, secret, contentName, serializedContent);
16
22
  }
17
23
  return result;
18
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@functionalcms/svelte-components",
3
- "version": "5.5.2",
3
+ "version": "5.5.3",
4
4
  "license": "MIT",
5
5
  "watch": {
6
6
  "build": {
@@ -61,6 +61,7 @@
61
61
  "flowbite-svelte": "^1.31.0",
62
62
  "flowbite-svelte-icons": "^3.1.0",
63
63
  "ioredis": "^5.10.0",
64
+ "lz-string": "^1.5.0",
64
65
  "oauth4webapi": "^3.8.5",
65
66
  "tailwindcss": "^4.2.2"
66
67
  },