Way to extend whats saved into the .canvas file

Hi,
I’m trying to implement a sort of flow based programming paradigm to the canvas for features like in GitHub - comfyanonymous/ComfyUI: The most powerful and modular stable diffusion GUI with a graph/nodes interface.

flow-nodes

I got a rickshaw solution going, but i’m having trouble finding a way for it to remain function after switching tabs and coming back to the canvas.

I’m really looking for a way to extend what is saved in the .canvas files- as attempts to manually do it through the fs package are overwritten

any ideas ?

thanks!

I’m not familiar with Canvas, but one idea is to patch the app.internalPlugins.plugins.canvas.constructor.prototype.saveData method.

You can use monkey-around for that purpose.

1 Like

Wonderous, this is likely exactly what I need.

Thank you

1 Like

This monkey-around thing will undoubtedly be handy in the future, though for posterity attempting

// inside the onload function of a custom plugin
		this.register(around(this.app.internalPlugins.plugins.canvas.constructor.prototype, {
			saveData(oldMethod) {
				console.log('hi')	
				console.log('old', oldMethod)
				return function(...args) {
					console.log('there')
					const result = oldMethod && oldMethod.apply(this, args)
					console.log('newsave', result)
					return result
				}
			},
			handleConfigFileChange(oldMethod) {
				console.log('config file change')
				console.log('oldMethod', oldMethod)
				return function (...args) {
					const result = oldMethod && oldMethod.apply(this, args)
					console.log('config filechange', result)
					return result
				}
			}
		}))

did not seem to trigger when the .canvas file was updated