f22c5ebbfe
- PHP/MySQL Backend (XAMPP + Produktionsserver) - Front-Controller, API-Endpunkte, Session-Management - Flussmanagement-Simulation (Echtzeit, Punkt-basierter Fluss) - Stadt & Raumplanung (Prototyp, Top-Down Kachelsystem) - Klimawaechter 3D: Deiche kleiner, Baeume kippen, Budget angepasst - persistence.ts: Dualer Speicher (localStorage + Server-API) - 6 Unit-Test-Dateien fuer bestehende Simulationen Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
44 lines
1.6 KiB
PHP
44 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* Vite Manifest Reader
|
|
* Liest dist/.vite/manifest.json und gibt die korrekten Script-Tags aus.
|
|
* Im Dev-Modus (kein manifest vorhanden) wird direkt auf die TS-Quellen verwiesen.
|
|
*/
|
|
|
|
function viteAssets(string $entry): void {
|
|
$manifestPath = APP_ROOT . '/dist/.vite/manifest.json';
|
|
|
|
// Production: Lese Manifest
|
|
if (file_exists($manifestPath)) {
|
|
$manifest = json_decode(file_get_contents($manifestPath), true);
|
|
$chunk = $manifest[$entry] ?? null;
|
|
if (!$chunk) return;
|
|
|
|
// CSS
|
|
foreach ($chunk['css'] ?? [] as $css) {
|
|
echo '<link rel="stylesheet" href="' . BASE_PATH . '/dist/' . $css . '">' . "\n";
|
|
}
|
|
// Preload imports
|
|
foreach ($chunk['imports'] ?? [] as $importKey) {
|
|
$imp = $manifest[$importKey] ?? null;
|
|
if ($imp) {
|
|
echo '<link rel="modulepreload" crossorigin href="' . BASE_PATH . '/dist/' . $imp['file'] . '">' . "\n";
|
|
}
|
|
}
|
|
// Main entry
|
|
echo '<script type="module" crossorigin src="' . BASE_PATH . '/dist/' . $chunk['file'] . '"></script>' . "\n";
|
|
}
|
|
// Dev fallback: keine Manifest-Datei → direkte TS-Referenz (Vite Dev Server)
|
|
}
|
|
|
|
/** Session-Kontext als JS-Variable injizieren */
|
|
function injectSessionContext(): void {
|
|
$ctx = [
|
|
'sessionId' => Session::studentId(),
|
|
'teacherId' => Session::teacherId(),
|
|
'baseUrl' => BASE_URL,
|
|
'basePath' => BASE_PATH,
|
|
];
|
|
echo '<script>window.__GGS__ = ' . json_encode($ctx, JSON_UNESCAPED_UNICODE) . ';</script>' . "\n";
|
|
}
|