@@ -8,7 +8,7 @@ import type { BaseServerInfo } from './AddServerOrConnect'
8
8
9
9
// when opening html file locally in browser, localStorage is shared between all ever opened html files, so we try to avoid conflicts
10
10
const localStoragePrefix = process . env ?. SINGLE_FILE_BUILD ? 'minecraft-web-client:' : ''
11
- const cookiePrefix = ''
11
+ const cookiePrefix = process . env . COOKIE_STORAGE_PREFIX || ''
12
12
const { localStorage } = window
13
13
const migrateRemoveLocalStorage = false
14
14
@@ -146,7 +146,7 @@ const detectStorageConflicts = (): StorageConflict[] => {
146
146
key,
147
147
localStorageValue : localData ,
148
148
localStorageTimestamp : localTimestamp ,
149
- cookieValue : cookieData ,
149
+ cookieValue : ( typeof cookieData === 'object' && cookieData !== null && 'data' in cookieData ) ? cookieData . data : cookieData ,
150
150
cookieTimestamp
151
151
} )
152
152
}
@@ -231,9 +231,10 @@ export const appStorage = proxy({ ...defaultStorageData })
231
231
232
232
// Check if cookie storage should be used (will be set by options)
233
233
const shouldUseCookieStorage = ( ) => {
234
+ const isSafari = / ^ ( (? ! c h r o m e | a n d r o i d ) .) * s a f a r i / i. test ( navigator . userAgent )
234
235
const isSecureCookiesAvailable = ( ) => {
235
236
// either https or localhost
236
- return window . location . protocol === 'https:' || window . location . hostname === 'localhost'
237
+ return window . location . protocol === 'https:' || ( window . location . hostname === 'localhost' && ! isSafari )
237
238
}
238
239
if ( ! isSecureCookiesAvailable ( ) ) {
239
240
return false
@@ -402,6 +403,12 @@ export const resolveStorageConflicts = (useLocalStorage: boolean) => {
402
403
}
403
404
}
404
405
406
+ // forcefully set data again
407
+ for ( const conflict of storageConflicts ) {
408
+ appStorage [ conflict . key ] = useLocalStorage ? conflict . localStorageValue : conflict . cookieValue
409
+ saveKey ( conflict . key as keyof StorageData )
410
+ }
411
+
405
412
// Clear conflicts and restore data
406
413
storageConflicts = [ ]
407
414
restoreStorageData ( )
0 commit comments