UNPKG

@nent/core

Version:

Functional elements to add routing, data-binding, dynamic HTML, declarative actions, audio, video, and so much more. Supercharge static HTML files into web apps without script or builds.

81 lines (76 loc) 2.22 kB
/*! * NENT 2022 */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const index = require('./index-1829aebc.js'); const service = require('./service-18bf7431.js'); const logging = require('./logging-37c154cf.js'); const interfaces = require('./interfaces-f9ceab29.js'); const state = require('./state-9c7a0826.js'); require('./index-637e8c28.js'); require('./state-f97ff0e6.js'); require('./index-96f3ab3f.js'); const AudioMusicAction = class { constructor(hostRef) { index.registerInstance(this, hostRef); this.valid = true; /** * Readonly topic * */ this.topic = interfaces.AUDIO_TOPIC; this.actionService = new service.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: interfaces.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.state.hasAudioComponent) { Object.assign(data, this.getData()); this.actionService.sendAction(data); } else { this.dispose = state.onChange('hasAudioComponent', async (loaded) => { var _a; if (loaded) { this.actionService.sendAction(data); logging.debugIf(state.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 index.h(index.Host, null); } disconnectedCallback() { var _a; (_a = this.dispose) === null || _a === void 0 ? void 0 : _a.call(this); } get el() { return index.getElement(this); } }; exports.n_audio_action_music = AudioMusicAction;