Component file reference
The exports properties and functions of the server code of a component.
On this page
The server code in <script total> describes the component with properties of exports. Flow reads the file when the component is installed. For the other parts of the file, see The component file.
API
property
exports.id = 'uppercase';
The id of the component inside a FlowStream.
exports.id = 'uppercase';Installing a file with an id that is already installed replaces that component. Without an id, the designer generates one. Write it on one line that ends with a semicolon.
property
exports.name = 'Uppercase';
The name in the list of components, on the node and in the catalogue.
exports.name = 'Uppercase';Required to install the component from a URL address or a catalogue.
property
exports.group = 'Demo';
The group under which the designer lists the component.
exports.group = 'Demo';
property
exports.icon = 'ti ti-font';
The icon of the component.
exports.icon = 'ti ti-font';A class of the Total.js icon font, for example ti ti-print. Required to install the component from a URL address or a catalogue.
property
exports.version = '1';
The version of the component, as a string.
exports.version = '1';Required to install the component from a URL address or a catalogue. The Download components window compares it with the version in the catalogue and shows an update badge when the catalogue has a higher one.
property
exports.author = 'Jane Doe';
The author of the component.
exports.author = 'Jane Doe';The catalogue copies it. An author that does not contain Total.js gets a Community badge in the Download components window.
property
exports.color = '#E73323';
A color for the icon of the component.
exports.color = '#E73323';The catalogue copies it, and the Download components window uses it as the background of the icon.
property
exports.kind = 'trigger';
A label for the kind of component.
exports.kind = 'trigger';The official components use trigger, action and output. The catalogue copies it.
property
exports.config = { greeting: 'Hello', uppercase: false };
The default configuration of a new node.
exports.config = { greeting: 'Hello', uppercase: false };Each node gets a copy. The settings form edits it, and exports.make receives it as config. See Configuration and the settings form.
property
exports.inputs = [{ id: 'input', name: 'Input' }];
The inputs of the node.
exports.inputs = [{ id: 'input', name: 'Input' }];Each input has an id, which messages report in $.input, and a name, which the node shows. See Inputs, outputs and messages.
property
exports.outputs = [{ id: 'output', name: 'Output' }, { id: 'error', name: 'Error' }];
The outputs of the node.
exports.outputs = [{ id: 'output', name: 'Output' }, { id: 'error', name: 'Error' }];Each output has an id, which you pass to $.send(), and a name, which the node shows. A node can change its outputs with instance.outputs and instance.save().
property
exports.npm = ['qrcode'];
npm packages that the component needs.
exports.npm = ['qrcode'];Flow installs each package when the component is added to a FlowStream. A package can have a version, for example mongodb@4.0.0. Load it in exports.make with require().
exports.npm = ['qrcode'];
exports.make = function(instance, config) {
var QRCode = require('qrcode');
};
property
exports.meta = { singleton: true, settingswidth: 1200 };
Options for the designer.
exports.meta = { singleton: true, settingswidth: 1200 };| Option | What it does |
|---|---|
settingswidth | The width of the settings window in pixels. The default is 800. |
singleton | A FlowStream can hold only one node of the component. The designer refuses a second one. |
hidden | The node is drawn transparent on the canvas. |
readonly | The designer does not offer Edit source code, Copy node or Clone, and Flow refuses to read or save its source. |
protected | The component cannot be removed from the FlowStream. |
event
exports.make = function(instance, config) {}
Creates a node.
exports.make = function(instance, config) {}| Parameter | Type | Description |
|---|---|---|
instance |
Object |
The node. See Instance reference. |
config |
Object |
The configuration of the node. It stays the same object when the user changes the settings. |
Flow calls it once for each node of the component: when the design is applied, when the FlowStream starts and when the component changes. Define the handlers of the instance here.
exports.make = function(instance, config) {
instance.message = function($) {
$.send('output');
};
};
event
exports.install = function(com) {}
Runs once when the component is added to a FlowStream.
exports.install = function(com) {}| Parameter | Type | Description |
|---|---|---|
com |
Object |
The component. |
Flow calls it when it registers the component for the first time in the FlowStream process, before the nodes are created. com.main is the FlowStream and com.config the default configuration.
event
exports.uninstall = function(com) {}
Runs when the component is removed from a FlowStream.
exports.uninstall = function(com) {}| Parameter | Type | Description |
|---|---|---|
com |
Object |
The component. |
Flow calls it after it has closed all nodes of the component.
event
exports.call = function(data, callback) {}
Answers a call from the browser script that is not bound to one node.
exports.call = function(data, callback) {}| Parameter | Type | Description |
|---|---|---|
data |
Object |
The data from the browser. |
callback |
Function |
Call it with the answer. |
this is the FlowStream. The browser script calls it with exports.call(data, callback, true). The Publish and Subscribe components use it to list the nodes of other FlowStreams.
exports.call = function(data, callback) {
callback({ flowstream: this.id });
};