experimenting with different types of clones...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-12-19 14:59:34 +03:00
parent c024867d80
commit b84c0229dd
6 changed files with 96 additions and 38 deletions

View File

@ -304,12 +304,9 @@ actions.Actions({
clone: ['- File/', clone: ['- File/',
function(full){ return function(res){ function(full){ return function(res){
if(this.data){ if(this.data){
res.data = this.data.clone() res.data = this.data.clone() }
}
if(this.images){ if(this.images){
res.images = this.images.clone() res.images = this.images.clone() } } }],
}
} }],
dataFromURLs: ['- File/', dataFromURLs: ['- File/',
function(lst, base){ function(lst, base){

View File

@ -170,16 +170,14 @@ if(typeof(process) != 'undefined'){
// XXX this will not work directly as we will need to explicitly // XXX this will not work directly as we will need to explicitly
// require jli... // require jli...
//patchDate(global.Date) //patchDate(global.Date)
} } }
}
// browser... // browser...
// NOTE: we're avoiding detecting browser specifics for as long as possible, // NOTE: we're avoiding detecting browser specifics for as long as possible,
// this will minimize the headaches of supporting several non-standard // this will minimize the headaches of supporting several non-standard
// versions of code... // versions of code...
if(typeof(window) != 'undefined'){ if(typeof(window) != 'undefined'){
runtime.browser = true runtime.browser = true }
}
@ -596,6 +594,8 @@ var LoggerActions = actions.Actions({
return (this.__logger = return (this.__logger =
this.__logger this.__logger
|| this.Logger(this)) }, || this.Logger(this)) },
set logger(value){
this.__logger = value },
// XXX move this to console-logger??? // XXX move this to console-logger???
// XXX should this be an action??? // XXX should this be an action???
@ -1029,7 +1029,8 @@ module.LifeCycle = ImageGridFeatures.Feature({
var SerializationActions = actions.Actions({ var SerializationActions = actions.Actions({
clone: ['- System/', clone: ['- System/',
function(full){ return actions.MetaActions.clone.call(this, full) }], function(full){
return actions.MetaActions.clone.call(this, full) }],
json: ['- System/', json: ['- System/',
function(){ return {} }], function(){ return {} }],
load: ['- System/', load: ['- System/',
@ -2935,6 +2936,51 @@ var TaskActions = actions.Actions({
|| this.tasks.Task(name, queue) || this.tasks.Task(name, queue)
return queue }), return queue }),
// isolated tasks (XXX EXPERIMENTAL)
// 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,
isolate: ['- System/',
function(){
var clones = this.__clones = this.__clones || []
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'])
// link clone in...
clone.logger = this.logger.push(['Task', clones.length].join(' '))
clones.push(clone)
return clone }],
// 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,
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 link = ImageGridFeatures.setup([...this.features.input, '-ui'])
// XXX this is not a clean clone...
return Object.assign(
link,
this)
.run(function(){
this.logger = that.logger.push(['Task', links.length].join(' '))
links.push(this) }) }],
}) })
var Tasks = var Tasks =

View File

@ -558,6 +558,11 @@ var SharpActions = actions.Actions({
// - we could abort the update if we go away... // - we could abort the update if we go away...
// - we could clone the index and if index.gid does not // - we could clone the index and if index.gid does not
// match the main index use the clone to save.... // match the main index use the clone to save....
// ...the cloning approach would be quite simple:
// ig.clone().makePreviews()
// or:
// ig.peer.clone().makePreviews() // hypothetical api...
// the only question here is how to manage this...
// XXX change base_path to target path... // XXX change base_path to target path...
_makePreviews: ['- Sharp|File/Make image $previews (experimental)', _makePreviews: ['- Sharp|File/Make image $previews (experimental)',
core.queueHandler('Make image previews', core.queueHandler('Make image previews',

View File

@ -580,6 +580,15 @@
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
}, },
"copy-anything": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/copy-anything/-/copy-anything-2.0.1.tgz",
"integrity": "sha512-lA57e7viQHOdPQcrytv5jFeudZZOXuyk47lZym279FiDQ8jeZomXiGuVf6ffMKkJ+3TIai3J1J3yi6M+/4U35g==",
"dev": true,
"requires": {
"is-what": "^3.7.1"
}
},
"core-js": { "core-js": {
"version": "3.8.1", "version": "3.8.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.8.1.tgz", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.8.1.tgz",
@ -813,9 +822,9 @@
"integrity": "sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA==" "integrity": "sha512-6u0VYSCo/OW6IoD5WCLLy9JUGARbamfSavcNXry/eu8aHVFei6CD3Sw+VGX5alea1i9pgPHW0mbu6Xj0uBh7gA=="
}, },
"errno": { "errno": {
"version": "0.1.7", "version": "0.1.8",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.8.tgz",
"integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", "integrity": "sha512-dJ6oBr5SQ1VSd9qkk7ByRgb/1SH4JZjCHSW/mr63/QcXO9zLVxvJ6Oy13nio03rxpSnVDDjFor75SjVeZWPW/A==",
"dev": true, "dev": true,
"optional": true, "optional": true,
"requires": { "requires": {
@ -1172,9 +1181,9 @@
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
}, },
"ig-actions": { "ig-actions": {
"version": "3.24.24", "version": "3.24.28",
"resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.24.24.tgz", "resolved": "https://registry.npmjs.org/ig-actions/-/ig-actions-3.24.28.tgz",
"integrity": "sha512-WFLV64Zn5KKZLuUz+puPTiZAakF4HuQ0LYYYXFRLMBbKXFb2oZbmuLJQIEYtanlOpW6aBeMYWmeb3Gpg0QgjyA==", "integrity": "sha512-3Um0eHHg15y6bxpLZV+FB88qtBro9iXXHNcoOvOf64I4eu+VPThSe3HBUkw03V81Qv19dSlmNYIPHXU1LcMbRw==",
"requires": { "requires": {
"ig-object": "^5.4.12" "ig-object": "^5.4.12"
} }
@ -1188,25 +1197,18 @@
} }
}, },
"ig-features": { "ig-features": {
"version": "3.4.2", "version": "3.4.5",
"resolved": "https://registry.npmjs.org/ig-features/-/ig-features-3.4.2.tgz", "resolved": "https://registry.npmjs.org/ig-features/-/ig-features-3.4.5.tgz",
"integrity": "sha512-vzmxDU/jknxii++h5ldU6f66uFzYvbmMIdk+VaNO3d6ADi5Y0y4NaQPM1NSagfXTlj3FAGMbvloZf5V9+ORIKA==", "integrity": "sha512-koFV8Rx5MUmnbwQcGKuO6A62XQB4F/TJ2ZwDwpTGDkeUmNkLLkPaPaW9fwMosUZRZoKCiH6evARqaSW/PX91Ww==",
"requires": { "requires": {
"ig-actions": "^3.24.7", "ig-actions": "^3.24.28",
"ig-object": "^2.2.2" "ig-object": "^5.4.14"
},
"dependencies": {
"ig-object": {
"version": "2.7.2",
"resolved": "https://registry.npmjs.org/ig-object/-/ig-object-2.7.2.tgz",
"integrity": "sha512-oDkhxH2mnrC148nNeLuYbgT1c6XNuJbVWm7j6WStIUZPpOQWR7/XnE4uodKmwjP47GbBKWuWtPhjA+F9pUubaA=="
}
} }
}, },
"ig-object": { "ig-object": {
"version": "5.4.13", "version": "5.4.14",
"resolved": "https://registry.npmjs.org/ig-object/-/ig-object-5.4.13.tgz", "resolved": "https://registry.npmjs.org/ig-object/-/ig-object-5.4.14.tgz",
"integrity": "sha512-6qJjoDWZ4VmXJvga3LoFH7/JmUoOZuGC73iG54hC8uvv8CAOAMTwTpMm4c2kKAeZ+HdA1sHfa1cjSPVbElmUTA==" "integrity": "sha512-7gSU0Qg4E0rnCPuITu6nJzgr4N73tFN57CISVrQjB+EglixfDI5SwOVRgPtG0EBOgtE8IL4O7fmq/UV87OUYyA=="
}, },
"ig-types": { "ig-types": {
"version": "6.0.4", "version": "6.0.4",
@ -1268,6 +1270,12 @@
"integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
"dev": true "dev": true
}, },
"is-what": {
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/is-what/-/is-what-3.12.0.tgz",
"integrity": "sha512-2ilQz5/f/o9V7WRWJQmpFYNmQFZ9iM+OXRonZKcYgTkCzjb949Vi4h282PD1UfmgHk666rcWonbRJ++KI41VGw==",
"dev": true
},
"is-wsl": { "is-wsl": {
"version": "2.2.0", "version": "2.2.0",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz",
@ -1359,11 +1367,12 @@
} }
}, },
"less": { "less": {
"version": "3.13.0", "version": "3.13.1",
"resolved": "https://registry.npmjs.org/less/-/less-3.13.0.tgz", "resolved": "https://registry.npmjs.org/less/-/less-3.13.1.tgz",
"integrity": "sha512-uPhr9uoSGVKKYVGz0rXcYBK1zjwcIWRGcbnSgNt66XuIZYrYPaQiS+LeUOvqedBwrwdBYYaLqSff5ytGYuT7rA==", "integrity": "sha512-SwA1aQXGUvp+P5XdZslUOhhLnClSLIjWvJhmd+Vgib5BFIr9lMNlQwmwUNOjXThF/A0x+MCYYPeWEfeWiLRnTw==",
"dev": true, "dev": true,
"requires": { "requires": {
"copy-anything": "^2.0.1",
"errno": "^0.1.1", "errno": "^0.1.1",
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",
"image-size": "~0.5.0", "image-size": "~0.5.0",

View File

@ -30,10 +30,10 @@
"generic-walk": "^1.4.0", "generic-walk": "^1.4.0",
"glob": "^7.1.6", "glob": "^7.1.6",
"guarantee-events": "^1.0.0", "guarantee-events": "^1.0.0",
"ig-actions": "^3.24.24", "ig-actions": "^3.24.28",
"ig-argv": "^2.16.3", "ig-argv": "^2.16.3",
"ig-features": "^3.4.2", "ig-features": "^3.4.5",
"ig-object": "^5.4.13", "ig-object": "^5.4.14",
"ig-types": "^6.0.4", "ig-types": "^6.0.4",
"json5": "^2.1.3", "json5": "^2.1.3",
"object-run": "^1.0.1", "object-run": "^1.0.1",
@ -55,7 +55,7 @@
"devDependencies": { "devDependencies": {
"asar": "^3.0.1", "asar": "^3.0.1",
"electron-rebuild": "^1.11.0", "electron-rebuild": "^1.11.0",
"less": "^3.13.0", "less": "^3.13.1",
"rcedit": "^3.0.0" "rcedit": "^3.0.0"
}, },
"bin": { "bin": {

View File

@ -35,6 +35,7 @@ $(function(){
// setup actions... // setup actions...
window.ig = window.ig =
window.ImageGrid = window.ImageGrid =
// XXX should this be core???
viewer.ImageGridFeatures viewer.ImageGridFeatures
.setup([ .setup([
'imagegrid-testing', 'imagegrid-testing',