~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/atlibs-socialweb-computer-requester

socialweb.computer market requester and policy modules for atlibs, with its web pages and lexicons

0
0
main
23 lines · 888 B Raw History
import { templated } from 'atlibs/component/index.js'

const Base = await templated(new URL('./webrtc-terminal.html', import.meta.url));

// A line terminal over the datachannel: emits send-line {line}; output goes in as textContent.
customElements.define('webrtc-terminal', class extends Base {
	connectedCallback() {
		super.connectedCallback();
		this.querySelector(".line").onsubmit = (e) => {
			e.preventDefault();
			this.dispatchEvent(new CustomEvent("send-line", { bubbles: true, detail: { line: e.target.line.value } }));
			e.target.line.value = "";
		};
	}

	render(state, previous) {
		this.querySelector(".panel").style.display = ["open", "closed"].includes(state.phase) ? "block" : "none";
		if (previous?.output === state.output) return;
		const output = this.querySelector(".output");
		output.textContent = state.output;
		output.scrollTop = output.scrollHeight;
	}
});