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.

4 lines 1.18 kB
/*! * NENT 2022 */ import{w as t}from"./logging-5a93c8af.js";import{a as n}from"./state-27a8a5bc.js";import{hasToken as a,resolveTokens as o}from"./tokens-78f8cdbe.js";function r(t,n,a){const o=t.querySelector(n);(null==o?void 0:o.innerHTML)!=(null==a?void 0:a.innerHTML)&&(o&&o.remove(),a&&t.append(a))}async function s(t,n,a){const o=await t.fetch(n,{mode:a});if(200==o.status||o.ok){return await o.text()||null}throw new Error(`Request to ${n} was not successful: ${o.statusText}`)}async function e(t,n,a,o="GET",r){const s=await t.fetch(n,{mode:a,method:o,body:r,headers:{"content-type":"application/json"}});if(200==s.status||s.ok)return await s.json();throw new Error(`Request to ${n} was not successful: ${s.statusText}`)}async function c(t,a,r,e){const c=await u(a),i=await s(t,c,r);return i&&e&&n.dataEnabled?await o(i):i}async function i(n,a,o,r,s,e){try{const t=await c(n,a,o,s);if(null==t)return null;const i=window.document.createElement("div");return e&&(i.slot="content"),i.innerHTML=t,i.id=r,i}catch(n){return t(`remote: Unable to retrieve from ${a}`),null}}async function u(t){return n.dataEnabled&&a(t)?await o(t):t}export{e as a,c as b,i as c,u as d,s as f,r}