frontend-hamroun 1.2.67 → 1.2.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,75 +0,0 @@
1
- //go:build js && wasm
2
- // +build js,wasm
3
-
4
- package main
5
-
6
- import (
7
- "encoding/json"
8
- "fmt"
9
- "syscall/js"
10
- )
11
-
12
- // Example Go function to be called from JavaScript
13
- func add(this js.Value, args []js.Value) interface{} {
14
- if len(args) != 2 {
15
- return js.ValueOf("Error: Expected two arguments")
16
- }
17
-
18
- a := args[0].Int()
19
- b := args[1].Int()
20
- return js.ValueOf(a + b)
21
- }
22
-
23
- // Process complex data in Go
24
- func processData(this js.Value, args []js.Value) interface{} {
25
- if len(args) == 0 {
26
- return js.ValueOf("Error: Expected at least one argument")
27
- }
28
-
29
- // Get input data
30
- data := args[0]
31
- if data.Type() != js.TypeObject {
32
- return js.ValueOf("Error: Expected JSON object")
33
- }
34
-
35
- // Convert JS object to Go map
36
- jsonStr := js.Global().Get("JSON").Call("stringify", data).String()
37
- var inputMap map[string]interface{}
38
- if err := json.Unmarshal([]byte(jsonStr), &inputMap); err != nil {
39
- return js.ValueOf(fmt.Sprintf("Error parsing JSON: %s", err.Error()))
40
- }
41
-
42
- // Add new fields
43
- inputMap["processed"] = true
44
- inputMap["processor"] = "Go WASM"
45
-
46
- // Add some computed fields
47
- if values, ok := inputMap["values"].([]interface{}); ok {
48
- sum := 0.0
49
- for _, v := range values {
50
- if num, ok := v.(float64); ok {
51
- sum += num
52
- }
53
- }
54
- inputMap["sum"] = sum
55
- }
56
-
57
- // Convert back to JS
58
- resultJSON, err := json.Marshal(inputMap)
59
- if err != nil {
60
- return js.ValueOf(fmt.Sprintf("Error generating JSON: %s", err.error()))
61
- }
62
-
63
- return js.ValueOf(string(resultJSON))
64
- }
65
-
66
- func main() {
67
- fmt.Println("Go WASM Module initialized")
68
-
69
- // Register functions to be callable from JavaScript
70
- js.Global().Set("goAdd", js.FuncOf(add))
71
- js.Global().Set("goProcessData", js.FuncOf(processData))
72
-
73
- // Keep the program running
74
- <-make(chan bool)
75
- }
@@ -1,3 +0,0 @@
1
- module wasmapp
2
-
3
- go 1.23.6
@@ -1,21 +0,0 @@
1
- # Frontend Hamroun - Go WebAssembly Template
2
-
3
- This template demonstrates integration between Frontend Hamroun and Go WebAssembly for high-performance web applications.
4
-
5
- ## Features
6
-
7
- - 🔄 Go + WebAssembly integration
8
- - ⚡ High-performance computation in the browser
9
- - 🔍 Typed API for Go WASM functions
10
- - 🔧 Automated build process for Go code
11
- - 🧩 Example Go WASM modules and usage
12
-
13
- ## Prerequisites
14
-
15
- - [Node.js](https://nodejs.org/) (v14+)
16
- - [Go](https://golang.org/dl/) (v1.16+)
17
-
18
- ## Getting Started
19
-
20
- 1. Install dependencies:
21
-