mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
tweaking + npm pupdate...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
1303d70774
commit
a43422566e
@ -2456,38 +2456,34 @@ module.taskAction =
|
|||||||
function(title, func){
|
function(title, func){
|
||||||
var action
|
var action
|
||||||
return (action = Object.assign(
|
return (action = Object.assign(
|
||||||
task(function(){
|
task(function(...args){
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
var ticket = {
|
var ticket = events.EventMixin({
|
||||||
// XXX revise naming...
|
|
||||||
start: eventMethod('start', function(handle, ...args){
|
|
||||||
if(this.state == 'ready'){
|
|
||||||
that.resumeTask(title, action)
|
|
||||||
handle(...args) } }),
|
|
||||||
pause: eventMethod('pause', function(handle, ...args){
|
|
||||||
if(this.state == 'running'){
|
|
||||||
that.pauseTask(title, action)
|
|
||||||
handle(...args) } }),
|
|
||||||
abort: eventMethod('abort', function(handle, ...args){
|
|
||||||
if(!this.state != 'done'){
|
|
||||||
that.abortTask(title, action)
|
|
||||||
handle(...args) } }),
|
|
||||||
|
|
||||||
// can be:
|
// can be:
|
||||||
// - ready
|
// - ready
|
||||||
// - running
|
// - running
|
||||||
// - done
|
// - done
|
||||||
get state(){
|
state: null,
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
return func.call(this, ticket, ...args)
|
start: events.Event('start', function(handle, ...args){
|
||||||
.then(function(){
|
if(this.state == 'ready'){
|
||||||
|
that.resumeTask(title, action)
|
||||||
|
handle(...args) } }),
|
||||||
|
pause: events.Event('pause', function(handle, ...args){
|
||||||
|
if(this.state == 'running'){
|
||||||
|
that.pauseTask(title, action)
|
||||||
|
handle(...args) } }),
|
||||||
|
abort: events.Event('abort', function(handle, ...args){
|
||||||
|
if(!this.state != 'done'){
|
||||||
|
that.abortTask(title, action)
|
||||||
|
handle(...args) } }),
|
||||||
})
|
})
|
||||||
.catch(function(){
|
|
||||||
}) }),
|
// XXX
|
||||||
|
|
||||||
|
return func.call(this, ticket, ...args) }),
|
||||||
{
|
{
|
||||||
toString: function(){
|
toString: function(){
|
||||||
return `core.taskAction('${ title }', \n${ func.toString() })` },
|
return `core.taskAction('${ title }', \n${ func.toString() })` },
|
||||||
|
|||||||
@ -266,6 +266,15 @@ var ExampleActions = actions.Actions({
|
|||||||
|
|
||||||
// XXX inner/outer action...
|
// XXX inner/outer action...
|
||||||
|
|
||||||
|
|
||||||
|
exampleTask: ['- Test/',
|
||||||
|
core.taskAction('Example task', function(ticket, ...args){
|
||||||
|
|
||||||
|
// XXX
|
||||||
|
console.log('>>>>', ticket, ...args)
|
||||||
|
|
||||||
|
return Promise.cooperative()
|
||||||
|
})],
|
||||||
})
|
})
|
||||||
|
|
||||||
var Example =
|
var Example =
|
||||||
|
|||||||
@ -329,7 +329,7 @@ var SharpActions = actions.Actions({
|
|||||||
return images
|
return images
|
||||||
.mapChunks(CHUNK_SIZE, function(gid){
|
.mapChunks(CHUNK_SIZE, function(gid){
|
||||||
if(abort.isAborted){
|
if(abort.isAborted){
|
||||||
throw array.StopIteration('aborted') }
|
throw array.STOP('aborted') }
|
||||||
|
|
||||||
// skip non-images...
|
// skip non-images...
|
||||||
if(!['image', null, undefined]
|
if(!['image', null, undefined]
|
||||||
@ -503,7 +503,7 @@ var SharpActions = actions.Actions({
|
|||||||
return images
|
return images
|
||||||
.mapChunks(CHUNK_SIZE, function(gid){
|
.mapChunks(CHUNK_SIZE, function(gid){
|
||||||
if(abort.isAborted){
|
if(abort.isAborted){
|
||||||
throw array.StopIteration('aborted') }
|
throw array.STOP('aborted') }
|
||||||
|
|
||||||
var img = that.images[gid]
|
var img = that.images[gid]
|
||||||
var base = base_path
|
var base = base_path
|
||||||
@ -513,7 +513,7 @@ var SharpActions = actions.Actions({
|
|||||||
return sizes
|
return sizes
|
||||||
.map(function(size, i){
|
.map(function(size, i){
|
||||||
if(abort.isAborted){
|
if(abort.isAborted){
|
||||||
throw array.StopIteration('aborted') }
|
throw array.STOP('aborted') }
|
||||||
|
|
||||||
var name = path = path_tpl
|
var name = path = path_tpl
|
||||||
.replace(/\$RESOLUTION|\$\{RESOLUTION\}/g, parseInt(size))
|
.replace(/\$RESOLUTION|\$\{RESOLUTION\}/g, parseInt(size))
|
||||||
@ -685,7 +685,7 @@ var SharpActions = actions.Actions({
|
|||||||
.mapChunks(CHUNK_SIZE, function(gid){
|
.mapChunks(CHUNK_SIZE, function(gid){
|
||||||
// abort...
|
// abort...
|
||||||
if(abort.isAborted){
|
if(abort.isAborted){
|
||||||
throw array.StopIteration('aborted') }
|
throw array.STOP('aborted') }
|
||||||
|
|
||||||
var img = cached_images[gid]
|
var img = cached_images[gid]
|
||||||
var path = img && that.getImagePath(gid)
|
var path = img && that.getImagePath(gid)
|
||||||
|
|||||||
@ -128,7 +128,7 @@ var ProgressActions = actions.Actions({
|
|||||||
var msg = text instanceof Array ? text.slice(1).join(': ') : null
|
var msg = text instanceof Array ? text.slice(1).join(': ') : null
|
||||||
text = text instanceof Array ? text[0] : text
|
text = text instanceof Array ? text[0] : text
|
||||||
|
|
||||||
// make sure we do not update too often...
|
// cache -- make sure we do not update too often...
|
||||||
if(value != 'close'){
|
if(value != 'close'){
|
||||||
var cache = (this.__progress_cache = this.__progress_cache || {})
|
var cache = (this.__progress_cache = this.__progress_cache || {})
|
||||||
cache = cache[text] =
|
cache = cache[text] =
|
||||||
@ -140,7 +140,8 @@ var ProgressActions = actions.Actions({
|
|||||||
var v = cache[name] || 0
|
var v = cache[name] || 0
|
||||||
return (cache[name] =
|
return (cache[name] =
|
||||||
value != null ?
|
value != null ?
|
||||||
(typeof(value) == typeof('str') && /[+-][0-9]+/.test(value) ?
|
((typeof(value) == typeof('str')
|
||||||
|
&& /[+-][0-9]+/.test(value)) ?
|
||||||
v + parseInt(value)
|
v + parseInt(value)
|
||||||
: parseInt(value))
|
: parseInt(value))
|
||||||
: v) }
|
: v) }
|
||||||
@ -151,10 +152,9 @@ var ProgressActions = actions.Actions({
|
|||||||
// update not due yet...
|
// update not due yet...
|
||||||
if('timeout' in cache){
|
if('timeout' in cache){
|
||||||
cache.update = true
|
cache.update = true
|
||||||
return
|
return }
|
||||||
|
|
||||||
// set next update point and continue...
|
// set next update point and continue...
|
||||||
} else {
|
|
||||||
delete cache.update
|
delete cache.update
|
||||||
cache.timeout = setTimeout(
|
cache.timeout = setTimeout(
|
||||||
function(){
|
function(){
|
||||||
@ -162,7 +162,7 @@ var ProgressActions = actions.Actions({
|
|||||||
delete cache.timeout
|
delete cache.timeout
|
||||||
cache.update
|
cache.update
|
||||||
&& that.showProgress(text) },
|
&& that.showProgress(text) },
|
||||||
this.config['progress-update-min'] || 200) } }
|
this.config['progress-update-min'] || 200) }
|
||||||
|
|
||||||
// container...
|
// container...
|
||||||
var container = viewer.find('.progress-container')
|
var container = viewer.find('.progress-container')
|
||||||
@ -190,7 +190,6 @@ var ProgressActions = actions.Actions({
|
|||||||
.append($('<span class="close">×</span>')
|
.append($('<span class="close">×</span>')
|
||||||
.on('click', function(){
|
.on('click', function(){
|
||||||
var cache = (that.__progress_cache || {})[text]
|
var cache = (that.__progress_cache || {})[text]
|
||||||
// XXX do we need both close and done callbacks???
|
|
||||||
cache.onclose
|
cache.onclose
|
||||||
&& cache.onclose()
|
&& cache.onclose()
|
||||||
widget.trigger('progressClose') }))
|
widget.trigger('progressClose') }))
|
||||||
@ -206,21 +205,19 @@ var ProgressActions = actions.Actions({
|
|||||||
var cache = (that.__progress_cache || {})[text]
|
var cache = (that.__progress_cache || {})[text]
|
||||||
cache.timeout
|
cache.timeout
|
||||||
&& clearTimeout(cache.timeout)
|
&& clearTimeout(cache.timeout)
|
||||||
// XXX do we need both close and done callbacks???
|
|
||||||
cache.ondone
|
cache.ondone
|
||||||
&& cache.ondone()
|
&& cache.ondone()
|
||||||
|
// clear cache...
|
||||||
delete (that.__progress_cache || {})[text]
|
delete (that.__progress_cache || {})[text]
|
||||||
$(this).remove() }) })
|
$(this).remove() })
|
||||||
|
widget = null })
|
||||||
.appendTo(container)
|
.appendTo(container)
|
||||||
: widget
|
: widget
|
||||||
|
|
||||||
// reset closing timeout...
|
// reset closing timeout...
|
||||||
var timeout = widget.attr('close-timeout')
|
var timeout = widget.attr('close-timeout')
|
||||||
timeout && clearTimeout(JSON.parse(timeout))
|
timeout
|
||||||
|
&& clearTimeout(JSON.parse(timeout))
|
||||||
// get the widget parts we are updating...
|
|
||||||
var bar = widget.find('progress')
|
|
||||||
var state = widget.find('.progress-details')
|
|
||||||
|
|
||||||
// format the message...
|
// format the message...
|
||||||
msg = msg ? ': '+msg : ''
|
msg = msg ? ': '+msg : ''
|
||||||
@ -230,23 +227,22 @@ var ProgressActions = actions.Actions({
|
|||||||
: '...')
|
: '...')
|
||||||
|
|
||||||
// update widget...
|
// update widget...
|
||||||
bar.attr({
|
widget.find('progress')
|
||||||
|
.attr({
|
||||||
value: value || '',
|
value: value || '',
|
||||||
max: max || '',
|
max: max || '',
|
||||||
})
|
})
|
||||||
state.text(msg)
|
widget.find('.progress-details')
|
||||||
|
.text(msg)
|
||||||
|
|
||||||
// auto-close...
|
// auto-close...
|
||||||
if(value && value >= (max || 0)){
|
if(value && value >= (max || 0)){
|
||||||
widget.attr('close-timeout',
|
widget.attr('close-timeout',
|
||||||
// XXX BUG: this appears to get triggered after we close progress...
|
JSON.stringify(setTimeout(
|
||||||
JSON.stringify(setTimeout(function(){
|
function(){
|
||||||
widget.trigger('progressClose')
|
widget
|
||||||
}, this.config['progress-done-delay'] || 1000))) }
|
&& widget.trigger('progressClose') },
|
||||||
|
this.config['progress-done-delay'] || 1000))) } }],
|
||||||
// XXX force the browser to render...
|
|
||||||
//bar.hide(0).show(0)
|
|
||||||
}],
|
|
||||||
|
|
||||||
// handle logger progress...
|
// handle logger progress...
|
||||||
// XXX revise...
|
// XXX revise...
|
||||||
@ -257,6 +253,13 @@ var ProgressActions = actions.Actions({
|
|||||||
rest[0].length
|
rest[0].length
|
||||||
: rest.length
|
: rest.length
|
||||||
|
|
||||||
|
// only pass the relevant stuff...
|
||||||
|
var attrs = {}
|
||||||
|
logger.ondone
|
||||||
|
&& (attrs.ondone = logger.ondone)
|
||||||
|
logger.onclose
|
||||||
|
&& (attrs.onclose = logger.onclose)
|
||||||
|
|
||||||
// get keywords...
|
// get keywords...
|
||||||
var {add, done, skip, close, error} =
|
var {add, done, skip, close, error} =
|
||||||
this.config['progress-logger-keywords']
|
this.config['progress-logger-keywords']
|
||||||
@ -270,23 +273,23 @@ var ProgressActions = actions.Actions({
|
|||||||
|
|
||||||
// close...
|
// close...
|
||||||
if(status == 'close' || close.has(status)){
|
if(status == 'close' || close.has(status)){
|
||||||
this.showProgress(path, 'close', logger)
|
this.showProgress(path, 'close', attrs)
|
||||||
// added new item -- increase max...
|
// added new item -- increase max...
|
||||||
// XXX show msg in the progress bar...
|
// XXX show msg in the progress bar???
|
||||||
} else if(status == 'add' || add.has(status)){
|
} else if(status == 'add' || add.has(status)){
|
||||||
this.showProgress(path, '+0', '+'+l, logger)
|
this.showProgress(path, '+0', '+'+l, attrs)
|
||||||
// resolved item -- increase done...
|
// resolved item -- increase done...
|
||||||
} else if(status == 'done' || done.has(status)){
|
} else if(status == 'done' || done.has(status)){
|
||||||
this.showProgress(path, '+'+l, logger)
|
this.showProgress(path, '+'+l, attrs)
|
||||||
// skipped item -- increase done...
|
// skipped item -- increase done...
|
||||||
// XXX should we instead decrease max here???
|
// XXX should we instead decrease max here???
|
||||||
// ...if not this is the same as done -- merge...
|
// ...if not this is the same as done -- merge...
|
||||||
} else if(status == 'skip' || skip.has(status)){
|
} else if(status == 'skip' || skip.has(status)){
|
||||||
this.showProgress(path, '+'+l, logger)
|
this.showProgress(path, '+'+l, attrs)
|
||||||
// error...
|
// error...
|
||||||
// XXX STUB...
|
// XXX STUB...
|
||||||
} else if(status == 'error' || error.has(status)){
|
} else if(status == 'error' || error.has(status)){
|
||||||
this.showProgress(['Error'].concat(msg), '+0', '+'+l, logger) }
|
this.showProgress(['Error'].concat(msg), '+0', '+'+l, attrs) }
|
||||||
}],
|
}],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
14
Viewer/package-lock.json
generated
14
Viewer/package-lock.json
generated
@ -1112,16 +1112,16 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ig-object": {
|
"ig-object": {
|
||||||
"version": "5.4.9",
|
"version": "5.4.11",
|
||||||
"resolved": "https://registry.npmjs.org/ig-object/-/ig-object-5.4.9.tgz",
|
"resolved": "https://registry.npmjs.org/ig-object/-/ig-object-5.4.11.tgz",
|
||||||
"integrity": "sha512-dmwTla11Kme9pSq7hUjHVNNnbJGg1fQZCm3bquuuTIj5KlI1OLgka14fAhjWOf3kGtHJ2x5Nznvd7yxka26OzQ=="
|
"integrity": "sha512-WPPQ5C41c6q3tPfa2fBbWE2xcLF7LoGRu2E6Wr/aoA5oxAyl8lAuE7Kqt4TyPwfW9jVI0+ifBztg9e1tR5mG1Q=="
|
||||||
},
|
},
|
||||||
"ig-types": {
|
"ig-types": {
|
||||||
"version": "3.7.12",
|
"version": "4.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/ig-types/-/ig-types-3.7.12.tgz",
|
"resolved": "https://registry.npmjs.org/ig-types/-/ig-types-4.1.0.tgz",
|
||||||
"integrity": "sha512-Qp5N79XLq+BvLyxJAn/JNVwt+IWmedQdHBUCImeZ57MJiX6e2I/EZ79D16xU4r866RAEwFFBSsm7q9RWoVNuBg==",
|
"integrity": "sha512-FTpXOA5bZUkRup1vJ4cD76/zkXPtjaFHLp9oNbP18qDUc0pEB/pLx8fdgNDwYGDWnFhetx0pMTuP11KOh2urTA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"ig-object": "^5.4.2",
|
"ig-object": "^5.4.11",
|
||||||
"object-run": "^1.0.1"
|
"object-run": "^1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -31,8 +31,8 @@
|
|||||||
"ig-actions": "^3.24.11",
|
"ig-actions": "^3.24.11",
|
||||||
"ig-argv": "^2.15.0",
|
"ig-argv": "^2.15.0",
|
||||||
"ig-features": "^3.4.2",
|
"ig-features": "^3.4.2",
|
||||||
"ig-object": "^5.4.9",
|
"ig-object": "^5.4.11",
|
||||||
"ig-types": "^3.7.12",
|
"ig-types": "^4.1.0",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"object-run": "^1.0.1",
|
"object-run": "^1.0.1",
|
||||||
"requirejs": "^2.3.6",
|
"requirejs": "^2.3.6",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user