diff --git a/Makefile b/Makefile index 52586a6a6..5e7dc2b17 100644 --- a/Makefile +++ b/Makefile @@ -289,31 +289,23 @@ testnet-basic: setup-testnet sh-testnet: mod-tidy CHAIN_ID="sonr-testnet-1" BLOCK_TIME="1000ms" CLEAN=true sh scripts/test_node.sh -.PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet +start-hway: hway + @echo "(start-proxy) Starting proxy server" + ./build/hway start + +.PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet start-hway + ############################################################################### -### templ & vault ### +### custom generation ### ############################################################################### -.PHONY: build-motr build-hway gen-templ gen-pkl build-nebula - -build-hway: - @echo "(motr) Building Highway gateway" - go build -o ./build/hway ./cmd/hway - -build-motr: - @echo "(dwn) Building motr.wasm -> Service Worker IPFS Vault" - GOOS=js GOARCH=wasm go build -o ./pkg/dwn/app.wasm ./cmd/motr/motr.go +.PHONY: gen-templ gen-pkl gen-templ: @echo "(templ) Generating templ files" templ generate -build-nebula: - @echo "(nebula) Building nebula" - cd pkg/nebula && bun run build - templ generate - gen-pkl: @echo "(pkl) Building PKL" go run github.com/apple/pkl-go/cmd/pkl-gen-go ./pkl/DWN.pkl @@ -321,13 +313,26 @@ gen-pkl: go run github.com/apple/pkl-go/cmd/pkl-gen-go ./pkl/Txns.pkl go run github.com/apple/pkl-go/cmd/pkl-gen-go ./pkl/UIUX.pkl -start-caddy: - @echo "(start-caddy) Starting caddy" - ./build/caddy run --config ./config/caddy/Caddyfile -start-hway: hway - @echo "(start-proxy) Starting proxy server" - ./build/hway start + +############################################################################### +### motr, hway & nebula ### +############################################################################### + +.PHONY: build-motr build-hway build-nebula + +build-hway: gen-templ gen-pkl + @echo "(motr) Building Highway gateway" + go build -o ./build/hway ./cmd/hway + +build-motr: gen-templ gen-pkl + @echo "(dwn) Building motr.wasm -> Service Worker IPFS Vault" + GOOS=js GOARCH=wasm go build -o ./pkg/dwn/app.wasm ./cmd/motr/motr.go + +build-nebula: + @echo "(nebula) Building nebula" + cd pkg/nebula && bun run build + ############################################################################### ### help ### diff --git a/cmd/motr/motr.go b/cmd/motr/motr.go index 328b44286..c053c393f 100644 --- a/cmd/motr/motr.go +++ b/cmd/motr/motr.go @@ -15,9 +15,9 @@ import ( "github.com/labstack/echo/v4" promise "github.com/nlepage/go-js-promise" - "github.com/onsonr/sonr/cmd/motr/state" "github.com/onsonr/sonr/internal/session" - "github.com/onsonr/sonr/pkg/nebula/router" + "github.com/onsonr/sonr/pkg/nebula/routes" + "github.com/onsonr/sonr/pkg/nebula/worker" ) func main() { @@ -30,21 +30,18 @@ func main() { func registerState(e *echo.Echo) { g := e.Group("state") - g.POST("/login/:identifier", state.HandleCredentialAssertion) - // g.GET("/discovery", state.GetDiscovery) - g.GET("/jwks", state.GetJWKS) - g.GET("/token", state.GetToken) - g.POST("/:origin/grant/:subject", state.GrantAuthorization) - g.POST("/register/:subject", state.HandleCredentialCreation) - g.POST("/register/:subject/check", state.CheckSubjectIsValid) + g.POST("/login/:identifier", worker.HandleCredentialAssertion) + g.GET("/jwks", worker.GetJWKS) + g.GET("/token", worker.GetToken) + g.POST("/:origin/grant/:subject", worker.GrantAuthorization) + g.POST("/register/:subject", worker.HandleCredentialCreation) + g.POST("/register/:subject/check", worker.CheckSubjectIsValid) } func registerViews(e *echo.Echo) { - e.GET("/home", router.Home) - e.GET("/login", router.Login) - e.GET("/register", router.Register) - e.GET("/profile", router.Profile) - e.GET("/authorize", router.Authorize) + e.GET("/home", routes.Home) + e.GET("/login", routes.LoginStart) + e.GET("/register", routes.RegisterStart) } // Serve serves HTTP requests using handler or http.DefaultServeMux if handler is nil. diff --git a/cmd/motr/state/manifest.go b/cmd/motr/state/manifest.go deleted file mode 100644 index 7bf2df5b4..000000000 --- a/cmd/motr/state/manifest.go +++ /dev/null @@ -1 +0,0 @@ -package state diff --git a/cmd/motr/state/wellknown.go b/cmd/motr/state/wellknown.go deleted file mode 100644 index 7bf2df5b4..000000000 --- a/cmd/motr/state/wellknown.go +++ /dev/null @@ -1 +0,0 @@ -package state diff --git a/pkg/dwn/embed.go b/pkg/dwn/embed.go index 134743eec..53db5c0a6 100644 --- a/pkg/dwn/embed.go +++ b/pkg/dwn/embed.go @@ -6,8 +6,8 @@ import ( _ "embed" "encoding/json" - "github.com/a-h/templ" "github.com/ipfs/boxo/files" + "github.com/onsonr/sonr/pkg/nebula/global" ) //go:embed app.wasm @@ -28,12 +28,8 @@ func NewVaultDirectory(cnfg *Config) (files.Node, error) { return nil, err } - dwnStr, err := templ.JSONString(cnfg) - if err != nil { - return nil, err - } w := bytes.NewBuffer(nil) - err = indexFile(dwnStr).Render(context.Background(), w) + err = global.IndexFile().Render(context.Background(), w) if err != nil { return nil, err } @@ -47,13 +43,9 @@ func NewVaultDirectory(cnfg *Config) (files.Node, error) { } // Use IndexHTML template to generate the index file -func IndexHTMLFile(c *Config) (files.Node, error) { - str, err := templ.JSONString(c) - if err != nil { - return nil, err - } +func IndexHTMLFile() (files.Node, error) { w := bytes.NewBuffer(nil) - err = indexFile(str).Render(context.Background(), w) + err := global.IndexFile().Render(context.Background(), w) if err != nil { return nil, err } diff --git a/pkg/dwn/index.templ b/pkg/dwn/index.templ deleted file mode 100644 index f8c4880eb..000000000 --- a/pkg/dwn/index.templ +++ /dev/null @@ -1,104 +0,0 @@ -package dwn - -var motrHandle = templ.NewOnceHandle() - -templ importScripts() { - - - -} - -templ indexFile(cfg string) { - - - - - - - - @importScripts() - - Sonr DWN - - - -
-
Loading...
-
- @motrHandle.Once() { - - @initializeMotr(cfg) - } - - -} - -script initializeMotr(config string) { - const motr = new Motr(JSON.parse(config)); - - async function demo() { - try { - // Insert a new account - const accountId = await motr.insertAccount({ - name: 'John Doe', - address: '0x1234567890123456789012345678901234567890', - publicKey: 'sample_public_key', - chainCode: 'SONR', - index: 0, - controller: 'sample_controller', - createdAt: new Date() - }); - - console.log('Inserted account with ID:', accountId); - - // Retrieve the account - const account = await motr.getAccount(accountId); - console.log('Retrieved account:', account); - - // Insert a new credential - const credentialId = await motr.insertCredential({ - subject: 'john@example.com', - label: 'John\'s Device', - controller: 'sample_controller', - attestationType: 'platform', - origin: 'https://app.sonr.io' - }); - - console.log('Inserted credential with ID:', credentialId); - - // Retrieve the credential - const credential = await motr.getCredential(credentialId); - console.log('Retrieved credential:', credential); - - document.getElementById('output').innerHTML = ` -

Demo Results:

-

Inserted account ID: ${accountId}

-

Retrieved account name: ${account.name}

-

Inserted credential ID: ${credentialId}

-

Retrieved credential subject: ${credential.subject}

- `; - } catch (error) { - console.error('Error in demo:', error); - document.getElementById('output').innerHTML = `

Error: ${error.message}

`; - } - } - // Run the demo when the page loads - window.onload = demo; -} diff --git a/pkg/dwn/index_templ.go b/pkg/dwn/index_templ.go deleted file mode 100644 index d240b403d..000000000 --- a/pkg/dwn/index_templ.go +++ /dev/null @@ -1,168 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.2.778 -package dwn - -//lint:file-ignore SA4006 This context is only used if a nested component is present. - -import "github.com/a-h/templ" -import templruntime "github.com/a-h/templ/runtime" - -var motrHandle = templ.NewOnceHandle() - -func importScripts() templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var1 := templ.GetChildren(ctx) - if templ_7745c5c3_Var1 == nil { - templ_7745c5c3_Var1 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -func indexFile(cfg string) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var2 := templ.GetChildren(ctx) - if templ_7745c5c3_Var2 == nil { - templ_7745c5c3_Var2 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = importScripts().Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Sonr DWN
Loading...
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Var3 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = initializeMotr(cfg).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = motrHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -func initializeMotr(config string) templ.ComponentScript { - return templ.ComponentScript{ - Name: `__templ_initializeMotr_d70f`, - Function: `function __templ_initializeMotr_d70f(config){const motr = new Motr(JSON.parse(config)); - - async function demo() { - try { - // Insert a new account - const accountId = await motr.insertAccount({ - name: 'John Doe', - address: '0x1234567890123456789012345678901234567890', - publicKey: 'sample_public_key', - chainCode: 'SONR', - index: 0, - controller: 'sample_controller', - createdAt: new Date() - }); - - console.log('Inserted account with ID:', accountId); - - // Retrieve the account - const account = await motr.getAccount(accountId); - console.log('Retrieved account:', account); - - // Insert a new credential - const credentialId = await motr.insertCredential({ - subject: 'john@example.com', - label: 'John\'s Device', - controller: 'sample_controller', - attestationType: 'platform', - origin: 'https://app.sonr.io' - }); - - console.log('Inserted credential with ID:', credentialId); - - // Retrieve the credential - const credential = await motr.getCredential(credentialId); - console.log('Retrieved credential:', credential); - - document.getElementById('output').innerHTML = ` + "`" + ` -

Demo Results:

-

Inserted account ID: ${accountId}

-

Retrieved account name: ${account.name}

-

Inserted credential ID: ${credentialId}

-

Retrieved credential subject: ${credential.subject}

- ` + "`" + `; - } catch (error) { - console.error('Error in demo:', error); - document.getElementById('output').innerHTML = ` + "`" + `

Error: ${error.message}

` + "`" + `; - } - } - // Run the demo when the page loads - window.onload = demo; -}`, - Call: templ.SafeScript(`__templ_initializeMotr_d70f`, config), - CallInline: templ.SafeScriptInline(`__templ_initializeMotr_d70f`, config), - } -} - -var _ = templruntime.GeneratedTemplate diff --git a/pkg/nebula/assets/js/motr.js b/pkg/nebula/assets/js/motr.js deleted file mode 100644 index 012bc6d9e..000000000 --- a/pkg/nebula/assets/js/motr.js +++ /dev/null @@ -1,3 +0,0 @@ -import "htmx.org"; -import "alpinejs"; -console.log("Hello from TypeScript!"); diff --git a/pkg/nebula/assets/js/sw.js b/pkg/nebula/assets/js/sw.js new file mode 100644 index 000000000..2a0b46c6c --- /dev/null +++ b/pkg/nebula/assets/js/sw.js @@ -0,0 +1,22 @@ +importScripts( + "https://cdn.jsdelivr.net/gh/golang/go@go1.22.5/misc/wasm/wasm_exec.js", + "https://cdn.jsdelivr.net/gh/nlepage/go-wasm-http-server@v1.1.0/sw.js", +); + +registerWasmHTTPListener("/app.wasm"); + +// Skip installed stage and jump to activating stage +self.addEventListener("install", (event) => { + event.waitUntil(skipWaiting()); +}); + +// Start controlling clients as soon as the SW is activated +self.addEventListener("activate", (event) => { + event.waitUntil(clients.claim()); +}); + +self.addEventListener("canmakepayment", function (e) { + e.respondWith(new Promise(function (resolve, reject) { + resolve(true); + })); +}); diff --git a/pkg/nebula/global/cdn/scripts.templ b/pkg/nebula/global/cdn/scripts.templ new file mode 100644 index 000000000..58e1d40dc --- /dev/null +++ b/pkg/nebula/global/cdn/scripts.templ @@ -0,0 +1,29 @@ +package cdn + +const ( + CDNPath = "https://cdn.sonr.id" +) + +var ( + stylesHandle = templ.NewOnceHandle() + alpineHandle = templ.NewOnceHandle() + htmxHandle = templ.NewOnceHandle() +) + +templ Styles() { + @stylesHandle.Once() { + + } +} + +templ Alpine() { + @alpineHandle.Once() { + + } +} + +templ Htmx() { + @htmxHandle.Once() { + + } +} diff --git a/pkg/nebula/global/cdn/scripts_templ.go b/pkg/nebula/global/cdn/scripts_templ.go new file mode 100644 index 000000000..8ecd534d4 --- /dev/null +++ b/pkg/nebula/global/cdn/scripts_templ.go @@ -0,0 +1,201 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.778 +package cdn + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +const ( + CDNPath = "https://cdn.sonr.id" +) + +var ( + stylesHandle = templ.NewOnceHandle() + alpineHandle = templ.NewOnceHandle() + htmxHandle = templ.NewOnceHandle() +) + +func Styles() templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = stylesHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func Alpine() templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var5 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = alpineHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func Htmx() templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var7 := templ.GetChildren(ctx) + if templ_7745c5c3_Var7 == nil { + templ_7745c5c3_Var7 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var8 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) + templ_7745c5c3_Err = htmxHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var8), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/pkg/nebula/global/index.templ b/pkg/nebula/global/index.templ new file mode 100644 index 000000000..9418b42de --- /dev/null +++ b/pkg/nebula/global/index.templ @@ -0,0 +1,27 @@ +package global + +import ( + "github.com/onsonr/sonr/pkg/nebula/global/cdn" + "github.com/onsonr/sonr/pkg/nebula/global/state" +) + +templ IndexFile() { + + + + @cdn.Alpine() + @cdn.Htmx() + @cdn.Styles() + + + + Sonr DWN + @state.RegisterServiceWorker() + + +
+
Loading...
+
+ + +} diff --git a/pkg/nebula/global/index_templ.go b/pkg/nebula/global/index_templ.go new file mode 100644 index 000000000..1cd0bd186 --- /dev/null +++ b/pkg/nebula/global/index_templ.go @@ -0,0 +1,69 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.778 +package global + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +import ( + "github.com/onsonr/sonr/pkg/nebula/global/cdn" + "github.com/onsonr/sonr/pkg/nebula/global/state" +) + +func IndexFile() templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cdn.Alpine().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cdn.Htmx().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = cdn.Styles().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("Sonr DWN") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = state.RegisterServiceWorker().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
Loading...
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/pkg/nebula/global/state/credentials.templ b/pkg/nebula/global/state/credentials.templ new file mode 100644 index 000000000..27072ce13 --- /dev/null +++ b/pkg/nebula/global/state/credentials.templ @@ -0,0 +1,86 @@ +package state + +templ NavigatorCredentialsCreate() { + +} + +templ NavigatorCredentialsGet() { + +} + +templ NavigatorCredentialsGetAll() { + +} + +templ NavigatorCredentialsHasPasskey() { + +} diff --git a/pkg/nebula/global/state/credentials_templ.go b/pkg/nebula/global/state/credentials_templ.go new file mode 100644 index 000000000..86c70be81 --- /dev/null +++ b/pkg/nebula/global/state/credentials_templ.go @@ -0,0 +1,127 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.778 +package state + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +func NavigatorCredentialsCreate() templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func NavigatorCredentialsGet() templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var2 := templ.GetChildren(ctx) + if templ_7745c5c3_Var2 == nil { + templ_7745c5c3_Var2 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func NavigatorCredentialsGetAll() templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +func NavigatorCredentialsHasPasskey() templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var4 := templ.GetChildren(ctx) + if templ_7745c5c3_Var4 == nil { + templ_7745c5c3_Var4 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/pkg/nebula/global/state/database.templ b/pkg/nebula/global/state/database.templ new file mode 100644 index 000000000..d6fb91a91 --- /dev/null +++ b/pkg/nebula/global/state/database.templ @@ -0,0 +1,17 @@ +package state + +templ InsertAccount(accountName string) { + +} diff --git a/pkg/nebula/global/state/database_templ.go b/pkg/nebula/global/state/database_templ.go new file mode 100644 index 000000000..5d9f24eff --- /dev/null +++ b/pkg/nebula/global/state/database_templ.go @@ -0,0 +1,40 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.2.778 +package state + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +func InsertAccount(accountName string) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return templ_7745c5c3_Err + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/pkg/nebula/global/state/worker.templ b/pkg/nebula/global/state/worker.templ index 9d4c3b963..c17b61507 100644 --- a/pkg/nebula/global/state/worker.templ +++ b/pkg/nebula/global/state/worker.templ @@ -1,55 +1,24 @@ package state -const ( - CDNPath = "https://cdn.sonr.id" -) - var ( - serviceWorkerHandle = templ.NewOnceHandle() - stylesHandle = templ.NewOnceHandle() - alpineHandle = templ.NewOnceHandle() - htmxHandle = templ.NewOnceHandle() + serviceWorkerHandle = templ.NewOnceHandle() ) -func cdnPath(path string, local bool) string { - if local { - return path - } - return CDNPath + path -} - templ RegisterServiceWorker() { - -} - -templ Styles(local bool) { - @stylesHandle.Once() { - } } - -templ Alpine(local bool) { - @alpineHandle.Once() { - - } -} - -templ Htmx(local bool) { - @htmxHandle.Once() { - - } -} - diff --git a/pkg/nebula/global/state/worker_templ.go b/pkg/nebula/global/state/worker_templ.go index 54287461b..ab168135b 100644 --- a/pkg/nebula/global/state/worker_templ.go +++ b/pkg/nebula/global/state/worker_templ.go @@ -8,24 +8,10 @@ package state import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -const ( - CDNPath = "https://cdn.sonr.id" -) - var ( serviceWorkerHandle = templ.NewOnceHandle() - stylesHandle = templ.NewOnceHandle() - alpineHandle = templ.NewOnceHandle() - htmxHandle = templ.NewOnceHandle() ) -func cdnPath(path string, local bool) string { - if local { - return path - } - return CDNPath + path -} - func RegisterServiceWorker() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context @@ -47,36 +33,7 @@ func RegisterServiceWorker() templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -func Styles(local bool) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var2 := templ.GetChildren(ctx) - if templ_7745c5c3_Var2 == nil { - templ_7745c5c3_Var2 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var3 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -88,146 +45,13 @@ func Styles(local bool) templ.Component { }() } ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return templ_7745c5c3_Err }) - templ_7745c5c3_Err = stylesHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -func Alpine(local bool) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var5 := templ.GetChildren(ctx) - if templ_7745c5c3_Var5 == nil { - templ_7745c5c3_Var5 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var6 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = alpineHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var6), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -func Htmx(local bool) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var8 := templ.GetChildren(ctx) - if templ_7745c5c3_Var8 == nil { - templ_7745c5c3_Var8 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var9 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = htmxHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = serviceWorkerHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/pkg/nebula/global/styles/head.templ b/pkg/nebula/global/styles/head.templ index 40083fadc..e93f8fc52 100644 --- a/pkg/nebula/global/styles/head.templ +++ b/pkg/nebula/global/styles/head.templ @@ -10,10 +10,6 @@ type Variant interface { Attributes() templ.Attributes } -var stylesHandle = templ.NewOnceHandle() -var alpineHandle = templ.NewOnceHandle() -var htmxHandle = templ.NewOnceHandle() - func clsxMerge(variants ...Variant) templ.Attributes { combinedAttrs := templ.Attributes{} var classElements []string @@ -50,24 +46,6 @@ templ Spacer() {
} -templ Styles(local bool) { - @stylesHandle.Once() { - - } -} - -templ Alpine(local bool) { - @alpineHandle.Once() { - - } -} - -templ Htmx(local bool) { - @htmxHandle.Once() { - - } -} - templ Rows() {
{ children... } diff --git a/pkg/nebula/global/styles/head_templ.go b/pkg/nebula/global/styles/head_templ.go index 935f8ca1b..ebb6deb23 100644 --- a/pkg/nebula/global/styles/head_templ.go +++ b/pkg/nebula/global/styles/head_templ.go @@ -18,10 +18,6 @@ type Variant interface { Attributes() templ.Attributes } -var stylesHandle = templ.NewOnceHandle() -var alpineHandle = templ.NewOnceHandle() -var htmxHandle = templ.NewOnceHandle() - func clsxMerge(variants ...Variant) templ.Attributes { combinedAttrs := templ.Attributes{} var classElements []string @@ -83,7 +79,7 @@ func Spacer() templ.Component { }) } -func Styles(local bool) templ.Component { +func Rows() templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -104,152 +100,11 @@ func Styles(local bool) templ.Component { templ_7745c5c3_Var2 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var3 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = stylesHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var3), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -func Alpine(local bool) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var4 := templ.GetChildren(ctx) - if templ_7745c5c3_Var4 == nil { - templ_7745c5c3_Var4 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var5 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = alpineHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var5), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -func Htmx(local bool) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var6 := templ.GetChildren(ctx) - if templ_7745c5c3_Var6 == nil { - templ_7745c5c3_Var6 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var7 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) - templ_7745c5c3_Err = htmxHandle.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return templ_7745c5c3_Err - }) -} - -func Rows() templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var8 := templ.GetChildren(ctx) - if templ_7745c5c3_Var8 == nil { - templ_7745c5c3_Var8 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templ_7745c5c3_Var8.Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = templ_7745c5c3_Var2.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -277,16 +132,16 @@ func Columns() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var9 := templ.GetChildren(ctx) - if templ_7745c5c3_Var9 == nil { - templ_7745c5c3_Var9 = templ.NopComponent + templ_7745c5c3_Var3 := templ.GetChildren(ctx) + if templ_7745c5c3_Var3 == nil { + templ_7745c5c3_Var3 = templ.NopComponent } ctx = templ.ClearChildren(ctx) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templ_7745c5c3_Var9.Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = templ_7745c5c3_Var3.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/pkg/nebula/global/styles/layout.templ b/pkg/nebula/global/styles/layout.templ index f56428d0f..b9e738fa2 100644 --- a/pkg/nebula/global/styles/layout.templ +++ b/pkg/nebula/global/styles/layout.templ @@ -1,12 +1,14 @@ package styles +import "github.com/onsonr/sonr/pkg/nebula/global/cdn" + templ Layout(title string, remote bool) { - @Alpine(remote) - @Htmx(remote) - @Styles(remote) + @cdn.Alpine() + @cdn.Htmx() + @cdn.Styles() @@ -28,9 +30,9 @@ templ LayoutNoBody(title string, remote bool) { - @Alpine(remote) - @Htmx(remote) - @Styles(remote) + @cdn.Alpine() + @cdn.Htmx() + @cdn.Styles() @@ -50,7 +52,6 @@ templ LayoutNoBody(title string, remote bool) { } - templ OpenModal(title, description string) {