0.0.10 • Published 5 months ago

@psychoscope/node-engine-js v0.0.10

Weekly downloads
-
License
-
Repository
github
Last release
5 months ago

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>"
}
```
  1. Whenever a Node is successfully completed, a message is sent to connection_url using body:
    {
      "event_code": "REPORT",
      "event_data": "<stringified NodeResult>",
      "event_timestamp": "<ISO8601-formatted UTC timestamp>"
    }
  2. When all Nodes are played, the client will post a request with an empty body to the connection_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.

0.0.10

5 months ago

0.0.9

5 months ago

0.0.8

5 months ago

0.0.7

5 months ago

0.0.6

5 months ago

0.0.5

5 months ago

0.0.4

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago