frontend-hamroun 1.2.77 → 1.2.79
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/batch/package.json +1 -1
- package/dist/client-router/package.json +1 -1
- package/dist/component/package.json +1 -1
- package/dist/context/package.json +1 -1
- package/dist/event-bus/package.json +1 -1
- package/dist/forms/package.json +1 -1
- package/dist/hooks/package.json +1 -1
- package/dist/index.mjs +1 -0
- package/dist/jsx-runtime/package.json +1 -1
- package/dist/lifecycle-events/package.json +1 -1
- package/dist/package.json +1 -1
- package/dist/render-component/package.json +1 -1
- package/dist/renderer/package.json +1 -1
- package/dist/router/package.json +1 -1
- package/dist/server/package.json +1 -1
- package/dist/server/src/index.js +24 -23
- package/dist/server/src/index.js.map +1 -1
- package/dist/server/src/renderComponent.d.ts +8 -9
- package/dist/server/src/renderComponent.js +10 -5
- package/dist/server/src/renderComponent.js.map +1 -1
- package/dist/server/src/server/index.d.ts +23 -34
- package/dist/server/src/server/index.js +170 -50
- package/dist/server/src/server/index.js.map +1 -1
- package/dist/server/src/server/templates.d.ts +2 -0
- package/dist/server/src/server/templates.js +9 -5
- package/dist/server/src/server/templates.js.map +1 -1
- package/dist/server/src/server/utils.d.ts +1 -1
- package/dist/server/src/server/utils.js +1 -1
- package/dist/server/src/server/utils.js.map +1 -1
- package/dist/server/tsconfig.server.tsbuildinfo +1 -1
- package/dist/server-renderer/package.json +1 -1
- package/dist/store/package.json +1 -1
- package/dist/types/package.json +1 -1
- package/dist/utils/package.json +1 -1
- package/dist/vdom/package.json +1 -1
- package/dist/wasm/package.json +1 -1
- package/package.json +1 -1
- package/templates/complete-app/client.js +58 -0
- package/templates/complete-app/package-lock.json +2536 -0
- package/templates/complete-app/package.json +8 -31
- package/templates/complete-app/pages/about.js +119 -0
- package/templates/complete-app/pages/index.js +157 -0
- package/templates/complete-app/pages/wasm-demo.js +290 -0
- package/templates/complete-app/public/client.js +80 -0
- package/templates/complete-app/public/index.html +47 -0
- package/templates/complete-app/public/styles.css +446 -212
- package/templates/complete-app/readme.md +188 -0
- package/templates/complete-app/server.js +417 -0
- package/templates/complete-app/server.ts +275 -0
- package/templates/complete-app/src/App.tsx +59 -0
- package/templates/complete-app/src/client.ts +61 -0
- package/templates/complete-app/src/client.tsx +18 -0
- package/templates/complete-app/src/pages/index.tsx +51 -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/complete-app/vite.config.js +57 -0
- package/templates/complete-app/vite.config.ts +30 -0
- package/templates/go/example.go +154 -99
- package/templates/complete-app/build.js +0 -284
- package/templates/complete-app/src/api/index.js +0 -31
- package/templates/complete-app/src/client.js +0 -93
- package/templates/complete-app/src/components/App.js +0 -66
- package/templates/complete-app/src/components/Footer.js +0 -19
- package/templates/complete-app/src/components/Header.js +0 -38
- package/templates/complete-app/src/pages/About.js +0 -59
- package/templates/complete-app/src/pages/Home.js +0 -54
- package/templates/complete-app/src/pages/WasmDemo.js +0 -136
- package/templates/complete-app/src/server.js +0 -186
- package/templates/complete-app/src/wasm/build.bat +0 -16
- package/templates/complete-app/src/wasm/build.sh +0 -16
- package/templates/complete-app/src/wasm/example.go +0 -101
@@ -1,284 +0,0 @@
|
|
1
|
-
import { execSync } from 'child_process';
|
2
|
-
import path from 'path';
|
3
|
-
import fs from 'fs';
|
4
|
-
import esbuild from 'esbuild';
|
5
|
-
import http from 'http';
|
6
|
-
import { fileURLToPath } from 'url';
|
7
|
-
|
8
|
-
// Get __dirname equivalent in ESM
|
9
|
-
const __filename = fileURLToPath(import.meta.url);
|
10
|
-
const __dirname = path.dirname(__filename);
|
11
|
-
|
12
|
-
// ANSI color codes for console output
|
13
|
-
const colors = {
|
14
|
-
reset: "\x1b[0m",
|
15
|
-
bright: "\x1b[1m",
|
16
|
-
dim: "\x1b[2m",
|
17
|
-
cyan: "\x1b[36m",
|
18
|
-
green: "\x1b[32m",
|
19
|
-
yellow: "\x1b[33m",
|
20
|
-
red: "\x1b[31m"
|
21
|
-
};
|
22
|
-
|
23
|
-
// Parse command line arguments
|
24
|
-
const args = process.argv.slice(2);
|
25
|
-
const isProduction = process.env.NODE_ENV === 'production';
|
26
|
-
const wasmOnly = args.includes('--wasm-only');
|
27
|
-
const serve = args.includes('--serve');
|
28
|
-
|
29
|
-
// Helper for logging with colors
|
30
|
-
function log(message, type = 'info') {
|
31
|
-
const prefix = {
|
32
|
-
info: `${colors.bright}${colors.cyan}[INFO]${colors.reset}`,
|
33
|
-
success: `${colors.bright}${colors.green}[SUCCESS]${colors.reset}`,
|
34
|
-
warning: `${colors.bright}${colors.yellow}[WARNING]${colors.reset}`,
|
35
|
-
error: `${colors.bright}${colors.red}[ERROR]${colors.reset}`
|
36
|
-
};
|
37
|
-
|
38
|
-
console.log(`${prefix[type] || prefix.info} ${message}`);
|
39
|
-
}
|
40
|
-
|
41
|
-
// Build configuration
|
42
|
-
const config = {
|
43
|
-
// Entry points
|
44
|
-
entryPoints: {
|
45
|
-
client: 'src/client.js',
|
46
|
-
server: 'src/server.js'
|
47
|
-
},
|
48
|
-
|
49
|
-
// Output directories
|
50
|
-
outDir: {
|
51
|
-
client: 'dist/public',
|
52
|
-
server: 'dist'
|
53
|
-
},
|
54
|
-
|
55
|
-
// WASM configuration
|
56
|
-
wasm: {
|
57
|
-
dir: 'src/wasm',
|
58
|
-
buildScript: process.platform === 'win32' ? 'build.bat' : './build.sh',
|
59
|
-
outputDir: 'dist/public/wasm'
|
60
|
-
}
|
61
|
-
};
|
62
|
-
|
63
|
-
// Build WASM modules if they exist
|
64
|
-
async function buildWasmModules() {
|
65
|
-
const wasmDir = path.join(__dirname, config.wasm.dir);
|
66
|
-
|
67
|
-
if (!fs.existsSync(wasmDir)) {
|
68
|
-
log('No WASM directory found, skipping WASM build', 'warning');
|
69
|
-
return;
|
70
|
-
}
|
71
|
-
|
72
|
-
log('Building WebAssembly modules...');
|
73
|
-
|
74
|
-
try {
|
75
|
-
// Execute build script in WASM directory
|
76
|
-
execSync(config.wasm.buildScript, {
|
77
|
-
cwd: wasmDir,
|
78
|
-
stdio: 'inherit'
|
79
|
-
});
|
80
|
-
|
81
|
-
// Ensure output directory exists
|
82
|
-
const outputDir = path.join(__dirname, config.wasm.outputDir);
|
83
|
-
if (!fs.existsSync(outputDir)) {
|
84
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
85
|
-
}
|
86
|
-
|
87
|
-
// Copy WASM files to output directory
|
88
|
-
const wasmFiles = fs.readdirSync(wasmDir).filter(file =>
|
89
|
-
file.endsWith('.wasm') || file === 'wasm_exec.js');
|
90
|
-
|
91
|
-
for (const file of wasmFiles) {
|
92
|
-
fs.copyFileSync(
|
93
|
-
path.join(wasmDir, file),
|
94
|
-
path.join(outputDir, file)
|
95
|
-
);
|
96
|
-
}
|
97
|
-
|
98
|
-
log(`WebAssembly modules built and copied to ${config.wasm.outputDir}`, 'success');
|
99
|
-
} catch (error) {
|
100
|
-
log(`Failed to build WebAssembly modules: ${error.message}`, 'error');
|
101
|
-
if (!wasmOnly) {
|
102
|
-
log('Continuing with rest of build...', 'warning');
|
103
|
-
} else {
|
104
|
-
process.exit(1);
|
105
|
-
}
|
106
|
-
}
|
107
|
-
}
|
108
|
-
|
109
|
-
// Build client-side code
|
110
|
-
async function buildClient() {
|
111
|
-
log('Building client bundle...');
|
112
|
-
|
113
|
-
try {
|
114
|
-
const clientOutDir = path.join(__dirname, config.outDir.client);
|
115
|
-
|
116
|
-
// Ensure output directory exists
|
117
|
-
if (!fs.existsSync(clientOutDir)) {
|
118
|
-
fs.mkdirSync(clientOutDir, { recursive: true });
|
119
|
-
}
|
120
|
-
|
121
|
-
// Bundle client code
|
122
|
-
await esbuild.build({
|
123
|
-
entryPoints: [path.join(__dirname, config.entryPoints.client)],
|
124
|
-
bundle: true,
|
125
|
-
outfile: path.join(clientOutDir, 'client.js'),
|
126
|
-
format: 'esm',
|
127
|
-
platform: 'browser',
|
128
|
-
target: ['es2020'],
|
129
|
-
minify: isProduction,
|
130
|
-
sourcemap: !isProduction,
|
131
|
-
define: {
|
132
|
-
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
|
133
|
-
},
|
134
|
-
loader: {
|
135
|
-
'.js': 'jsx',
|
136
|
-
'.jsx': 'jsx'
|
137
|
-
}
|
138
|
-
});
|
139
|
-
|
140
|
-
// Copy index.html if it exists
|
141
|
-
const indexPath = path.join(__dirname, 'src/index.html');
|
142
|
-
if (fs.existsSync(indexPath)) {
|
143
|
-
fs.copyFileSync(indexPath, path.join(clientOutDir, 'index.html'));
|
144
|
-
}
|
145
|
-
|
146
|
-
log('Client bundle built successfully', 'success');
|
147
|
-
} catch (error) {
|
148
|
-
log(`Failed to build client bundle: ${error.message}`, 'error');
|
149
|
-
process.exit(1);
|
150
|
-
}
|
151
|
-
}
|
152
|
-
|
153
|
-
// Build server-side code
|
154
|
-
async function buildServer() {
|
155
|
-
log('Building server bundle...');
|
156
|
-
|
157
|
-
try {
|
158
|
-
const serverOutDir = path.join(__dirname, config.outDir.server);
|
159
|
-
|
160
|
-
// Ensure output directory exists
|
161
|
-
if (!fs.existsSync(serverOutDir)) {
|
162
|
-
fs.mkdirSync(serverOutDir, { recursive: true });
|
163
|
-
}
|
164
|
-
|
165
|
-
// Bundle server code
|
166
|
-
await esbuild.build({
|
167
|
-
entryPoints: [path.join(__dirname, config.entryPoints.server)],
|
168
|
-
bundle: true,
|
169
|
-
outfile: path.join(serverOutDir, 'server.js'),
|
170
|
-
format: 'esm',
|
171
|
-
platform: 'node',
|
172
|
-
target: ['node16'],
|
173
|
-
minify: isProduction,
|
174
|
-
sourcemap: !isProduction,
|
175
|
-
define: {
|
176
|
-
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development')
|
177
|
-
},
|
178
|
-
loader: {
|
179
|
-
'.js': 'jsx',
|
180
|
-
'.jsx': 'jsx'
|
181
|
-
},
|
182
|
-
external: ['express', 'frontend-hamroun', 'compression', 'cors', 'path', 'fs', 'http', 'socket.io']
|
183
|
-
});
|
184
|
-
|
185
|
-
log('Server bundle built successfully', 'success');
|
186
|
-
} catch (error) {
|
187
|
-
log(`Failed to build server bundle: ${error.message}`, 'error');
|
188
|
-
process.exit(1);
|
189
|
-
}
|
190
|
-
}
|
191
|
-
|
192
|
-
// Copy static assets like CSS, images, etc.
|
193
|
-
function copyStaticAssets() {
|
194
|
-
log('Copying static assets...');
|
195
|
-
|
196
|
-
const publicDir = path.join(__dirname, 'public');
|
197
|
-
const outputDir = path.join(__dirname, config.outDir.client);
|
198
|
-
|
199
|
-
if (fs.existsSync(publicDir)) {
|
200
|
-
// Recursive function to copy directory contents
|
201
|
-
function copyDir(src, dest) {
|
202
|
-
// Create destination directory if it doesn't exist
|
203
|
-
if (!fs.existsSync(dest)) {
|
204
|
-
fs.mkdirSync(dest, { recursive: true });
|
205
|
-
}
|
206
|
-
|
207
|
-
// Read all files in source directory
|
208
|
-
const entries = fs.readdirSync(src, { withFileTypes: true });
|
209
|
-
|
210
|
-
for (const entry of entries) {
|
211
|
-
const srcPath = path.join(src, entry.name);
|
212
|
-
const destPath = path.join(dest, entry.name);
|
213
|
-
|
214
|
-
if (entry.isDirectory()) {
|
215
|
-
// Recursively copy subdirectories
|
216
|
-
copyDir(srcPath, destPath);
|
217
|
-
} else {
|
218
|
-
// Copy files
|
219
|
-
fs.copyFileSync(srcPath, destPath);
|
220
|
-
}
|
221
|
-
}
|
222
|
-
}
|
223
|
-
|
224
|
-
copyDir(publicDir, outputDir);
|
225
|
-
log('Static assets copied successfully', 'success');
|
226
|
-
} else {
|
227
|
-
log('No static assets to copy (public directory not found)', 'warning');
|
228
|
-
}
|
229
|
-
}
|
230
|
-
|
231
|
-
// Start a development server
|
232
|
-
async function startDevServer() {
|
233
|
-
log('Starting development server...');
|
234
|
-
|
235
|
-
// Import server module
|
236
|
-
try {
|
237
|
-
// Use dynamic import because this is ESM
|
238
|
-
const serverModule = await import('./dist/server.js');
|
239
|
-
log('Server started. Press Ctrl+C to stop.', 'success');
|
240
|
-
} catch (error) {
|
241
|
-
log(`Failed to start development server: ${error.message}`, 'error');
|
242
|
-
process.exit(1);
|
243
|
-
}
|
244
|
-
}
|
245
|
-
|
246
|
-
// Main build function
|
247
|
-
async function build() {
|
248
|
-
console.log('\n' + '='.repeat(60));
|
249
|
-
log(`Building ${isProduction ? 'production' : 'development'} bundle...`);
|
250
|
-
console.log('='.repeat(60) + '\n');
|
251
|
-
|
252
|
-
try {
|
253
|
-
// Build WASM first
|
254
|
-
await buildWasmModules();
|
255
|
-
|
256
|
-
// If wasm-only flag is provided, exit after building WASM
|
257
|
-
if (wasmOnly) {
|
258
|
-
log('WASM-only build completed', 'success');
|
259
|
-
return;
|
260
|
-
}
|
261
|
-
|
262
|
-
// Build client and server code
|
263
|
-
await Promise.all([
|
264
|
-
buildClient(),
|
265
|
-
buildServer()
|
266
|
-
]);
|
267
|
-
|
268
|
-
// Copy static assets
|
269
|
-
copyStaticAssets();
|
270
|
-
|
271
|
-
log('Build completed successfully', 'success');
|
272
|
-
|
273
|
-
// Start development server if requested
|
274
|
-
if (serve) {
|
275
|
-
await startDevServer();
|
276
|
-
}
|
277
|
-
} catch (error) {
|
278
|
-
log(`Build failed: ${error.message}`, 'error');
|
279
|
-
process.exit(1);
|
280
|
-
}
|
281
|
-
}
|
282
|
-
|
283
|
-
// Run the build
|
284
|
-
build();
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import express from 'express';
|
2
|
-
|
3
|
-
// Create API router
|
4
|
-
const ApiRouter = express.Router();
|
5
|
-
|
6
|
-
// Random data endpoint
|
7
|
-
ApiRouter.get('/random', (req, res) => {
|
8
|
-
const value = Math.floor(Math.random() * 1000);
|
9
|
-
res.json({ value });
|
10
|
-
});
|
11
|
-
|
12
|
-
// Echo endpoint
|
13
|
-
ApiRouter.post('/echo', (req, res) => {
|
14
|
-
res.json({
|
15
|
-
method: 'POST',
|
16
|
-
body: req.body,
|
17
|
-
timestamp: new Date().toISOString()
|
18
|
-
});
|
19
|
-
});
|
20
|
-
|
21
|
-
// Status endpoint
|
22
|
-
ApiRouter.get('/status', (req, res) => {
|
23
|
-
res.json({
|
24
|
-
status: 'ok',
|
25
|
-
timestamp: new Date().toISOString(),
|
26
|
-
environment: process.env.NODE_ENV || 'development',
|
27
|
-
uptime: process.uptime()
|
28
|
-
});
|
29
|
-
});
|
30
|
-
|
31
|
-
export { ApiRouter };
|
@@ -1,93 +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
|
-
hydrate,
|
10
|
-
render,
|
11
|
-
jsx,
|
12
|
-
useState,
|
13
|
-
useEffect,
|
14
|
-
loadGoWasm,
|
15
|
-
createContext,
|
16
|
-
useContext
|
17
|
-
} = frontendHamroun;
|
18
|
-
|
19
|
-
// Import components
|
20
|
-
import App from './components/App.js';
|
21
|
-
|
22
|
-
// Initialize the app
|
23
|
-
async function initApp() {
|
24
|
-
console.log('Initializing client-side app...');
|
25
|
-
|
26
|
-
// Check if we need to hydrate (SSR) or do a fresh render
|
27
|
-
const rootElement = document.getElementById('app');
|
28
|
-
const shouldHydrate = rootElement.hasAttribute('data-ssr');
|
29
|
-
|
30
|
-
try {
|
31
|
-
// Pre-load any WASM modules if needed
|
32
|
-
let wasmModule = null;
|
33
|
-
try {
|
34
|
-
wasmModule = await loadGoWasm('/wasm/example.wasm', {
|
35
|
-
debug: false,
|
36
|
-
goWasmPath: '/wasm/wasm_exec.js'
|
37
|
-
});
|
38
|
-
console.log('WASM module loaded successfully');
|
39
|
-
} catch (error) {
|
40
|
-
console.warn('WASM module loading skipped:', error.message);
|
41
|
-
}
|
42
|
-
|
43
|
-
// Create initial state from SSR data if available
|
44
|
-
const initialDataElement = document.getElementById('__INITIAL_DATA__');
|
45
|
-
const initialData = initialDataElement
|
46
|
-
? JSON.parse(initialDataElement.textContent || '{}')
|
47
|
-
: {};
|
48
|
-
|
49
|
-
// Setup global context values
|
50
|
-
const appContext = {
|
51
|
-
wasm: wasmModule,
|
52
|
-
initialData,
|
53
|
-
// Add any other global values
|
54
|
-
};
|
55
|
-
|
56
|
-
// Render or hydrate the app
|
57
|
-
if (shouldHydrate) {
|
58
|
-
console.log('Hydrating app from server-rendered HTML');
|
59
|
-
await hydrate(<App context={appContext} />, rootElement);
|
60
|
-
} else {
|
61
|
-
console.log('Rendering app from scratch (client-only)');
|
62
|
-
await render(<App context={appContext} />, rootElement);
|
63
|
-
}
|
64
|
-
|
65
|
-
console.log('App initialization complete');
|
66
|
-
} catch (error) {
|
67
|
-
console.error('Failed to initialize app:', error);
|
68
|
-
|
69
|
-
// Fallback to basic error display
|
70
|
-
rootElement.innerHTML = `
|
71
|
-
<div style="color: red; padding: 20px; border: 1px solid red; margin: 20px;">
|
72
|
-
<h2>Error Initializing App</h2>
|
73
|
-
<pre>${error.message}\n${error.stack}</pre>
|
74
|
-
</div>
|
75
|
-
`;
|
76
|
-
}
|
77
|
-
}
|
78
|
-
|
79
|
-
// Start the app when the DOM is ready
|
80
|
-
if (document.readyState === 'loading') {
|
81
|
-
document.addEventListener('DOMContentLoaded', initApp);
|
82
|
-
} else {
|
83
|
-
initApp();
|
84
|
-
}
|
85
|
-
|
86
|
-
// Export key utilities for components
|
87
|
-
export {
|
88
|
-
jsx,
|
89
|
-
useState,
|
90
|
-
useEffect,
|
91
|
-
createContext,
|
92
|
-
useContext
|
93
|
-
};
|
@@ -1,66 +0,0 @@
|
|
1
|
-
import { jsx, useState, useEffect, createContext, useContext } from '../client.js';
|
2
|
-
import Header from './Header.js';
|
3
|
-
import Footer from './Footer.js';
|
4
|
-
import Home from '../pages/Home.js';
|
5
|
-
import About from '../pages/About.js';
|
6
|
-
import WasmDemo from '../pages/WasmDemo.js';
|
7
|
-
|
8
|
-
// Create context for global state
|
9
|
-
export const AppContext = createContext({});
|
10
|
-
|
11
|
-
// Simple router implementation
|
12
|
-
function useRouter() {
|
13
|
-
const { initialData } = useContext(AppContext);
|
14
|
-
const [path, setPath] = useState(initialData?.path || '/');
|
15
|
-
|
16
|
-
useEffect(() => {
|
17
|
-
// Update path when URL changes
|
18
|
-
const handlePopState = () => {
|
19
|
-
setPath(window.location.pathname);
|
20
|
-
};
|
21
|
-
|
22
|
-
// Listen for navigation events
|
23
|
-
window.addEventListener('popstate', handlePopState);
|
24
|
-
|
25
|
-
// Cleanup
|
26
|
-
return () => {
|
27
|
-
window.removeEventListener('popstate', handlePopState);
|
28
|
-
};
|
29
|
-
}, []);
|
30
|
-
|
31
|
-
// Navigation function
|
32
|
-
const navigate = (to) => {
|
33
|
-
window.history.pushState(null, '', to);
|
34
|
-
setPath(to);
|
35
|
-
};
|
36
|
-
|
37
|
-
return { path, navigate };
|
38
|
-
}
|
39
|
-
|
40
|
-
// Define available routes
|
41
|
-
const routes = {
|
42
|
-
'/': Home,
|
43
|
-
'/about': About,
|
44
|
-
'/wasm': WasmDemo
|
45
|
-
};
|
46
|
-
|
47
|
-
// Main App component
|
48
|
-
export default function App({ context }) {
|
49
|
-
// Get current path from router
|
50
|
-
const { path, navigate } = useRouter();
|
51
|
-
|
52
|
-
// Find the component for the current route
|
53
|
-
const PageComponent = routes[path] || routes['/'];
|
54
|
-
|
55
|
-
return (
|
56
|
-
<AppContext.Provider value={{ ...context, navigate }}>
|
57
|
-
<div className="app">
|
58
|
-
<Header />
|
59
|
-
<main className="content">
|
60
|
-
<PageComponent />
|
61
|
-
</main>
|
62
|
-
<Footer />
|
63
|
-
</div>
|
64
|
-
</AppContext.Provider>
|
65
|
-
);
|
66
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { jsx } from '../client.js';
|
2
|
-
|
3
|
-
export default function Footer() {
|
4
|
-
return (
|
5
|
-
<footer className="app-footer">
|
6
|
-
<div className="footer-content">
|
7
|
-
<p>© {new Date().getFullYear()} Baraqex Framework</p>
|
8
|
-
<div className="footer-links">
|
9
|
-
<a href="https://github.com/hamroun/frontend-hamroun" target="_blank" rel="noopener">
|
10
|
-
GitHub
|
11
|
-
</a>
|
12
|
-
<a href="https://pfe-documantation-mohamedx2s-projects.vercel.app/" target="_blank" rel="noopener">
|
13
|
-
Documentation
|
14
|
-
</a>
|
15
|
-
</div>
|
16
|
-
</div>
|
17
|
-
</footer>
|
18
|
-
);
|
19
|
-
}
|
@@ -1,38 +0,0 @@
|
|
1
|
-
import { jsx } from '../client.js';
|
2
|
-
import { AppContext } from './App.js';
|
3
|
-
|
4
|
-
export default function Header() {
|
5
|
-
const { navigate } = AppContext;
|
6
|
-
|
7
|
-
const handleNavClick = (e, path) => {
|
8
|
-
e.preventDefault();
|
9
|
-
navigate(path);
|
10
|
-
};
|
11
|
-
|
12
|
-
return (
|
13
|
-
<header className="app-header">
|
14
|
-
<div className="logo">
|
15
|
-
<h1>Baraqex Complete App</h1>
|
16
|
-
</div>
|
17
|
-
<nav className="main-nav">
|
18
|
-
<ul>
|
19
|
-
<li>
|
20
|
-
<a href="/" onClick={(e) => handleNavClick(e, '/')}>
|
21
|
-
Home
|
22
|
-
</a>
|
23
|
-
</li>
|
24
|
-
<li>
|
25
|
-
<a href="/about" onClick={(e) => handleNavClick(e, '/about')}>
|
26
|
-
About
|
27
|
-
</a>
|
28
|
-
</li>
|
29
|
-
<li>
|
30
|
-
<a href="/wasm" onClick={(e) => handleNavClick(e, '/wasm')}>
|
31
|
-
WASM Demo
|
32
|
-
</a>
|
33
|
-
</li>
|
34
|
-
</ul>
|
35
|
-
</nav>
|
36
|
-
</header>
|
37
|
-
);
|
38
|
-
}
|
@@ -1,59 +0,0 @@
|
|
1
|
-
import { jsx, useEffect } from '../client.js';
|
2
|
-
|
3
|
-
export default function About() {
|
4
|
-
useEffect(() => {
|
5
|
-
document.title = 'About - Baraqex Complete App';
|
6
|
-
}, []);
|
7
|
-
|
8
|
-
return (
|
9
|
-
<div className="about-page">
|
10
|
-
<h1>About Baraqex Framework</h1>
|
11
|
-
|
12
|
-
<section className="about-section">
|
13
|
-
<h2>Framework Architecture</h2>
|
14
|
-
<p>
|
15
|
-
Baraqex is a lightweight full-stack JavaScript framework designed for modern web applications.
|
16
|
-
It features a virtual DOM implementation, hooks-based state management, server-side rendering,
|
17
|
-
and WebAssembly integration.
|
18
|
-
</p>
|
19
|
-
</section>
|
20
|
-
|
21
|
-
<section className="about-section">
|
22
|
-
<h2>Key Features</h2>
|
23
|
-
<ul>
|
24
|
-
<li>
|
25
|
-
<strong>Virtual DOM:</strong> Efficient DOM updates through a lightweight virtual DOM implementation.
|
26
|
-
</li>
|
27
|
-
<li>
|
28
|
-
<strong>Hooks:</strong> React-like hooks including useState, useEffect, useContext, and more.
|
29
|
-
</li>
|
30
|
-
<li>
|
31
|
-
<strong>Server-Side Rendering:</strong> Improve SEO and initial load performance with SSR.
|
32
|
-
</li>
|
33
|
-
<li>
|
34
|
-
<strong>WebAssembly Integration:</strong> Run high-performance Go code in the browser.
|
35
|
-
</li>
|
36
|
-
<li>
|
37
|
-
<strong>API Routing:</strong> Express-based API with file-based routing.
|
38
|
-
</li>
|
39
|
-
<li>
|
40
|
-
<strong>Development Tools:</strong> CLI tools for project scaffolding and component generation.
|
41
|
-
</li>
|
42
|
-
</ul>
|
43
|
-
</section>
|
44
|
-
|
45
|
-
<section className="about-section">
|
46
|
-
<h2>Use Cases</h2>
|
47
|
-
<p>
|
48
|
-
Baraqex is ideal for:
|
49
|
-
</p>
|
50
|
-
<ul>
|
51
|
-
<li>Web applications requiring high performance</li>
|
52
|
-
<li>Projects that need SEO optimization</li>
|
53
|
-
<li>Applications with computation-heavy features</li>
|
54
|
-
<li>Full-stack JavaScript applications</li>
|
55
|
-
</ul>
|
56
|
-
</section>
|
57
|
-
</div>
|
58
|
-
);
|
59
|
-
}
|
@@ -1,54 +0,0 @@
|
|
1
|
-
import { jsx, useState, useEffect, useContext } from '../client.js';
|
2
|
-
import { AppContext } from '../components/App.js';
|
3
|
-
|
4
|
-
export default function Home() {
|
5
|
-
const { initialData } = useContext(AppContext);
|
6
|
-
const [count, setCount] = useState(0);
|
7
|
-
|
8
|
-
useEffect(() => {
|
9
|
-
document.title = 'Home - Baraqex Complete App';
|
10
|
-
}, []);
|
11
|
-
|
12
|
-
return (
|
13
|
-
<div className="home-page">
|
14
|
-
<section className="hero">
|
15
|
-
<h1>Welcome to Baraqex Framework</h1>
|
16
|
-
<p className="subtitle">A complete JavaScript framework for modern web applications</p>
|
17
|
-
|
18
|
-
<div className="features">
|
19
|
-
<div className="feature">
|
20
|
-
<h3>Server-Side Rendering</h3>
|
21
|
-
<p>Initial page was rendered on the server at: {initialData?.timestamp}</p>
|
22
|
-
</div>
|
23
|
-
|
24
|
-
<div className="feature">
|
25
|
-
<h3>State Management</h3>
|
26
|
-
<div className="counter">
|
27
|
-
<button onClick={() => setCount(c => c - 1)}>-</button>
|
28
|
-
<span>{count}</span>
|
29
|
-
<button onClick={() => setCount(c => c + 1)}>+</button>
|
30
|
-
</div>
|
31
|
-
</div>
|
32
|
-
|
33
|
-
<div className="feature">
|
34
|
-
<h3>API Integration</h3>
|
35
|
-
<button className="api-button" onClick={fetchRandomData}>
|
36
|
-
Fetch Random Data
|
37
|
-
</button>
|
38
|
-
</div>
|
39
|
-
</div>
|
40
|
-
</section>
|
41
|
-
</div>
|
42
|
-
);
|
43
|
-
|
44
|
-
async function fetchRandomData() {
|
45
|
-
try {
|
46
|
-
const response = await fetch('/api/random');
|
47
|
-
const data = await response.json();
|
48
|
-
alert(`Random value: ${data.value}`);
|
49
|
-
} catch (error) {
|
50
|
-
console.error('Error fetching data:', error);
|
51
|
-
alert('Failed to fetch data. See console for details.');
|
52
|
-
}
|
53
|
-
}
|
54
|
-
}
|