Add gallery core and command: routes, sidebar, search, code panel, browser hook
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
727de5f110
commit
ff50f9b35a
10 files changed
+750
-2
No files matched your search
@@ -0,0 +1,30 @@
|
||||
//go:build js && wasm
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"syscall/js"
|
||||
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/CrychicUI/gallery"
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/CrychicUI/sound"
|
||||
)
|
||||
|
||||
// hook exports window.__crychic for Playwright.
|
||||
func hook(app *gallery.App) {
|
||||
obj := js.Global().Get("Object").New()
|
||||
js.Global().Get("Object").Call("defineProperty", obj, "ready", map[string]any{
|
||||
"get": js.FuncOf(func(js.Value, []js.Value) any { return app.Snapshot().Built }),
|
||||
})
|
||||
obj.Set("page", js.FuncOf(func(js.Value, []js.Value) any { return app.Snapshot().Page }))
|
||||
obj.Set("stats", js.FuncOf(func(js.Value, []js.Value) any {
|
||||
return map[string]any{"components": len(gallery.Entries()), "categories": len(gallery.Categories)}
|
||||
}))
|
||||
obj.Set("recent", js.FuncOf(func(js.Value, []js.Value) any {
|
||||
var out []any
|
||||
for _, c := range sound.Recent() {
|
||||
out = append(out, c.String())
|
||||
}
|
||||
return out
|
||||
}))
|
||||
js.Global().Set("__crychic", obj)
|
||||
}
|
||||
Reference in new issue
Block a user