@v-tilt/browser 1.1.3 → 1.1.4
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/dist/array.js +1 -1
- package/dist/array.js.map +1 -1
- package/dist/array.no-external.js +1 -1
- package/dist/array.no-external.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.js +1 -1
- package/dist/module.js.map +1 -1
- package/dist/module.no-external.js +1 -1
- package/dist/module.no-external.js.map +1 -1
- package/lib/session.js +1 -1
- package/lib/storage.js +14 -7
- package/package.json +1 -1
package/lib/session.js
CHANGED
|
@@ -105,7 +105,7 @@ class SessionManager {
|
|
|
105
105
|
_storeSessionId(sessionId) {
|
|
106
106
|
// Use setWithExpiry for localStorage/sessionStorage
|
|
107
107
|
// For cookies, the StorageManager handles Max-Age
|
|
108
|
-
this.storage.setWithExpiry(
|
|
108
|
+
this.storage.setWithExpiry(constants_1.STORAGE_KEY, sessionId, SESSION_TTL_MS);
|
|
109
109
|
// Also set as plain cookie for cookie mode (overwrites JSON format)
|
|
110
110
|
// This ensures cookies work properly with Max-Age
|
|
111
111
|
this.storage.set(constants_1.STORAGE_KEY, sessionId, storage_1.SESSION_COOKIE_MAX_AGE);
|
package/lib/storage.js
CHANGED
|
@@ -49,8 +49,9 @@ class StorageManager {
|
|
|
49
49
|
}
|
|
50
50
|
if (this.usesLocalStorage()) {
|
|
51
51
|
const value = localStorage.getItem(key);
|
|
52
|
-
if (value !== null)
|
|
52
|
+
if (value !== null) {
|
|
53
53
|
return value;
|
|
54
|
+
}
|
|
54
55
|
// Fall back to cookie for localStorage+cookie mode
|
|
55
56
|
if (this.method === constants_1.PERSISTENCE_METHODS.localStoragePlusCookie) {
|
|
56
57
|
return this.getCookie(key);
|
|
@@ -133,8 +134,9 @@ class StorageManager {
|
|
|
133
134
|
*/
|
|
134
135
|
getWithExpiry(key) {
|
|
135
136
|
const raw = this.get(key);
|
|
136
|
-
if (!raw)
|
|
137
|
+
if (!raw) {
|
|
137
138
|
return null;
|
|
139
|
+
}
|
|
138
140
|
try {
|
|
139
141
|
const item = JSON.parse(raw);
|
|
140
142
|
// Check expiry if set
|
|
@@ -165,8 +167,9 @@ class StorageManager {
|
|
|
165
167
|
*/
|
|
166
168
|
getJSON(key) {
|
|
167
169
|
const raw = this.get(key);
|
|
168
|
-
if (!raw)
|
|
170
|
+
if (!raw) {
|
|
169
171
|
return null;
|
|
172
|
+
}
|
|
170
173
|
try {
|
|
171
174
|
return JSON.parse(raw);
|
|
172
175
|
}
|
|
@@ -184,8 +187,9 @@ class StorageManager {
|
|
|
184
187
|
// Cookie operations (internal)
|
|
185
188
|
// ============================================================================
|
|
186
189
|
getCookie(name) {
|
|
187
|
-
if (typeof document === "undefined")
|
|
190
|
+
if (typeof document === "undefined") {
|
|
188
191
|
return null;
|
|
192
|
+
}
|
|
189
193
|
const cookies = document.cookie.split(";");
|
|
190
194
|
for (const cookie of cookies) {
|
|
191
195
|
const [key, ...valueParts] = cookie.trim().split("=");
|
|
@@ -202,8 +206,9 @@ class StorageManager {
|
|
|
202
206
|
return null;
|
|
203
207
|
}
|
|
204
208
|
setCookie(name, value, maxAge) {
|
|
205
|
-
if (typeof document === "undefined")
|
|
209
|
+
if (typeof document === "undefined") {
|
|
206
210
|
return;
|
|
211
|
+
}
|
|
207
212
|
let cookieString = `${name}=${encodeURIComponent(value)}`;
|
|
208
213
|
cookieString += `; Max-Age=${maxAge}`;
|
|
209
214
|
cookieString += `; path=/`;
|
|
@@ -217,8 +222,9 @@ class StorageManager {
|
|
|
217
222
|
document.cookie = cookieString;
|
|
218
223
|
}
|
|
219
224
|
removeCookie(name) {
|
|
220
|
-
if (typeof document === "undefined")
|
|
225
|
+
if (typeof document === "undefined") {
|
|
221
226
|
return;
|
|
227
|
+
}
|
|
222
228
|
// Set cookie with expired date
|
|
223
229
|
let cookieString = `${name}=; Max-Age=0; path=/`;
|
|
224
230
|
if (this.domain) {
|
|
@@ -260,8 +266,9 @@ class StorageManager {
|
|
|
260
266
|
*/
|
|
261
267
|
getSessionStorage() {
|
|
262
268
|
var _a;
|
|
263
|
-
if (!this.canUseSessionStorage())
|
|
269
|
+
if (!this.canUseSessionStorage()) {
|
|
264
270
|
return null;
|
|
271
|
+
}
|
|
265
272
|
return (_a = globals_1.window === null || globals_1.window === void 0 ? void 0 : globals_1.window.sessionStorage) !== null && _a !== void 0 ? _a : null;
|
|
266
273
|
}
|
|
267
274
|
/**
|