@nodecg/types
Version:
Dynamic broadcast graphics rendered in a browser
293 lines (290 loc) • 9.33 kB
JavaScript
const require_typed_emitter = require('./typed-emitter.js');
//#region package.json
var require_package = /* @__PURE__ */ require_typed_emitter.__commonJS({ "package.json": ((exports, module) => {
module.exports = {
"name": "nodecg",
"version": "2.8.0",
"description": "Dynamic broadcast graphics rendered in a browser",
"keywords": [
"graphics",
"nodecg",
"node",
"dynamic",
"broadcast"
],
"homepage": "https://nodecg.dev/",
"bugs": "https://github.com/nodecg/nodecg/issues",
"repository": {
"type": "git",
"url": "git+https://github.com/nodecg/nodecg.git",
"directory": "workspaces/nodecg"
},
"license": "MIT",
"type": "commonjs",
"exports": {
".": "./dist/server/bootstrap.js",
"./types": { "types": "./types/index.d.ts" },
"./types/augment-window": { "types": "./types/augment-window.d.ts" }
},
"main": "./dist/server/bootstrap.js",
"bin": { "nodecg": "./cli.mjs" },
"files": [
"dist",
"schemas",
"src",
"types",
"cli.mjs",
"index.js"
],
"scripts": {
"build": "tsdown",
"start": "node index.js",
"test": "vitest",
"typetest": "cd typetest/fake-bundle && npm run build",
"watch": "tsdown --watch"
},
"dependencies": {
"@effect/opentelemetry": "^0.59.1",
"@effect/platform": "^0.93.1",
"@effect/platform-node": "^0.100.0",
"@nodecg/cli": "2.8.0",
"@nodecg/database-adapter-sqlite-legacy": "2.7.2",
"@nodecg/database-adapter-types": "2.7.0",
"@nodecg/internal-util": "2.7.2",
"@nodecg/json-schema-defaults": "^1.0.4",
"@nodecg/json-schema-lib": "0.1.0",
"@open-iframe-resizer/core": "^1.6.0",
"@opentelemetry/sdk-logs": "^0.203.0",
"@opentelemetry/sdk-metrics": "^2.2.0",
"@opentelemetry/sdk-trace-node": "^2.2.0",
"@polymer/app-layout": "^3.1.0",
"@polymer/app-route": "^3.0.2",
"@polymer/iron-collapse": "^3.0.1",
"@polymer/iron-flex-layout": "^3.0.1",
"@polymer/iron-icons": "^3.0.1",
"@polymer/iron-image": "^3.0.2",
"@polymer/iron-localstorage": "^3.0.1",
"@polymer/iron-pages": "^3.0.1",
"@polymer/iron-selector": "^3.0.1",
"@polymer/paper-button": "^3.0.1",
"@polymer/paper-card": "^3.0.1",
"@polymer/paper-dialog": "^3.0.1",
"@polymer/paper-dialog-behavior": "^3.0.1",
"@polymer/paper-dialog-scrollable": "^3.0.1",
"@polymer/paper-icon-button": "^3.0.2",
"@polymer/paper-item": "^3.0.1",
"@polymer/paper-slider": "^3.0.1",
"@polymer/paper-spinner": "^3.0.2",
"@polymer/paper-styles": "^3.0.1",
"@polymer/paper-tabs": "^3.1.0",
"@polymer/paper-toast": "^3.0.1",
"@polymer/paper-toolbar": "^3.0.1",
"@polymer/polymer": "^3.5.1",
"@sentry/browser": "^7.91.0",
"@sentry/node": "^7.91.0",
"@types/cookie-parser": "^1.4.6",
"@types/express-session": "^1.17.10",
"@types/multer": "^1.4.11",
"@types/node": "^20.19.0",
"@types/passport": "^1.0.16",
"@types/soundjs": "^0.6.31",
"@vaadin/vaadin-upload": "^4.4.3",
"@webcomponents/webcomponentsjs": "^2.8.0",
"ajv": "^8.17.1",
"ajv-draft-04": "^1.0.0",
"ajv-formats": "^2.1.1",
"body-parser": "^1.20.2",
"cheerio": "1.0.0-rc.12",
"chokidar": "^4.0.3",
"clipboard": "^2.0.11",
"compression": "^1.7.4",
"cookie-parser": "^1.4.6",
"cookies-js": "^1.2.3",
"cosmiconfig": "^8.3.6",
"draggabilly": "^2.4.1",
"effect": "^3.19.3",
"events": "^3.3.0",
"express": "^4.18.2",
"express-session": "^1.17.3",
"express-transform-bare-module-specifiers": "^1.0.4",
"extend": "^3.0.2",
"fast-equals": "^5.0.1",
"fast-memoize": "^2.5.2",
"fp-ts": "^2.16.9",
"git-rev-sync": "^3.0.2",
"hasha": "^5.2.2",
"httpolyglot": "^0.1.2",
"is-error": "^2.2.2",
"isomorphic-git": "^1.35.1",
"json-ptr": "^3.1.1",
"klona": "^2.0.6",
"lodash": "^4.17.21",
"multer": "^1.4.5-lts.1",
"nano-spawn": "^0.2.0",
"object-path": "^0.11.8",
"packery": "^3.0.0",
"passport": "^0.6.0",
"passport-discord": "^0.1.4",
"passport-local": "^1.0.0",
"passport-steam": "^1.0.18",
"passport-twitch-helix": "^1.1.0",
"process": "^0.11.10",
"semver": "^7.6.3",
"serialize-error": "^8.1.0",
"socket.io": "^4.8.1",
"socket.io-client": "^4.8.1",
"soundjs": "^1.0.1",
"ts-essentials": "^9.4.1",
"type-fest": "^5.2.0",
"util": "^0.12.5",
"winston": "^3.11.0",
"yargs": "^15.4.1",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/compression": "^1.7.5",
"@types/express": "^4.17.21",
"@types/extend": "^3.0.4",
"@types/git-rev-sync": "^2.0.2",
"@types/is-ci": "^3.0.4",
"@types/lodash": "^4.17.13",
"@types/object-path": "^0.11.4",
"@types/passport-discord": "^0.1.14",
"@types/passport-local": "^1.0.38",
"@types/passport-steam": "^1.0.5",
"@types/semver": "^7.5.8",
"@types/yargs": "^15.0.19",
"is-ci": "^3.0.1",
"npm-run-all2": "^7.0.2",
"onchange": "^7.1.0",
"puppeteer": "^25.1.0",
"tinyglobby": "^0.2.15",
"tsdown": "^0.16.6",
"tsx": "^4.19.2",
"typescript": "~5.9.3",
"vitest-mock-express": "^2.2.0"
},
"publishConfig": {
"access": "public",
"provenance": true,
"registry": "https://registry.npmjs.org"
}
};
}) });
//#endregion
//#region src/shared/api.base.ts
const { version } = require_package();
var NodeCGAPIBase = class extends require_typed_emitter.TypedEmitter {
static version = version;
/**
* An object containing references to all Replicants that have been declared in this `window`, sorted by bundle.
* E.g., `NodeCG.declaredReplicants.myBundle.myRep`
*/
static declaredReplicants;
/**
* Lets you easily wait for a group of Replicants to finish declaring.
*
* Returns a promise which is resolved once all provided Replicants
* have emitted a `change` event, which is indicates that they must
* have finished declaring.
*
* This method is only useful in client-side code.
* Server-side code never has to wait for Replicants.
*
* @param replicants {Replicant}
* @returns {Promise<any>}
*
* @example <caption>From a graphic or dashboard panel:</caption>
* const rep1 = nodecg.Replicant('rep1');
* const rep2 = nodecg.Replicant('rep2');
*
* // You can provide as many Replicant arguments as you want,
* // this example just uses two Replicants.
* NodeCG.waitForReplicants(rep1, rep2).then(() => {
* console.log('rep1 and rep2 are fully declared and ready to use!');
* });
*/
static async waitForReplicants(...replicants) {
return new Promise((resolve) => {
const numReplicants = replicants.length;
let declaredReplicants = 0;
replicants.forEach((replicant) => {
replicant.once("change", () => {
declaredReplicants++;
if (declaredReplicants >= numReplicants) resolve();
});
});
});
}
/**
* The name of the bundle which this NodeCG API instance is for.
*/
bundleName;
/**
* 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.
*/
bundleConfig;
/**
* The version (from package.json) of the bundle which this NodeCG API instance is for.
* @name NodeCG#bundleVersion
*/
bundleVersion;
/**
* Provides information about the current git status of this bundle, if found.
*/
bundleGit;
_messageHandlers = [];
constructor(bundle) {
super();
this.bundleName = bundle.name;
this.bundleConfig = bundle.config;
this.bundleVersion = bundle.version;
this.bundleGit = bundle.git;
}
listenFor(messageName, bundleNameOrHandlerFunc, handlerFunc) {
let bundleName;
if (typeof bundleNameOrHandlerFunc === "string") bundleName = bundleNameOrHandlerFunc;
else {
bundleName = this.bundleName;
handlerFunc = bundleNameOrHandlerFunc;
}
if (typeof handlerFunc !== "function") throw new Error(`argument "handler" must be a function, but you provided a(n) ${typeof handlerFunc}`);
this.log.trace("Listening for %s from bundle %s", messageName, bundleNameOrHandlerFunc);
this._messageHandlers.push({
messageName,
bundleName,
func: handlerFunc
});
}
unlisten(messageName, bundleNameOrHandler, maybeHandler) {
let { bundleName } = this;
let handlerFunc = maybeHandler;
if (typeof bundleNameOrHandler === "string") bundleName = bundleNameOrHandler;
else handlerFunc = bundleNameOrHandler;
if (typeof handlerFunc !== "function") throw new Error(`argument "handler" must be a function, but you provided a(n) ${typeof handlerFunc}`);
this.log.trace("[%s] Removing listener for %s from bundle %s", this.bundleName, messageName, bundleName);
const index = this._messageHandlers.findIndex((handler) => handler.messageName === messageName && handler.bundleName === bundleName && handler.func === handlerFunc);
if (index >= 0) {
this._messageHandlers.splice(index, 1);
return true;
}
return false;
}
Replicant(name, namespaceOrOpts, opts) {
let namespace;
if (typeof namespaceOrOpts === "string") namespace = namespaceOrOpts;
else namespace = this.bundleName;
if (typeof namespaceOrOpts !== "string") opts = namespaceOrOpts;
opts = opts ?? {};
return this._replicantFactory(name, namespace, opts);
}
};
//#endregion
Object.defineProperty(exports, 'NodeCGAPIBase', {
enumerable: true,
get: function () {
return NodeCGAPIBase;
}
});
//# sourceMappingURL=api.base.js.map