2025-02-04 15:23:21 +02:00
|
|
|
/* global process */
|
2021-04-24 17:56:00 +03:00
|
|
|
import { createStore } from 'vuex'
|
2023-04-04 21:17:54 -06:00
|
|
|
import { createPinia } from 'pinia'
|
2016-10-26 19:03:55 +02:00
|
|
|
|
2020-01-23 23:53:48 +03:00
|
|
|
import 'custom-event-polyfill'
|
|
|
|
import './lib/event_target_polyfill.js'
|
|
|
|
|
2018-09-09 21:21:23 +03:00
|
|
|
import instanceModule from './modules/instance.js'
|
2016-10-27 18:03:25 +02:00
|
|
|
import statusesModule from './modules/statuses.js'
|
2023-11-16 19:26:18 +02:00
|
|
|
import notificationsModule from './modules/notifications.js'
|
2016-10-27 18:03:25 +02:00
|
|
|
import usersModule from './modules/users.js'
|
2016-11-26 18:57:08 +01:00
|
|
|
import apiModule from './modules/api.js'
|
2017-02-14 22:21:23 +01:00
|
|
|
import configModule from './modules/config.js'
|
2023-03-12 14:32:13 +02:00
|
|
|
import profileConfigModule from './modules/profileConfig.js'
|
2022-08-04 01:56:52 +03:00
|
|
|
import serverSideStorageModule from './modules/serverSideStorage.js'
|
2023-03-13 00:09:47 +02:00
|
|
|
import adminSettingsModule from './modules/adminSettings.js'
|
2018-10-26 15:16:23 +02:00
|
|
|
import oauthModule from './modules/oauth.js'
|
2019-06-12 20:16:55 +00:00
|
|
|
import authFlowModule from './modules/auth_flow.js'
|
2019-02-12 21:53:59 +03:00
|
|
|
import oauthTokensModule from './modules/oauth_tokens.js'
|
2023-03-10 11:20:06 -05:00
|
|
|
import draftsModule from './modules/drafts.js'
|
2020-05-07 16:10:53 +03:00
|
|
|
import chatsModule from './modules/chats.js'
|
2024-09-23 23:10:32 +02:00
|
|
|
import bookmarkFoldersModule from './modules/bookmark_folders.js'
|
2016-10-26 19:03:55 +02:00
|
|
|
|
2021-04-24 17:56:00 +03:00
|
|
|
import { createI18n } from 'vue-i18n'
|
2016-11-28 17:37:47 +01:00
|
|
|
|
2017-02-20 18:25:19 +01:00
|
|
|
import createPersistedState from './lib/persisted_state.js'
|
2018-12-25 20:43:18 +07:00
|
|
|
import pushNotifications from './lib/push_notifications_plugin.js'
|
2017-02-14 22:42:13 +01:00
|
|
|
|
2017-11-07 15:14:37 +01:00
|
|
|
import messages from './i18n/messages.js'
|
|
|
|
|
2018-10-26 15:16:23 +02:00
|
|
|
import afterStoreSetup from './boot/after_store.js'
|
|
|
|
|
2017-11-08 22:18:42 +02:00
|
|
|
const currentLocale = (window.navigator.language || 'en').split('-')[0]
|
|
|
|
|
2022-03-16 22:02:44 +02:00
|
|
|
const i18n = createI18n({
|
2018-08-25 13:12:33 +03:00
|
|
|
// By default, use the browser locale, we will update it if neccessary
|
2020-06-08 17:22:07 +02:00
|
|
|
locale: 'en',
|
2017-11-07 15:14:37 +01:00
|
|
|
fallbackLocale: 'en',
|
2020-06-08 17:22:07 +02:00
|
|
|
messages: messages.default
|
2017-11-07 15:14:37 +01:00
|
|
|
})
|
|
|
|
|
2023-04-13 00:03:36 +08:00
|
|
|
messages.setLanguage(i18n.global, currentLocale)
|
2020-06-08 17:22:07 +02:00
|
|
|
|
2018-10-26 15:16:23 +02:00
|
|
|
const persistedStateOptions = {
|
|
|
|
paths: [
|
2022-08-04 01:56:52 +03:00
|
|
|
'serverSideStorage.cache',
|
2018-10-26 15:16:23 +02:00
|
|
|
'config',
|
|
|
|
'users.lastLoginName',
|
|
|
|
'oauth'
|
|
|
|
]
|
2019-03-13 11:29:45 +01:00
|
|
|
};
|
2018-12-13 18:04:09 +07:00
|
|
|
|
2019-03-13 11:29:45 +01:00
|
|
|
(async () => {
|
2024-09-18 03:37:59 +03:00
|
|
|
const isFox = Math.floor(Math.random() * 2) > 0 ? '_fox' : ''
|
|
|
|
|
|
|
|
const splashError = (i18n, e) => {
|
|
|
|
const throbber = document.querySelector('#throbber')
|
|
|
|
throbber.addEventListener('animationend', () => {
|
|
|
|
document.querySelector('#mascot').src = `/static/pleromatan_orz${isFox}.png`
|
|
|
|
})
|
|
|
|
throbber.classList.add('dead')
|
|
|
|
document.querySelector('#status').textContent = i18n.global.t('splash.error')
|
|
|
|
console.error('PleromaFE failed to initialize: ', e)
|
2024-12-12 15:58:18 +02:00
|
|
|
document.querySelector('#statusError').textContent = e
|
|
|
|
document.querySelector('#statusStack').textContent = e.stack
|
|
|
|
document.querySelector('#statusError').style = 'display: block'
|
|
|
|
document.querySelector('#statusStack').style = 'display: block'
|
2020-07-01 19:15:28 +03:00
|
|
|
}
|
2023-04-05 21:06:37 -06:00
|
|
|
|
2024-12-12 15:42:03 +02:00
|
|
|
window.splashError = e => splashError(i18n, e)
|
|
|
|
window.splashUpdate = key => {
|
2024-12-18 16:29:38 +02:00
|
|
|
if (document.querySelector('#status')) {
|
|
|
|
document.querySelector('#status').textContent = i18n.global.t(key)
|
|
|
|
}
|
2020-07-01 19:15:28 +03:00
|
|
|
}
|
2023-04-04 21:17:54 -06:00
|
|
|
|
2020-07-01 19:15:28 +03:00
|
|
|
try {
|
2024-09-17 05:04:52 +03:00
|
|
|
let storageError
|
|
|
|
const plugins = [pushNotifications]
|
2025-01-30 18:08:05 +02:00
|
|
|
const pinia = createPinia()
|
2024-09-17 05:04:52 +03:00
|
|
|
try {
|
|
|
|
const persistedState = await createPersistedState(persistedStateOptions)
|
|
|
|
plugins.push(persistedState)
|
|
|
|
} catch (e) {
|
|
|
|
console.error('Storage error', e)
|
|
|
|
storageError = e
|
|
|
|
}
|
2024-09-18 03:37:59 +03:00
|
|
|
document.querySelector('#mascot').src = `/static/pleromatan_apology${isFox}.png`
|
2024-09-17 05:04:52 +03:00
|
|
|
document.querySelector('#status').removeAttribute('class')
|
|
|
|
document.querySelector('#status').textContent = i18n.global.t('splash.loading')
|
2024-09-17 22:56:06 +03:00
|
|
|
document.querySelector('#splash-credit').textContent = i18n.global.t('update.art_by', { linkToArtist: 'pipivovott' })
|
2024-09-17 05:04:52 +03:00
|
|
|
const store = createStore({
|
|
|
|
modules: {
|
|
|
|
instance: instanceModule,
|
|
|
|
// TODO refactor users/statuses modules, they depend on each other
|
|
|
|
users: usersModule,
|
|
|
|
statuses: statusesModule,
|
|
|
|
notifications: notificationsModule,
|
|
|
|
api: apiModule,
|
|
|
|
config: configModule,
|
|
|
|
profileConfig: profileConfigModule,
|
|
|
|
serverSideStorage: serverSideStorageModule,
|
|
|
|
adminSettings: adminSettingsModule,
|
|
|
|
oauth: oauthModule,
|
|
|
|
authFlow: authFlowModule,
|
|
|
|
oauthTokens: oauthTokensModule,
|
2024-12-26 23:51:54 +00:00
|
|
|
drafts: draftsModule,
|
2024-09-17 05:04:52 +03:00
|
|
|
chats: chatsModule,
|
2024-10-03 21:52:44 +02:00
|
|
|
bookmarkFolders: bookmarkFoldersModule
|
2019-03-31 21:59:18 -04:00
|
|
|
},
|
2024-09-17 05:04:52 +03:00
|
|
|
plugins,
|
2025-01-06 00:24:02 +00:00
|
|
|
options: {
|
|
|
|
devtools: process.env.NODE_ENV !== 'production'
|
|
|
|
},
|
2024-09-17 05:04:52 +03:00
|
|
|
strict: false // Socket modifies itself, let's ignore this for now.
|
|
|
|
// strict: process.env.NODE_ENV !== 'production'
|
|
|
|
})
|
2025-01-30 21:56:07 +02:00
|
|
|
window.vuex = store
|
|
|
|
// Temporarily passing pinia and vuex stores along with storageError result until migration is fully complete.
|
2025-01-30 18:08:05 +02:00
|
|
|
return await afterStoreSetup({ pinia, store, storageError, i18n })
|
2024-09-17 05:04:52 +03:00
|
|
|
} catch (e) {
|
|
|
|
splashError(i18n, e)
|
2020-07-02 10:40:41 +03:00
|
|
|
}
|
2019-03-13 11:29:45 +01:00
|
|
|
})()
|
2018-12-11 18:45:25 +03:00
|
|
|
|
|
|
|
// These are inlined by webpack's DefinePlugin
|
|
|
|
/* eslint-disable */
|
|
|
|
window.___pleromafe_mode = process.env
|
|
|
|
window.___pleromafe_commit_hash = COMMIT_HASH
|
|
|
|
window.___pleromafe_dev_overrides = DEV_OVERRIDES
|