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,128 +0,0 @@
|
|
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 WebAssembly</title>
|
7
|
-
<style>
|
8
|
-
:root {
|
9
|
-
--primary-color: #0070f3;
|
10
|
-
--secondary-color: #0051cc;
|
11
|
-
--background: #f9f9f9;
|
12
|
-
--text-color: #333;
|
13
|
-
--card-background: #fff;
|
14
|
-
--border-color: #eaeaea;
|
15
|
-
--error-color: #f44336;
|
16
|
-
--success-color: #4caf50;
|
17
|
-
}
|
18
|
-
|
19
|
-
* {
|
20
|
-
box-sizing: border-box;
|
21
|
-
}
|
22
|
-
|
23
|
-
body {
|
24
|
-
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
25
|
-
max-width: 800px;
|
26
|
-
margin: 0 auto;
|
27
|
-
padding: 2rem;
|
28
|
-
line-height: 1.6;
|
29
|
-
color: #333;
|
30
|
-
}
|
31
|
-
|
32
|
-
.app {
|
33
|
-
max-width: 900px;
|
34
|
-
margin: 0 auto;
|
35
|
-
padding: 20px;
|
36
|
-
}
|
37
|
-
|
38
|
-
header {
|
39
|
-
text-align: center;
|
40
|
-
margin-bottom: 2rem;
|
41
|
-
}
|
42
|
-
|
43
|
-
header h1 {
|
44
|
-
margin-bottom: 0.5rem;
|
45
|
-
color: var(--primary-color);
|
46
|
-
}
|
47
|
-
|
48
|
-
header p {
|
49
|
-
color: #666;
|
50
|
-
}
|
51
|
-
|
52
|
-
.card {
|
53
|
-
background-color: var(--card-background);
|
54
|
-
border: 1px solid var(--border-color);
|
55
|
-
border-radius: 8px;
|
56
|
-
padding: 1.5rem;
|
57
|
-
margin-bottom: 2rem;
|
58
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
59
|
-
}
|
60
|
-
|
61
|
-
pre {
|
62
|
-
background-color: #f5f5f5;
|
63
|
-
padding: 1rem;
|
64
|
-
border-radius: 4px;
|
65
|
-
overflow-x: auto;
|
66
|
-
}
|
67
|
-
|
68
|
-
footer {
|
69
|
-
margin-top: 3rem;
|
70
|
-
text-align: center;
|
71
|
-
color: #666;
|
72
|
-
padding: 1rem 0;
|
73
|
-
border-top: 1px solid var(--border-color);
|
74
|
-
}
|
75
|
-
|
76
|
-
.warning {
|
77
|
-
display: none;
|
78
|
-
background-color: #fff3cd;
|
79
|
-
border: 1px solid #ffecb5;
|
80
|
-
color: #856404;
|
81
|
-
padding: 1rem;
|
82
|
-
border-radius: 4px;
|
83
|
-
margin-bottom: 1rem;
|
84
|
-
}
|
85
|
-
|
86
|
-
code {
|
87
|
-
background-color: #f5f5f5;
|
88
|
-
padding: 0.2rem 0.4rem;
|
89
|
-
border-radius: 3px;
|
90
|
-
}
|
91
|
-
|
92
|
-
.loading {
|
93
|
-
text-align: center;
|
94
|
-
padding: 3rem 1rem;
|
95
|
-
color: #666;
|
96
|
-
}
|
97
|
-
</style>
|
98
|
-
<script src="/wasm/wasm_exec.js" defer></script>
|
99
|
-
</head>
|
100
|
-
<body>
|
101
|
-
<div id="root">
|
102
|
-
<!-- Server-rendered content will be inserted here -->
|
103
|
-
<div class="loading">
|
104
|
-
<h2>Loading...</h2>
|
105
|
-
<p>Please wait while the server starts.</p>
|
106
|
-
<p>If this message persists, there might be an issue with the server.</p>
|
107
|
-
</div>
|
108
|
-
</div>
|
109
|
-
<script type="module" src="/src/client.js"></script>
|
110
|
-
<script>
|
111
|
-
// The server should replace this entire page with server-rendered content
|
112
|
-
// If you're seeing this, something is wrong with the server-side rendering
|
113
|
-
setTimeout(() => {
|
114
|
-
if (document.querySelector('.loading')) {
|
115
|
-
document.querySelector('#root').innerHTML = `
|
116
|
-
<div class="warning" style="display:block; background-color: #fff3cd; border: 1px solid #ffecb5; color: #856404; padding: 1rem; border-radius: 4px; margin-bottom: 1rem;">
|
117
|
-
<h2>Server Not Responding</h2>
|
118
|
-
<p>The server is not responding with the expected server-rendered content.</p>
|
119
|
-
<p>Please make sure the server is running properly with:</p>
|
120
|
-
<code>npm run dev</code>
|
121
|
-
<p>This static HTML file should be replaced by server-rendered content.</p>
|
122
|
-
</div>
|
123
|
-
`;
|
124
|
-
}
|
125
|
-
}, 2000);
|
126
|
-
</script>
|
127
|
-
</body>
|
128
|
-
</html>
|
@@ -1,197 +0,0 @@
|
|
1
|
-
:root {
|
2
|
-
--primary-color: #0070f3;
|
3
|
-
--secondary-color: #0051cc;
|
4
|
-
--background: #f9f9f9;
|
5
|
-
--text-color: #333;
|
6
|
-
--card-background: #fff;
|
7
|
-
--border-color: #eaeaea;
|
8
|
-
--error-color: #f44336;
|
9
|
-
--success-color: #4caf50;
|
10
|
-
}
|
11
|
-
|
12
|
-
* {
|
13
|
-
box-sizing: border-box;
|
14
|
-
}
|
15
|
-
|
16
|
-
body {
|
17
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
18
|
-
background-color: var(--background);
|
19
|
-
color: var(--text-color);
|
20
|
-
margin: 0;
|
21
|
-
padding: 0;
|
22
|
-
line-height: 1.6;
|
23
|
-
}
|
24
|
-
|
25
|
-
.app {
|
26
|
-
max-width: 900px;
|
27
|
-
margin: 0 auto;
|
28
|
-
padding: 20px;
|
29
|
-
}
|
30
|
-
|
31
|
-
header {
|
32
|
-
text-align: center;
|
33
|
-
margin-bottom: 2rem;
|
34
|
-
}
|
35
|
-
|
36
|
-
header h1 {
|
37
|
-
margin-bottom: 0.5rem;
|
38
|
-
color: var(--primary-color);
|
39
|
-
}
|
40
|
-
|
41
|
-
header p {
|
42
|
-
color: #666;
|
43
|
-
}
|
44
|
-
|
45
|
-
.rendering-info {
|
46
|
-
display: flex;
|
47
|
-
gap: 10px;
|
48
|
-
justify-content: center;
|
49
|
-
margin-top: 10px;
|
50
|
-
}
|
51
|
-
|
52
|
-
.badge {
|
53
|
-
display: inline-block;
|
54
|
-
padding: 4px 8px;
|
55
|
-
border-radius: 4px;
|
56
|
-
background-color: #eaeaea;
|
57
|
-
color: #666;
|
58
|
-
font-size: 0.8rem;
|
59
|
-
}
|
60
|
-
|
61
|
-
.badge.active {
|
62
|
-
background-color: var(--success-color);
|
63
|
-
color: white;
|
64
|
-
}
|
65
|
-
|
66
|
-
footer {
|
67
|
-
margin-top: 3rem;
|
68
|
-
text-align: center;
|
69
|
-
color: #666;
|
70
|
-
padding: 1rem 0;
|
71
|
-
border-top: 1px solid var(--border-color);
|
72
|
-
}
|
73
|
-
|
74
|
-
footer a {
|
75
|
-
color: var(--primary-color);
|
76
|
-
text-decoration: none;
|
77
|
-
}
|
78
|
-
|
79
|
-
.loading {
|
80
|
-
text-align: center;
|
81
|
-
padding: 2rem;
|
82
|
-
}
|
83
|
-
|
84
|
-
.error {
|
85
|
-
background-color: rgba(244, 67, 54, 0.1);
|
86
|
-
border: 1px solid var(--error-color);
|
87
|
-
border-radius: 8px;
|
88
|
-
padding: 1rem;
|
89
|
-
margin: 1rem 0;
|
90
|
-
}
|
91
|
-
|
92
|
-
.error-message {
|
93
|
-
background-color: rgba(244, 67, 54, 0.1);
|
94
|
-
color: var(--error-color);
|
95
|
-
padding: 1rem;
|
96
|
-
border-radius: 8px;
|
97
|
-
margin-bottom: 1rem;
|
98
|
-
}
|
99
|
-
|
100
|
-
.card {
|
101
|
-
background-color: var(--card-background);
|
102
|
-
border: 1px solid var(--border-color);
|
103
|
-
border-radius: 8px;
|
104
|
-
padding: 1.5rem;
|
105
|
-
margin-bottom: 2rem;
|
106
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
107
|
-
}
|
108
|
-
|
109
|
-
.demo-section {
|
110
|
-
background-color: var(--card-background);
|
111
|
-
border: 1px solid var(--border-color);
|
112
|
-
border-radius: 8px;
|
113
|
-
padding: 1.5rem;
|
114
|
-
margin-bottom: 2rem;
|
115
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
116
|
-
}
|
117
|
-
|
118
|
-
.input-row {
|
119
|
-
display: flex;
|
120
|
-
align-items: center;
|
121
|
-
gap: 0.5rem;
|
122
|
-
margin-bottom: 1rem;
|
123
|
-
}
|
124
|
-
|
125
|
-
.input-row input {
|
126
|
-
width: 80px;
|
127
|
-
padding: 0.5rem;
|
128
|
-
border: 1px solid var(--border-color);
|
129
|
-
border-radius: 4px;
|
130
|
-
font-size: 1rem;
|
131
|
-
}
|
132
|
-
|
133
|
-
.input-row .operator {
|
134
|
-
font-size: 1.5rem;
|
135
|
-
margin: 0 0.5rem;
|
136
|
-
}
|
137
|
-
|
138
|
-
button {
|
139
|
-
background-color: var(--primary-color);
|
140
|
-
color: white;
|
141
|
-
border: none;
|
142
|
-
border-radius: 4px;
|
143
|
-
padding: 0.5rem 1rem;
|
144
|
-
cursor: pointer;
|
145
|
-
font-size: 1rem;
|
146
|
-
transition: background-color 0.2s;
|
147
|
-
}
|
148
|
-
|
149
|
-
button:hover {
|
150
|
-
background-color: var(--secondary-color);
|
151
|
-
}
|
152
|
-
|
153
|
-
.json-editor {
|
154
|
-
display: flex;
|
155
|
-
flex-direction: column;
|
156
|
-
gap: 1rem;
|
157
|
-
}
|
158
|
-
|
159
|
-
.json-editor textarea {
|
160
|
-
width: 100%;
|
161
|
-
padding: 0.5rem;
|
162
|
-
border: 1px solid var(--border-color);
|
163
|
-
border-radius: 4px;
|
164
|
-
font-family: monospace;
|
165
|
-
font-size: 0.9rem;
|
166
|
-
resize: vertical;
|
167
|
-
}
|
168
|
-
|
169
|
-
.result {
|
170
|
-
background-color: #f0f7ff;
|
171
|
-
padding: 1rem;
|
172
|
-
border-radius: 4px;
|
173
|
-
margin-top: 1rem;
|
174
|
-
}
|
175
|
-
|
176
|
-
.result pre {
|
177
|
-
margin: 0;
|
178
|
-
white-space: pre-wrap;
|
179
|
-
font-family: monospace;
|
180
|
-
font-size: 0.9rem;
|
181
|
-
}
|
182
|
-
|
183
|
-
.info-section {
|
184
|
-
background-color: #f0f7ff;
|
185
|
-
border: 1px solid #e1e7fd;
|
186
|
-
border-radius: 8px;
|
187
|
-
padding: 1.5rem;
|
188
|
-
}
|
189
|
-
|
190
|
-
.info-section h2 {
|
191
|
-
color: var(--primary-color);
|
192
|
-
margin-top: 0;
|
193
|
-
}
|
194
|
-
|
195
|
-
.info-section ol {
|
196
|
-
padding-left: 1.5rem;
|
197
|
-
}
|
Binary file
|
@@ -1,39 +0,0 @@
|
|
1
|
-
// Copyright 2021 The Go Authors. All rights reserved.
|
2
|
-
// Use of this source code is governed by a BSD-style
|
3
|
-
// license that can be found in the LICENSE file.
|
4
|
-
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
if (process.argv.length < 3) {
|
8
|
-
console.error("usage: go_js_wasm_exec [wasm binary] [arguments]");
|
9
|
-
process.exit(1);
|
10
|
-
}
|
11
|
-
|
12
|
-
globalThis.require = require;
|
13
|
-
globalThis.fs = require("fs");
|
14
|
-
globalThis.TextEncoder = require("util").TextEncoder;
|
15
|
-
globalThis.TextDecoder = require("util").TextDecoder;
|
16
|
-
|
17
|
-
globalThis.performance ??= require("performance");
|
18
|
-
|
19
|
-
globalThis.crypto ??= require("crypto");
|
20
|
-
|
21
|
-
require("./wasm_exec");
|
22
|
-
|
23
|
-
const go = new Go();
|
24
|
-
go.argv = process.argv.slice(2);
|
25
|
-
go.env = Object.assign({ TMPDIR: require("os").tmpdir() }, process.env);
|
26
|
-
go.exit = process.exit;
|
27
|
-
WebAssembly.instantiate(fs.readFileSync(process.argv[2]), go.importObject).then((result) => {
|
28
|
-
process.on("exit", (code) => { // Node.js exits if no event handler is pending
|
29
|
-
if (code === 0 && !go.exited) {
|
30
|
-
// deadlock, make Go print error and stack traces
|
31
|
-
go._pendingEvent = { id: 0 };
|
32
|
-
go._resume();
|
33
|
-
}
|
34
|
-
});
|
35
|
-
return go.run(result.instance);
|
36
|
-
}).catch((err) => {
|
37
|
-
console.error(err);
|
38
|
-
process.exit(1);
|
39
|
-
});
|
@@ -1,70 +0,0 @@
|
|
1
|
-
// Server script with dual module support (ESM/CommonJS)
|
2
|
-
|
3
|
-
// Dynamically import dependencies based on module system
|
4
|
-
const isESM = typeof require === 'undefined';
|
5
|
-
let express, path, fs;
|
6
|
-
|
7
|
-
if (isESM) {
|
8
|
-
// ESM imports
|
9
|
-
import('express').then(module => express = module.default);
|
10
|
-
import('path').then(module => path = module);
|
11
|
-
import('fs').then(module => fs = module);
|
12
|
-
} else {
|
13
|
-
// CommonJS requires
|
14
|
-
express = require('express');
|
15
|
-
path = require('path');
|
16
|
-
fs = require('fs');
|
17
|
-
}
|
18
|
-
|
19
|
-
// Wait for all imports to resolve
|
20
|
-
async function startServer() {
|
21
|
-
// Ensure all modules are loaded
|
22
|
-
if (!express || !path || !fs) {
|
23
|
-
if (isESM) {
|
24
|
-
express = (await import('express')).default;
|
25
|
-
path = await import('path');
|
26
|
-
fs = await import('fs');
|
27
|
-
}
|
28
|
-
}
|
29
|
-
|
30
|
-
const app = express();
|
31
|
-
const PORT = process.env.PORT || 3000;
|
32
|
-
|
33
|
-
// Serve static files from public directory
|
34
|
-
app.use(express.static(path.join(__dirname, 'public')));
|
35
|
-
|
36
|
-
// Special handling for wasm files to ensure correct MIME type
|
37
|
-
app.get('*.wasm', (req, res, next) => {
|
38
|
-
res.set('Content-Type', 'application/wasm');
|
39
|
-
next();
|
40
|
-
});
|
41
|
-
|
42
|
-
// Always return index.html for client-side routing
|
43
|
-
app.get('*', (req, res) => {
|
44
|
-
res.sendFile(path.join(__dirname, 'public', 'index.html'));
|
45
|
-
});
|
46
|
-
|
47
|
-
// Start the server
|
48
|
-
app.listen(PORT, () => {
|
49
|
-
console.log(`
|
50
|
-
┌────────────────────────────────────────────────────┐
|
51
|
-
│ │
|
52
|
-
│ Go WASM Demo Server running on port ${PORT} │
|
53
|
-
│ │
|
54
|
-
│ Local: http://localhost:${PORT} │
|
55
|
-
│ │
|
56
|
-
└────────────────────────────────────────────────────┘
|
57
|
-
`);
|
58
|
-
});
|
59
|
-
}
|
60
|
-
|
61
|
-
startServer();
|
62
|
-
|
63
|
-
// Module export for both ESM and CommonJS
|
64
|
-
const server = { startServer };
|
65
|
-
|
66
|
-
if (typeof module !== 'undefined' && module.exports) {
|
67
|
-
module.exports = server;
|
68
|
-
}
|
69
|
-
|
70
|
-
export default server;
|
@@ -1,38 +0,0 @@
|
|
1
|
-
import { jsx } from 'frontend-hamroun';
|
2
|
-
import WasmDemo from './components/WasmDemo';
|
3
|
-
import Header from './components/Header';
|
4
|
-
import Footer from './components/Footer';
|
5
|
-
|
6
|
-
// Simple App component - will be used with proper rendering in a future step
|
7
|
-
export default function App({ initialState = {} }) {
|
8
|
-
return (
|
9
|
-
<div className="app">
|
10
|
-
<header>
|
11
|
-
<h1>Frontend Hamroun + Go WebAssembly</h1>
|
12
|
-
<p>A powerful combination for high-performance web applications</p>
|
13
|
-
</header>
|
14
|
-
|
15
|
-
<main>
|
16
|
-
<div className="card">
|
17
|
-
<h2>Server-Side Rendered Content</h2>
|
18
|
-
<p>This content was rendered on the server and hydrated on the client.</p>
|
19
|
-
<p>Path: {initialState.path || 'Unknown'}</p>
|
20
|
-
<p>WASM Available: {initialState.wasmAvailable ? 'Yes' : 'No'}</p>
|
21
|
-
</div>
|
22
|
-
|
23
|
-
{initialState.processedData && (
|
24
|
-
<div className="card">
|
25
|
-
<h2>Server-Processed Data</h2>
|
26
|
-
<pre>{JSON.stringify(initialState.processedData, null, 2)}</pre>
|
27
|
-
</div>
|
28
|
-
)}
|
29
|
-
</main>
|
30
|
-
|
31
|
-
<footer>
|
32
|
-
<p>
|
33
|
-
Built with Frontend Hamroun and Go WebAssembly
|
34
|
-
</p>
|
35
|
-
</footer>
|
36
|
-
</div>
|
37
|
-
);
|
38
|
-
}
|
@@ -1,173 +0,0 @@
|
|
1
|
-
// Support both ESM and CommonJS importing styles
|
2
|
-
const frontendHamroun =
|
3
|
-
typeof require !== 'undefined'
|
4
|
-
? require('frontend-hamroun')
|
5
|
-
: await import('frontend-hamroun');
|
6
|
-
|
7
|
-
// Destructure the imports from either ESM or CJS modules
|
8
|
-
const {
|
9
|
-
useState,
|
10
|
-
useEffect,
|
11
|
-
jsx,
|
12
|
-
Fragment,
|
13
|
-
loadGoWasm,
|
14
|
-
createTypedWasmFunction,
|
15
|
-
goValues
|
16
|
-
} = frontendHamroun;
|
17
|
-
|
18
|
-
export function GoWasmDemo() {
|
19
|
-
// Track loading state
|
20
|
-
const [loading, setLoading] = useState(true);
|
21
|
-
const [error, setError] = useState(null);
|
22
|
-
const [wasm, setWasm] = useState(null);
|
23
|
-
|
24
|
-
// Track calculation values
|
25
|
-
const [num1, setNum1] = useState(5);
|
26
|
-
const [num2, setNum2] = useState(7);
|
27
|
-
const [result, setResult] = useState(null);
|
28
|
-
|
29
|
-
// Track JSON example
|
30
|
-
const [jsonInput, setJsonInput] = useState('{"name": "Frontend Hamroun", "version": "1.0"}');
|
31
|
-
const [jsonResult, setJsonResult] = useState(null);
|
32
|
-
|
33
|
-
// Load the WASM module when component mounts
|
34
|
-
useEffect(() => {
|
35
|
-
async function loadWasmModule() {
|
36
|
-
try {
|
37
|
-
setLoading(true);
|
38
|
-
console.log('Loading WASM module...');
|
39
|
-
|
40
|
-
// Load WASM module using frontend-hamroun's loadGoWasm
|
41
|
-
const wasmInstance = await loadGoWasm('/wasm/example.wasm', {
|
42
|
-
debug: true, // Enable debug logging
|
43
|
-
goWasmPath: '/wasm/wasm_exec.js' // Path to Go's wasm_exec.js
|
44
|
-
});
|
45
|
-
|
46
|
-
console.log('WASM module loaded successfully!', wasmInstance);
|
47
|
-
setWasm(wasmInstance);
|
48
|
-
|
49
|
-
// Demonstrate calling a function right away
|
50
|
-
if (wasmInstance.functions.goAdd) {
|
51
|
-
const sum = wasmInstance.functions.goAdd(5, 7);
|
52
|
-
console.log('5 + 7 =', sum);
|
53
|
-
setResult(sum);
|
54
|
-
}
|
55
|
-
|
56
|
-
setLoading(false);
|
57
|
-
} catch (err) {
|
58
|
-
console.error('Failed to load WASM module:', err);
|
59
|
-
setError(err.toString());
|
60
|
-
setLoading(false);
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
loadWasmModule();
|
65
|
-
|
66
|
-
// Cleanup function
|
67
|
-
return () => {
|
68
|
-
console.log('Cleaning up WASM resources...');
|
69
|
-
// Any cleanup needed for WASM resources
|
70
|
-
};
|
71
|
-
}, []); // Empty dependency array means this runs once on mount
|
72
|
-
|
73
|
-
// Function to calculate using WASM
|
74
|
-
const calculateResult = () => {
|
75
|
-
if (!wasm || !wasm.functions.goAdd) {
|
76
|
-
setError('WASM module not loaded or function not available');
|
77
|
-
return;
|
78
|
-
}
|
79
|
-
|
80
|
-
try {
|
81
|
-
// Call the WASM function
|
82
|
-
const sum = wasm.functions.goAdd(parseInt(num1), parseInt(num2));
|
83
|
-
setResult(sum);
|
84
|
-
setError(null);
|
85
|
-
} catch (err) {
|
86
|
-
console.error('Error calling WASM function:', err);
|
87
|
-
setError('Error calling WASM function: ' + err);
|
88
|
-
}
|
89
|
-
};
|
90
|
-
|
91
|
-
// Function to parse JSON using WASM
|
92
|
-
const parseJsonWithWasm = () => {
|
93
|
-
if (!wasm || !wasm.functions.goParseJSON) {
|
94
|
-
setError('WASM module not loaded or JSON parsing function not available');
|
95
|
-
return;
|
96
|
-
}
|
97
|
-
|
98
|
-
try {
|
99
|
-
// Call the WASM function
|
100
|
-
const parsed = wasm.functions.goParseJSON(jsonInput);
|
101
|
-
setJsonResult(JSON.stringify(parsed, null, 2));
|
102
|
-
setError(null);
|
103
|
-
} catch (err) {
|
104
|
-
console.error('Error parsing JSON with WASM:', err);
|
105
|
-
setError('Error parsing JSON with WASM: ' + err);
|
106
|
-
}
|
107
|
-
};
|
108
|
-
|
109
|
-
// Render the component
|
110
|
-
return (
|
111
|
-
<div className="wasm-demo">
|
112
|
-
<h1>Go WebAssembly Demo</h1>
|
113
|
-
|
114
|
-
{loading && <p>Loading WASM module...</p>}
|
115
|
-
|
116
|
-
{error && (
|
117
|
-
<div className="error">
|
118
|
-
<h3>Error:</h3>
|
119
|
-
<pre>{error}</pre>
|
120
|
-
</div>
|
121
|
-
)}
|
122
|
-
|
123
|
-
{wasm && !loading && (
|
124
|
-
<div className="demo-section">
|
125
|
-
<h2>WASM Addition</h2>
|
126
|
-
<div className="calculator">
|
127
|
-
<input
|
128
|
-
type="number"
|
129
|
-
value={num1}
|
130
|
-
onChange={(e) => setNum1(e.target.value)}
|
131
|
-
/>
|
132
|
-
<span> + </span>
|
133
|
-
<input
|
134
|
-
type="number"
|
135
|
-
value={num2}
|
136
|
-
onChange={(e) => setNum2(e.target.value)}
|
137
|
-
/>
|
138
|
-
<button onClick={calculateResult}>Calculate</button>
|
139
|
-
<span className="result">Result: {result}</span>
|
140
|
-
</div>
|
141
|
-
|
142
|
-
<h2>WASM JSON Parsing</h2>
|
143
|
-
<div className="json-parser">
|
144
|
-
<textarea
|
145
|
-
rows="5"
|
146
|
-
value={jsonInput}
|
147
|
-
onChange={(e) => setJsonInput(e.target.value)}
|
148
|
-
/>
|
149
|
-
<button onClick={parseJsonWithWasm}>Parse JSON</button>
|
150
|
-
{jsonResult && (
|
151
|
-
<pre className="json-result">{jsonResult}</pre>
|
152
|
-
)}
|
153
|
-
</div>
|
154
|
-
|
155
|
-
<h2>Available WASM Functions</h2>
|
156
|
-
<ul>
|
157
|
-
{wasm && Object.keys(wasm.functions).map(funcName => (
|
158
|
-
<li key={funcName}>{funcName}</li>
|
159
|
-
))}
|
160
|
-
</ul>
|
161
|
-
</div>
|
162
|
-
)}
|
163
|
-
</div>
|
164
|
-
);
|
165
|
-
}
|
166
|
-
|
167
|
-
// Support both CommonJS and ESM exports
|
168
|
-
export default GoWasmDemo;
|
169
|
-
|
170
|
-
// Add CommonJS compatibility
|
171
|
-
if (typeof module !== 'undefined' && module.exports) {
|
172
|
-
module.exports = { GoWasmDemo };
|
173
|
-
}
|
@@ -1,57 +0,0 @@
|
|
1
|
-
import { hydrate } from 'frontend-hamroun';
|
2
|
-
import App from './App.jsx';
|
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
|
-
// Simple client-side script for hydration
|
12
|
-
console.log('Client-side script loaded');
|
13
|
-
console.log('Initial state:', window.__INITIAL_STATE__);
|
14
|
-
|
15
|
-
// Wait for DOMContentLoaded to ensure the DOM is ready
|
16
|
-
document.addEventListener('DOMContentLoaded', () => {
|
17
|
-
// Hydrate the application
|
18
|
-
hydrate(<App initialState={initialState} />, document.getElementById('root'));
|
19
|
-
console.log('Client-side hydration complete');
|
20
|
-
|
21
|
-
if (window.__INITIAL_STATE__) {
|
22
|
-
console.log('Hydrating with initial state:', window.__INITIAL_STATE__);
|
23
|
-
|
24
|
-
// For now, we'll just display a message that we've loaded on the client
|
25
|
-
const root = document.getElementById('root');
|
26
|
-
|
27
|
-
// Add a "Client Hydrated" indicator
|
28
|
-
const clientIndicator = document.createElement('div');
|
29
|
-
clientIndicator.className = 'client-indicator';
|
30
|
-
clientIndicator.textContent = 'Client-Side Hydration Active';
|
31
|
-
clientIndicator.style.backgroundColor = '#4caf50';
|
32
|
-
clientIndicator.style.color = 'white';
|
33
|
-
clientIndicator.style.padding = '10px';
|
34
|
-
clientIndicator.style.borderRadius = '4px';
|
35
|
-
clientIndicator.style.margin = '10px 0';
|
36
|
-
clientIndicator.style.textAlign = 'center';
|
37
|
-
|
38
|
-
root.appendChild(clientIndicator);
|
39
|
-
|
40
|
-
// Load WASM if needed
|
41
|
-
if (typeof window.Go !== 'undefined') {
|
42
|
-
console.log('Go WASM runtime detected, initializing WASM module');
|
43
|
-
|
44
|
-
// This will be replaced with proper WASM loading in a future step
|
45
|
-
const wasmInfo = document.createElement('div');
|
46
|
-
wasmInfo.textContent = 'WASM runtime loaded successfully';
|
47
|
-
wasmInfo.style.backgroundColor = '#2196f3';
|
48
|
-
wasmInfo.style.color = 'white';
|
49
|
-
wasmInfo.style.padding = '10px';
|
50
|
-
wasmInfo.style.borderRadius = '4px';
|
51
|
-
wasmInfo.style.margin = '10px 0';
|
52
|
-
wasmInfo.style.textAlign = 'center';
|
53
|
-
|
54
|
-
root.appendChild(wasmInfo);
|
55
|
-
}
|
56
|
-
}
|
57
|
-
});
|