@lengkapp/edge 0.0.35 → 0.0.37
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 +319 -759
- package/dist/README.md +319 -759
- package/dist/client.d.ts +109 -0
- package/dist/client.js +29 -0
- package/dist/server.d.ts +121 -0
- package/dist/server.js +29 -0
- package/package.json +12 -10
- package/dist/edge-client.d.ts +0 -1
- package/dist/edge-client.js +0 -33
- package/dist/edge-server.d.ts +0 -235
- package/dist/edge-server.js +0 -33
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Edge runtime attributes — set any of these on an element to wire it up
|
|
5
|
+
* to a request. The runtime scans the document (and any nodes inserted
|
|
6
|
+
* later) for elements matching `[_get], [_post], [_go], [_open]` and binds
|
|
7
|
+
* a handler based on `_trigger`.
|
|
8
|
+
*
|
|
9
|
+
* Response HTML is inserted through a DocumentFragment, so any `<script>`
|
|
10
|
+
* tags in the response are re-created as fresh elements and executed in
|
|
11
|
+
* document order. Classic external scripts are awaited before the next
|
|
12
|
+
* script is injected, so ordering matches a normal page load. `async`
|
|
13
|
+
* scripts are left fire-and-forget, and `type="module"` scripts are
|
|
14
|
+
* awaited via their `load` event.
|
|
15
|
+
*
|
|
16
|
+
* Error handling:
|
|
17
|
+
* • If the response is non-2xx and the triggering element has a `_toast`
|
|
18
|
+
* attribute pointing at an existing element, the response body is
|
|
19
|
+
* injected into that element using `_in` semantics — script-aware, so
|
|
20
|
+
* any <script> in the error fragment also executes.
|
|
21
|
+
* • If `_toast` is absent or its selector does not resolve, the default
|
|
22
|
+
* inline `_edge-error` UI (with a Retry button) is shown in the
|
|
23
|
+
* `_in`/`_out`/`_before`/`_after` target as before.
|
|
24
|
+
*/
|
|
25
|
+
declare global {
|
|
26
|
+
interface Window {
|
|
27
|
+
/**
|
|
28
|
+
* Optional override for the `X-DeviceId` header value. Called each time
|
|
29
|
+
* a request opts in via `_id`. Return value is coerced to a string.
|
|
30
|
+
* When omitted, the runtime falls back to `new Date().toString()`.
|
|
31
|
+
*/
|
|
32
|
+
deviceId?: () => string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface HTMLElement {
|
|
36
|
+
/** GET request URL. Response is placed according to `_in`/`_out`/`_before`/`_after`. */
|
|
37
|
+
_get?: string;
|
|
38
|
+
/** POST request URL. Requires `_form` or `_json` to supply the request body. */
|
|
39
|
+
_post?: string;
|
|
40
|
+
/** Navigate the current tab to the URL. */
|
|
41
|
+
_go?: string;
|
|
42
|
+
/** Open the URL in a new tab (with `noopener`). */
|
|
43
|
+
_open?: string;
|
|
44
|
+
/** CSS selector — replace the target's children with the response HTML. */
|
|
45
|
+
_in?: string;
|
|
46
|
+
/** CSS selector — replace the target element itself with the response HTML. */
|
|
47
|
+
_out?: string;
|
|
48
|
+
/** CSS selector — insert the response HTML before the target. */
|
|
49
|
+
_before?: string;
|
|
50
|
+
/** CSS selector — insert the response HTML after the target. */
|
|
51
|
+
_after?: string;
|
|
52
|
+
/** CSS selector for a `<form>`; its `FormData` becomes the POST body. */
|
|
53
|
+
_form?: string;
|
|
54
|
+
/** CSS selector(s) for inputs; their values become a JSON POST body. */
|
|
55
|
+
_json?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Optional CSS selector for a toast host. On a non-2xx response from
|
|
58
|
+
* `_get` / `_post`, if this attribute is present AND the selector
|
|
59
|
+
* resolves to an element, the response body is injected into that
|
|
60
|
+
* element using `_in` semantics (script-aware). When absent, or when
|
|
61
|
+
* the selector does not resolve, the default inline retry error UI is
|
|
62
|
+
* used instead.
|
|
63
|
+
*/
|
|
64
|
+
_toast?: string;
|
|
65
|
+
/**
|
|
66
|
+
* When to fire the request. Defaults to `'click'`.
|
|
67
|
+
* - `'click'` — on user click (default).
|
|
68
|
+
* - `'load'` — immediately on init.
|
|
69
|
+
* - `'visible'` — first time the element enters the viewport.
|
|
70
|
+
*/
|
|
71
|
+
_trigger?: 'click' | 'load' | 'visible';
|
|
72
|
+
/** Opt-in to sending the `X-DeviceId` header on this request. */
|
|
73
|
+
_id?: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface SVGElement {
|
|
77
|
+
_get?: string;
|
|
78
|
+
_post?: string;
|
|
79
|
+
_go?: string;
|
|
80
|
+
_open?: string;
|
|
81
|
+
_in?: string;
|
|
82
|
+
_out?: string;
|
|
83
|
+
_before?: string;
|
|
84
|
+
_after?: string;
|
|
85
|
+
_form?: string;
|
|
86
|
+
_json?: string;
|
|
87
|
+
_toast?: string;
|
|
88
|
+
_trigger?: 'click' | 'load' | 'visible';
|
|
89
|
+
_id?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
interface MathMLElement {
|
|
93
|
+
_get?: string;
|
|
94
|
+
_post?: string;
|
|
95
|
+
_go?: string;
|
|
96
|
+
_open?: string;
|
|
97
|
+
_in?: string;
|
|
98
|
+
_out?: string;
|
|
99
|
+
_before?: string;
|
|
100
|
+
_after?: string;
|
|
101
|
+
_form?: string;
|
|
102
|
+
_json?: string;
|
|
103
|
+
_toast?: string;
|
|
104
|
+
_trigger?: 'click' | 'load' | 'visible';
|
|
105
|
+
_id?: string;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export {};
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*! LengkApp Edge License
|
|
2
|
+
|
|
3
|
+
Copyright (c) LengkApp — Yasir Haris
|
|
4
|
+
Contact: yh@lengk.app / yasir.haris@gmail.com
|
|
5
|
+
|
|
6
|
+
Permission is granted to any person obtaining a copy of this software
|
|
7
|
+
and associated documentation files (the "Software") to use, copy, and
|
|
8
|
+
distribute the Software free of charge, for any purpose, including
|
|
9
|
+
commercial use, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
1. The Software may not be modified, adapted, or altered in any way
|
|
12
|
+
without prior written permission from the copyright holder.
|
|
13
|
+
|
|
14
|
+
2. Redistribution of the Software, in whole or in part, must retain
|
|
15
|
+
this LICENSE file unmodified and include the copyright notice above.
|
|
16
|
+
|
|
17
|
+
3. This permission notice does not grant any right to use the
|
|
18
|
+
LengkApp name, brand, or trademarks without separate written
|
|
19
|
+
permission.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
22
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
23
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
24
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT HOLDER BE
|
|
25
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
26
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
27
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
*/
|
|
29
|
+
(()=>{const e={loader:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-loader-circle"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>',alert:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-triangle-alert"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>',refresh:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-refresh-cw"><path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/></svg>'},t=new WeakMap;function n(t){return e[t]||""}function r(){const e=document.querySelector('meta[name="_csrf"]');return e?e.content:""}function o(e,t,n){const r=document.querySelector(e);if(!r)throw new Error("Target not found: "+e);const o=document.createElement("template");o.innerHTML="string"==typeof n?n:String(n);const c=o.content,s=[],a=[];c.querySelectorAll("script").forEach(e=>{const t=document.createComment("_edge-script");s.push(e),a.push(t),e.replaceWith(t)}),"in"===t?r.replaceChildren(c):"out"===t?(r.parentNode.insertBefore(c,r),r.remove()):"before"===t?r.parentNode.insertBefore(c,r):"after"===t?r.parentNode.insertBefore(c,r.nextSibling):r.replaceChildren(c),function(e,t){if(0===e.length)return;let n=Promise.resolve();for(let r=0;r<e.length;r++){const o=e[r],c=t[r];n=n.then(()=>i(o,c))}n.catch(()=>{})}(s,a)}function i(e,t){return new Promise(n=>{if(!t.parentNode)return void n();const r=document.createElement("script");for(let t=0;t<e.attributes.length;t++){const n=e.attributes[t];r.setAttribute(n.name,n.value)}const o=e.hasAttribute("src"),i=e.hasAttribute("async");if(!o)return r.textContent=e.textContent,t.parentNode.replaceChild(r,t),void n();if(i)return t.parentNode.replaceChild(r,t),void n();let c=!1;const s=()=>{c||(c=!0,n())};r.addEventListener("load",s,{once:!0}),r.addEventListener("error",s,{once:!0}),t.parentNode.replaceChild(r,t),setTimeout(s,3e4)})}async function c(e){const i=t.get(e);i&&i.abort&&i.abort.abort();const s=new AbortController;t.set(e,{abort:s,retry:()=>c(e)});const a=e.hasAttribute("_post")?"POST":"GET",d=e.getAttribute("POST"===a?"_post":"_get")||e.getAttribute("_go")||e.getAttribute("_open");if(!d)return;if(e.hasAttribute("_go"))return void(location.href=d);if(e.hasAttribute("_open"))return void window.open(d,"_blank","noopener");const l=e.getAttribute("_in")&&{sel:e.getAttribute("_in"),mode:"in"}||e.getAttribute("_out")&&{sel:e.getAttribute("_out"),mode:"out"}||e.getAttribute("_before")&&{sel:e.getAttribute("_before"),mode:"before"}||e.getAttribute("_after")&&{sel:e.getAttribute("_after"),mode:"after"};if(!l)return;const u=function(e,t){const r=document.querySelector(e);if(!r)return null;const o=document.createElement("span");return o.className="_edge-loader",o.innerHTML=n("loader"),"in"===t?(r.innerHTML="",r.appendChild(o)):"out"===t||"before"===t?r.parentNode.insertBefore(o,r):r.parentNode.insertBefore(o,r.nextSibling),o}(l.sel,l.mode);try{const t={"X-CSRF-Token":r()};let n;if(e.hasAttribute("_id")&&(t["X-DeviceId"]=function(){if(typeof window<"u"&&"function"==typeof window.deviceId)try{const e=window.deviceId();if(null!=e)return String(e)}catch{}return(new Date).toString()}()),"POST"===a){const r=e.getAttribute("_form"),o=e.getAttribute("_json");if(r)n=function(e){const t=document.querySelector(e);if(!t)throw new Error("Form not found: "+e);return new FormData(t)}(r);else{if(!o)throw new Error("_post requires _form or _json");t["Content-Type"]="application/json",n=JSON.stringify(function(e){const t=e.split(",").map(e=>e.trim()).filter(Boolean),n={};for(const e of t){const t=document.querySelector(e);if(!t)continue;const r=t.name||t.id||e;"checkbox"===t.type?n[r]=t.checked:"radio"===t.type?t.checked&&(n[r]=t.value):t.multiple?n[r]=Array.from(t.selectedOptions).map(e=>e.value):n[r]=t.value}return n}(o))}}const i=await fetch(d,{method:a,headers:t,body:n,signal:s.signal}),c=await i.text();if(!i.ok){const t=e.getAttribute("_toast");if(t&&document.querySelector(t))return void o(t,"in",c);throw new Error("HTTP "+i.status)}o(l.sel,l.mode,c)}catch(t){if("AbortError"===t.name)return;!function(e,t,r,o){const i=document.querySelector(e);if(!i)return;const c=document.createElement("div");c.className="_edge-error",c.innerHTML=n("alert");const s=document.createElement("span");s.textContent=r.message||"Request failed",c.appendChild(s);const a=document.createElement("button");a.type="button",a.innerHTML=n("refresh")+" Retry",a.onclick=()=>{c.remove(),o()},c.appendChild(a),"in"===t?(i.innerHTML="",i.appendChild(c)):"out"===t||"before"===t?i.parentNode.insertBefore(c,i):i.parentNode.insertBefore(c,i.nextSibling)}(l.sel,l.mode,t,()=>c(e))}finally{u&&u.remove()}}function s(e){if(e.__edgeInit)return;e.__edgeInit=!0;const t=function(e){return e.getAttribute("_trigger")||"click"}(e);if("click"===t)e.addEventListener("click",t=>{t.preventDefault(),c(e)});else if("load"===t)c(e);else if("visible"===t){const t=new IntersectionObserver(n=>{n.some(e=>e.isIntersecting)&&(t.disconnect(),c(e))});t.observe(e)}}function a(e=document){(function(){if(document.getElementById("_edge-style"))return;const e=document.createElement("style");e.id="_edge-style",e.textContent="._edge-loader{display:inline-flex;align-items:center;gap:.35rem;opacity:.7}._edge-loader svg{animation:_edge-spin 1s linear infinite}._edge-error{display:flex;align-items:center;gap:.5rem;color:#b91c1c;background:#fef2f2;border:1px solid #fecaca;padding:.5rem .75rem;border-radius:.5rem;font:14px system-ui,sans-serif}._edge-error button{display:inline-flex;align-items:center;gap:.25rem;margin-left:auto;cursor:pointer;border:1px solid #fca5a5;background:#fff;color:#991b1b;border-radius:.35rem;padding:.25rem .5rem}@keyframes _edge-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)})(),e.querySelectorAll&&e.querySelectorAll("[_get], [_post], [_go], [_open]").forEach(s)}function d(){new MutationObserver(e=>{for(const t of e)t.addedNodes.forEach(e=>{1===e.nodeType&&(e.matches&&e.matches("[_get], [_post], [_go], [_open]")&&s(e),a(e))})}).observe(document.documentElement,{childList:!0,subtree:!0})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{a(),d()}):(a(),d())})();
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/* server.d.ts */
|
|
2
|
+
|
|
3
|
+
export class Html {
|
|
4
|
+
readonly value: string;
|
|
5
|
+
constructor(value: string);
|
|
6
|
+
toString(): string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Runtime value is `Symbol('Fragment')`. The function signature is a
|
|
11
|
+
* type-level shim so `<></>` works with the automatic JSX runtime.
|
|
12
|
+
* Never called directly — `jsx(Fragment, …)` passes it through and
|
|
13
|
+
* `renderToString` compares by identity.
|
|
14
|
+
*/
|
|
15
|
+
export const Fragment: (props: { children?: any }) => JSXNode;
|
|
16
|
+
|
|
17
|
+
export type JsxChild =
|
|
18
|
+
| Html
|
|
19
|
+
| string
|
|
20
|
+
| number
|
|
21
|
+
| boolean
|
|
22
|
+
| null
|
|
23
|
+
| undefined
|
|
24
|
+
| JsxChild[];
|
|
25
|
+
|
|
26
|
+
export type JsxType =
|
|
27
|
+
| string
|
|
28
|
+
| typeof Fragment
|
|
29
|
+
| ((props: Record<string, any>) => Html | string | number | null | undefined);
|
|
30
|
+
|
|
31
|
+
export function jsx(type: JsxType, props: Record<string, any> | null, ...children: JsxChild[]): Html;
|
|
32
|
+
export const jsxs: typeof jsx;
|
|
33
|
+
export const jsxDEV: typeof jsx;
|
|
34
|
+
|
|
35
|
+
/* ------------------------------ cookies ------------------------------ */
|
|
36
|
+
|
|
37
|
+
export interface CookieOptions {
|
|
38
|
+
path?: string;
|
|
39
|
+
domain?: string;
|
|
40
|
+
maxAge?: number;
|
|
41
|
+
expires?: Date | string | number;
|
|
42
|
+
httpOnly?: boolean;
|
|
43
|
+
secure?: boolean;
|
|
44
|
+
sameSite?: 'strict' | 'lax' | 'none' | boolean;
|
|
45
|
+
partitioned?: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* ------------------------------- routes ------------------------------ */
|
|
49
|
+
|
|
50
|
+
export interface RouteConfig {
|
|
51
|
+
valid?: boolean;
|
|
52
|
+
auth?: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface RequestHelper {
|
|
56
|
+
raw: Request;
|
|
57
|
+
url: string;
|
|
58
|
+
method: string;
|
|
59
|
+
params: Record<string, string>;
|
|
60
|
+
readonly cookies: Record<string, string>;
|
|
61
|
+
param(key: string): string | undefined;
|
|
62
|
+
query(key: string): string | null;
|
|
63
|
+
header(key: string): string | null;
|
|
64
|
+
cookie(key: string): string | undefined;
|
|
65
|
+
json<T = any>(): Promise<T>;
|
|
66
|
+
text(): Promise<string>;
|
|
67
|
+
formData(): Promise<FormData>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface Context<E = any> {
|
|
71
|
+
req: RequestHelper;
|
|
72
|
+
env: E;
|
|
73
|
+
ctx: ExecutionContext;
|
|
74
|
+
readonly cookies: Record<string, string>;
|
|
75
|
+
getCookie(name: string): string | undefined;
|
|
76
|
+
setCookie(name: string, value: string, options?: CookieOptions): void;
|
|
77
|
+
deleteCookie(name: string, options?: CookieOptions): void;
|
|
78
|
+
redirect(url: string, status?: 301 | 302 | 303 | 307 | 308): Response;
|
|
79
|
+
text(body: string | Html, status?: number, headers?: Record<string, string>): Response;
|
|
80
|
+
json(body: any, status?: number, headers?: Record<string, string>): Response;
|
|
81
|
+
html(body: string | Html, status?: number, headers?: Record<string, string>): Response;
|
|
82
|
+
page(body: string | Html, status?: number, headers?: Record<string, string>): Response;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type HandlerResult = Response | string | number | Html | null | undefined;
|
|
86
|
+
export type Handler<E = any> = (c: Context<E>) => HandlerResult | Promise<HandlerResult>;
|
|
87
|
+
|
|
88
|
+
export class Edge<E = any> {
|
|
89
|
+
cors: string[];
|
|
90
|
+
headers: Record<string, string>;
|
|
91
|
+
|
|
92
|
+
get(path: string, config: RouteConfig, handler: Handler<E>): void;
|
|
93
|
+
get(path: string, handler: Handler<E>): void;
|
|
94
|
+
|
|
95
|
+
post(path: string, config: RouteConfig, handler: Handler<E>): void;
|
|
96
|
+
post(path: string, handler: Handler<E>): void;
|
|
97
|
+
|
|
98
|
+
put(path: string, config: RouteConfig, handler: Handler<E>): void;
|
|
99
|
+
put(path: string, handler: Handler<E>): void;
|
|
100
|
+
|
|
101
|
+
delete(path: string, config: RouteConfig, handler: Handler<E>): void;
|
|
102
|
+
delete(path: string, handler: Handler<E>): void;
|
|
103
|
+
|
|
104
|
+
options(path: string, config: RouteConfig, handler: Handler<E>): void;
|
|
105
|
+
options(path: string, handler: Handler<E>): void;
|
|
106
|
+
|
|
107
|
+
fetch(request: Request, env: E, ctx: ExecutionContext): Promise<Response>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* -------- Global JSX namespace for the classic transform -------- */
|
|
111
|
+
declare global {
|
|
112
|
+
namespace JSX {
|
|
113
|
+
type Element = Html;
|
|
114
|
+
interface ElementChildrenAttribute {
|
|
115
|
+
children: {};
|
|
116
|
+
}
|
|
117
|
+
interface IntrinsicElements {
|
|
118
|
+
[elemName: string]: Record<string, any>;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*! LengkApp Edge License
|
|
2
|
+
|
|
3
|
+
Copyright (c) LengkApp — Yasir Haris
|
|
4
|
+
Contact: yh@lengk.app / yasir.haris@gmail.com
|
|
5
|
+
|
|
6
|
+
Permission is granted to any person obtaining a copy of this software
|
|
7
|
+
and associated documentation files (the "Software") to use, copy, and
|
|
8
|
+
distribute the Software free of charge, for any purpose, including
|
|
9
|
+
commercial use, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
1. The Software may not be modified, adapted, or altered in any way
|
|
12
|
+
without prior written permission from the copyright holder.
|
|
13
|
+
|
|
14
|
+
2. Redistribution of the Software, in whole or in part, must retain
|
|
15
|
+
this LICENSE file unmodified and include the copyright notice above.
|
|
16
|
+
|
|
17
|
+
3. This permission notice does not grant any right to use the
|
|
18
|
+
LengkApp name, brand, or trademarks without separate written
|
|
19
|
+
permission.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
22
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
23
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
24
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR OR COPYRIGHT HOLDER BE
|
|
25
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
26
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
27
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
*/
|
|
29
|
+
const e=Symbol("Fragment");class t{constructor(e){this.value=String(e)}toString(){return this.value}}const s=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function n(n,r,...o){if(n===e)return new t(o.flat(1/0).map(i).join(""));if("function"==typeof n){const e=n({...r||{},children:o});return e instanceof t?e:new t(null==e?"":String(e))}const h=[];if(r)for(const[e,t]of Object.entries(r)){if("children"===e||null==t||!1===t||"dangerouslySetInnerHTML"===e)continue;let s=e;if("className"===e?s="class":"htmlFor"===e?s="for":e.startsWith("on")&&e.length>2&&(s=e.toLowerCase()),"style"===e&&"object"==typeof t){const e=Object.entries(t).map(([e,t])=>`${c(e)}:${a(String(t))}`).join(";");h.push(`style="${e}"`)}else!0===t?h.push(s):h.push(`${s}="${a(String(t))}"`)}let u;u=r&&r.dangerouslySetInnerHTML&&null!=r.dangerouslySetInnerHTML.__html?String(r.dangerouslySetInnerHTML.__html):o.flat(1/0).map(i).join("");const l=h.length?" "+h.join(" "):"";return s.has(n)?new t(`<${n}${l} />`):new t(`<${n}${l}>${u}</${n}>`)}const r=n,o=n;function i(e){return null==e||!1===e||!0===e?"":e instanceof t?e.value:Array.isArray(e)?e.flat(1/0).map(i).join(""):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function a(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function c(e){return e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}const h=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;class u{constructor(){this.routes=[],this.cors=["*"],this.headers={}}add(e,t,s,n){"function"==typeof s&&(n=s,s={});const r=[],o=t.replace(/:([A-Za-z0-9_]+)/g,(e,t)=>(r.push(t),"([^/]+)")),i=new RegExp(`^${o}$`);this.routes.push({method:e,regex:i,keys:r,config:s||{},handler:n})}get(e,t,s){this.add("GET",e,t,s)}post(e,t,s){this.add("POST",e,t,s)}put(e,t,s){this.add("PUT",e,t,s)}delete(e,t,s){this.add("DELETE",e,t,s)}options(e,t,s){this.add("OPTIONS",e,t,s)}async fetch(e,t,s){const n=new URL(e.url),r=e.headers.get("Origin")||"",o=this.corsHeaders(r);if("OPTIONS"===e.method)return new Response(null,{status:204,headers:o});for(const r of this.routes){if(r.method!==e.method)continue;const i=r.regex.exec(n.pathname);if(!i)continue;const a={};r.keys.forEach((e,t)=>{a[e]=decodeURIComponent(i[t+1])});const c=new l(e,t,s,a,this);if(r.config.valid&&!await this.validCsrf(c))return this.withHeaders(c.text("Invalid CSRF",403),o,c);if(r.config.auth&&!this.auth(c))return this.withHeaders(c.text("Unauthorized",401),o,c);try{const e=await r.handler(c),t=e instanceof Response?e:c.text(null==e?"":String(e));return this.withHeaders(t,o,c)}catch(e){return this.withHeaders(c.text(e.message||"Internal Error",500),o,c)}}return this.withHeaders(new Response("Not Found",{status:404}),o)}corsHeaders(e){const t={};return!this.cors||this.cors.includes("*")?t["Access-Control-Allow-Origin"]="*":e&&this.cors.some(t=>function(e,t){try{const s=new URL(e).host;if(t===s)return!0;if(t.startsWith("*.")){const e=t.slice(2);return s===e||s.endsWith("."+e)}return!1}catch{return!1}}(e,t))&&(t["Access-Control-Allow-Origin"]=e,t.Vary="Origin"),t["Access-Control-Allow-Methods"]="GET,POST,PUT,DELETE,OPTIONS",t["Access-Control-Allow-Headers"]="Content-Type, X-CSRF-Token, X-DeviceId",t}withHeaders(e,t={},s=null){const n=function(e){const t=new Headers,s="function"==typeof e.getSetCookie?e.getSetCookie():[];let n=null;for(const[s,r]of e)"set-cookie"!==s.toLowerCase()?t.set(s,r):n=r;if(s.length)for(const e of s)t.append("Set-Cookie",e);else n&&t.append("Set-Cookie",n);return t}(e.headers);for(const[e,t]of Object.entries(this.headers))n.set(e,t);for(const[e,s]of Object.entries(t))n.set(e,s);if(s&&s._setCookies.length)for(const e of s._setCookies)n.append("Set-Cookie",e);const r=101===e.status||204===e.status||205===e.status||304===e.status;return new Response(r?null:e.body,{status:e.status,statusText:e.statusText,headers:n})}async validCsrf(e){const t=e.req.cookie("_csrf"),s=e.req.header("x-csrf-token");return!(!t||!s||t!==s)}auth(e){return!!e.req.cookie("_auth")}}class l{constructor(e,t,s,n,r){this.req=new p(e,n),this.env=t,this.ctx=s,this.app=r,this._setCookies=[]}get cookies(){return this.req.cookies}getCookie(e){return this.req.cookie(e)}setCookie(e,t,s={}){this._setCookies.push(function(e,t,s={}){if(!h.test(e))throw new TypeError(`Invalid cookie name: ${JSON.stringify(e)}`);const n=[`${e}=${encodeURIComponent(null==t?"":String(t))}`];if(null!=s.maxAge&&n.push(`Max-Age=${Math.floor(Number(s.maxAge))}`),s.domain&&n.push(`Domain=${s.domain}`),s.path&&n.push(`Path=${s.path}`),null!=s.expires){const e=s.expires instanceof Date?s.expires:new Date(s.expires);n.push(`Expires=${e.toUTCString()}`)}if(s.httpOnly&&n.push("HttpOnly"),s.secure&&n.push("Secure"),s.sameSite){const e=!0===s.sameSite?"strict":String(s.sameSite);n.push(`SameSite=${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()}`)}return s.partitioned&&n.push("Partitioned"),n.join("; ")}(e,t,s))}deleteCookie(e,t={}){this.setCookie(e,"",{...t,maxAge:0,expires:new Date(0)})}redirect(e,t=302){return Response.redirect(new URL(e,this.req.url),t)}text(e,t=200,s={}){return new Response(String(e),{status:t,headers:{"Content-Type":"text/plain; charset=utf-8",...s}})}json(e,t=200,s={}){const n="string"==typeof e?e:JSON.stringify(e);return new Response(n,{status:t,headers:{"Content-Type":"application/json; charset=utf-8",...s}})}html(e,t=200,s={}){return new Response(String(e),{status:t,headers:{"Content-Type":"text/html; charset=utf-8",...s}})}page(e,t=200,s={}){const n=String(e),r=n.startsWith("<!DOCTYPE html>")?n:"<!DOCTYPE html>"+n;return new Response(r,{status:t,headers:{"Content-Type":"text/html; charset=utf-8",...s}})}}class p{constructor(e,t){this.raw=e,this.url=e.url,this.method=e.method,this.params=t,this._url=new URL(e.url),this._cookies=null}param(e){return this.params[e]}query(e){return this._url.searchParams.get(e)}header(e){return this.raw.headers.get(e)}get cookies(){return this._cookies||(this._cookies=function(e){const t=Object.create(null);if(!e)return t;for(const s of e.split(";")){const e=s.indexOf("=");if(e<0)continue;const n=s.slice(0,e).trim();if(!n||"__proto__"===n||n in t)continue;const r=s.slice(e+1).trim();try{t[n]=decodeURIComponent(r)}catch{t[n]=r}}return t}(this.raw.headers.get("Cookie"))),this._cookies}cookie(e){return this.cookies[e]}json(){return this.raw.json()}text(){return this.raw.text()}formData(){return this.raw.formData()}}export{u as Edge,e as Fragment,t as Html,n as jsx,o as jsxDEV,r as jsxs};
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lengkapp/edge",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"description": "Edge framework used by Lengkapp",
|
|
5
5
|
"main": "dist/edge-server.js",
|
|
6
6
|
"types": "dist/edge-server.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"types": "./dist/
|
|
10
|
-
"node": "./dist/
|
|
11
|
-
"default": "./dist/
|
|
9
|
+
"types": "./dist/server.d.ts",
|
|
10
|
+
"node": "./dist/server.js",
|
|
11
|
+
"default": "./dist/server.js"
|
|
12
12
|
},
|
|
13
13
|
"./client": {
|
|
14
|
-
"types": "./dist/
|
|
15
|
-
"default": "./dist/
|
|
14
|
+
"types": "./dist/client.d.ts",
|
|
15
|
+
"default": "./dist/client.js"
|
|
16
16
|
},
|
|
17
17
|
"./server": {
|
|
18
|
-
"types": "./dist/
|
|
19
|
-
"default": "./dist/
|
|
18
|
+
"types": "./dist/server.d.ts",
|
|
19
|
+
"default": "./dist/server.js"
|
|
20
20
|
},
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"dist"
|
|
25
25
|
],
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "node build.mjs"
|
|
27
|
+
"build": "node build.mjs",
|
|
28
|
+
"dev": "wrangler dev"
|
|
28
29
|
},
|
|
29
30
|
"publishConfig": {
|
|
30
31
|
"access": "public"
|
|
@@ -38,6 +39,7 @@
|
|
|
38
39
|
"license": "MIT",
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"esbuild": "^0.28.2",
|
|
41
|
-
"terser": "^5.51.2"
|
|
42
|
+
"terser": "^5.51.2",
|
|
43
|
+
"wrangler": "^4.141.0"
|
|
42
44
|
}
|
|
43
45
|
}
|
package/dist/edge-client.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/edge-client.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* @lengkapp/edge v0.0.35
|
|
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 x(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 g(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&&g(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=g(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),O=Promise.resolve();if(!t)if(e.hasAttribute("_json"))O=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 x(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 x(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 x(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 A=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);A&&(S.body=A)}n(e)&&(O=Promise.all([O,a()]).then(function(r){var e=r[1];e&&(S.headers["X-DeviceId"]=e)})),O.then(function(){return fetch(i,S)}).then(function(r){if(clearTimeout(M),!r.ok){var e=new Error("HTTP "+r.status);throw e.status=r.status,e}return r.text()}).then(function(t){clearTimeout(d),C(function(){var n=function(){b(e),t&&function(e,t){var n=g(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++)B(c[i]);for(i=0;i<l.length;i++)U(l[i]);U(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(r){var t;clearTimeout(M),clearTimeout(d),c.get(e)===s&&(t=r&&"AbortError"===r.name?"Request timed out":r&&r.message?r.message:"Request failed",r&&"AbortError"!==r.name&&console.error("[app]",r),C(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=g(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,t)}))})}}function C(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,O=new WeakMap,A=new WeakMap,C=new Set,j=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,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 I(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(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(a){var i=JSON.parse(a);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(!r.ok)throw new Error("HTTP "+r.status);return r.json()}).then(function(r){T[t]=r;try{localStorage.setItem(n,JSON.stringify(r))}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&&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&&!E(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&&(A.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 x=v[m];if(1===x.nodeType&&(x===e||!E(x,e))){var g=O.get(x);g||(g=Object.create(null),O.set(x,g));for(var h=0;h<L.length;h++){var b=L[h];if(x.hasAttribute(b)){b in g||(g[b]=x.getAttribute(b));var w=g[b],k=String(w||"").trim();if(k){var _=t[k],y="string"==typeof _?_:k;x.getAttribute(b)!==y&&x.setAttribute(b,y)}}}}}}(e,t)})}}}function N(r){if(r&&r.isConnected&&(C.add(r),!j)){var t=e.requestAnimationFrame||function(r){return setTimeout(r,16)};j=t(function(){j=0;var r=[];C.forEach(function(e){r.push(e)}),C.clear();for(var e=0;e<r.length;e++)I(r[e])})}}function U(r){if(r&&1===r.nodeType){r.hasAttribute&&r.hasAttribute("_translate")&&N(r);for(var e=r.querySelectorAll?r.querySelectorAll("[_translate]"):[],t=0;t<e.length;t++)N(e[t])}}function W(){U(r.documentElement)}function z(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 B(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),z(r[e].target))},{rootMargin:"300px"})),s.observe(r)):z(r)))}function D(r){for(var e=r.querySelectorAll(v),t=0;t<e.length;t++)B(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||A.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&&N(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&&U(s)}}}else if("lang"===n.attributeName&&n.target===r.documentElement)return void W()}}).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(){D(r),U(r.documentElement)}):(D(r),U(r.documentElement))}()}();
|