Ticket #632 (closed enhancement: wontfix)

Opened 5 years ago

Last modified 4 years ago

plugin dependencies

Reported by: FND Owned by: FND
Priority: major Milestone: 2.4.2
Component: core Version:
Severity: medium Keywords: plugins
Cc:

Description (last modified by FND) (diff)

When processing plugins, TiddlyWiki should evaluate the Requires* slice to check for dependencies.

If a dependency does not exist, an error should be raised.

* this slice name is an implicit convention in the TiddlyWiki community

Attachments

ticket632.patch Download (1.2 KB) - added by FND 5 years ago.

Change History

follow-up: ↓ 2   Changed 5 years ago by EricShulman

The core currently *does* use the "Requires" slice value to check for dependencies.

in loadPlugins(),

the code first gathers the slice information for all tiddlers:

for(var i=0; i<nPlugins; i++) {
	var p = getPluginInfo(tiddlers[i]);
	installedPlugins[i] = p;
	...

then, it recursively 'visits' each tiddler to build the toLoad[] array:

var visit = function(p) {
	if(!p || p.done)
		return;
	p.done = 1;
	var reqs = p.Requires;
	if(reqs) {
		reqs = reqs.readBracketedList();
		for(var i=0; i<reqs.length; i++)
			visit(map[reqs[i]]);
	}
	toLoad.push(p);
};
for(i=0; i<nPlugins; i++)
	visit(installedPlugins[i]);

and finally, it processes the toLoad[] array to actually load the tiddler in dependent-specific order:

for(i=0; i<toLoad.length; i++) {
	p = toLoad[i];
	pluginInfo = p;
	tiddler = p.tiddler;
	if(isPluginExecutable(p)) {
		if(isPluginEnabled(p)) {
		...
			window.eval(tiddler.text);
		...

Note: the Requires slice is supposed to contain a space-separated list of tiddler titles. However, in some cases, this slice has been used to enter free-form or comma-separated information.

Currently, TiddlyTools uses comma-separated values. I will correct this shortly.

in reply to: ↑ 1   Changed 5 years ago by FND

  • description modified (diff)

Replying to EricShulman:

The core currently *does* use the "Requires" slice value to check for dependencies.

True, but that only affects loading order - if a dependency does not exist, that's simply being ignored (at least that's my understanding).

I've clarified the ticket description accordingly.

  Changed 5 years ago by FND

  • cc plugins added

  Changed 5 years ago by FND

  • cc plugins removed
  • keywords plugins added

Changed 5 years ago by FND

  Changed 5 years ago by FND

  • owner changed from JeremyRuston to FND
  • status changed from new to assigned

  Changed 5 years ago by FND

  • status changed from assigned to closed
  • resolution set to wontfix

The Requires mechanism exists primarily to resolve loading-order issues.

Elaborate dependency handling should be delegated to plugins, which could specifically check for the required objects (functions, variables etc.) rather than using plugin names. (By analogy, this is similar to using object detection vs. user-agent sniffing for browsers.)

  Changed 4 years ago by MartinBudden

  • milestone changed from 2.5 to 2.4.2

  Changed 4 years ago by FND

Note: See TracTickets for help on using tickets.