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
@@ -1,38 +0,0 @@
|
|
1
|
-
# Frontend Hamroun - Go WebAssembly Template with SSR
|
2
|
-
|
3
|
-
This template demonstrates integration between Frontend Hamroun, Go WebAssembly, and Server-Side Rendering for high-performance web applications.
|
4
|
-
|
5
|
-
## Features
|
6
|
-
|
7
|
-
- 🔄 Go + WebAssembly integration
|
8
|
-
- 🌐 Server-Side Rendering with client hydration
|
9
|
-
- ⚡ High-performance computation in both browser and server
|
10
|
-
- 🚀 Same Go code runs in both environments
|
11
|
-
- 🔍 SEO-friendly with pre-rendered HTML
|
12
|
-
|
13
|
-
## Prerequisites
|
14
|
-
|
15
|
-
- [Node.js](https://nodejs.org/) (v14+)
|
16
|
-
- [Go](https://golang.org/dl/) (v1.16+)
|
17
|
-
|
18
|
-
## Getting Started
|
19
|
-
|
20
|
-
1. Install dependencies:
|
21
|
-
```
|
22
|
-
npm install
|
23
|
-
```
|
24
|
-
|
25
|
-
2. Start the development server:
|
26
|
-
```
|
27
|
-
npm run dev
|
28
|
-
```
|
29
|
-
|
30
|
-
3. Open your browser and navigate to `http://localhost:3000`
|
31
|
-
|
32
|
-
The development server includes:
|
33
|
-
- Automatic WASM compilation from Go source
|
34
|
-
- Server-side rendering with Express
|
35
|
-
- Hot reloading of server code with Node's `--watch` flag
|
36
|
-
- Client-side hydration for interactivity
|
37
|
-
|
38
|
-
## Project Structure
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import fs from 'fs-extra';
|
2
|
-
import path from 'path';
|
3
|
-
import { fileURLToPath } from 'url';
|
4
|
-
|
5
|
-
// Get __dirname equivalent in ESM
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
7
|
-
const __dirname = path.dirname(__filename);
|
8
|
-
|
9
|
-
// Output directory
|
10
|
-
const outputDir = path.join(__dirname, 'dist');
|
11
|
-
|
12
|
-
// Ensure output directory exists
|
13
|
-
fs.ensureDirSync(outputDir);
|
14
|
-
|
15
|
-
// Copy necessary files for production
|
16
|
-
console.log('Copying files for production...');
|
17
|
-
|
18
|
-
// Copy HTML template
|
19
|
-
fs.copySync(path.join(__dirname, 'public', 'index.html'), path.join(outputDir, 'index.html'));
|
20
|
-
|
21
|
-
// Copy WASM files
|
22
|
-
const wasmDir = path.join(__dirname, 'public', 'wasm');
|
23
|
-
const distWasmDir = path.join(outputDir, 'wasm');
|
24
|
-
fs.ensureDirSync(distWasmDir);
|
25
|
-
|
26
|
-
if (fs.existsSync(wasmDir)) {
|
27
|
-
fs.copySync(wasmDir, distWasmDir);
|
28
|
-
console.log('Copied WASM files to:', distWasmDir);
|
29
|
-
} else {
|
30
|
-
console.warn('WASM directory not found:', wasmDir);
|
31
|
-
}
|
32
|
-
|
33
|
-
// Copy client.js for hydration
|
34
|
-
const srcDir = path.join(__dirname, 'src');
|
35
|
-
const distSrcDir = path.join(outputDir, 'src');
|
36
|
-
fs.ensureDirSync(distSrcDir);
|
37
|
-
fs.copySync(path.join(srcDir, 'client.js'), path.join(distSrcDir, 'client.js'));
|
38
|
-
|
39
|
-
// Copy any other static assets
|
40
|
-
const publicDir = path.join(__dirname, 'public');
|
41
|
-
fs.readdirSync(publicDir).forEach(file => {
|
42
|
-
if (file !== 'index.html' && file !== 'wasm') {
|
43
|
-
const srcPath = path.join(publicDir, file);
|
44
|
-
const destPath = path.join(outputDir, file);
|
45
|
-
fs.copySync(srcPath, destPath);
|
46
|
-
}
|
47
|
-
});
|
48
|
-
|
49
|
-
console.log('Build completed successfully.');
|
@@ -1,237 +0,0 @@
|
|
1
|
-
import { execSync } from 'child_process';
|
2
|
-
import { fileURLToPath } from 'url';
|
3
|
-
import { dirname, resolve, join } from 'path';
|
4
|
-
import fs from 'fs';
|
5
|
-
import os from 'os';
|
6
|
-
|
7
|
-
// Get __dirname equivalent in ESM
|
8
|
-
const __filename = fileURLToPath(import.meta.url);
|
9
|
-
const __dirname = dirname(__filename);
|
10
|
-
|
11
|
-
// Check if running on Windows
|
12
|
-
const isWindows = os.platform() === 'win32';
|
13
|
-
|
14
|
-
// Check if Go is installed
|
15
|
-
function checkGoInstallation() {
|
16
|
-
try {
|
17
|
-
const output = execSync('go version', { encoding: 'utf8' });
|
18
|
-
console.log(`✓ Found Go: ${output.trim()}`);
|
19
|
-
return true;
|
20
|
-
} catch (error) {
|
21
|
-
console.error('✗ Go is not installed or not in PATH');
|
22
|
-
console.error('Please install Go from https://golang.org/dl/');
|
23
|
-
return false;
|
24
|
-
}
|
25
|
-
}
|
26
|
-
|
27
|
-
// Ensure directory exists
|
28
|
-
function ensureDir(dir) {
|
29
|
-
if (!fs.existsSync(dir)) {
|
30
|
-
fs.mkdirSync(dir, { recursive: true });
|
31
|
-
console.log(`Created directory: ${dir}`);
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
// Build Go WASM modules
|
36
|
-
async function buildWasmModules() {
|
37
|
-
// Check if Go is installed
|
38
|
-
if (!checkGoInstallation()) {
|
39
|
-
process.exit(1);
|
40
|
-
}
|
41
|
-
|
42
|
-
// Directory containing Go source files
|
43
|
-
const goSourceDir = resolve(__dirname, 'src', 'wasm');
|
44
|
-
|
45
|
-
// Output directory for WASM files
|
46
|
-
const wasmOutputDir = resolve(__dirname, 'public', 'wasm');
|
47
|
-
|
48
|
-
// Create directories if they don't exist
|
49
|
-
ensureDir(goSourceDir);
|
50
|
-
ensureDir(wasmOutputDir);
|
51
|
-
|
52
|
-
// Get the Go root directory
|
53
|
-
const goRoot = execSync('go env GOROOT', { encoding: 'utf8' }).trim();
|
54
|
-
|
55
|
-
// Copy the wasm_exec.js files to the output directory (for both browser and Node.js)
|
56
|
-
const wasmExecJsPath = join(goRoot, 'misc', 'wasm', 'wasm_exec.js');
|
57
|
-
const wasmExecJsDest = join(wasmOutputDir, 'wasm_exec.js');
|
58
|
-
|
59
|
-
const wasmExecNodeJsPath = join(goRoot, 'misc', 'wasm', 'wasm_exec_node.js');
|
60
|
-
const wasmExecNodeJsDest = join(wasmOutputDir, 'wasm_exec_node.js');
|
61
|
-
|
62
|
-
console.log(`Copying ${wasmExecJsPath} to ${wasmExecJsDest}`);
|
63
|
-
fs.copyFileSync(wasmExecJsPath, wasmExecJsDest);
|
64
|
-
|
65
|
-
console.log(`Copying ${wasmExecNodeJsPath} to ${wasmExecNodeJsDest}`);
|
66
|
-
fs.copyFileSync(wasmExecNodeJsPath, wasmExecNodeJsDest);
|
67
|
-
|
68
|
-
// Build all Go files in the WASM directory
|
69
|
-
const goFiles = fs.readdirSync(goSourceDir).filter(file => file.endsWith('.go'));
|
70
|
-
|
71
|
-
if (goFiles.length === 0) {
|
72
|
-
console.log('No Go files found in src/wasm');
|
73
|
-
|
74
|
-
// Create an example Go file
|
75
|
-
const exampleGoFile = join(goSourceDir, 'example.go');
|
76
|
-
const exampleGoContent = `//go:build js && wasm
|
77
|
-
// +build js,wasm
|
78
|
-
|
79
|
-
package main
|
80
|
-
|
81
|
-
import (
|
82
|
-
"encoding/json"
|
83
|
-
"fmt"
|
84
|
-
"syscall/js"
|
85
|
-
)
|
86
|
-
|
87
|
-
// Example Go function to be called from JavaScript
|
88
|
-
func add(this js.Value, args []js.Value) interface{} {
|
89
|
-
if len(args) != 2 {
|
90
|
-
return js.ValueOf("Error: Expected two arguments")
|
91
|
-
}
|
92
|
-
|
93
|
-
a := args[0].Int()
|
94
|
-
b := args[1].Int()
|
95
|
-
return js.ValueOf(a + b)
|
96
|
-
}
|
97
|
-
|
98
|
-
// Process complex data in Go
|
99
|
-
func processData(this js.Value, args []js.Value) interface{} {
|
100
|
-
if len(args) == 0 {
|
101
|
-
return js.ValueOf("Error: Expected at least one argument")
|
102
|
-
}
|
103
|
-
|
104
|
-
// Get input data
|
105
|
-
data := args[0]
|
106
|
-
if data.Type() != js.TypeObject {
|
107
|
-
return js.ValueOf("Error: Expected JSON object")
|
108
|
-
}
|
109
|
-
|
110
|
-
// Convert JS object to Go map
|
111
|
-
jsonStr := js.Global().Get("JSON").Call("stringify", data).String()
|
112
|
-
var inputMap map[string]interface{}
|
113
|
-
if err := json.Unmarshal([]byte(jsonStr), &inputMap); err != nil {
|
114
|
-
return js.ValueOf(fmt.Sprintf("Error parsing JSON: %s", err.Error()))
|
115
|
-
}
|
116
|
-
|
117
|
-
// Add new fields
|
118
|
-
inputMap["processed"] = true
|
119
|
-
inputMap["processor"] = "Go WASM"
|
120
|
-
|
121
|
-
// Add some computed fields
|
122
|
-
if values, ok := inputMap["values"].([]interface{}); ok {
|
123
|
-
sum := 0.0
|
124
|
-
for _, v := range values {
|
125
|
-
if num, ok := v.(float64); ok {
|
126
|
-
sum += num
|
127
|
-
}
|
128
|
-
}
|
129
|
-
inputMap["sum"] = sum
|
130
|
-
}
|
131
|
-
|
132
|
-
// Convert back to JS
|
133
|
-
resultJSON, err := json.Marshal(inputMap)
|
134
|
-
if err != nil {
|
135
|
-
return js.ValueOf(fmt.Sprintf("Error generating JSON: %s", err.Error()))
|
136
|
-
}
|
137
|
-
|
138
|
-
return js.ValueOf(string(resultJSON))
|
139
|
-
}
|
140
|
-
|
141
|
-
func main() {
|
142
|
-
fmt.Println("Go WASM Module initialized")
|
143
|
-
|
144
|
-
// Register functions to be callable from JavaScript
|
145
|
-
js.Global().Set("goAdd", js.FuncOf(add))
|
146
|
-
js.Global().Set("goProcessData", js.FuncOf(processData))
|
147
|
-
|
148
|
-
// Keep the program running
|
149
|
-
<-make(chan bool)
|
150
|
-
}
|
151
|
-
`;
|
152
|
-
|
153
|
-
fs.writeFileSync(exampleGoFile, exampleGoContent);
|
154
|
-
console.log(`Created example Go file at ${exampleGoFile}`);
|
155
|
-
|
156
|
-
// Add the new file to the list
|
157
|
-
goFiles.push('example.go');
|
158
|
-
}
|
159
|
-
|
160
|
-
// Build each Go file
|
161
|
-
for (const goFile of goFiles) {
|
162
|
-
const goFilePath = join(goSourceDir, goFile);
|
163
|
-
const wasmFileName = goFile.replace('.go', '.wasm');
|
164
|
-
const wasmFilePath = join(wasmOutputDir, wasmFileName);
|
165
|
-
|
166
|
-
console.log(`Building ${goFile} to ${wasmFilePath}`);
|
167
|
-
|
168
|
-
try {
|
169
|
-
// Create a unique temporary directory with timestamp
|
170
|
-
const timestamp = Date.now();
|
171
|
-
const tempDir = join(os.tmpdir(), `go-wasm-build-${timestamp}`);
|
172
|
-
|
173
|
-
// Ensure the directory is clean (doesn't exist from previous builds)
|
174
|
-
if (fs.existsSync(tempDir)) {
|
175
|
-
if (isWindows) {
|
176
|
-
// On Windows, we need to handle directory removal differently
|
177
|
-
execSync(`rmdir /s /q "${tempDir}"`, { shell: true });
|
178
|
-
} else {
|
179
|
-
fs.rmSync(tempDir, { recursive: true, force: true });
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
// Create the temporary directory
|
184
|
-
ensureDir(tempDir);
|
185
|
-
|
186
|
-
// Copy the Go file to the temp directory
|
187
|
-
const tempGoFile = join(tempDir, goFile);
|
188
|
-
fs.copyFileSync(goFilePath, tempGoFile);
|
189
|
-
|
190
|
-
// Initialize Go module
|
191
|
-
console.log(`Initializing Go module in ${tempDir}`);
|
192
|
-
execSync(`go mod init wasmapp`, { cwd: tempDir });
|
193
|
-
|
194
|
-
// Build the WASM module with OS-specific command
|
195
|
-
if (isWindows) {
|
196
|
-
// Fix: Use Windows-specific environment variable setting
|
197
|
-
execSync(`go build -o "${wasmFilePath}" "${tempGoFile}"`, {
|
198
|
-
cwd: tempDir,
|
199
|
-
env: {
|
200
|
-
...process.env,
|
201
|
-
GOOS: 'js',
|
202
|
-
GOARCH: 'wasm'
|
203
|
-
}
|
204
|
-
});
|
205
|
-
} else {
|
206
|
-
// Unix/Linux/Mac command
|
207
|
-
execSync(`GOOS=js GOARCH=wasm go build -o "${wasmFilePath}" "${tempGoFile}"`, {
|
208
|
-
cwd: tempDir
|
209
|
-
});
|
210
|
-
}
|
211
|
-
|
212
|
-
// Clean up temporary directory
|
213
|
-
try {
|
214
|
-
if (isWindows) {
|
215
|
-
execSync(`rmdir /s /q "${tempDir}"`, { shell: true });
|
216
|
-
} else {
|
217
|
-
fs.rmSync(tempDir, { recursive: true, force: true });
|
218
|
-
}
|
219
|
-
} catch (cleanupError) {
|
220
|
-
console.warn(`Warning: Failed to clean up temp directory ${tempDir}:`, cleanupError);
|
221
|
-
}
|
222
|
-
|
223
|
-
console.log(`✓ Successfully built ${wasmFileName}`);
|
224
|
-
} catch (error) {
|
225
|
-
console.error(`✗ Error building ${goFile}:`);
|
226
|
-
console.error(error.message);
|
227
|
-
if (error.stdout) console.error(error.stdout.toString());
|
228
|
-
if (error.stderr) console.error(error.stderr.toString());
|
229
|
-
}
|
230
|
-
}
|
231
|
-
}
|
232
|
-
|
233
|
-
// Run the build process
|
234
|
-
buildWasmModules().catch(error => {
|
235
|
-
console.error('Build failed:', error);
|
236
|
-
process.exit(1);
|
237
|
-
});
|
@@ -1,23 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"name": "go-wasm-app",
|
3
|
-
"version": "1.0.0",
|
4
|
-
"description": "WebAssembly integration with Go for Frontend Hamroun with SSR",
|
5
|
-
"type": "module",
|
6
|
-
"main": "server.js",
|
7
|
-
"scripts": {
|
8
|
-
"build:wasm": "node build-wasm.js",
|
9
|
-
"prepare": "node -e \"if (!require('fs').existsSync('public/wasm')) { require('fs').mkdirSync('public/wasm', {recursive: true}); }\"",
|
10
|
-
"dev": "npm run build:wasm && node --watch server.js",
|
11
|
-
"build": "npm run build:wasm && node -e \"require('fs').mkdirSync('dist', {recursive: true}); require('fs-extra').copySync('public', 'dist')\"",
|
12
|
-
"start": "cross-env NODE_ENV=production node server.js"
|
13
|
-
},
|
14
|
-
"dependencies": {
|
15
|
-
"express": "^4.18.2",
|
16
|
-
"frontend-hamroun": "^1.2.71",
|
17
|
-
"fs-extra": "^10.0.0"
|
18
|
-
},
|
19
|
-
"devDependencies": {
|
20
|
-
"@babel/core": "^7.22.9",
|
21
|
-
"cross-env": "^7.0.3"
|
22
|
-
}
|
23
|
-
}
|
@@ -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
|