async function share(
key,
view
) {
if (typeof key !== 'string')
throw new Error("First arg of share, 'key', must be a string");
if (view.value === undefined)
throw new Error("Sencond arg of share, 'view', must be a viewof");
const dbRef = db.ref(
`/shareinput/${FKEY.encode(
html`<a href>`.href.split('?')[0]
)}/${FKEY.encode(key)}`
);
const inputListener = e => {
if (e.isTrusted || e.isUser) dbRef.set(view.value);
};
const dbListener = snapshot => {
const val = snapshot.val();
if (val) {
view.value = val;
view.dispatchEvent(new Event('input'));
}
};
view.addEventListener("input", inputListener);
dbRef.on('value', dbListener);
invalidation.then(() => {
view.removeEventListener("input", inputListener);
dbRef.off('value', dbListener);
});
return html`<a target="_blank" href="${dbRef.toString() +
".json"}">${key}</a>`;
}