@lengkapp/edge 0.0.40 → 0.0.41
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/README.md +171 -202
- package/dist/README.md +171 -202
- package/dist/edge-client.d.ts +1 -0
- package/dist/edge-client.js +33 -0
- package/dist/edge-server.d.ts +235 -0
- package/dist/edge-server.js +33 -0
- package/package.json +12 -14
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @lengkapp/edge v0.0.41
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* LengkApp Edge License
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) LengkApp — Yasir Haris
|
|
8
|
+
* Contact: yh@lengk.app / yasir.haris@gmail.com
|
|
9
|
+
*
|
|
10
|
+
* Permission is granted to any person obtaining a copy of this software
|
|
11
|
+
* and associated documentation files (the "Software") to use, copy, and
|
|
12
|
+
* distribute the Software free of charge, for any purpose, including
|
|
13
|
+
* commercial use, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* 1. The Software may not be modified, adapted, or altered in any way
|
|
16
|
+
* without prior written permission from the copyright holder.
|
|
17
|
+
*
|
|
18
|
+
* 2. Redistribution of the Software, in whole or in part, must retain
|
|
19
|
+
* this LICENSE file unmodified and include the copyright notice above.
|
|
20
|
+
*
|
|
21
|
+
* 3. This permission notice does not grant any right to use the
|
|
22
|
+
* LengkApp name, brand, or trademarks without separate written
|
|
23
|
+
* permission.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
26
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
27
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
28
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT HOLDER BE
|
|
29
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
30
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
31
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
32
|
+
*/
|
|
33
|
+
!function(){"use strict";var r=document,e=window,t=null;function n(r){return!!r.hasAttribute("_id")&&(r.hasAttribute("_get")||r.hasAttribute("_post")||r.hasAttribute("_go")||r.hasAttribute("_open"))}function a(){return t||(t=function(){var t=[navigator.userAgent,navigator.language,screen.width,screen.height,screen.colorDepth,(new Date).getTimezoneOffset(),navigator.hardwareConcurrency||"?",navigator.deviceMemory||"?"].join("|"),n=r.createElement("canvas"),a="",i=n.getContext&&n.getContext("2d");if(i){i.textBaseline="top",i.font="14px Arial",i.fillStyle="#f60",i.fillRect(125,1,62,20),i.fillStyle="#069",i.fillText("FP",2,15),i.fillStyle="rgba(102,204,0,0.7)",i.fillText("FP",4,17);try{a=n.toDataURL()}catch(r){a=""}}var o="";try{var s=n.getContext("webgl")||n.getContext("experimental-webgl");if(s){var f=s.getExtension("WEBGL_debug_renderer_info");o=f?s.getParameter(f.UNMASKED_VENDOR_WEBGL)+"~"+s.getParameter(f.UNMASKED_RENDERER_WEBGL):s.getParameter(s.VERSION)+"~"+s.getParameter(s.RENDERER)}}catch(r){o=""}var u=["Arial","Courier New","Times New Roman","Helvetica","Georgia","Verdana","Comic Sans MS","Trebuchet MS","Impact","Lucida Console"],c="",l=r.body||r.documentElement;if(l){for(var v=[],d=0;d<u.length;d++){var p=r.createElement("span");p.style.cssText='position:absolute;left:-9999px;visibility:hidden;font:72px "'+u[d]+'",monospace',p.textContent="mmmmmmmmmmlli",l.appendChild(p),v.push(p.offsetWidth),l.removeChild(p)}c=v.join(",")}return function(){var r=e.OfflineAudioContext||e.webkitOfflineAudioContext;if(!r)return Promise.resolve("");try{var t=new r(1,44100,44100),n=t.createOscillator();n.type="triangle",n.frequency.value=1e4;var a=t.createDynamicsCompressor();return a.threshold.value=-50,a.knee.value=40,a.ratio.value=12,a.attack.value=0,a.release.value=.25,n.connect(a),a.connect(t.destination),n.start(0),t.startRendering().then(function(r){for(var e=r.getChannelData(0),t=0,n=4500;n<5e3;n++)t+=Math.abs(e[n]);return t.toString()}).catch(function(){return""})}catch(r){return Promise.resolve("")}}().then(function(r){return function(r){if(!e.crypto||!e.crypto.subtle||!e.TextEncoder){for(var t=5381,n=0;n<r.length;n++)t=(t<<5)+t^r.charCodeAt(n);return Promise.resolve((t>>>0).toString(16))}var a=(new TextEncoder).encode(r);return e.crypto.subtle.digest("SHA-256",a).then(function(r){for(var e=new Uint8Array(r),t="",n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,"0");return t})}([t,a,o,c,r].join("||"))})}().catch(function(){return""})),t}var i="ax-app-style",o=["@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);","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{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);","border:none;","background:inherit;","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(!r.getElementById(i)){var e=r.createElement("style");e.id=i,e.appendChild(r.createTextNode(o)),(r.head||r.documentElement).appendChild(e)}}();var s,f=new Set,u=new WeakSet,c=new WeakMap,l=new WeakMap,v="[_get],[_post],[_go],[_open]",d=["_in","_out","_before","_after"];function p(e){return new URL(e,r.baseURI).href}function m(r){return new Promise(function(e){var t=new FileReader;t.onload=function(){e({name:r.name,type:r.type||"application/octet-stream",size:r.size,data:t.result})},t.onerror=function(){e({name:r.name,type:r.type,size:r.size,data:null})},t.readAsDataURL(r)})}function g(r){if(r.disabled)return Promise.resolve(void 0);var e=r.type;if("file"===e){var t=r.files;return t&&t.length?r.multiple?Promise.all(Array.prototype.map.call(t,m)):m(t[0]):Promise.resolve(r.multiple?[]:null)}return"checkbox"===e?Promise.resolve(r.checked?r.value||"on":null):"radio"===e?Promise.resolve(r.checked?r.value:null):"SELECT"===r.tagName&&r.multiple?Promise.resolve(Array.prototype.map.call(r.selectedOptions,function(r){return r.value})):Promise.resolve(r.value)}function x(e){var t,n=null,a=null;for(t=0;t<d.length;t++)if(e.hasAttribute(d[t])){n=d[t],a=e.getAttribute(d[t]);break}if(!n)return null;var i=e;if(a&&"this"!==a)try{i=r.querySelector(a)}catch(r){return null}return i&&i.parentNode?{mode:n,el:i,parent:i.parentNode}:null}function h(r,e){"_before"===r.mode||"_out"===r.mode?r.parent.insertBefore(e,r.el):r.parent.insertBefore(e,r.el.nextSibling)}function b(r){var e=l.get(r);e&&(e.node&&e.node.parentNode&&e.node.parentNode.removeChild(e.node),e.target&&e.target.removeAttribute("aria-busy"),l.delete(r))}function w(r,e){var t=r.querySelector(".ax-state-btn");t&&t.addEventListener("click",function(r){r.preventDefault(),r.stopPropagation(),P(e)})}function k(e){var t=r.createElement("div");return t.className="ax-state ax-state--error",t.setAttribute("role","alert"),t.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(e).replace(/[&<>"']/g,function(r){return{"&":"&","<":"<",">":">",'"':""","'":"'"}[r]})+"</span>",t}function _(e){if("function"==typeof r.startViewTransition)try{return void r.startViewTransition(e)}catch(r){}e()}function y(r,t){if(r.hasAttribute("_go"))e.location.assign(t);else{var n=e.open(t,"_blank","noopener,noreferrer");n&&(n.opener=null)}}function P(e){if(function(r){return r.hasAttribute("_go")||r.hasAttribute("_open")}(e))!function(r){var e=function(r){var e=r.hasAttribute("_go")?r.getAttribute("_go"):r.getAttribute("_open");if(!(e=(e||"").trim())||"this"===e){var t=r.getAttribute("href");t&&(e=t)}return e?p(e):""}(r);e&&(n(r)?a().then(function(t){y(r,function(r,e){return e?r+(r.indexOf("?")>=0?"&":"?")+"_did="+encodeURIComponent(e):r}(e,t))}):y(r,e))}(e);else{var t=e.hasAttribute("_get"),i=e.getAttribute(t?"_get":"_post");if(null!==i&&x(e)){var o=c.get(e),s=new AbortController;c.set(e,s),o&&o.abort(),b(e);var u=0,d=setTimeout(function(){c.get(e)===s&&(function(e){var t=x(e);if(!t)return null;var n=(e.getAttribute("_loader")||"spinner").toLowerCase();if("none"===n||"off"===n||"false"===n)return null;t.el.classList.add("ax-hide"),t.el.setAttribute("aria-busy","true");var a=function(e){var t="skeleton"===e,n=r.createElement("div");return n.className="ax-state ax-state--"+(t?"skeleton":"loading"),n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.setAttribute("aria-busy","true"),n.innerHTML=t?'<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>',n}(n);h(t,a),l.set(e,{node:a,target:t.el})}(e),u=performance.now())},100),m=parseInt(e.getAttribute("_timeout"),10);m>0||(m=2e4);var P=r.querySelector('meta[name="_csrf"]'),T=P?P.content:void 0,S={method:t?"GET":"POST",credentials:"same-origin",headers:T?{"x-csrf-token":T}:void 0,redirect:"follow",referrerPolicy:"same-origin",signal:s.signal},M=setTimeout(function(){s.abort()},m),j=Promise.resolve();if(!t)if(e.hasAttribute("_json"))j=function(e){var t=(e.getAttribute("_json")||"").trim();if(!t)return Promise.resolve(null);var n=t.split(",").map(function(r){return r.trim()}).filter(Boolean);if(!n.length)return Promise.resolve(null);var a=e.closest("form")||r;return Promise.all(n.map(function(e){return function(e,t){var n=r.getElementById(t);if(n&&e.contains(n))return g(n);var a=function(r,e){for(var t=r.querySelectorAll("input[name],select[name],textarea[name]"),n=[],a=0;a<t.length;a++)t[a].name===e&&n.push(t[a]);return n}(e,t);if(!a.length)return Promise.resolve(void 0);if(1===a.length)return g(a[0]);var i=a[0];if("radio"===i.type){for(var o=0;o<a.length;o++)if(a[o].checked)return Promise.resolve(a[o].value);return Promise.resolve(null)}if("checkbox"===i.type){for(var s=[],f=0;f<a.length;f++)a[f].checked&&!a[f].disabled&&s.push(a[f].value||"on");return Promise.resolve(s)}return g(i)}(a,e).then(function(r){return[e,r]})})).then(function(r){for(var e={},t=0;t<r.length;t++)void 0!==r[t][1]&&(e[r[t][0]]=r[t][1]);return JSON.stringify(e)})}(e).then(function(r){null!==r&&(S.headers["Content-Type"]="application/json",S.body=r)});else if(e.hasAttribute("_form")){var O=function(e){var t,n=e.getAttribute("_form");try{t=r.querySelector(n)||r.getElementById(n)}catch(r){t=null}return t?new FormData(t):null}(e);O&&(S.body=O)}n(e)&&(j=Promise.all([j,a()]).then(function(r){var e=r[1];e&&(S.headers["X-DeviceId"]=e)})),j.then(function(){return fetch(i,S)}).then(function(r){if(clearTimeout(M),!r.ok){var t=new Error("HTTP "+r.status);if(t.status=r.status,e.hasAttribute("_toast"))return r.text().then(function(r){throw t.toast=r,t});throw t}return r.text()}).then(function(t){clearTimeout(d),A(function(){var n=function(){b(e),t&&function(e,t){var n=x(e);if(n){var a=r.createElement("template");a.innerHTML=t;var i,o,s=a.content,u=[],c=[],l=[];for(o=s.querySelectorAll("script"),i=0;i<o.length;i++)u.push(o[i]),o[i].parentNode.removeChild(o[i]);for(o=s.querySelectorAll(v),i=0;i<o.length;i++)c.push(o[i]);for(o=s.querySelectorAll("[_translate]"),i=0;i<o.length;i++)l.push(o[i]);var d=n.el,m=n.parent;if("_in"===n.mode){for(;d.firstChild;)d.removeChild(d.firstChild);d.appendChild(s),d.classList.remove("ax-hide")}else"_out"===n.mode?m.replaceChild(s,d):"_before"===n.mode?(m.insertBefore(s,d),d.classList.remove("ax-hide")):(m.insertBefore(s,d.nextSibling),d.classList.remove("ax-hide"));for(i=0;i<c.length;i++)D(c[i]);for(i=0;i<l.length;i++)W(l[i]);W(d),function(e){for(var t=0;t<e.length;t++){var n=e[t],a=n.getAttribute("src");if(a){if(a=p(a),f.has(a))continue;f.add(a)}for(var i=r.createElement("script"),o=0;o<n.attributes.length;o++)i.setAttribute(n.attributes[o].name,n.attributes[o].value);a||(i.text=n.text),i.async=!1,r.head.appendChild(i)}}(u)}}(e,t)};l.get(e)?_(n):n()})}).catch(function(t){if(clearTimeout(M),clearTimeout(d),c.get(e)===s){if(t&&void 0!==t.toast){var n=function(e){var t=(e.getAttribute("_toast")||"").trim();if(!t)return null;if("this"===t)return e;try{return r.querySelector(t)}catch(r){return null}}(e);if(n)return void A(function(){b(e),n.innerHTML=t.toast})}var a;a=t&&"AbortError"===t.name?"Request timed out":t&&t.message?t.message:"Request failed",t&&"AbortError"!==t.name&&console.error("[app]",t),A(function(){!function(r,e){var t=l.get(r),n=function(){if(t&&t.node&&t.node.parentNode){var n=t.node,a=k(e);n.parentNode.replaceChild(a,n),t.target&&t.target.removeAttribute("aria-busy"),l.set(r,{node:a,target:t.target}),w(a,r)}else{var i=x(r);if(!i)return;i.el.classList.add("ax-hide"),i.el.setAttribute("aria-busy","true");var o=k(e);h(i,o),l.set(r,{node:o,target:i.el}),w(o,r)}};t?_(n):n()}(e,a)})}})}}function A(r){if(0!==u){var t=Math.max(0,240-(performance.now()-u));0===t?c.get(e)===s&&r():setTimeout(function(){c.get(e)===s&&r()},t)}else c.get(e)===s&&r()}}var T=Object.create(null),S=Object.create(null),M=new WeakMap,j=new WeakMap,O=new WeakMap,A=new Set,C=0,L=["title","placeholder","aria-label","alt"];function R(){var e=r.documentElement&&r.documentElement.getAttribute("lang");return e&&e.trim()||"en"}function E(r){for(var e in r)return!0;return!1}function I(r,e){for(var t=r.parentNode;t&&t!==e;){if(1===t.nodeType&&t.hasAttribute&&t.hasAttribute("_translate"))return!0;t=t.parentNode}return!1}function N(e){if(e&&e.isConnected){var t=e.getAttribute("_translate");if(t){var n=R();(function(r,e){if("en"===e)return Promise.resolve({});var t=e+"-"+r;if(void 0!==T[t])return Promise.resolve(T[t]);if(S[t])return S[t];var n="tr:"+e+"-"+r;try{var a=localStorage.getItem(n);if(null!==a){var i=JSON.parse(a);if(i&&"object"==typeof i&&E(i))return T[t]=i,Promise.resolve(i)}}catch(r){}var o=fetch("/t/"+encodeURIComponent(e)+"/"+encodeURIComponent(r)+".json",{credentials:"same-origin",headers:{Accept:"application/json"}}).then(function(r){if(404===r.status||410===r.status)return{};if(!r.ok)throw new Error("HTTP "+r.status);return r.json()}).then(function(r){if(r&&"object"==typeof r||(r={}),T[t]=r,E(r))try{localStorage.setItem(n,JSON.stringify(r))}catch(r){}else try{localStorage.removeItem(n)}catch(r){}return delete S[t],r}).catch(function(){return delete S[t],{}});return S[t]=o,o})(t,n).then(function(t){e.isConnected&&R()===n&&("en"===n||t&&E(t))&&function(e,t){for(var n,a=r.createTreeWalker(e,4,null,!1);n=a.nextNode();){var i=n.parentNode;if(i){var o=i.nodeName;if("SCRIPT"!==o&&"STYLE"!==o&&"NOSCRIPT"!==o&&!I(n,e)){M.has(n)||M.set(n,n.nodeValue);var s=M.get(n),f=String(s||"").trim();if(f){var u=t[f],c="string"==typeof u?u:f,l=(s.match(/^\s*/)||[""])[0]+c+(s.match(/\s*$/)||[""])[0];n.nodeValue!==l&&(O.set(n,l),n.nodeValue=l)}}}}for(var v=[e],d=e.querySelectorAll?e.querySelectorAll("*"):[],p=0;p<d.length;p++)v.push(d[p]);for(var m=0;m<v.length;m++){var g=v[m];if(1===g.nodeType&&(g===e||!I(g,e))){var x=j.get(g);x||(x=Object.create(null),j.set(g,x));for(var h=0;h<L.length;h++){var b=L[h];if(g.hasAttribute(b)){b in x||(x[b]=g.getAttribute(b));var w=x[b],k=String(w||"").trim();if(k){var _=t[k],y="string"==typeof _?_:k;g.getAttribute(b)!==y&&g.setAttribute(b,y)}}}}}}(e,t||{})})}}}function U(r){if(r&&r.isConnected&&"en"!==R()&&(A.add(r),!C)){var t=e.requestAnimationFrame||function(r){return setTimeout(r,16)};C=t(function(){C=0;var r=[];A.forEach(function(e){r.push(e)}),A.clear();for(var e=0;e<r.length;e++)N(r[e])})}}function W(r){if(r&&1===r.nodeType){r.hasAttribute&&r.hasAttribute("_translate")&&U(r);for(var e=r.querySelectorAll?r.querySelectorAll("[_translate]"):[],t=0;t<e.length;t++)U(e[t])}}function z(){for(var e=r.querySelectorAll("[_translate]"),t=0;t<e.length;t++)N(e[t])}function B(r){var e=r.getAttribute("_trigger");"load"===e||"visible"===e?P(r):r.addEventListener(e,function(e){if("click"===e.type){var t=r.tagName;"BUTTON"!==t&&"A"!==t||e.preventDefault()}P(r)})}function D(r){u.has(r)||(u.add(r),"click"!==(r.getAttribute("_trigger")||"click")&&("IntersectionObserver"in e?(s||(s=new IntersectionObserver(function(r){for(var e=0;e<r.length;e++)r[e].isIntersecting&&(s.unobserve(r[e].target),B(r[e].target))},{rootMargin:"300px"})),s.observe(r)):B(r)))}function F(r){for(var e=r.querySelectorAll(v),t=0;t<e.length;t++)D(e[t])}e.MutationObserver&&new MutationObserver(function(e){for(var t=0;t<e.length;t++){var n=e[t];if("attributes"!==n.type){if("characterData"!==n.type||O.get(n.target)!==n.target.nodeValue){var a=n.target;if(a&&3===a.nodeType&&(a=a.parentNode),a&&a.closest){var i=a.closest("[_translate]");i&&U(i)}if("childList"===n.type&&n.addedNodes)for(var o=0;o<n.addedNodes.length;o++){var s=n.addedNodes[o];s&&1===s.nodeType&&W(s)}}}else if("lang"===n.attributeName&&n.target===r.documentElement)return void z()}}).observe(r.documentElement,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["lang"]}),r.addEventListener("click",function(r){if(!r.target.closest(".ax-state")){var e=r.target.closest(v);if(e&&"click"===(e.getAttribute("_trigger")||"click")&&!(e.hasAttribute("_go")&&"A"===e.tagName&&e.getAttribute("href")&&(0!==r.button||r.metaKey||r.ctrlKey||r.shiftKey||r.altKey))){var t=e.tagName;"BUTTON"!==t&&"A"!==t||r.preventDefault(),P(e)}}},!0),function(){for(var e=r.querySelectorAll("script[src]"),t=0;t<e.length;t++)f.add(p(e[t].src));r.querySelector("[_id]")&&a(),"loading"===r.readyState?r.addEventListener("DOMContentLoaded",function(){F(r),W(r.documentElement)}):(F(r),W(r.documentElement))}()}();
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @lengkapp/edge v0.0.41
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* LengkApp Edge License
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) LengkApp — Yasir Haris
|
|
8
|
+
* Contact: yh@lengk.app / yasir.haris@gmail.com
|
|
9
|
+
*
|
|
10
|
+
* Permission is granted to any person obtaining a copy of this software
|
|
11
|
+
* and associated documentation files (the "Software") to use, copy, and
|
|
12
|
+
* distribute the Software free of charge, for any purpose, including
|
|
13
|
+
* commercial use, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* 1. The Software may not be modified, adapted, or altered in any way
|
|
16
|
+
* without prior written permission from the copyright holder.
|
|
17
|
+
*
|
|
18
|
+
* 2. Redistribution of the Software, in whole or in part, must retain
|
|
19
|
+
* this LICENSE file unmodified and include the copyright notice above.
|
|
20
|
+
*
|
|
21
|
+
* 3. This permission notice does not grant any right to use the
|
|
22
|
+
* LengkApp name, brand, or trademarks without separate written
|
|
23
|
+
* permission.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
26
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
27
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
28
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT HOLDER BE
|
|
29
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
30
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
31
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
32
|
+
*/
|
|
33
|
+
// edge-server.d.ts
|
|
34
|
+
|
|
35
|
+
/* ------------------------------------------------------------------ *
|
|
36
|
+
* JSX runtime *
|
|
37
|
+
* ------------------------------------------------------------------ */
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Runtime value is `Symbol('Fragment')`. The function signature is a
|
|
41
|
+
* type-level shim so `<></>` works with the automatic JSX runtime.
|
|
42
|
+
* Never called directly — `jsx(Fragment, …)` passes it through and
|
|
43
|
+
* `renderToString` compares by identity.
|
|
44
|
+
*/
|
|
45
|
+
export const Fragment: (props: { children?: any }) => JSXNode;
|
|
46
|
+
|
|
47
|
+
export interface JSXNode {
|
|
48
|
+
type: string | symbol | ((props: any) => any);
|
|
49
|
+
props: Record<string, any>;
|
|
50
|
+
children: any[];
|
|
51
|
+
__isJSX: true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function jsx(
|
|
55
|
+
type: JSXNode['type'],
|
|
56
|
+
props: Record<string, any> | null,
|
|
57
|
+
...children: any[]
|
|
58
|
+
): JSXNode;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Renders a JSX tree to an HTML string. Async because components may be
|
|
62
|
+
* `async`. Accepts `null`/boolean children, Promises, and arrays.
|
|
63
|
+
*
|
|
64
|
+
* The optional `ctx` is normally supplied by `Context.html`/`Context.page`;
|
|
65
|
+
* user code never needs to pass it.
|
|
66
|
+
*/
|
|
67
|
+
export function renderToString(node: any, ctx?: Context): Promise<string>;
|
|
68
|
+
|
|
69
|
+
/* ------------------------------------------------------------------ *
|
|
70
|
+
* Ambient context *
|
|
71
|
+
* ------------------------------------------------------------------ */
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Returns the Context of the request whose render is currently executing.
|
|
75
|
+
*
|
|
76
|
+
* MUST be called synchronously at the top of a component — before any
|
|
77
|
+
* `await`. After an `await`, use the captured local reference; the
|
|
78
|
+
* ambient slot is no longer guaranteed to belong to your request.
|
|
79
|
+
*
|
|
80
|
+
* Throws if called outside an active render (module top-level, scheduled
|
|
81
|
+
* handler, `waitUntil` callback, or after an `await`).
|
|
82
|
+
*/
|
|
83
|
+
export function useCtx(): Context;
|
|
84
|
+
|
|
85
|
+
/* ------------------------------------------------------------------ *
|
|
86
|
+
* Context *
|
|
87
|
+
* ------------------------------------------------------------------ */
|
|
88
|
+
|
|
89
|
+
export interface CookieOptions {
|
|
90
|
+
path?: string;
|
|
91
|
+
domain?: string;
|
|
92
|
+
maxAge?: number;
|
|
93
|
+
expires?: Date;
|
|
94
|
+
secure?: boolean;
|
|
95
|
+
httpOnly?: boolean;
|
|
96
|
+
sameSite?: 'Strict' | 'Lax' | 'None' | string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface CorsOptions {
|
|
100
|
+
origin?: string | string[];
|
|
101
|
+
methods?: string;
|
|
102
|
+
headers?: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface CacheOptions {
|
|
106
|
+
/** TTL in seconds. Default: 3600 */
|
|
107
|
+
ttl?: number;
|
|
108
|
+
/** stale-while-revalidate in seconds. Default: 0 */
|
|
109
|
+
staleWhileRevalidate?: number;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface RouteOptions {
|
|
113
|
+
cors?: boolean | CorsOptions;
|
|
114
|
+
cache?: boolean | CacheOptions;
|
|
115
|
+
compress?: boolean;
|
|
116
|
+
log?: boolean;
|
|
117
|
+
validate?: (ctx: Context) => boolean | Promise<boolean>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export class Context {
|
|
121
|
+
constructor(
|
|
122
|
+
request: Request,
|
|
123
|
+
env: Record<string, any>,
|
|
124
|
+
executionCtx: ExecutionContext,
|
|
125
|
+
params?: Record<string, string>,
|
|
126
|
+
parsedUrl?: URL | null
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
req: Request;
|
|
130
|
+
env: Record<string, any>;
|
|
131
|
+
executionCtx: ExecutionContext;
|
|
132
|
+
params: Record<string, string>;
|
|
133
|
+
status: number;
|
|
134
|
+
headers: Headers;
|
|
135
|
+
url: URL;
|
|
136
|
+
|
|
137
|
+
getCookie(name: string): string | null;
|
|
138
|
+
readonly query: URLSearchParams;
|
|
139
|
+
setCookie(name: string, value: string, options?: CookieOptions): void;
|
|
140
|
+
deleteCookie(name: string, options?: CookieOptions): void;
|
|
141
|
+
|
|
142
|
+
text(data: string, status?: number, headers?: Record<string, string>): Response;
|
|
143
|
+
json(data: any, status?: number, headers?: Record<string, string>): Response;
|
|
144
|
+
|
|
145
|
+
/** Async — JSX trees may contain async components. */
|
|
146
|
+
html(
|
|
147
|
+
data: string | JSXNode | JSXNode[] | null | undefined,
|
|
148
|
+
status?: number,
|
|
149
|
+
headers?: Record<string, string>
|
|
150
|
+
): Promise<Response>;
|
|
151
|
+
|
|
152
|
+
/** Async — JSX trees may contain async components. */
|
|
153
|
+
page(
|
|
154
|
+
data: string | JSXNode | JSXNode[] | null | undefined,
|
|
155
|
+
status?: number,
|
|
156
|
+
headers?: Record<string, string>
|
|
157
|
+
): Promise<Response>;
|
|
158
|
+
|
|
159
|
+
redirect(location: string, status?: number): Response;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* ------------------------------------------------------------------ *
|
|
163
|
+
* Edge router *
|
|
164
|
+
* ------------------------------------------------------------------ */
|
|
165
|
+
|
|
166
|
+
export type RouteHandler = (ctx: Context) => any | Promise<any>;
|
|
167
|
+
|
|
168
|
+
export type ScheduledHandler = (
|
|
169
|
+
event: ScheduledEvent,
|
|
170
|
+
env: Record<string, any>,
|
|
171
|
+
ctx: ExecutionContext
|
|
172
|
+
) => void | Promise<void>;
|
|
173
|
+
|
|
174
|
+
export interface SecurityOptions {
|
|
175
|
+
logSecurityEvents?: boolean;
|
|
176
|
+
extraHeaders?: Record<string, string> | null;
|
|
177
|
+
trustedProxies?: string[] | null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface EdgeDefaults {
|
|
181
|
+
cors: CorsOptions & { methods: string };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export class Edge {
|
|
185
|
+
constructor();
|
|
186
|
+
|
|
187
|
+
readonly staticRoutes: Map<string, Map<string, { handler: RouteHandler; options: RouteOptions }>>;
|
|
188
|
+
readonly dynamicTries: Record<string, any>;
|
|
189
|
+
defaults: EdgeDefaults;
|
|
190
|
+
scheduledHandler: ScheduledHandler | null;
|
|
191
|
+
security: SecurityOptions;
|
|
192
|
+
|
|
193
|
+
get(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
194
|
+
get(path: string, handler: RouteHandler): void;
|
|
195
|
+
post(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
196
|
+
post(path: string, handler: RouteHandler): void;
|
|
197
|
+
put(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
198
|
+
put(path: string, handler: RouteHandler): void;
|
|
199
|
+
delete(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
200
|
+
delete(path: string, handler: RouteHandler): void;
|
|
201
|
+
patch(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
202
|
+
patch(path: string, handler: RouteHandler): void;
|
|
203
|
+
options(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
204
|
+
options(path: string, handler: RouteHandler): void;
|
|
205
|
+
head(path: string, options: RouteOptions | boolean, handler: RouteHandler): void;
|
|
206
|
+
head(path: string, handler: RouteHandler): void;
|
|
207
|
+
|
|
208
|
+
scheduled(handler: ScheduledHandler): void;
|
|
209
|
+
|
|
210
|
+
fetch(
|
|
211
|
+
request: Request,
|
|
212
|
+
env: Record<string, any>,
|
|
213
|
+
executionCtx: ExecutionContext
|
|
214
|
+
): Promise<Response>;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* ---------------- JSX typing for this runtime ---------------- */
|
|
218
|
+
type ComponentReturn =
|
|
219
|
+
| JSXNode
|
|
220
|
+
| string
|
|
221
|
+
| number
|
|
222
|
+
| boolean
|
|
223
|
+
| null
|
|
224
|
+
| undefined
|
|
225
|
+
| ComponentReturn[]
|
|
226
|
+
| Promise<ComponentReturn>;
|
|
227
|
+
|
|
228
|
+
declare global {
|
|
229
|
+
namespace JSX {
|
|
230
|
+
type Element = any;
|
|
231
|
+
type ElementType = string | symbol | ((props: any) => ComponentReturn);
|
|
232
|
+
interface IntrinsicElements { [elemName: string]: any; }
|
|
233
|
+
interface ElementChildrenAttribute { children: {}; }
|
|
234
|
+
}
|
|
235
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* @lengkapp/edge v0.0.41
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* LengkApp Edge License
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) LengkApp — Yasir Haris
|
|
8
|
+
* Contact: yh@lengk.app / yasir.haris@gmail.com
|
|
9
|
+
*
|
|
10
|
+
* Permission is granted to any person obtaining a copy of this software
|
|
11
|
+
* and associated documentation files (the "Software") to use, copy, and
|
|
12
|
+
* distribute the Software free of charge, for any purpose, including
|
|
13
|
+
* commercial use, subject to the following conditions:
|
|
14
|
+
*
|
|
15
|
+
* 1. The Software may not be modified, adapted, or altered in any way
|
|
16
|
+
* without prior written permission from the copyright holder.
|
|
17
|
+
*
|
|
18
|
+
* 2. Redistribution of the Software, in whole or in part, must retain
|
|
19
|
+
* this LICENSE file unmodified and include the copyright notice above.
|
|
20
|
+
*
|
|
21
|
+
* 3. This permission notice does not grant any right to use the
|
|
22
|
+
* LengkApp name, brand, or trademarks without separate written
|
|
23
|
+
* permission.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
26
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
27
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
28
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT HOLDER BE
|
|
29
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
30
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
31
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
32
|
+
*/
|
|
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 a of n(i))o.call(r,a)||a===s||t(r,a,{get:()=>i[a],enumerable:!(c=e(i,a))||c.enumerable});return r},s=e=>i(t({},"__esModule",{value:!0}),e),c={};function a(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 l(t){const e=t.length;return e>1&&47===t.charCodeAt(e-1)?t.slice(0,-1):t}r(c,{Context:()=>P,Edge:()=>Edge,Fragment:()=>Fragment,jsx:()=>jsx,renderToString:()=>renderToString,useCtx:()=>useCtx}),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}function p(t){return t>=65&&t<=90||t>=97&&t<=122}function d(t){return t>=48&&t<=57}function y(t){const e=t.length;if(0===e||!p(t.charCodeAt(0)))return!1;for(let n=1;n<e;n++){const e=t.charCodeAt(n);if(!p(e)&&!d(e)&&45!==e)return!1}return!0}function g(t){const e=t.length;if(0===e)return!1;const n=t.charCodeAt(0);if(!p(n)&&95!==n&&58!==n)return!1;for(let n=1;n<e;n++){const e=t.charCodeAt(n);if(!p(e)&&!d(e)&&95!==e&&58!==e&&46!==e&&45!==e)return!1}return!0}function w(t){const e=t.charCodeAt(0),n=t.charCodeAt(1);return!(111!==e&&79!==e||110!==n&&78!==n)}var Fragment=Symbol("Fragment");function jsx(t,e,...n){return{type:t,props:e||{},children:n,__isJSX:!0}}var m=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),C=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"]),b=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"]),T=new Map,O=2e3;function x(t){const e=T.get(t);if(void 0!==e)return e;const n=t.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,"");return T.size>=O&&T.clear(),T.set(t,n),n}function S(t){if(!t||"object"!=typeof t)return"";let e="";for(const n in t){if(!Object.prototype.hasOwnProperty.call(t,n))continue;const o=x(n);let r=t[n];"number"!=typeof r||b.has(o)||(r+="px"),e&&(e+=";"),e+=o+":"+r}return e}var A=new Set(["href","src","xlink:href","action","formaction"]),v=[];function useCtx(){const t=v[v.length-1];if(!t)throw new Error("useCtx() must be called synchronously at the top of a component (before any await). It is not available after an await, nor outside a render.");return t}async function renderToString(t,e){if(void 0===e&&(e=v[v.length-1]),null==t||"boolean"==typeof t)return"";const n=typeof t;if("string"===n)return h(t);if("number"===n)return h(String(t));if("object"===n&&"function"==typeof t.then)return renderToString(await t,e);if(Array.isArray(t)){let n="";for(let o=0;o<t.length;o++)n+=await renderToString(t[o],e);return n}if(!t.__isJSX)return h(String(t));const{type:o,props:r,children:i}=t;if(o===Fragment){let t="";for(let n=0;n<i.length;n++)t+=await renderToString(i[n],e);return t}if("symbol"==typeof o)return"";if("function"==typeof o){let t;if(e){v.push(e);try{t=o({...r,children:i})}finally{v.pop()}}else t=o({...r,children:i});return renderToString(await t,e)}if("string"!=typeof o||!y(o))return"";const s=m.has(o);let c="";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)&&!w(n)&&g(n)){if(A.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(C.has(n))!0===e&&(c+=" "+n);else if(!0!==e){if("style"===n&&"object"==typeof e){const t=S(e);t&&(c+=' style="'+h(t)+'"');continue}c+=" "+n+'="'+h(String(e))+'"'}else c+=" "+n+'="true"'}}let a="";const l=r.dangerouslySetInnerHTML;if(l&&null!=l.__html)a=l.__html;else for(let t=0;t<i.length;t++)a+=await renderToString(i[t],e);return s?"<"+o+c+"/>":"<"+o+c+">"+a+"</"+o+">"}var E=Object.freeze([["X-Content-Type-Options","nosniff"],["X-Frame-Options","DENY"],["Referrer-Policy","strict-origin-when-cross-origin"],["Permissions-Policy","geolocation=(), microphone=(), camera=()"]]),j=Object.freeze(Object.create(null)),P=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(E),this.t=null,this.url=r||new URL(t.url)}o(){if(null!==this.t)return this.t;const t=this.req.headers.get("Cookie");if(!t)return this.t=j,j;const e=Object.create(null);let n=0;const o=t.length;for(;n<o;){let r=t.indexOf(";",n);-1===r&&(r=o);let i=n,s=r;for(;i<s&&32===t.charCodeAt(i);)i++;for(;s>i&&32===t.charCodeAt(s-1);)s--;if(s>i){const n=t.indexOf("=",i);if(n>i&&n<s)try{const o=decodeURIComponent(t.slice(i,n));f(o)&&(e[o]=decodeURIComponent(t.slice(n+1,s)))}catch{}}n=r+1}return this.t=e,e}getCookie(t){const e=this.o()[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)})}i(t){if(!t)return this.headers;const e=Object.keys(t);if(0===e.length)return this.headers;const n=new Headers(this.headers);for(let o=0;o<e.length;o++)n.set(e[o],t[e[o]]);return n}text(t,e=this.status,n={}){const o=this.i(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.i(n);return o.has("Content-Type")||o.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(t),{status:e,headers:o})}async html(t,e=this.status,n={}){const o=this.i(n);let r;return o.has("Content-Type")||o.set("Content-Type","text/html; charset=utf-8"),r="string"==typeof t?t:t&&t.__isJSX||Array.isArray(t)?await renderToString(t,this):null==t?"":String(t),new Response(r,{status:e,headers:o})}async page(t,e=this.status,n={}){const o=this.i(n);let r;return o.has("Content-Type")||o.set("Content-Type","text/html; charset=utf-8"),r="string"==typeof t?t:t&&t.__isJSX||Array.isArray(t)?await renderToString(t,this):null==t?"":String(t),/^\s*<!doctype\s/i.test(r)||(r="<!DOCTYPE html>"+r),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})}},_=class{constructor(){this.children=null,this.paramChild=null,this.handler=null}},k=class{constructor(){this.root=new _}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 _),o=o.paramChild}else{o.children||(o.children=new Map);let t=o.children.get(n);t||(t=new _,o.children.set(n,t)),o=t}}o.handler={handler:e,options:n,paramNames:r}}match(t){const e=[],n=this.l(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}}l(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.l(t,e,n+1,o);if(r)return r}}const s=t.paramChild;if(s){o.push(r);const t=this.l(s,e,n+1,o);if(t)return t;o.pop()}return null}},H=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD"],R=["text/","application/json","application/xml","application/javascript","application/xhtml","application/ld+json","application/manifest+json","image/svg"];function D(t){if(!t)return!0;const e=t.toLowerCase();for(let t=0;t<R.length;t++)if(e.startsWith(R[t]))return!0;return!1}var I=new Map,L=0;function N(t,e,n){const o=t+"|"+(e||"")+"|"+(n||""),r=Date.now(),i=I.get(o);if(i&&r-i<6e4)return!1;if(I.set(o,r),r-L>3e4){L=r;for(const[t,e]of I)r-e>6e4&&I.delete(t)}return!0}var Edge=class{constructor(){this.staticRoutes=new Map;for(let t=0;t<H.length;t++)this.staticRoutes.set(H[t],new Map);this.dynamicTries={};for(let t=0;t<H.length;t++)this.dynamicTries[H[t]]=new k;this.defaults={cors:{origin:"*",methods:"GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD"}},this.scheduledHandler=null,this.security={logSecurityEvents:!0,extraHeaders:null,trustedProxies:null}}u(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(l(e),{handler:o,options:r}):this.dynamicTries[t].add(a(e),o,r)}get(t,e,n){this.u("GET",t,e,n)}post(t,e,n){this.u("POST",t,e,n)}put(t,e,n){this.u("PUT",t,e,n)}delete(t,e,n){this.u("DELETE",t,e,n)}patch(t,e,n){this.u("PATCH",t,e,n)}options(t,e,n){this.u("OPTIONS",t,e,n)}head(t,e,n){this.u("HEAD",t,e,n)}scheduled(t){this.scheduledHandler=t}h(t,e,n){if(this.security.logSecurityEvents)try{const o=t.req.headers.get("CF-Connecting-IP")||"",r=t.url?t.url.pathname:"";if(!N(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{}}p(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")}m(t,e){e&&console.log(t.req.method+" "+t.req.url+" - "+t.status)}C(t,e){if(!D(e.headers.get("Content-Type")))return e;const n=e.headers.get("Content-Length");if(null!==n&&+n<1024)return e;const o=t.headers.get("Accept-Encoding")||"";let r=null;if(-1!==o.indexOf("gzip")?r="gzip":-1!==o.indexOf("deflate")&&(r="deflate"),!r||!e.body)return e;const i=e.body.pipeThrough(new CompressionStream(r)),s=new Headers(e.headers);return s.set("Content-Encoding",r),s.set("Vary","Accept-Encoding"),s.delete("Content-Length"),new Response(i,{status:e.status,statusText:e.statusText,headers:s})}async T(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=new Headers(e.headers);s.set("Cache-Control","max-age="+r+(i>0?", stale-while-revalidate="+i:"")),s.delete("Set-Cookie"),await caches.default.put(t,new Response(e.body,{status:e.status,statusText:e.statusText,headers:s}))}async fetch(t,e,n){const o=new URL(t.url),r=l(o.pathname),i=t.method,s=this.staticRoutes.get(i);if(s){const i=s.get(r);if(i)return this.A(i.handler,i.options,t,e,n,Object.create(null),o)}const c=this.dynamicTries[i];if(c){const i=c.match(a(r));if(i)return this.A(i.handler,i.options,t,e,n,i.params,o)}return new Response("Not Found",{status:404})}async A(t,e,n,o,r,i,s){const c=new P(n,o,r,i,s),a=this.security.extraHeaders;if(a)for(const t in a)Object.prototype.hasOwnProperty.call(a,t)&&c.headers.set(t,a[t]);let l,u=!1;try{u=await this.T(c,e.validate)}catch(t){this.h(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.p(c,e.cors),this.m(c,e.log),t}this.p(c,e.cors);try{const e=await t(c);l=e instanceof Response?e:e&&e.__isJSX?await c.html(e):c.text("OK")}catch(t){this.h(c,"handler_error",t&&t.message),l=c.text("Internal Server Error",500)}return e.cache&&"GET"===n.method&&200===l.status&&c.executionCtx.waitUntil(this.S(n,l.clone(),e.cache)),e.compress&&(l=this.C(n,l)),this.m(c,e.log),l}};
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lengkapp/edge",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.41",
|
|
4
4
|
"description": "Edge framework used by Lengkapp",
|
|
5
|
-
"main": "dist/server.js",
|
|
6
|
-
"types": "dist/server.d.ts",
|
|
5
|
+
"main": "dist/edge-server.js",
|
|
6
|
+
"types": "dist/edge-server.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"types": "./dist/server.d.ts",
|
|
10
|
-
"node": "./dist/server.js",
|
|
11
|
-
"default": "./dist/server.js"
|
|
9
|
+
"types": "./dist/edge-server.d.ts",
|
|
10
|
+
"node": "./dist/edge-server.js",
|
|
11
|
+
"default": "./dist/edge-server.js"
|
|
12
12
|
},
|
|
13
13
|
"./client": {
|
|
14
|
-
"types": "./dist/client.d.ts",
|
|
15
|
-
"default": "./dist/client.js"
|
|
14
|
+
"types": "./dist/edge-client.d.ts",
|
|
15
|
+
"default": "./dist/edge-client.js"
|
|
16
16
|
},
|
|
17
17
|
"./server": {
|
|
18
|
-
"types": "./dist/server.d.ts",
|
|
19
|
-
"default": "./dist/server.js"
|
|
18
|
+
"types": "./dist/edge-server.d.ts",
|
|
19
|
+
"default": "./dist/edge-server.js"
|
|
20
20
|
},
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
@@ -24,8 +24,7 @@
|
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "node build.mjs"
|
|
28
|
-
"dev": "wrangler dev"
|
|
27
|
+
"build": "node build.mjs"
|
|
29
28
|
},
|
|
30
29
|
"publishConfig": {
|
|
31
30
|
"access": "public"
|
|
@@ -39,7 +38,6 @@
|
|
|
39
38
|
"license": "MIT",
|
|
40
39
|
"devDependencies": {
|
|
41
40
|
"esbuild": "^0.28.2",
|
|
42
|
-
"terser": "^5.51.2"
|
|
43
|
-
"wrangler": "^4.141.0"
|
|
41
|
+
"terser": "^5.51.2"
|
|
44
42
|
}
|
|
45
43
|
}
|