@nent/core
Version:
77 lines (74 loc) • 2.15 kB
JavaScript
/*!
* NENT 2022
*/
import { r as registerInstance, h, a as getElement, H as Host } from './index-916ca544.js';
import { A as ActionService } from './service-9338e502.js';
import { f as debugIf } from './logging-5a93c8af.js';
import { a as AUDIO_TOPIC, c as AudioType } from './interfaces-13ff7aec.js';
import { s as state, o as onChange } from './state-627a24e0.js';
import './index-f7016b94.js';
import './state-27a8a5bc.js';
import './index-4bfabbbd.js';
const AudioMusicAction = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.valid = true;
/**
* Readonly topic
*
*/
this.topic = AUDIO_TOPIC;
this.actionService = new ActionService(this, 'n-audio-action-music');
}
get childScript() {
return this.el.querySelector('script');
}
get childInputs() {
return this.el.querySelectorAll('input,select,textarea');
}
getData() {
return {
type: AudioType.music,
trackId: this.trackId,
value: this.value,
};
}
/**
* Get the underlying actionEvent instance. Used by the n-action-activator element.
*/
async getAction() {
const action = await this.actionService.getAction();
if (action == null)
return null;
Object.assign(action.data, this.getData());
return action;
}
/**
* Send this action to the the action messaging system.
*/
async sendAction(data) {
if (state.hasAudioComponent) {
Object.assign(data, this.getData());
this.actionService.sendAction(data);
}
else {
this.dispose = onChange('hasAudioComponent', async (loaded) => {
var _a;
if (loaded) {
this.actionService.sendAction(data);
debugIf(state.debug, `n-audio-action-music: load-action sent for ${this.trackId}`);
}
(_a = this.dispose) === null || _a === void 0 ? void 0 : _a.call(this);
});
}
}
render() {
return h(Host, null);
}
disconnectedCallback() {
var _a;
(_a = this.dispose) === null || _a === void 0 ? void 0 : _a.call(this);
}
get el() { return getElement(this); }
};
export { AudioMusicAction as n_audio_action_music };