Salah 0.6: restore user-confirmed smooth v0.3 native list

This commit is contained in:
2026-09-12 13:22:30 +01:00
parent 1c20c2927c
commit d7e707e800
7 changed files with 37 additions and 138 deletions
-40
View File
@@ -1,40 +0,0 @@
const assert = require('node:assert/strict')
const fs = require('node:fs')
const vm = require('node:vm')
const src = fs.readFileSync('src/pages/index/index.ux', 'utf8')
const body = src.match(/<script>([\s\S]*?)<\/script>/)[1].replace(/import\s+\w+\s+from\s+'[^']*';?/, '').replace('export default', 'globalThis.spec =')
const ctx = {prayer: require('../src/common/prayer.js'), setInterval: () => 1, clearInterval: () => {}}
vm.createContext(ctx); vm.runInContext(body, ctx)
const p = Object.assign({}, ctx.spec, JSON.parse(JSON.stringify(ctx.spec.private)))
p.update()
assert.equal(typeof p.onScroll, 'function', 'scroll handler drives center magnification')
const size = i => parseFloat(p.rows[i].timeStyle.fontSize)
p.onScroll({scrollY: 0, scrollState: 0})
assert.equal(size(0), 60, 'first centered prayer gets 60px time')
assert.ok(size(1) < size(0))
p.onScroll({scrollY: 104, scrollState: 0})
assert.equal(size(1), 60)
assert.equal(size(0), size(2), 'symmetric shrink around center')
p.onScroll({scrollY: 52, scrollState: 0})
assert.equal(size(1), 60, 'nearest row wins after stopping halfway')
assert.equal(size(0), 30)
p.onScroll({scrollY: 520, scrollState: 0})
assert.equal(size(5), 60, 'last prayer can be magnified')
p.update()
assert.equal(size(5), 60, 'clock refresh preserves scroll focus')
for (const offset of [-100, 9999]) {
p.onScroll({scrollY: offset, scrollState: 0})
p.rows.forEach(row => assert.ok(parseFloat(row.timeStyle.fontSize) >= 30 && parseFloat(row.timeStyle.fontSize) <= 60))
}
const before = JSON.stringify(p.rows)
for (const event of [undefined, {}, {scrollY: NaN}, {scrollY: Infinity}]) p.onScroll(event)
assert.equal(JSON.stringify(p.rows), before, 'invalid events do not corrupt styles')
assert.ok(!src.includes('SWIPE TO SCROLL'))
assert.match(src, /onscroll="onScroll"/)
assert.match(src, /style="\{\{ row.timeStyle \}\}"/)
assert.match(src, /style="\{\{ row.nameStyle \}\}"/)
function css(c,k) { return parseFloat(src.match(new RegExp('\\.'+c+'\\s*\\{([^}]+)'))[1].match(new RegExp(k+':\\s*([^;]+)'))[1]) }
assert.equal(css('prayers','top') + css('prayers','height') / 2, 233, 'magnification center is physical screen center')
assert.equal(css('row','height'), 104, 'fixed row geometry prevents scroll feedback')
assert.ok(css('clock','font-size') > 42, 'header clock enlarged too')
console.log('Center magnification, settled focus, end rows, refresh preservation, invalid events and wiring passed')
+15
View File
@@ -0,0 +1,15 @@
const assert = require('node:assert/strict')
const fs = require('node:fs')
const {execFileSync} = require('node:child_process')
const src = fs.readFileSync('src/pages/index/index.ux','utf8')
const baseline = execFileSync('git',['show','8e660f4:src/pages/index/index.ux'],{encoding:'utf8'})
assert.ok(!/onscroll|onScroll|applyFocus|timeStyle|nameStyle|_scrolling|_scrollY/.test(src), 'remove the entire scroll-driven zoom path')
assert.equal(src.match(/<list\b[\s\S]*?<\/list>/)[0], baseline.match(/<list\b[\s\S]*?<\/list>/)[0], 'native list markup matches user-confirmed smooth v0.3')
assert.equal(src.match(/<script>[\s\S]*?<\/script>/)[0], baseline.match(/<script>[\s\S]*?<\/script>/)[0], 'page logic matches smooth v0.3')
for(const name of ['prayers','spacer','row','rowName','rowTime','rowNext','nameNext','timeNext']) {
const re = new RegExp('\\.'+name+'\\s*\\{[^}]+}')
assert.equal(src.match(re)[0],baseline.match(re)[0],name+' uses proven static styling')
}
assert.ok(!src.includes('SWIPE TO SCROLL'))
assert.match(src,/font-size: 50px;/,'keep enlarged header clock')
console.log('Exact v0.3 list, row styles and script parity verified; zoom code absent; larger clock and no hint retained')
-2
View File
@@ -94,8 +94,6 @@ function page() {
p.onHide = spec.onHide
p.onDestroy = spec.onDestroy
p.update = spec.update
p.applyFocus = spec.applyFocus
p.onScroll = spec.onScroll
p.rows = []
return p
}
-38
View File
@@ -1,38 +0,0 @@
const assert = require('node:assert/strict')
const fs = require('node:fs')
const vm = require('node:vm')
const src = fs.readFileSync('src/pages/index/index.ux', 'utf8')
const body = src.match(/<script>([\s\S]*?)<\/script>/)[1].replace(/import\s+\w+\s+from\s+'[^']*';?/, '').replace('export default', 'globalThis.spec =')
const ctx = {prayer: require('../src/common/prayer.js'), setInterval: () => 1, clearInterval: () => {}}
vm.createContext(ctx); vm.runInContext(body, ctx)
const p = Object.assign({}, ctx.spec, JSON.parse(JSON.stringify(ctx.spec.private)))
p.update()
let rows = p.rows, writes = 0
Object.defineProperty(p, 'rows', {get: () => rows, set: value => {writes++; rows = value}})
const original = JSON.stringify(rows)
for (let i=0; i<500; i++) p.onScroll({scrollY: i, scrollState: i < 250 ? 1 : 2})
console.log('Row-array replacements during 500 gesture/inertia events:', writes)
assert.equal(writes, 0, 'native scrolling must not rebuild reactive rows')
assert.equal(JSON.stringify(rows), original, 'no font changes while scrolling')
p.update()
assert.equal(writes, 0, 'periodic refresh must defer during scrolling')
p.onScroll({scrollY: 520, scrollState: 0})
assert.equal(parseFloat(p.rows[5].timeStyle.fontSize), 60, 'last row grows after stop')
assert.ok(writes <= 1, 'one focus update at stop')
const settled = writes
p.onScrollEnd()
assert.equal(writes, settled, 'duplicate stop event is a no-op')
p.onScroll({scrollY: 208, scrollState: 1})
p.onScrollEnd()
assert.equal(parseFloat(p.rows[2].timeStyle.fontSize), 60, 'scrollend fallback applies nearest row')
assert.equal(parseFloat(p.rows[1].timeStyle.fontSize), 30)
const saved = JSON.stringify(p.rows)
for (const e of [undefined, {}, {scrollY: NaN}, {scrollY: Infinity}]) p.onScroll(e)
assert.equal(JSON.stringify(p.rows), saved)
p.onScroll({scrollY: 312, scrollState: 1})
p.onHide()
p.onShow()
assert.equal(p._scrolling, false, 'hiding during a swipe must not freeze refresh after resume')
assert.equal(parseFloat(p.rows[3].timeStyle.fontSize), 60)
assert.match(src, /onscrollend="onScrollEnd"/)
console.log('Scroll workload, deferred refresh, settled focus and duplicate-event checks passed')