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.

101 lines (97 loc) 2.73 kB
/*! * NENT 2022 */ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client'; import { A as ActionService } from './service.js'; import { f as debugIf } from './logging.js'; import { c as AudioType } from './interfaces2.js'; import { s as state, o as onChange } from './state3.js'; const AudioSoundAction = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement { constructor() { super(); this.__registerHost(); this.__attachShadow(); this.valid = true; /** * Readonly topic * */ this.topic = 'audio'; 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.sound, 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 this; } }, [1, "n-audio-action-sound", { "topic": [1], "command": [1], "trackId": [1, "track-id"], "value": [8], "when": [1], "valid": [32], "getAction": [64], "sendAction": [64] }]); function defineCustomElement$1() { if (typeof customElements === "undefined") { return; } const components = ["n-audio-action-sound"]; components.forEach(tagName => { switch (tagName) { case "n-audio-action-sound": if (!customElements.get(tagName)) { customElements.define(tagName, AudioSoundAction); } break; } }); } const NAudioActionSound = AudioSoundAction; const defineCustomElement = defineCustomElement$1; export { NAudioActionSound, defineCustomElement };