Files
summercms/admin/src/main.ts
Jakub Zych 83fa2f7b2c feat(16.2-01): host plugin field type elements in the admin SPA
- loadFieldTypes fetches GET /field-types after sign-in, loads each script
  once and adds the styles as global links activateStyles never disables
- PluginField creates the type's element, sets the value property and the
  contract attributes, takes summer-change as the form value and never
  writes back a value the element just emitted
- rendererForField and isRegisteredField route any field with an element
  to PluginField in forms, previews and the save payload
- rebuilt modules/boardwalk/dist
2026-10-10 11:10:41 +02:00

39 lines
1.6 KiB
TypeScript

import { createApp } from 'vue'
import App from './App.vue'
import { createAdminRouter } from './app/router'
import { onUnauthorized } from './api/client'
import { loadFieldTypes } from './app/fieldTypes'
import { loadStrings } from './app/i18n'
import { applyColorScheme } from './app/theme'
import { expireSession, me } from './state/useAuth'
import { loadNavigation } from './state/useNavigation'
import { loadSettings } from './state/useSettings'
import './styles/main.css'
async function boot(): Promise<void> {
// Dark mode follows the system preference before anything renders (A6).
applyColorScheme()
// Boot order (research Pattern 7): the public strings bundle first, so the
// login screen is translated, then the session, then navigation and the
// plugin field types.
await loadStrings().catch(() => undefined)
// A 401 here only means "not signed in"; the router guard sends the
// visitor to the login route with the requested path as redirect.
const user = await me().catch(() => null)
if (user) {
// Plugin field types load once per session: their scripts define the
// elements any controller's form may use, their styles stay enabled.
await Promise.all([loadNavigation().catch(() => []), loadSettings().catch(() => []), loadFieldTypes()])
}
const router = createAdminRouter()
// A session that cannot be recovered ends here: the profile and every
// stored list query are cleared before the login screen shows (T-16.1-03).
onUnauthorized(() => expireSession(router))
const app = createApp(App)
app.use(router)
await router.isReady()
app.mount('#app')
}
void boot()