UNPKG

@mixer/interactive-node

Version:

A NodeJS and Browser compatible client for mixer.com's interactive 2 Protocol

72 lines 2.69 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var Control_1 = require("./Control"); /** * Textboxes can be used by participants to send text to the game. */ var Textbox = /** @class */ (function (_super) { __extends(Textbox, _super); function Textbox() { return _super !== null && _super.apply(this, arguments) || this; } /** * Sets a new placeholder value for this textbox. */ Textbox.prototype.setPlaceholder = function (placeholder) { return this.updateAttribute('placeholder', placeholder); }; /** * Sets a new submit button text value for this textbox. */ Textbox.prototype.setSubmitText = function (submitText) { return this.updateAttribute('submitText', submitText); }; /** * Sets the cooldown for this textbox. Specified in Milliseconds. * The Client will convert this to a Unix timestamp for you. */ Textbox.prototype.setCooldown = function (duration) { var target = this.client.state.synchronizeLocalTime().getTime() + duration; return this.updateAttribute('cooldown', target); }; /** * Sets the spark cost for this textbox. * An Integer greater than 0 */ Textbox.prototype.setCost = function (cost) { return this.updateAttribute('cost', cost); }; /** * Sends an input event from a participant to the server for consumption. */ Textbox.prototype.giveInput = function (input) { return this.sendInput(input); }; /** * Update this textbox on the server. */ Textbox.prototype.update = function (controlUpdate) { // Clone to prevent mutations // XXX: Typescript 2.4 is strict, let the compiler be clever. var changedData = Object.assign({}, controlUpdate); if (changedData.cooldown) { changedData.cooldown = this.client.state.synchronizeLocalTime().getTime() + changedData.cooldown; } return _super.prototype.update.call(this, changedData); }; return Textbox; }(Control_1.Control)); exports.Textbox = Textbox; //# sourceMappingURL=Textbox.js.map