| 76 | } |
| 77 | |
| 78 | export async function safeSet(key: string, value: any) { |
| 79 | if (typeof window === "undefined") { |
| 80 | return; |
| 81 | } |
| 82 | |
| 83 | try { |
| 84 | if (!globalStore) { |
| 85 | init(); |
| 86 | } |
| 87 | |
| 88 | Cookies.set(key, value, { |
| 89 | expires: 365, |
| 90 | path: "/editor", |
| 91 | sameSite: "strict", |
| 92 | }); |
| 93 | await set(key, value, globalStore); |
| 94 | } catch (e) { |
| 95 | if ((e as unknown as Error).name === "InvalidStateError") { |
| 96 | console.error("InvalidStateError", e); |
| 97 | } else { |
| 98 | throw e; |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | export async function safeDel(key: string) { |
| 104 | if (typeof window === "undefined") { |