@m13v/seo-components 0.41.2 → 0.41.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m13v/seo-components",
3
- "version": "0.41.2",
3
+ "version": "0.41.3",
4
4
  "scripts": {
5
5
  "build:css": "tailwind -i src/_build.css -o dist/styles.css --minify",
6
6
  "lint:mobile-spans": "node scripts/lint-mobile-spans.mjs",
@@ -100,35 +100,53 @@ function nanoid(prefix: string, n = 16): string {
100
100
  return out;
101
101
  }
102
102
 
103
+ // localStorage can throw (quota exceeded, disabled in private mode, blocked by
104
+ // privacy settings). Never let storage access crash the host page: every read
105
+ // and write is wrapped so the chat panel degrades gracefully instead of taking
106
+ // down the entire site through its mount in the root layout.
107
+ function safeGet(key: string): string | null {
108
+ if (typeof window === "undefined") return null;
109
+ try {
110
+ return window.localStorage.getItem(key);
111
+ } catch {
112
+ return null;
113
+ }
114
+ }
115
+
116
+ function safeSet(key: string, value: string): void {
117
+ if (typeof window === "undefined") return;
118
+ try {
119
+ window.localStorage.setItem(key, value);
120
+ } catch {
121
+ /* quota exceeded / storage disabled — ignore */
122
+ }
123
+ }
124
+
103
125
  function getOrCreateVisitorId(): string {
104
126
  if (typeof window === "undefined") return "";
105
127
  const key = "fcp_visitor_id";
106
- let v = window.localStorage.getItem(key);
128
+ let v = safeGet(key);
107
129
  if (!v) {
108
130
  v = nanoid("web_", 16);
109
- window.localStorage.setItem(key, v);
131
+ safeSet(key, v);
110
132
  }
111
133
  return v;
112
134
  }
113
135
 
114
136
  function getStoredThreadId(project: string): string | null {
115
- if (typeof window === "undefined") return null;
116
- return window.localStorage.getItem(`fcp_thread_${project}`);
137
+ return safeGet(`fcp_thread_${project}`);
117
138
  }
118
139
 
119
140
  function setStoredThreadId(project: string, threadId: string): void {
120
- if (typeof window === "undefined") return;
121
- window.localStorage.setItem(`fcp_thread_${project}`, threadId);
141
+ safeSet(`fcp_thread_${project}`, threadId);
122
142
  }
123
143
 
124
144
  function getStoredEmail(): string | null {
125
- if (typeof window === "undefined") return null;
126
- return window.localStorage.getItem("fcp_email");
145
+ return safeGet("fcp_email");
127
146
  }
128
147
 
129
148
  function setStoredEmail(email: string): void {
130
- if (typeof window === "undefined") return;
131
- window.localStorage.setItem("fcp_email", email);
149
+ safeSet("fcp_email", email);
132
150
  }
133
151
 
134
152
  export function FounderChatPanel({