baraqex 1.0.47 → 1.0.49
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.js +236 -189
- package/dist/index.js.map +4 -4
- package/dist/server.js +1282 -864
- package/dist/server.js.map +4 -4
- package/package.json +1 -1
- package/templates/fullstack-template/package-lock.json +931 -4
- package/templates/fullstack-template/package.json +7 -5
- package/templates/fullstack-template/server.js +548 -15
- package/templates/fullstack-template/src/api/hello.js +9 -11
- package/templates/fullstack-template/src/pages/index.js +196 -114
- package/templates/fullstack-app/package-lock.json +0 -3683
- package/templates/fullstack-app/package.json +0 -26
- package/templates/fullstack-app/public/client.js +0 -139
- package/templates/fullstack-app/public/fullstack-styles.css +0 -445
- package/templates/fullstack-app/server.js +0 -32
- package/templates/fullstack-app/src/api/auth.js +0 -48
- package/templates/fullstack-app/src/api/users.js +0 -85
- package/templates/fullstack-app/src/pages/index.js +0 -0
- package/templates/fullstack-app/src/pages/index.jsx +0 -181
- package/templates/fullstack-app/src/pages/login.js +0 -139
- package/templates/fullstack-app/src/pages/login.jsx +0 -150
- package/templates/fullstack-template/public/client.js +0 -17
- package/templates/fullstack-template/src/api/users/index.js +0 -43
- package/templates/go-wasm-app/package.json +0 -24
- package/templates/go-wasm-app/public/wasm-styles.css +0 -184
- package/templates/go-wasm-app/server.js +0 -36
- package/templates/go-wasm-app/src/pages/index.jsx +0 -161
- package/templates/go-wasm-app/src/wasm/main.go +0 -164
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
* {
|
|
2
|
-
margin: 0;
|
|
3
|
-
padding: 0;
|
|
4
|
-
box-sizing: border-box;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
body {
|
|
8
|
-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
9
|
-
background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
|
|
10
|
-
color: #333;
|
|
11
|
-
min-height: 100vh;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.wasm-app {
|
|
15
|
-
max-width: 1200px;
|
|
16
|
-
margin: 0 auto;
|
|
17
|
-
padding: 20px;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.header {
|
|
21
|
-
text-align: center;
|
|
22
|
-
color: white;
|
|
23
|
-
margin-bottom: 40px;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.header h1 {
|
|
27
|
-
font-size: 3rem;
|
|
28
|
-
margin-bottom: 10px;
|
|
29
|
-
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.status {
|
|
33
|
-
display: inline-block;
|
|
34
|
-
padding: 8px 16px;
|
|
35
|
-
border-radius: 20px;
|
|
36
|
-
font-weight: bold;
|
|
37
|
-
margin-top: 10px;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.status.ready {
|
|
41
|
-
background: #4caf50;
|
|
42
|
-
color: white;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.status.loading {
|
|
46
|
-
background: #ff9800;
|
|
47
|
-
color: white;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.main-content {
|
|
51
|
-
background: white;
|
|
52
|
-
border-radius: 15px;
|
|
53
|
-
padding: 40px;
|
|
54
|
-
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.demo-section h2 {
|
|
58
|
-
color: #1e3c72;
|
|
59
|
-
margin-bottom: 30px;
|
|
60
|
-
text-align: center;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.demo-grid {
|
|
64
|
-
display: grid;
|
|
65
|
-
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
|
66
|
-
gap: 20px;
|
|
67
|
-
margin-bottom: 40px;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.demo-card {
|
|
71
|
-
background: #f8f9fa;
|
|
72
|
-
border-radius: 10px;
|
|
73
|
-
padding: 25px;
|
|
74
|
-
text-align: center;
|
|
75
|
-
border: 2px solid #e9ecef;
|
|
76
|
-
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.demo-card:hover {
|
|
80
|
-
transform: translateY(-5px);
|
|
81
|
-
box-shadow: 0 8px 25px rgba(0,0,0,0.1);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.demo-card h3 {
|
|
85
|
-
color: #1e3c72;
|
|
86
|
-
margin-bottom: 15px;
|
|
87
|
-
font-size: 1.2rem;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.demo-btn {
|
|
91
|
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
92
|
-
color: white;
|
|
93
|
-
border: none;
|
|
94
|
-
padding: 12px 24px;
|
|
95
|
-
border-radius: 6px;
|
|
96
|
-
cursor: pointer;
|
|
97
|
-
font-size: 1rem;
|
|
98
|
-
font-weight: 600;
|
|
99
|
-
transition: all 0.3s ease;
|
|
100
|
-
margin-bottom: 15px;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.demo-btn:hover:not(:disabled) {
|
|
104
|
-
transform: translateY(-2px);
|
|
105
|
-
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.demo-btn:disabled {
|
|
109
|
-
background: #ccc;
|
|
110
|
-
cursor: not-allowed;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.result {
|
|
114
|
-
background: #e8f5e8;
|
|
115
|
-
border: 1px solid #4caf50;
|
|
116
|
-
border-radius: 6px;
|
|
117
|
-
padding: 15px;
|
|
118
|
-
font-family: 'Courier New', monospace;
|
|
119
|
-
font-size: 0.9rem;
|
|
120
|
-
text-align: left;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.result strong {
|
|
124
|
-
color: #2e7d32;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.info-section {
|
|
128
|
-
margin-top: 40px;
|
|
129
|
-
padding-top: 30px;
|
|
130
|
-
border-top: 2px solid #e9ecef;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
.info-section h3 {
|
|
134
|
-
color: #1e3c72;
|
|
135
|
-
text-align: center;
|
|
136
|
-
margin-bottom: 30px;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
.benefit-grid {
|
|
140
|
-
display: grid;
|
|
141
|
-
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
142
|
-
gap: 20px;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.benefit {
|
|
146
|
-
text-align: center;
|
|
147
|
-
padding: 20px;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.benefit h4 {
|
|
151
|
-
color: #667eea;
|
|
152
|
-
margin-bottom: 10px;
|
|
153
|
-
font-size: 1.1rem;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
.benefit p {
|
|
157
|
-
color: #666;
|
|
158
|
-
line-height: 1.5;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.footer {
|
|
162
|
-
text-align: center;
|
|
163
|
-
color: white;
|
|
164
|
-
margin-top: 30px;
|
|
165
|
-
padding: 20px;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
@media (max-width: 768px) {
|
|
169
|
-
.header h1 {
|
|
170
|
-
font-size: 2rem;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
.main-content {
|
|
174
|
-
padding: 20px;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
.demo-grid {
|
|
178
|
-
grid-template-columns: 1fr;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.benefit-grid {
|
|
182
|
-
grid-template-columns: 1fr;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { createServer, loadGoWasmFromFile } from '../../dist/server/index.js';
|
|
2
|
-
|
|
3
|
-
const server = createServer({
|
|
4
|
-
port: process.env.PORT || 3000,
|
|
5
|
-
pagesDir: './src/pages',
|
|
6
|
-
staticDir: './public',
|
|
7
|
-
enableCors: true
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
server.enableSSR({ hydratable: true });
|
|
11
|
-
|
|
12
|
-
// Load WASM module on server startup
|
|
13
|
-
async function initializeWasm() {
|
|
14
|
-
try {
|
|
15
|
-
console.log('🔄 Loading Go WASM module...');
|
|
16
|
-
await loadGoWasmFromFile('./public/app.wasm', {
|
|
17
|
-
debug: true,
|
|
18
|
-
goWasmPath: './public/wasm_exec.js'
|
|
19
|
-
});
|
|
20
|
-
console.log('✅ Go WASM module loaded successfully on server');
|
|
21
|
-
} catch (error) {
|
|
22
|
-
console.warn('⚠️ Could not load WASM on server:', error.message);
|
|
23
|
-
console.log('💡 WASM will be loaded on the client side only');
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
server.start().then(async () => {
|
|
28
|
-
console.log('🚀 Baraqex Go WASM server started successfully!');
|
|
29
|
-
console.log('📱 Visit http://localhost:3000 to see your app');
|
|
30
|
-
|
|
31
|
-
// Initialize WASM after server starts
|
|
32
|
-
await initializeWasm();
|
|
33
|
-
}).catch(error => {
|
|
34
|
-
console.error('❌ Failed to start server:', error);
|
|
35
|
-
process.exit(1);
|
|
36
|
-
});
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { jsx, useState, useEffect } from 'baraqex';
|
|
2
|
-
import { loadGoWasm, callWasmFunction, isWasmReady } from 'baraqex';
|
|
3
|
-
|
|
4
|
-
export default function WasmApp() {
|
|
5
|
-
const [wasmReady, setWasmReady] = useState(false);
|
|
6
|
-
const [results, setResults] = useState({});
|
|
7
|
-
const [loading, setLoading] = useState(false);
|
|
8
|
-
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
initializeWasm();
|
|
11
|
-
}, []);
|
|
12
|
-
|
|
13
|
-
const initializeWasm = async () => {
|
|
14
|
-
try {
|
|
15
|
-
setLoading(true);
|
|
16
|
-
await loadGoWasm('/app.wasm', { debug: true });
|
|
17
|
-
setWasmReady(isWasmReady());
|
|
18
|
-
} catch (error) {
|
|
19
|
-
console.error('Failed to load WASM:', error);
|
|
20
|
-
} finally {
|
|
21
|
-
setLoading(false);
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const runFactorial = () => {
|
|
26
|
-
if (!wasmReady) return;
|
|
27
|
-
const result = callWasmFunction('goFactorial', 10);
|
|
28
|
-
setResults(prev => ({ ...prev, factorial: result }));
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const runMatrixMultiply = () => {
|
|
32
|
-
if (!wasmReady) return;
|
|
33
|
-
const result = callWasmFunction('goMatrixMultiply');
|
|
34
|
-
setResults(prev => ({ ...prev, matrix: result }));
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const runComplexComputation = () => {
|
|
38
|
-
if (!wasmReady) return;
|
|
39
|
-
setLoading(true);
|
|
40
|
-
setTimeout(() => {
|
|
41
|
-
const result = callWasmFunction('goComplexComputation', 100000);
|
|
42
|
-
setResults(prev => ({ ...prev, computation: result }));
|
|
43
|
-
setLoading(false);
|
|
44
|
-
}, 10);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const runCryptoHash = () => {
|
|
48
|
-
if (!wasmReady) return;
|
|
49
|
-
const result = callWasmFunction('goCryptoHash', 'Hello, Baraqex WASM!');
|
|
50
|
-
setResults(prev => ({ ...prev, hash: result }));
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
return (
|
|
54
|
-
<html>
|
|
55
|
-
<head>
|
|
56
|
-
<title>Baraqex Go WASM App</title>
|
|
57
|
-
<meta name="description" content="High-performance Go WebAssembly integration with Baraqex" />
|
|
58
|
-
<link rel="stylesheet" href="/wasm-styles.css" />
|
|
59
|
-
</head>
|
|
60
|
-
<body>
|
|
61
|
-
<div className="wasm-app">
|
|
62
|
-
<header className="header">
|
|
63
|
-
<h1>🔄 Baraqex + Go WebAssembly</h1>
|
|
64
|
-
<p>High-performance computing in the browser</p>
|
|
65
|
-
<div className={`status ${wasmReady ? 'ready' : 'loading'}`}>
|
|
66
|
-
WASM Status: {loading ? 'Loading...' : wasmReady ? 'Ready' : 'Not Ready'}
|
|
67
|
-
</div>
|
|
68
|
-
</header>
|
|
69
|
-
|
|
70
|
-
<main className="main-content">
|
|
71
|
-
<section className="demo-section">
|
|
72
|
-
<h2>Go Function Demonstrations</h2>
|
|
73
|
-
|
|
74
|
-
<div className="demo-grid">
|
|
75
|
-
<div className="demo-card">
|
|
76
|
-
<h3>📊 Factorial Calculation</h3>
|
|
77
|
-
<button onClick={runFactorial} disabled={!wasmReady} className="demo-btn">
|
|
78
|
-
Calculate 10!
|
|
79
|
-
</button>
|
|
80
|
-
{results.factorial && (
|
|
81
|
-
<div className="result">
|
|
82
|
-
Result: <strong>{results.factorial}</strong>
|
|
83
|
-
</div>
|
|
84
|
-
)}
|
|
85
|
-
</div>
|
|
86
|
-
|
|
87
|
-
<div className="demo-card">
|
|
88
|
-
<h3>🔢 Matrix Multiplication</h3>
|
|
89
|
-
<button onClick={runMatrixMultiply} disabled={!wasmReady} className="demo-btn">
|
|
90
|
-
Multiply 2x2 Matrices
|
|
91
|
-
</button>
|
|
92
|
-
{results.matrix && (
|
|
93
|
-
<div className="result">
|
|
94
|
-
<strong>{results.matrix.computation}</strong>
|
|
95
|
-
</div>
|
|
96
|
-
)}
|
|
97
|
-
</div>
|
|
98
|
-
|
|
99
|
-
<div className="demo-card">
|
|
100
|
-
<h3>🧮 Complex Computation</h3>
|
|
101
|
-
<button onClick={runComplexComputation} disabled={!wasmReady || loading} className="demo-btn">
|
|
102
|
-
{loading ? 'Computing...' : 'Estimate π (Monte Carlo)'}
|
|
103
|
-
</button>
|
|
104
|
-
{results.computation && (
|
|
105
|
-
<div className="result">
|
|
106
|
-
<div>π ≈ <strong>{results.computation.pi?.toFixed(6)}</strong></div>
|
|
107
|
-
<div>Time: {results.computation.duration}ms</div>
|
|
108
|
-
<div>Accuracy: {results.computation.accuracy?.toFixed(6)}</div>
|
|
109
|
-
</div>
|
|
110
|
-
)}
|
|
111
|
-
</div>
|
|
112
|
-
|
|
113
|
-
<div className="demo-card">
|
|
114
|
-
<h3>🔐 Crypto Hash</h3>
|
|
115
|
-
<button onClick={runCryptoHash} disabled={!wasmReady} className="demo-btn">
|
|
116
|
-
Hash String
|
|
117
|
-
</button>
|
|
118
|
-
{results.hash && (
|
|
119
|
-
<div className="result">
|
|
120
|
-
<div>Input: <strong>{results.hash.input}</strong></div>
|
|
121
|
-
<div>Hash: <strong>{results.hash.hash}</strong></div>
|
|
122
|
-
</div>
|
|
123
|
-
)}
|
|
124
|
-
</div>
|
|
125
|
-
</div>
|
|
126
|
-
</section>
|
|
127
|
-
|
|
128
|
-
<section className="info-section">
|
|
129
|
-
<h3>🚀 Why Go + WebAssembly?</h3>
|
|
130
|
-
<div className="benefit-grid">
|
|
131
|
-
<div className="benefit">
|
|
132
|
-
<h4>⚡ Performance</h4>
|
|
133
|
-
<p>Near-native speed for computationally intensive tasks</p>
|
|
134
|
-
</div>
|
|
135
|
-
<div className="benefit">
|
|
136
|
-
<h4>🔒 Security</h4>
|
|
137
|
-
<p>Sandboxed execution environment</p>
|
|
138
|
-
</div>
|
|
139
|
-
<div className="benefit">
|
|
140
|
-
<h4>🌐 Portability</h4>
|
|
141
|
-
<p>Run the same code in browser and server</p>
|
|
142
|
-
</div>
|
|
143
|
-
<div className="benefit">
|
|
144
|
-
<h4>📦 Small Size</h4>
|
|
145
|
-
<p>Optimized binary size</p>
|
|
146
|
-
</div>
|
|
147
|
-
</div>
|
|
148
|
-
</section>
|
|
149
|
-
</main>
|
|
150
|
-
|
|
151
|
-
<footer className="footer">
|
|
152
|
-
<p>Built with Baraqex Framework + Go WebAssembly</p>
|
|
153
|
-
</footer>
|
|
154
|
-
</div>
|
|
155
|
-
|
|
156
|
-
<script src="/wasm_exec.js"></script>
|
|
157
|
-
<script src="/wasm-client.js" type="module"></script>
|
|
158
|
-
</body>
|
|
159
|
-
</html>
|
|
160
|
-
);
|
|
161
|
-
}
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
package main
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"fmt"
|
|
5
|
-
"math"
|
|
6
|
-
"syscall/js"
|
|
7
|
-
"time"
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
// Global function registry
|
|
11
|
-
var funcs = make(map[string]js.Func)
|
|
12
|
-
|
|
13
|
-
// Register a Go function in the global scope
|
|
14
|
-
func registerFunc(name string, fn func(this js.Value, args []js.Value) interface{}) {
|
|
15
|
-
f := js.FuncOf(fn)
|
|
16
|
-
funcs[name] = f
|
|
17
|
-
js.Global().Set(name, f)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Calculate factorial using Go
|
|
21
|
-
func goFactorial(this js.Value, args []js.Value) interface{} {
|
|
22
|
-
if len(args) < 1 {
|
|
23
|
-
return 1
|
|
24
|
-
}
|
|
25
|
-
n := int(args[0].Float())
|
|
26
|
-
if n <= 1 {
|
|
27
|
-
return 1
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
result := 1
|
|
31
|
-
for i := 2; i <= n; i++ {
|
|
32
|
-
result *= i
|
|
33
|
-
}
|
|
34
|
-
return result
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// High-performance matrix multiplication
|
|
38
|
-
func goMatrixMultiply(this js.Value, args []js.Value) interface{} {
|
|
39
|
-
if len(args) < 2 {
|
|
40
|
-
return js.ValueOf([]interface{}{})
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Simple 2x2 matrix multiplication example
|
|
44
|
-
matrixA := [][]float64{{1, 2}, {3, 4}}
|
|
45
|
-
matrixB := [][]float64{{5, 6}, {7, 8}}
|
|
46
|
-
|
|
47
|
-
result := make([][]float64, 2)
|
|
48
|
-
for i := range result {
|
|
49
|
-
result[i] = make([]float64, 2)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
for i := 0; i < 2; i++ {
|
|
53
|
-
for j := 0; j < 2; j++ {
|
|
54
|
-
for k := 0; k < 2; k++ {
|
|
55
|
-
result[i][j] += matrixA[i][k] * matrixB[k][j]
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return js.ValueOf(map[string]interface{}{
|
|
61
|
-
"result": result,
|
|
62
|
-
"computation": "2x2 matrix multiplication completed",
|
|
63
|
-
})
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Complex mathematical computation
|
|
67
|
-
func goComplexComputation(this js.Value, args []js.Value) interface{} {
|
|
68
|
-
iterations := 10000
|
|
69
|
-
if len(args) > 0 {
|
|
70
|
-
iterations = int(args[0].Float())
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
start := time.Now()
|
|
74
|
-
|
|
75
|
-
// Monte Carlo estimation of Pi
|
|
76
|
-
inside := 0
|
|
77
|
-
for i := 0; i < iterations; i++ {
|
|
78
|
-
x := float64(i%1000) / 1000.0
|
|
79
|
-
y := float64((i*7)%1000) / 1000.0
|
|
80
|
-
if x*x+y*y <= 1.0 {
|
|
81
|
-
inside++
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
pi := 4.0 * float64(inside) / float64(iterations)
|
|
86
|
-
duration := time.Since(start)
|
|
87
|
-
|
|
88
|
-
return js.ValueOf(map[string]interface{}{
|
|
89
|
-
"pi": pi,
|
|
90
|
-
"iterations": iterations,
|
|
91
|
-
"duration": duration.Milliseconds(),
|
|
92
|
-
"accuracy": math.Abs(math.Pi - pi),
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Image processing simulation
|
|
97
|
-
func goImageFilter(this js.Value, args []js.Value) interface{} {
|
|
98
|
-
if len(args) < 1 {
|
|
99
|
-
return js.ValueOf(map[string]interface{}{
|
|
100
|
-
"error": "Image data required",
|
|
101
|
-
})
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Simulate image processing
|
|
105
|
-
width, height := 100, 100
|
|
106
|
-
processed := make([][]int, height)
|
|
107
|
-
|
|
108
|
-
for i := range processed {
|
|
109
|
-
processed[i] = make([]int, width)
|
|
110
|
-
for j := range processed[i] {
|
|
111
|
-
// Simple blur filter simulation
|
|
112
|
-
processed[i][j] = (i + j) % 256
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return js.ValueOf(map[string]interface{}{
|
|
117
|
-
"width": width,
|
|
118
|
-
"height": height,
|
|
119
|
-
"processed": true,
|
|
120
|
-
"filter": "blur",
|
|
121
|
-
"pixels": width * height,
|
|
122
|
-
})
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Cryptographic hash function
|
|
126
|
-
func goCryptoHash(this js.Value, args []js.Value) interface{} {
|
|
127
|
-
if len(args) < 1 {
|
|
128
|
-
return ""
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
input := args[0].String()
|
|
132
|
-
|
|
133
|
-
// Simple hash implementation (not cryptographically secure)
|
|
134
|
-
hash := uint32(0)
|
|
135
|
-
for _, char := range input {
|
|
136
|
-
hash = hash*31 + uint32(char)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return js.ValueOf(map[string]interface{}{
|
|
140
|
-
"input": input,
|
|
141
|
-
"hash": fmt.Sprintf("%x", hash),
|
|
142
|
-
"length": len(input),
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
func main() {
|
|
147
|
-
fmt.Println("Go WASM module for Baraqex starting...")
|
|
148
|
-
|
|
149
|
-
// Register all Go functions
|
|
150
|
-
registerFunc("goFactorial", goFactorial)
|
|
151
|
-
registerFunc("goMatrixMultiply", goMatrixMultiply)
|
|
152
|
-
registerFunc("goComplexComputation", goComplexComputation)
|
|
153
|
-
registerFunc("goImageFilter", goImageFilter)
|
|
154
|
-
registerFunc("goCryptoHash", goCryptoHash)
|
|
155
|
-
|
|
156
|
-
fmt.Printf("Registered %d Go functions for Baraqex\n", len(funcs))
|
|
157
|
-
|
|
158
|
-
// Notify JavaScript that Go WASM is ready
|
|
159
|
-
if console := js.Global().Get("console"); !console.IsUndefined() {
|
|
160
|
-
console.Call("log", "🔄 Go WASM functions ready for Baraqex!")
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
fmt.Println("Go WASM initialization complete")
|
|
164
|
-
}
|