2024-09-16 01:06:00 -04:00
|
|
|
//go:build js && wasm
|
|
|
|
|
// +build js,wasm
|
|
|
|
|
|
2024-09-18 02:22:17 -04:00
|
|
|
package middleware
|
2024-09-16 01:06:00 -04:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/donseba/go-htmx"
|
|
|
|
|
"github.com/labstack/echo/v4"
|
2024-09-19 02:04:22 -04:00
|
|
|
"github.com/onsonr/sonr/config/dwn"
|
2024-09-18 02:22:17 -04:00
|
|
|
"github.com/onsonr/sonr/internal/dwn/middleware/jsexc"
|
2024-09-16 01:06:00 -04:00
|
|
|
)
|
|
|
|
|
|
2024-09-19 02:04:22 -04:00
|
|
|
type Client struct {
|
2024-09-16 01:06:00 -04:00
|
|
|
echo.Context
|
|
|
|
|
isMobile bool
|
|
|
|
|
userAgent string
|
|
|
|
|
width int
|
|
|
|
|
olc string
|
|
|
|
|
ksuid string
|
|
|
|
|
|
|
|
|
|
// HTMX Specific
|
|
|
|
|
htmx *htmx.HTMX
|
|
|
|
|
|
|
|
|
|
// WebAPIs
|
2024-09-18 02:22:17 -04:00
|
|
|
indexedDB jsexc.IndexedDBAPI
|
|
|
|
|
localStorage jsexc.LocalStorageAPI
|
|
|
|
|
sessionStorage jsexc.SessionStorageAPI
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-19 02:04:22 -04:00
|
|
|
func UseNavigator(next echo.HandlerFunc, cnfg *dwn.Config) echo.HandlerFunc {
|
2024-09-18 02:22:17 -04:00
|
|
|
return func(c echo.Context) error {
|
2024-09-19 02:04:22 -04:00
|
|
|
cc := jsexc.NewNavigator(c, cnfg)
|
2024-09-18 02:22:17 -04:00
|
|
|
return next(cc)
|
|
|
|
|
}
|
2024-09-16 01:06:00 -04:00
|
|
|
}
|