@lengkapp/edge 0.0.22 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/edge-client.js +2 -2
- package/dist/edge-server.d.ts +89 -89
- package/dist/edge-server.js +2 -2
- package/package.json +1 -1
- package/readme.md +580 -135
package/dist/edge-client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @lengkapp/edge v0.0.
|
|
2
|
+
* @lengkapp/edge v0.0.24
|
|
3
3
|
* MIT License
|
|
4
4
|
*
|
|
5
5
|
* LengkApp Edge License
|
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
31
31
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
32
32
|
*/
|
|
33
|
-
!function(){"use strict";var e=document,t=window,r="ax-app-style",a=["@keyframes ax-spin{to{transform:rotate(360deg)}}","@keyframes ax-shimmer{0%{background-position:100% 50%}100%{background-position:0 50%}}","@keyframes ax-fade-in{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:translateY(0)}}",".ax-state,.ax-state *,.ax-state *::before,.ax-state *::after{box-sizing:border-box;margin:0;padding:0}",".ax-state{","display:flex;flex-direction:column;align-items:center;justify-content:center;","gap:calc(var(--pad,1) * 12px);","width:100%;min-width:min(240px,100%);min-height:240px;","padding:calc(var(--pad,1) * 20px);","border:1px dashed var(--bd,#e4e4e7);border-radius:var(--br,10px);","background:inherit;","color:var(--fg2,#71717a);","font-family:var(--font,system-ui,-apple-system,sans-serif);","font-size:var(--fs,14px);line-height:1.45;text-align:center;","transition:var(--t,all .25s ease);","-webkit-user-select:none;user-select:none;","}",".ax-state--loading,.ax-state--skeleton{animation:ax-fade-in 220ms ease-out both}",".ax-state svg{display:block;flex:0 0 auto;width:24px;height:24px}",".ax-state--loading svg{color:var(--p,#6d28d9);animation:ax-spin .85s linear infinite}",".ax-state--skeleton{align-items:stretch}",".ax-skel{display:flex;flex-direction:column;gap:calc(var(--pad,1) * 10px);width:100%}",".ax-skel-line{","height:12px;border-radius:calc(var(--br,10px) / 2);","background-color:transparent;","background-image:linear-gradient(90deg,","var(--sk1,#e4e4e7) 25%,var(--sk2,#f4f4f5) 37%,var(--sk1,#e4e4e7) 63%);","background-size:400% 100%;","animation:ax-shimmer 1.4s ease-in-out infinite;","}",".ax-state-text{font-size:var(--fs,14px);color:var(--fg2,#71717a);max-width:34ch}",".ax-state--skeleton .ax-state-text{align-self:center}",".ax-state--error{border-style:solid;color:var(--fg,#18181b);animation:ax-fade-in 200ms ease-out both}",".ax-state--error .ax-state-text{color:var(--err,#ef4444)}",".ax-state-btn{","display:inline-flex;align-items:center;justify-content:center;","width:44px;height:44px;padding:0;font:inherit;color:var(--fg,#18181b);","background:var(--card,#fff);border:1px solid var(--bd,#e4e4e7);","border-radius:calc(var(--br,10px) - 2px);","box-shadow:var(--sh1,0 1px 2px rgba(0,0,0,.04));","cursor:pointer;transition:var(--t,all .25s ease);","}",".ax-state-btn:hover{color:var(--p,#6d28d9);border-color:var(--p,#6d28d9);box-shadow:var(--sh2,0 4px 12px rgba(0,0,0,.08))}",".ax-state-btn:focus-visible{outline:2px solid var(--p,#6d28d9);outline-offset:2px}",".ax-state-btn:active{transform:scale(.96)}",".ax-state-btn svg{transition:transform .25s ease}",".ax-state-btn:hover svg{transform:rotate(-45deg)}",".ax-hide{display:none !important}","@media (prefers-reduced-motion:reduce){",".ax-state,.ax-state--loading,.ax-state--skeleton,.ax-state--error{animation:none}",".ax-state--loading svg{animation-duration:2s}",".ax-skel-line{animation:none;background-image:none;background-color:var(--sk1,#e4e4e7)}",".ax-state-btn:hover svg{transform:none}","::view-transition-old(root),::view-transition-new(root){animation:none}","}"].join("\n");!function(){if(!e.getElementById(r)){var t=e.createElement("style");t.id=r,t.appendChild(e.createTextNode(a)),(e.head||e.documentElement).appendChild(t)}}();var n,i=new Set,o=new WeakSet,s=new WeakMap,l=new WeakMap,c="[_get],[_post]",u=["_in","_out","_before","_after"];function f(t){return new URL(t,e.baseURI).href}function d(e){return new Promise(function(t){var r=new FileReader;r.onload=function(){t({name:e.name,type:e.type||"application/octet-stream",size:e.size,data:r.result})},r.onerror=function(){t({name:e.name,type:e.type,size:e.size,data:null})},r.readAsDataURL(e)})}function v(e){if(e.disabled)return Promise.resolve(void 0);var t=e.type;if("file"===t){var r=e.files;return r&&r.length?e.multiple?Promise.all(Array.prototype.map.call(r,d)):d(r[0]):Promise.resolve(e.multiple?[]:null)}return"checkbox"===t?Promise.resolve(e.checked?e.value||"on":null):"radio"===t?Promise.resolve(e.checked?e.value:null):"SELECT"===e.tagName&&e.multiple?Promise.resolve(Array.prototype.map.call(e.selectedOptions,function(e){return e.value})):Promise.resolve(e.value)}function x(t){var r,a=null,n=null;for(r=0;r<u.length;r++)if(t.hasAttribute(u[r])){a=u[r],n=t.getAttribute(u[r]);break}if(!a)return null;var i=t;if(n&&"this"!==n)try{i=e.querySelector(n)}catch(e){return null}return i&&i.parentNode?{mode:a,el:i,parent:i.parentNode}:null}function p(e,t){"_before"===e.mode||"_out"===e.mode?e.parent.insertBefore(t,e.el):e.parent.insertBefore(t,e.el.nextSibling)}function m(e){var t=l.get(e);t&&(t.node&&t.node.parentNode&&t.node.parentNode.removeChild(t.node),t.target&&t.target.removeAttribute("aria-busy"),l.delete(e))}function g(e,t){var r=e.querySelector(".ax-state-btn");r&&r.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),k(t)})}function h(t){var r=e.createElement("div");return r.className="ax-state ax-state--error",r.setAttribute("role","alert"),r.innerHTML='<button type="button" class="ax-state-btn" aria-label="Retry"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-rotate-ccw preview-icon" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg></button><span class="ax-state-text">'+String(t).replace(/[&<>"']/g,function(e){return{"&":"&","<":"<",">":">",'"':""","'":"'"}[e]})+"</span>",r}function b(t){if("function"==typeof e.startViewTransition)try{return void e.startViewTransition(t)}catch(e){}t()}function k(t){var r=t.hasAttribute("_get"),a=t.getAttribute(r?"_get":"_post");if(null!==a&&x(t)){var n=s.get(t),o=new AbortController;s.set(t,o),n&&n.abort(),m(t);var u=0,d=setTimeout(function(){s.get(t)===o&&(function(t){var r=x(t);if(!r)return null;var a=(t.getAttribute("_loader")||"spinner").toLowerCase();if("none"===a||"off"===a||"false"===a)return null;r.el.classList.add("ax-hide"),r.el.setAttribute("aria-busy","true");var n=function(t){var r="skeleton"===t,a=e.createElement("div");return a.className="ax-state ax-state--"+(r?"skeleton":"loading"),a.setAttribute("role","status"),a.setAttribute("aria-live","polite"),a.setAttribute("aria-busy","true"),a.innerHTML=r?'<div class="ax-skel" aria-hidden="true"><span class="ax-skel-line" style="width:48%"></span><span class="ax-skel-line"></span><span class="ax-skel-line" style="width:86%"></span><span class="ax-skel-line" style="width:64%"></span></div><span class="ax-state-text">Loading…</span>':'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-loader-circle preview-icon" aria-hidden="true"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg><span class="ax-state-text">Loading…</span>',a}(a);p(r,n),l.set(t,{node:n,target:r.el})}(t),u=performance.now())},100),k=parseInt(t.getAttribute("_timeout"),10);k>0||(k=2e4);var w={method:r?"GET":"POST",credentials:"same-origin",headers:{"X-Requested-With":"XMLHttpRequest"},redirect:"follow",referrerPolicy:"same-origin",signal:o.signal},_=setTimeout(function(){o.abort()},k),P=Promise.resolve();if(!r)if(t.hasAttribute("_json"))P=function(t){var r=(t.getAttribute("_json")||"").trim();if(!r)return Promise.resolve(null);var a=r.split(",").map(function(e){return e.trim()}).filter(Boolean);if(!a.length)return Promise.resolve(null);var n=t.closest("form")||e;return Promise.all(a.map(function(t){return function(t,r){var a=e.getElementById(r);if(a&&t.contains(a))return v(a);var n=function(e,t){for(var r=e.querySelectorAll("input[name],select[name],textarea[name]"),a=[],n=0;n<r.length;n++)r[n].name===t&&a.push(r[n]);return a}(t,r);if(!n.length)return Promise.resolve(void 0);if(1===n.length)return v(n[0]);var i=n[0];if("radio"===i.type){for(var o=0;o<n.length;o++)if(n[o].checked)return Promise.resolve(n[o].value);return Promise.resolve(null)}if("checkbox"===i.type){for(var s=[],l=0;l<n.length;l++)n[l].checked&&!n[l].disabled&&s.push(n[l].value||"on");return Promise.resolve(s)}return v(i)}(n,t).then(function(e){return[t,e]})})).then(function(e){for(var t={},r=0;r<e.length;r++)void 0!==e[r][1]&&(t[e[r][0]]=e[r][1]);return JSON.stringify(t)})}(t).then(function(e){null!==e&&(w.headers["Content-Type"]="application/json",w.body=e)});else if(t.hasAttribute("_form")){var T=function(t){var r,a=t.getAttribute("_form");try{r=e.querySelector(a)||e.getElementById(a)}catch(e){r=null}return r?new FormData(r):null}(t);T&&(w.body=T)}P.then(function(){return fetch(a,w)}).then(function(e){if(clearTimeout(_),!e.ok){var t=new Error("HTTP "+e.status);throw t.status=e.status,t}return e.text()}).then(function(r){clearTimeout(d),M(function(){var a=function(){m(t),r&&function(t,r){var a=x(t);if(a){var n=e.createElement("template");n.innerHTML=r;var o,s,l=n.content,u=[],d=[];for(s=l.querySelectorAll("script"),o=0;o<s.length;o++)u.push(s[o]),s[o].parentNode.removeChild(s[o]);for(s=l.querySelectorAll(c),o=0;o<s.length;o++)d.push(s[o]);var v=a.el,p=a.parent;if("_in"===a.mode){for(;v.firstChild;)v.removeChild(v.firstChild);v.appendChild(l),v.classList.remove("ax-hide")}else"_out"===a.mode?p.replaceChild(l,v):"_before"===a.mode?(p.insertBefore(l,v),v.classList.remove("ax-hide")):(p.insertBefore(l,v.nextSibling),v.classList.remove("ax-hide"));for(o=0;o<d.length;o++)y(d[o]);!function(t){for(var r=0;r<t.length;r++){var a=t[r],n=a.getAttribute("src");if(n){if(n=f(n),i.has(n))continue;i.add(n)}for(var o=e.createElement("script"),s=0;s<a.attributes.length;s++)o.setAttribute(a.attributes[s].name,a.attributes[s].value);n||(o.text=a.text),o.async=!1,e.head.appendChild(o)}}(u)}}(t,r)};l.get(t)?b(a):a()})}).catch(function(e){var r;clearTimeout(_),clearTimeout(d),s.get(t)===o&&(r=e&&"AbortError"===e.name?"Request timed out":e&&e.message?e.message:"Request failed",e&&"AbortError"!==e.name&&console.error("[app]",e),M(function(){!function(e,t){var r=l.get(e),a=function(){if(r&&r.node&&r.node.parentNode){var a=r.node,n=h(t);a.parentNode.replaceChild(n,a),r.target&&r.target.removeAttribute("aria-busy"),l.set(e,{node:n,target:r.target}),g(n,e)}else{var i=x(e);if(!i)return;i.el.classList.add("ax-hide"),i.el.setAttribute("aria-busy","true");var o=h(t);p(i,o),l.set(e,{node:o,target:i.el}),g(o,e)}};r?b(a):a()}(t,r)}))})}function M(e){if(0!==u){var r=Math.max(0,240-(performance.now()-u));0===r?s.get(t)===o&&e():setTimeout(function(){s.get(t)===o&&e()},r)}else s.get(t)===o&&e()}}function w(e){var t=e.getAttribute("_trigger");"load"===t||"visible"===t?k(e):e.addEventListener(t,function(t){if("click"===t.type){var r=e.tagName;"BUTTON"!==r&&"A"!==r||t.preventDefault()}k(e)})}function y(e){o.has(e)||(o.add(e),"click"!==(e.getAttribute("_trigger")||"click")&&("IntersectionObserver"in t?(n||(n=new IntersectionObserver(function(e){for(var t=0;t<e.length;t++)e[t].isIntersecting&&(n.unobserve(e[t].target),w(e[t].target))},{rootMargin:"300px"})),n.observe(e)):w(e)))}function _(e){for(var t=e.querySelectorAll(c),r=0;r<t.length;r++)y(t[r])}e.addEventListener("click",function(e){if(!e.target.closest(".ax-state")){var t=e.target.closest(c);if(t&&"click"===(t.getAttribute("_trigger")||"click")){var r=t.tagName;"BUTTON"!==r&&"A"!==r||e.preventDefault(),k(t)}}},!0),function(){for(var t=e.querySelectorAll("script[src]"),r=0;r<t.length;r++)i.add(f(t[r].src));"loading"===e.readyState?e.addEventListener("DOMContentLoaded",function(){_(e)}):_(e)}()}();
|
|
33
|
+
!function(){"use strict";var e=document,t=window,r="ax-app-style",a=["@keyframes ax-spin{to{transform:rotate(360deg)}}","@keyframes ax-shimmer{0%{background-position:100% 50%}100%{background-position:0 50%}}","@keyframes ax-fade-in{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:translateY(0)}}",".ax-state,.ax-state *,.ax-state *::before,.ax-state *::after{box-sizing:border-box;margin:0;padding:0}",".ax-state{","display:flex;flex-direction:column;align-items:center;justify-content:center;","gap:calc(var(--pad,1) * 12px);","width:100%;min-width:min(240px,100%);min-height:240px;","padding:calc(var(--pad,1) * 20px);","border:1px dashed var(--bd,#e4e4e7);border-radius:var(--br,10px);","background:inherit;","color:var(--fg2,#71717a);","font-family:var(--font,system-ui,-apple-system,sans-serif);","font-size:var(--fs,14px);line-height:1.45;text-align:center;","transition:var(--t,all .25s ease);","-webkit-user-select:none;user-select:none;","}",".ax-state--loading,.ax-state--skeleton{animation:ax-fade-in 220ms ease-out both}",".ax-state svg{display:block;flex:0 0 auto;width:24px;height:24px}",".ax-state--loading svg{color:var(--p,#6d28d9);animation:ax-spin .85s linear infinite}",".ax-state--skeleton{align-items:stretch}",".ax-skel{display:flex;flex-direction:column;gap:calc(var(--pad,1) * 10px);width:100%}",".ax-skel-line{","height:12px;border-radius:calc(var(--br,10px) / 2);","background-color:transparent;","background-image:linear-gradient(90deg,","var(--sk1,#e4e4e7) 25%,var(--sk2,#f4f4f5) 37%,var(--sk1,#e4e4e7) 63%);","background-size:400% 100%;","animation:ax-shimmer 1.4s ease-in-out infinite;","}",".ax-state-text{font-size:var(--fs,14px);color:var(--fg2,#71717a);max-width:34ch}",".ax-state--skeleton .ax-state-text{align-self:center}",".ax-state--error{border-style:solid;color:var(--fg,#18181b);animation:ax-fade-in 200ms ease-out both}",".ax-state--error .ax-state-text{color:var(--err,#ef4444)}",".ax-state-btn{","display:inline-flex;align-items:center;justify-content:center;","width:44px;height:44px;padding:0;font:inherit;color:var(--fg,#18181b);","background:var(--card,#fff);border:1px solid var(--bd,#e4e4e7);","border-radius:calc(var(--br,10px) - 2px);","box-shadow:var(--sh1,0 1px 2px rgba(0,0,0,.04));","cursor:pointer;transition:var(--t,all .25s ease);","}",".ax-state-btn:hover{color:var(--p,#6d28d9);border-color:var(--p,#6d28d9);box-shadow:var(--sh2,0 4px 12px rgba(0,0,0,.08))}",".ax-state-btn:focus-visible{outline:2px solid var(--p,#6d28d9);outline-offset:2px}",".ax-state-btn:active{transform:scale(.96)}",".ax-state-btn svg{transition:transform .25s ease}",".ax-state-btn:hover svg{transform:rotate(-45deg)}",".ax-hide{display:none !important}","@media (prefers-reduced-motion:reduce){",".ax-state,.ax-state--loading,.ax-state--skeleton,.ax-state--error{animation:none}",".ax-state--loading svg{animation-duration:2s}",".ax-skel-line{animation:none;background-image:none;background-color:var(--sk1,#e4e4e7)}",".ax-state-btn:hover svg{transform:none}","::view-transition-old(root),::view-transition-new(root){animation:none}","}"].join("\n");!function(){if(!e.getElementById(r)){var t=e.createElement("style");t.id=r,t.appendChild(e.createTextNode(a)),(e.head||e.documentElement).appendChild(t)}}();var n,i=new Set,o=new WeakSet,s=new WeakMap,l=new WeakMap,u="[_get],[_post],[_go],[_open]",c=["_in","_out","_before","_after"];function f(t){return new URL(t,e.baseURI).href}function d(e){return new Promise(function(t){var r=new FileReader;r.onload=function(){t({name:e.name,type:e.type||"application/octet-stream",size:e.size,data:r.result})},r.onerror=function(){t({name:e.name,type:e.type,size:e.size,data:null})},r.readAsDataURL(e)})}function v(e){if(e.disabled)return Promise.resolve(void 0);var t=e.type;if("file"===t){var r=e.files;return r&&r.length?e.multiple?Promise.all(Array.prototype.map.call(r,d)):d(r[0]):Promise.resolve(e.multiple?[]:null)}return"checkbox"===t?Promise.resolve(e.checked?e.value||"on":null):"radio"===t?Promise.resolve(e.checked?e.value:null):"SELECT"===e.tagName&&e.multiple?Promise.resolve(Array.prototype.map.call(e.selectedOptions,function(e){return e.value})):Promise.resolve(e.value)}function p(t){var r,a=null,n=null;for(r=0;r<c.length;r++)if(t.hasAttribute(c[r])){a=c[r],n=t.getAttribute(c[r]);break}if(!a)return null;var i=t;if(n&&"this"!==n)try{i=e.querySelector(n)}catch(e){return null}return i&&i.parentNode?{mode:a,el:i,parent:i.parentNode}:null}function x(e,t){"_before"===e.mode||"_out"===e.mode?e.parent.insertBefore(t,e.el):e.parent.insertBefore(t,e.el.nextSibling)}function m(e){var t=l.get(e);t&&(t.node&&t.node.parentNode&&t.node.parentNode.removeChild(t.node),t.target&&t.target.removeAttribute("aria-busy"),l.delete(e))}function g(e,t){var r=e.querySelector(".ax-state-btn");r&&r.addEventListener("click",function(e){e.preventDefault(),e.stopPropagation(),k(t)})}function h(t){var r=e.createElement("div");return r.className="ax-state ax-state--error",r.setAttribute("role","alert"),r.innerHTML='<button type="button" class="ax-state-btn" aria-label="Retry"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-rotate-ccw preview-icon" aria-hidden="true"><path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/></svg></button><span class="ax-state-text">'+String(t).replace(/[&<>"']/g,function(e){return{"&":"&","<":"<",">":">",'"':""","'":"'"}[e]})+"</span>",r}function b(t){if("function"==typeof e.startViewTransition)try{return void e.startViewTransition(t)}catch(e){}t()}function k(r){if(function(e){return e.hasAttribute("_go")||e.hasAttribute("_open")}(r))!function(e){var r=function(e){var t=e.hasAttribute("_go")?e.getAttribute("_go"):e.getAttribute("_open");if(!(t=(t||"").trim())||"this"===t){var r=e.getAttribute("href");r&&(t=r)}return t?f(t):""}(e);if(r)if(e.hasAttribute("_go"))t.location.assign(r);else{var a=t.open(r,"_blank","noopener,noreferrer");a&&(a.opener=null)}}(r);else{var a=r.hasAttribute("_get"),n=r.getAttribute(a?"_get":"_post");if(null!==n&&p(r)){var o=s.get(r),c=new AbortController;s.set(r,c),o&&o.abort(),m(r);var d=0,k=setTimeout(function(){s.get(r)===c&&(function(t){var r=p(t);if(!r)return null;var a=(t.getAttribute("_loader")||"spinner").toLowerCase();if("none"===a||"off"===a||"false"===a)return null;r.el.classList.add("ax-hide"),r.el.setAttribute("aria-busy","true");var n=function(t){var r="skeleton"===t,a=e.createElement("div");return a.className="ax-state ax-state--"+(r?"skeleton":"loading"),a.setAttribute("role","status"),a.setAttribute("aria-live","polite"),a.setAttribute("aria-busy","true"),a.innerHTML=r?'<div class="ax-skel" aria-hidden="true"><span class="ax-skel-line" style="width:48%"></span><span class="ax-skel-line"></span><span class="ax-skel-line" style="width:86%"></span><span class="ax-skel-line" style="width:64%"></span></div><span class="ax-state-text">Loading…</span>':'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-loader-circle preview-icon" aria-hidden="true"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg><span class="ax-state-text">Loading…</span>',a}(a);x(r,n),l.set(t,{node:n,target:r.el})}(r),d=performance.now())},100),w=parseInt(r.getAttribute("_timeout"),10);w>0||(w=2e4);var _={method:a?"GET":"POST",credentials:"same-origin",headers:{"X-Requested-With":"XMLHttpRequest"},redirect:"follow",referrerPolicy:"same-origin",signal:c.signal},P=setTimeout(function(){c.abort()},w),T=Promise.resolve();if(!a)if(r.hasAttribute("_json"))T=function(t){var r=(t.getAttribute("_json")||"").trim();if(!r)return Promise.resolve(null);var a=r.split(",").map(function(e){return e.trim()}).filter(Boolean);if(!a.length)return Promise.resolve(null);var n=t.closest("form")||e;return Promise.all(a.map(function(t){return function(t,r){var a=e.getElementById(r);if(a&&t.contains(a))return v(a);var n=function(e,t){for(var r=e.querySelectorAll("input[name],select[name],textarea[name]"),a=[],n=0;n<r.length;n++)r[n].name===t&&a.push(r[n]);return a}(t,r);if(!n.length)return Promise.resolve(void 0);if(1===n.length)return v(n[0]);var i=n[0];if("radio"===i.type){for(var o=0;o<n.length;o++)if(n[o].checked)return Promise.resolve(n[o].value);return Promise.resolve(null)}if("checkbox"===i.type){for(var s=[],l=0;l<n.length;l++)n[l].checked&&!n[l].disabled&&s.push(n[l].value||"on");return Promise.resolve(s)}return v(i)}(n,t).then(function(e){return[t,e]})})).then(function(e){for(var t={},r=0;r<e.length;r++)void 0!==e[r][1]&&(t[e[r][0]]=e[r][1]);return JSON.stringify(t)})}(r).then(function(e){null!==e&&(_.headers["Content-Type"]="application/json",_.body=e)});else if(r.hasAttribute("_form")){var M=function(t){var r,a=t.getAttribute("_form");try{r=e.querySelector(a)||e.getElementById(a)}catch(e){r=null}return r?new FormData(r):null}(r);M&&(_.body=M)}T.then(function(){return fetch(n,_)}).then(function(e){if(clearTimeout(P),!e.ok){var t=new Error("HTTP "+e.status);throw t.status=e.status,t}return e.text()}).then(function(t){clearTimeout(k),A(function(){var a=function(){m(r),t&&function(t,r){var a=p(t);if(a){var n=e.createElement("template");n.innerHTML=r;var o,s,l=n.content,c=[],d=[];for(s=l.querySelectorAll("script"),o=0;o<s.length;o++)c.push(s[o]),s[o].parentNode.removeChild(s[o]);for(s=l.querySelectorAll(u),o=0;o<s.length;o++)d.push(s[o]);var v=a.el,x=a.parent;if("_in"===a.mode){for(;v.firstChild;)v.removeChild(v.firstChild);v.appendChild(l),v.classList.remove("ax-hide")}else"_out"===a.mode?x.replaceChild(l,v):"_before"===a.mode?(x.insertBefore(l,v),v.classList.remove("ax-hide")):(x.insertBefore(l,v.nextSibling),v.classList.remove("ax-hide"));for(o=0;o<d.length;o++)y(d[o]);!function(t){for(var r=0;r<t.length;r++){var a=t[r],n=a.getAttribute("src");if(n){if(n=f(n),i.has(n))continue;i.add(n)}for(var o=e.createElement("script"),s=0;s<a.attributes.length;s++)o.setAttribute(a.attributes[s].name,a.attributes[s].value);n||(o.text=a.text),o.async=!1,e.head.appendChild(o)}}(c)}}(r,t)};l.get(r)?b(a):a()})}).catch(function(e){var t;clearTimeout(P),clearTimeout(k),s.get(r)===c&&(t=e&&"AbortError"===e.name?"Request timed out":e&&e.message?e.message:"Request failed",e&&"AbortError"!==e.name&&console.error("[app]",e),A(function(){!function(e,t){var r=l.get(e),a=function(){if(r&&r.node&&r.node.parentNode){var a=r.node,n=h(t);a.parentNode.replaceChild(n,a),r.target&&r.target.removeAttribute("aria-busy"),l.set(e,{node:n,target:r.target}),g(n,e)}else{var i=p(e);if(!i)return;i.el.classList.add("ax-hide"),i.el.setAttribute("aria-busy","true");var o=h(t);x(i,o),l.set(e,{node:o,target:i.el}),g(o,e)}};r?b(a):a()}(r,t)}))})}}function A(e){if(0!==d){var t=Math.max(0,240-(performance.now()-d));0===t?s.get(r)===c&&e():setTimeout(function(){s.get(r)===c&&e()},t)}else s.get(r)===c&&e()}}function w(e){var t=e.getAttribute("_trigger");"load"===t||"visible"===t?k(e):e.addEventListener(t,function(t){if("click"===t.type){var r=e.tagName;"BUTTON"!==r&&"A"!==r||t.preventDefault()}k(e)})}function y(e){o.has(e)||(o.add(e),"click"!==(e.getAttribute("_trigger")||"click")&&("IntersectionObserver"in t?(n||(n=new IntersectionObserver(function(e){for(var t=0;t<e.length;t++)e[t].isIntersecting&&(n.unobserve(e[t].target),w(e[t].target))},{rootMargin:"300px"})),n.observe(e)):w(e)))}function _(e){for(var t=e.querySelectorAll(u),r=0;r<t.length;r++)y(t[r])}e.addEventListener("click",function(e){if(!e.target.closest(".ax-state")){var t=e.target.closest(u);if(t&&"click"===(t.getAttribute("_trigger")||"click")&&!(t.hasAttribute("_go")&&"A"===t.tagName&&t.getAttribute("href")&&(0!==e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey))){var r=t.tagName;"BUTTON"!==r&&"A"!==r||e.preventDefault(),k(t)}}},!0),function(){for(var t=e.querySelectorAll("script[src]"),r=0;r<t.length;r++)i.add(f(t[r].src));"loading"===e.readyState?e.addEventListener("DOMContentLoaded",function(){_(e)}):_(e)}()}();
|
package/dist/edge-server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @lengkapp/edge v0.0.
|
|
2
|
+
* @lengkapp/edge v0.0.24
|
|
3
3
|
* MIT License
|
|
4
4
|
*
|
|
5
5
|
* LengkApp Edge License
|
|
@@ -32,19 +32,30 @@
|
|
|
32
32
|
*/
|
|
33
33
|
// edge-server.d.ts
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
/* ------------------------------------------------------------------ *
|
|
36
|
+
* JSX runtime *
|
|
37
|
+
* ------------------------------------------------------------------ */
|
|
38
|
+
|
|
39
|
+
export const Fragment: unique symbol;
|
|
36
40
|
|
|
37
41
|
export interface JSXNode {
|
|
38
|
-
type:
|
|
42
|
+
type: string | symbol | ((props: any) => any);
|
|
39
43
|
props: Record<string, any>;
|
|
40
44
|
children: any[];
|
|
41
45
|
__isJSX: true;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
|
-
export function jsx(
|
|
48
|
+
export function jsx(
|
|
49
|
+
type: JSXNode['type'],
|
|
50
|
+
props: Record<string, any> | null,
|
|
51
|
+
...children: any[]
|
|
52
|
+
): JSXNode;
|
|
53
|
+
|
|
45
54
|
export function renderToString(node: any): string;
|
|
46
55
|
|
|
47
|
-
/*
|
|
56
|
+
/* ------------------------------------------------------------------ *
|
|
57
|
+
* Context *
|
|
58
|
+
* ------------------------------------------------------------------ */
|
|
48
59
|
|
|
49
60
|
export interface CookieOptions {
|
|
50
61
|
path?: string;
|
|
@@ -53,127 +64,116 @@ export interface CookieOptions {
|
|
|
53
64
|
expires?: Date;
|
|
54
65
|
secure?: boolean;
|
|
55
66
|
httpOnly?: boolean;
|
|
56
|
-
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
67
|
+
sameSite?: 'Strict' | 'Lax' | 'None' | string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface CorsOptions {
|
|
71
|
+
origin?: string | string[];
|
|
72
|
+
methods?: string;
|
|
73
|
+
headers?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface CacheOptions {
|
|
77
|
+
/** TTL in seconds. Default: 3600 */
|
|
78
|
+
ttl?: number;
|
|
79
|
+
/** stale-while-revalidate in seconds. Default: 0 */
|
|
80
|
+
staleWhileRevalidate?: number;
|
|
57
81
|
}
|
|
58
82
|
|
|
59
83
|
export interface RouteOptions {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
scopes?: string[];
|
|
63
|
-
};
|
|
64
|
-
rateLimit?: boolean | {
|
|
65
|
-
/** max requests per window (default 100) */
|
|
66
|
-
max?: number;
|
|
67
|
-
/** window in seconds (default 60) */
|
|
68
|
-
window?: number;
|
|
69
|
-
};
|
|
70
|
-
cors?: boolean | {
|
|
71
|
-
origin?: string | string[];
|
|
72
|
-
methods?: string;
|
|
73
|
-
headers?: string;
|
|
74
|
-
};
|
|
75
|
-
cache?: boolean | {
|
|
76
|
-
/** seconds (default 3600) */
|
|
77
|
-
ttl?: number;
|
|
78
|
-
staleWhileRevalidate?: number;
|
|
79
|
-
};
|
|
84
|
+
cors?: boolean | CorsOptions;
|
|
85
|
+
cache?: boolean | CacheOptions;
|
|
80
86
|
compress?: boolean;
|
|
81
87
|
log?: boolean;
|
|
82
88
|
validate?: (ctx: Context) => boolean | Promise<boolean>;
|
|
83
89
|
}
|
|
84
90
|
|
|
85
|
-
export
|
|
86
|
-
|
|
87
|
-
export class Context<E = any> {
|
|
91
|
+
export class Context {
|
|
88
92
|
constructor(
|
|
89
93
|
request: Request,
|
|
90
|
-
env:
|
|
94
|
+
env: Record<string, any>,
|
|
91
95
|
executionCtx: ExecutionContext,
|
|
92
96
|
params?: Record<string, string>,
|
|
93
|
-
parsedUrl?: URL | null
|
|
97
|
+
parsedUrl?: URL | null
|
|
94
98
|
);
|
|
95
99
|
|
|
96
100
|
req: Request;
|
|
97
|
-
env:
|
|
101
|
+
env: Record<string, any>;
|
|
98
102
|
executionCtx: ExecutionContext;
|
|
99
103
|
params: Record<string, string>;
|
|
100
104
|
status: number;
|
|
101
105
|
headers: Headers;
|
|
102
106
|
url: URL;
|
|
103
107
|
|
|
104
|
-
readonly query: URLSearchParams;
|
|
105
|
-
|
|
106
108
|
getCookie(name: string): string | null;
|
|
109
|
+
readonly query: URLSearchParams;
|
|
107
110
|
setCookie(name: string, value: string, options?: CookieOptions): void;
|
|
108
111
|
deleteCookie(name: string, options?: CookieOptions): void;
|
|
109
112
|
|
|
110
113
|
text(data: string, status?: number, headers?: Record<string, string>): Response;
|
|
111
114
|
json(data: any, status?: number, headers?: Record<string, string>): Response;
|
|
112
|
-
|
|
113
|
-
/** Accepts a raw HTML string, JSX, or an array of JSX. */
|
|
114
115
|
html(
|
|
115
116
|
data: string | JSXNode | JSXNode[] | null | undefined,
|
|
116
117
|
status?: number,
|
|
117
|
-
headers?: Record<string, string
|
|
118
|
+
headers?: Record<string, string>
|
|
118
119
|
): Response;
|
|
120
|
+
redirect(location: string, status?: number): Response;
|
|
119
121
|
}
|
|
120
122
|
|
|
121
|
-
/*
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
/* ------------------------------------------------------------------ *
|
|
124
|
+
* Edge router *
|
|
125
|
+
* ------------------------------------------------------------------ */
|
|
126
|
+
|
|
127
|
+
export type RouteHandler = (ctx: Context) => any | Promise<any>;
|
|
128
|
+
|
|
129
|
+
export type ScheduledHandler = (
|
|
130
|
+
event: ScheduledEvent,
|
|
131
|
+
env: Record<string, any>,
|
|
132
|
+
ctx: ExecutionContext
|
|
133
|
+
) => void | Promise<void>;
|
|
134
|
+
|
|
135
|
+
export interface SecurityOptions {
|
|
136
|
+
/** Emit structured security logs. Default: true */
|
|
137
|
+
logSecurityEvents?: boolean;
|
|
138
|
+
/** Extra response headers applied to every route. */
|
|
139
|
+
extraHeaders?: Record<string, string> | null;
|
|
140
|
+
/** Trusted proxy list (reserved). */
|
|
141
|
+
trustedProxies?: string[] | null;
|
|
128
142
|
}
|
|
129
143
|
|
|
130
|
-
export interface
|
|
131
|
-
cors:
|
|
144
|
+
export interface EdgeDefaults {
|
|
145
|
+
cors: CorsOptions & { methods: string };
|
|
132
146
|
}
|
|
133
147
|
|
|
134
|
-
export class Edge
|
|
148
|
+
export class Edge {
|
|
135
149
|
constructor();
|
|
136
150
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
defaults:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
get(path: string, handler:
|
|
144
|
-
|
|
145
|
-
post(path: string, options
|
|
146
|
-
post(path: string, handler:
|
|
147
|
-
|
|
148
|
-
put(path: string,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
): void;
|
|
166
|
-
|
|
167
|
-
fetch(request: Request, env: E, executionCtx: ExecutionContext): Promise<Response>;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/* ---------------- JSX typing for this runtime ---------------- */
|
|
171
|
-
|
|
172
|
-
declare global {
|
|
173
|
-
namespace JSX {
|
|
174
|
-
type Element = JSXNode;
|
|
175
|
-
type ElementType = string | symbol | ((props: any) => JSXNode);
|
|
176
|
-
interface IntrinsicElements { [elemName: string]: any; }
|
|
177
|
-
interface ElementChildrenAttribute { children: {}; }
|
|
178
|
-
}
|
|
151
|
+
readonly staticRoutes: Map<string, Map<string, { handler: RouteHandler; options: RouteOptions }>>;
|
|
152
|
+
readonly dynamicTries: Record<string, any>;
|
|
153
|
+
defaults: EdgeDefaults;
|
|
154
|
+
scheduledHandler: ScheduledHandler | null;
|
|
155
|
+
security: SecurityOptions;
|
|
156
|
+
|
|
157
|
+
get(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
158
|
+
get(path: string, handler: RouteHandler): void;
|
|
159
|
+
post(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
160
|
+
post(path: string, handler: RouteHandler): void;
|
|
161
|
+
put(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
162
|
+
put(path: string, handler: RouteHandler): void;
|
|
163
|
+
delete(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
164
|
+
delete(path: string, handler: RouteHandler): void;
|
|
165
|
+
patch(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
166
|
+
patch(path: string, handler: RouteHandler): void;
|
|
167
|
+
options(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
168
|
+
options(path: string, handler: RouteHandler): void;
|
|
169
|
+
head(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
170
|
+
head(path: string, handler: RouteHandler): void;
|
|
171
|
+
|
|
172
|
+
scheduled(handler: ScheduledHandler): void;
|
|
173
|
+
|
|
174
|
+
fetch(
|
|
175
|
+
request: Request,
|
|
176
|
+
env: Record<string, any>,
|
|
177
|
+
executionCtx: ExecutionContext
|
|
178
|
+
): Promise<Response>;
|
|
179
179
|
}
|
package/dist/edge-server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @lengkapp/edge v0.0.
|
|
2
|
+
* @lengkapp/edge v0.0.24
|
|
3
3
|
* MIT License
|
|
4
4
|
*
|
|
5
5
|
* LengkApp Edge License
|
|
@@ -30,4 +30,4 @@
|
|
|
30
30
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
31
31
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
32
32
|
*/
|
|
33
|
-
var t=Object.defineProperty,e=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,r=Object.prototype.hasOwnProperty,o=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},i=(o,i,s,a)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let c of n(i))r.call(o,c)||c===s||t(o,c,{get:()=>i[c],enumerable:!(a=e(i,c))||a.enumerable});return o},s=e=>i(t({},"__esModule",{value:!0}),e),a={};function c(t){const e=[],n=t.length;let r=1;for(let o=1;o<=n;o++)o!==n&&47!==t.charCodeAt(o)||(o>r&&e.push(t.slice(r,o)),r=o+1);return e}function l(t){const e=t.length;return e>1&&47===t.charCodeAt(e-1)?t.slice(0,-1):t}o(a,{Context:()=>T,Edge:()=>Edge,Fragment:()=>Fragment,jsx:()=>jsx,renderToString:()=>renderToString}),module.exports=s(a);var u=new Set(["__proto__","constructor","prototype"]);function f(t){return"string"==typeof t&&!u.has(t)}function h(t){const e=JSON.parse(t);if(e&&"object"==typeof e)for(const t of Object.keys(e))if(!f(t))throw new SyntaxError("Forbidden key in JSON payload");return e}function p(t){const e=t.length;let n=0;for(;n<e;){const e=t.charCodeAt(n);if(38===e||60===e||62===e||34===e||39===e)break;n++}if(n===e)return t;let r=t.slice(0,n),o=n;for(;n<e;n++){const e=t.charCodeAt(n);let i;if(38===e)i="&";else if(60===e)i="<";else if(62===e)i=">";else if(34===e)i=""";else{if(39!==e)continue;i="'"}n>o&&(r+=t.slice(o,n)),r+=i,o=n+1}return o<e&&(r+=t.slice(o)),r}var Fragment=Symbol("Fragment");function jsx(t,e,...n){return{type:t,props:e||{},children:n,__isJSX:!0}}var d=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),y=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),m=new Set(["animation-iteration-count","border-image-outset","border-image-slice","border-image-width","box-flex","box-flex-group","box-ordinal-group","column-count","columns","flex","flex-grow","flex-positive","flex-shrink","flex-negative","flex-order","grid-row","grid-row-end","grid-row-span","grid-row-start","grid-column","grid-column-end","grid-column-span","grid-column-start","font-weight","line-clamp","line-height","opacity","order","orphans","tab-size","widows","z-index","zoom","fill-opacity","flood-opacity","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","stroke-width"]),g=new Map,w=2e3;function b(t){const e=g.get(t);if(void 0!==e)return e;const n=t.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,"");return g.size>=w&&g.clear(),g.set(t,n),n}function A(t){if(!t||"object"!=typeof t)return"";let e="";for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const r=b(n);let o=t[n];"number"!=typeof o||m.has(r)||(o+="px"),e&&(e+=";"),e+=r+":"+o}return e}var C=new Set(["href","src","xlink:href","action","formaction"]);function renderToString(t){if(null==t||"boolean"==typeof t)return"";const e=typeof t;if("string"===e)return p(t);if("number"===e)return p(String(t));if(Array.isArray(t)){let e="";for(let n=0;n<t.length;n++)e+=renderToString(t[n]);return e}if(!t.__isJSX)return p(String(t));const{type:n,props:r,children:o}=t;if(n===Fragment){let t="";for(let e=0;e<o.length;e++)t+=renderToString(o[e]);return t}if("symbol"==typeof n)return"";if("function"==typeof n)return renderToString(n({...r,children:o}));if("string"!=typeof n||!/^[A-Za-z][A-Za-z0-9-]*$/.test(n))return"";const i=d.has(n);let s="";for(const t in r){if(!Object.prototype.hasOwnProperty.call(r,t))continue;if("children"===t||"key"===t||"ref"===t)continue;const e=r[t];if(null==e||!1===e)continue;if("dangerouslySetInnerHTML"===t)continue;let n=t;if("className"===t||"class"===t?n="class":"htmlFor"!==t&&"for"!==t||(n="for"),f(n)&&!/^on/i.test(n)&&/^[A-Za-z_:][A-Za-z0-9_:.-]*$/.test(n)){if(C.has(n)){const t=String(e).replace(/[\u0000-\u0020]/g,"").toLowerCase();if(t.startsWith("javascript:")||t.startsWith("vbscript:")||t.startsWith("data:text/html"))continue}if(y.has(n))!0===e&&(s+=" "+n);else if(!0!==e){if("style"===n&&"object"==typeof e){const t=A(e);t&&(s+=' style="'+p(t)+'"');continue}s+=" "+n+'="'+p(String(e))+'"'}else s+=" "+n+'="true"'}}let a="";const c=r.dangerouslySetInnerHTML;if(c&&null!=c.__html)a=c.__html;else for(let t=0;t<o.length;t++)a+=renderToString(o[t]);return i?"<"+n+s+"/>":"<"+n+s+">"+a+"</"+n+">"}var T=class{constructor(t,e,n,r={},o=null){this.req=t,this.env=e,this.executionCtx=n,this.params=r,this.status=200,this.headers=new Headers,this.headers.set("X-Content-Type-Options","nosniff"),this.headers.set("X-Frame-Options","DENY"),this.headers.set("Referrer-Policy","strict-origin-when-cross-origin"),this.headers.set("Permissions-Policy","geolocation=(), microphone=(), camera=()"),this.t=t.headers.get("Cookie")||"",this.o=null,this.url=o||new URL(t.url)}i(){if(null!==this.o)return this.o;const t=Object.create(null),e=this.t;if(e){let n=0;const r=e.length;for(;n<r;){let o=e.indexOf(";",n);-1===o&&(o=r);let i=n,s=o;for(;i<s&&32===e.charCodeAt(i);)i++;for(;s>i&&32===e.charCodeAt(s-1);)s--;if(s>i){const n=e.indexOf("=",i);if(n>i&&n<s)try{const r=decodeURIComponent(e.slice(i,n));f(r)&&(t[r]=decodeURIComponent(e.slice(n+1,s)))}catch{}}n=o+1}}return this.o=t,t}getCookie(t){const e=this.i()[t];return void 0===e?null:e}get query(){return this.url.searchParams}setCookie(t,e,n={}){if("string"!=typeof t||!f(t)||/[\r\n;=]/.test(t))return;let r=encodeURIComponent(t)+"="+encodeURIComponent(e);n.path&&(r+="; Path="+n.path),n.domain&&(r+="; Domain="+n.domain),void 0!==n.maxAge&&(r+="; Max-Age="+n.maxAge),n.expires&&(r+="; Expires="+n.expires.toUTCString()),n.secure&&(r+="; Secure"),n.httpOnly&&(r+="; HttpOnly"),n.sameSite&&(r+="; SameSite="+n.sameSite),this.headers.append("Set-Cookie",r)}deleteCookie(t,e={}){this.setCookie(t,"",{...e,maxAge:0,expires:new Date(0)})}l(t){if(!t)return this.headers;let e=!1;for(const n in t){e=!0;break}if(!e)return this.headers;const n=new Headers(this.headers);for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&n.set(e,t[e]);return n}text(t,e=this.status,n={}){const r=this.l(n);return r.has("Content-Type")||r.set("Content-Type","text/plain; charset=utf-8"),new Response(t,{status:e,headers:r})}json(t,e=this.status,n={}){const r=this.l(n);return r.has("Content-Type")||r.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(t),{status:e,headers:r})}html(t,e=this.status,n={}){const r=this.l(n);r.has("Content-Type")||r.set("Content-Type","text/html; charset=utf-8");const o="string"==typeof t?t:t&&t.__isJSX||Array.isArray(t)?renderToString(t):null==t?"":String(t);return new Response(o,{status:e,headers:r})}},_=class{constructor(){this.children=null,this.paramChild=null,this.handler=null}},k=class{constructor(){this.root=new _}add(t,e,n){let r=this.root;const o=[];for(let e=0;e<t.length;e++){const n=t[e];if(58===n.charCodeAt(0)){const t=n.slice(1);o.push(f(t)?t:"_p"+e),r.paramChild||(r.paramChild=new _),r=r.paramChild}else{r.children||(r.children=new Map);let t=r.children.get(n);t||(t=new _,r.children.set(n,t)),r=t}}r.handler={handler:e,options:n,paramNames:o}}match(t){const e=[],n=this.u(this.root,t,0,e);if(!n)return null;const{handler:r,options:o,paramNames:i}=n,s=Object.create(null);for(let t=0;t<i.length;t++)s[i[t]]=e[t];return{handler:r,options:o,params:s}}u(t,e,n,r){if(n===e.length)return t.handler;const o=e[n],i=t.children;if(i){const t=i.get(o);if(t){const o=this.u(t,e,n+1,r);if(o)return o}}const s=t.paramChild;if(s){r.push(o);const t=this.u(s,e,n+1,r);if(t)return t;r.pop()}return null}},O=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD"],S=new Map;function E(t,e,n){const r=t+"|"+(e||"")+"|"+(n||""),o=Date.now(),i=S.get(r);if(i&&o-i<6e4)return!1;if(S.set(r,o),S.size>5e3)for(const[t,e]of S)o-e>6e4&&S.delete(t);return!0}var Edge=class{constructor(){this.staticRoutes=new Map;for(let t=0;t<O.length;t++)this.staticRoutes.set(O[t],new Map);this.dynamicTries={};for(let t=0;t<O.length;t++)this.dynamicTries[O[t]]=new k;this.authKvBinding="AUTH_KV",this.rateLimitKvBinding="RATE_LIMIT_KV",this.defaults={cors:{origin:"*",methods:"GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD"}},this.scheduledHandler=null,this.security={hashAuthTokens:!1,logSecurityEvents:!0,extraHeaders:null,trustedProxies:null}}h(t,e,n,r){if("boolean"==typeof n?n={auth:n}:"function"==typeof n&&(r=n,n={}),"function"!=typeof r)throw new Error("Handler for "+t+" "+e+" must be a function");const o={...this.defaults,...n||{}};-1===e.indexOf(":")?this.staticRoutes.get(t).set(l(e),{handler:r,options:o}):this.dynamicTries[t].add(c(e),r,o)}get(t,e,n){this.h("GET",t,e,n)}post(t,e,n){this.h("POST",t,e,n)}put(t,e,n){this.h("PUT",t,e,n)}delete(t,e,n){this.h("DELETE",t,e,n)}patch(t,e,n){this.h("PATCH",t,e,n)}options(t,e,n){this.h("OPTIONS",t,e,n)}head(t,e,n){this.h("HEAD",t,e,n)}scheduled(t){this.scheduledHandler=t}p(t,e,n){if(this.security.logSecurityEvents)try{const r=t.req.headers.get("CF-Connecting-IP")||"",o=t.url?t.url.pathname:"";if(!E(e,r,o))return;console.log(JSON.stringify({ts:(new Date).toISOString(),kind:"security",event:e,detail:"string"==typeof n?n:void 0,ip:r||void 0,method:t.req.method,path:o,ua:t.req.headers.get("User-Agent")||void 0}))}catch{}}async m(t,e){if(!e)return{ok:!0};const n=t.getCookie("auth_token")||t.req.headers.get("Authorization")?.replace(/^Bearer\s+/i,"");if(!n)return{ok:!1,reason:"missing_token"};const r=t.env[this.authKvBinding];if(!r)return{ok:!1,reason:"kv_unavailable"};let o,i=n;if(this.security.hashAuthTokens&&globalThis.crypto&&crypto.subtle){const t=await crypto.subtle.digest("SHA-256",(new TextEncoder).encode(n)),e=new Uint8Array(t);let r="";for(let t=0;t<e.length;t++)r+=e[t].toString(16).padStart(2,"0");i="tok:"+r}try{o=await r.get(i)}catch{return{ok:!1,reason:"kv_error"}}if(!o)return{ok:!1,reason:"invalid_token"};if("object"==typeof e&&null!==e){let t;try{t=h(o)}catch{return{ok:!1,reason:"malformed_payload"}}if(t&&"object"==typeof t){if(null!=t.exp&&"number"==typeof t.exp&&t.exp<Date.now()/1e3)return{ok:!1,reason:"expired_token"};if(e.role&&t.role!==e.role)return{ok:!1,reason:"insufficient_role"};if(e.scopes){const n=Array.isArray(t.scopes)?t.scopes:[];for(let t=0;t<e.scopes.length;t++)if(-1===n.indexOf(e.scopes[t]))return{ok:!1,reason:"insufficient_scopes"}}}}return{ok:!0,payload:o}}async A(t,e){if(!e)return!0;const n=!0===e?{}:e,r=n.max??100,o=n.window??60,i="rl:"+(t.req.headers.get("CF-Connecting-IP")||"unknown"),s=t.env[this.rateLimitKvBinding];if(!s)return!0;let a;try{a=await s.get(i,"json")}catch{return!0}if(("number"!=typeof a||!isFinite(a)||a<0)&&(a=0),a>=r)return!1;a++;try{await s.put(i,JSON.stringify(a),{expirationTtl:o})}catch{}return!0}C(t,e){if(!e)return;const n="object"==typeof e?e:this.defaults.cors,r=t.req.headers.get("Origin"),o=n.origin;"*"===o?t.headers.set("Access-Control-Allow-Origin","*"):Array.isArray(o)?r&&-1!==o.indexOf(r)&&(t.headers.set("Access-Control-Allow-Origin",r),t.headers.set("Vary","Origin"),t.headers.set("Access-Control-Allow-Credentials","true")):"string"==typeof o&&r===o&&(t.headers.set("Access-Control-Allow-Origin",r),t.headers.set("Vary","Origin"),t.headers.set("Access-Control-Allow-Credentials","true")),t.headers.set("Access-Control-Allow-Methods",n.methods||"GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD"),t.headers.set("Access-Control-Allow-Headers",n.headers||"Content-Type, Authorization, X-CSRF-Token"),t.headers.set("Access-Control-Max-Age","86400")}T(t,e){e&&console.log(t.req.method+" "+t.req.url+" - "+t.status)}_(t,e){const n=t.headers.get("Accept-Encoding")||"";let r=null;if(-1!==n.indexOf("gzip")?r="gzip":-1!==n.indexOf("deflate")&&(r="deflate"),!r||!e.body)return e;const o=e.body.pipeThrough(new CompressionStream(r)),i=new Headers(e.headers);return i.set("Content-Encoding",r),i.set("Vary","Accept-Encoding"),i.delete("Content-Length"),new Response(o,{status:e.status,statusText:e.statusText,headers:i})}async k(t,e){return!e||"function"!=typeof e||!!await e(t)}async O(t){return await caches.default.match(t)||null}async S(t,e,n){if(!n)return;const r=!0===n?{}:n,o=r.ttl??3600,i=r.staleWhileRevalidate??0,s=e.clone();s.headers.set("Cache-Control","max-age="+o+(i>0?", stale-while-revalidate="+i:"")),s.headers.delete("Set-Cookie"),await caches.default.put(t,s)}async fetch(t,e,n){const r=new URL(t.url),o=l(r.pathname),i=t.method,s=this.staticRoutes.get(i);if(s){const i=s.get(o);if(i)return this.v(i.handler,i.options,t,e,n,Object.create(null),r)}const a=this.dynamicTries[i];if(a){const i=a.match(c(o));if(i)return this.v(i.handler,i.options,t,e,n,i.params,r)}return new Response("Not Found",{status:404})}async v(t,e,n,r,o,i,s){const a=new T(n,r,o,i,s),c=this.security.extraHeaders;if(c)for(const t in c)Object.prototype.hasOwnProperty.call(c,t)&&a.headers.set(t,c[t]);let l,u=!1;try{u=await this.k(a,e.validate)}catch(t){this.p(a,"validation_error",t&&t.message),u=!1}if(!u)return a.text("Validation failed",400);try{l=await this.m(a,e.auth)}catch(t){this.p(a,"auth_error",t&&t.message),l={ok:!1,reason:"auth_error"}}if(!("boolean"==typeof l?l:l&&l.ok))return this.p(a,"auth_failure",l&&l.reason||"denied"),a.text("Unauthorized",401);let f,h=!1;try{h=await this.A(a,e.rateLimit)}catch(t){this.p(a,"rate_limit_error",t&&t.message),h=!1}if(!h)return this.p(a,"rate_limit_exceeded",null),a.text("Too Many Requests",429,{"Retry-After":"60"});if(e.cache&&"GET"===n.method){const t=await this.O(n);if(t)return this.C(a,e.cors),this.T(a,e.log),t}this.C(a,e.cors);try{const e=await t(a);f=e instanceof Response?e:e&&e.__isJSX?a.html(e):a.text("OK"),a.status=f.status}catch(t){this.p(a,"handler_error",t&&t.message),f=a.text("Internal Server Error",500),a.status=500}return e.cache&&"GET"===n.method&&200===f.status&&a.executionCtx.waitUntil(this.S(n,f.clone(),e.cache)),e.compress&&(f=this._(n,f)),this.T(a,e.log),f}};
|
|
33
|
+
var t=Object.defineProperty,e=Object.getOwnPropertyDescriptor,n=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,r=(e,n)=>{for(var o in n)t(e,o,{get:n[o],enumerable:!0})},i=(r,i,s,c)=>{if(i&&"object"==typeof i||"function"==typeof i)for(let l of n(i))o.call(r,l)||l===s||t(r,l,{get:()=>i[l],enumerable:!(c=e(i,l))||c.enumerable});return r},s=e=>i(t({},"__esModule",{value:!0}),e),c={};function l(t){const e=[],n=t.length;let o=1;for(let r=1;r<=n;r++)r!==n&&47!==t.charCodeAt(r)||(r>o&&e.push(t.slice(o,r)),o=r+1);return e}function a(t){const e=t.length;return e>1&&47===t.charCodeAt(e-1)?t.slice(0,-1):t}r(c,{Context:()=>T,Edge:()=>Edge,Fragment:()=>Fragment,jsx:()=>jsx,renderToString:()=>renderToString}),module.exports=s(c);var u=new Set(["__proto__","constructor","prototype"]);function f(t){return"string"==typeof t&&!u.has(t)}function h(t){const e=t.length;let n=0;for(;n<e;){const e=t.charCodeAt(n);if(38===e||60===e||62===e||34===e||39===e)break;n++}if(n===e)return t;let o=t.slice(0,n),r=n;for(;n<e;n++){const e=t.charCodeAt(n);let i;if(38===e)i="&";else if(60===e)i="<";else if(62===e)i=">";else if(34===e)i=""";else{if(39!==e)continue;i="'"}n>r&&(o+=t.slice(r,n)),o+=i,r=n+1}return r<e&&(o+=t.slice(r)),o}var Fragment=Symbol("Fragment");function jsx(t,e,...n){return{type:t,props:e||{},children:n,__isJSX:!0}}var p=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),d=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),y=new Set(["animation-iteration-count","border-image-outset","border-image-slice","border-image-width","box-flex","box-flex-group","box-ordinal-group","column-count","columns","flex","flex-grow","flex-positive","flex-shrink","flex-negative","flex-order","grid-row","grid-row-end","grid-row-span","grid-row-start","grid-column","grid-column-end","grid-column-span","grid-column-start","font-weight","line-clamp","line-height","opacity","order","orphans","tab-size","widows","z-index","zoom","fill-opacity","flood-opacity","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-miterlimit","stroke-opacity","stroke-width"]),g=new Map,m=2e3;function w(t){const e=g.get(t);if(void 0!==e)return e;const n=t.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,"");return g.size>=m&&g.clear(),g.set(t,n),n}function C(t){if(!t||"object"!=typeof t)return"";let e="";for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const o=w(n);let r=t[n];"number"!=typeof r||y.has(o)||(r+="px"),e&&(e+=";"),e+=o+":"+r}return e}var b=new Set(["href","src","xlink:href","action","formaction"]);function renderToString(t){if(null==t||"boolean"==typeof t)return"";const e=typeof t;if("string"===e)return h(t);if("number"===e)return h(String(t));if(Array.isArray(t)){let e="";for(let n=0;n<t.length;n++)e+=renderToString(t[n]);return e}if(!t.__isJSX)return h(String(t));const{type:n,props:o,children:r}=t;if(n===Fragment){let t="";for(let e=0;e<r.length;e++)t+=renderToString(r[e]);return t}if("symbol"==typeof n)return"";if("function"==typeof n)return renderToString(n({...o,children:r}));if("string"!=typeof n||!/^[A-Za-z][A-Za-z0-9-]*$/.test(n))return"";const i=p.has(n);let s="";for(const t in o){if(!Object.prototype.hasOwnProperty.call(o,t))continue;if("children"===t||"key"===t||"ref"===t)continue;const e=o[t];if(null==e||!1===e)continue;if("dangerouslySetInnerHTML"===t)continue;let n=t;if("className"===t||"class"===t?n="class":"htmlFor"!==t&&"for"!==t||(n="for"),f(n)&&!/^on/i.test(n)&&/^[A-Za-z_:][A-Za-z0-9_:.-]*$/.test(n)){if(b.has(n)){const t=String(e).replace(/[\u0000-\u0020]/g,"").toLowerCase();if(t.startsWith("javascript:")||t.startsWith("vbscript:")||t.startsWith("data:text/html"))continue}if(d.has(n))!0===e&&(s+=" "+n);else if(!0!==e){if("style"===n&&"object"==typeof e){const t=C(e);t&&(s+=' style="'+h(t)+'"');continue}s+=" "+n+'="'+h(String(e))+'"'}else s+=" "+n+'="true"'}}let c="";const l=o.dangerouslySetInnerHTML;if(l&&null!=l.__html)c=l.__html;else for(let t=0;t<r.length;t++)c+=renderToString(r[t]);return i?"<"+n+s+"/>":"<"+n+s+">"+c+"</"+n+">"}var T=class{constructor(t,e,n,o={},r=null){this.req=t,this.env=e,this.executionCtx=n,this.params=o,this.status=200,this.headers=new Headers,this.headers.set("X-Content-Type-Options","nosniff"),this.headers.set("X-Frame-Options","DENY"),this.headers.set("Referrer-Policy","strict-origin-when-cross-origin"),this.headers.set("Permissions-Policy","geolocation=(), microphone=(), camera=()"),this.t=t.headers.get("Cookie")||"",this.o=null,this.url=r||new URL(t.url)}i(){if(null!==this.o)return this.o;const t=Object.create(null),e=this.t;if(e){let n=0;const o=e.length;for(;n<o;){let r=e.indexOf(";",n);-1===r&&(r=o);let i=n,s=r;for(;i<s&&32===e.charCodeAt(i);)i++;for(;s>i&&32===e.charCodeAt(s-1);)s--;if(s>i){const n=e.indexOf("=",i);if(n>i&&n<s)try{const o=decodeURIComponent(e.slice(i,n));f(o)&&(t[o]=decodeURIComponent(e.slice(n+1,s)))}catch{}}n=r+1}}return this.o=t,t}getCookie(t){const e=this.i()[t];return void 0===e?null:e}get query(){return this.url.searchParams}setCookie(t,e,n={}){if("string"!=typeof t||!f(t)||/[\r\n;=]/.test(t))return;let o=encodeURIComponent(t)+"="+encodeURIComponent(e);n.path&&(o+="; Path="+n.path),n.domain&&(o+="; Domain="+n.domain),void 0!==n.maxAge&&(o+="; Max-Age="+n.maxAge),n.expires&&(o+="; Expires="+n.expires.toUTCString()),n.secure&&(o+="; Secure"),n.httpOnly&&(o+="; HttpOnly"),n.sameSite&&(o+="; SameSite="+n.sameSite),this.headers.append("Set-Cookie",o)}deleteCookie(t,e={}){this.setCookie(t,"",{...e,maxAge:0,expires:new Date(0)})}l(t){if(!t)return this.headers;let e=!1;for(const n in t){e=!0;break}if(!e)return this.headers;const n=new Headers(this.headers);for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&n.set(e,t[e]);return n}text(t,e=this.status,n={}){const o=this.l(n);return o.has("Content-Type")||o.set("Content-Type","text/plain; charset=utf-8"),new Response(t,{status:e,headers:o})}json(t,e=this.status,n={}){const o=this.l(n);return o.has("Content-Type")||o.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(t),{status:e,headers:o})}html(t,e=this.status,n={}){const o=this.l(n);o.has("Content-Type")||o.set("Content-Type","text/html; charset=utf-8");const r="string"==typeof t?t:t&&t.__isJSX||Array.isArray(t)?renderToString(t):null==t?"":String(t);return new Response(r,{status:e,headers:o})}redirect(t,e=302){const n=new Headers(this.headers);return n.set("Location",String(t)),n.delete("Content-Type"),new Response(null,{status:e,headers:n})}},A=class{constructor(){this.children=null,this.paramChild=null,this.handler=null}},O=class{constructor(){this.root=new A}add(t,e,n){let o=this.root;const r=[];for(let e=0;e<t.length;e++){const n=t[e];if(58===n.charCodeAt(0)){const t=n.slice(1);r.push(f(t)?t:"_p"+e),o.paramChild||(o.paramChild=new A),o=o.paramChild}else{o.children||(o.children=new Map);let t=o.children.get(n);t||(t=new A,o.children.set(n,t)),o=t}}o.handler={handler:e,options:n,paramNames:r}}match(t){const e=[],n=this.u(this.root,t,0,e);if(!n)return null;const{handler:o,options:r,paramNames:i}=n,s=Object.create(null);for(let t=0;t<i.length;t++)s[i[t]]=e[t];return{handler:o,options:r,params:s}}u(t,e,n,o){if(n===e.length)return t.handler;const r=e[n],i=t.children;if(i){const t=i.get(r);if(t){const r=this.u(t,e,n+1,o);if(r)return r}}const s=t.paramChild;if(s){o.push(r);const t=this.u(s,e,n+1,o);if(t)return t;o.pop()}return null}},S=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD"],E=new Map;function v(t,e,n){const o=t+"|"+(e||"")+"|"+(n||""),r=Date.now(),i=E.get(o);if(i&&r-i<6e4)return!1;if(E.set(o,r),E.size>5e3)for(const[t,e]of E)r-e>6e4&&E.delete(t);return!0}var Edge=class{constructor(){this.staticRoutes=new Map;for(let t=0;t<S.length;t++)this.staticRoutes.set(S[t],new Map);this.dynamicTries={};for(let t=0;t<S.length;t++)this.dynamicTries[S[t]]=new O;this.defaults={cors:{origin:"*",methods:"GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD"}},this.scheduledHandler=null,this.security={logSecurityEvents:!0,extraHeaders:null,trustedProxies:null}}h(t,e,n,o){if("boolean"==typeof n?n={}:"function"==typeof n&&(o=n,n={}),"function"!=typeof o)throw new Error("Handler for "+t+" "+e+" must be a function");const r={...this.defaults,...n||{}};-1===e.indexOf(":")?this.staticRoutes.get(t).set(a(e),{handler:o,options:r}):this.dynamicTries[t].add(l(e),o,r)}get(t,e,n){this.h("GET",t,e,n)}post(t,e,n){this.h("POST",t,e,n)}put(t,e,n){this.h("PUT",t,e,n)}delete(t,e,n){this.h("DELETE",t,e,n)}patch(t,e,n){this.h("PATCH",t,e,n)}options(t,e,n){this.h("OPTIONS",t,e,n)}head(t,e,n){this.h("HEAD",t,e,n)}scheduled(t){this.scheduledHandler=t}p(t,e,n){if(this.security.logSecurityEvents)try{const o=t.req.headers.get("CF-Connecting-IP")||"",r=t.url?t.url.pathname:"";if(!v(e,o,r))return;console.log(JSON.stringify({ts:(new Date).toISOString(),kind:"security",event:e,detail:"string"==typeof n?n:void 0,ip:o||void 0,method:t.req.method,path:r,ua:t.req.headers.get("User-Agent")||void 0}))}catch{}}m(t,e){if(!e)return;const n="object"==typeof e?e:this.defaults.cors,o=t.req.headers.get("Origin"),r=n.origin;"*"===r?t.headers.set("Access-Control-Allow-Origin","*"):Array.isArray(r)?o&&-1!==r.indexOf(o)&&(t.headers.set("Access-Control-Allow-Origin",o),t.headers.set("Vary","Origin"),t.headers.set("Access-Control-Allow-Credentials","true")):"string"==typeof r&&o===r&&(t.headers.set("Access-Control-Allow-Origin",o),t.headers.set("Vary","Origin"),t.headers.set("Access-Control-Allow-Credentials","true")),t.headers.set("Access-Control-Allow-Methods",n.methods||"GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD"),t.headers.set("Access-Control-Allow-Headers",n.headers||"Content-Type, Authorization, X-CSRF-Token"),t.headers.set("Access-Control-Max-Age","86400")}C(t,e){e&&console.log(t.req.method+" "+t.req.url+" - "+t.status)}T(t,e){const n=t.headers.get("Accept-Encoding")||"";let o=null;if(-1!==n.indexOf("gzip")?o="gzip":-1!==n.indexOf("deflate")&&(o="deflate"),!o||!e.body)return e;const r=e.body.pipeThrough(new CompressionStream(o)),i=new Headers(e.headers);return i.set("Content-Encoding",o),i.set("Vary","Accept-Encoding"),i.delete("Content-Length"),new Response(r,{status:e.status,statusText:e.statusText,headers:i})}async A(t,e){return!e||"function"!=typeof e||!!await e(t)}async O(t){return await caches.default.match(t)||null}async S(t,e,n){if(!n)return;const o=!0===n?{}:n,r=o.ttl??3600,i=o.staleWhileRevalidate??0,s=e.clone();s.headers.set("Cache-Control","max-age="+r+(i>0?", stale-while-revalidate="+i:"")),s.headers.delete("Set-Cookie"),await caches.default.put(t,s)}async fetch(t,e,n){const o=new URL(t.url),r=a(o.pathname),i=t.method,s=this.staticRoutes.get(i);if(s){const i=s.get(r);if(i)return this.v(i.handler,i.options,t,e,n,Object.create(null),o)}const c=this.dynamicTries[i];if(c){const i=c.match(l(r));if(i)return this.v(i.handler,i.options,t,e,n,i.params,o)}return new Response("Not Found",{status:404})}async v(t,e,n,o,r,i,s){const c=new T(n,o,r,i,s),l=this.security.extraHeaders;if(l)for(const t in l)Object.prototype.hasOwnProperty.call(l,t)&&c.headers.set(t,l[t]);let a,u=!1;try{u=await this.A(c,e.validate)}catch(t){this.p(c,"validation_error",t&&t.message),u=!1}if(!u)return c.text("Validation failed",400);if(e.cache&&"GET"===n.method){const t=await this.O(n);if(t)return this.m(c,e.cors),this.C(c,e.log),t}this.m(c,e.cors);try{const e=await t(c);a=e instanceof Response?e:e&&e.__isJSX?c.html(e):c.text("OK"),c.status=a.status}catch(t){this.p(c,"handler_error",t&&t.message),a=c.text("Internal Server Error",500),c.status=500}return e.cache&&"GET"===n.method&&200===a.status&&c.executionCtx.waitUntil(this.S(n,a.clone(),e.cache)),e.compress&&(a=this.T(n,a)),this.C(c,e.log),a}};
|