Skip to content

Commit

Permalink
Merge pull request #92 from realPy/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
realPy authored Oct 23, 2021
2 parents 8147e79 + c6447da commit 07ea5ca
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,22 @@ Use Go compiler for developpement (faster) and tinygo for production
When your compile your project you must provide the wasm_exec.js corresponding with your current compiler.
If you upgrade your compiler dont forget to copy the new wasm_exec.js that target your compiler.

### Start with docker and tinygo
### Live testing thanks to wasmbrowsertest


You can live testing your code thanks to https://github.com/agnivade/wasmbrowsertest

Follow the quick start guide https://github.com/agnivade/wasmbrowsertest#quickstart

and go run your project or some example

```
WASM_HEADLESS=off GOOS=js GOARCH=wasm go run example/hello/main.go
```

The hello world is open on your browser

### building with tinygo

Start the tinygo container with your source
```
Expand All @@ -49,6 +64,18 @@ apt-get update
apt-get install make
```

### building with Go

Just

```
GOOS=js GOARCH=wasm go build -o ./example/static/hello.wasm example/hello/main.go
```

dont forget to always include the wasm_exec.js from your go compiler
```
cp $(go env GOROOT)/misc/wasm/wasm_exec.js example/static/
```

## How to load the wasm product with a web application

Expand Down Expand Up @@ -105,6 +132,7 @@ runWasmAdd();
```
Just replace the "example.wasm" with the relative (or absolute) link of you binary wasm


## Why there is so many directory in hogosuru ?

Hogosuru is splitted in several directory for each components for a specific reason:
Expand Down
8 changes: 4 additions & 4 deletions document/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/realPy/hogosuru/element"
"github.com/realPy/hogosuru/htmlcollection"
"github.com/realPy/hogosuru/node"
"github.com/realPy/hogosuru/htmlelement"
)

func (d Document) getAttributeElement(attribute string) (element.Element, error) {
Expand Down Expand Up @@ -40,14 +40,14 @@ func (d Document) ActiveElement() (element.Element, error) {

}

func (d Document) Body() (node.Node, error) {
var body node.Node
func (d Document) Body() (htmlelement.HtmlElement, error) {
var body htmlelement.HtmlElement
var bodyObject js.Value
var err error

if bodyObject, err = d.Get("body"); err == nil {

body, err = node.NewFromJSObject(bodyObject)
body, err = htmlelement.NewFromJSObject(bodyObject)

}

Expand Down
4 changes: 2 additions & 2 deletions document/chaining.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package document

import (
"github.com/realPy/hogosuru/node"
"github.com/realPy/hogosuru/htmlelement"
"github.com/realPy/hogosuru/nodelist"
)

Expand All @@ -10,7 +10,7 @@ func New_() Document {
return d
}

func (d Document) Body_() node.Node {
func (d Document) Body_() htmlelement.HtmlElement {
body, _ := d.Body()
return body
}
Expand Down
4 changes: 2 additions & 2 deletions routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (r *RouteMap) DefaultRendering(obj Rendering) {
func (r *RouteMap) loadDefaultRendering() {
if d, err := document.New(); AssertErr(err) {
if body, err := d.Body(); AssertErr(err) {
r.loadChilds(d, r.defaultRendering, body)
r.loadChilds(d, r.defaultRendering, body.Node)
}
}
}
Expand Down Expand Up @@ -213,7 +213,7 @@ func (r *RouteMap) LoadRendering(obj Rendering) {
r.loadChilds(d, obj, r.defaultRendering.Node(r.defaultRendering))
} else {
if body, err := d.Body(); err == nil {
r.loadChilds(d, obj, body)
r.loadChilds(d, obj, body.Node)

}
}
Expand Down

0 comments on commit 07ea5ca

Please sign in to comment.