Conventions
Modules
A module is an ESM file that contains one default export and named exports that are used to provide additional metadata about the usage of the former.
- Any default export should be a function—ideally stateless.
- Named exports should be modifiers for this function, consistent with the WASL standard.
export default (message="world") => console.log(`hello ${message}!`)
Components
A component is specified by a [name].wasl.json
file and accompanied by a package.json
file, which may use its main
field to specify an exposed library—composed of modules—for distribution on Node Package Manager (NPM).
This is what is visualized by the Files tab of the brainsatplay-editor
.
When exposing the default export of each module, the exposed library functions will only work properly if all functions are stateless and don't require access to additional variables in the module files.
To be editable by brainsatplay.editable
classes, you must have your source code accessible from Github, NPM, or other locations.
Native vs. Mashup
Native components contain all of their logic internally.
// self-contained logic
export default (message="world") => console.log(`hello ${message}!`)
Mashup components adapt existing NPM libraries by wrapping their essential classes and function calls.
// external library usage
import * as graphscript from 'https://cdn.jsdelivr.net/npm/graphscript/dist/index.esm.js'
const graph = new graphscript.Graph({
operator: (message="world") => console.log(`hello ${message}!`)
})
// encapsulated library object
export default () => graph.run('world')
Graphs
A graph is a connected set of components that pass messages between each other.
Nodes in the graph are individually visualized by the Properties tab (TBD) of the @brainsatplay/studio
, while edges are visualized by the Graph tab.
Although specified in the WASL standard, these are not handled by the wasl library itself. Instead, graphs are assembled by external libraries such as graphscript.