From af3f85ae4cdc0e61d50a9880d3b60508cb278d5d Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 20 Dec 2020 06:12:47 +0300 Subject: [PATCH] experimenting... Signed-off-by: Alex A. Naanou --- Viewer/e.js | 3 ++- Viewer/features/cli.js | 12 ++++++++- Viewer/features/core.js | 56 ++++++++++++++++++++++++++++++---------- Viewer/features/sharp.js | 11 ++++++++ Viewer/package-lock.json | 6 ++--- Viewer/package.json | 2 +- 6 files changed, 71 insertions(+), 19 deletions(-) diff --git a/Viewer/e.js b/Viewer/e.js index 9d8d7b0a..dfdf3dbc 100644 --- a/Viewer/e.js +++ b/Viewer/e.js @@ -148,7 +148,8 @@ function start(){ var _start = function(){ createSplash() createWindow() } - // NOTE: by this time (arg parsing and stuff) the app may already be ready... + // NOTE: by this time (arg parsing and stuff) the app may already + // be ready... app.isReady() ? _start() : app.on('ready', _start) } diff --git a/Viewer/features/cli.js b/Viewer/features/cli.js index 8b0bc871..12f6c649 100755 --- a/Viewer/features/cli.js +++ b/Viewer/features/cli.js @@ -181,7 +181,7 @@ var CLIActions = actions.Actions({ startREPL: ['- System/Start CLI interpreter', {cli: { name: '@repl', - interactive: true, + //interactive: true, }}, function(){ var that = this @@ -429,6 +429,16 @@ var CLIActions = actions.Actions({ return index .sortImages() .saveIndex() }) }], + + // XXX this is still wrong... + _makeIndex: ['- System/', + `chain: + "loadImages: $1" + "saveIndex" + "makePreviews: 'all'" + "sortImages" + "saveIndex"`], + // XXX does not work yet... updateIndex: ['- System/Update index', {cli: { diff --git a/Viewer/features/core.js b/Viewer/features/core.js index 641bc68a..5821e580 100755 --- a/Viewer/features/core.js +++ b/Viewer/features/core.js @@ -2944,43 +2944,73 @@ var TaskActions = actions.Actions({ // XXX would be nice to have an ability to partially clone the instance... // ...currently we can do a full clone and remove things we do // not want but that still takes time and memory... - // XXX sould we also do a fast clone or shallow clone??? - __clones: null, + // XXX this does not copy aliases... + // XXX might be a good idea to add a 'IsolatedTask' feature/mixin to + // handle cleanup (via .done() action) + // XXX should this be a prop -- .isolated??? + __isolated: null, + get isolated(){ + return (this.__isolated = this.__isolated || []) }, isolate: ['- System/', function(){ - var clones = this.__clones = this.__clones || [] + var clones = this.isolated var clone = this.clone(true) - // reset actions to exclude UI... - // XXX this still has all the ui handlers setup... clone.__proto__ = ImageGridFeatures.setup([...this.features.input, '-ui']) - + clone.parent = this // link clone in... clone.logger = this.logger.push(['Task', clones.length].join(' ')) clones.push(clone) return clone }], + // XXX this is the same as LinkedTask(..) make a meta-function... + IsolatedTask: ['- System/', + function(action, ...args){ + var that = this + var context = this.isolate + + var res = context[action](...args) + + var cleanup = function(){ + var l = (that.__isolated || []) + l.includes(context) + && l.splice(l.indexOf(context), 1) } + + res.then ? + res.finally(cleanup) + : cleanup() + + return res === context ? + undefined + : res }], + // Create a new ig instance with the same data... // // This will reflect the data changes while when the main index is // cleared or reloaded this will retain the old data... - __links: null, + // + // XXX should this be a prop -- .linked??? + __linked: null, + get linked(){ + return (this.__linked = this.__linked || []) }, link: ['- System/', function(){ var that = this - var links = this.__links = this.__links || [] - // XXX we need to only link it part of the data, for example - // ._action_handlers is action-set specific and should - // not be overwritten... + var links = this.linked var link = ImageGridFeatures.setup([...this.features.input, '-ui']) - // XXX this is not a clean clone... + return Object.assign( link, - this) + this, + {parent: this}) .run(function(){ this.logger = that.logger.push(['Task', links.length].join(' ')) links.push(this) }) }], + // XXX this should delete the clone when done... + LinkedTask: ['- System/', + function(){}], + }) var Tasks = diff --git a/Viewer/features/sharp.js b/Viewer/features/sharp.js index 6b3c9289..ebb43a79 100755 --- a/Viewer/features/sharp.js +++ b/Viewer/features/sharp.js @@ -856,6 +856,17 @@ var SharpActions = actions.Actions({ return gid }) })], cacheAllMetadata: ['- Sharp/Image/', 'cacheMetadata: "all" ...'], + + + // XXX EXPERIMENTAL... + makePreviewsAndSave: ['- Sharp|File/', + function(){ + var link = this.link() + return link + .makePreviews(...arguments) + .then(function(){ + link.saveIndex + && link.saveIndex() }) }], }) diff --git a/Viewer/package-lock.json b/Viewer/package-lock.json index 72a89d57..50519b8c 100755 --- a/Viewer/package-lock.json +++ b/Viewer/package-lock.json @@ -1181,9 +1181,9 @@ "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" }, "ig-actions": { - "version": "3.24.28", - "resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.24.28.tgz", - "integrity": "sha512-3Um0eHHg15y6bxpLZV+FB88qtBro9iXXHNcoOvOf64I4eu+VPThSe3HBUkw03V81Qv19dSlmNYIPHXU1LcMbRw==", + "version": "3.24.29", + "resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.24.29.tgz", + "integrity": "sha512-qfb4zda/cQQ3feOCXO97EOn5i/ac8Zei1CXeiTZlwo+QgtpGdSLC6/pV6Dby+8ikjWLfxVhbd/lK0hBk3g39Jw==", "requires": { "ig-object": "^5.4.12" } diff --git a/Viewer/package.json b/Viewer/package.json index 74199f65..184dd927 100755 --- a/Viewer/package.json +++ b/Viewer/package.json @@ -30,7 +30,7 @@ "generic-walk": "^1.4.0", "glob": "^7.1.6", "guarantee-events": "^1.0.0", - "ig-actions": "^3.24.28", + "ig-actions": "^3.24.29", "ig-argv": "^2.16.3", "ig-features": "^3.4.5", "ig-object": "^5.4.14",