catcrafts.net/implementations/main.cpp

40 lines
1.1 KiB
C++
Raw Normal View History

2025-11-12 20:58:07 +01:00
/*
catcrafts.net
Copyright (C) 2026 Catcrafts
2025-11-12 20:58:07 +01:00
The source code of this website is made available for viewing purposes only.
2025-11-12 20:58:07 +01:00
No permission is granted to copy, modify, distribute, or create derivative works.
*/
import Catcrafts;
import Crafter.Graphics;
2025-11-12 20:58:07 +01:00
import std;
using namespace Catcrafts;
using namespace Crafter;
2025-11-12 21:24:23 +01:00
int main() {
Device::Initialize();
// Window in CRAFTER_GRAPHICS_WINDOW_DOM mode is a page-level event hub
// plus the rAF driver; even without subscribing to its events we need
// it so StartSync() can keep the wasm module alive past main() (the
// bridge stashes a raw pointer, so the storage has to outlive main).
static Window window(0, 0, "Catcrafts");
InitializePage();
Router::AddPopStateListener([]{
RenderRoot(Router::GetPath());
2025-11-12 21:24:23 +01:00
});
2025-11-12 20:58:07 +01:00
static Dom::HtmlElementPtr blogButton("blog-nav-button");
blogButton.AddClickListener([](Dom::MouseEvent) {
Router::PushState("{}", "", "/blog");
2025-11-12 21:56:18 +01:00
RenderRoot("/blog");
2025-11-12 20:58:07 +01:00
});
RenderRoot(Router::GetPath());
window.StartUpdate();
window.StartSync();
return 0;
}