sigment 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2025] [wappaa/jv.dev]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # jv-start
2
+
3
+ JavaScript Vanilla (JV) — A lightweight JavaScript library for building client-side applications.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install sigment
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ /* if import from @wappaa/jv not work then you can add to index.html this code
15
+ <script type="importmap">
16
+ {"imports": {"sigment": "/node_modules/sigment/dist/index.js"}}
17
+ </script>
18
+ */
19
+
20
+ import "sigment";
21
+
22
+ // Tag functions (div, h1, p, button, etc.) are globally available after this import
23
+
24
+ function ComponentName() {
25
+
26
+ return div("hello sigment");
27
+
28
+ }
29
+
30
+ document.body.appendChild(ComponentName());
31
+
32
+
33
+ // Reactive counter example:
34
+
35
+ import { createSignal } from "sigment";
36
+
37
+ function Counter() {
38
+ const [count, setCount] = createSignal(0);
39
+
40
+ return div({ class: "counter" },
41
+ h1("Sigment Reactive Framework"),
42
+ p(() => `Count is: ${count()}`), // Reactive text updates
43
+ button({ onClick: () => setCount(count() + 1) }, "Increment") // Event handler
44
+ );
45
+ }
46
+
47
+ document.body.appendChild(Counter());
48
+
49
+
50
+ ```
51
+
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ var P=Object.defineProperty;var c=(e,t)=>P(e,"name",{value:t,configurable:!0});var y={cleanHtml:K,cleanhtml:!0,setMaxCacheSize:G,maxCacheSize:10},b={funcname:[],dataMap:new Map},C=null,x={},T=new Map,v=new Map,w={innerHTMLElements:["div","p","span","h1","h2","h3","h4","h5","h6","a","ul","ol","li","table","tr","td","th","thead","tbody","tfoot","form","label","button","section","article","header","footer","nav","aside","main","figure","figcaption","blockquote","cite","code","pre","em","strong","i","b","u","s","small","mark","time","abbr","q","dl","dt","dd","fieldset","legend","textarea","output","progress","meter","fragment","details","summary","dialog","menu","slot","template"],valueElements:["input","textarea","select","button","option","progress","meter"],srcElements:["img","script","iframe","audio","video","source","track","embed","frame","input"],hrefElements:["a","link","area","base"],voidElements:["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr","frame"]};Object.values(w).flat().forEach(e=>{globalThis[e]=(...t)=>N(e,...t)});var H=new Set(w.valueElements),Y=new Set(w.srcElements),Q=new Set(w.hrefElements),I=new Set(w.voidElements);function X(e,t){x[e]||(x[e]=V(t))}c(X,"createGlobalSignal");function J(e){return x[e]}c(J,"getGlobalSignal");var Z=J;function ee(e){k(e)}c(ee,"getVirtualElementById");function R(e,t){b.dataMap.has(e)&&b.dataMap.delete(e),b.dataMap.set(e,t)}c(R,"addEntry");function k(e){A(k.name);let t=b.dataMap.get(e);return t?t.value:null}c(k,"gve");function te(e,t,n){let o;if(t instanceof HTMLElement?o=t.outerHTML:typeof t=="object"?o=JSON.stringify(t):o=t.toString(),o.length>4096){console.error("Cookie size exceeds 4KB limit. Data not stored.");return}document.cookie=e+"="+o+"; max-age="+n+" ; path=/ ;",setTimeout(()=>{document.cookie="testCookie=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/;"},n*1e3)}c(te,"setCookie");function ne(e){let n=`; ${document.cookie}`.split(`; ${e}=`);if(n.length===2){let o=n.pop().split(";").shift();try{let i=JSON.parse(o);return typeof i=="object"&&i!==null&&"nodeType"in i&&i.nodeType===1,i}catch{return o}}return null}c(ne,"getCookie");function oe(e,t){let n;t instanceof HTMLElement?n=t.outerHTML:typeof t=="object"?n=JSON.stringify(t):n=t.toString(),localStorage.setItem(e,n)}c(oe,"setStorage");function re(e){let t=localStorage.getItem(e);if(t!==null)try{let n=JSON.parse(t);return typeof n=="object"&&n!==null&&"nodeType"in n&&n.nodeType===1,n}catch{return t}}c(re,"getStorage");function M(e,t=void 0){A(M.name),b.createInstance=M.name;let n="";t===void 0?n=e():n=e(t)}c(M,"createInstance");function z(e,t){A(z.name),b.rpc=z.name;let n={};for(let[o,i]of Object.entries(t))e[o]?n[o]=e[o].apply(null,i):(console.error(`Function ${o} not found!`),n[o]=null);return n}c(z,"rpc");function D(e,t=!1,n){A(D.name),b.gvec=D.name;let o=Object.keys(e),i=o[0],l=o[1],r=o[2];var a=e[i];a=a.name;var p=e[l];let f=e[l];debugger;var h=k(l)===null;if(h||t===!1){var m=""+l;b.dataMap.delete(m),M(p,e[r])}p=k(l);var s=k(i);if(s===null)throw new Error(` source id '${i} is not found in source component `);if(p===null)throw new Error(` target id '${l} is not found in target component `);if(s.replaceWith(p),n!==void 0)for(let g in f){let S=g.toString();if(typeof n=="object"){for(var u in n)if(S===u){var d=n[u];typeof d=="object"?f[g].apply(null,d):f[g].apply(null,[])}}else if(n.indexOf(",">-1)){let j=n.split(",");for(let O=0;O<j.length;O++)S===j[O]&&f[g].apply(null,[])}else S===n&&f[g].apply(null,[])}}c(D,"gvec");async function ie(e,t={}){let{passRestriction:n=[]}=t,o=window.location.pathname.replace(/^\/|\/$/g,"").toLowerCase(),i=e.replace(/^\/|\/$/g,"").toLowerCase();if(!new RegExp("^"+i.replace(/:[^\/]+/g,"[^/]+")+"$").test(o))return!1;let r=Array.isArray(n)?n:[n];for(let a of r)try{let p=typeof a=="function"?a():a;if(p instanceof Promise){if(!await p)return!1}else if(!p)return!1}catch(p){return console.error("Route check failed:",p),!1}return!0}c(ie,"Route");function se(e){return e==null||e===""}c(se,"IsEmpty");function ce(e){window.history.pushState(e,e,e)}c(ce,"Navigate");function G(e){y.maxCacheSize=e}c(G,"setMaxCacheSize");function K(e){y.cleanhtml=e}c(K,"cleanHtml");async function le(e,t){let n=t.replace(/\//g,"").toLowerCase(),o=Object.keys(e).find(i=>i.toLowerCase()===n);if(!o){let i=Object.keys(e).join(", ");throw new Error(`Unknown component: "${t}".
2
+ Available components: ${i}
3
+
4
+ To add this component:
5
+
6
+ const loadAsyncComponents = {
7
+ ...existingComponents,
8
+ "${t}": () => import('./${t}.js')
9
+ };`)}if(v.has(o))return v.get(o);try{let l=(await e[o]()).default;return v.set(o,l),l}catch(i){throw new Error(`Failed to load component "${o}": ${i.message}`)}}c(le,"loadFunc");function ae(e){if(e){let t=e.toLowerCase(),n=!1;for(let o of v.keys())o.toLowerCase()===t&&(v.delete(o),n=!0);return n}else return v.clear(),!0}c(ae,"clearComponentCache");function ue(e){var a,p;let n=window.location.pathname.split("/").filter(Boolean),o=n[0]||"home",i=n.slice(1),l=(p=(a=e[o])==null?void 0:a.urlParam)==null?void 0:p.split(":"),r={};return l&&l.length&&l[0].includes("{")?(l.forEach((f,h)=>{f=f.replace(/[{}]/g,""),r[f]=i[h]}),{componentName:o,params:r}):{componentName:o,params:i}}c(ue,"parsePath");function E(e){return new DOMParser().parseFromString(e,"text/html").body.firstChild}c(E,"parseHTML");async function fe(e,t,n=null,o=null){let i=e[t];if(i||(typeof e.fallback=="string"?i=e[e.fallback]:i=e.fallback),!i)return E("<h1>404 - Component not found</h1>");let{loader:l,guard:r,cacheExpiration:a=null,...p}=i;if(o===null&&typeof i.logic=="function"&&(o=i.logic),typeof r=="function"&&!await r(n))return E("<h1>403 - Forbidden</h1><p>You do not have access to this page.</p>");for(let f in p){let h=p[f];if(typeof h=="function")try{await h()}catch(m){console.error(m)}}try{let f=Date.now(),h=v.get(t);h&&a!==null&&f-h.cachedAt>a&&(v.delete(t),h=null);let m;if(h)m=h.component,v.set(t,{component:m,cachedAt:f});else{if(m=(await l()).default,v.size>=y.maxCacheSize){let u=v.keys().next().value;v.delete(u)}v.set(t,{component:m,cachedAt:f})}return typeof m!="function"?E("<h1>Invalid component</h1>"):typeof n=="object"&&!Array.isArray(n)?m(n):n?m(...n):m()}catch(f){return console.error(f),E("<h1>Error loading component</h1>")}}c(fe,"loadRunFunc");function L(e=""){var i,l;A(L.name),b.buildRoadMap=L.name;var t="";let n=(i=new Error().stack)==null?void 0:i.toString();navigator.userAgent.toLowerCase().indexOf("firefox")>0?n=n.split("@"):n=n.split(`
10
+ `);for(let r=0;r<n.length;r++){var o="";if(navigator.userAgent.indexOf("Firefox")>0){let a=n[r].lastIndexOf(`
11
+ `);if(a===-1)continue;o=n[r].slice(a+1),o===""?(a=n[r].lastIndexOf("/")+1,a>-1&&(o=n[r].substr(a),o=o.substr(0,o.indexOf(".")))):o.indexOf("/")>-1&&(o=o.substr(0,o.indexOf("/")))}else o=(l=n[r])==null?void 0:l.trim().split(" ")[1];if(!b.funcname.includes(o)&&!(o===void 0||o==="")&&!(o.indexOf("http://")>-1||o.indexOf("https://")>-1)){if(b.gvec!==void 0&&o.indexOf(b.gvec)>-1)break;t.indexOf("|"+o)>-1||(t+="|"+o.replace(".","|"))}}return e+t}c(L,"buildRoadMap");function A(e){!b.funcname.includes(e)&&b.funcname.push(e)}c(A,"setFuncName");function V(e){let t=e,n=new Set;function o(){return C&&n.add(C),t}c(o,"get");function i(l,r=!1){(r||t!==l)&&(t=l,n.forEach(a=>a()))}return c(i,"set"),[o,i]}c(V,"createSignal");function F(e){function t(){C=t,e(),C=null}c(t,"wrapped"),t()}c(F,"createEffect");function B(e){e=e.toLowerCase(),w.innerHTMLElements.includes(e)||(w.innerHTMLElements.push(e),globalThis[e]=(...t)=>N(e,...t))}c(B,"createTypeElement");function de(e,...t){if(B(e),t.length!==0)return globalThis[e](...t)}c(de,"createElement");function U(e){let t=document.createTextNode("");return F(()=>{if(typeof x!="object"||x===null){t.textContent=e;return}let n=e.replace(/{{(.*?)}}/g,(o,i)=>{let l=i.trim();if(x.hasOwnProperty(l)){let r=x[l];if(r&&typeof r[0]=="function")return r[0]()??""}return""});t.textContent=n}),t}c(U,"interpolateReactiveText");function pe(e,t=5e3,n={}){let o=JSON.stringify([e,n,t]);if(!T.has(o)){let i=q(async()=>{let l=await fetch(e,n);if(!l.ok)throw new Error(`Fetch failed: ${l.status}`);return l.json()},t);T.set(o,i)}return T.get(o)()}c(pe,"fetchCache");function $(e){if(Array.isArray(e))return e.map($);if(e&&typeof e=="object"){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=$(e[n])}),t}return e}c($,"sortObjectDeep");function _(e){if(e&&typeof e=="object"&&!Array.isArray(e)){let t={};return Object.keys(e).sort().forEach(n=>{t[n]=e[n]}),t}return e}c(_,"sortObjectShallow");function q(e,t=5e3,n={}){let o=new Map,i=c((...l)=>{let{deepSort:r}=n,a;r===!0?a=l.map(s=>s&&typeof s=="object"?$(s):s):r===!1?a=l.map(s=>s&&typeof s=="object"?_(s):s):a=l;let p=JSON.stringify(a),f=Date.now(),h=o.get(p);if(h&&f-h.timestamp<t)return h.value;let m=e(...l);return o.set(p,{value:m,timestamp:f}),m instanceof Promise&&m.catch(()=>o.delete(p)),m},"wrapped");return i.clear=()=>o.clear(),i}c(q,"memoizeFunc");function N(e,...t){let n={},o=[];A(N.name);var i="";i=L();var l=i.split("|");if(l.includes(b.rpc))return;t[0]&&typeof t[0]=="object"&&!Array.isArray(t[0])&&!(t[0]instanceof Node)?(n=t[0],o=t.slice(1)):o=t;let r=null,a=e.toLowerCase()==="fragment";if(a){debugger;r=document.createDocumentFragment()}else r=document.createElement(e);let p=I.has(e),f=H.has(e),h=e==="input"||e==="option",m=e==="option";if(!a)for(let s in n){let u=n[s];s.startsWith("on")&&typeof u=="function"?r.addEventListener(s.slice(2).toLowerCase(),u):typeof u=="function"&&s!=="children"?F(()=>{let d=u();d==null||d===!1?(r.removeAttribute(s),s==="value"&&f&&(r.value="",y.cleanhtml||r.removeAttribute("value")),s==="checked"&&h&&(r.checked=!1,y.cleanhtml||r.removeAttribute("checked")),s==="selected"&&m&&(r.selected=!1,y.cleanhtml||r.removeAttribute("selected")),s==="id"&&(r.iid="",y.cleanhtml||r.removeAttribute("id"))):s==="id"?(r.iid=d,y.cleanhtml?r.setAttribute("id",d):r.removeAttribute("id"),R(d,{name:d,caller:d+i,value:r})):s==="value"&&f?(r.value=d,y.cleanhtml?r.setAttribute("value",d):r.removeAttribute("value")):s==="checked"&&h?(r.checked=d,y.cleanhtml&&d?r.setAttribute("checked",""):r.removeAttribute("checked")):s==="selected"&&m?(r.selected=d,y.cleanhtml&&d?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(s,d)}):u!=null&&u!==!1&&(s==="id"?(r.iid=u,y.cleanhtml?r.setAttribute("id",u):r.removeAttribute("id"),R(u,{name:u,caller:u+i,value:r})):s==="value"&&f?(r.value=u,y.cleanhtml?r.setAttribute("value",u):r.removeAttribute("value")):s==="checked"&&h?(r.checked=u,y.cleanhtml?r.setAttribute("checked",""):r.removeAttribute("checked")):s==="selected"&&m?(r.selected=u,y.cleanhtml?r.setAttribute("selected",""):r.removeAttribute("selected")):r.setAttribute(s,u))}return p?o.length===1&&(typeof o[0]=="string"||typeof o[0]=="number")?f&&(r.value=o[0],y.cleanhtml?r.setAttribute("value",o[0]):r.removeAttribute("value")):o.length>0&&console.warn(`Void element <${e}> should not have children.`):o.flat().forEach(s=>{if(typeof s=="function"){let u=document.createTextNode("");r.appendChild(u),F(()=>{let d=s();if(d instanceof Node){let g=u.parentNode;if(!g)return;g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.replaceChildren(d):g.replaceChild(d,u),u=d}else{let g=d==null?"":String(d);u.textContent!==g&&(u.textContent=g)}})}else if(typeof s=="string"&&s.includes("{{")&&!s.includes("function")){debugger;r.appendChild(U(s))}else if(typeof s=="string"||typeof s=="number"){if(s.includes("function get(")||s.includes("function (")||s.includes("[native code]"))throw new Error("Detected reactive getter function used inside a template string. Use a function instead like: div(() => `Your text is: ${someState()}`)");r.appendChild(document.createTextNode(s))}else(s instanceof DocumentFragment||s instanceof Node)&&r.appendChild(s)}),r}c(N,"h");export{se as IsEmpty,y as MyApp,ce as Navigate,ie as Route,ae as clearComponentCache,F as createEffect,de as createElement,X as createGlobalSignal,V as createSignal,pe as fetchCache,ne as getCookie,J as getGlobalSignal,re as getStorage,ee as getVirtualElementById,k as gve,D as gvec,N as h,le as loadFunc,fe as loadRunFunc,q as memoizeFunc,ue as parsePath,z as rpc,te as setCookie,oe as setStorage,Z as useGlobalSignal};
@@ -0,0 +1,497 @@
1
+ // index.d.ts
2
+
3
+ /**
4
+ * The main app object with some properties and functions
5
+ */
6
+ export declare const MyApp: {
7
+ cleanHtml: (flag: boolean) => void; // accepts boolean, returns void
8
+ cleanhtml: true;
9
+ setMaxCacheSize: (size: number) => void; // accepts number, returns void
10
+ maxCacheSize: number;
11
+ };
12
+
13
+ /**
14
+ * Creates a reactive signal with getter and setter.
15
+ * Setter optionally accepts a second argument 'force' (boolean).
16
+ */
17
+ export declare function createSignal<T = undefined>(
18
+ initialValue?: T
19
+ ): [() => T, (newValue: T, force?: boolean) => void];
20
+
21
+ /**
22
+ * Creates a reactive effect that runs the given function and tracks dependencies.
23
+ */
24
+ export declare function createEffect(fn: () => void): void;
25
+
26
+ /**
27
+ * Creates an HTML element of the given tag name.
28
+ * Returns void.
29
+ */
30
+ export declare function createTypeElement(name: string): void;
31
+
32
+ /**
33
+ * Fetches a URL with caching and TTL, returning parsed JSON.
34
+ */
35
+ export declare function fetchCache<T = any>(
36
+ url: string,
37
+ ttl?: number,
38
+ options?: RequestInit
39
+ ): Promise<T>;
40
+
41
+ export interface MemoizeOptions {
42
+ /**
43
+ * Controls sorting of object keys before memoization cache key generation.
44
+ * - true: Deep sort all nested object keys (default behavior).
45
+ * - false: Shallow sort only top-level keys.
46
+ * - undefined: No sorting (cache key uses raw arguments).
47
+ */
48
+ deepSort?: boolean;
49
+ }
50
+
51
+ /**
52
+ * Memoizes the results of a function with optional TTL and key sorting.
53
+ *
54
+ * @param fn The function to memoize.
55
+ * @param ttl Time to live for cache entries in milliseconds. Defaults to 5000ms.
56
+ * @param options Optional memoization options.
57
+ * @returns The memoized function with a `.clear()` method to clear the cache.
58
+ */
59
+ export function memoizeFunc<
60
+ F extends (...args: any[]) => any
61
+ >(
62
+ fn: F,
63
+ ttl?: number,
64
+ options?: MemoizeOptions
65
+ ): F & { clear(): void };
66
+
67
+ /**
68
+ * Parses a path given a user-defined routes object.
69
+ */
70
+ export declare function parsePath(
71
+ componentImports: Record<
72
+ string,
73
+ | {
74
+ loader: () => Promise<any>;
75
+ urlParam?: string;
76
+ guard?: (params: Record<string, any>) => Promise<boolean>;
77
+ logic?: () => void;
78
+ cacheExpiration?: number;
79
+ }
80
+ | string // fallback route as string route name
81
+ >
82
+ ): {
83
+ componentName: string;
84
+ params: any | object;
85
+ };
86
+
87
+ /**
88
+ * Loads a component and optionally runs logic, returning an HTMLElement.
89
+ */
90
+ export declare function loadRunFunc(
91
+ componentMap: Record<
92
+ string,
93
+ | {
94
+ loader: () => Promise<any>;
95
+ urlParam?: string;
96
+ guard?: (params: Record<string, any>) => Promise<boolean>;
97
+ logic?: () => void;
98
+ cacheExpiration?: number;
99
+ }
100
+ | string
101
+ >,
102
+ componentName: string,
103
+ params?: Record<string, any> | null,
104
+ logic?: (() => void) | null
105
+ ): Promise<HTMLElement>;
106
+
107
+ /**
108
+ * Clears cached component for a given component name.
109
+ */
110
+ export declare function clearComponentCache(componentName: string): void;
111
+
112
+ /**
113
+ * Creates a global signal with a key and initial value.
114
+ */
115
+ export declare function createGlobalSignal<T>(
116
+ key: string,
117
+ initialValue: T
118
+ ): void;
119
+
120
+ /**
121
+ * Gets a global signal by key.
122
+ */
123
+ export declare function getGlobalSignal<T>(key: string): [() => T, (newValue: T) => void];
124
+
125
+ /**
126
+ * Alias for getGlobalSignal.
127
+ */
128
+ export declare const useGlobalSignal: typeof getGlobalSignal;
129
+
130
+ /**
131
+ * Function gve creates an HTML element with the given name.
132
+ */
133
+ export declare function gve(name: string): HTMLElement;
134
+
135
+ /**
136
+ * Sets a cookie; value can be string or object (will be JSON.stringified).
137
+ */
138
+ export declare function setCookie(k: string, v: any, t?: number): void;
139
+
140
+ /**
141
+ * Gets a cookie by key, returns string, parsed object, or null.
142
+ */
143
+ export declare function getCookie(k: string): any;
144
+
145
+ /**
146
+ * Sets localStorage item; value can be string, object, or HTMLElement (stored as outerHTML).
147
+ */
148
+ export declare function setStorage(key: string, value: any): void;
149
+
150
+ /**
151
+ * Gets localStorage item; parses JSON or returns string or HTMLElement-like object.
152
+ */
153
+ export declare function getStorage(key: string): any;
154
+
155
+ /**
156
+ * Hyperscript-style function to create elements or components.
157
+ */
158
+ export declare function h(
159
+ tag: string | ((props?: Record<string, any>, ...children: any[]) => HTMLElement | any),
160
+ ...args: (Record<string, any> | string | number | HTMLElement | (() => string | HTMLElement) | Array<any>)[]
161
+ ): HTMLElement;
162
+
163
+ /**
164
+ * Groups and optionally executes components or HTML elements and metadata.
165
+ */
166
+ export declare function gvec(
167
+ obj: {
168
+ [key: string]: any;
169
+ param?: string | any[] | Record<string, any>;
170
+ },
171
+ s?: boolean,
172
+ o?: Record<string, any>
173
+ ): any;
174
+
175
+
176
+ /**
177
+ * Checks if a value is undefined, null, or an empty string.
178
+ *
179
+ * @param v - The value to check.
180
+ * @returns True if empty, otherwise false.
181
+ */
182
+ export declare function IsEmpty(v: any): boolean;
183
+
184
+ /**
185
+ * Pushes a new state to the browser's history (for navigation).
186
+ *
187
+ * @param path - The path to navigate to.
188
+ */
189
+ export declare function Navigate(path: string): void;
190
+
191
+ /**
192
+ * Retrieves a virtual HTML element by its name using `gve`.
193
+ *
194
+ * @param e - The name of the element to retrieve.
195
+ * @returns The corresponding HTMLElement.
196
+ */
197
+ export declare function getVirtualElementById(e: string): HTMLElement;
198
+
199
+ /**
200
+ * Loads a component module by name from a given map of dynamic import functions.
201
+ *
202
+ * @param componentImports - An object mapping names to dynamic import functions.
203
+ * @param componentName - The name of the component to load.
204
+ * @returns A promise that resolves to the loaded component.
205
+ */
206
+ export declare function loadFunc(
207
+ componentImports: Record<string, () => Promise<any>>,
208
+ componentName: string
209
+ ): Promise<any>;
210
+
211
+
212
+ /**
213
+ * Executes an RPC call with a function and a params object.
214
+ *
215
+ * @param func - A function representing the RPC call body.
216
+ * @param params - An object mapping method names to arrays of parameters.
217
+ * @returns any
218
+ */
219
+ export declare function rpc(
220
+ func: Function,
221
+ params: Record<string, any[]>
222
+ ): any;
223
+
224
+ /**
225
+ * Route function that checks if the current path matches the pattern and optional restrictions.
226
+ *
227
+ * @param pathPattern - The URL pattern string (e.g., "/admin/:id").
228
+ * @param options - Optional object with passRestriction(s) functions.
229
+ * @returns Promise resolving to boolean indicating match and restrictions pass.
230
+ */
231
+ export declare function Route(
232
+ pathPattern: string,
233
+ options?: {
234
+ passRestriction?: Array<(() => boolean | Promise<boolean>)> | (() => boolean | Promise<boolean>);
235
+ }
236
+ ): Promise<boolean>;
237
+
238
+
239
+
240
+
241
+ declare global {
242
+
243
+ type Child =
244
+ | string
245
+ | number
246
+ | boolean
247
+ | null
248
+ | undefined
249
+ | HTMLElement
250
+ | Text
251
+ | DocumentFragment
252
+ | (() => Child)
253
+ | Child[];
254
+
255
+ type Props = Partial<HTMLElement> & {
256
+ [key: `data-${string}`]: string | number | boolean;
257
+ [key: `aria-${string}`]: string | number | boolean;
258
+ [key: string]: any; // allow fake attributes like fake-prop="123"
259
+ };
260
+
261
+ type TagFunction = {
262
+ (props: Props, ...children: Child[]): HTMLElement;
263
+ (...children: Child[]): HTMLElement;
264
+ };
265
+
266
+
267
+ const elements: string[];
268
+
269
+ function createTagFunctions(tags: string[]): Record<string, TagFunction>;
270
+
271
+ function a(props: Props, ...children: Child[]): HTMLElement;
272
+ function a(...children: Child[]): HTMLElement;
273
+ function abbr(props: Props, ...children: Child[]): HTMLElement;
274
+ function abbr(...children: Child[]): HTMLElement;
275
+ function area(props: Props, ...children: Child[]): HTMLElement;
276
+ function area(...children: Child[]): HTMLElement;
277
+ function article(props: Props, ...children: Child[]): HTMLElement;
278
+ function article(...children: Child[]): HTMLElement;
279
+ function aside(props: Props, ...children: Child[]): HTMLElement;
280
+ function aside(...children: Child[]): HTMLElement;
281
+ function audio(props: Props, ...children: Child[]): HTMLElement;
282
+ function audio(...children: Child[]): HTMLElement;
283
+ function base(props: Props, ...children: Child[]): HTMLElement;
284
+ function base(...children: Child[]): HTMLElement;
285
+ function b(props: Props, ...children: Child[]): HTMLElement;
286
+ function b(...children: Child[]): HTMLElement;
287
+ function bdi(props: Props, ...children: Child[]): HTMLElement;
288
+ function bdi(...children: Child[]): HTMLElement;
289
+ function bdo(props: Props, ...children: Child[]): HTMLElement;
290
+ function bdo(...children: Child[]): HTMLElement;
291
+ function blockquote(props: Props, ...children: Child[]): HTMLElement;
292
+ function blockquote(...children: Child[]): HTMLElement;
293
+ function body(props: Props, ...children: Child[]): HTMLElement;
294
+ function body(...children: Child[]): HTMLElement;
295
+ function br(props: Props, ...children: Child[]): HTMLElement;
296
+ function br(...children: Child[]): HTMLElement;
297
+ function button(props: Props, ...children: Child[]): HTMLElement;
298
+ function button(...children: Child[]): HTMLElement;
299
+ function canvas(props: Props, ...children: Child[]): HTMLElement;
300
+ function canvas(...children: Child[]): HTMLElement;
301
+ function cite(props: Props, ...children: Child[]): HTMLElement;
302
+ function cite(...children: Child[]): HTMLElement;
303
+ function code(props: Props, ...children: Child[]): HTMLElement;
304
+ function code(...children: Child[]): HTMLElement;
305
+ function col(props: Props, ...children: Child[]): HTMLElement;
306
+ function col(...children: Child[]): HTMLElement;
307
+ function colgroup(props: Props, ...children: Child[]): HTMLElement;
308
+ function colgroup(...children: Child[]): HTMLElement;
309
+ function data(props: Props, ...children: Child[]): HTMLElement;
310
+ function data(...children: Child[]): HTMLElement;
311
+ function datalist(props: Props, ...children: Child[]): HTMLElement;
312
+ function datalist(...children: Child[]): HTMLElement;
313
+ function dd(props: Props, ...children: Child[]): HTMLElement;
314
+ function dd(...children: Child[]): HTMLElement;
315
+ function del(props: Props, ...children: Child[]): HTMLElement;
316
+ function del(...children: Child[]): HTMLElement;
317
+ function details(props: Props, ...children: Child[]): HTMLElement;
318
+ function details(...children: Child[]): HTMLElement;
319
+ function dfn(props: Props, ...children: Child[]): HTMLElement;
320
+ function dfn(...children: Child[]): HTMLElement;
321
+ function dialog(props: Props, ...children: Child[]): HTMLElement;
322
+ function dialog(...children: Child[]): HTMLElement;
323
+ function div(props: Props, ...children: Child[]): HTMLElement;
324
+ function div(...children: Child[]): HTMLElement;
325
+ function dl(props: Props, ...children: Child[]): HTMLElement;
326
+ function dl(...children: Child[]): HTMLElement;
327
+ function dt(props: Props, ...children: Child[]): HTMLElement;
328
+ function dt(...children: Child[]): HTMLElement;
329
+ function em(props: Props, ...children: Child[]): HTMLElement;
330
+ function em(...children: Child[]): HTMLElement;
331
+ function embed(props: Props, ...children: Child[]): HTMLElement;
332
+ function embed(...children: Child[]): HTMLElement;
333
+ function fieldset(props: Props, ...children: Child[]): HTMLElement;
334
+ function fieldset(...children: Child[]): HTMLElement;
335
+ function figcaption(props: Props, ...children: Child[]): HTMLElement;
336
+ function figcaption(...children: Child[]): HTMLElement;
337
+ function figure(props: Props, ...children: Child[]): HTMLElement;
338
+ function figure(...children: Child[]): HTMLElement;
339
+ function footer(props: Props, ...children: Child[]): HTMLElement;
340
+ function footer(...children: Child[]): HTMLElement;
341
+ function form(props: Props, ...children: Child[]): HTMLElement;
342
+ function form(...children: Child[]): HTMLElement;
343
+ function h1(props: Props, ...children: Child[]): HTMLElement;
344
+ function h1(...children: Child[]): HTMLElement;
345
+ function h2(props: Props, ...children: Child[]): HTMLElement;
346
+ function h2(...children: Child[]): HTMLElement;
347
+ function h3(props: Props, ...children: Child[]): HTMLElement;
348
+ function h3(...children: Child[]): HTMLElement;
349
+ function h4(props: Props, ...children: Child[]): HTMLElement;
350
+ function h4(...children: Child[]): HTMLElement;
351
+ function h5(props: Props, ...children: Child[]): HTMLElement;
352
+ function h5(...children: Child[]): HTMLElement;
353
+ function h6(props: Props, ...children: Child[]): HTMLElement;
354
+ function h6(...children: Child[]): HTMLElement;
355
+ function head(props: Props, ...children: Child[]): HTMLElement;
356
+ function head(...children: Child[]): HTMLElement;
357
+ function header(props: Props, ...children: Child[]): HTMLElement;
358
+ function header(...children: Child[]): HTMLElement;
359
+ function hr(props: Props, ...children: Child[]): HTMLElement;
360
+ function hr(...children: Child[]): HTMLElement;
361
+ function html(props: Props, ...children: Child[]): HTMLElement;
362
+ function html(...children: Child[]): HTMLElement;
363
+ function i(props: Props, ...children: Child[]): HTMLElement;
364
+ function i(...children: Child[]): HTMLElement;
365
+ function iframe(props: Props, ...children: Child[]): HTMLElement;
366
+ function iframe(...children: Child[]): HTMLElement;
367
+ function img(props: Props, ...children: Child[]): HTMLElement;
368
+ function img(...children: Child[]): HTMLElement;
369
+ function input(props: Props, ...children: Child[]): HTMLElement;
370
+ function input(...children: Child[]): HTMLElement;
371
+ function ins(props: Props, ...children: Child[]): HTMLElement;
372
+ function ins(...children: Child[]): HTMLElement;
373
+ function kbd(props: Props, ...children: Child[]): HTMLElement;
374
+ function kbd(...children: Child[]): HTMLElement;
375
+ function label(props: Props, ...children: Child[]): HTMLElement;
376
+ function label(...children: Child[]): HTMLElement;
377
+ function legend(props: Props, ...children: Child[]): HTMLElement;
378
+ function legend(...children: Child[]): HTMLElement;
379
+ function li(props: Props, ...children: Child[]): HTMLElement;
380
+ function li(...children: Child[]): HTMLElement;
381
+ function link(props: Props, ...children: Child[]): HTMLElement;
382
+ function link(...children: Child[]): HTMLElement;
383
+ function main(props: Props, ...children: Child[]): HTMLElement;
384
+ function main(...children: Child[]): HTMLElement;
385
+ function map(props: Props, ...children: Child[]): HTMLElement;
386
+ function map(...children: Child[]): HTMLElement;
387
+ function mark(props: Props, ...children: Child[]): HTMLElement;
388
+ function mark(...children: Child[]): HTMLElement;
389
+ function menu(props: Props, ...children: Child[]): HTMLElement;
390
+ function menu(...children: Child[]): HTMLElement;
391
+ function meta(props: Props, ...children: Child[]): HTMLElement;
392
+ function meta(...children: Child[]): HTMLElement;
393
+ function meter(props: Props, ...children: Child[]): HTMLElement;
394
+ function meter(...children: Child[]): HTMLElement;
395
+ function nav(props: Props, ...children: Child[]): HTMLElement;
396
+ function nav(...children: Child[]): HTMLElement;
397
+ function noscript(props: Props, ...children: Child[]): HTMLElement;
398
+ function noscript(...children: Child[]): HTMLElement;
399
+ function object(props: Props, ...children: Child[]): HTMLElement;
400
+ function object(...children: Child[]): HTMLElement;
401
+ function ol(props: Props, ...children: Child[]): HTMLElement;
402
+ function ol(...children: Child[]): HTMLElement;
403
+ function optgroup(props: Props, ...children: Child[]): HTMLElement;
404
+ function optgroup(...children: Child[]): HTMLElement;
405
+ function option(props: Props, ...children: Child[]): HTMLElement;
406
+ function option(...children: Child[]): HTMLElement;
407
+ function output(props: Props, ...children: Child[]): HTMLElement;
408
+ function output(...children: Child[]): HTMLElement;
409
+ function p(props: Props, ...children: Child[]): HTMLElement;
410
+ function p(...children: Child[]): HTMLElement;
411
+ function param(props: Props, ...children: Child[]): HTMLElement;
412
+ function param(...children: Child[]): HTMLElement;
413
+ function picture(props: Props, ...children: Child[]): HTMLElement;
414
+ function picture(...children: Child[]): HTMLElement;
415
+ function pre(props: Props, ...children: Child[]): HTMLElement;
416
+ function pre(...children: Child[]): HTMLElement;
417
+ function progress(props: Props, ...children: Child[]): HTMLElement;
418
+ function progress(...children: Child[]): HTMLElement;
419
+ function q(props: Props, ...children: Child[]): HTMLElement;
420
+ function q(...children: Child[]): HTMLElement;
421
+ function rp(props: Props, ...children: Child[]): HTMLElement;
422
+ function rp(...children: Child[]): HTMLElement;
423
+ function rt(props: Props, ...children: Child[]): HTMLElement;
424
+ function rt(...children: Child[]): HTMLElement;
425
+ function ruby(props: Props, ...children: Child[]): HTMLElement;
426
+ function ruby(...children: Child[]): HTMLElement;
427
+ function s(props: Props, ...children: Child[]): HTMLElement;
428
+ function s(...children: Child[]): HTMLElement;
429
+ function samp(props: Props, ...children: Child[]): HTMLElement;
430
+ function samp(...children: Child[]): HTMLElement;
431
+ function script(props: Props, ...children: Child[]): HTMLElement;
432
+ function script(...children: Child[]): HTMLElement;
433
+ function section(props: Props, ...children: Child[]): HTMLElement;
434
+ function section(...children: Child[]): HTMLElement;
435
+ function select(props: Props, ...children: Child[]): HTMLElement;
436
+ function select(...children: Child[]): HTMLElement;
437
+ function slot(props: Props, ...children: Child[]): HTMLElement;
438
+ function slot(...children: Child[]): HTMLElement;
439
+ function small(props: Props, ...children: Child[]): HTMLElement;
440
+ function small(...children: Child[]): HTMLElement;
441
+ function source(props: Props, ...children: Child[]): HTMLElement;
442
+ function source(...children: Child[]): HTMLElement;
443
+ function span(props: Props, ...children: Child[]): HTMLElement;
444
+ function span(...children: Child[]): HTMLElement;
445
+ function strong(props: Props, ...children: Child[]): HTMLElement;
446
+ function strong(...children: Child[]): HTMLElement;
447
+ function style(props: Props, ...children: Child[]): HTMLElement;
448
+ function style(...children: Child[]): HTMLElement;
449
+ function sub(props: Props, ...children: Child[]): HTMLElement;
450
+ function sub(...children: Child[]): HTMLElement;
451
+ function summary(props: Props, ...children: Child[]): HTMLElement;
452
+ function summary(...children: Child[]): HTMLElement;
453
+ function sup(props: Props, ...children: Child[]): HTMLElement;
454
+ function sup(...children: Child[]): HTMLElement;
455
+ function table(props: Props, ...children: Child[]): HTMLElement;
456
+ function table(...children: Child[]): HTMLElement;
457
+ function tbody(props: Props, ...children: Child[]): HTMLElement;
458
+ function tbody(...children: Child[]): HTMLElement;
459
+ function td(props: Props, ...children: Child[]): HTMLElement;
460
+ function td(...children: Child[]): HTMLElement;
461
+ function template(props: Props, ...children: Child[]): HTMLElement;
462
+ function template(...children: Child[]): HTMLElement;
463
+ function textarea(props: Props, ...children: Child[]): HTMLElement;
464
+ function textarea(...children: Child[]): HTMLElement;
465
+ function tfoot(props: Props, ...children: Child[]): HTMLElement;
466
+ function tfoot(...children: Child[]): HTMLElement;
467
+ function th(props: Props, ...children: Child[]): HTMLElement;
468
+ function th(...children: Child[]): HTMLElement;
469
+ function thead(props: Props, ...children: Child[]): HTMLElement;
470
+ function thead(...children: Child[]): HTMLElement;
471
+ function time(props: Props, ...children: Child[]): HTMLElement;
472
+ function time(...children: Child[]): HTMLElement;
473
+ function title(props: Props, ...children: Child[]): HTMLElement;
474
+ function title(...children: Child[]): HTMLElement;
475
+ function tr(props: Props, ...children: Child[]): HTMLElement;
476
+ function tr(...children: Child[]): HTMLElement;
477
+ function track(props: Props, ...children: Child[]): HTMLElement;
478
+ function track(...children: Child[]): HTMLElement;
479
+ function u(props: Props, ...children: Child[]): HTMLElement;
480
+ function u(...children: Child[]): HTMLElement;
481
+ function ul(props: Props, ...children: Child[]): HTMLElement;
482
+ function ul(...children: Child[]): HTMLElement;
483
+ function var_(props: Props, ...children: Child[]): HTMLElement;
484
+ function var_(...children: Child[]): HTMLElement;
485
+ function video(props: Props, ...children: Child[]): HTMLElement;
486
+ function video(...children: Child[]): HTMLElement;
487
+ function wbr(props: Props, ...children: Child[]): HTMLElement;
488
+ function wbr(...children: Child[]): HTMLElement;
489
+ function fragment(props: Props, ...children: Child[]): DocumentFragment;
490
+ function fragment(...children: Child[]): DocumentFragment;
491
+
492
+
493
+ }
494
+
495
+
496
+ export function createElement(tagName: string, ...args: (string | HTMLElement)[]): HTMLElement;
497
+
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "sigment",
3
+ "version": "1.0.0",
4
+ "description": "JavaScript Vanilla library",
5
+ "main": "./dist/index.js",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/wappaa/jv.git"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./types/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./throw-on-require.js"
15
+ }
16
+ },
17
+ "type": "module",
18
+ "types": "./types/index.d.ts",
19
+ "author": "wappaa",
20
+ "license": "MIT",
21
+ "files": [
22
+ "dist",
23
+ "types",
24
+ "throw-on-require.js"
25
+ ],
26
+ "scripts": {
27
+ "build": "esbuild index.js --bundle --format=esm --minify --keep-names --target=es2020,chrome90,firefox88,safari15 --outfile=dist/index.js",
28
+ "prepare": "npm run build"
29
+ },
30
+ "devDependencies": {
31
+ "esbuild": "^0.25.2"
32
+ },
33
+ "engines": {
34
+ "node": ">=14.8.0"
35
+ },
36
+ "keywords": [
37
+ "Javascript",
38
+ "Vanilla"
39
+ ],
40
+ "bugs": {
41
+ "url": "https://github.com/wappaa/jv/issues"
42
+ },
43
+ "homepage": "https://github.com/wappaa/jv#readme"
44
+ }
@@ -0,0 +1 @@
1
+ throw new Error('@wappaa/jv is ESM-only. Use import instead of require.');
@@ -0,0 +1,497 @@
1
+ // index.d.ts
2
+
3
+ /**
4
+ * The main app object with some properties and functions
5
+ */
6
+ export declare const MyApp: {
7
+ cleanHtml: (flag: boolean) => void; // accepts boolean, returns void
8
+ cleanhtml: true;
9
+ setMaxCacheSize: (size: number) => void; // accepts number, returns void
10
+ maxCacheSize: number;
11
+ };
12
+
13
+ /**
14
+ * Creates a reactive signal with getter and setter.
15
+ * Setter optionally accepts a second argument 'force' (boolean).
16
+ */
17
+ export declare function createSignal<T = undefined>(
18
+ initialValue?: T
19
+ ): [() => T, (newValue: T, force?: boolean) => void];
20
+
21
+ /**
22
+ * Creates a reactive effect that runs the given function and tracks dependencies.
23
+ */
24
+ export declare function createEffect(fn: () => void): void;
25
+
26
+ /**
27
+ * Creates an HTML element of the given tag name.
28
+ * Returns void.
29
+ */
30
+ export declare function createTypeElement(name: string): void;
31
+
32
+ /**
33
+ * Fetches a URL with caching and TTL, returning parsed JSON.
34
+ */
35
+ export declare function fetchCache<T = any>(
36
+ url: string,
37
+ ttl?: number,
38
+ options?: RequestInit
39
+ ): Promise<T>;
40
+
41
+ export interface MemoizeOptions {
42
+ /**
43
+ * Controls sorting of object keys before memoization cache key generation.
44
+ * - true: Deep sort all nested object keys (default behavior).
45
+ * - false: Shallow sort only top-level keys.
46
+ * - undefined: No sorting (cache key uses raw arguments).
47
+ */
48
+ deepSort?: boolean;
49
+ }
50
+
51
+ /**
52
+ * Memoizes the results of a function with optional TTL and key sorting.
53
+ *
54
+ * @param fn The function to memoize.
55
+ * @param ttl Time to live for cache entries in milliseconds. Defaults to 5000ms.
56
+ * @param options Optional memoization options.
57
+ * @returns The memoized function with a `.clear()` method to clear the cache.
58
+ */
59
+ export function memoizeFunc<
60
+ F extends (...args: any[]) => any
61
+ >(
62
+ fn: F,
63
+ ttl?: number,
64
+ options?: MemoizeOptions
65
+ ): F & { clear(): void };
66
+
67
+ /**
68
+ * Parses a path given a user-defined routes object.
69
+ */
70
+ export declare function parsePath(
71
+ componentImports: Record<
72
+ string,
73
+ | {
74
+ loader: () => Promise<any>;
75
+ urlParam?: string;
76
+ guard?: (params: Record<string, any>) => Promise<boolean>;
77
+ logic?: () => void;
78
+ cacheExpiration?: number;
79
+ }
80
+ | string // fallback route as string route name
81
+ >
82
+ ): {
83
+ componentName: string;
84
+ params: any | object;
85
+ };
86
+
87
+ /**
88
+ * Loads a component and optionally runs logic, returning an HTMLElement.
89
+ */
90
+ export declare function loadRunFunc(
91
+ componentMap: Record<
92
+ string,
93
+ | {
94
+ loader: () => Promise<any>;
95
+ urlParam?: string;
96
+ guard?: (params: Record<string, any>) => Promise<boolean>;
97
+ logic?: () => void;
98
+ cacheExpiration?: number;
99
+ }
100
+ | string
101
+ >,
102
+ componentName: string,
103
+ params?: Record<string, any> | null,
104
+ logic?: (() => void) | null
105
+ ): Promise<HTMLElement>;
106
+
107
+ /**
108
+ * Clears cached component for a given component name.
109
+ */
110
+ export declare function clearComponentCache(componentName: string): void;
111
+
112
+ /**
113
+ * Creates a global signal with a key and initial value.
114
+ */
115
+ export declare function createGlobalSignal<T>(
116
+ key: string,
117
+ initialValue: T
118
+ ): void;
119
+
120
+ /**
121
+ * Gets a global signal by key.
122
+ */
123
+ export declare function getGlobalSignal<T>(key: string): [() => T, (newValue: T) => void];
124
+
125
+ /**
126
+ * Alias for getGlobalSignal.
127
+ */
128
+ export declare const useGlobalSignal: typeof getGlobalSignal;
129
+
130
+ /**
131
+ * Function gve creates an HTML element with the given name.
132
+ */
133
+ export declare function gve(name: string): HTMLElement;
134
+
135
+ /**
136
+ * Sets a cookie; value can be string or object (will be JSON.stringified).
137
+ */
138
+ export declare function setCookie(k: string, v: any, t?: number): void;
139
+
140
+ /**
141
+ * Gets a cookie by key, returns string, parsed object, or null.
142
+ */
143
+ export declare function getCookie(k: string): any;
144
+
145
+ /**
146
+ * Sets localStorage item; value can be string, object, or HTMLElement (stored as outerHTML).
147
+ */
148
+ export declare function setStorage(key: string, value: any): void;
149
+
150
+ /**
151
+ * Gets localStorage item; parses JSON or returns string or HTMLElement-like object.
152
+ */
153
+ export declare function getStorage(key: string): any;
154
+
155
+ /**
156
+ * Hyperscript-style function to create elements or components.
157
+ */
158
+ export declare function h(
159
+ tag: string | ((props?: Record<string, any>, ...children: any[]) => HTMLElement | any),
160
+ ...args: (Record<string, any> | string | number | HTMLElement | (() => string | HTMLElement) | Array<any>)[]
161
+ ): HTMLElement;
162
+
163
+ /**
164
+ * Groups and optionally executes components or HTML elements and metadata.
165
+ */
166
+ export declare function gvec(
167
+ obj: {
168
+ [key: string]: any;
169
+ param?: string | any[] | Record<string, any>;
170
+ },
171
+ s?: boolean,
172
+ o?: Record<string, any>
173
+ ): any;
174
+
175
+
176
+ /**
177
+ * Checks if a value is undefined, null, or an empty string.
178
+ *
179
+ * @param v - The value to check.
180
+ * @returns True if empty, otherwise false.
181
+ */
182
+ export declare function IsEmpty(v: any): boolean;
183
+
184
+ /**
185
+ * Pushes a new state to the browser's history (for navigation).
186
+ *
187
+ * @param path - The path to navigate to.
188
+ */
189
+ export declare function Navigate(path: string): void;
190
+
191
+ /**
192
+ * Retrieves a virtual HTML element by its name using `gve`.
193
+ *
194
+ * @param e - The name of the element to retrieve.
195
+ * @returns The corresponding HTMLElement.
196
+ */
197
+ export declare function getVirtualElementById(e: string): HTMLElement;
198
+
199
+ /**
200
+ * Loads a component module by name from a given map of dynamic import functions.
201
+ *
202
+ * @param componentImports - An object mapping names to dynamic import functions.
203
+ * @param componentName - The name of the component to load.
204
+ * @returns A promise that resolves to the loaded component.
205
+ */
206
+ export declare function loadFunc(
207
+ componentImports: Record<string, () => Promise<any>>,
208
+ componentName: string
209
+ ): Promise<any>;
210
+
211
+
212
+ /**
213
+ * Executes an RPC call with a function and a params object.
214
+ *
215
+ * @param func - A function representing the RPC call body.
216
+ * @param params - An object mapping method names to arrays of parameters.
217
+ * @returns any
218
+ */
219
+ export declare function rpc(
220
+ func: Function,
221
+ params: Record<string, any[]>
222
+ ): any;
223
+
224
+ /**
225
+ * Route function that checks if the current path matches the pattern and optional restrictions.
226
+ *
227
+ * @param pathPattern - The URL pattern string (e.g., "/admin/:id").
228
+ * @param options - Optional object with passRestriction(s) functions.
229
+ * @returns Promise resolving to boolean indicating match and restrictions pass.
230
+ */
231
+ export declare function Route(
232
+ pathPattern: string,
233
+ options?: {
234
+ passRestriction?: Array<(() => boolean | Promise<boolean>)> | (() => boolean | Promise<boolean>);
235
+ }
236
+ ): Promise<boolean>;
237
+
238
+
239
+
240
+
241
+ declare global {
242
+
243
+ type Child =
244
+ | string
245
+ | number
246
+ | boolean
247
+ | null
248
+ | undefined
249
+ | HTMLElement
250
+ | Text
251
+ | DocumentFragment
252
+ | (() => Child)
253
+ | Child[];
254
+
255
+ type Props = Partial<HTMLElement> & {
256
+ [key: `data-${string}`]: string | number | boolean;
257
+ [key: `aria-${string}`]: string | number | boolean;
258
+ [key: string]: any; // allow fake attributes like fake-prop="123"
259
+ };
260
+
261
+ type TagFunction = {
262
+ (props: Props, ...children: Child[]): HTMLElement;
263
+ (...children: Child[]): HTMLElement;
264
+ };
265
+
266
+
267
+ const elements: string[];
268
+
269
+ function createTagFunctions(tags: string[]): Record<string, TagFunction>;
270
+
271
+ function a(props: Props, ...children: Child[]): HTMLElement;
272
+ function a(...children: Child[]): HTMLElement;
273
+ function abbr(props: Props, ...children: Child[]): HTMLElement;
274
+ function abbr(...children: Child[]): HTMLElement;
275
+ function area(props: Props, ...children: Child[]): HTMLElement;
276
+ function area(...children: Child[]): HTMLElement;
277
+ function article(props: Props, ...children: Child[]): HTMLElement;
278
+ function article(...children: Child[]): HTMLElement;
279
+ function aside(props: Props, ...children: Child[]): HTMLElement;
280
+ function aside(...children: Child[]): HTMLElement;
281
+ function audio(props: Props, ...children: Child[]): HTMLElement;
282
+ function audio(...children: Child[]): HTMLElement;
283
+ function base(props: Props, ...children: Child[]): HTMLElement;
284
+ function base(...children: Child[]): HTMLElement;
285
+ function b(props: Props, ...children: Child[]): HTMLElement;
286
+ function b(...children: Child[]): HTMLElement;
287
+ function bdi(props: Props, ...children: Child[]): HTMLElement;
288
+ function bdi(...children: Child[]): HTMLElement;
289
+ function bdo(props: Props, ...children: Child[]): HTMLElement;
290
+ function bdo(...children: Child[]): HTMLElement;
291
+ function blockquote(props: Props, ...children: Child[]): HTMLElement;
292
+ function blockquote(...children: Child[]): HTMLElement;
293
+ function body(props: Props, ...children: Child[]): HTMLElement;
294
+ function body(...children: Child[]): HTMLElement;
295
+ function br(props: Props, ...children: Child[]): HTMLElement;
296
+ function br(...children: Child[]): HTMLElement;
297
+ function button(props: Props, ...children: Child[]): HTMLElement;
298
+ function button(...children: Child[]): HTMLElement;
299
+ function canvas(props: Props, ...children: Child[]): HTMLElement;
300
+ function canvas(...children: Child[]): HTMLElement;
301
+ function cite(props: Props, ...children: Child[]): HTMLElement;
302
+ function cite(...children: Child[]): HTMLElement;
303
+ function code(props: Props, ...children: Child[]): HTMLElement;
304
+ function code(...children: Child[]): HTMLElement;
305
+ function col(props: Props, ...children: Child[]): HTMLElement;
306
+ function col(...children: Child[]): HTMLElement;
307
+ function colgroup(props: Props, ...children: Child[]): HTMLElement;
308
+ function colgroup(...children: Child[]): HTMLElement;
309
+ function data(props: Props, ...children: Child[]): HTMLElement;
310
+ function data(...children: Child[]): HTMLElement;
311
+ function datalist(props: Props, ...children: Child[]): HTMLElement;
312
+ function datalist(...children: Child[]): HTMLElement;
313
+ function dd(props: Props, ...children: Child[]): HTMLElement;
314
+ function dd(...children: Child[]): HTMLElement;
315
+ function del(props: Props, ...children: Child[]): HTMLElement;
316
+ function del(...children: Child[]): HTMLElement;
317
+ function details(props: Props, ...children: Child[]): HTMLElement;
318
+ function details(...children: Child[]): HTMLElement;
319
+ function dfn(props: Props, ...children: Child[]): HTMLElement;
320
+ function dfn(...children: Child[]): HTMLElement;
321
+ function dialog(props: Props, ...children: Child[]): HTMLElement;
322
+ function dialog(...children: Child[]): HTMLElement;
323
+ function div(props: Props, ...children: Child[]): HTMLElement;
324
+ function div(...children: Child[]): HTMLElement;
325
+ function dl(props: Props, ...children: Child[]): HTMLElement;
326
+ function dl(...children: Child[]): HTMLElement;
327
+ function dt(props: Props, ...children: Child[]): HTMLElement;
328
+ function dt(...children: Child[]): HTMLElement;
329
+ function em(props: Props, ...children: Child[]): HTMLElement;
330
+ function em(...children: Child[]): HTMLElement;
331
+ function embed(props: Props, ...children: Child[]): HTMLElement;
332
+ function embed(...children: Child[]): HTMLElement;
333
+ function fieldset(props: Props, ...children: Child[]): HTMLElement;
334
+ function fieldset(...children: Child[]): HTMLElement;
335
+ function figcaption(props: Props, ...children: Child[]): HTMLElement;
336
+ function figcaption(...children: Child[]): HTMLElement;
337
+ function figure(props: Props, ...children: Child[]): HTMLElement;
338
+ function figure(...children: Child[]): HTMLElement;
339
+ function footer(props: Props, ...children: Child[]): HTMLElement;
340
+ function footer(...children: Child[]): HTMLElement;
341
+ function form(props: Props, ...children: Child[]): HTMLElement;
342
+ function form(...children: Child[]): HTMLElement;
343
+ function h1(props: Props, ...children: Child[]): HTMLElement;
344
+ function h1(...children: Child[]): HTMLElement;
345
+ function h2(props: Props, ...children: Child[]): HTMLElement;
346
+ function h2(...children: Child[]): HTMLElement;
347
+ function h3(props: Props, ...children: Child[]): HTMLElement;
348
+ function h3(...children: Child[]): HTMLElement;
349
+ function h4(props: Props, ...children: Child[]): HTMLElement;
350
+ function h4(...children: Child[]): HTMLElement;
351
+ function h5(props: Props, ...children: Child[]): HTMLElement;
352
+ function h5(...children: Child[]): HTMLElement;
353
+ function h6(props: Props, ...children: Child[]): HTMLElement;
354
+ function h6(...children: Child[]): HTMLElement;
355
+ function head(props: Props, ...children: Child[]): HTMLElement;
356
+ function head(...children: Child[]): HTMLElement;
357
+ function header(props: Props, ...children: Child[]): HTMLElement;
358
+ function header(...children: Child[]): HTMLElement;
359
+ function hr(props: Props, ...children: Child[]): HTMLElement;
360
+ function hr(...children: Child[]): HTMLElement;
361
+ function html(props: Props, ...children: Child[]): HTMLElement;
362
+ function html(...children: Child[]): HTMLElement;
363
+ function i(props: Props, ...children: Child[]): HTMLElement;
364
+ function i(...children: Child[]): HTMLElement;
365
+ function iframe(props: Props, ...children: Child[]): HTMLElement;
366
+ function iframe(...children: Child[]): HTMLElement;
367
+ function img(props: Props, ...children: Child[]): HTMLElement;
368
+ function img(...children: Child[]): HTMLElement;
369
+ function input(props: Props, ...children: Child[]): HTMLElement;
370
+ function input(...children: Child[]): HTMLElement;
371
+ function ins(props: Props, ...children: Child[]): HTMLElement;
372
+ function ins(...children: Child[]): HTMLElement;
373
+ function kbd(props: Props, ...children: Child[]): HTMLElement;
374
+ function kbd(...children: Child[]): HTMLElement;
375
+ function label(props: Props, ...children: Child[]): HTMLElement;
376
+ function label(...children: Child[]): HTMLElement;
377
+ function legend(props: Props, ...children: Child[]): HTMLElement;
378
+ function legend(...children: Child[]): HTMLElement;
379
+ function li(props: Props, ...children: Child[]): HTMLElement;
380
+ function li(...children: Child[]): HTMLElement;
381
+ function link(props: Props, ...children: Child[]): HTMLElement;
382
+ function link(...children: Child[]): HTMLElement;
383
+ function main(props: Props, ...children: Child[]): HTMLElement;
384
+ function main(...children: Child[]): HTMLElement;
385
+ function map(props: Props, ...children: Child[]): HTMLElement;
386
+ function map(...children: Child[]): HTMLElement;
387
+ function mark(props: Props, ...children: Child[]): HTMLElement;
388
+ function mark(...children: Child[]): HTMLElement;
389
+ function menu(props: Props, ...children: Child[]): HTMLElement;
390
+ function menu(...children: Child[]): HTMLElement;
391
+ function meta(props: Props, ...children: Child[]): HTMLElement;
392
+ function meta(...children: Child[]): HTMLElement;
393
+ function meter(props: Props, ...children: Child[]): HTMLElement;
394
+ function meter(...children: Child[]): HTMLElement;
395
+ function nav(props: Props, ...children: Child[]): HTMLElement;
396
+ function nav(...children: Child[]): HTMLElement;
397
+ function noscript(props: Props, ...children: Child[]): HTMLElement;
398
+ function noscript(...children: Child[]): HTMLElement;
399
+ function object(props: Props, ...children: Child[]): HTMLElement;
400
+ function object(...children: Child[]): HTMLElement;
401
+ function ol(props: Props, ...children: Child[]): HTMLElement;
402
+ function ol(...children: Child[]): HTMLElement;
403
+ function optgroup(props: Props, ...children: Child[]): HTMLElement;
404
+ function optgroup(...children: Child[]): HTMLElement;
405
+ function option(props: Props, ...children: Child[]): HTMLElement;
406
+ function option(...children: Child[]): HTMLElement;
407
+ function output(props: Props, ...children: Child[]): HTMLElement;
408
+ function output(...children: Child[]): HTMLElement;
409
+ function p(props: Props, ...children: Child[]): HTMLElement;
410
+ function p(...children: Child[]): HTMLElement;
411
+ function param(props: Props, ...children: Child[]): HTMLElement;
412
+ function param(...children: Child[]): HTMLElement;
413
+ function picture(props: Props, ...children: Child[]): HTMLElement;
414
+ function picture(...children: Child[]): HTMLElement;
415
+ function pre(props: Props, ...children: Child[]): HTMLElement;
416
+ function pre(...children: Child[]): HTMLElement;
417
+ function progress(props: Props, ...children: Child[]): HTMLElement;
418
+ function progress(...children: Child[]): HTMLElement;
419
+ function q(props: Props, ...children: Child[]): HTMLElement;
420
+ function q(...children: Child[]): HTMLElement;
421
+ function rp(props: Props, ...children: Child[]): HTMLElement;
422
+ function rp(...children: Child[]): HTMLElement;
423
+ function rt(props: Props, ...children: Child[]): HTMLElement;
424
+ function rt(...children: Child[]): HTMLElement;
425
+ function ruby(props: Props, ...children: Child[]): HTMLElement;
426
+ function ruby(...children: Child[]): HTMLElement;
427
+ function s(props: Props, ...children: Child[]): HTMLElement;
428
+ function s(...children: Child[]): HTMLElement;
429
+ function samp(props: Props, ...children: Child[]): HTMLElement;
430
+ function samp(...children: Child[]): HTMLElement;
431
+ function script(props: Props, ...children: Child[]): HTMLElement;
432
+ function script(...children: Child[]): HTMLElement;
433
+ function section(props: Props, ...children: Child[]): HTMLElement;
434
+ function section(...children: Child[]): HTMLElement;
435
+ function select(props: Props, ...children: Child[]): HTMLElement;
436
+ function select(...children: Child[]): HTMLElement;
437
+ function slot(props: Props, ...children: Child[]): HTMLElement;
438
+ function slot(...children: Child[]): HTMLElement;
439
+ function small(props: Props, ...children: Child[]): HTMLElement;
440
+ function small(...children: Child[]): HTMLElement;
441
+ function source(props: Props, ...children: Child[]): HTMLElement;
442
+ function source(...children: Child[]): HTMLElement;
443
+ function span(props: Props, ...children: Child[]): HTMLElement;
444
+ function span(...children: Child[]): HTMLElement;
445
+ function strong(props: Props, ...children: Child[]): HTMLElement;
446
+ function strong(...children: Child[]): HTMLElement;
447
+ function style(props: Props, ...children: Child[]): HTMLElement;
448
+ function style(...children: Child[]): HTMLElement;
449
+ function sub(props: Props, ...children: Child[]): HTMLElement;
450
+ function sub(...children: Child[]): HTMLElement;
451
+ function summary(props: Props, ...children: Child[]): HTMLElement;
452
+ function summary(...children: Child[]): HTMLElement;
453
+ function sup(props: Props, ...children: Child[]): HTMLElement;
454
+ function sup(...children: Child[]): HTMLElement;
455
+ function table(props: Props, ...children: Child[]): HTMLElement;
456
+ function table(...children: Child[]): HTMLElement;
457
+ function tbody(props: Props, ...children: Child[]): HTMLElement;
458
+ function tbody(...children: Child[]): HTMLElement;
459
+ function td(props: Props, ...children: Child[]): HTMLElement;
460
+ function td(...children: Child[]): HTMLElement;
461
+ function template(props: Props, ...children: Child[]): HTMLElement;
462
+ function template(...children: Child[]): HTMLElement;
463
+ function textarea(props: Props, ...children: Child[]): HTMLElement;
464
+ function textarea(...children: Child[]): HTMLElement;
465
+ function tfoot(props: Props, ...children: Child[]): HTMLElement;
466
+ function tfoot(...children: Child[]): HTMLElement;
467
+ function th(props: Props, ...children: Child[]): HTMLElement;
468
+ function th(...children: Child[]): HTMLElement;
469
+ function thead(props: Props, ...children: Child[]): HTMLElement;
470
+ function thead(...children: Child[]): HTMLElement;
471
+ function time(props: Props, ...children: Child[]): HTMLElement;
472
+ function time(...children: Child[]): HTMLElement;
473
+ function title(props: Props, ...children: Child[]): HTMLElement;
474
+ function title(...children: Child[]): HTMLElement;
475
+ function tr(props: Props, ...children: Child[]): HTMLElement;
476
+ function tr(...children: Child[]): HTMLElement;
477
+ function track(props: Props, ...children: Child[]): HTMLElement;
478
+ function track(...children: Child[]): HTMLElement;
479
+ function u(props: Props, ...children: Child[]): HTMLElement;
480
+ function u(...children: Child[]): HTMLElement;
481
+ function ul(props: Props, ...children: Child[]): HTMLElement;
482
+ function ul(...children: Child[]): HTMLElement;
483
+ function var_(props: Props, ...children: Child[]): HTMLElement;
484
+ function var_(...children: Child[]): HTMLElement;
485
+ function video(props: Props, ...children: Child[]): HTMLElement;
486
+ function video(...children: Child[]): HTMLElement;
487
+ function wbr(props: Props, ...children: Child[]): HTMLElement;
488
+ function wbr(...children: Child[]): HTMLElement;
489
+ function fragment(props: Props, ...children: Child[]): DocumentFragment;
490
+ function fragment(...children: Child[]): DocumentFragment;
491
+
492
+
493
+ }
494
+
495
+
496
+ export function createElement(tagName: string, ...args: (string | HTMLElement)[]): HTMLElement;
497
+