aiplang 2.10.5 → 2.10.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/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.10.5'
8
+ const VERSION = '2.10.6'
9
9
  const RUNTIME_DIR = path.join(__dirname, '..', 'runtime')
10
10
  const cmd = process.argv[2]
11
11
  const args = process.argv.slice(3)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aiplang",
3
- "version": "2.10.5",
3
+ "version": "2.10.6",
4
4
  "description": "AI-first web language. One .aip file = complete app. Frontend + backend + database + auth.",
5
5
  "keywords": [
6
6
  "aiplang",
@@ -841,9 +841,9 @@ self.onmessage = function(e) {
841
841
  const cached = cache[id]
842
842
  if (!cached) { inserts.push({ id, row, idx: i }); continue }
843
843
  for (let c = 0; c < colKeys.length; c++) {
844
- const nStr = row[colKeys[c]] != null ? String(row[colKeys[c]]) : ''
845
- const oStr = cached[c] != null ? String(cached[c]) : ''
846
- if (nStr !== oStr) patches.push({ id, col: c, val: row[colKeys[c]] })
844
+ const nv = row[colKeys[c]] ?? null
845
+ const ov = cached[c] ?? null
846
+ if (nv !== ov) patches.push({ id, col: c, val: row[colKeys[c]] })
847
847
  }
848
848
  }
849
849
  for (const id in cache) {
@@ -884,15 +884,31 @@ function _diffAsync(rows, colKeys, rowCache) {
884
884
 
885
885
  function _diffSync(rows, colKeys, rowCache) {
886
886
  const patches = [], inserts = [], deletes = [], seen = new Set()
887
+ const nCols = colKeys.length
887
888
  for (let i = 0; i < rows.length; i++) {
888
889
  const r = rows[i], id = r.id != null ? r.id : i
889
890
  seen.add(id)
890
891
  const c = rowCache.get(id)
891
892
  if (!c) { inserts.push({ id, row:r, idx:i }); continue }
892
- for (let j = 0; j < colKeys.length; j++) {
893
- const n = r[colKeys[j]] != null ? String(r[colKeys[j]]) : ''
894
- const o = c.vals[j] != null ? String(c.vals[j]) : ''
895
- if (n !== o) patches.push({ id, col:j, val:r[colKeys[j]] })
893
+ const vals = c.vals
894
+ // Unrolled loops for 2-4 columns avoids JS loop overhead (Vue does this via template compiler)
895
+ if (nCols === 2) {
896
+ const v0=r[colKeys[0]]??null; if(vals[0]!==v0){patches.push({id,col:0,val:r[colKeys[0]]});vals[0]=v0}
897
+ const v1=r[colKeys[1]]??null; if(vals[1]!==v1){patches.push({id,col:1,val:r[colKeys[1]]});vals[1]=v1}
898
+ } else if (nCols === 3) {
899
+ const v0=r[colKeys[0]]??null; if(vals[0]!==v0){patches.push({id,col:0,val:r[colKeys[0]]});vals[0]=v0}
900
+ const v1=r[colKeys[1]]??null; if(vals[1]!==v1){patches.push({id,col:1,val:r[colKeys[1]]});vals[1]=v1}
901
+ const v2=r[colKeys[2]]??null; if(vals[2]!==v2){patches.push({id,col:2,val:r[colKeys[2]]});vals[2]=v2}
902
+ } else if (nCols === 4) {
903
+ const v0=r[colKeys[0]]??null; if(vals[0]!==v0){patches.push({id,col:0,val:r[colKeys[0]]});vals[0]=v0}
904
+ const v1=r[colKeys[1]]??null; if(vals[1]!==v1){patches.push({id,col:1,val:r[colKeys[1]]});vals[1]=v1}
905
+ const v2=r[colKeys[2]]??null; if(vals[2]!==v2){patches.push({id,col:2,val:r[colKeys[2]]});vals[2]=v2}
906
+ const v3=r[colKeys[3]]??null; if(vals[3]!==v3){patches.push({id,col:3,val:r[colKeys[3]]});vals[3]=v3}
907
+ } else {
908
+ for (let j = 0; j < nCols; j++) {
909
+ const nv = r[colKeys[j]] ?? null
910
+ if (vals[j] !== nv) { patches.push({ id, col:j, val:r[colKeys[j]] }); vals[j]=nv }
911
+ }
896
912
  }
897
913
  }
898
914
  for (const [id] of rowCache) if (!seen.has(id)) deletes.push(id)
package/server/server.js CHANGED
@@ -1839,7 +1839,7 @@ async function startServer(aipFile, port = 3000) {
1839
1839
 
1840
1840
  // Health
1841
1841
  srv.addRoute('GET', '/health', (req, res) => res.json(200, {
1842
- status:'ok', version:'2.10.5',
1842
+ status:'ok', version:'2.10.6',
1843
1843
  models: app.models.map(m=>m.name),
1844
1844
  routes: app.apis.length, pages: app.pages.length,
1845
1845
  admin: app.admin?.prefix || null,