NodeCG

new NodeCG(bundle, socket)

Creates a new NodeCG API instance. It should never be necessary to use this constructor in a bundle, as NodeCG automatically injects a pre-made API instance.

NameTypeDescription
bundleobjectThe bundle object to build an API instance from.
socketobjectThe Socket.IO socket instance to communicate with.

Members

(static) declaredReplicants

An object containing references to all Replicants that have been declared in this window, sorted by bundle. E.g., NodeCG.declaredReplicants.myBundle.myRep

bundleConfig

An object containing the parsed content of cfg/<bundle-name>.json, the contents of which are read once when NodeCG starts up. Used to quickly access per-bundle configuration properties.

(readonly) bundleGit

Provides information about the current git status of this bundle, if found.

Properties

NameTypeAttribuesDescription
branchStringWhat branch this bundle is on.
hashStringThe full hash of the commit this bundle is on.
shortHashStringThe short hash of the commit this bundle is on.
dateDate<optional>The date of the commit this bundle is on.
messageString<optional>The message of the commit this bundle is on.

bundleName

The name of the bundle which this NodeCG API instance is for.

bundleVersion

The version (from package.json) of the bundle which this NodeCG API instance is for.

extensions

Extension Only

This can only be used in code which runs on the server.

Object containing references to all other loaded extensions. To access another bundle's extension, it must be declared as a bundleDependency in your bundle's manifest.

// bundles/my-bundle/package.json
{
"name": "my-bundle"
...
"bundleDependencies": {
"other-bundle": "^1.0.0"
}
}
// bundles/my-bundle/extension.js
module.exports = function (nodecg) {
const otherBundle = nodecg.extensions['other-bundle'];
// Now I can use `otherBundle`!
}

Logger :Object

Provides easy access to the Logger class. Useful in cases where you want to create your own custom logger.

Last updated on by Ewan Lyon