Skip to content

Commit

Permalink
feat: integrate nebula UI with worker-assets-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
prnk28 committed Oct 8, 2024
1 parent e926e5b commit af6e073
Show file tree
Hide file tree
Showing 22 changed files with 114 additions and 101 deletions.
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,7 @@ testnet-basic: setup-testnet
sh-testnet: mod-tidy
CHAIN_ID="sonr-testnet-1" BLOCK_TIME="1000ms" CLEAN=true sh scripts/test_node.sh

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
.PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet


###############################################################################
Expand Down Expand Up @@ -323,11 +319,13 @@ gen-pkl:

build-hway: gen-templ gen-pkl
@echo "(motr) Building Highway gateway"
go build -o ./build/hway ./cmd/hway
go run github.com/syumai/workers/cmd/[email protected] -o ./web/build -mode go
GOOS=js GOARCH=wasm go build -o ./web/build/app.wasm ./web/server.go


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
GOOS=js GOARCH=wasm go build -o ./pkg/dwn/app.wasm ./pkg/dwn/wasm/main.go

build-nebula:
@echo "(nebula) Building nebula"
Expand Down
10 changes: 0 additions & 10 deletions cmd/hway/commands/root.go

This file was deleted.

18 changes: 0 additions & 18 deletions cmd/hway/commands/start.go

This file was deleted.

13 changes: 0 additions & 13 deletions cmd/hway/main.go

This file was deleted.

40 changes: 0 additions & 40 deletions cmd/hway/server/server.go

This file was deleted.

9 changes: 0 additions & 9 deletions deploy/process-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ processes:
depends:
- ipfs

hway:
namespace: testnet
command: "devbox run start:hway"
restart: on_failure
max_restarts: 1
depends:
- ipfs
- sonr

tunnel:
namespace: public
command: "cloudflared tunnel run --token $TUNNEL_TOKEN"
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ require (
github.com/strangelove-ventures/poa v0.50.0
github.com/strangelove-ventures/tokenfactory v0.50.0
github.com/stretchr/testify v1.9.0
github.com/syumai/workers v0.26.3
golang.org/x/crypto v0.26.0
google.golang.org/genproto/googleapis/api v0.0.0-20240617180043-68d350f18fd4
google.golang.org/grpc v1.64.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,8 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
github.com/syumai/workers v0.26.3 h1:AF+IBaRccbR4JIj2kNJLJblruPFMD/pAbzkopejGcP8=
github.com/syumai/workers v0.26.3/go.mod h1:ZnqmdiHNBrbxOLrZ/HJ5jzHy6af9cmiNZk10R9NrIEA=
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI=
Expand Down
18 changes: 18 additions & 0 deletions internal/channel/broadcast.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//go:build js && wasm

package channel

import (
"syscall/js"

"github.com/labstack/echo/v4"
)

type BroadcastContext struct {
echo.Context
Channel js.Value
}

func (c *BroadcastContext) BroadcastMessage(message string) {
c.Channel.Call("postMessage", message)
}
35 changes: 35 additions & 0 deletions internal/channel/middleware.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//go:build js && wasm

package channel

import (
"syscall/js"

"github.com/labstack/echo/v4"
)

type JSHandler func(this js.Value, args []js.Value) interface{}

func UseBroadcastChannel(channelName string, handler JSHandler) echo.MiddlewareFunc {
var channel js.Value

return func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
if channel.IsUndefined() {
channel = js.Global().Get("BroadcastChannel").New(channelName)
channel.Call("addEventListener", "message", handler)
}

cc := &BroadcastContext{
Context: c,
Channel: channel,
}
return next(cc)
}
}
}

func PostBroadcastMessage(c echo.Context, message string) {
cc := c.(*BroadcastContext)
cc.BroadcastMessage(message)
}
2 changes: 1 addition & 1 deletion internal/auth/macaroon.go → internal/swtkn/macaroon.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package auth
package swt

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package auth
package swt

import (
"net/http"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pkg/nebula/global/state/credentials_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/nebula/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "nebula",
"name": "@onsonr/nebula",
"version": "0.0.2",
"scripts": {
"fetch:deps": "bun run .deps.mjs",
Expand Down
23 changes: 23 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@onsonr/sonr.id",
"version": "0.0.2",
"scripts": {
"fetch:deps": "bun run .deps.mjs",
"build:css": "bunx tailwindcss -i ./global/styles/globals.css -o ./assets/css/styles.css",
"build": "bun run fetch:deps && bun run build:css",
"watch": "bunx tailwindcss -i ./global/styles/globals.css -o ./assets/css/styles.css --watch"
},
"devDependencies": {
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "^0.5.15",
"alpinejs": "^3.14.1",
"htmx.org": "^1.9.12",
"tailwindcss": "^3.3.0",
"tailwindcss-motion": "^0.3.0-beta",
"typescript": "^4.9.0"
},
"dependencies": {
"node-fetch": "^3.3.2",
"sonr-es": "^0.5.3"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions web/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//go:build js && wasm

package main

import (
"github.com/labstack/echo/v4"
"github.com/onsonr/sonr/internal/session"
"github.com/onsonr/sonr/pkg/nebula/routes"
"github.com/syumai/workers"
)

func main() {
s := echo.New()
s.Use(session.UseSession)

s.GET("/", routes.Home)
s.GET("/login", routes.LoginStart)
s.GET("/register", routes.RegisterStart)
workers.Serve(s)
}
6 changes: 6 additions & 0 deletions web/wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name = "sonr-id"
main = "./build/worker.mjs"
compatibility_date = "2024-10-07"

[build]
command = "devbox run build:hway"

0 comments on commit af6e073

Please sign in to comment.