A module aggregates other components to form a scoped unit, and needs to follow the
module descriptor.
Examples of existing modules:
and can have one or more of the following characteristics:
A module is considered local if it has at least one local command, either directly or in inner modules.
Example:
let module = {
name: "mymodule",
title: "My Module",
commands: {
sayhi: {
title: "Say Hi",
returns: "ui.message",
syntax: "say hi",
handler: function() {
return "hi!";
}
}
}
}
A module containing a remote configuration or a descendant of such module.
Example:
{
"name": "mymodule",
"title": "My Module",
"remote": {
"origin": "//mydomain.com/",
"base": "mymodule/"
}
}
The first module which meets at least one of the following:
- contains a remote configuration
- has at least one component which isn't a module
- contains two or more modules
Examples:
Here the root module is: mymodule.moduleone
{
"name": "mymodule",
"modules": {
"moduleone": {
"types": {
"mytype": "string"
}
}
}
}
Which is the same as:
{
"name": "mymodule.moduleone",
"types": {
"mytype": "string"
}
}
A module can be loaded in one of two ways:
A json descriptor has to be a valid json file, and has to end with .json
.
Modules which are loaded as json can not contain the following components:
- Local Commands
- Type Converters
- Type Constraints
These components can be referenced.
Examples:
{
"name": "mymodule",
"title": "My Module",
"remote": {
// ...
},
"types": {
// ...
},
"commands": {
// ...
}
}
A javascript module needs to be a valid javascript file which can run in the browser.
The code shouldn't rely on any 3rd party library, and has to have the following format:
(function() {
// your code here
fugazi.components.modules.descriptor.loaded({
name: "mymodule",
title: "My Module",
// ...
});
})();
A module can reference other modules or "partial modules".
When referencing the collection needs to be an array instead of an object:
{
"name": "mymodule",
"modules": [
"http://mydomain.com/othermodule.json",
"../anothermodule.js"
],
"constraints": "../myconstraints.js"
}
The descriptors which are referenced, if they are not a new module, should only contain the name of the
module which referenced them and their addition, they shouldn't contain title
nor description
.
Example:
{
"name": "mymodule",
"modules": {
"othermodule": {
"title": "Other Module",
"types": "../mytypes.js"
}
}
}
Then mytypes.js
needs to look like this:
{
"name": "mymodule.othermodule",
"types": {
// ...
}
}