frontend-hamroun 1.2.80 → 1.2.83
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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.client.cjs +1 -1
- package/dist/index.client.js +2 -2
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/{renderer-Din1y3YM.cjs → renderer-BL3gq8cW.cjs} +2 -2
- package/dist/{renderer-Din1y3YM.cjs.map → renderer-BL3gq8cW.cjs.map} +1 -1
- package/dist/{renderer-Bo9zkUZ_.js → renderer-Dyy-o05F.js} +2 -2
- package/dist/{renderer-Bo9zkUZ_.js.map → renderer-Dyy-o05F.js.map} +1 -1
- package/dist/{server-renderer-QHt45Ip2.js → server-renderer-C1WXH-zV.js} +99 -73
- package/dist/server-renderer-C1WXH-zV.js.map +1 -0
- package/dist/server-renderer-Chs-nmJm.cjs +2 -0
- package/dist/server-renderer-Chs-nmJm.cjs.map +1 -0
- package/dist/server-renderer.cjs +1 -1
- package/dist/server-renderer.js +1 -1
- package/package.json +1 -1
- package/templates/basic-app/src/App.jsx +16 -0
- package/templates/basic-app/src/client.jsx +5 -0
- package/templates/basic-app/src/components/Counter.jsx +13 -0
- package/templates/basic-app/src/jsx-shim.js +3 -0
- package/templates/basic-app/src/jsx-shim.ts +7 -0
- package/templates/basic-app/src/main.jsx +98 -0
- package/templates/basic-app/src/server.js +47 -0
- package/templates/complete-app/api/hello.js +0 -0
- package/templates/complete-app/lib/frontend-hamroun.js +182 -0
- package/templates/complete-app/package.json +18 -0
- package/templates/complete-app/pages/about.js +119 -0
- package/templates/complete-app/pages/about.jsx +0 -0
- package/templates/complete-app/pages/index.js +157 -0
- package/templates/complete-app/pages/index.jsx +0 -0
- package/templates/complete-app/pages/wasm-demo.js +290 -0
- package/templates/complete-app/pages/wasm-demo.jsx +0 -0
- package/templates/complete-app/public/client.js +89 -0
- package/templates/complete-app/public/index.html +118 -0
- package/templates/complete-app/public/styles.css +76 -0
- package/templates/complete-app/server.js +226 -0
- package/templates/complete-app/src/App.tsx +59 -0
- package/templates/complete-app/src/client.tsx +18 -0
- package/templates/complete-app/src/server.ts +218 -0
- package/templates/complete-app/tsconfig.json +22 -0
- package/templates/complete-app/tsconfig.server.json +19 -0
- package/templates/{ssr-template → complete-app}/vite.config.js +16 -5
- package/templates/complete-app/vite.config.ts +30 -0
- package/templates/complete-app/wasm/build.bat +0 -0
- package/templates/complete-app/wasm/build.sh +0 -0
- package/templates/complete-app/wasm/example.go +0 -0
- package/templates/fullstack-app/build/main.css +874 -874
- package/templates/fullstack-app/build/main.css.map +7 -7
- package/templates/fullstack-app/build/main.js +996 -967
- package/templates/fullstack-app/build/main.js.map +7 -7
- package/templates/fullstack-app/package-lock.json +6301 -0
- package/templates/fullstack-app/public/styles.css +768 -768
- package/templates/go/example.go +154 -99
- package/templates/ssr-template/dist/client/assets/main-D-VH3xOb.js +1 -0
- package/templates/ssr-template/dist/client/index.html +23 -0
- package/templates/ssr-template/dist/client.js +951 -0
- package/templates/ssr-template/dist/server.js +739 -0
- package/templates/ssr-template/esbuild.config.js +33 -0
- package/templates/ssr-template/jsx-shim.js +1 -0
- package/templates/ssr-template/package.json +14 -8
- package/templates/ssr-template/src/App.tsx +847 -49
- package/templates/ssr-template/src/client.tsx +3 -17
- package/templates/ssr-template/src/server.ts +21 -204
- package/templates/ssr-template/tsconfig.json +9 -8
- package/templates/ssr-template/tsconfig.server.json +6 -14
- package/templates/ssr-template/vite.config.ts +19 -17
- package/templates/wasm/build-wasm.js +228 -0
- package/templates/wasm/dist/assets/index-BNqTDBdE.js +295 -0
- package/templates/wasm/dist/example.wasm +0 -0
- package/templates/wasm/dist/index.html +53 -0
- package/templates/{go-wasm-app/public/wasm → wasm/dist}/wasm_exec.js +572 -561
- package/templates/wasm/esbuild.config.js +63 -0
- package/templates/wasm/go/main.go +256 -0
- package/templates/wasm/go/wasm_exec.js +0 -0
- package/templates/wasm/index.html +97 -0
- package/templates/wasm/jsx-shim.js +9 -0
- package/templates/wasm/package-lock.json +4577 -0
- package/templates/wasm/package.json +25 -0
- package/templates/wasm/public/example.wasm +0 -0
- package/templates/wasm/public/wasm_exec.js +572 -0
- package/templates/wasm/src/App.tsx +550 -0
- package/templates/wasm/src/client.tsx +220 -0
- package/templates/wasm/src/index.tsx +21 -0
- package/templates/wasm/src/server.ts +145 -0
- package/templates/wasm/tsconfig.json +21 -0
- package/templates/wasm/tsconfig.node.json +13 -0
- package/templates/wasm/tsconfig.server.json +23 -0
- package/templates/wasm/vite.config.ts +38 -0
- package/templates/wasm/wasm-loader.js +103 -0
- package/dist/server-renderer-CqIpQ-od.cjs +0 -2
- package/dist/server-renderer-CqIpQ-od.cjs.map +0 -1
- package/dist/server-renderer-QHt45Ip2.js.map +0 -1
- package/templates/basic-app/bun.lock +0 -196
- package/templates/basic-app/docs/rapport_pfe.aux +0 -27
- package/templates/basic-app/docs/rapport_pfe.out +0 -10
- package/templates/basic-app/docs/rapport_pfe.pdf +0 -0
- package/templates/basic-app/docs/rapport_pfe.tex +0 -68
- package/templates/basic-app/docs/rapport_pfe.toc +0 -14
- package/templates/basic-app/package-lock.json +0 -4185
- package/templates/go-wasm-app/README.md +0 -38
- package/templates/go-wasm-app/babel.config.js +0 -15
- package/templates/go-wasm-app/build-client.js +0 -49
- package/templates/go-wasm-app/build-wasm.js +0 -237
- package/templates/go-wasm-app/package.json +0 -23
- package/templates/go-wasm-app/public/index.html +0 -128
- package/templates/go-wasm-app/public/styles.css +0 -197
- package/templates/go-wasm-app/public/wasm/example.wasm +0 -0
- package/templates/go-wasm-app/public/wasm/wasm_exec_node.js +0 -39
- package/templates/go-wasm-app/server.js +0 -521
- package/templates/go-wasm-app/src/App.jsx +0 -38
- package/templates/go-wasm-app/src/app.js +0 -153
- package/templates/go-wasm-app/src/client.js +0 -57
- package/templates/go-wasm-app/src/components/Footer.jsx +0 -13
- package/templates/go-wasm-app/src/components/Header.jsx +0 -19
- package/templates/go-wasm-app/src/components/WasmDemo.jsx +0 -120
- package/templates/go-wasm-app/src/main.jsx +0 -12
- package/templates/go-wasm-app/src/wasm/example.go +0 -75
- package/templates/go-wasm-app/tsconfig.server.json +0 -18
- package/templates/go-wasm-app/vite.config.js +0 -34
- package/templates/ssr-template/package-lock.json +0 -2478
- package/templates/ssr-template/public/index.html +0 -47
- package/templates/ssr-template/server.js +0 -369
- /package/templates/{ssr-template → complete-app}/client.js +0 -0
- /package/templates/{ssr-template → complete-app}/readme.md +0 -0
- /package/templates/{ssr-template → complete-app}/server.ts +0 -0
- /package/templates/{ssr-template → complete-app}/src/client.ts +0 -0
- /package/templates/{ssr-template → complete-app}/src/pages/index.tsx +0 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
import esbuild from 'esbuild';
|
2
|
+
import { fileURLToPath } from 'url';
|
3
|
+
import { dirname, join } from 'path';
|
4
|
+
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
6
|
+
const __dirname = dirname(__filename);
|
7
|
+
|
8
|
+
// Build client
|
9
|
+
await esbuild.build({
|
10
|
+
entryPoints: ['src/client.tsx'],
|
11
|
+
bundle: true,
|
12
|
+
outfile: 'dist/client.js',
|
13
|
+
platform: 'browser',
|
14
|
+
format: 'esm',
|
15
|
+
minify: false,
|
16
|
+
jsx: 'transform',
|
17
|
+
jsxFactory: 'jsx',
|
18
|
+
jsxFragment: 'Fragment',
|
19
|
+
inject: ['./jsx-shim.js'],
|
20
|
+
});
|
21
|
+
|
22
|
+
// Build server
|
23
|
+
await esbuild.build({
|
24
|
+
entryPoints: ['src/server.ts'],
|
25
|
+
bundle: true,
|
26
|
+
outfile: 'dist/server.js',
|
27
|
+
platform: 'node',
|
28
|
+
format: 'esm',
|
29
|
+
external: ['frontend-hamroun'],
|
30
|
+
packages: 'external',
|
31
|
+
minify: false,
|
32
|
+
jsx: 'transform',
|
33
|
+
jsxFactory: 'jsx',
|
34
|
+
jsxFragment: 'Fragment',
|
35
|
+
inject: ['./jsx-shim.js'],
|
36
|
+
});
|
37
|
+
|
38
|
+
const config = {
|
39
|
+
entryPoints: ['src/index.js'],
|
40
|
+
bundle: true,
|
41
|
+
outfile: 'dist/bundle.js',
|
42
|
+
format: 'esm',
|
43
|
+
target: 'es2020',
|
44
|
+
minify: process.env.NODE_ENV === 'production',
|
45
|
+
sourcemap: process.env.NODE_ENV !== 'production',
|
46
|
+
platform: 'browser',
|
47
|
+
loader: {
|
48
|
+
'.wasm': 'file'
|
49
|
+
},
|
50
|
+
external: [],
|
51
|
+
define: {
|
52
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
|
53
|
+
}
|
54
|
+
};
|
55
|
+
|
56
|
+
if (process.argv.includes('--watch')) {
|
57
|
+
const ctx = await esbuild.context(config);
|
58
|
+
await ctx.watch();
|
59
|
+
console.log('Watching for changes...');
|
60
|
+
} else {
|
61
|
+
await esbuild.build(config);
|
62
|
+
console.log('Build complete!');
|
63
|
+
}
|
@@ -0,0 +1,256 @@
|
|
1
|
+
package main
|
2
|
+
|
3
|
+
import (
|
4
|
+
"fmt"
|
5
|
+
"strings"
|
6
|
+
"syscall/js"
|
7
|
+
)
|
8
|
+
|
9
|
+
// Global variable to hold JS values for complex data exchange
|
10
|
+
var jsGlobal = js.Global()
|
11
|
+
|
12
|
+
// Hello function - greeting with name
|
13
|
+
func goHello(this js.Value, args []js.Value) interface{} {
|
14
|
+
if len(args) != 1 {
|
15
|
+
return js.ValueOf("Error: goHello requires exactly 1 argument")
|
16
|
+
}
|
17
|
+
|
18
|
+
name := args[0].String()
|
19
|
+
result := fmt.Sprintf("Hello, %s from Go WASM!", name)
|
20
|
+
|
21
|
+
fmt.Printf("Go WASM: goHello('%s') = '%s'\n", name, result)
|
22
|
+
return js.ValueOf(result)
|
23
|
+
}
|
24
|
+
|
25
|
+
// Add function - simple arithmetic
|
26
|
+
func goAdd(this js.Value, args []js.Value) interface{} {
|
27
|
+
if len(args) != 2 {
|
28
|
+
return js.ValueOf("Error: goAdd requires exactly 2 arguments")
|
29
|
+
}
|
30
|
+
|
31
|
+
a := args[0].Float()
|
32
|
+
b := args[1].Float()
|
33
|
+
result := a + b
|
34
|
+
|
35
|
+
fmt.Printf("Go WASM: goAdd(%f, %f) = %f\n", a, b, result)
|
36
|
+
return js.ValueOf(result)
|
37
|
+
}
|
38
|
+
|
39
|
+
// Multiply function - simple arithmetic
|
40
|
+
func goMultiply(this js.Value, args []js.Value) interface{} {
|
41
|
+
if len(args) != 2 {
|
42
|
+
return js.ValueOf("Error: goMultiply requires exactly 2 arguments")
|
43
|
+
}
|
44
|
+
|
45
|
+
a := args[0].Float()
|
46
|
+
b := args[1].Float()
|
47
|
+
result := a * b
|
48
|
+
|
49
|
+
fmt.Printf("Go WASM: goMultiply(%f, %f) = %f\n", a, b, result)
|
50
|
+
return js.ValueOf(result)
|
51
|
+
}
|
52
|
+
|
53
|
+
// Fibonacci function - recursive computation
|
54
|
+
func goFibonacci(this js.Value, args []js.Value) interface{} {
|
55
|
+
if len(args) != 1 {
|
56
|
+
return js.ValueOf("Error: goFibonacci requires exactly 1 argument")
|
57
|
+
}
|
58
|
+
|
59
|
+
n := int(args[0].Float())
|
60
|
+
if n < 0 {
|
61
|
+
return js.ValueOf("Error: goFibonacci requires non-negative number")
|
62
|
+
}
|
63
|
+
|
64
|
+
result := fibonacciCalc(n)
|
65
|
+
fmt.Printf("Go WASM: goFibonacci(%d) = %d\n", n, result)
|
66
|
+
return js.ValueOf(result)
|
67
|
+
}
|
68
|
+
|
69
|
+
// Prime check function
|
70
|
+
func goIsPrime(this js.Value, args []js.Value) interface{} {
|
71
|
+
if len(args) != 1 {
|
72
|
+
return js.ValueOf("Error: goIsPrime requires exactly 1 argument")
|
73
|
+
}
|
74
|
+
|
75
|
+
n := int(args[0].Float())
|
76
|
+
if n < 2 {
|
77
|
+
return js.ValueOf(false)
|
78
|
+
}
|
79
|
+
if n == 2 {
|
80
|
+
return js.ValueOf(true)
|
81
|
+
}
|
82
|
+
if n%2 == 0 {
|
83
|
+
return js.ValueOf(false)
|
84
|
+
}
|
85
|
+
|
86
|
+
for i := 3; i*i <= n; i += 2 {
|
87
|
+
if n%i == 0 {
|
88
|
+
return js.ValueOf(false)
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
fmt.Printf("Go WASM: goIsPrime(%d) = %t\n", n, true)
|
93
|
+
return js.ValueOf(true)
|
94
|
+
}
|
95
|
+
|
96
|
+
// Helper function for fibonacci calculation
|
97
|
+
func fibonacciCalc(n int) int {
|
98
|
+
if n <= 1 {
|
99
|
+
return n
|
100
|
+
}
|
101
|
+
|
102
|
+
a, b := 0, 1
|
103
|
+
for i := 2; i <= n; i++ {
|
104
|
+
a, b = b, a+b
|
105
|
+
}
|
106
|
+
return b
|
107
|
+
}
|
108
|
+
|
109
|
+
// Process array function - demonstrates array handling
|
110
|
+
func goProcessArray(this js.Value, args []js.Value) interface{} {
|
111
|
+
if len(args) != 1 {
|
112
|
+
return js.ValueOf("Error: goProcessArray requires exactly 1 argument")
|
113
|
+
}
|
114
|
+
|
115
|
+
jsArray := args[0]
|
116
|
+
if jsArray.Type() != js.TypeObject {
|
117
|
+
return js.ValueOf("Error: argument must be an array")
|
118
|
+
}
|
119
|
+
|
120
|
+
length := jsArray.Get("length").Int()
|
121
|
+
goSlice := make([]int, length)
|
122
|
+
|
123
|
+
// Convert JS array to Go slice
|
124
|
+
for i := 0; i < length; i++ {
|
125
|
+
goSlice[i] = int(jsArray.Index(i).Float())
|
126
|
+
}
|
127
|
+
|
128
|
+
// Process the slice (double each element and add index)
|
129
|
+
processedSlice := make([]interface{}, length)
|
130
|
+
for i, val := range goSlice {
|
131
|
+
processedSlice[i] = (val * 2) + i
|
132
|
+
}
|
133
|
+
|
134
|
+
fmt.Printf("Go WASM: goProcessArray([%s]) = [", strings.Trim(fmt.Sprint(goSlice), "[]"))
|
135
|
+
for i, val := range processedSlice {
|
136
|
+
if i > 0 {
|
137
|
+
fmt.Printf(" ")
|
138
|
+
}
|
139
|
+
fmt.Printf("%v", val)
|
140
|
+
}
|
141
|
+
fmt.Printf("]\n")
|
142
|
+
|
143
|
+
// Convert back to JS array
|
144
|
+
result := jsGlobal.Get("Array").New(length)
|
145
|
+
for i, val := range processedSlice {
|
146
|
+
result.SetIndex(i, val)
|
147
|
+
}
|
148
|
+
|
149
|
+
return result
|
150
|
+
}
|
151
|
+
|
152
|
+
// Calculate PI using series approximation
|
153
|
+
func goCalculatePI(this js.Value, args []js.Value) interface{} {
|
154
|
+
if len(args) != 1 {
|
155
|
+
return js.ValueOf("Error: goCalculatePI requires exactly 1 argument")
|
156
|
+
}
|
157
|
+
|
158
|
+
iterations := int(args[0].Float())
|
159
|
+
pi := 0.0
|
160
|
+
|
161
|
+
for i := 0; i < iterations; i++ {
|
162
|
+
term := 1.0 / float64(2*i+1)
|
163
|
+
if i%2 == 1 {
|
164
|
+
term = -term
|
165
|
+
}
|
166
|
+
pi += term
|
167
|
+
}
|
168
|
+
|
169
|
+
result := pi * 4
|
170
|
+
fmt.Printf("Go WASM: goCalculatePI(%d iterations) = %f\n", iterations, result)
|
171
|
+
return js.ValueOf(result)
|
172
|
+
}
|
173
|
+
|
174
|
+
// Performance benchmark function
|
175
|
+
func goPerformanceBenchmark(this js.Value, args []js.Value) interface{} {
|
176
|
+
if len(args) != 1 {
|
177
|
+
return js.ValueOf("Error: goPerformanceBenchmark requires exactly 1 argument")
|
178
|
+
}
|
179
|
+
|
180
|
+
iterations := int(args[0].Float())
|
181
|
+
|
182
|
+
// Simple computational benchmark
|
183
|
+
sum := 0
|
184
|
+
for i := 0; i < iterations; i++ {
|
185
|
+
sum += i * i
|
186
|
+
}
|
187
|
+
|
188
|
+
// Convert Go map to JS object
|
189
|
+
jsResult := jsGlobal.Get("Object").New()
|
190
|
+
jsResult.Set("iterations", js.ValueOf(iterations))
|
191
|
+
jsResult.Set("result", js.ValueOf(sum))
|
192
|
+
jsResult.Set("message", js.ValueOf(fmt.Sprintf("Completed %d iterations in Go WASM", iterations)))
|
193
|
+
|
194
|
+
fmt.Printf("Go WASM: goPerformanceBenchmark(%d) = %d\n", iterations, sum)
|
195
|
+
return jsResult
|
196
|
+
}
|
197
|
+
|
198
|
+
// String utilities function
|
199
|
+
func goStringUtils(this js.Value, args []js.Value) interface{} {
|
200
|
+
if len(args) != 1 {
|
201
|
+
return js.ValueOf("Error: goStringUtils requires exactly 1 argument")
|
202
|
+
}
|
203
|
+
|
204
|
+
input := args[0].String()
|
205
|
+
|
206
|
+
// Create result object with various string operations
|
207
|
+
result := jsGlobal.Get("Object").New()
|
208
|
+
result.Set("original", js.ValueOf(input))
|
209
|
+
result.Set("uppercase", js.ValueOf(strings.ToUpper(input)))
|
210
|
+
result.Set("lowercase", js.ValueOf(strings.ToLower(input)))
|
211
|
+
result.Set("reversed", js.ValueOf(reverseString(input)))
|
212
|
+
result.Set("length", js.ValueOf(len(input)))
|
213
|
+
result.Set("wordCount", js.ValueOf(len(strings.Fields(input))))
|
214
|
+
|
215
|
+
fmt.Printf("Go WASM: goStringUtils('%s') completed\n", input)
|
216
|
+
return result
|
217
|
+
}
|
218
|
+
|
219
|
+
// Helper function to reverse a string
|
220
|
+
func reverseString(s string) string {
|
221
|
+
runes := []rune(s)
|
222
|
+
for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
|
223
|
+
runes[i], runes[j] = runes[j], runes[i]
|
224
|
+
}
|
225
|
+
return string(runes)
|
226
|
+
}
|
227
|
+
|
228
|
+
// Initialize and register functions
|
229
|
+
func main() {
|
230
|
+
fmt.Println("🚀 Go WASM module initializing...")
|
231
|
+
|
232
|
+
// Register all functions to the global JS scope with "go" prefix
|
233
|
+
jsGlobal.Set("goHello", js.FuncOf(goHello))
|
234
|
+
jsGlobal.Set("goAdd", js.FuncOf(goAdd))
|
235
|
+
jsGlobal.Set("goMultiply", js.FuncOf(goMultiply))
|
236
|
+
jsGlobal.Set("goFibonacci", js.FuncOf(goFibonacci))
|
237
|
+
jsGlobal.Set("goIsPrime", js.FuncOf(goIsPrime))
|
238
|
+
jsGlobal.Set("goProcessArray", js.FuncOf(goProcessArray))
|
239
|
+
jsGlobal.Set("goCalculatePI", js.FuncOf(goCalculatePI))
|
240
|
+
jsGlobal.Set("goPerformanceBenchmark", js.FuncOf(goPerformanceBenchmark))
|
241
|
+
jsGlobal.Set("goStringUtils", js.FuncOf(goStringUtils))
|
242
|
+
|
243
|
+
fmt.Println("✅ Go WASM functions registered:")
|
244
|
+
fmt.Println(" • goHello(name) - Greeting function")
|
245
|
+
fmt.Println(" • goAdd(a, b) - Addition")
|
246
|
+
fmt.Println(" • goMultiply(a, b) - Multiplication")
|
247
|
+
fmt.Println(" • goFibonacci(n) - Fibonacci sequence")
|
248
|
+
fmt.Println(" • goIsPrime(n) - Prime number check")
|
249
|
+
fmt.Println(" • goProcessArray(arr) - Array processing")
|
250
|
+
fmt.Println(" • goCalculatePI(iterations) - PI calculation")
|
251
|
+
fmt.Println(" • goPerformanceBenchmark(n) - Performance testing")
|
252
|
+
fmt.Println(" • goStringUtils(str) - String utilities")
|
253
|
+
|
254
|
+
// Keep the program running
|
255
|
+
select {}
|
256
|
+
}
|
File without changes
|
@@ -0,0 +1,97 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>Frontend Hamroun + Go WASM</title>
|
7
|
+
<style>
|
8
|
+
body {
|
9
|
+
margin: 0;
|
10
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
.loading-fallback {
|
14
|
+
display: flex;
|
15
|
+
justify-content: center;
|
16
|
+
align-items: center;
|
17
|
+
min-height: 100vh;
|
18
|
+
flex-direction: column;
|
19
|
+
background: #f7f7f7;
|
20
|
+
}
|
21
|
+
|
22
|
+
.loading-spinner {
|
23
|
+
width: 40px;
|
24
|
+
height: 40px;
|
25
|
+
border: 4px solid #f3f3f3;
|
26
|
+
border-top: 4px solid #007acc;
|
27
|
+
border-radius: 50%;
|
28
|
+
animation: spin 1s linear infinite;
|
29
|
+
margin-bottom: 20px;
|
30
|
+
}
|
31
|
+
|
32
|
+
@keyframes spin {
|
33
|
+
0% { transform: rotate(0deg); }
|
34
|
+
100% { transform: rotate(360deg); }
|
35
|
+
}
|
36
|
+
</style>
|
37
|
+
</head>
|
38
|
+
<body>
|
39
|
+
<div id="app">
|
40
|
+
<div class="loading-fallback">
|
41
|
+
<div class="loading-spinner"></div>
|
42
|
+
<h2>Loading Frontend Hamroun + WASM...</h2>
|
43
|
+
<p>Initializing application and WebAssembly runtime...</p>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<!-- Go WASM Runtime -->
|
48
|
+
<script src="/wasm_exec.js"></script>
|
49
|
+
|
50
|
+
<!-- Application -->
|
51
|
+
<script type="module">
|
52
|
+
import { jsx, render } from 'frontend-hamroun';
|
53
|
+
import App from './src/App.tsx';
|
54
|
+
|
55
|
+
// Wait for WASM runtime to be available
|
56
|
+
function waitForGo() {
|
57
|
+
return new Promise((resolve) => {
|
58
|
+
if (window.Go) {
|
59
|
+
resolve();
|
60
|
+
} else {
|
61
|
+
setTimeout(() => waitForGo().then(resolve), 50);
|
62
|
+
}
|
63
|
+
});
|
64
|
+
}
|
65
|
+
|
66
|
+
async function startApp() {
|
67
|
+
try {
|
68
|
+
// Wait for Go WASM runtime
|
69
|
+
await waitForGo();
|
70
|
+
|
71
|
+
// Render the app
|
72
|
+
const appElement = jsx(App, {});
|
73
|
+
render(appElement, document.getElementById('app'));
|
74
|
+
} catch (error) {
|
75
|
+
console.error('Failed to start app:', error);
|
76
|
+
document.getElementById('app').innerHTML = `
|
77
|
+
<div class="loading-fallback">
|
78
|
+
<h2 style="color: #dc2626;">Application Error</h2>
|
79
|
+
<p>Failed to initialize the application. Check the console for more details.</p>
|
80
|
+
<button onclick="window.location.reload()" style="
|
81
|
+
background: #007acc;
|
82
|
+
color: white;
|
83
|
+
border: none;
|
84
|
+
padding: 10px 20px;
|
85
|
+
border-radius: 5px;
|
86
|
+
cursor: pointer;
|
87
|
+
margin-top: 10px;
|
88
|
+
">Reload Page</button>
|
89
|
+
</div>
|
90
|
+
`;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
|
94
|
+
startApp();
|
95
|
+
</script>
|
96
|
+
</body>
|
97
|
+
</html>
|