aiplang 2.7.1 → 2.7.2

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/bin/aiplang.js CHANGED
@@ -5,7 +5,7 @@ const fs = require('fs')
5
5
  const path = require('path')
6
6
  const http = require('http')
7
7
 
8
- const VERSION = '2.7.1'
8
+ const VERSION = '2.7.2'
9
9
  const RUNTIME_DIR = path.join(__dirname, '..', 'runtime')
10
10
  const cmd = process.argv[2]
11
11
  const args = process.argv.slice(3)
@@ -625,13 +625,16 @@ function parseBlock(line) {
625
625
  }
626
626
 
627
627
  // ── form ────────────────────────────────────────────────────
628
- if(line.startsWith('form ')) {
628
+ if(line.startsWith('form ') || line.startsWith('form{')) {
629
629
  const bi=line.indexOf('{');if(bi===-1) return null
630
- let head=line.slice(5,bi).trim(); const content=line.slice(bi+1,line.lastIndexOf('}')).trim()
630
+ let head=line.slice(line.startsWith('form{')?4:5,bi).trim()
631
+ const content=line.slice(bi+1,line.lastIndexOf('}')).trim()
631
632
  let action=''; const ai=head.indexOf('=>')
632
633
  if(ai!==-1){action=head.slice(ai+2).trim();head=head.slice(0,ai).trim()}
633
- const [method,bpath]=head.split(/\s+/)
634
- return{kind:'form',method:method||'POST',bpath:bpath||'',action,fields:parseFields(content),extraClass,animate}
634
+ const parts=head.trim().split(/\s+/)
635
+ const method=parts[0]&&['GET','POST','PUT','PATCH','DELETE'].includes(parts[0].toUpperCase())?parts[0].toUpperCase():'POST'
636
+ const bpath=parts[method===parts[0].toUpperCase()?1:0]||''
637
+ return{kind:'form',method,bpath,action,fields:parseFields(content)||[],extraClass,animate}
635
638
  }
636
639
 
637
640
  // ── pricing ─────────────────────────────────────────────────
@@ -841,13 +844,15 @@ function rTable(b) {
841
844
  }
842
845
 
843
846
  function rForm(b) {
844
- const fields=b.fields.map(f=>{
847
+ const fields=(b.fields||[]).map(f=>{
848
+ if(!f) return ''
845
849
  const inp=f.type==='select'
846
850
  ?`<select class="fx-input" name="${esc(f.name)}"><option value="">Select...</option></select>`
847
- :`<input class="fx-input" type="${esc(f.type)}" name="${esc(f.name)}" placeholder="${esc(f.placeholder)}">`
851
+ :`<input class="fx-input" type="${esc(f.type||'text')}" name="${esc(f.name)}" placeholder="${esc(f.placeholder)}">`
848
852
  return`<div class="fx-field"><label class="fx-label">${esc(f.label)}</label>${inp}</div>`
849
853
  }).join('')
850
- return `<div class="fx-form-wrap"><form class="fx-form" data-fx-form="${esc(b.bpath)}" data-fx-method="${esc(b.method)}" data-fx-action="${esc(b.action)}">${fields}<div class="fx-form-msg"></div><button type="submit" class="fx-btn">Submit</button></form></div>\n`
854
+ const label=b.submitLabel||'Submit'
855
+ return `<div class="fx-form-wrap"><form class="fx-form" data-fx-form="${esc(b.bpath)}" data-fx-method="${esc(b.method)}" data-fx-action="${esc(b.action)}">${fields}<div class="fx-form-msg"></div><button type="submit" class="fx-btn">${esc(label)}</button></form></div>\n`
851
856
  }
852
857
 
853
858
  function rBtn(b) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiplang",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "description": "AI-first web language. One .aip file = complete app. Frontend + backend + database + auth.",
5
5
  "keywords": [
6
6
  "aiplang",
package/server/server.js CHANGED
@@ -1435,7 +1435,7 @@ async function startServer(aipFile, port = 3000) {
1435
1435
 
1436
1436
  // Health
1437
1437
  srv.addRoute('GET', '/health', (req, res) => res.json(200, {
1438
- status:'ok', version:'2.7.1',
1438
+ status:'ok', version:'2.7.2',
1439
1439
  models: app.models.map(m=>m.name),
1440
1440
  routes: app.apis.length, pages: app.pages.length,
1441
1441
  admin: app.admin?.prefix || null,