add day15

This commit is contained in:
Zoe
2022-10-07 18:21:08 -05:00
parent f3718a1229
commit b37cfee924
29 changed files with 6367 additions and 0 deletions

34
day15/src/entry-client.js Normal file
View File

@@ -0,0 +1,34 @@
import { renderPage, hydratePage } from './lib/router';
import { appState } from '/src/main';
export async function mount(mounted) {
eval(mounted)
}
let SSR
export function isSSR() {
if (!import.meta.env.SSR) {
if (SSR !== undefined) return SSR
if (document.getElementById('app').childNodes[1].childNodes.length == null) {
SSR = false
} else {
SSR = document.getElementById('app').childNodes[1].childNodes.length > 0
}
return SSR
}
}
if (!import.meta.env.SSR) {
// waits for the page to fully load to render the page from the virtDOM
console.log(document.getElementById('app').childNodes[1].childNodes.length > 0)
if (!document.getElementById('app').childNodes[1].childNodes.length > 0) {
await import('/src/style.css')
await renderPage()
window.onpopstate = async () => {
await renderPage()
}
} else {
hydratePage()
}
}