Wire admin studio SSR and search infrastructure

This commit is contained in:
2026-05-01 11:46:06 +02:00
parent 257b0dbef6
commit 18cea8b0f0
329 changed files with 197465 additions and 2741 deletions

View File

@@ -1,16 +1,24 @@
import axios from 'axios'
import Echo from 'laravel-echo'
import Pusher from 'pusher-js'
import React from 'react'
import { createRoot, hydrateRoot } from 'react-dom/client'
window.axios = axios
window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
const browserWindow = typeof window !== 'undefined' ? window : null
const csrfToken = typeof document !== 'undefined'
? document.querySelector('meta[name="csrf-token"]')?.getAttribute('content')
: null
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content')
if (csrfToken) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = csrfToken
axios.defaults.headers.common['X-CSRF-TOKEN'] = csrfToken
}
window.Pusher = Pusher
if (browserWindow) {
browserWindow.axios = axios
browserWindow.Pusher = Pusher
}
let echoInstance = null
@@ -23,16 +31,21 @@ export function getEcho() {
return echoInstance || null
}
if (!browserWindow) {
echoInstance = false
return null
}
const key = import.meta.env.VITE_REVERB_APP_KEY
if (!key) {
echoInstance = false
return null
}
const scheme = import.meta.env.VITE_REVERB_SCHEME || window.location.protocol.replace(':', '') || 'https'
const scheme = import.meta.env.VITE_REVERB_SCHEME || browserWindow.location.protocol.replace(':', '') || 'https'
const forceTLS = scheme === 'https'
const configuredHost = import.meta.env.VITE_REVERB_HOST || window.location.hostname
const publicHostname = window.location.hostname
const configuredHost = import.meta.env.VITE_REVERB_HOST || browserWindow.location.hostname
const publicHostname = browserWindow.location.hostname
const useWindowHost = !isLoopbackHost(publicHostname) && isLoopbackHost(configuredHost)
const resolvedHost = useWindowHost ? publicHostname : configuredHost
const resolvedPort = useWindowHost
@@ -59,7 +72,22 @@ export function getEcho() {
},
})
window.Echo = echoInstance
browserWindow.Echo = echoInstance
return echoInstance
}
export function mountInertiaRoot(el, App, props) {
if (!el) {
return null
}
const node = React.createElement(App, props)
const hasServerMarkup = el.childNodes.length > 0 && el.innerHTML.trim() !== ''
if (hasServerMarkup) {
return hydrateRoot(el, node)
}
return createRoot(el).render(node)
}