refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2026-10-14 13:00:14 +03:00
parent 23d4331881
commit 890ee1e738
3 changed files with 48 additions and 8 deletions

View File

@ -728,6 +728,10 @@ stretching in width... */
/* XXX we are taking care of this in code -- see if we can use this */ /* XXX we are taking care of this in code -- see if we can use this */
image-orientation: none; image-orientation: none;
/* XXX does this affect gifs???
animation-play-state: paused;
*/
} }
.image { .image {

View File

@ -35,20 +35,50 @@ var core = require('features/core')
/*********************************************************************/ /*********************************************************************/
// Merge indexi into the first/base...
//
// merge(base, ...)
// -> res
//
// res format:
// {
// base: <index>,
//
// // sparse array (optional)...
// conflicts: [
// ...
// // conflict objects are at positions corresponding to its
// // input index in the arguments....
// // for format see: Data's .join(..)
// <conflict-object>,
// ...
// ],
// }
//
var merge = var merge =
module.merge = module.merge =
function(base, ...others){ function(base, ...others){
// XXX get deconfliction mode... // XXX get deconfliction mode...
// XXX // XXX
var res = { base }
var i = 0
for(var other of others){ for(var other of others){
i++
// merge data...
base.data.join(other.data) base.data.join(other.data)
// deconflict... // deconflict...
// NOTE: .data.join(..) deconflicts data internally, we need to keep
// the deconflicted GIDs in sync with .images...
if(base.data.deconfliction){
res.conflicts ??= []
res.conflicts[i] = base.data.deconfliction
for(var c in base.data.deconfliction ?? {}){ for(var c in base.data.deconfliction ?? {}){
var n = base.data.deconfliction[c] var n = base.data.deconfliction[c]
other.images.replaceGID(c, n) } other.images.replaceGID(c, n) }
delete base.data.deconfliction delete base.data.deconfliction }
// merge images...
base.images.join(other.images) } base.images.join(other.images) }
return base } return res }

View File

@ -367,7 +367,10 @@ var FileSystemLoaderActions = actions.Actions({
//console.log('MERGING:', k, part) //console.log('MERGING:', k, part)
logger && logger.emit('merge index', k, res) logger && logger.emit('merge index', k, res)
index = that.merge(index, part) } var {base, conflicts} = that.merge(index, part)
index = base
conflicts && logger && logger.emit('GID conflicts', conflicts) }
loaded.push(k) } loaded.push(k) }
@ -780,9 +783,12 @@ var FileSystemLoaderActions = actions.Actions({
var new_data = that.data.constructor.fromArray(gids) var new_data = that.data.constructor.fromArray(gids)
// prepend to index... // prepend to index...
// NOTE: we are ignoring conflicts here as we are
// generating the index ouselves...
var index = that.merge( var index = that.merge(
{ data: new_data, images: imgs }, { data: new_data, images: imgs },
that) that)
.base
var cur = that.data.current var cur = that.data.current
that.images = index.images that.images = index.images
that.data = index.data that.data = index.data