@psychoscope/node-engine-js v0.0.10
node-engine-js
This is a TypeScript package which exports the NodeEngine namespace, with the .play(nodeGraph:NodeGraph) function.
Just feed a valid NodeGraph (JSON-serialized) in, and the rest happens automatically.
Server communication
If the page is loaded with the ?connection_url query parameter, it will post (provisional) NodeResults there, as well as start and end messages.
If no such query parameter is provided, this does not occur, and the code runs without posting anything.
Here are the times in which the client will post to the connection_url:
1. On page load, the client will post a "START" event to the connection_url with body:
```json
{
"event_code": "START",
"event_timestamp": "<ISO8601-formatted UTC timestamp>"
}
```- Whenever a
Nodeis successfully completed, a message is sent toconnection_urlusing body:{ "event_code": "REPORT", "event_data": "<stringified NodeResult>", "event_timestamp": "<ISO8601-formatted UTC timestamp>" } When all
Nodesare played, the client will post a request with an empty body to theconnection_url, with body:{ "event_code": "END", "event_timestamp": "<ISO8601-formatted UTC timestamp>" }
At this point, the server may optionally send back JSON responses of the form:
type PostEventResponse = {
message?: string,
redirect_url?: string,
}If message is provided, the client will log it to the console.
If redirect_url is provided following the transmission of an END event, the client will redirect to that URL.
Structure
main.ts is the entrypoint to understand this package.
Compiling
This vite project generates a UMD module (node-engine.js) which may be imported in an .html file using a simple <script src> tag. It creates window.NodeEngine, which has the window.NodeEngine.play(nodeGraph) method.
This JavaScript package uses vite. Run npm run dev to auto-compile as you develop. This will use the index.html file as a harness.
Publishing
Before publishing, ensure the semantic version (semver) is updated in the plugin's */package.json.
1. Navigate to the plugin's root folder.
2. Run npm login
3. Run npm publish --access public
Style
Following BEM convention for CSS class naming.