I downloaded conversejs 9.1.1 and I am trying to learn the plugin architecture by making my own custom plugin. I looked at the http-auth plugin here to see how to add a plugin. https://github.com/conversejs/community-plugins/tree/master/packages/http-auth
To install the plugin it directs me to the instructions here: https://m.conversejs.org/docs/html/plugin_development.html
I understand I have to modify my webpage to whitelist the plugin, but for some reason I can't grok a few things. Here is my awesome plugin which resides in a file called Hello-World.js
import { converse } from "@converse/headless/core";
const plugin = {
initialize() {
console.error("Hello World!")
}
}
if (typeof converse === "undefined") {
window.addEventListener(
'converse-loaded',
() => converse.plugins.add("Hello-World", plugin)
);
} else {
converse.plugins.add("Hello-World", plugin);
}
- The htpp-auth.js has no imports, but WebStorm was complaining that converse was unknown so I had to add the import. Why does the http-auth plugin not have to do that?
- I am not sure where the plugin code is supposed to live. I added Hello-World under src/plugins/Hello-World. Is this correct?
- Maybe related to above, but to get the plugin to actually run in addition to whitelisting it in my webpage I had to modify converse.js and add import "./plugins/Hello-World/Hello-World.js" which makes me think I am missing something obvious as I would think adding a plugin shouldn't require you to change the base code.
If it matters I am testing my plugin by running make serve in the conversejs directory and directing my web-browser (Chrome) to localhost:8000/fullscreen.html
Thanks, Wray