luxaura 1.0.1 → 1.0.3

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": "luxaura",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Luxaura — The Intent-Driven Full-Stack Web Framework. Build complete apps with .lux files.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -10,7 +10,7 @@
10
10
  "test": "node test/run-tests.js"
11
11
  },
12
12
  "keywords": ["luxaura", "framework", "web", "fullstack", "lux", "intent-driven"],
13
- "author": "Imed Rebhi <imedrebhi@gmail.com>",
13
+ "author": "Luxaura Contributors",
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
16
  "chokidar": "^3.5.3",
@@ -307,7 +307,10 @@ ${events}
307
307
  (node.children || []).forEach(c => this._collectWhen(c, out));
308
308
  }
309
309
 
310
- // ─── Vault JS (was Server JS) ──────────────────────────────────────────────
310
+ // ─── Vault JS ──────────────────────────────────────────────────────────────
311
+ // Built 100% from the AST — never uses regex heuristics to close braces.
312
+ // Imports are extracted from raw (require lines only).
313
+ // Function bodies come directly from actions[].body (already clean/dedented).
311
314
 
312
315
  _compileVaultJS() {
313
316
  const name = this.opts.componentName;
@@ -317,22 +320,34 @@ ${events}
317
320
 
318
321
  const { actions, raw } = this.ast.vault;
319
322
 
320
- // Translate action async function
321
- let code = raw
322
- .replace(/^action\s+(\w+)\s*\(([^)]*)\)\s*:/gm, 'async function $1($2) {');
323
-
324
- // Close open function blocks
325
- code = code.replace(/\n\n/g, '\n}\n\n');
326
-
327
- const exports = actions.map(a => ` ${a.name}`).join(',\n');
328
-
329
- return `/* Luxaura Vault ${name} | NEVER sent to browser */
330
- 'use strict';
331
- ${code}
332
-
333
- module.exports = {
334
- ${exports || ' /* no exported actions */'}
335
- };`;
323
+ // Extract only the require/const lines from raw — skip action definitions
324
+ const importLines = (raw || '')
325
+ .split('\n')
326
+ .filter(line => {
327
+ const t = line.trim();
328
+ return t.startsWith('const ') || t.startsWith('let ') || t.startsWith('var ');
329
+ })
330
+ .join('\n');
331
+
332
+ // Build each async function from the AST body properly opened and closed
333
+ const functions = actions.map(a => {
334
+ const params = (a.params || []).join(', ');
335
+ // Indent body by 2 spaces
336
+ const body = (a.body || '').trimEnd().split('\n').map(l => ' ' + l).join('\n');
337
+ return `async function ${a.name}(${params}) {\n${body}\n}`;
338
+ }).join('\n\n');
339
+
340
+ const exportNames = actions.map(a => ` ${a.name}`).join(',\n');
341
+
342
+ const parts = [
343
+ `/* Luxaura Vault — ${name} | NEVER sent to browser */`,
344
+ `'use strict';`,
345
+ ];
346
+ if (importLines.trim()) parts.push(importLines);
347
+ if (functions.trim()) parts.push(functions);
348
+ parts.push(`module.exports = {\n${exportNames || ' /* no exported actions */'}\n};`);
349
+
350
+ return parts.join('\n\n');
336
351
  }
337
352
 
338
353
  // ─── Paint CSS (was Style CSS) ─────────────────────────────────────────────