baraqex 2.0.4 → 2.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baraqex",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "A full-stack WebAssembly framework for building fast, modern web applications.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -63,11 +63,20 @@ function buildWasm() {
63
63
 
64
64
  function copyRuntime() {
65
65
  const root = goRoot();
66
- const wasmExec = path.join(root, 'lib', 'wasm', 'wasm_exec.js');
66
+ const candidates = [
67
+ path.join(root, 'lib', 'wasm', 'wasm_exec.js'),
68
+ path.join(root, 'misc', 'wasm', 'wasm_exec.js')
69
+ ];
70
+ const wasmExec = candidates.find((p) => existsSync(p));
67
71
  const dest = path.join(outputDir, 'wasm_exec.js');
68
72
 
69
- if (!existsSync(wasmExec)) {
70
- console.warn(`⚠️ wasm_exec.js not found at ${wasmExec}. You must copy it manually.`);
73
+ if (!wasmExec) {
74
+ console.warn(
75
+ '⚠️ wasm_exec.js not found in this Go install. ' +
76
+ 'Copy it to public/wasm/wasm_exec.js manually:\n' +
77
+ ` cp "${candidates.join('" OR "')}" ${dest}\n` +
78
+ '(location varies by Go version: misc/wasm or lib/wasm)'
79
+ );
71
80
  return;
72
81
  }
73
82
 
@@ -4,6 +4,7 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Baraqex Full-Stack App</title>
7
+ <link rel="icon" href="data:,">
7
8
  <link rel="stylesheet" href="/build/styles.css">
8
9
  <script>window.__INITIAL_STATE__ = {};</script>
9
10
  </head>
@@ -57,16 +57,20 @@ app.get('/api/users', (req, res) => {
57
57
  res.json(store.users);
58
58
  });
59
59
 
60
- app.get('/api/users/:id', (req, res) => {
60
+ app.get('/api/users/:id', (req: Request, res: Response) => {
61
61
  const user = store.users.find((u) => u.id === parseInt(req.params.id, 10));
62
- if (user) return res.json(user);
62
+ if (user) {
63
+ res.json(user);
64
+ return;
65
+ }
63
66
  res.status(404).json({ error: 'User not found' });
64
67
  });
65
68
 
66
- app.get('/api/posts', (req, res) => {
69
+ app.get('/api/posts', (req: Request, res: Response) => {
67
70
  const { authorId } = req.query;
68
71
  if (authorId) {
69
- return res.json(store.posts.filter((p) => p.authorId === parseInt(authorId as string, 10)));
72
+ res.json(store.posts.filter((p) => p.authorId === parseInt(authorId as string, 10)));
73
+ return;
70
74
  }
71
75
  res.json(store.posts);
72
76
  });
@@ -134,6 +138,20 @@ async function buildStyles() {
134
138
  // Build the Tailwind stylesheet used by the SSR-rendered page (both modes)
135
139
  await buildStyles();
136
140
 
141
+ // In dev, bundle the client with esbuild (rebuilds on change via the watcher below)
142
+ if (isDev) {
143
+ await setupEsbuild();
144
+ }
145
+
146
+ // Only load the Go runtime scripts when the WASM module has been built
147
+ // (`npm run build:wasm` requires Go). Off by default so dev works without Go.
148
+ const hasWasm = existsSync(path.join(__dirname, 'public', 'wasm', 'example.wasm'))
149
+ && existsSync(path.join(__dirname, 'public', 'wasm', 'wasm_exec.js'));
150
+
151
+ const wasmScripts = hasWasm
152
+ ? '<script src="/wasm/wasm_exec.js"></script>'
153
+ : '<script>console.warn("Go WASM not built — run `npm run build:wasm` (requires Go)");</script>';
154
+
137
155
  // ---------------------------------------------------------------------------
138
156
  // SSR: render the App on the server, then hydrate on the client
139
157
  // ---------------------------------------------------------------------------
@@ -160,11 +178,12 @@ app.get('*', async (req: Request, res: Response, next: NextFunction) => {
160
178
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
161
179
  <title>Baraqex Full-Stack App (SSR + WASM + Go)</title>
162
180
  <link rel="stylesheet" href="/build/styles.css">
181
+ <link rel="icon" href="data:,">
163
182
  <script>window.__INITIAL_STATE__ = ${JSON.stringify(initialState)};</script>
164
183
  </head>
165
184
  <body>
166
185
  <div id="root">${content}</div>
167
- <script src="/wasm/wasm_exec.js"></script>
186
+ ${wasmScripts}
168
187
  ${isDev ? '<script src="/socket.io/socket.io.js"></script>' : ''}
169
188
  <script src="/build/main.js" type="module"></script>
170
189
  </body>
@@ -3,7 +3,9 @@
3
3
  "target": "ES2020",
4
4
  "module": "ESNext",
5
5
  "moduleResolution": "Bundler",
6
- "jsx": "preserve",
6
+ "jsx": "react",
7
+ "jsxFactory": "jsx",
8
+ "jsxFragmentFactory": "Fragment",
7
9
  "lib": ["ES2020", "DOM", "DOM.Iterable"],
8
10
  "strict": true,
9
11
  "esModuleInterop": true,