UNPKG

streamdeck-typescript

Version:

This library will help you build elgato stream deck plugins in typescript

137 lines 4.42 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StreamDeckActionClass = void 0; class StreamDeckActionClass { constructor(_handler) { this._handler = _handler; this._autoSave = true; this._autoDebounce = true; this._isInMultiAction = false; } set settings(value) { this._settings = value; } get action() { return this._action; } set action(value) { this._action = value; } get context() { return this._context; } set context(value) { this._context = value; } get device() { return this._device; } set device(value) { this._device = value; } get column() { return this._column; } set column(value) { this._column = value; } get row() { return this._row; } set row(value) { this._row = value; } get isInMultiAction() { return this._isInMultiAction; } set isInMultiAction(value) { this._isInMultiAction = value; } get state() { return this._state; } set state(value) { this._state = value; } get userDesiredState() { return this._userDesiredState; } set userDesiredState(value) { this._userDesiredState = value; } set controller(value) { this._controller = value; } get controller() { return this._controller; } disableAutoSave() { this._autoSave = false; } disableAutoDebounce() { this._autoDebounce = false; } enableAutoSave() { this._autoSave = true; } enableAutoDebounce() { this._autoDebounce = true; } getSettings() { return this._settings; } getAction() { return this._action; } getContext() { return this._context; } getDevice() { return this._device; } setSettings(settings, ms = 0) { this._settings = settings; if (this._autoSave) this.saveSettings(ms); } setSettingsAttributes(attributes, ms = 0) { const oldSettings = this.getSettings(); if (oldSettings) this.setSettings(Object.assign(Object.assign({}, oldSettings), attributes), ms); else this.setSettings(Object.assign({}, attributes), ms); } saveSettings(ms) { const fn = () => { this._handler.setSettings(this._settings, this._context); }; if (this._autoDebounce) { this.debounceSettingsCall(fn, ms); } else { fn(); } } debounceSettingsCall(fn, ms) { clearTimeout(this._settingsTimeoutId); this._settingsTimeoutId = setTimeout(fn, ms); } update(self) { const { _action, _autoDebounce, _autoSave, _handler, _column, _context, _device, _isInMultiAction, _row, _settings, _state, _userDesiredState, _controller } = self; this._action = _action !== null && _action !== void 0 ? _action : this._action; this._autoDebounce = _autoDebounce !== null && _autoDebounce !== void 0 ? _autoDebounce : this._autoDebounce; this._autoSave = _autoSave !== null && _autoSave !== void 0 ? _autoSave : this._autoSave; this._handler = _handler !== null && _handler !== void 0 ? _handler : this._handler; this._column = _column !== null && _column !== void 0 ? _column : this._column; this._context = _context !== null && _context !== void 0 ? _context : this._context; this._device = _device !== null && _device !== void 0 ? _device : this._device; this._isInMultiAction = _isInMultiAction !== null && _isInMultiAction !== void 0 ? _isInMultiAction : this._isInMultiAction; this._row = _row !== null && _row !== void 0 ? _row : this._row; this._settings = _settings !== null && _settings !== void 0 ? _settings : this._settings; this._state = _state !== null && _state !== void 0 ? _state : this._state; this._userDesiredState = _userDesiredState !== null && _userDesiredState !== void 0 ? _userDesiredState : this._userDesiredState; this._controller = _controller !== null && _controller !== void 0 ? _controller : this._controller; } } exports.StreamDeckActionClass = StreamDeckActionClass; //# sourceMappingURL=stream-deck-action.class.js.map