frontend-hamroun 1.2.79 → 1.2.82
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/LICENSE +21 -0
- package/README.md +129 -1513
- package/bin/cli.js +506 -145
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.client.cjs +2 -0
- package/dist/index.client.cjs.map +1 -0
- package/dist/index.client.js +26 -0
- package/dist/index.client.js.map +1 -0
- package/dist/index.js +299 -1
- package/dist/index.js.map +1 -0
- package/dist/jsx-runtime.cjs +2 -0
- package/dist/jsx-runtime.cjs.map +1 -0
- package/dist/jsx-runtime.js +93 -1
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/renderer-Bo9zkUZ_.js +52 -0
- package/dist/renderer-Bo9zkUZ_.js.map +1 -0
- package/dist/renderer-Din1y3YM.cjs +2 -0
- package/dist/renderer-Din1y3YM.cjs.map +1 -0
- package/dist/server-renderer-CqIpQ-od.cjs +2 -0
- package/dist/server-renderer-CqIpQ-od.cjs.map +1 -0
- package/dist/server-renderer-QHt45Ip2.js +255 -0
- package/dist/server-renderer-QHt45Ip2.js.map +1 -0
- package/dist/server-renderer.cjs +2 -0
- package/dist/server-renderer.cjs.map +1 -0
- package/dist/server-renderer.js +5 -1
- package/dist/server-renderer.js.map +1 -0
- package/package.json +77 -120
- package/templates/basic-app/build.js +22 -0
- package/templates/basic-app/dev.js +27 -0
- package/templates/basic-app/esbuild.config.js +28 -0
- package/templates/basic-app/index.html +1 -1
- package/templates/basic-app/package.json +29 -28
- package/templates/basic-app/server.js +24 -0
- package/templates/basic-app/src/App.jsx +16 -0
- package/templates/basic-app/src/App.tsx +26 -0
- package/templates/basic-app/src/client.jsx +5 -0
- package/templates/basic-app/src/client.tsx +11 -0
- package/templates/basic-app/src/components/Counter.jsx +13 -0
- package/templates/basic-app/src/components/Counter.tsx +18 -0
- package/templates/basic-app/src/jsx-shim.js +3 -0
- package/templates/basic-app/src/jsx-shim.ts +11 -0
- package/templates/basic-app/src/main.jsx +98 -0
- package/templates/basic-app/src/main.tsx +0 -1
- package/templates/basic-app/src/server.js +47 -0
- package/templates/basic-app/src/server.ts +52 -0
- package/templates/basic-app/tsconfig.server.json +11 -0
- package/templates/complete-app/lib/frontend-hamroun.js +182 -0
- package/templates/complete-app/package.json +2 -1
- package/templates/complete-app/pages/about.jsx +0 -0
- package/templates/complete-app/pages/index.jsx +0 -0
- package/templates/complete-app/pages/wasm-demo.jsx +0 -0
- package/templates/complete-app/public/client.js +58 -49
- package/templates/complete-app/public/index.html +88 -17
- package/templates/complete-app/public/styles.css +30 -533
- package/templates/complete-app/server.js +31 -222
- 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.js +130 -101
- package/templates/fullstack-app/build/main.js.map +4 -4
- package/templates/fullstack-app/package-lock.json +1773 -566
- package/templates/ssr-template/esbuild.config.js +33 -0
- package/templates/ssr-template/jsx-shim.js +1 -0
- package/templates/ssr-template/package.json +22 -16
- package/templates/ssr-template/src/App.tsx +12 -52
- package/templates/ssr-template/src/client.tsx +3 -17
- package/templates/ssr-template/src/server.ts +21 -204
- package/templates/ssr-template/tsconfig.json +10 -13
- package/templates/ssr-template/tsconfig.server.json +6 -14
- package/templates/wasm/build-wasm.js +228 -0
- 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/{go-wasm-app → wasm}/package-lock.json +5307 -3732
- package/templates/wasm/package.json +42 -0
- package/templates/wasm/public/example.wasm +0 -0
- package/templates/wasm/src/App.tsx +564 -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 +56 -0
- package/templates/wasm/wasm-loader.js +103 -0
- package/dist/batch/package.json +0 -16
- package/dist/client-router/package.json +0 -16
- package/dist/component/package.json +0 -16
- package/dist/context/package.json +0 -16
- package/dist/event-bus/package.json +0 -16
- package/dist/forms/package.json +0 -16
- package/dist/hooks/package.json +0 -16
- package/dist/hooks-0728361a.cjs +0 -1
- package/dist/hooks-b58f947c.js +0 -133
- package/dist/hooks.js +0 -1
- package/dist/hooks.mjs +0 -13
- package/dist/index.mjs +0 -137
- package/dist/jsx-runtime/package.json +0 -16
- package/dist/jsx-runtime.mjs +0 -64
- package/dist/lifecycle-events/package.json +0 -16
- package/dist/package.json +0 -71
- package/dist/render-component/package.json +0 -16
- package/dist/renderer/package.json +0 -16
- package/dist/renderer.js +0 -1
- package/dist/renderer.mjs +0 -27
- package/dist/router/package.json +0 -16
- package/dist/server/package.json +0 -17
- package/dist/server/src/batch.d.ts +0 -3
- package/dist/server/src/batch.js +0 -23
- package/dist/server/src/batch.js.map +0 -1
- package/dist/server/src/client-router.d.ts +0 -60
- package/dist/server/src/client-router.js +0 -210
- package/dist/server/src/client-router.js.map +0 -1
- package/dist/server/src/component.d.ts +0 -14
- package/dist/server/src/component.js +0 -106
- package/dist/server/src/component.js.map +0 -1
- package/dist/server/src/context.d.ts +0 -13
- package/dist/server/src/context.js +0 -21
- package/dist/server/src/context.js.map +0 -1
- package/dist/server/src/event-bus.d.ts +0 -23
- package/dist/server/src/event-bus.js +0 -75
- package/dist/server/src/event-bus.js.map +0 -1
- package/dist/server/src/forms.d.ts +0 -40
- package/dist/server/src/forms.js +0 -148
- package/dist/server/src/forms.js.map +0 -1
- package/dist/server/src/hooks.d.ts +0 -12
- package/dist/server/src/hooks.js +0 -170
- package/dist/server/src/hooks.js.map +0 -1
- package/dist/server/src/index.client.d.ts +0 -12
- package/dist/server/src/index.client.js +0 -14
- package/dist/server/src/index.client.js.map +0 -1
- package/dist/server/src/index.d.ts +0 -88
- package/dist/server/src/index.js +0 -79
- package/dist/server/src/index.js.map +0 -1
- package/dist/server/src/jsx-runtime/jsx-dev-runtime.d.ts +0 -1
- package/dist/server/src/jsx-runtime/jsx-dev-runtime.js +0 -2
- package/dist/server/src/jsx-runtime/jsx-dev-runtime.js.map +0 -1
- package/dist/server/src/jsx-runtime/jsx-runtime.d.ts +0 -4
- package/dist/server/src/jsx-runtime/jsx-runtime.js +0 -41
- package/dist/server/src/jsx-runtime/jsx-runtime.js.map +0 -1
- package/dist/server/src/jsx-runtime.d.ts +0 -20
- package/dist/server/src/jsx-runtime.js +0 -105
- package/dist/server/src/jsx-runtime.js.map +0 -1
- package/dist/server/src/lifecycle-events.d.ts +0 -108
- package/dist/server/src/lifecycle-events.js +0 -177
- package/dist/server/src/lifecycle-events.js.map +0 -1
- package/dist/server/src/renderComponent.d.ts +0 -13
- package/dist/server/src/renderComponent.js +0 -30
- package/dist/server/src/renderComponent.js.map +0 -1
- package/dist/server/src/renderer.d.ts +0 -2
- package/dist/server/src/renderer.js +0 -31
- package/dist/server/src/renderer.js.map +0 -1
- package/dist/server/src/router.d.ts +0 -55
- package/dist/server/src/router.js +0 -166
- package/dist/server/src/router.js.map +0 -1
- package/dist/server/src/server/api-router.d.ts +0 -15
- package/dist/server/src/server/api-router.js +0 -111
- package/dist/server/src/server/api-router.js.map +0 -1
- package/dist/server/src/server/auth.d.ts +0 -32
- package/dist/server/src/server/auth.js +0 -80
- package/dist/server/src/server/auth.js.map +0 -1
- package/dist/server/src/server/database.d.ts +0 -24
- package/dist/server/src/server/database.js +0 -135
- package/dist/server/src/server/database.js.map +0 -1
- package/dist/server/src/server/index.d.ts +0 -116
- package/dist/server/src/server/index.js +0 -508
- package/dist/server/src/server/index.js.map +0 -1
- package/dist/server/src/server/middleware.d.ts +0 -11
- package/dist/server/src/server/middleware.js +0 -46
- package/dist/server/src/server/middleware.js.map +0 -1
- package/dist/server/src/server/server.d.ts +0 -9
- package/dist/server/src/server/server.js +0 -87
- package/dist/server/src/server/server.js.map +0 -1
- package/dist/server/src/server/templates.d.ts +0 -30
- package/dist/server/src/server/templates.js +0 -208
- package/dist/server/src/server/templates.js.map +0 -1
- package/dist/server/src/server/types.d.ts +0 -38
- package/dist/server/src/server/types.js +0 -4
- package/dist/server/src/server/types.js.map +0 -1
- package/dist/server/src/server/utils.d.ts +0 -70
- package/dist/server/src/server/utils.js +0 -156
- package/dist/server/src/server/utils.js.map +0 -1
- package/dist/server/src/server/wasm.d.ts +0 -9
- package/dist/server/src/server/wasm.js +0 -117
- package/dist/server/src/server/wasm.js.map +0 -1
- package/dist/server/src/server-renderer.d.ts +0 -5
- package/dist/server/src/server-renderer.js +0 -106
- package/dist/server/src/server-renderer.js.map +0 -1
- package/dist/server/src/server-types.d.ts +0 -42
- package/dist/server/src/server-types.js +0 -6
- package/dist/server/src/server-types.js.map +0 -1
- package/dist/server/src/store.d.ts +0 -41
- package/dist/server/src/store.js +0 -99
- package/dist/server/src/store.js.map +0 -1
- package/dist/server/src/types.d.ts +0 -19
- package/dist/server/src/types.js +0 -2
- package/dist/server/src/types.js.map +0 -1
- package/dist/server/src/utils.d.ts +0 -46
- package/dist/server/src/utils.js +0 -144
- package/dist/server/src/utils.js.map +0 -1
- package/dist/server/src/vdom.d.ts +0 -8
- package/dist/server/src/vdom.js +0 -22
- package/dist/server/src/vdom.js.map +0 -1
- package/dist/server/src/wasm.d.ts +0 -36
- package/dist/server/src/wasm.js +0 -159
- package/dist/server/src/wasm.js.map +0 -1
- package/dist/server/tsconfig.server.tsbuildinfo +0 -1
- package/dist/server-renderer/package.json +0 -16
- package/dist/server-renderer.mjs +0 -64
- package/dist/store/package.json +0 -16
- package/dist/types/package.json +0 -16
- package/dist/utils/package.json +0 -16
- package/dist/vdom/package.json +0 -16
- package/dist/wasm/package.json +0 -16
- package/dist/wasm.js +0 -1
- package/dist/wasm.mjs +0 -103
- package/templates/basic-app/docs/rapport_pfe.aux +0 -27
- package/templates/basic-app/docs/rapport_pfe.log +0 -399
- 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/complete-app/package-lock.json +0 -2536
- package/templates/go-wasm-app/README.md +0 -38
- package/templates/go-wasm-app/babel.config.js +0 -21
- 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/build.config.js +0 -62
- package/templates/go-wasm-app/build.js +0 -218
- package/templates/go-wasm-app/package.json +0 -32
- 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 -70
- package/templates/go-wasm-app/src/App.jsx +0 -38
- package/templates/go-wasm-app/src/app.js +0 -173
- 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 -45
- package/templates/ssr-template/client.js +0 -58
- package/templates/ssr-template/package-lock.json +0 -2478
- package/templates/ssr-template/public/index.html +0 -47
- package/templates/ssr-template/readme.md +0 -188
- package/templates/ssr-template/server.js +0 -369
- package/templates/ssr-template/server.ts +0 -275
- package/templates/ssr-template/src/client.ts +0 -61
- package/templates/ssr-template/src/pages/index.tsx +0 -51
- package/templates/ssr-template/vite.config.js +0 -57
- /package/{dist/Counter.d.ts → templates/complete-app/api/hello.js} +0 -0
- /package/templates/{go-wasm-app/public/wasm → wasm/public}/wasm_exec.js +0 -0
@@ -1,13 +0,0 @@
|
|
1
|
-
import { jsx } from 'frontend-hamroun';
|
2
|
-
|
3
|
-
export default function Footer() {
|
4
|
-
return (
|
5
|
-
<footer>
|
6
|
-
<p>
|
7
|
-
Built with <a href="https://github.com/hamroun/frontend-hamroun" target="_blank" rel="noopener noreferrer">
|
8
|
-
Frontend Hamroun
|
9
|
-
</a> and Go WebAssembly
|
10
|
-
</p>
|
11
|
-
</footer>
|
12
|
-
);
|
13
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { jsx } from 'frontend-hamroun';
|
2
|
-
|
3
|
-
export default function Header({ isSSR, isHydrated }) {
|
4
|
-
return (
|
5
|
-
<header>
|
6
|
-
<h1>Frontend Hamroun + Go WebAssembly</h1>
|
7
|
-
<p>A powerful combination for high-performance web applications</p>
|
8
|
-
|
9
|
-
<div className="rendering-info">
|
10
|
-
<span className={`badge ${isSSR ? 'active' : ''}`}>
|
11
|
-
Server Rendered
|
12
|
-
</span>
|
13
|
-
<span className={`badge ${isHydrated ? 'active' : ''}`}>
|
14
|
-
Hydrated
|
15
|
-
</span>
|
16
|
-
</div>
|
17
|
-
</header>
|
18
|
-
);
|
19
|
-
}
|
@@ -1,120 +0,0 @@
|
|
1
|
-
import { jsx, useState } from 'frontend-hamroun';
|
2
|
-
|
3
|
-
export default function WasmDemo({ wasm }) {
|
4
|
-
// Addition demo state
|
5
|
-
const [num1, setNum1] = useState(5);
|
6
|
-
const [num2, setNum2] = useState(7);
|
7
|
-
const [sum, setSum] = useState(null);
|
8
|
-
|
9
|
-
// Data processing demo state
|
10
|
-
const [processInput, setProcessInput] = useState(JSON.stringify({
|
11
|
-
name: 'Test data',
|
12
|
-
source: 'client',
|
13
|
-
values: [10, 20, 30, 40, 50],
|
14
|
-
timestamp: new Date().toISOString()
|
15
|
-
}, null, 2));
|
16
|
-
const [processResult, setProcessResult] = useState(null);
|
17
|
-
|
18
|
-
// Error state
|
19
|
-
const [error, setError] = useState(null);
|
20
|
-
|
21
|
-
// Handle addition with Go WASM
|
22
|
-
const handleCalculate = () => {
|
23
|
-
try {
|
24
|
-
setError(null);
|
25
|
-
// Get the goAdd function from the WASM instance
|
26
|
-
const goAdd = wasm.functions.goAdd;
|
27
|
-
// Call the Go function and get the result
|
28
|
-
const result = goAdd(parseInt(num1), parseInt(num2));
|
29
|
-
setSum(result);
|
30
|
-
} catch (err) {
|
31
|
-
console.error('Error calling Go function:', err);
|
32
|
-
setError(`Error: ${err.message}`);
|
33
|
-
}
|
34
|
-
};
|
35
|
-
|
36
|
-
// Handle complex data processing with Go WASM
|
37
|
-
const handleProcessData = () => {
|
38
|
-
try {
|
39
|
-
setError(null);
|
40
|
-
// Parse the input JSON
|
41
|
-
const inputData = JSON.parse(processInput);
|
42
|
-
// Get the goProcessData function from the WASM instance
|
43
|
-
const goProcessData = wasm.functions.goProcessData;
|
44
|
-
// Call the Go function with the data
|
45
|
-
const result = goProcessData(inputData);
|
46
|
-
// Parse the returned JSON and format it
|
47
|
-
setProcessResult(JSON.parse(result));
|
48
|
-
} catch (err) {
|
49
|
-
console.error('Error processing data with Go:', err);
|
50
|
-
setError(`Error: ${err.message}`);
|
51
|
-
}
|
52
|
-
};
|
53
|
-
|
54
|
-
return (
|
55
|
-
<div className="wasm-demo">
|
56
|
-
{error && (
|
57
|
-
<div className="error-message">
|
58
|
-
{error}
|
59
|
-
</div>
|
60
|
-
)}
|
61
|
-
|
62
|
-
<section className="demo-section">
|
63
|
-
<h2>Simple Addition with Go</h2>
|
64
|
-
<p>Call a Go WASM function to add two numbers:</p>
|
65
|
-
<div className="input-row">
|
66
|
-
<input
|
67
|
-
type="number"
|
68
|
-
value={num1}
|
69
|
-
onChange={(e) => setNum1(e.target.value)}
|
70
|
-
/>
|
71
|
-
<span className="operator">+</span>
|
72
|
-
<input
|
73
|
-
type="number"
|
74
|
-
value={num2}
|
75
|
-
onChange={(e) => setNum2(e.target.value)}
|
76
|
-
/>
|
77
|
-
<button onClick={handleCalculate}>Calculate</button>
|
78
|
-
</div>
|
79
|
-
|
80
|
-
{sum !== null && (
|
81
|
-
<div className="result">
|
82
|
-
<h3>Result:</h3>
|
83
|
-
<pre>{sum}</pre>
|
84
|
-
</div>
|
85
|
-
)}
|
86
|
-
</section>
|
87
|
-
|
88
|
-
<section className="demo-section">
|
89
|
-
<h2>Complex Data Processing with Go</h2>
|
90
|
-
<p>Process JSON data using a Go WASM function:</p>
|
91
|
-
<div className="json-editor">
|
92
|
-
<textarea
|
93
|
-
value={processInput}
|
94
|
-
onChange={(e) => setProcessInput(e.target.value)}
|
95
|
-
rows={10}
|
96
|
-
/>
|
97
|
-
<button onClick={handleProcessData}>Process Data</button>
|
98
|
-
</div>
|
99
|
-
|
100
|
-
{processResult && (
|
101
|
-
<div className="result">
|
102
|
-
<h3>Processed Result:</h3>
|
103
|
-
<pre>{JSON.stringify(processResult, null, 2)}</pre>
|
104
|
-
</div>
|
105
|
-
)}
|
106
|
-
</section>
|
107
|
-
|
108
|
-
<section className="info-section">
|
109
|
-
<h2>How It Works</h2>
|
110
|
-
<p>This demo demonstrates the integration between Frontend Hamroun and Go WebAssembly with SSR:</p>
|
111
|
-
<ol>
|
112
|
-
<li>Server renders the initial HTML using the same React-like components</li>
|
113
|
-
<li>Server can process data with Go WASM before sending the response</li>
|
114
|
-
<li>Browser hydrates the app and loads its own WASM module</li>
|
115
|
-
<li>The same Go code runs in both server and browser environments</li>
|
116
|
-
</ol>
|
117
|
-
</section>
|
118
|
-
</div>
|
119
|
-
);
|
120
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { hydrate } from 'frontend-hamroun';
|
2
|
-
import App from './App';
|
3
|
-
|
4
|
-
// Get initial state from server
|
5
|
-
const initialState = window.__INITIAL_STATE__ || {
|
6
|
-
path: window.location.pathname,
|
7
|
-
ssrRendered: false,
|
8
|
-
wasmAvailable: false
|
9
|
-
};
|
10
|
-
|
11
|
-
// Hydrate the application
|
12
|
-
hydrate(<App initialState={initialState} />, document.getElementById('root'));
|
@@ -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,18 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "ESNext",
|
4
|
-
"module": "ESNext",
|
5
|
-
"moduleResolution": "Node",
|
6
|
-
"esModuleInterop": true,
|
7
|
-
"strict": true,
|
8
|
-
"skipLibCheck": true,
|
9
|
-
"outDir": "dist/server",
|
10
|
-
"jsx": "react",
|
11
|
-
"jsxFactory": "jsx",
|
12
|
-
"jsxFragmentFactory": "Fragment",
|
13
|
-
"allowJs": true,
|
14
|
-
"declaration": false
|
15
|
-
},
|
16
|
-
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.js", "src/**/*.jsx"],
|
17
|
-
"exclude": ["node_modules"]
|
18
|
-
}
|
@@ -1,45 +0,0 @@
|
|
1
|
-
import { defineConfig } from 'vite';
|
2
|
-
import { resolve } from 'path';
|
3
|
-
|
4
|
-
export default defineConfig({
|
5
|
-
// Configure JSX
|
6
|
-
esbuild: {
|
7
|
-
jsxFactory: 'createElement',
|
8
|
-
jsxFragment: 'Fragment',
|
9
|
-
jsxInject: `import { createElement, Fragment } from 'frontend-hamroun'`
|
10
|
-
},
|
11
|
-
|
12
|
-
// Configure build
|
13
|
-
build: {
|
14
|
-
outDir: 'dist',
|
15
|
-
emptyOutDir: true,
|
16
|
-
rollupOptions: {
|
17
|
-
input: {
|
18
|
-
client: resolve(__dirname, 'src/client.js')
|
19
|
-
},
|
20
|
-
output: [
|
21
|
-
{
|
22
|
-
// ESM output
|
23
|
-
entryFileNames: 'assets/[name].mjs',
|
24
|
-
chunkFileNames: 'assets/[name]-[hash].mjs',
|
25
|
-
assetFileNames: 'assets/[name]-[hash].[ext]',
|
26
|
-
format: 'es',
|
27
|
-
},
|
28
|
-
{
|
29
|
-
// CommonJS output
|
30
|
-
entryFileNames: 'assets/[name].js',
|
31
|
-
chunkFileNames: 'assets/[name]-[hash].js',
|
32
|
-
assetFileNames: 'assets/[name]-[hash].[ext]',
|
33
|
-
format: 'cjs',
|
34
|
-
}
|
35
|
-
]
|
36
|
-
}
|
37
|
-
},
|
38
|
-
|
39
|
-
// Resolve aliases for better imports
|
40
|
-
resolve: {
|
41
|
-
alias: {
|
42
|
-
'@': resolve(__dirname, 'src')
|
43
|
-
}
|
44
|
-
}
|
45
|
-
});
|
@@ -1,58 +0,0 @@
|
|
1
|
-
import { hydrate, jsx } from 'frontend-hamroun';
|
2
|
-
|
3
|
-
// Create a sample virtual DOM matching what was rendered on the server
|
4
|
-
const app = {
|
5
|
-
type: 'div',
|
6
|
-
props: {
|
7
|
-
id: 'app',
|
8
|
-
children: [
|
9
|
-
{
|
10
|
-
type: 'h1',
|
11
|
-
props: {
|
12
|
-
children: 'Hello from Server-Side Rendering!'
|
13
|
-
}
|
14
|
-
},
|
15
|
-
{
|
16
|
-
type: 'p',
|
17
|
-
props: {
|
18
|
-
children: `This page was rendered at ${new Date().toISOString()}`
|
19
|
-
}
|
20
|
-
},
|
21
|
-
{
|
22
|
-
type: 'button',
|
23
|
-
props: {
|
24
|
-
id: 'counter-btn',
|
25
|
-
className: 'btn',
|
26
|
-
onClick: () => {
|
27
|
-
let count = 1; // Start at 1 since we're updating
|
28
|
-
const btn = document.getElementById('counter-btn');
|
29
|
-
if (btn) {
|
30
|
-
btn.textContent = `Click me (${count})`;
|
31
|
-
btn.addEventListener('click', () => {
|
32
|
-
count++;
|
33
|
-
btn.textContent = `Click me (${count})`;
|
34
|
-
});
|
35
|
-
}
|
36
|
-
},
|
37
|
-
children: 'Click me (0)'
|
38
|
-
}
|
39
|
-
}
|
40
|
-
]
|
41
|
-
}
|
42
|
-
};
|
43
|
-
|
44
|
-
// Wait for DOM to be fully loaded before hydrating
|
45
|
-
window.addEventListener('DOMContentLoaded', () => {
|
46
|
-
console.log('Hydrating client-side content...');
|
47
|
-
|
48
|
-
// Get the container element
|
49
|
-
const container = document.getElementById('app');
|
50
|
-
if (!container) {
|
51
|
-
console.error('Could not find app container for hydration');
|
52
|
-
return;
|
53
|
-
}
|
54
|
-
|
55
|
-
// Hydrate the app
|
56
|
-
hydrate(app, container);
|
57
|
-
console.log('Hydration complete!');
|
58
|
-
});
|