New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

frameless-js

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frameless-js - npm Package Compare versions

Comparing version
0.0.4
to
0.0.5
+1
dist/cjs/404-Bp5uwYPw.cjs
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(t){return console.log("Route params:",t),alert("Page not found"),{}}exports.init=e;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let i=!1;function r(e){return i=e,i}async function n(e){try{const o=await fetch(e);if(!o.ok)throw new Error("Not found in public");return await o.text()}catch{console.warn(`[TemplateLoader] Falling back to src for: ${e}`);const t=Object.assign({"/src/modules/Login/components/Login.html":()=>Promise.resolve().then(()=>require("./Login-B1Ntlzgu.cjs")).then(l=>l.default)}),s=e.split("/").pop()||"",a=Object.keys(t).find(l=>l.endsWith(`/${s}`));if(!a)throw new Error(`Template '${s}' not found in src fallback`);return t[a]()}}const u=[{path:"home",view:()=>n("./views/home.html"),onLoad:()=>console.log("Home loaded"),layout:"./views/layouts/default.html",scripts:["modules/home"]},{path:"login",view:"./views/login.html",onLoad:()=>console.log("Login loaded"),layout:"./views/layouts/default.html",scripts:["modules/Login/Login"]},{path:"profile/:id",view:"./views/profile.html",onLoad:()=>console.log("Profile loaded"),layout:"./views/layouts/default.html",middleware:async e=>{if(console.log(e,">>>>"),e?.user)return e.user!="banned";const o=!!e.user;return await r(o)?!0:(location.hash="#login",!1)},script:["modules/about"]},{path:"about",view:"./views/about.html",layout:"./views/layouts/default.html",middleware:()=>(console.log("About middleware ran"),!0),onLoad:()=>console.log("About page is now visible"),script:"modules/about"},{path:"contact",view:"./views/contact.html",layout:"./views/layouts/default.html",middleware:()=>(console.log("Checking something before showing contact"),confirm("Do you really want to view the contact page?"))},{path:"dashboard",view:"./views/dashboard.html",script:"modules/dashboard",layout:"./views/layouts/dashboard.html"},{path:"*",view:"./views/404.html",script:"modules/404"}];exports.loadTemplate=n;exports.routes=u;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(c){const s=new Map,i=t=>{(s.get(t)||[]).forEach(o=>o(a[t]))},e={...c},a=new Proxy(e,{get(t,n,o){return typeof n=="string"&&n in t?t[n]:Reflect.get(t,n,o)},set(t,n,o,r){if(typeof n=="string"&&n in t){const u=n;return t[u]!==o&&(t[u]=o,i(u)),!0}return Reflect.set(t,n,o,r)}});return{state:a,setState(t,n){a[t]=n},subscribe(t,n){s.has(t)||s.set(t,[]),s.get(t).push(n),n(a[t])}}}function g(c={},s){const i=new Map,e=(r,u)=>{(i.get(r)||[]).forEach(f=>f(u))},a={...s,...c},t=new Proxy(a,{set(r,u,f,d){if(console.log(d),typeof u=="string"&&Object.prototype.hasOwnProperty.call(r,u)){const b=u;r[b]!==f&&(r[b]=f,e(b,f))}return!0}}),n=(r,u)=>{i.has(r)||i.set(r,[]),i.get(r).push(u),u(t[r])},o={};for(const r of Object.keys(t))o[r]=u=>(u!==void 0&&(t[r]=u),t[r]);return{state:t,subscribe:n,bindings:o}}function S(c){document.querySelectorAll("[data-bind], [data-model]").forEach(s=>{const i=s.getAttribute("data-bind")||s.getAttribute("data-model");i&&(s.addEventListener("input",e=>{const a=e.target;c.state[i]=a.value}),c.subscribe(i,e=>{s.value!==e&&(s.value=e)}))}),document.querySelectorAll("[data-bind-text]").forEach(s=>{const i=s.getAttribute("data-bind-text");i&&c.subscribe(i,e=>{s.textContent=e})})}function h(c,s=document){const i=e=>s.querySelectorAll(e);i("[data-bind], [data-model]").forEach(e=>{const a=e.getAttribute("data-bind")||e.getAttribute("data-model");a&&(e.addEventListener("input",t=>{const n=t.target;c.setState(a,n.value)}),c.subscribe(a,t=>{e.value!==t&&(e.value=t??"")}))}),i("[data-bind-text]").forEach(e=>{const a=e.getAttribute("data-bind-text");a&&c.subscribe(a,t=>{e.textContent=t??""})}),i("[data-bind-attr]").forEach(e=>{(e.getAttribute("data-bind-attr")?.split(",")??[]).forEach(t=>{const[n,o]=t.trim().split(":").map(r=>r.trim());c.subscribe(o,r=>e.setAttribute(n,r))})})}function l({props:c={},store:s,callback:i}){if(!s||typeof i!="function")return;let e=JSON.stringify(c),a=JSON.stringify(s.state);const t=()=>{const n=JSON.stringify(c),o=JSON.stringify(s.state);(n!==e||o!==a)&&(e=n,a=o,i({props:c,state:s.state}))};Object.keys(s.state).forEach(n=>{s.subscribe(n,t)}),i({props:c,state:s.state})}exports.bind=S;exports.setupReactivity=h;exports.usePropsStore=g;exports.useStore=y;exports.watchEffect=l;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./core/components/defineComponent.js");require("./core/hooks/basic.js");require("./vite-env.d-D9PmDmJR.cjs");const r=require("./routecore.js"),t=e=>({surge:n=>{window.addEventListener("hashchange",()=>r.handleHashChange(n,e)),window.addEventListener("DOMContentLoaded",()=>r.handleHashChange(n,e))}});exports.bootstrapContainers=t;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=new Map;function o(n,t){e.set(n,{lazy:t})}exports.componentRegistry=e;exports.defineComponent=o;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function f(c,e,r){c.textContent=typeof e=="function"?e():e}function d(c,e={}){const r=Object.keys(e);r.forEach(n=>{const t=c.querySelector(`[data-ref="${n}"]`);t&&f(t,e[n])}),r.forEach(n=>{const t=e[n];typeof t?.subscribe!="function"||typeof t?.peek!="function"||(c.querySelectorAll(`[data-bind="${n}"]`).forEach(i=>{i.textContent=t.peek(),t.subscribe(s=>i.textContent=s)}),c.querySelectorAll("[data-bind-attr]").forEach(i=>{(i.getAttribute("data-bind-attr")?.split(",")||[]).forEach(o=>{const[a,b]=o.trim().split(":");b===n&&(i.setAttribute(a,t.peek()),t.subscribe(u=>i.setAttribute(a,u)))})}))})}exports.hydrateElmentAttibutesBindings=d;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../vite-env.d-D9PmDmJR.cjs");function d(e,n){return n.split(".").reduce((o,r)=>o?.[r],e)}function l(e,n,o){const r=n.split("."),s=r.pop();if(!s)return;const u=r.reduce((t,i)=>(t[i]===void 0&&(t[i]={}),t[i]),e);u[s]=o}function p(e,n,o){document.querySelectorAll(`[data-model="${e}"]`).forEach(s=>{const u=d(n,e)??"";s.value!==u&&(s.value=u);const t=i=>{const a=i.target.value;l(n,e,a),o({...n})};s.removeEventListener("input",t),s.addEventListener("input",t)})}function v(e,n,o,r=document){const s=r.querySelectorAll(`[data-model="${e}"]`),u=c.getNestedValue(n(),e);s.forEach(t=>{t.value!==u&&(t.value=u),t.addEventListener("input",i=>{const a=i.target.value;o(a)})})}exports.getDeep=d;exports.hydrateInputs=v;exports.hydrateInputsBindings=p;exports.setDeep=l;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(t,e,n){t&&(t.textContent=e(),n(()=>{t.textContent=e()}))}exports.bindText=i;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=new Map;function o(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function a(e,n){const r=o(e);t.set(r,n)}function c(e){const n=o(e);if(t.has(n))return t.get(n)}exports.defineComponent=a;exports.getComponentLoader=c;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../hydrations/hydrateComponent.js"),a=require("../hooks/basic.js"),p=require("../../vite-env.d-D9PmDmJR.cjs");function y(f,o={}){const e=f(o),s=document.createElement("div"),d=typeof e.template=="string"?e.template:"<div><slot></slot></div>";s.innerHTML=d;const r=s.firstElementChild,i={props:o,...e};if(e.store?.state){for(const[t,n]of Object.entries(o))typeof e.store.state[t]>"u"&&e.store.setState(t,n);p.bindPropsToStore(e),a.watchEffect({props:o,store:e.store,callback:({props:t,state:n})=>{for(const[c,u]of Object.entries(t))typeof n[c]>"u"&&e.store.setState(c,u);typeof e.onPropsChanged=="function"&&e.onPropsChanged({props:t,state:n})}})}return requestAnimationFrame(async()=>{e.store&&a.setupReactivity(e.store,r),await l.hydrateComponent(r,i),typeof e.onMount=="function"&&e.onMount(i)}),r}exports.renderComponent=y;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("../hydrations/hydrateComponent.js"),p=require("../hooks/basic.js"),v=require("./defineComponent.js"),w=require("../../vite-env.d-D9PmDmJR.cjs"),S=new Set(["html","head","body","base","link","meta","style","title","address","article","aside","footer","header","h1","h2","h3","h4","h5","main","nav","section","div","span","a","p","ul","li","ol","table","thead","tbody","tr","th","td","form","input","button","select","option","textarea","label","fieldset","legend","script","noscript","template","slot","img","video","audio","canvas","iframe","strong","em","b","i","u","small","br","hr"]);function _(i){const n=i.toLowerCase();return!S.has(n)&&(n.includes("-")||/[A-Z]/.test(i))}function q(i){const n={};for(const f of Array.from(i.attributes)){let e=f.name;e.startsWith(":")&&(e=e.slice(1)),e=e.replace(/-([a-z])/g,(d,a)=>a.toUpperCase()),n[e]=f.value}return n}async function b(i,n={}){const f=[...i.querySelectorAll("*")].filter(e=>_(e.tagName));for(const e of f){const d=e.tagName.toLowerCase();try{const a=v.getComponentLoader(d);if(!a)continue;const m=(await a())?.init;if(typeof m!="function")continue;const c=q(e);console.log(c,"changing...");const t=await m({...n,props:c});if(!t)continue;if(t.store?.state)for(const[o,s]of Object.entries(c))typeof t.store.state[o]>"u"&&t.store.setState(o,s);w.bindPropsToStore(t),p.watchEffect({props:c,store:t.store,callback:({props:o,state:s})=>{for(const[l,g]of Object.entries(o))console.log(c,o,l,g,".............."),typeof s[l]>"u"&&t.store.setState(l,g);typeof t.onPropsChanged=="function"&&t.onPropsChanged({props:o,state:s})}});const h=document.createElement("div");h.innerHTML=`<div>${t.template??""}</div>`;const r=h.firstElementChild;if(!r)continue;const u={...n,...t,props:c,bindings:t.bindings||{}};t.store&&p.setupReactivity(t.store,r),await C.hydrateComponent(r,u);for(const o of Array.from(e.children))if(o.tagName==="TEMPLATE"){const s=o.getAttribute("slot"),l=s?r.querySelector(`slot[name="${s}"]`):r.querySelector("slot:not([name])");l&&l.replaceWith(o.content.cloneNode(!0))}await b(r,u);const y=Array.from(r.children);e.replaceWith(...y),y.forEach(o=>{t.store&&p.setupReactivity(t.store,o)}),typeof t.onMount=="function"&&requestAnimationFrame(()=>{t.onMount?.({...u})})}catch(a){console.warn(`Failed to load component <${d}>`,a)}}}exports.resolveChildComponents=b;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(c){const s=new Map,i=t=>{(s.get(t)||[]).forEach(o=>o(a[t]))},e={...c},a=new Proxy(e,{get(t,n,o){return typeof n=="string"&&n in t?t[n]:Reflect.get(t,n,o)},set(t,n,o,r){if(typeof n=="string"&&n in t){const u=n;return t[u]!==o&&(t[u]=o,i(u)),!0}return Reflect.set(t,n,o,r)}});return{state:a,setState(t,n){a[t]=n},subscribe(t,n){s.has(t)||s.set(t,[]),s.get(t).push(n),n(a[t])}}}function g(c={},s){const i=new Map,e=(r,u)=>{(i.get(r)||[]).forEach(f=>f(u))},a={...s,...c},t=new Proxy(a,{set(r,u,f,d){if(console.log(d),typeof u=="string"&&Object.prototype.hasOwnProperty.call(r,u)){const b=u;r[b]!==f&&(r[b]=f,e(b,f))}return!0}}),n=(r,u)=>{i.has(r)||i.set(r,[]),i.get(r).push(u),u(t[r])},o={};for(const r of Object.keys(t))o[r]=u=>(u!==void 0&&(t[r]=u),t[r]);return{state:t,subscribe:n,bindings:o}}function S(c){document.querySelectorAll("[data-bind], [data-model]").forEach(s=>{const i=s.getAttribute("data-bind")||s.getAttribute("data-model");i&&(s.addEventListener("input",e=>{const a=e.target;c.state[i]=a.value}),c.subscribe(i,e=>{s.value!==e&&(s.value=e)}))}),document.querySelectorAll("[data-bind-text]").forEach(s=>{const i=s.getAttribute("data-bind-text");i&&c.subscribe(i,e=>{s.textContent=e})})}function h(c,s=document){const i=e=>s.querySelectorAll(e);i("[data-bind], [data-model]").forEach(e=>{const a=e.getAttribute("data-bind")||e.getAttribute("data-model");a&&(e.addEventListener("input",t=>{const n=t.target;c.setState(a,n.value)}),c.subscribe(a,t=>{e.value!==t&&(e.value=t??"")}))}),i("[data-bind-text]").forEach(e=>{const a=e.getAttribute("data-bind-text");a&&c.subscribe(a,t=>{e.textContent=t??""})}),i("[data-bind-attr]").forEach(e=>{(e.getAttribute("data-bind-attr")?.split(",")??[]).forEach(t=>{const[n,o]=t.trim().split(":").map(r=>r.trim());c.subscribe(o,r=>e.setAttribute(n,r))})})}function l({props:c={},store:s,callback:i}){if(!s||typeof i!="function")return;let e=JSON.stringify(c),a=JSON.stringify(s.state);const t=()=>{const n=JSON.stringify(c),o=JSON.stringify(s.state);(n!==e||o!==a)&&(e=n,a=o,i({props:c,state:s.state}))};Object.keys(s.state).forEach(n=>{s.subscribe(n,t)}),i({props:c,state:s.state})}exports.bind=S;exports.setupReactivity=h;exports.usePropsStore=g;exports.useStore=y;exports.watchEffect=l;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../hooks/basic.js");async function g(o,d={}){if(!o||o instanceof HTMLElement&&o.dataset.hydrated==="true")return;o.dataset.hydrated="true";const{store:f,bindings:s={},effects:u=[],actions:p={},props:e={},onPropsChange:r}=d;console.log("[hydrateComponent] Hydrating element:",o.tagName,{props:e}),f&&h.setupReactivity(f,o);for(const t of u)typeof t=="function"&&await t({element:o,context:d});if(o.querySelectorAll("[data-bind-text]").forEach(t=>{const n=t.dataset.bindText,a=s[n];typeof a=="function"&&(t.textContent=a())}),o.querySelectorAll("[data-bind-html]").forEach(t=>{const n=t.dataset.bindHtml,a=s[n];typeof a=="function"&&(t.innerHTML=a())}),o.querySelectorAll("[data-model]").forEach(t=>{const n=t.dataset.model,a=s[n];if(typeof a=="function"){const c=a();t.value!==c&&(t.value=c),t.addEventListener("input",i=>{const y=i.target;a(y.value),typeof r=="function"&&r({props:e,element:o,changed:{[n]:y.value}})})}}),o.querySelectorAll("[data-action]").forEach(t=>{const n=t.dataset.action,a=t.dataset.eventType||"click",c=p[n];typeof c=="function"&&t.addEventListener(a,i=>{i.preventDefault(),c({event:i,element:t,dataset:{...t.dataset},props:e,store:f})})}),typeof r=="function")try{await r({props:e,element:o,changed:e})}catch(t){console.warn("[hydrateComponent] onPropsChange error:",t)}}exports.hydrateComponent=g;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=new Map;function o(n,t){e.set(n,{lazy:t})}exports.componentRegistry=e;exports.defineComponent=o;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../vite-env.d-D9PmDmJR.cjs");exports.bindPropsToStore=e.bindPropsToStore;exports.getNestedValue=e.getNestedValue;exports.loadModule=e.loadModule;exports.setNestedValue=e.setNestedValue;exports.syncStoreAndProps=e.syncStoreAndProps;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=new Map;function o(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function a(e,n){const r=o(e);t.set(r,n)}function c(e){const n=o(e);if(t.has(n))return t.get(n)}exports.defineComponent=a;exports.getComponentLoader=c;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function f(c,e,r){c.textContent=typeof e=="function"?e():e}function d(c,e={}){const r=Object.keys(e);r.forEach(n=>{const t=c.querySelector(`[data-ref="${n}"]`);t&&f(t,e[n])}),r.forEach(n=>{const t=e[n];typeof t?.subscribe!="function"||typeof t?.peek!="function"||(c.querySelectorAll(`[data-bind="${n}"]`).forEach(i=>{i.textContent=t.peek(),t.subscribe(s=>i.textContent=s)}),c.querySelectorAll("[data-bind-attr]").forEach(i=>{(i.getAttribute("data-bind-attr")?.split(",")||[]).forEach(o=>{const[a,b]=o.trim().split(":");b===n&&(i.setAttribute(a,t.peek()),t.subscribe(u=>i.setAttribute(a,u)))})}))})}exports.hydrateElmentAttibutesBindings=d;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./basic-C1TNk-WP.cjs");async function g(a,d={}){if(!a||a instanceof HTMLElement&&a.dataset.hydrated==="true")return;a.dataset.hydrated="true";const{store:f,bindings:s={},effects:u=[],actions:p={},props:e={},onPropsChange:r}=d;console.log("[hydrateComponent] Hydrating element:",a.tagName,{props:e}),f&&h.setupReactivity(f,a);for(const t of u)typeof t=="function"&&await t({element:a,context:d});if(a.querySelectorAll("[data-bind-text]").forEach(t=>{const n=t.dataset.bindText,o=s[n];typeof o=="function"&&(t.textContent=o())}),a.querySelectorAll("[data-bind-html]").forEach(t=>{const n=t.dataset.bindHtml,o=s[n];typeof o=="function"&&(t.innerHTML=o())}),a.querySelectorAll("[data-model]").forEach(t=>{const n=t.dataset.model,o=s[n];if(typeof o=="function"){const c=o();t.value!==c&&(t.value=c),t.addEventListener("input",i=>{const y=i.target;o(y.value),typeof r=="function"&&r({props:e,element:a,changed:{[n]:y.value}})})}}),a.querySelectorAll("[data-action]").forEach(t=>{const n=t.dataset.action,o=t.dataset.eventType||"click",c=p[n];typeof c=="function"&&t.addEventListener(o,i=>{i.preventDefault(),c({event:i,element:t,dataset:{...t.dataset},props:e,store:f})})}),typeof r=="function")try{await r({props:e,element:a,changed:e})}catch(t){console.warn("[hydrateComponent] onPropsChange error:",t)}}exports.hydrateComponent=g;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./index-ClTbtigK.cjs");function i(e,n){return n.split(".").reduce((o,r)=>o?.[r],e)}function l(e,n,o){const r=n.split("."),s=r.pop();if(!s)return;const u=r.reduce((t,a)=>(t[a]===void 0&&(t[a]={}),t[a]),e);u[s]=o}function p(e,n,o){document.querySelectorAll(`[data-model="${e}"]`).forEach(s=>{const u=i(n,e)??"";s.value!==u&&(s.value=u);const t=a=>{const d=a.target.value;l(n,e,d),o({...n})};s.removeEventListener("input",t),s.addEventListener("input",t)})}function v(e,n,o,r=document){const s=r.querySelectorAll(`[data-model="${e}"]`),u=c.getNestedValue(n(),e);s.forEach(t=>{t.value!==u&&(t.value=u),t.addEventListener("input",a=>{const d=a.target.value;o(d)})})}exports.getDeep=i;exports.hydrateInputs=v;exports.hydrateInputsBindings=p;exports.setDeep=l;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function i(t,e,n){t&&(t.textContent=e(),n(()=>{t.textContent=e()}))}exports.bindText=i;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(r,o){return o.split(".").reduce((t,s)=>t?.[s],r)}function d(r,o,t){const s=o.split("."),i=s.pop(),l=s.reduce((e,n)=>(e[n]=e[n]||{},e[n]),r);i&&(l[i]=t)}function u(r){if(!(!r?.props||!r?.store)){r.bindings||(r.bindings={});for(const o of Object.keys(r.props))o in r.bindings||(r.bindings[o]=t=>(t!==void 0&&(r.store.state[o]=t),r.store.state[o]))}}function m(r,o={},t=3e3){r?.state&&setTimeout(()=>{for(const s in o)s in r.state||(r.state[s]=o[s]);for(const s in r.state)s in o||(o[s]=r.state[s])},t)}const h=async(r,o)=>{const t=Object.assign({"/src/AppRoutes.ts":()=>Promise.resolve().then(()=>require("./AppRoutes-a6uRQLNk.cjs")),"/src/lib/bootstrap.ts":()=>Promise.resolve().then(()=>require("./main-XcPdamVV.cjs")).then(e=>e.bootstrap),"/src/lib/core/bindings/hydrateBindings.ts":()=>Promise.resolve().then(()=>require("./hydrateBindings-DTULgyJo.cjs")),"/src/lib/core/bindings/hydrateInputs.ts":()=>Promise.resolve().then(()=>require("./hydrateInputs-Bl8fvEO4.cjs")),"/src/lib/core/bindings/index.ts":()=>Promise.resolve().then(()=>require("./index-7ceBYcik.cjs")),"/src/lib/core/components/defineComponent.ts":()=>Promise.resolve().then(()=>require("./defineComponent-OpQ17e8W.cjs")),"/src/lib/core/components/renderComponent.ts":()=>Promise.resolve().then(()=>require("./renderComponent-DExUwGPc.cjs")),"/src/lib/core/components/resolveChildComponent.ts":()=>Promise.resolve().then(()=>require("./resolveChildComponent-CWhZpjZT.cjs")),"/src/lib/core/hooks/basic.ts":()=>Promise.resolve().then(()=>require("./basic-C1TNk-WP.cjs")),"/src/lib/core/hydrations/hydrateComponent.ts":()=>Promise.resolve().then(()=>require("./hydrateComponent-BZxCy-8X.cjs")),"/src/lib/core/registry/componentRegistry.ts":()=>Promise.resolve().then(()=>require("./componentRegistry-Ct85XGAk.cjs")),"/src/lib/main.ts":()=>Promise.resolve().then(()=>require("./main-XcPdamVV.cjs")).then(e=>e.main),"/src/lib/routecore.ts":()=>Promise.resolve().then(()=>require("./routecore-wEhaDazD.cjs")),"/src/lib/vite-env.d.ts":()=>Promise.resolve().then(()=>require("./vite-env.d-D9PmDmJR.cjs")).then(e=>e.viteEnv_d),"/src/main.ts":()=>Promise.resolve().then(()=>require("./main-BTdLB0oj.cjs")),"/src/modules/404.ts":()=>Promise.resolve().then(()=>require("./404-Bp5uwYPw.cjs")),"/src/modules/Login/Login.ts":()=>Promise.resolve().then(()=>require("./vite-env.d-D9PmDmJR.cjs")).then(e=>e.Login),"/src/modules/about.ts":()=>Promise.resolve().then(()=>require("./vite-env.d-D9PmDmJR.cjs")).then(e=>e.about),"/src/modules/components/childComponentSample.ts":()=>Promise.resolve().then(()=>require("./vite-env.d-D9PmDmJR.cjs")).then(e=>e.childComponentSample),"/src/modules/contact.ts":()=>Promise.resolve().then(()=>require("./vite-env.d-D9PmDmJR.cjs")).then(e=>e.contact),"/src/modules/dashboard.ts":()=>Promise.resolve().then(()=>require("./vite-env.d-D9PmDmJR.cjs")).then(e=>e.dashboard),"/src/modules/home.ts":()=>Promise.resolve().then(()=>require("./vite-env.d-D9PmDmJR.cjs")).then(e=>e.home),"/src/vite-env.d.ts":()=>Promise.resolve().then(()=>require("./vite-env.d-D9PmDmJR.cjs")).then(e=>e.viteEnv_d$1)});console.log(o);let s=r;s.startsWith("/src")||(s=`/src/${s}`);const l=/\.[jt]s$/.test(s)?[s]:[`${s}.js`,`${s}.ts`];for(const e of l){const n=t[e];if(n)return n()}throw console.error("[Framework] Available modules:",Object.keys(t)),new Error(`[Framework] Cannot find module for path: ${s}`)};exports.bindPropsToStore=u;exports.getNestedValue=c;exports.loadModule=h;exports.setNestedValue=d;exports.syncStoreAndProps=m;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`<div>\r
<h2>Hello <span data-ref="userName"></span>!</h2>\r
\r
<input\r
type="text"\r
placeholder="Enter name"\r
data-model="userName"\r
/>\r
</div>\r
`;exports.default=e;
"use strict";const o=require("./main-XcPdamVV.cjs"),r=require("./AppRoutes-a6uRQLNk.cjs"),t=document.getElementById("app");if(!t)throw new Error("❌ Could not find #app in DOM");o.bootstrapContainers(r.routes).surge(t);
"use strict";const i=require("./defineComponent-OpQ17e8W.cjs"),e=require("./basic-C1TNk-WP.cjs"),r=require("./index-ClTbtigK.cjs"),s=require("./routecore-wEhaDazD.cjs"),t=o=>({surge:n=>{window.addEventListener("hashchange",()=>s.handleHashChange(n,o)),window.addEventListener("DOMContentLoaded",()=>s.handleHashChange(n,o))}}),a=Object.freeze(Object.defineProperty({__proto__:null,bootstrapContainers:t},Symbol.toStringTag,{value:"Module"})),d=Object.freeze(Object.defineProperty({__proto__:null,bind:e.bind,bindPropsToStore:r.bindPropsToStore,bootstrapContainers:t,defineComponent:i.defineComponent,setupReactivity:e.setupReactivity,syncStoreAndProps:r.syncStoreAndProps,usePropsStore:e.usePropsStore,useStore:e.useStore,watchEffect:e.watchEffect},Symbol.toStringTag,{value:"Module"}));exports.bootstrap=a;exports.bootstrapContainers=t;exports.main=d;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./core/components/defineComponent.js"),e=require("./core/hooks/basic.js"),o=require("./vite-env.d-D9PmDmJR.cjs"),r=require("./bootstrap.js");exports.defineComponent=t.defineComponent;exports.bind=e.bind;exports.setupReactivity=e.setupReactivity;exports.usePropsStore=e.usePropsStore;exports.useStore=e.useStore;exports.watchEffect=e.watchEffect;exports.bindPropsToStore=o.bindPropsToStore;exports.syncStoreAndProps=o.syncStoreAndProps;exports.bootstrapContainers=r.bootstrapContainers;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./hydrateComponent-BZxCy-8X.cjs"),a=require("./basic-C1TNk-WP.cjs"),p=require("./index-ClTbtigK.cjs");function m(f,o={}){const e=f(o),i=document.createElement("div"),d=typeof e.template=="string"?e.template:"<div><slot></slot></div>";i.innerHTML=d;const r=i.firstElementChild,s={props:o,...e};if(e.store?.state){for(const[t,n]of Object.entries(o))typeof e.store.state[t]>"u"&&e.store.setState(t,n);p.bindPropsToStore(e),a.watchEffect({props:o,store:e.store,callback:({props:t,state:n})=>{for(const[c,u]of Object.entries(t))typeof n[c]>"u"&&e.store.setState(c,u);typeof e.onPropsChanged=="function"&&e.onPropsChanged({props:t,state:n})}})}return requestAnimationFrame(async()=>{e.store&&a.setupReactivity(e.store,r),await l.hydrateComponent(r,s),typeof e.onMount=="function"&&e.onMount(s)}),r}exports.renderComponent=m;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./hydrateComponent-BZxCy-8X.cjs"),p=require("./basic-C1TNk-WP.cjs"),v=require("./defineComponent-OpQ17e8W.cjs"),w=require("./index-ClTbtigK.cjs"),S=new Set(["html","head","body","base","link","meta","style","title","address","article","aside","footer","header","h1","h2","h3","h4","h5","main","nav","section","div","span","a","p","ul","li","ol","table","thead","tbody","tr","th","td","form","input","button","select","option","textarea","label","fieldset","legend","script","noscript","template","slot","img","video","audio","canvas","iframe","strong","em","b","i","u","small","br","hr"]);function q(s){const n=s.toLowerCase();return!S.has(n)&&(n.includes("-")||/[A-Z]/.test(s))}function A(s){const n={};for(const f of Array.from(s.attributes)){let e=f.name;e.startsWith(":")&&(e=e.slice(1)),e=e.replace(/-([a-z])/g,(d,a)=>a.toUpperCase()),n[e]=f.value}return n}async function b(s,n={}){const f=[...s.querySelectorAll("*")].filter(e=>q(e.tagName));for(const e of f){const d=e.tagName.toLowerCase();try{const a=v.getComponentLoader(d);if(!a)continue;const m=(await a())?.init;if(typeof m!="function")continue;const c=A(e);console.log(c,"changing...");const t=await m({...n,props:c});if(!t)continue;if(t.store?.state)for(const[o,i]of Object.entries(c))typeof t.store.state[o]>"u"&&t.store.setState(o,i);w.bindPropsToStore(t),p.watchEffect({props:c,store:t.store,callback:({props:o,state:i})=>{for(const[l,g]of Object.entries(o))console.log(c,o,l,g,".............."),typeof i[l]>"u"&&t.store.setState(l,g);typeof t.onPropsChanged=="function"&&t.onPropsChanged({props:o,state:i})}});const h=document.createElement("div");h.innerHTML=`<div>${t.template??""}</div>`;const r=h.firstElementChild;if(!r)continue;const u={...n,...t,props:c,bindings:t.bindings||{}};t.store&&p.setupReactivity(t.store,r),await C.hydrateComponent(r,u);for(const o of Array.from(e.children))if(o.tagName==="TEMPLATE"){const i=o.getAttribute("slot"),l=i?r.querySelector(`slot[name="${i}"]`):r.querySelector("slot:not([name])");l&&l.replaceWith(o.content.cloneNode(!0))}await b(r,u);const y=Array.from(r.children);e.replaceWith(...y),y.forEach(o=>{t.store&&p.setupReactivity(t.store,o)}),typeof t.onMount=="function"&&requestAnimationFrame(()=>{t.onMount?.({...u})})}catch(a){console.warn(`Failed to load component <${d}>`,a)}}}exports.resolveChildComponents=b;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./hydrateComponent-BZxCy-8X.cjs"),P=require("./basic-C1TNk-WP.cjs"),T=require("./resolveChildComponent-CWhZpjZT.cjs"),D=require("./index-ClTbtigK.cjs"),$=new Set,p="home";let M=null;console.log(M);function F(){const e=decodeURIComponent(location.hash.slice(1)),[t=p,s=""]=e.split("?"),r=Object.fromEntries(new URLSearchParams(s));return{path:t,params:r}}function O(e,t){const s=c=>{for(const o of t){if(typeof o.path=="string"&&o.path===c)return{route:o,match:null,params:{}};if(typeof o.path=="string"&&o.path.includes(":")){const l=[],i=o.path.split("/").map(u=>u.startsWith(":")?(l.push(u.slice(1)),"([^/]+)"):u).join("/"),d=new RegExp(`^${i}$`),a=c.match(d);if(a){const u=Object.fromEntries(l.map((C,f)=>[C,a[f+1]]));return{route:o,match:a,params:u}}}if(o.path instanceof RegExp){const l=c.match(o.path);if(l)return{route:o,match:l,params:{}}}}return null};let r=s(e);if(r)return r;if(e.endsWith("/")){for(const c of[`${e}index`,`${e}home`])if(r=s(c),r)return r}const n=t.find(c=>c.path==="*");return n?{route:n,match:null,params:{}}:null}function j(e,t){if(!e||!t){console.warn("shallowDiffAndPatch: parent or newChildren is null/undefined");return}const s=Array.from(e.children),r=Array.from(t);for(let n=0;n<r.length;n++){const c=r[n],o=s[n];o?c.isEqualNode(o)||e.replaceChild(c,o):e.appendChild(c)}for(let n=r.length;n<s.length;n++)s[n].remove()}function v(e){const t=document.createElement("div");return t.innerHTML=e,t}function w(e,t){((r,n)=>{r.querySelectorAll("slot[name]").forEach(o=>{const l=o.getAttribute("name"),i=n.querySelector(`template[slot="${l}"]`);if(i){const a=i.content.cloneNode(!0);w(a,n),o.replaceWith(a);return}const d=n.querySelector(`[slot="${l}"]:not(template)`);d&&o.replaceWith(d.cloneNode(!0))});const c=r.querySelector("slot:not([name])");if(c){const o=n.querySelector("template:not([slot])");if(o){const i=o.content.cloneNode(!0);w(i,n),c.replaceWith(i);return}const l=[...n.children].filter(i=>i.tagName!=="TEMPLATE"&&!i.hasAttribute("slot"));l.length>0&&c.replaceWith(...l.map(i=>i.cloneNode(!0)))}})(e,t)}function k(e,t){const s=document.getElementById(t);s&&s.remove();const r=document.createElement("style");r.id=t,r.textContent=e,document.head.appendChild(r)}async function x({app:e,route:t,viewHTML:s,layoutHTML:r,params:n,match:c=null}){const o={...n},l={app:e,params:n,props:o},i=v(s);let d=i,a={},u;if(console.log(c),r){const f=v(r);w(f,i),d=f}if(t.styles||t.style){const f=Array.isArray(t.styles||t.style)?t.styles||t.style:[t.style];for(const y of f){const m=await(await fetch(y)).text();k(m,`scoped-style-${t.path}`)}}await(async()=>{const f=d.cloneNode(!0);if(t.script||t.scripts){const h=Array.isArray(t.scripts||t.script)?t.scripts||t.script:[t.script];if(u=await D.loadModule(`${h[0]}`,t.scriptBase||"modules"),typeof u.init=="function"){a=await u.init({...l})||{};const{template:m}=a;if(m&&typeof m=="string"){const E=document.createElement("div");E.innerHTML=m;for(const g of[...E.children]){const b=g.getAttribute("slot")||null;await q.hydrateComponent(g,{...l,...a,props:{...o}});const A=b?f.querySelector(`slot[name="${b}"]`):f.querySelector("slot:not([name])");A&&A.replaceWith(g)}}requestAnimationFrame(()=>{a.onMount?.({...l,...a,props:o}),a.store&&P.setupReactivity(a.store,e),M=()=>a.onDestroy?.()})}}await q.hydrateComponent(f,{...l,...a,props:{...o}}),await T.resolveChildComponents(f,{...l,...a,props:{...o}}),requestAnimationFrame(()=>{if(!e||!f||!f.children){console.warn("[hydrate] Skipping patch - app or domClone is null");return}j(e,f.children),Array.from(e.children).forEach(h=>{a.store&&P.setupReactivity(a.store,h)})});const y=new DOMParser().parseFromString(s,"text/html");for(const h of y.querySelectorAll("script")){const m=document.createElement("script");if(h.src){if($.has(h.src))continue;m.src=h.src,$.add(h.src)}else m.textContent=h.textContent;h.type&&(m.type=h.type),document.body.appendChild(m)}t.onLoad?.()})()}function R(e,t){if(location.hash==="#"){history.replaceState(null,"",`#${p}`);return}const{path:s,params:r}=F(),n=r.queryParams;let c=s;(!location.hash||s===p)&&(c=p,location.hash||history.replaceState(null,"",`#${p}`));const o=O(c,t);if(o){const{route:l,match:i,params:d}=o,a={...n||{},...d||{}};L(e,l,a,i)}else e.innerHTML="<h2>404 - Not Found</h2>"}async function N(e){const t=e.replace(/^\/+/,""),s=Object.assign({"/src/modules/Login/components/Login.html":()=>Promise.resolve().then(()=>require("./Login-B1Ntlzgu.cjs")).then(n=>n.default)}),r=Object.keys(s).find(n=>n.endsWith(`/${t}`)||n.endsWith(t));if(!r)throw new Error(`[fallbackImportFromSrc] '${e}' not found in src`);try{return await s[r]()}catch(n){throw new Error(`[fallbackImportFromSrc] Failed to import '${e}' from '${r}': ${n.message}`)}}async function S(e){if(!e)return"";if(typeof e=="function"){const t=await e();return typeof t=="string"?t:t?.default||""}if(typeof e=="string"){if(/<\/?[a-z][\s\S]*>/i.test(e.trim()))return e;try{const s=await fetch(e);if(!s.ok)throw new Error("Not found in public");return await s.text()}catch{try{return await N(e)}catch(s){throw console.error(s.message),new Error(`[resolveContent] Cannot resolve: ${e}`)}}}return""}async function L(e,t,s={},r=null){try{window.__currentDestroy?.();const[n,c]=await Promise.all([S(t.view),S(t.layout)]);await x({app:e,route:t,viewHTML:n,layoutHTML:c,params:s,match:r}),console.log("running...")}catch(n){console.error("Render error:",n),e.innerHTML="<h2>Error loading page</h2>"}}function W(e=document.getElementById("app"),t){R(e,t)}exports.fallbackImportFromSrc=N;exports.handleHashChange=W;exports.handleRoute=R;exports.loadPage=L;exports.resolveContent=S;exports.slotAwareRender=x;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("./core/hydrations/hydrateComponent.js"),P=require("./core/hooks/basic.js"),T=require("./core/components/resolveChildComponent.js"),D=require("./vite-env.d-D9PmDmJR.cjs"),$=new Set,p="home";let M=null;console.log(M);function F(){const e=decodeURIComponent(location.hash.slice(1)),[t=p,s=""]=e.split("?"),r=Object.fromEntries(new URLSearchParams(s));return{path:t,params:r}}function O(e,t){const s=c=>{for(const o of t){if(typeof o.path=="string"&&o.path===c)return{route:o,match:null,params:{}};if(typeof o.path=="string"&&o.path.includes(":")){const l=[],i=o.path.split("/").map(u=>u.startsWith(":")?(l.push(u.slice(1)),"([^/]+)"):u).join("/"),d=new RegExp(`^${i}$`),a=c.match(d);if(a){const u=Object.fromEntries(l.map((C,f)=>[C,a[f+1]]));return{route:o,match:a,params:u}}}if(o.path instanceof RegExp){const l=c.match(o.path);if(l)return{route:o,match:l,params:{}}}}return null};let r=s(e);if(r)return r;if(e.endsWith("/")){for(const c of[`${e}index`,`${e}home`])if(r=s(c),r)return r}const n=t.find(c=>c.path==="*");return n?{route:n,match:null,params:{}}:null}function _(e,t){if(!e||!t){console.warn("shallowDiffAndPatch: parent or newChildren is null/undefined");return}const s=Array.from(e.children),r=Array.from(t);for(let n=0;n<r.length;n++){const c=r[n],o=s[n];o?c.isEqualNode(o)||e.replaceChild(c,o):e.appendChild(c)}for(let n=r.length;n<s.length;n++)s[n].remove()}function v(e){const t=document.createElement("div");return t.innerHTML=e,t}function w(e,t){((r,n)=>{r.querySelectorAll("slot[name]").forEach(o=>{const l=o.getAttribute("name"),i=n.querySelector(`template[slot="${l}"]`);if(i){const a=i.content.cloneNode(!0);w(a,n),o.replaceWith(a);return}const d=n.querySelector(`[slot="${l}"]:not(template)`);d&&o.replaceWith(d.cloneNode(!0))});const c=r.querySelector("slot:not([name])");if(c){const o=n.querySelector("template:not([slot])");if(o){const i=o.content.cloneNode(!0);w(i,n),c.replaceWith(i);return}const l=[...n.children].filter(i=>i.tagName!=="TEMPLATE"&&!i.hasAttribute("slot"));l.length>0&&c.replaceWith(...l.map(i=>i.cloneNode(!0)))}})(e,t)}function j(e,t){const s=document.getElementById(t);s&&s.remove();const r=document.createElement("style");r.id=t,r.textContent=e,document.head.appendChild(r)}async function x({app:e,route:t,viewHTML:s,layoutHTML:r,params:n,match:c=null}){const o={...n},l={app:e,params:n,props:o},i=v(s);let d=i,a={},u;if(console.log(c),r){const f=v(r);w(f,i),d=f}if(t.styles||t.style){const f=Array.isArray(t.styles||t.style)?t.styles||t.style:[t.style];for(const y of f){const m=await(await fetch(y)).text();j(m,`scoped-style-${t.path}`)}}await(async()=>{const f=d.cloneNode(!0);if(t.script||t.scripts){const h=Array.isArray(t.scripts||t.script)?t.scripts||t.script:[t.script];if(u=await D.loadModule(`${h[0]}`,t.scriptBase||"modules"),typeof u.init=="function"){a=await u.init({...l})||{};const{template:m}=a;if(m&&typeof m=="string"){const E=document.createElement("div");E.innerHTML=m;for(const g of[...E.children]){const b=g.getAttribute("slot")||null;await q.hydrateComponent(g,{...l,...a,props:{...o}});const A=b?f.querySelector(`slot[name="${b}"]`):f.querySelector("slot:not([name])");A&&A.replaceWith(g)}}requestAnimationFrame(()=>{a.onMount?.({...l,...a,props:o}),a.store&&P.setupReactivity(a.store,e),M=()=>a.onDestroy?.()})}}await q.hydrateComponent(f,{...l,...a,props:{...o}}),await T.resolveChildComponents(f,{...l,...a,props:{...o}}),requestAnimationFrame(()=>{if(!e||!f||!f.children){console.warn("[hydrate] Skipping patch - app or domClone is null");return}_(e,f.children),Array.from(e.children).forEach(h=>{a.store&&P.setupReactivity(a.store,h)})});const y=new DOMParser().parseFromString(s,"text/html");for(const h of y.querySelectorAll("script")){const m=document.createElement("script");if(h.src){if($.has(h.src))continue;m.src=h.src,$.add(h.src)}else m.textContent=h.textContent;h.type&&(m.type=h.type),document.body.appendChild(m)}t.onLoad?.()})()}function R(e,t){if(location.hash==="#"){history.replaceState(null,"",`#${p}`);return}const{path:s,params:r}=F(),n=r.queryParams;let c=s;(!location.hash||s===p)&&(c=p,location.hash||history.replaceState(null,"",`#${p}`));const o=O(c,t);if(o){const{route:l,match:i,params:d}=o,a={...n||{},...d||{}};L(e,l,a,i)}else e.innerHTML="<h2>404 - Not Found</h2>"}async function N(e){const t=e.replace(/^\/+/,""),s=Object.assign({"/src/modules/Login/components/Login.html":()=>Promise.resolve().then(()=>require("./Login-B1Ntlzgu.cjs")).then(n=>n.default)}),r=Object.keys(s).find(n=>n.endsWith(`/${t}`)||n.endsWith(t));if(!r)throw new Error(`[fallbackImportFromSrc] '${e}' not found in src`);try{return await s[r]()}catch(n){throw new Error(`[fallbackImportFromSrc] Failed to import '${e}' from '${r}': ${n.message}`)}}async function S(e){if(!e)return"";if(typeof e=="function"){const t=await e();return typeof t=="string"?t:t?.default||""}if(typeof e=="string"){if(/<\/?[a-z][\s\S]*>/i.test(e.trim()))return e;try{const s=await fetch(e);if(!s.ok)throw new Error("Not found in public");return await s.text()}catch{try{return await N(e)}catch(s){throw console.error(s.message),new Error(`[resolveContent] Cannot resolve: ${e}`)}}}return""}async function L(e,t,s={},r=null){try{window.__currentDestroy?.();const[n,c]=await Promise.all([S(t.view),S(t.layout)]);await x({app:e,route:t,viewHTML:n,layoutHTML:c,params:s,match:r}),console.log("running...")}catch(n){console.error("Render error:",n),e.innerHTML="<h2>Error loading page</h2>"}}function k(e=document.getElementById("app"),t){R(e,t)}exports.fallbackImportFromSrc=N;exports.handleHashChange=k;exports.handleRoute=R;exports.loadPage=L;exports.resolveContent=S;exports.slotAwareRender=x;
"use strict";function p(e,r){return r.split(".").reduce((t,o)=>t?.[o],e)}function f(e,r,t){const o=r.split("."),i=o.pop(),l=o.reduce((s,n)=>(s[n]=s[n]||{},s[n]),e);i&&(l[i]=t)}function P(e){if(!(!e?.props||!e?.store)){e.bindings||(e.bindings={});for(const r of Object.keys(e.props))r in e.bindings||(e.bindings[r]=t=>(t!==void 0&&(e.store.state[r]=t),e.store.state[r]))}}function _(e,r={},t=3e3){e?.state&&setTimeout(()=>{for(const o in r)o in e.state||(e.state[o]=r[o]);for(const o in e.state)o in r||(r[o]=e.state[o])},t)}const g=async(e,r)=>{const t=Object.assign({"/src/AppRoutes.ts":()=>Promise.resolve().then(()=>require("./AppRoutes-a6uRQLNk.cjs")),"/src/lib/bootstrap.ts":()=>Promise.resolve().then(()=>require("./main-XcPdamVV.cjs")).then(s=>s.bootstrap),"/src/lib/core/bindings/hydrateBindings.ts":()=>Promise.resolve().then(()=>require("./hydrateBindings-DTULgyJo.cjs")),"/src/lib/core/bindings/hydrateInputs.ts":()=>Promise.resolve().then(()=>require("./hydrateInputs-Bl8fvEO4.cjs")),"/src/lib/core/bindings/index.ts":()=>Promise.resolve().then(()=>require("./index-7ceBYcik.cjs")),"/src/lib/core/components/defineComponent.ts":()=>Promise.resolve().then(()=>require("./defineComponent-OpQ17e8W.cjs")),"/src/lib/core/components/renderComponent.ts":()=>Promise.resolve().then(()=>require("./renderComponent-DExUwGPc.cjs")),"/src/lib/core/components/resolveChildComponent.ts":()=>Promise.resolve().then(()=>require("./resolveChildComponent-CWhZpjZT.cjs")),"/src/lib/core/hooks/basic.ts":()=>Promise.resolve().then(()=>require("./basic-C1TNk-WP.cjs")),"/src/lib/core/hydrations/hydrateComponent.ts":()=>Promise.resolve().then(()=>require("./hydrateComponent-BZxCy-8X.cjs")),"/src/lib/core/registry/componentRegistry.ts":()=>Promise.resolve().then(()=>require("./componentRegistry-Ct85XGAk.cjs")),"/src/lib/core/utils/index.ts":()=>Promise.resolve().then(()=>require("./index-ClTbtigK.cjs")),"/src/lib/main.ts":()=>Promise.resolve().then(()=>require("./main-XcPdamVV.cjs")).then(s=>s.main),"/src/lib/routecore.ts":()=>Promise.resolve().then(()=>require("./routecore-wEhaDazD.cjs")),"/src/lib/vite-env.d.ts":()=>Promise.resolve().then(()=>c),"/src/main.ts":()=>Promise.resolve().then(()=>require("./main-BTdLB0oj.cjs")),"/src/modules/404.ts":()=>Promise.resolve().then(()=>require("./404-Bp5uwYPw.cjs")),"/src/modules/Login/Login.ts":()=>Promise.resolve().then(()=>d),"/src/modules/about.ts":()=>Promise.resolve().then(()=>u),"/src/modules/components/childComponentSample.ts":()=>Promise.resolve().then(()=>m),"/src/modules/contact.ts":()=>Promise.resolve().then(()=>a),"/src/modules/dashboard.ts":()=>Promise.resolve().then(()=>b),"/src/modules/home.ts":()=>Promise.resolve().then(()=>h),"/src/vite-env.d.ts":()=>Promise.resolve().then(()=>v)});console.log(r);let o=e;o.startsWith("/src")||(o=`/src/${o}`);const l=/\.[jt]s$/.test(o)?[o]:[`${o}.js`,`${o}.ts`];for(const s of l){const n=t[s];if(n)return n()}throw console.error("[Framework] Available modules:",Object.keys(t)),new Error(`[Framework] Cannot find module for path: ${o}`)},c=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),d=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),u=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),m=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),a=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),b=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),h=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),v=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.Login=d;exports.about=u;exports.bindPropsToStore=P;exports.childComponentSample=m;exports.contact=a;exports.dashboard=b;exports.getNestedValue=p;exports.home=h;exports.loadModule=g;exports.setNestedValue=f;exports.syncStoreAndProps=_;exports.viteEnv_d=c;exports.viteEnv_d$1=v;
function n(o) {
return console.log("Route params:", o), alert("Page not found"), {};
}
export {
n as init
};
let i = !1;
function n(o) {
return i = o, i;
}
async function r(o) {
try {
const e = await fetch(o);
if (!e.ok) throw new Error("Not found in public");
return await e.text();
} catch {
console.warn(`[TemplateLoader] Falling back to src for: ${o}`);
const t = /* @__PURE__ */ Object.assign({
"/src/modules/Login/components/Login.html": () => import("./Login-DaokiISj.js").then((l) => l.default)
}), a = o.split("/").pop() || "", s = Object.keys(t).find(
(l) => l.endsWith(`/${a}`)
);
if (!s)
throw new Error(`Template '${a}' not found in src fallback`);
return t[s]();
}
}
const u = [
{
path: "home",
view: () => r("./views/home.html"),
onLoad: () => console.log("Home loaded"),
layout: "./views/layouts/default.html",
// scriptBase: 'src/modules',
scripts: ["modules/home"]
// accepts array of string
},
{
path: "login",
view: "./views/login.html",
onLoad: () => console.log("Login loaded"),
layout: "./views/layouts/default.html",
scripts: ["modules/Login/Login"]
// accepts array of string
},
{
path: "profile/:id",
// /^profile\/(\d+)$/,
view: "./views/profile.html",
onLoad: () => console.log("Profile loaded"),
layout: "./views/layouts/default.html",
middleware: async (o) => {
if (console.log(o, ">>>>"), o?.user)
return o.user != "banned";
const e = !!o.user;
return await n(e) ? !0 : (location.hash = "#login", !1);
},
script: ["modules/about"]
// accepts array of string
},
{
path: "about",
view: "./views/about.html",
layout: "./views/layouts/default.html",
middleware: () => (console.log("About middleware ran"), !0),
onLoad: () => console.log("About page is now visible"),
script: "modules/about"
},
{
path: "contact",
view: "./views/contact.html",
layout: "./views/layouts/default.html",
middleware: () => (console.log("Checking something before showing contact"), confirm("Do you really want to view the contact page?"))
},
/// test life cycle
{
path: "dashboard",
view: "./views/dashboard.html",
script: "modules/dashboard",
layout: "./views/layouts/dashboard.html"
// todo add route beforeEnter and beforeLeave
// beforeEnter: (params) => {
// if (!checkLoginStatus(false)) {
// navigate('login');
// return false;
// }
// return true;
// },
},
{
path: "*",
view: "./views/404.html",
script: "modules/404"
}
];
export {
r as loadTemplate,
u as routes
};
function y(c) {
const s = /* @__PURE__ */ new Map(), i = (t) => {
(s.get(t) || []).forEach((o) => o(a[t]));
}, e = { ...c }, a = new Proxy(e, {
get(t, n, o) {
return typeof n == "string" && n in t ? t[n] : Reflect.get(t, n, o);
},
set(t, n, o, r) {
if (typeof n == "string" && n in t) {
const u = n;
return t[u] !== o && (t[u] = o, i(u)), !0;
}
return Reflect.set(t, n, o, r);
}
});
return {
state: a,
setState(t, n) {
a[t] = n;
},
subscribe(t, n) {
s.has(t) || s.set(t, []), s.get(t).push(n), n(a[t]);
}
};
}
function g(c = {}, s) {
const i = /* @__PURE__ */ new Map(), e = (r, u) => {
(i.get(r) || []).forEach((f) => f(u));
}, a = { ...s, ...c }, t = new Proxy(a, {
set(r, u, f, d) {
if (console.log(d), typeof u == "string" && Object.prototype.hasOwnProperty.call(r, u)) {
const b = u;
r[b] !== f && (r[b] = f, e(b, f));
}
return !0;
}
}), n = (r, u) => {
i.has(r) || i.set(r, []), i.get(r).push(u), u(t[r]);
}, o = {};
for (const r of Object.keys(t))
o[r] = (u) => (u !== void 0 && (t[r] = u), t[r]);
return { state: t, subscribe: n, bindings: o };
}
function h(c) {
document.querySelectorAll("[data-bind], [data-model]").forEach((s) => {
const i = s.getAttribute("data-bind") || s.getAttribute("data-model");
i && (s.addEventListener("input", (e) => {
const a = e.target;
c.state[i] = a.value;
}), c.subscribe(i, (e) => {
s.value !== e && (s.value = e);
}));
}), document.querySelectorAll("[data-bind-text]").forEach((s) => {
const i = s.getAttribute("data-bind-text");
i && c.subscribe(i, (e) => {
s.textContent = e;
});
});
}
function S(c, s = document) {
const i = (e) => s.querySelectorAll(e);
i("[data-bind], [data-model]").forEach((e) => {
const a = e.getAttribute("data-bind") || e.getAttribute("data-model");
a && (e.addEventListener("input", (t) => {
const n = t.target;
c.setState(a, n.value);
}), c.subscribe(a, (t) => {
e.value !== t && (e.value = t ?? "");
}));
}), i("[data-bind-text]").forEach((e) => {
const a = e.getAttribute("data-bind-text");
a && c.subscribe(a, (t) => {
e.textContent = t ?? "";
});
}), i("[data-bind-attr]").forEach((e) => {
(e.getAttribute("data-bind-attr")?.split(",") ?? []).forEach((t) => {
const [n, o] = t.trim().split(":").map((r) => r.trim());
c.subscribe(o, (r) => e.setAttribute(n, r));
});
});
}
function l({
props: c = {},
store: s,
callback: i
}) {
if (!s || typeof i != "function") return;
let e = JSON.stringify(c), a = JSON.stringify(s.state);
const t = () => {
const n = JSON.stringify(c), o = JSON.stringify(s.state);
(n !== e || o !== a) && (e = n, a = o, i({ props: c, state: s.state }));
};
Object.keys(s.state).forEach((n) => {
s.subscribe(n, t);
}), i({ props: c, state: s.state });
}
export {
h as bind,
S as setupReactivity,
g as usePropsStore,
y as useStore,
l as watchEffect
};
import "./core/components/defineComponent.js";
import "./core/hooks/basic.js";
import "./vite-env.d-rlNtK3Bt.js";
import { handleHashChange as e } from "./routecore.js";
const i = (n) => ({
surge: (t) => {
window.addEventListener(
"hashchange",
() => e(t, n)
), window.addEventListener(
"DOMContentLoaded",
() => e(t, n)
);
}
});
export {
i as bootstrapContainers
};
const o = /* @__PURE__ */ new Map();
function t(n, e) {
o.set(n, { lazy: e });
}
export {
o as componentRegistry,
t as defineComponent
};
function u(c, e, r) {
c.textContent = typeof e == "function" ? e() : e;
}
function d(c, e = {}) {
const r = Object.keys(e);
r.forEach((n) => {
const t = c.querySelector(`[data-ref="${n}"]`);
t && u(t, e[n]);
}), r.forEach((n) => {
const t = e[n];
typeof t?.subscribe != "function" || typeof t?.peek != "function" || (c.querySelectorAll(`[data-bind="${n}"]`).forEach((i) => {
i.textContent = t.peek(), t.subscribe((s) => i.textContent = s);
}), c.querySelectorAll("[data-bind-attr]").forEach((i) => {
(i.getAttribute("data-bind-attr")?.split(",") || []).forEach((o) => {
const [a, b] = o.trim().split(":");
b === n && (i.setAttribute(a, t.peek()), t.subscribe((f) => i.setAttribute(a, f)));
});
}));
});
}
export {
d as hydrateElmentAttibutesBindings
};
import { g as c } from "../../vite-env.d-rlNtK3Bt.js";
function d(e, n) {
return n.split(".").reduce((s, r) => s?.[r], e);
}
function i(e, n, s) {
const r = n.split("."), o = r.pop();
if (!o) return;
const u = r.reduce((t, a) => (t[a] === void 0 && (t[a] = {}), t[a]), e);
u[o] = s;
}
function p(e, n, s) {
document.querySelectorAll(`[data-model="${e}"]`).forEach((o) => {
const u = d(n, e) ?? "";
o.value !== u && (o.value = u);
const t = (a) => {
const l = a.target.value;
i(n, e, l), s({ ...n });
};
o.removeEventListener("input", t), o.addEventListener("input", t);
});
}
function v(e, n, s, r = document) {
const o = r.querySelectorAll(`[data-model="${e}"]`), u = c(n(), e);
o.forEach((t) => {
t.value !== u && (t.value = u), t.addEventListener("input", (a) => {
const l = a.target.value;
s(l);
});
});
}
export {
d as getDeep,
v as hydrateInputs,
p as hydrateInputsBindings,
i as setDeep
};
function o(t, n, e) {
t && (t.textContent = n(), e(() => {
t.textContent = n();
}));
}
export {
o as bindText
};
const t = /* @__PURE__ */ new Map();
function o(e) {
return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
}
function a(e, n) {
const r = o(e);
t.set(r, n);
}
function c(e) {
const n = o(e);
if (t.has(n))
return t.get(n);
}
export {
a as defineComponent,
c as getComponentLoader
};
import { hydrateComponent as p } from "../hydrations/hydrateComponent.js";
import { watchEffect as d, setupReactivity as l } from "../hooks/basic.js";
import { b as u } from "../../vite-env.d-rlNtK3Bt.js";
function b(a, o = {}) {
const t = a(o), i = document.createElement("div"), c = typeof t.template == "string" ? t.template : "<div><slot></slot></div>";
i.innerHTML = c;
const r = i.firstElementChild, s = {
props: o,
...t
};
if (t.store?.state) {
for (const [e, n] of Object.entries(o))
typeof t.store.state[e] > "u" && t.store.setState(e, n);
u(t), d({
props: o,
store: t.store,
callback: ({
props: e,
state: n
}) => {
for (const [f, m] of Object.entries(e))
typeof n[f] > "u" && t.store.setState(f, m);
typeof t.onPropsChanged == "function" && t.onPropsChanged({ props: e, state: n });
}
});
}
return requestAnimationFrame(async () => {
t.store && l(t.store, r), await p(r, s), typeof t.onMount == "function" && t.onMount(s);
}), r;
}
export {
b as renderComponent
};
import { hydrateComponent as b } from "../hydrations/hydrateComponent.js";
import { watchEffect as v, setupReactivity as y } from "../hooks/basic.js";
import { getComponentLoader as C } from "./defineComponent.js";
import { b as w } from "../../vite-env.d-rlNtK3Bt.js";
const A = /* @__PURE__ */ new Set([
"html",
"head",
"body",
"base",
"link",
"meta",
"style",
"title",
"address",
"article",
"aside",
"footer",
"header",
"h1",
"h2",
"h3",
"h4",
"h5",
"main",
"nav",
"section",
"div",
"span",
"a",
"p",
"ul",
"li",
"ol",
"table",
"thead",
"tbody",
"tr",
"th",
"td",
"form",
"input",
"button",
"select",
"option",
"textarea",
"label",
"fieldset",
"legend",
"script",
"noscript",
"template",
"slot",
"img",
"video",
"audio",
"canvas",
"iframe",
"strong",
"em",
"b",
"i",
"u",
"small",
"br",
"hr"
]);
function S(i) {
const n = i.toLowerCase();
return !A.has(n) && (n.includes("-") || /[A-Z]/.test(i));
}
function E(i) {
const n = {};
for (const f of Array.from(i.attributes)) {
let e = f.name;
e.startsWith(":") && (e = e.slice(1)), e = e.replace(/-([a-z])/g, (m, s) => s.toUpperCase()), n[e] = f.value;
}
return n;
}
async function P(i, n = {}) {
const f = [...i.querySelectorAll("*")].filter(
(e) => S(e.tagName)
);
for (const e of f) {
const m = e.tagName.toLowerCase();
try {
const s = C(m);
if (!s) continue;
const p = (await s())?.init;
if (typeof p != "function") continue;
const c = E(e);
console.log(c, "changing...");
const t = await p({
...n,
props: c
});
if (!t) continue;
if (t.store?.state)
for (const [o, a] of Object.entries(c))
typeof t.store.state[o] > "u" && t.store.setState(o, a);
w(t), v({
props: c,
store: t.store,
callback: ({ props: o, state: a }) => {
for (const [l, g] of Object.entries(o))
console.log(c, o, l, g, ".............."), typeof a[l] > "u" && t.store.setState(l, g);
typeof t.onPropsChanged == "function" && t.onPropsChanged({ props: o, state: a });
}
});
const u = document.createElement("div");
u.innerHTML = `<div>${t.template ?? ""}</div>`;
const r = u.firstElementChild;
if (!r) continue;
const d = {
...n,
...t,
props: c,
bindings: t.bindings || {}
};
t.store && y(t.store, r), await b(r, d);
for (const o of Array.from(e.children))
if (o.tagName === "TEMPLATE") {
const a = o.getAttribute("slot"), l = a ? r.querySelector(`slot[name="${a}"]`) : r.querySelector("slot:not([name])");
l && l.replaceWith(o.content.cloneNode(!0));
}
await P(r, d);
const h = Array.from(r.children);
e.replaceWith(...h), h.forEach((o) => {
t.store && y(t.store, o);
}), typeof t.onMount == "function" && requestAnimationFrame(() => {
t.onMount?.({ ...d });
});
} catch (s) {
console.warn(`Failed to load component <${m}>`, s);
}
}
}
export {
P as resolveChildComponents
};
function y(c) {
const s = /* @__PURE__ */ new Map(), i = (t) => {
(s.get(t) || []).forEach((o) => o(a[t]));
}, e = { ...c }, a = new Proxy(e, {
get(t, n, o) {
return typeof n == "string" && n in t ? t[n] : Reflect.get(t, n, o);
},
set(t, n, o, r) {
if (typeof n == "string" && n in t) {
const u = n;
return t[u] !== o && (t[u] = o, i(u)), !0;
}
return Reflect.set(t, n, o, r);
}
});
return {
state: a,
setState(t, n) {
a[t] = n;
},
subscribe(t, n) {
s.has(t) || s.set(t, []), s.get(t).push(n), n(a[t]);
}
};
}
function g(c = {}, s) {
const i = /* @__PURE__ */ new Map(), e = (r, u) => {
(i.get(r) || []).forEach((f) => f(u));
}, a = { ...s, ...c }, t = new Proxy(a, {
set(r, u, f, d) {
if (console.log(d), typeof u == "string" && Object.prototype.hasOwnProperty.call(r, u)) {
const b = u;
r[b] !== f && (r[b] = f, e(b, f));
}
return !0;
}
}), n = (r, u) => {
i.has(r) || i.set(r, []), i.get(r).push(u), u(t[r]);
}, o = {};
for (const r of Object.keys(t))
o[r] = (u) => (u !== void 0 && (t[r] = u), t[r]);
return { state: t, subscribe: n, bindings: o };
}
function h(c) {
document.querySelectorAll("[data-bind], [data-model]").forEach((s) => {
const i = s.getAttribute("data-bind") || s.getAttribute("data-model");
i && (s.addEventListener("input", (e) => {
const a = e.target;
c.state[i] = a.value;
}), c.subscribe(i, (e) => {
s.value !== e && (s.value = e);
}));
}), document.querySelectorAll("[data-bind-text]").forEach((s) => {
const i = s.getAttribute("data-bind-text");
i && c.subscribe(i, (e) => {
s.textContent = e;
});
});
}
function S(c, s = document) {
const i = (e) => s.querySelectorAll(e);
i("[data-bind], [data-model]").forEach((e) => {
const a = e.getAttribute("data-bind") || e.getAttribute("data-model");
a && (e.addEventListener("input", (t) => {
const n = t.target;
c.setState(a, n.value);
}), c.subscribe(a, (t) => {
e.value !== t && (e.value = t ?? "");
}));
}), i("[data-bind-text]").forEach((e) => {
const a = e.getAttribute("data-bind-text");
a && c.subscribe(a, (t) => {
e.textContent = t ?? "";
});
}), i("[data-bind-attr]").forEach((e) => {
(e.getAttribute("data-bind-attr")?.split(",") ?? []).forEach((t) => {
const [n, o] = t.trim().split(":").map((r) => r.trim());
c.subscribe(o, (r) => e.setAttribute(n, r));
});
});
}
function l({
props: c = {},
store: s,
callback: i
}) {
if (!s || typeof i != "function") return;
let e = JSON.stringify(c), a = JSON.stringify(s.state);
const t = () => {
const n = JSON.stringify(c), o = JSON.stringify(s.state);
(n !== e || o !== a) && (e = n, a = o, i({ props: c, state: s.state }));
};
Object.keys(s.state).forEach((n) => {
s.subscribe(n, t);
}), i({ props: c, state: s.state });
}
export {
h as bind,
S as setupReactivity,
g as usePropsStore,
y as useStore,
l as watchEffect
};
import { setupReactivity as h } from "../hooks/basic.js";
async function v(a, d = {}) {
if (!a || a instanceof HTMLElement && a.dataset.hydrated === "true") return;
a.dataset.hydrated = "true";
const {
store: i,
bindings: s = {},
effects: u = [],
actions: p = {},
props: e = {},
onPropsChange: r
} = d;
console.log("[hydrateComponent] Hydrating element:", a.tagName, { props: e }), i && h(i, a);
for (const t of u)
typeof t == "function" && await t({ element: a, context: d });
if (a.querySelectorAll("[data-bind-text]").forEach((t) => {
const n = t.dataset.bindText, o = s[n];
typeof o == "function" && (t.textContent = o());
}), a.querySelectorAll("[data-bind-html]").forEach((t) => {
const n = t.dataset.bindHtml, o = s[n];
typeof o == "function" && (t.innerHTML = o());
}), a.querySelectorAll("[data-model]").forEach((t) => {
const n = t.dataset.model, o = s[n];
if (typeof o == "function") {
const c = o();
t.value !== c && (t.value = c), t.addEventListener("input", (f) => {
const y = f.target;
o(y.value), typeof r == "function" && r({ props: e, element: a, changed: { [n]: y.value } });
});
}
}), a.querySelectorAll("[data-action]").forEach((t) => {
const n = t.dataset.action, o = t.dataset.eventType || "click", c = p[n];
typeof c == "function" && t.addEventListener(o, (f) => {
f.preventDefault(), c({
event: f,
element: t,
dataset: { ...t.dataset },
props: e,
store: i
});
});
}), typeof r == "function")
try {
await r({ props: e, element: a, changed: e });
} catch (t) {
console.warn("[hydrateComponent] onPropsChange error:", t);
}
}
export {
v as hydrateComponent
};
const o = /* @__PURE__ */ new Map();
function t(n, e) {
o.set(n, { lazy: e });
}
export {
o as componentRegistry,
t as defineComponent
};
import { b as a, g as o, l as t, a as d, s as r } from "../../vite-env.d-rlNtK3Bt.js";
export {
a as bindPropsToStore,
o as getNestedValue,
t as loadModule,
d as setNestedValue,
r as syncStoreAndProps
};
const t = /* @__PURE__ */ new Map();
function o(e) {
return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
}
function a(e, n) {
const r = o(e);
t.set(r, n);
}
function c(e) {
const n = o(e);
if (t.has(n))
return t.get(n);
}
export {
a as defineComponent,
c as getComponentLoader
};
function u(c, e, r) {
c.textContent = typeof e == "function" ? e() : e;
}
function d(c, e = {}) {
const r = Object.keys(e);
r.forEach((n) => {
const t = c.querySelector(`[data-ref="${n}"]`);
t && u(t, e[n]);
}), r.forEach((n) => {
const t = e[n];
typeof t?.subscribe != "function" || typeof t?.peek != "function" || (c.querySelectorAll(`[data-bind="${n}"]`).forEach((i) => {
i.textContent = t.peek(), t.subscribe((s) => i.textContent = s);
}), c.querySelectorAll("[data-bind-attr]").forEach((i) => {
(i.getAttribute("data-bind-attr")?.split(",") || []).forEach((o) => {
const [a, b] = o.trim().split(":");
b === n && (i.setAttribute(a, t.peek()), t.subscribe((f) => i.setAttribute(a, f)));
});
}));
});
}
export {
d as hydrateElmentAttibutesBindings
};
import { setupReactivity as h } from "./basic-DD18cb2c.js";
async function v(a, d = {}) {
if (!a || a instanceof HTMLElement && a.dataset.hydrated === "true") return;
a.dataset.hydrated = "true";
const {
store: i,
bindings: s = {},
effects: u = [],
actions: p = {},
props: e = {},
onPropsChange: r
} = d;
console.log("[hydrateComponent] Hydrating element:", a.tagName, { props: e }), i && h(i, a);
for (const t of u)
typeof t == "function" && await t({ element: a, context: d });
if (a.querySelectorAll("[data-bind-text]").forEach((t) => {
const n = t.dataset.bindText, o = s[n];
typeof o == "function" && (t.textContent = o());
}), a.querySelectorAll("[data-bind-html]").forEach((t) => {
const n = t.dataset.bindHtml, o = s[n];
typeof o == "function" && (t.innerHTML = o());
}), a.querySelectorAll("[data-model]").forEach((t) => {
const n = t.dataset.model, o = s[n];
if (typeof o == "function") {
const c = o();
t.value !== c && (t.value = c), t.addEventListener("input", (f) => {
const y = f.target;
o(y.value), typeof r == "function" && r({ props: e, element: a, changed: { [n]: y.value } });
});
}
}), a.querySelectorAll("[data-action]").forEach((t) => {
const n = t.dataset.action, o = t.dataset.eventType || "click", c = p[n];
typeof c == "function" && t.addEventListener(o, (f) => {
f.preventDefault(), c({
event: f,
element: t,
dataset: { ...t.dataset },
props: e,
store: i
});
});
}), typeof r == "function")
try {
await r({ props: e, element: a, changed: e });
} catch (t) {
console.warn("[hydrateComponent] onPropsChange error:", t);
}
}
export {
v as hydrateComponent
};
import { getNestedValue as c } from "./index-imKjdn-q.js";
function d(e, n) {
return n.split(".").reduce((r, s) => r?.[s], e);
}
function i(e, n, r) {
const s = n.split("."), o = s.pop();
if (!o) return;
const u = s.reduce((t, a) => (t[a] === void 0 && (t[a] = {}), t[a]), e);
u[o] = r;
}
function p(e, n, r) {
document.querySelectorAll(`[data-model="${e}"]`).forEach((o) => {
const u = d(n, e) ?? "";
o.value !== u && (o.value = u);
const t = (a) => {
const l = a.target.value;
i(n, e, l), r({ ...n });
};
o.removeEventListener("input", t), o.addEventListener("input", t);
});
}
function v(e, n, r, s = document) {
const o = s.querySelectorAll(`[data-model="${e}"]`), u = c(n(), e);
o.forEach((t) => {
t.value !== u && (t.value = u), t.addEventListener("input", (a) => {
const l = a.target.value;
r(l);
});
});
}
export {
d as getDeep,
v as hydrateInputs,
p as hydrateInputsBindings,
i as setDeep
};
function o(t, n, e) {
t && (t.textContent = n(), e(() => {
t.textContent = n();
}));
}
export {
o as bindText
};
function m(o, e) {
return e.split(".").reduce((r, s) => r?.[s], o);
}
function d(o, e, r) {
const s = e.split("."), n = s.pop(), c = s.reduce((t, i) => (t[i] = t[i] || {}, t[i]), o);
n && (c[n] = r);
}
function p(o) {
if (!(!o?.props || !o?.store)) {
o.bindings || (o.bindings = {});
for (const e of Object.keys(o.props))
e in o.bindings || (o.bindings[e] = (r) => (r !== void 0 && (o.store.state[e] = r), o.store.state[e]));
}
}
function l(o, e = {}, r = 3e3) {
o?.state && setTimeout(() => {
for (const s in e)
s in o.state || (o.state[s] = e[s]);
for (const s in o.state)
s in e || (e[s] = o.state[s]);
}, r);
}
const a = async (o, e) => {
const r = /* @__PURE__ */ Object.assign({ "/src/AppRoutes.ts": () => import("./AppRoutes-Cyk4xBY_.js"), "/src/lib/bootstrap.ts": () => import("./main-KN5dnde2.js").then((t) => t.a), "/src/lib/core/bindings/hydrateBindings.ts": () => import("./hydrateBindings-DCVLl7dJ.js"), "/src/lib/core/bindings/hydrateInputs.ts": () => import("./hydrateInputs-Cacvjdsn.js"), "/src/lib/core/bindings/index.ts": () => import("./index-BN9rm4CO.js"), "/src/lib/core/components/defineComponent.ts": () => import("./defineComponent-DQx_F9F9.js"), "/src/lib/core/components/renderComponent.ts": () => import("./renderComponent-D2WpQVP1.js"), "/src/lib/core/components/resolveChildComponent.ts": () => import("./resolveChildComponent-aHsuwXBS.js"), "/src/lib/core/hooks/basic.ts": () => import("./basic-DD18cb2c.js"), "/src/lib/core/hydrations/hydrateComponent.ts": () => import("./hydrateComponent-DvBNWogZ.js"), "/src/lib/core/registry/componentRegistry.ts": () => import("./componentRegistry-LyDY_wMg.js"), "/src/lib/main.ts": () => import("./main-KN5dnde2.js").then((t) => t.m), "/src/lib/routecore.ts": () => import("./routecore-CNRUqdX7.js"), "/src/lib/vite-env.d.ts": () => import("./vite-env.d-rlNtK3Bt.js").then((t) => t.v), "/src/main.ts": () => import("./main-BDqiIq5t.js"), "/src/modules/404.ts": () => import("./404-e-t8vB2c.js"), "/src/modules/Login/Login.ts": () => import("./vite-env.d-rlNtK3Bt.js").then((t) => t.L), "/src/modules/about.ts": () => import("./vite-env.d-rlNtK3Bt.js").then((t) => t.c), "/src/modules/components/childComponentSample.ts": () => import("./vite-env.d-rlNtK3Bt.js").then((t) => t.d), "/src/modules/contact.ts": () => import("./vite-env.d-rlNtK3Bt.js").then((t) => t.e), "/src/modules/dashboard.ts": () => import("./vite-env.d-rlNtK3Bt.js").then((t) => t.f), "/src/modules/home.ts": () => import("./vite-env.d-rlNtK3Bt.js").then((t) => t.h), "/src/vite-env.d.ts": () => import("./vite-env.d-rlNtK3Bt.js").then((t) => t.i) });
console.log(e);
let s = o;
s.startsWith("/src") || (s = `/src/${s}`);
const c = /\.[jt]s$/.test(s) ? [s] : [`${s}.js`, `${s}.ts`];
for (const t of c) {
const i = r[t];
if (i)
return i();
}
throw console.error("[Framework] Available modules:", Object.keys(r)), new Error(`[Framework] Cannot find module for path: ${s}`);
};
export {
p as bindPropsToStore,
m as getNestedValue,
a as loadModule,
d as setNestedValue,
l as syncStoreAndProps
};
const n = `<div>\r
<h2>Hello <span data-ref="userName"></span>!</h2>\r
\r
<input\r
type="text"\r
placeholder="Enter name"\r
data-model="userName"\r
/>\r
</div>\r
`;
export {
n as default
};
import { b as r } from "./main-KN5dnde2.js";
import { routes as t } from "./AppRoutes-Cyk4xBY_.js";
const o = document.getElementById("app");
if (!o)
throw new Error("❌ Could not find #app in DOM");
r(t).surge(o);
import { defineComponent as n } from "./defineComponent-DQx_F9F9.js";
import { useStore as a, watchEffect as s, usePropsStore as i, bind as d, setupReactivity as p } from "./basic-DD18cb2c.js";
import { bindPropsToStore as m, syncStoreAndProps as c } from "./index-imKjdn-q.js";
import { handleHashChange as t } from "./routecore-CNRUqdX7.js";
const r = (e) => ({
surge: (o) => {
window.addEventListener(
"hashchange",
() => t(o, e)
), window.addEventListener(
"DOMContentLoaded",
() => t(o, e)
);
}
}), S = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
bootstrapContainers: r
}, Symbol.toStringTag, { value: "Module" })), _ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
bind: d,
bindPropsToStore: m,
bootstrapContainers: r,
defineComponent: n,
setupReactivity: p,
syncStoreAndProps: c,
usePropsStore: i,
useStore: a,
watchEffect: s
}, Symbol.toStringTag, { value: "Module" }));
export {
S as a,
r as b,
_ as m
};
import { defineComponent as r } from "./core/components/defineComponent.js";
import { bind as s, setupReactivity as p, usePropsStore as n, useStore as f, watchEffect as a } from "./core/hooks/basic.js";
import { b as m, s as b } from "./vite-env.d-rlNtK3Bt.js";
import { bootstrapContainers as d } from "./bootstrap.js";
export {
s as bind,
m as bindPropsToStore,
d as bootstrapContainers,
r as defineComponent,
p as setupReactivity,
b as syncStoreAndProps,
n as usePropsStore,
f as useStore,
a as watchEffect
};
import { hydrateComponent as p } from "./hydrateComponent-DvBNWogZ.js";
import { watchEffect as d, setupReactivity as l } from "./basic-DD18cb2c.js";
import { bindPropsToStore as u } from "./index-imKjdn-q.js";
function C(a, o = {}) {
const t = a(o), i = document.createElement("div"), c = typeof t.template == "string" ? t.template : "<div><slot></slot></div>";
i.innerHTML = c;
const r = i.firstElementChild, s = {
props: o,
...t
};
if (t.store?.state) {
for (const [e, n] of Object.entries(o))
typeof t.store.state[e] > "u" && t.store.setState(e, n);
u(t), d({
props: o,
store: t.store,
callback: ({
props: e,
state: n
}) => {
for (const [f, m] of Object.entries(e))
typeof n[f] > "u" && t.store.setState(f, m);
typeof t.onPropsChanged == "function" && t.onPropsChanged({ props: e, state: n });
}
});
}
return requestAnimationFrame(async () => {
t.store && l(t.store, r), await p(r, s), typeof t.onMount == "function" && t.onMount(s);
}), r;
}
export {
C as renderComponent
};
import { hydrateComponent as b } from "./hydrateComponent-DvBNWogZ.js";
import { watchEffect as v, setupReactivity as y } from "./basic-DD18cb2c.js";
import { getComponentLoader as C } from "./defineComponent-DQx_F9F9.js";
import { bindPropsToStore as w } from "./index-imKjdn-q.js";
const A = /* @__PURE__ */ new Set([
"html",
"head",
"body",
"base",
"link",
"meta",
"style",
"title",
"address",
"article",
"aside",
"footer",
"header",
"h1",
"h2",
"h3",
"h4",
"h5",
"main",
"nav",
"section",
"div",
"span",
"a",
"p",
"ul",
"li",
"ol",
"table",
"thead",
"tbody",
"tr",
"th",
"td",
"form",
"input",
"button",
"select",
"option",
"textarea",
"label",
"fieldset",
"legend",
"script",
"noscript",
"template",
"slot",
"img",
"video",
"audio",
"canvas",
"iframe",
"strong",
"em",
"b",
"i",
"u",
"small",
"br",
"hr"
]);
function S(a) {
const n = a.toLowerCase();
return !A.has(n) && (n.includes("-") || /[A-Z]/.test(a));
}
function E(a) {
const n = {};
for (const f of Array.from(a.attributes)) {
let e = f.name;
e.startsWith(":") && (e = e.slice(1)), e = e.replace(/-([a-z])/g, (m, s) => s.toUpperCase()), n[e] = f.value;
}
return n;
}
async function P(a, n = {}) {
const f = [...a.querySelectorAll("*")].filter(
(e) => S(e.tagName)
);
for (const e of f) {
const m = e.tagName.toLowerCase();
try {
const s = C(m);
if (!s) continue;
const p = (await s())?.init;
if (typeof p != "function") continue;
const c = E(e);
console.log(c, "changing...");
const t = await p({
...n,
props: c
});
if (!t) continue;
if (t.store?.state)
for (const [o, i] of Object.entries(c))
typeof t.store.state[o] > "u" && t.store.setState(o, i);
w(t), v({
props: c,
store: t.store,
callback: ({ props: o, state: i }) => {
for (const [l, g] of Object.entries(o))
console.log(c, o, l, g, ".............."), typeof i[l] > "u" && t.store.setState(l, g);
typeof t.onPropsChanged == "function" && t.onPropsChanged({ props: o, state: i });
}
});
const u = document.createElement("div");
u.innerHTML = `<div>${t.template ?? ""}</div>`;
const r = u.firstElementChild;
if (!r) continue;
const d = {
...n,
...t,
props: c,
bindings: t.bindings || {}
};
t.store && y(t.store, r), await b(r, d);
for (const o of Array.from(e.children))
if (o.tagName === "TEMPLATE") {
const i = o.getAttribute("slot"), l = i ? r.querySelector(`slot[name="${i}"]`) : r.querySelector("slot:not([name])");
l && l.replaceWith(o.content.cloneNode(!0));
}
await P(r, d);
const h = Array.from(r.children);
e.replaceWith(...h), h.forEach((o) => {
t.store && y(t.store, o);
}), typeof t.onMount == "function" && requestAnimationFrame(() => {
t.onMount?.({ ...d });
});
} catch (s) {
console.warn(`Failed to load component <${m}>`, s);
}
}
}
export {
P as resolveChildComponents
};
import { hydrateComponent as b } from "./hydrateComponent-DvBNWogZ.js";
import { setupReactivity as $ } from "./basic-DD18cb2c.js";
import { resolveChildComponents as N } from "./resolveChildComponent-aHsuwXBS.js";
import { loadModule as L } from "./index-imKjdn-q.js";
const M = /* @__PURE__ */ new Set(), u = "home";
let P = null;
console.log(P);
function v() {
const e = decodeURIComponent(location.hash.slice(1)), [t = u, s = ""] = e.split("?"), r = Object.fromEntries(new URLSearchParams(s));
return { path: t, params: r };
}
function D(e, t) {
const s = (c) => {
for (const o of t) {
if (typeof o.path == "string" && o.path === c)
return { route: o, match: null, params: {} };
if (typeof o.path == "string" && o.path.includes(":")) {
const i = [], l = o.path.split("/").map((p) => p.startsWith(":") ? (i.push(p.slice(1)), "([^/]+)") : p).join("/"), d = new RegExp(`^${l}$`), a = c.match(d);
if (a) {
const p = Object.fromEntries(i.map((S, f) => [S, a[f + 1]]));
return { route: o, match: a, params: p };
}
}
if (o.path instanceof RegExp) {
const i = c.match(o.path);
if (i) return { route: o, match: i, params: {} };
}
}
return null;
};
let r = s(e);
if (r) return r;
if (e.endsWith("/")) {
for (const c of [`${e}index`, `${e}home`])
if (r = s(c), r) return r;
}
const n = t.find((c) => c.path === "*");
return n ? { route: n, match: null, params: {} } : null;
}
function R(e, t) {
if (!e || !t) {
console.warn("shallowDiffAndPatch: parent or newChildren is null/undefined");
return;
}
const s = Array.from(e.children), r = Array.from(t);
for (let n = 0; n < r.length; n++) {
const c = r[n], o = s[n];
o ? c.isEqualNode(o) || e.replaceChild(c, o) : e.appendChild(c);
}
for (let n = r.length; n < s.length; n++)
s[n].remove();
}
function q(e) {
const t = document.createElement("div");
return t.innerHTML = e, t;
}
function w(e, t) {
((r, n) => {
r.querySelectorAll("slot[name]").forEach((o) => {
const i = o.getAttribute("name"), l = n.querySelector(`template[slot="${i}"]`);
if (l) {
const a = l.content.cloneNode(!0);
w(a, n), o.replaceWith(a);
return;
}
const d = n.querySelector(`[slot="${i}"]:not(template)`);
d && o.replaceWith(d.cloneNode(!0));
});
const c = r.querySelector("slot:not([name])");
if (c) {
const o = n.querySelector("template:not([slot])");
if (o) {
const l = o.content.cloneNode(!0);
w(l, n), c.replaceWith(l);
return;
}
const i = [...n.children].filter(
(l) => l.tagName !== "TEMPLATE" && !l.hasAttribute("slot")
);
i.length > 0 && c.replaceWith(...i.map((l) => l.cloneNode(!0)));
}
})(e, t);
}
function T(e, t) {
const s = document.getElementById(t);
s && s.remove();
const r = document.createElement("style");
r.id = t, r.textContent = e, document.head.appendChild(r);
}
async function F({
app: e,
route: t,
viewHTML: s,
layoutHTML: r,
params: n,
match: c = null
}) {
const o = { ...n }, i = { app: e, params: n, props: o }, l = q(s);
let d = l, a = {}, p;
if (console.log(c), r) {
const f = q(r);
w(f, l), d = f;
}
if (t.styles || t.style) {
const f = Array.isArray(t.styles || t.style) ? t.styles || t.style : [t.style];
for (const y of f) {
const h = await (await fetch(y)).text();
T(h, `scoped-style-${t.path}`);
}
}
await (async () => {
const f = d.cloneNode(!0);
if (t.script || t.scripts) {
const m = Array.isArray(t.scripts || t.script) ? t.scripts || t.script : [t.script];
if (p = await L(`${m[0]}`, t.scriptBase || "modules"), typeof p.init == "function") {
a = await p.init({ ...i }) || {};
const { template: h } = a;
if (h && typeof h == "string") {
const E = document.createElement("div");
E.innerHTML = h;
for (const g of [...E.children]) {
const A = g.getAttribute("slot") || null;
await b(g, {
...i,
...a,
props: { ...o }
});
const C = A ? f.querySelector(`slot[name="${A}"]`) : f.querySelector("slot:not([name])");
C && C.replaceWith(g);
}
}
requestAnimationFrame(() => {
a.onMount?.({ ...i, ...a, props: o }), a.store && $(a.store, e), P = () => a.onDestroy?.();
});
}
}
await b(f, {
...i,
...a,
props: { ...o }
}), await N(f, {
...i,
...a,
props: { ...o }
}), requestAnimationFrame(() => {
if (!e || !f || !f.children) {
console.warn("[hydrate] Skipping patch - app or domClone is null");
return;
}
R(e, f.children), Array.from(e.children).forEach((m) => {
a.store && $(a.store, m);
});
});
const y = new DOMParser().parseFromString(s, "text/html");
for (const m of y.querySelectorAll("script")) {
const h = document.createElement("script");
if (m.src) {
if (M.has(m.src)) continue;
h.src = m.src, M.add(m.src);
} else
h.textContent = m.textContent;
m.type && (h.type = m.type), document.body.appendChild(h);
}
t.onLoad?.();
})();
}
function O(e, t) {
if (location.hash === "#") {
history.replaceState(null, "", `#${u}`);
return;
}
const { path: s, params: r } = v(), n = r.queryParams;
let c = s;
(!location.hash || s === u) && (c = u, location.hash || history.replaceState(null, "", `#${u}`));
const o = D(c, t);
if (o) {
const { route: i, match: l, params: d } = o, a = {
...n || {},
...d || {}
};
W(e, i, a, l);
} else
e.innerHTML = "<h2>404 - Not Found</h2>";
}
async function j(e) {
const t = e.replace(/^\/+/, ""), s = /* @__PURE__ */ Object.assign({
"/src/modules/Login/components/Login.html": () => import("./Login-DaokiISj.js").then((n) => n.default)
}), r = Object.keys(s).find(
(n) => n.endsWith(`/${t}`) || n.endsWith(t)
);
if (!r)
throw new Error(`[fallbackImportFromSrc] '${e}' not found in src`);
try {
return await s[r]();
} catch (n) {
throw new Error(`[fallbackImportFromSrc] Failed to import '${e}' from '${r}': ${n.message}`);
}
}
async function x(e) {
if (!e) return "";
if (typeof e == "function") {
const t = await e();
return typeof t == "string" ? t : t?.default || "";
}
if (typeof e == "string") {
if (/<\/?[a-z][\s\S]*>/i.test(e.trim())) return e;
try {
const s = await fetch(e);
if (!s.ok) throw new Error("Not found in public");
return await s.text();
} catch {
try {
return await j(e);
} catch (s) {
throw console.error(s.message), new Error(`[resolveContent] Cannot resolve: ${e}`);
}
}
}
return "";
}
async function W(e, t, s = {}, r = null) {
try {
window.__currentDestroy?.();
const [n, c] = await Promise.all([
x(t.view),
x(t.layout)
]);
await F({
app: e,
route: t,
viewHTML: n,
layoutHTML: c,
params: s,
match: r
}), console.log("running...");
} catch (n) {
console.error("Render error:", n), e.innerHTML = "<h2>Error loading page</h2>";
}
}
function B(e = document.getElementById("app"), t) {
O(e, t);
}
export {
j as fallbackImportFromSrc,
B as handleHashChange,
O as handleRoute,
W as loadPage,
x as resolveContent,
F as slotAwareRender
};
import { hydrateComponent as b } from "./core/hydrations/hydrateComponent.js";
import { setupReactivity as $ } from "./core/hooks/basic.js";
import { resolveChildComponents as N } from "./core/components/resolveChildComponent.js";
import { l as L } from "./vite-env.d-rlNtK3Bt.js";
const M = /* @__PURE__ */ new Set(), u = "home";
let P = null;
console.log(P);
function v() {
const e = decodeURIComponent(location.hash.slice(1)), [t = u, s = ""] = e.split("?"), r = Object.fromEntries(new URLSearchParams(s));
return { path: t, params: r };
}
function D(e, t) {
const s = (c) => {
for (const o of t) {
if (typeof o.path == "string" && o.path === c)
return { route: o, match: null, params: {} };
if (typeof o.path == "string" && o.path.includes(":")) {
const i = [], l = o.path.split("/").map((p) => p.startsWith(":") ? (i.push(p.slice(1)), "([^/]+)") : p).join("/"), d = new RegExp(`^${l}$`), a = c.match(d);
if (a) {
const p = Object.fromEntries(i.map((S, f) => [S, a[f + 1]]));
return { route: o, match: a, params: p };
}
}
if (o.path instanceof RegExp) {
const i = c.match(o.path);
if (i) return { route: o, match: i, params: {} };
}
}
return null;
};
let r = s(e);
if (r) return r;
if (e.endsWith("/")) {
for (const c of [`${e}index`, `${e}home`])
if (r = s(c), r) return r;
}
const n = t.find((c) => c.path === "*");
return n ? { route: n, match: null, params: {} } : null;
}
function R(e, t) {
if (!e || !t) {
console.warn("shallowDiffAndPatch: parent or newChildren is null/undefined");
return;
}
const s = Array.from(e.children), r = Array.from(t);
for (let n = 0; n < r.length; n++) {
const c = r[n], o = s[n];
o ? c.isEqualNode(o) || e.replaceChild(c, o) : e.appendChild(c);
}
for (let n = r.length; n < s.length; n++)
s[n].remove();
}
function q(e) {
const t = document.createElement("div");
return t.innerHTML = e, t;
}
function w(e, t) {
((r, n) => {
r.querySelectorAll("slot[name]").forEach((o) => {
const i = o.getAttribute("name"), l = n.querySelector(`template[slot="${i}"]`);
if (l) {
const a = l.content.cloneNode(!0);
w(a, n), o.replaceWith(a);
return;
}
const d = n.querySelector(`[slot="${i}"]:not(template)`);
d && o.replaceWith(d.cloneNode(!0));
});
const c = r.querySelector("slot:not([name])");
if (c) {
const o = n.querySelector("template:not([slot])");
if (o) {
const l = o.content.cloneNode(!0);
w(l, n), c.replaceWith(l);
return;
}
const i = [...n.children].filter(
(l) => l.tagName !== "TEMPLATE" && !l.hasAttribute("slot")
);
i.length > 0 && c.replaceWith(...i.map((l) => l.cloneNode(!0)));
}
})(e, t);
}
function T(e, t) {
const s = document.getElementById(t);
s && s.remove();
const r = document.createElement("style");
r.id = t, r.textContent = e, document.head.appendChild(r);
}
async function F({
app: e,
route: t,
viewHTML: s,
layoutHTML: r,
params: n,
match: c = null
}) {
const o = { ...n }, i = { app: e, params: n, props: o }, l = q(s);
let d = l, a = {}, p;
if (console.log(c), r) {
const f = q(r);
w(f, l), d = f;
}
if (t.styles || t.style) {
const f = Array.isArray(t.styles || t.style) ? t.styles || t.style : [t.style];
for (const y of f) {
const h = await (await fetch(y)).text();
T(h, `scoped-style-${t.path}`);
}
}
await (async () => {
const f = d.cloneNode(!0);
if (t.script || t.scripts) {
const m = Array.isArray(t.scripts || t.script) ? t.scripts || t.script : [t.script];
if (p = await L(`${m[0]}`, t.scriptBase || "modules"), typeof p.init == "function") {
a = await p.init({ ...i }) || {};
const { template: h } = a;
if (h && typeof h == "string") {
const E = document.createElement("div");
E.innerHTML = h;
for (const g of [...E.children]) {
const A = g.getAttribute("slot") || null;
await b(g, {
...i,
...a,
props: { ...o }
});
const C = A ? f.querySelector(`slot[name="${A}"]`) : f.querySelector("slot:not([name])");
C && C.replaceWith(g);
}
}
requestAnimationFrame(() => {
a.onMount?.({ ...i, ...a, props: o }), a.store && $(a.store, e), P = () => a.onDestroy?.();
});
}
}
await b(f, {
...i,
...a,
props: { ...o }
}), await N(f, {
...i,
...a,
props: { ...o }
}), requestAnimationFrame(() => {
if (!e || !f || !f.children) {
console.warn("[hydrate] Skipping patch - app or domClone is null");
return;
}
R(e, f.children), Array.from(e.children).forEach((m) => {
a.store && $(a.store, m);
});
});
const y = new DOMParser().parseFromString(s, "text/html");
for (const m of y.querySelectorAll("script")) {
const h = document.createElement("script");
if (m.src) {
if (M.has(m.src)) continue;
h.src = m.src, M.add(m.src);
} else
h.textContent = m.textContent;
m.type && (h.type = m.type), document.body.appendChild(h);
}
t.onLoad?.();
})();
}
function O(e, t) {
if (location.hash === "#") {
history.replaceState(null, "", `#${u}`);
return;
}
const { path: s, params: r } = v(), n = r.queryParams;
let c = s;
(!location.hash || s === u) && (c = u, location.hash || history.replaceState(null, "", `#${u}`));
const o = D(c, t);
if (o) {
const { route: i, match: l, params: d } = o, a = {
...n || {},
...d || {}
};
W(e, i, a, l);
} else
e.innerHTML = "<h2>404 - Not Found</h2>";
}
async function j(e) {
const t = e.replace(/^\/+/, ""), s = /* @__PURE__ */ Object.assign({
"/src/modules/Login/components/Login.html": () => import("./Login-DaokiISj.js").then((n) => n.default)
}), r = Object.keys(s).find(
(n) => n.endsWith(`/${t}`) || n.endsWith(t)
);
if (!r)
throw new Error(`[fallbackImportFromSrc] '${e}' not found in src`);
try {
return await s[r]();
} catch (n) {
throw new Error(`[fallbackImportFromSrc] Failed to import '${e}' from '${r}': ${n.message}`);
}
}
async function x(e) {
if (!e) return "";
if (typeof e == "function") {
const t = await e();
return typeof t == "string" ? t : t?.default || "";
}
if (typeof e == "string") {
if (/<\/?[a-z][\s\S]*>/i.test(e.trim())) return e;
try {
const s = await fetch(e);
if (!s.ok) throw new Error("Not found in public");
return await s.text();
} catch {
try {
return await j(e);
} catch (s) {
throw console.error(s.message), new Error(`[resolveContent] Cannot resolve: ${e}`);
}
}
}
return "";
}
async function W(e, t, s = {}, r = null) {
try {
window.__currentDestroy?.();
const [n, c] = await Promise.all([
x(t.view),
x(t.layout)
]);
await F({
app: e,
route: t,
viewHTML: n,
layoutHTML: c,
params: s,
match: r
}), console.log("running...");
} catch (n) {
console.error("Render error:", n), e.innerHTML = "<h2>Error loading page</h2>";
}
}
function B(e = document.getElementById("app"), t) {
O(e, t);
}
export {
j as fallbackImportFromSrc,
B as handleHashChange,
O as handleRoute,
W as loadPage,
x as resolveContent,
F as slotAwareRender
};
function _(e, t) {
return t.split(".").reduce((s, o) => s?.[o], e);
}
function g(e, t, s) {
const o = t.split("."), i = o.pop(), l = o.reduce((r, n) => (r[n] = r[n] || {}, r[n]), e);
i && (l[i] = s);
}
function h(e) {
if (!(!e?.props || !e?.store)) {
e.bindings || (e.bindings = {});
for (const t of Object.keys(e.props))
t in e.bindings || (e.bindings[t] = (s) => (s !== void 0 && (e.store.state[t] = s), e.store.state[t]));
}
}
function y(e, t = {}, s = 3e3) {
e?.state && setTimeout(() => {
for (const o in t)
o in e.state || (e.state[o] = t[o]);
for (const o in e.state)
o in t || (t[o] = e.state[o]);
}, s);
}
const v = async (e, t) => {
const s = /* @__PURE__ */ Object.assign({ "/src/AppRoutes.ts": () => import("./AppRoutes-Cyk4xBY_.js"), "/src/lib/bootstrap.ts": () => import("./main-KN5dnde2.js").then((r) => r.a), "/src/lib/core/bindings/hydrateBindings.ts": () => import("./hydrateBindings-DCVLl7dJ.js"), "/src/lib/core/bindings/hydrateInputs.ts": () => import("./hydrateInputs-Cacvjdsn.js"), "/src/lib/core/bindings/index.ts": () => import("./index-BN9rm4CO.js"), "/src/lib/core/components/defineComponent.ts": () => import("./defineComponent-DQx_F9F9.js"), "/src/lib/core/components/renderComponent.ts": () => import("./renderComponent-D2WpQVP1.js"), "/src/lib/core/components/resolveChildComponent.ts": () => import("./resolveChildComponent-aHsuwXBS.js"), "/src/lib/core/hooks/basic.ts": () => import("./basic-DD18cb2c.js"), "/src/lib/core/hydrations/hydrateComponent.ts": () => import("./hydrateComponent-DvBNWogZ.js"), "/src/lib/core/registry/componentRegistry.ts": () => import("./componentRegistry-LyDY_wMg.js"), "/src/lib/core/utils/index.ts": () => import("./index-imKjdn-q.js"), "/src/lib/main.ts": () => import("./main-KN5dnde2.js").then((r) => r.m), "/src/lib/routecore.ts": () => import("./routecore-CNRUqdX7.js"), "/src/lib/vite-env.d.ts": () => Promise.resolve().then(() => c), "/src/main.ts": () => import("./main-BDqiIq5t.js"), "/src/modules/404.ts": () => import("./404-e-t8vB2c.js"), "/src/modules/Login/Login.ts": () => Promise.resolve().then(() => d), "/src/modules/about.ts": () => Promise.resolve().then(() => a), "/src/modules/components/childComponentSample.ts": () => Promise.resolve().then(() => m), "/src/modules/contact.ts": () => Promise.resolve().then(() => b), "/src/modules/dashboard.ts": () => Promise.resolve().then(() => u), "/src/modules/home.ts": () => Promise.resolve().then(() => p), "/src/vite-env.d.ts": () => Promise.resolve().then(() => f) });
console.log(t);
let o = e;
o.startsWith("/src") || (o = `/src/${o}`);
const l = /\.[jt]s$/.test(o) ? [o] : [`${o}.js`, `${o}.ts`];
for (const r of l) {
const n = s[r];
if (n)
return n();
}
throw console.error("[Framework] Available modules:", Object.keys(s)), new Error(`[Framework] Cannot find module for path: ${o}`);
}, c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), b = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), u = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), p = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" }));
export {
d as L,
g as a,
h as b,
a as c,
m as d,
b as e,
u as f,
_ as g,
p as h,
f as i,
v as l,
y as s,
c as v
};

Sorry, the diff of this file is not supported yet

interface IRoutes {
path: string | RegExp;
view: string | (() => Promise<string | {
default: string;
}>) | any;
layout?: string | (() => Promise<string | {
default: string;
}>) | any;
style?: string | string[];
styles?: string | string[];
script?: string | string[];
scripts?: string | string[];
scriptBase?: string;
onLoad?: () => void;
}
export declare const bootstrapContainers: (routes: IRoutes[]) => {
surge: (app: HTMLElement | Document | any) => void;
};
export {};
type Props = Record<string, any>;
export declare function hydrateElmentAttibutesBindings(rootEl: HTMLElement, props?: Props): void;
export {};
export declare function getDeep<T = any>(obj: Record<string, any>, path: string): T | undefined | any;
export declare function setDeep(obj: Record<string, any>, path: string, value: any): void;
export declare function hydrateInputsBindings(key: string, valueObj: Record<string, any>, setter: (updatedValue: Record<string, any>) => void): void;
export declare function hydrateInputs(keyPath: string, state: () => Record<string, any>, setter: (val: string) => void, root?: Document | HTMLElement): void;
export declare function bindText(el: HTMLElement | null, get: () => string, subscribe: (callback: () => void) => void): void;
type ComponentLoader = () => Promise<any>;
/**
* Registers a component loader function under a normalized kebab-case name.
*
* @param name - The component's name (e.g., `MyComponent`).
* @param loaderFn - A function that returns a dynamic import promise.
*/
export declare function defineComponent(name: string, loaderFn: ComponentLoader): void;
/**
* Resolves a component loader function by tag name.
*
* @param tagName - The tag name to look up (e.g., `my-component`).
* @returns The registered loader function, or undefined if not found.
*/
export declare function getComponentLoader(tagName: string): ComponentLoader | undefined;
export {};
type Props = Record<string, any>;
type State = Record<string, any>;
interface Store {
state: State;
setState: (key: string, value: any) => void;
}
interface ComponentInstance {
template?: string;
store?: Store;
onMount?: (ctx: any) => void;
onPropsChanged?: (ctx: {
props: Props;
state: State;
}) => void;
}
type ComponentFn = (props: Props) => ComponentInstance;
/**
* Renders a component and sets up its reactive lifecycle.
*
* @param ComponentFn - The function that returns the component definition.
* @param props - Initial props to pass to the component.
* @returns HTMLElement root of the component.
*/
export declare function renderComponent(ComponentFn: ComponentFn, props?: Props): HTMLElement;
export {};
export declare function resolveChildComponents(root: HTMLElement, parentContext?: Record<string, any>): Promise<void>;
type Subscriber<T> = (value: T) => void;
export declare function useStore<T extends Record<string, any>>(initialState: T): {
state: T;
setState<K extends keyof T>(key: K, val: T[K]): void;
subscribe<K extends keyof T>(key: K, fn: Subscriber<T[K] | any>): void;
};
type Callback<T> = (val: T) => void;
export declare function usePropsStore<T extends Record<string, any>>(initial: Partial<T> | undefined, fallback: T): {
state: T;
subscribe: <K extends keyof T>(key: K, cb: Callback<T[K]> | any) => void;
bindings: { [K in keyof T]: (val?: T[K]) => T[K]; };
};
export declare function bind<T extends Record<string, any>>(store: {
state: T | any;
subscribe: <K extends keyof T>(key: K, cb: (val: T[K]) => void) => void;
}): void;
export declare function setupReactivity<T extends Record<string, any>>(store: {
state: T;
setState: <K extends keyof T>(key: K, val: T[K]) => void | any;
subscribe: <K extends keyof T>(key: K, cb: (val: T[K]) => void) => void;
} | any, root?: HTMLElement | HTMLDivElement | Document): void;
type Props = Record<string, any>;
type WatchEffectArgs = {
props: Record<string, any>;
store: any;
callback: (ctx: {
props: Record<string, any>;
state: Record<string, any>;
}) => void;
};
export declare function watchEffect<T extends Record<string, any>>({ props, store, callback, }: {
props: Props;
store: {
state: T;
subscribe: <K extends keyof T>(key: K, cb: () => void) => void;
} | any;
callback: (args: {
props: Props;
state: T;
}) => void;
} | WatchEffectArgs): void;
export {};
type BindFunction = () => any;
type ModelBindFunction = (value?: any) => any;
type ActionFunction = (params: {
event: Event;
element: HTMLElement;
dataset: DOMStringMap;
props: Record<string, any>;
store?: any;
}) => void;
type EffectFunction = (args: {
element: Element;
context: ComponentContext;
}) => Promise<void> | void;
type OnPropsChangeFunction = (args: {
props: Record<string, any>;
element: Element;
changed: Record<string, any>;
}) => Promise<void> | void;
interface ComponentContext {
store?: any;
bindings?: Record<string, BindFunction | ModelBindFunction>;
effects?: EffectFunction[];
actions?: Record<string, ActionFunction>;
props?: Record<string, any>;
onPropsChange?: OnPropsChangeFunction;
}
export declare function hydrateComponent(element: Element | null, context?: ComponentContext): Promise<void>;
export {};
export declare const componentRegistry: Map<any, any>;
export declare function defineComponent(name: string, loaderFn: any): void;
export declare function getNestedValue<T = any>(obj: Record<string, any>, keyPath: string): T | undefined;
export declare function setNestedValue(obj: Record<string, any>, path: string, value: any): void;
interface Store {
state: Record<string, any>;
}
interface Instance {
props: Record<string, any>;
store: Store;
bindings?: Record<string, (val?: any) => any>;
}
export declare function bindPropsToStore(instance: Instance | any): void;
export declare function syncStoreAndProps(store: Store, props?: Record<string, any>, delay?: number): void;
export declare const loadModule: (path: string, basePath?: string) => Promise<any>;
export {};
export { defineComponent } from './core/components/defineComponent';
export { useStore, watchEffect, usePropsStore, bind, setupReactivity, } from './core/hooks/basic';
export { bindPropsToStore, syncStoreAndProps } from './core/utils';
export { bootstrapContainers } from './bootstrap';
interface Route {
path: string | RegExp;
view: string | (() => Promise<string | {
default: string;
}>);
layout?: string | (() => Promise<string | {
default: string;
}>);
style?: string | string[];
styles?: string | string[];
script?: string | string[];
scripts?: string | string[];
scriptBase?: string;
onLoad?: () => void;
}
declare global {
interface Window {
__currentDestroy?: () => void;
}
}
interface RenderOptions {
app: HTMLElement;
route: Route;
viewHTML: string;
layoutHTML?: string;
params: Record<string, any>;
match?: any;
}
export declare function slotAwareRender({ app, route, viewHTML, layoutHTML, params, match }: RenderOptions): Promise<void>;
export declare function handleRoute(app: HTMLElement, routes: Route[]): void;
/**
* Attempts to load a file from the Vite src directory using import.meta.glob
* @param {string} filename - e.g. "Main.html" or "views/About.html"
* @returns {Promise<string>} - raw file content
*/
export declare function fallbackImportFromSrc(filename: string): Promise<string>;
export declare function resolveContent(input: string | (() => Promise<string | {
default: string;
}>) | undefined): Promise<string>;
export declare function loadPage(app: HTMLElement, route: Route, params?: Record<string, any>, match?: RegExpMatchArray | null): Promise<void>;
export declare function handleHashChange(app: (HTMLElement | Document | any) | undefined, routes: Route[]): void;
export {};
+31
-6

@@ -5,8 +5,30 @@ {

"private": false,
"version": "0.0.4",
"version": "0.0.5",
"type": "module",
"main": "dist/cjs/main.js",
"module": "dist/esm/main.js",
"exports": {
".": {
"types": "./dist/lib/main.d.ts",
"default": "./dist/main.js"
"require": "./dist/cjs/main.js",
"import": "./dist/esm/main.js"
},
"./hydrations": {
"import": {
"types": "./dist/esm/types/core/hydrations/hydrateComponent.d.ts",
"default": "./dist/esm/core/hydrations/hydrateComponent.js"
},
"require": {
"types": "./dist/cjs/types/core/hydrations/hydrateComponent.d.ts",
"default": "./dist/cjs/core/hydrations/hydrateComponent.js"
}
},
"./hooks": {
"import": {
"types": "./dist/esm/types/core/hooks/basic.d.ts",
"default": "./dist/esm/core/hooks/basic.js"
},
"require": {
"types": "./dist/cjs/types/core/hooks/basic.d.ts",
"default": "./dist/cjs/core/hooks/basic.js"
}
}

@@ -26,3 +48,6 @@ },

"dev": "vite",
"build": "tsc -b ./tsconfig.lib.json && vite build",
"build:types": "tsc -p tsconfig.lib.json",
"build:cjs": "tsc -p tsconfig.lib.cjs.json",
"build:esm": "vite build",
"build": "npm run build:types && npm run build:cjs && npm run build:esm",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",

@@ -54,4 +79,4 @@ "preview": "vite preview"

"@ast-grep/napi": "^0.38.7",
"frameless-js": "^0.0.1"
"frameless-js": "0.0.4"
}
}
}
-6
function o(n) {
return console.log("Route params:", n), alert("Page not found"), {};
}
export {
o as init
};
function n(o) {
return console.log("Route params:", o), alert("Page not found"), {};
}
export {
n as init
};
let s = !1;
function i(o) {
return s = o, s;
}
async function n(o) {
try {
const e = await fetch(o);
if (!e.ok) throw new Error("Not found in public");
return await e.text();
} catch {
console.warn(`[TemplateLoader] Falling back to src for: ${o}`);
const e = /* @__PURE__ */ Object.assign({
"/src/modules/Login/components/Login.html": () => import("./Login-DaokiISj-DOK9VfTk.js").then((t) => t.default)
}), a = o.split("/").pop() || "", l = Object.keys(e).find(
(t) => t.endsWith(`/${a}`)
);
if (!l)
throw new Error(`Template '${a}' not found in src fallback`);
return e[l]();
}
}
const r = [
{
path: "home",
view: () => n("./views/home.html"),
onLoad: () => console.log("Home loaded"),
layout: "./views/layouts/default.html",
// scriptBase: 'src/modules',
scripts: ["modules/home.js"]
// accepts array of string
},
{
path: "login",
view: "./views/login.html",
onLoad: () => console.log("Login loaded"),
layout: "./views/layouts/default.html",
scripts: ["./modules/Login/Login.js"]
// accepts array of string
},
{
path: "profile/:id",
// /^profile\/(\d+)$/,
view: "./views/profile.html",
onLoad: () => console.log("Profile loaded"),
layout: "./views/layouts/default.html",
middleware: async (o) => {
if (console.log(o, ">>>>"), o?.user)
return o.user != "banned";
const e = !!o.user;
return await i(e) ? !0 : (location.hash = "#login", !1);
},
script: ["./modules/about.js"]
// accepts array of string
},
{
path: "about",
view: "./views/about.html",
layout: "./views/layouts/default.html",
middleware: () => (console.log("About middleware ran"), !0),
onLoad: () => console.log("About page is now visible"),
script: "./modules/about.js"
},
{
path: "contact",
view: "./views/contact.html",
layout: "./views/layouts/default.html",
middleware: () => (console.log("Checking something before showing contact"), confirm("Do you really want to view the contact page?"))
},
/// test life cycle
{
path: "dashboard",
view: "./views/dashboard.html",
script: "./modules/dashboard.js",
layout: "./views/layouts/dashboard.html"
// todo add route beforeEnter and beforeLeave
// beforeEnter: (params) => {
// if (!checkLoginStatus(false)) {
// navigate('login');
// return false;
// }
// return true;
// },
},
{
path: "*",
view: "./views/404.html",
script: "./modules/404.js"
}
];
export {
n as loadTemplate,
r as routes
};
let i = !1;
function n(o) {
return i = o, i;
}
async function r(o) {
try {
const e = await fetch(o);
if (!e.ok) throw new Error("Not found in public");
return await e.text();
} catch {
console.warn(`[TemplateLoader] Falling back to src for: ${o}`);
const t = /* @__PURE__ */ Object.assign({
"/src/modules/Login/components/Login.html": () => import("./Login-DaokiISj.js").then((l) => l.default)
}), s = o.split("/").pop() || "", a = Object.keys(t).find(
(l) => l.endsWith(`/${s}`)
);
if (!a)
throw new Error(`Template '${s}' not found in src fallback`);
return t[a]();
}
}
const u = [
{
path: "home",
view: () => r("./views/home.html"),
onLoad: () => console.log("Home loaded"),
layout: "./views/layouts/default.html",
// scriptBase: 'src/modules',
scripts: ["modules/home.ts"]
// accepts array of string
},
{
path: "login",
view: "./views/login.html",
onLoad: () => console.log("Login loaded"),
layout: "./views/layouts/default.html",
scripts: ["./modules/Login/Login.js"]
// accepts array of string
},
{
path: "profile/:id",
// /^profile\/(\d+)$/,
view: "./views/profile.html",
onLoad: () => console.log("Profile loaded"),
layout: "./views/layouts/default.html",
middleware: async (o) => {
if (console.log(o, ">>>>"), o?.user)
return o.user != "banned";
const e = !!o.user;
return await n(e) ? !0 : (location.hash = "#login", !1);
},
script: ["./modules/about.js"]
// accepts array of string
},
{
path: "about",
view: "./views/about.html",
layout: "./views/layouts/default.html",
middleware: () => (console.log("About middleware ran"), !0),
onLoad: () => console.log("About page is now visible"),
script: "./modules/about.js"
},
{
path: "contact",
view: "./views/contact.html",
layout: "./views/layouts/default.html",
middleware: () => (console.log("Checking something before showing contact"), confirm("Do you really want to view the contact page?"))
},
/// test life cycle
{
path: "dashboard",
view: "./views/dashboard.html",
script: "./modules/dashboard.js",
layout: "./views/layouts/dashboard.html"
// todo add route beforeEnter and beforeLeave
// beforeEnter: (params) => {
// if (!checkLoginStatus(false)) {
// navigate('login');
// return false;
// }
// return true;
// },
},
{
path: "*",
view: "./views/404.html",
script: "./modules/404.js"
}
];
export {
r as loadTemplate,
u as routes
};
function b(n) {
const s = /* @__PURE__ */ new Map(), o = (t) => {
(s.get(t) || []).forEach((e) => e(r[t]));
}, a = { ...n }, r = new Proxy(a, {
get(t, e, i) {
return typeof e == "string" && e in t ? t[e] : Reflect.get(t, e, i);
},
set(t, e, i, c) {
if (typeof e == "string" && e in t) {
const u = e;
return t[u] !== i && (t[u] = i, o(u)), !0;
}
return Reflect.set(t, e, i, c);
}
});
return {
state: r,
setState(t, e) {
r[t] = e;
},
subscribe(t, e) {
s.has(t) || s.set(t, []), s.get(t).push(e), e(r[t]);
}
};
}
function f(n, s = document) {
const o = (a) => s.querySelectorAll(a);
o("[data-bind], [data-model]").forEach((a) => {
const r = a.getAttribute("data-bind") || a.getAttribute("data-model");
r && (a.addEventListener("input", (t) => {
const e = t.target;
n.setState(r, e.value);
}), n.subscribe(r, (t) => {
a.value !== t && (a.value = t ?? "");
}));
}), o("[data-bind-text]").forEach((a) => {
const r = a.getAttribute("data-bind-text");
r && n.subscribe(r, (t) => {
a.textContent = t ?? "";
});
}), o("[data-bind-attr]").forEach((a) => {
(a.getAttribute("data-bind-attr")?.split(",") ?? []).forEach((r) => {
const [t, e] = r.trim().split(":").map((i) => i.trim());
n.subscribe(e, (i) => a.setAttribute(t, i));
});
});
}
function d({
props: n = {},
store: s,
callback: o
}) {
if (!s || typeof o != "function") return;
let a = JSON.stringify(n), r = JSON.stringify(s.state);
const t = () => {
const e = JSON.stringify(n), i = JSON.stringify(s.state);
(e !== a || i !== r) && (a = e, r = i, o({ props: n, state: s.state }));
};
Object.keys(s.state).forEach((e) => {
s.subscribe(e, t);
}), o({ props: n, state: s.state });
}
export {
f as S,
d as l,
b as y
};
import "./core/components/defineComponent.js";
import "./core/hooks/basic.js";
import "./core/utils/index.js";
import { handleHashChange as e } from "./routecore.js";
const i = (n) => ({
surge: (t) => {
window.addEventListener(
"hashchange",
() => e(t, n)
), window.addEventListener(
"DOMContentLoaded",
() => e(t, n)
);
}
});
export {
i as bootstrapContainers
};
import { y as i, l as p } from "./basic-Beb9CozU.js";
function r({ props: n }) {
const o = i({
bio: n?.bio || ""
});
return p({
props: n,
store: o,
callback: ({ props: t, state: e }) => {
console.log("[watchEffect:my-profile]", { props: t, state: e }), o.setState({ ...e, bio: e.bio });
}
}), {
store: o,
template: `
<div>
<h4>My Profile Component</h4>
<input type="text" data-model="bio" />
<p>Live bio: <span data-bind-text="bio"></span></p>
</div>
`,
onMount({ props: t }) {
console.log("[my-profile] onMount props", t), o.setState({ ...o.state, bio: t.bio });
},
onDestroy() {
console.log("[my-profile] destroyed");
},
onPropsChange(t, e) {
console.log("[my-profile] onMount props", n);
}
};
}
export {
r as init
};
function u(c, e, r) {
c.textContent = typeof e == "function" ? e() : e;
}
function d(c, e = {}) {
const r = Object.keys(e);
r.forEach((n) => {
const t = c.querySelector(`[data-ref="${n}"]`);
t && u(t, e[n]);
}), r.forEach((n) => {
const t = e[n];
typeof t?.subscribe != "function" || typeof t?.peek != "function" || (c.querySelectorAll(`[data-bind="${n}"]`).forEach((i) => {
i.textContent = t.peek(), t.subscribe((s) => i.textContent = s);
}), c.querySelectorAll("[data-bind-attr]").forEach((i) => {
(i.getAttribute("data-bind-attr")?.split(",") || []).forEach((o) => {
const [a, b] = o.trim().split(":");
b === n && (i.setAttribute(a, t.peek()), t.subscribe((f) => i.setAttribute(a, f)));
});
}));
});
}
export {
d as hydrateElmentAttibutesBindings
};
import { getNestedValue as c } from "../utils/index.js";
function d(e, n) {
return n.split(".").reduce((r, s) => r?.[s], e);
}
function i(e, n, r) {
const s = n.split("."), o = s.pop();
if (!o) return;
const u = s.reduce((t, a) => (t[a] === void 0 && (t[a] = {}), t[a]), e);
u[o] = r;
}
function p(e, n, r) {
document.querySelectorAll(`[data-model="${e}"]`).forEach((o) => {
const u = d(n, e) ?? "";
o.value !== u && (o.value = u);
const t = (a) => {
const l = a.target.value;
i(n, e, l), r({ ...n });
};
o.removeEventListener("input", t), o.addEventListener("input", t);
});
}
function v(e, n, r, s = document) {
const o = s.querySelectorAll(`[data-model="${e}"]`), u = c(n(), e);
o.forEach((t) => {
t.value !== u && (t.value = u), t.addEventListener("input", (a) => {
const l = a.target.value;
r(l);
});
});
}
export {
d as getDeep,
v as hydrateInputs,
p as hydrateInputsBindings,
i as setDeep
};
function o(t, n, e) {
t && (t.textContent = n(), e(() => {
t.textContent = n();
}));
}
export {
o as bindText
};
const t = /* @__PURE__ */ new Map();
function o(e) {
return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
}
function a(e, n) {
const r = o(e);
t.set(r, n);
}
function c(e) {
const n = o(e);
if (t.has(n))
return t.get(n);
}
export {
a as defineComponent,
c as getComponentLoader
};
import { hydrateComponent as p } from "../hydrations/hydrateComponent.js";
import { watchEffect as d, setupReactivity as l } from "../hooks/basic.js";
import { bindPropsToStore as u } from "../utils/index.js";
function C(a, o = {}) {
const t = a(o), i = document.createElement("div"), c = typeof t.template == "string" ? t.template : "<div><slot></slot></div>";
i.innerHTML = c;
const r = i.firstElementChild, s = {
props: o,
...t
};
if (t.store?.state) {
for (const [e, n] of Object.entries(o))
typeof t.store.state[e] > "u" && t.store.setState(e, n);
u(t), d({
props: o,
store: t.store,
callback: ({
props: e,
state: n
}) => {
for (const [f, m] of Object.entries(e))
typeof n[f] > "u" && t.store.setState(f, m);
typeof t.onPropsChanged == "function" && t.onPropsChanged({ props: e, state: n });
}
});
}
return requestAnimationFrame(async () => {
t.store && l(t.store, r), await p(r, s), typeof t.onMount == "function" && t.onMount(s);
}), r;
}
export {
C as renderComponent
};
import { hydrateComponent as b } from "../hydrations/hydrateComponent.js";
import { watchEffect as v, setupReactivity as y } from "../hooks/basic.js";
import { getComponentLoader as C } from "./defineComponent.js";
import { bindPropsToStore as w } from "../utils/index.js";
const A = /* @__PURE__ */ new Set([
"html",
"head",
"body",
"base",
"link",
"meta",
"style",
"title",
"address",
"article",
"aside",
"footer",
"header",
"h1",
"h2",
"h3",
"h4",
"h5",
"main",
"nav",
"section",
"div",
"span",
"a",
"p",
"ul",
"li",
"ol",
"table",
"thead",
"tbody",
"tr",
"th",
"td",
"form",
"input",
"button",
"select",
"option",
"textarea",
"label",
"fieldset",
"legend",
"script",
"noscript",
"template",
"slot",
"img",
"video",
"audio",
"canvas",
"iframe",
"strong",
"em",
"b",
"i",
"u",
"small",
"br",
"hr"
]);
function S(a) {
const n = a.toLowerCase();
return !A.has(n) && (n.includes("-") || /[A-Z]/.test(a));
}
function E(a) {
const n = {};
for (const f of Array.from(a.attributes)) {
let e = f.name;
e.startsWith(":") && (e = e.slice(1)), e = e.replace(/-([a-z])/g, (m, s) => s.toUpperCase()), n[e] = f.value;
}
return n;
}
async function P(a, n = {}) {
const f = [...a.querySelectorAll("*")].filter(
(e) => S(e.tagName)
);
for (const e of f) {
const m = e.tagName.toLowerCase();
try {
const s = C(m);
if (!s) continue;
const p = (await s())?.init;
if (typeof p != "function") continue;
const c = E(e);
console.log(c, "changing...");
const t = await p({
...n,
props: c
});
if (!t) continue;
if (t.store?.state)
for (const [o, i] of Object.entries(c))
typeof t.store.state[o] > "u" && t.store.setState(o, i);
w(t), v({
props: c,
store: t.store,
callback: ({ props: o, state: i }) => {
for (const [l, g] of Object.entries(o))
console.log(c, o, l, g, ".............."), typeof i[l] > "u" && t.store.setState(l, g);
typeof t.onPropsChanged == "function" && t.onPropsChanged({ props: o, state: i });
}
});
const u = document.createElement("div");
u.innerHTML = `<div>${t.template ?? ""}</div>`;
const r = u.firstElementChild;
if (!r) continue;
const d = {
...n,
...t,
props: c,
bindings: t.bindings || {}
};
t.store && y(t.store, r), await b(r, d);
for (const o of Array.from(e.children))
if (o.tagName === "TEMPLATE") {
const i = o.getAttribute("slot"), l = i ? r.querySelector(`slot[name="${i}"]`) : r.querySelector("slot:not([name])");
l && l.replaceWith(o.content.cloneNode(!0));
}
await P(r, d);
const h = Array.from(r.children);
e.replaceWith(...h), h.forEach((o) => {
t.store && y(t.store, o);
}), typeof t.onMount == "function" && requestAnimationFrame(() => {
t.onMount?.({ ...d });
});
} catch (s) {
console.warn(`Failed to load component <${m}>`, s);
}
}
}
export {
P as resolveChildComponents
};
function y(c) {
const s = /* @__PURE__ */ new Map(), i = (t) => {
(s.get(t) || []).forEach((o) => o(a[t]));
}, e = { ...c }, a = new Proxy(e, {
get(t, n, o) {
return typeof n == "string" && n in t ? t[n] : Reflect.get(t, n, o);
},
set(t, n, o, r) {
if (typeof n == "string" && n in t) {
const u = n;
return t[u] !== o && (t[u] = o, i(u)), !0;
}
return Reflect.set(t, n, o, r);
}
});
return {
state: a,
setState(t, n) {
a[t] = n;
},
subscribe(t, n) {
s.has(t) || s.set(t, []), s.get(t).push(n), n(a[t]);
}
};
}
function g(c = {}, s) {
const i = /* @__PURE__ */ new Map(), e = (r, u) => {
(i.get(r) || []).forEach((f) => f(u));
}, a = { ...s, ...c }, t = new Proxy(a, {
set(r, u, f, d) {
if (console.log(d), typeof u == "string" && Object.prototype.hasOwnProperty.call(r, u)) {
const b = u;
r[b] !== f && (r[b] = f, e(b, f));
}
return !0;
}
}), n = (r, u) => {
i.has(r) || i.set(r, []), i.get(r).push(u), u(t[r]);
}, o = {};
for (const r of Object.keys(t))
o[r] = (u) => (u !== void 0 && (t[r] = u), t[r]);
return { state: t, subscribe: n, bindings: o };
}
function h(c) {
document.querySelectorAll("[data-bind], [data-model]").forEach((s) => {
const i = s.getAttribute("data-bind") || s.getAttribute("data-model");
i && (s.addEventListener("input", (e) => {
const a = e.target;
c.state[i] = a.value;
}), c.subscribe(i, (e) => {
s.value !== e && (s.value = e);
}));
}), document.querySelectorAll("[data-bind-text]").forEach((s) => {
const i = s.getAttribute("data-bind-text");
i && c.subscribe(i, (e) => {
s.textContent = e;
});
});
}
function S(c, s = document) {
const i = (e) => s.querySelectorAll(e);
i("[data-bind], [data-model]").forEach((e) => {
const a = e.getAttribute("data-bind") || e.getAttribute("data-model");
a && (e.addEventListener("input", (t) => {
const n = t.target;
c.setState(a, n.value);
}), c.subscribe(a, (t) => {
e.value !== t && (e.value = t ?? "");
}));
}), i("[data-bind-text]").forEach((e) => {
const a = e.getAttribute("data-bind-text");
a && c.subscribe(a, (t) => {
e.textContent = t ?? "";
});
}), i("[data-bind-attr]").forEach((e) => {
(e.getAttribute("data-bind-attr")?.split(",") ?? []).forEach((t) => {
const [n, o] = t.trim().split(":").map((r) => r.trim());
c.subscribe(o, (r) => e.setAttribute(n, r));
});
});
}
function l({
props: c = {},
store: s,
callback: i
}) {
if (!s || typeof i != "function") return;
let e = JSON.stringify(c), a = JSON.stringify(s.state);
const t = () => {
const n = JSON.stringify(c), o = JSON.stringify(s.state);
(n !== e || o !== a) && (e = n, a = o, i({ props: c, state: s.state }));
};
Object.keys(s.state).forEach((n) => {
s.subscribe(n, t);
}), i({ props: c, state: s.state });
}
export {
h as bind,
S as setupReactivity,
g as usePropsStore,
y as useStore,
l as watchEffect
};
import { setupReactivity as h } from "../hooks/basic.js";
async function v(a, d = {}) {
if (!a || a instanceof HTMLElement && a.dataset.hydrated === "true") return;
a.dataset.hydrated = "true";
const {
store: i,
bindings: s = {},
effects: u = [],
actions: p = {},
props: e = {},
onPropsChange: r
} = d;
console.log("[hydrateComponent] Hydrating element:", a.tagName, { props: e }), i && h(i, a);
for (const t of u)
typeof t == "function" && await t({ element: a, context: d });
if (a.querySelectorAll("[data-bind-text]").forEach((t) => {
const n = t.dataset.bindText, o = s[n];
typeof o == "function" && (t.textContent = o());
}), a.querySelectorAll("[data-bind-html]").forEach((t) => {
const n = t.dataset.bindHtml, o = s[n];
typeof o == "function" && (t.innerHTML = o());
}), a.querySelectorAll("[data-model]").forEach((t) => {
const n = t.dataset.model, o = s[n];
if (typeof o == "function") {
const c = o();
t.value !== c && (t.value = c), t.addEventListener("input", (f) => {
const y = f.target;
o(y.value), typeof r == "function" && r({ props: e, element: a, changed: { [n]: y.value } });
});
}
}), a.querySelectorAll("[data-action]").forEach((t) => {
const n = t.dataset.action, o = t.dataset.eventType || "click", c = p[n];
typeof c == "function" && t.addEventListener(o, (f) => {
f.preventDefault(), c({
event: f,
element: t,
dataset: { ...t.dataset },
props: e,
store: i
});
});
}), typeof r == "function")
try {
await r({ props: e, element: a, changed: e });
} catch (t) {
console.warn("[hydrateComponent] onPropsChange error:", t);
}
}
export {
v as hydrateComponent
};
const o = /* @__PURE__ */ new Map();
function t(n, e) {
o.set(n, { lazy: e });
}
export {
o as componentRegistry,
t as defineComponent
};
function f(e, o) {
return o.split(".").reduce((s, t) => s?.[t], e);
}
function b(e, o, s) {
const t = o.split("."), i = t.pop(), l = t.reduce((n, r) => (n[r] = n[r] || {}, n[r]), e);
i && (l[i] = s);
}
function p(e) {
if (!(!e?.props || !e?.store)) {
e.bindings || (e.bindings = {});
for (const o of Object.keys(e.props))
o in e.bindings || (e.bindings[o] = (s) => (s !== void 0 && (e.store.state[o] = s), e.store.state[o]));
}
}
function _(e, o = {}, s = 3e3) {
e?.state && setTimeout(() => {
for (const t in o)
t in e.state || (e.state[t] = o[t]);
for (const t in e.state)
t in o || (o[t] = e.state[t]);
}, s);
}
const g = async (e, o) => {
const s = /* @__PURE__ */ Object.assign({ "/src/AppRoutes.ts": () => import("../../AppRoutes-C2_yRQI1.js"), "/src/main.ts": () => import("../../main-BSKe34Kd.js"), "/src/modules/404.ts": () => import("../../404-e-t8vB2c.js"), "/src/modules/Login/Login.ts": () => Promise.resolve().then(() => c), "/src/modules/about.ts": () => Promise.resolve().then(() => d), "/src/modules/components/childComponentSample.ts": () => import("../../childComponentSample-CGkaIy8z.js"), "/src/modules/contact.ts": () => Promise.resolve().then(() => u), "/src/modules/dashboard.ts": () => Promise.resolve().then(() => a), "/src/modules/home.ts": () => import("../../home-BLLy75-R.js"), "/src/vite-env.d.ts": () => Promise.resolve().then(() => m) });
console.log(o);
let t = e;
t.startsWith("/src") || (t = `/src/${t}`);
const l = /\.[jt]s$/.test(t) ? [t] : [`${t}.js`, `${t}.ts`];
for (const n of l) {
const r = s[n];
if (r)
return r();
}
throw console.error("[Framework] Available modules:", Object.keys(s)), new Error(`[Framework] Cannot find module for path: ${t}`);
}, c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), d = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), u = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), a = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" }));
export {
p as bindPropsToStore,
f as getNestedValue,
g as loadModule,
b as setNestedValue,
_ as syncStoreAndProps
};
const e = /* @__PURE__ */ new Map();
function o(n) {
return n.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase();
}
function r(n, t) {
const c = o(n);
e.set(c, t);
}
function a(n) {
const t = o(n);
if (e.has(t))
return e.get(t);
}
export {
r as a,
a as c
};
import { init as t } from "./childComponentSample-CGkaIy8z.js";
import { a as o } from "./defineComponent-DzIfUJ1K.js";
import { y as i } from "./basic-Beb9CozU.js";
o("my-profile", () => Promise.resolve({ init: t }));
function r({ props: n = {} }) {
return {
store: i({
name: "Victor",
image: "https://placekitten.com/200/200"
}),
template: `
<main>
<h2>Welcom to Frameless</h2>
<div slot="header">Main Section</div>
<div slot="sidebar">
<my-profile :bio="this is a demo"></my-profile>
</div>
<div style="margin-top:20px">
<label>Your Name:</label>
<h3>Hello, <strong data-bind-text="name"></strong>!</h3>
<input type="text" data-model="name" />
</div>
<!-- Type 1: Template slot -->
<template slot="more1">
<h1>This is the header</h1>
</template>
<!-- Type 2: Component slot -->
<div slot="more2">
another slot method
</div>
<!-- Type 3: Fallback unnamed content -->
<div>
<p>This is default content in the unnamed slot</p>
</div>
</main>
`,
onMount(e) {
console.log("[home.js] Mounted", e);
},
onDestroy() {
console.log("[home.js] Destroyed");
}
};
}
export {
r as init
};
interface IRoutes {
path: string | RegExp;
view: string | (() => Promise<string | {
default: string;
}>) | any;
layout?: string | (() => Promise<string | {
default: string;
}>) | any;
style?: string | string[];
styles?: string | string[];
script?: string | string[];
scripts?: string | string[];
scriptBase?: string;
onLoad?: () => void;
}
export declare const bootstrapContainers: (routes: IRoutes[]) => {
surge: (app: HTMLElement | Document | any) => void;
};
export {};
type Props = Record<string, any>;
export declare function hydrateElmentAttibutesBindings(rootEl: HTMLElement, props?: Props): void;
export {};
export declare function getDeep<T = any>(obj: Record<string, any>, path: string): T | undefined | any;
export declare function setDeep(obj: Record<string, any>, path: string, value: any): void;
export declare function hydrateInputsBindings(key: string, valueObj: Record<string, any>, setter: (updatedValue: Record<string, any>) => void): void;
export declare function hydrateInputs(keyPath: string, state: () => Record<string, any>, setter: (val: string) => void, root?: Document | HTMLElement): void;
export declare function bindText(el: HTMLElement | null, get: () => string, subscribe: (callback: () => void) => void): void;
type ComponentLoader = () => Promise<any>;
/**
* Registers a component loader function under a normalized kebab-case name.
*
* @param name - The component's name (e.g., `MyComponent`).
* @param loaderFn - A function that returns a dynamic import promise.
*/
export declare function defineComponent(name: string, loaderFn: ComponentLoader): void;
/**
* Resolves a component loader function by tag name.
*
* @param tagName - The tag name to look up (e.g., `my-component`).
* @returns The registered loader function, or undefined if not found.
*/
export declare function getComponentLoader(tagName: string): ComponentLoader | undefined;
export {};
type Props = Record<string, any>;
type State = Record<string, any>;
interface Store {
state: State;
setState: (key: string, value: any) => void;
}
interface ComponentInstance {
template?: string;
store?: Store;
onMount?: (ctx: any) => void;
onPropsChanged?: (ctx: {
props: Props;
state: State;
}) => void;
}
type ComponentFn = (props: Props) => ComponentInstance;
/**
* Renders a component and sets up its reactive lifecycle.
*
* @param ComponentFn - The function that returns the component definition.
* @param props - Initial props to pass to the component.
* @returns HTMLElement root of the component.
*/
export declare function renderComponent(ComponentFn: ComponentFn, props?: Props): HTMLElement;
export {};
export declare function resolveChildComponents(root: HTMLElement, parentContext?: Record<string, any>): Promise<void>;
type Subscriber<T> = (value: T) => void;
export declare function useStore<T extends Record<string, any>>(initialState: T): {
state: T;
setState<K extends keyof T>(key: K, val: T[K]): void;
subscribe<K extends keyof T>(key: K, fn: Subscriber<T[K] | any>): void;
};
type Callback<T> = (val: T) => void;
export declare function usePropsStore<T extends Record<string, any>>(initial: Partial<T> | undefined, fallback: T): {
state: T;
subscribe: <K extends keyof T>(key: K, cb: Callback<T[K]> | any) => void;
bindings: { [K in keyof T]: (val?: T[K]) => T[K]; };
};
export declare function bind<T extends Record<string, any>>(store: {
state: T | any;
subscribe: <K extends keyof T>(key: K, cb: (val: T[K]) => void) => void;
}): void;
export declare function setupReactivity<T extends Record<string, any>>(store: {
state: T;
setState: <K extends keyof T>(key: K, val: T[K]) => void | any;
subscribe: <K extends keyof T>(key: K, cb: (val: T[K]) => void) => void;
} | any, root?: HTMLElement | HTMLDivElement | Document): void;
type Props = Record<string, any>;
type WatchEffectArgs = {
props: Record<string, any>;
store: any;
callback: (ctx: {
props: Record<string, any>;
state: Record<string, any>;
}) => void;
};
export declare function watchEffect<T extends Record<string, any>>({ props, store, callback, }: {
props: Props;
store: {
state: T;
subscribe: <K extends keyof T>(key: K, cb: () => void) => void;
} | any;
callback: (args: {
props: Props;
state: T;
}) => void;
} | WatchEffectArgs): void;
export {};
type BindFunction = () => any;
type ModelBindFunction = (value?: any) => any;
type ActionFunction = (params: {
event: Event;
element: HTMLElement;
dataset: DOMStringMap;
props: Record<string, any>;
store?: any;
}) => void;
type EffectFunction = (args: {
element: Element;
context: ComponentContext;
}) => Promise<void> | void;
type OnPropsChangeFunction = (args: {
props: Record<string, any>;
element: Element;
changed: Record<string, any>;
}) => Promise<void> | void;
interface ComponentContext {
store?: any;
bindings?: Record<string, BindFunction | ModelBindFunction>;
effects?: EffectFunction[];
actions?: Record<string, ActionFunction>;
props?: Record<string, any>;
onPropsChange?: OnPropsChangeFunction;
}
export declare function hydrateComponent(element: Element | null, context?: ComponentContext): Promise<void>;
export {};
export declare const componentRegistry: Map<any, any>;
export declare function defineComponent(name: string, loaderFn: any): void;
export declare function getNestedValue<T = any>(obj: Record<string, any>, keyPath: string): T | undefined;
export declare function setNestedValue(obj: Record<string, any>, path: string, value: any): void;
interface Store {
state: Record<string, any>;
}
interface Instance {
props: Record<string, any>;
store: Store;
bindings?: Record<string, (val?: any) => any>;
}
export declare function bindPropsToStore(instance: Instance | any): void;
export declare function syncStoreAndProps(store: Store, props?: Record<string, any>, delay?: number): void;
export declare const loadModule: (path: string, basePath?: string) => Promise<any>;
export {};
export { defineComponent } from './core/components/defineComponent';
export { useStore, watchEffect, usePropsStore, bind, setupReactivity, } from './core/hooks/basic';
export { bindPropsToStore, syncStoreAndProps } from './core/utils';
export { bootstrapContainers } from './bootstrap';
interface Route {
path: string | RegExp;
view: string | (() => Promise<string | {
default: string;
}>);
layout?: string | (() => Promise<string | {
default: string;
}>);
style?: string | string[];
styles?: string | string[];
script?: string | string[];
scripts?: string | string[];
scriptBase?: string;
onLoad?: () => void;
}
declare global {
interface Window {
__currentDestroy?: () => void;
}
}
interface RenderOptions {
app: HTMLElement;
route: Route;
viewHTML: string;
layoutHTML?: string;
params: Record<string, any>;
match?: any;
}
export declare function slotAwareRender({ app, route, viewHTML, layoutHTML, params, match }: RenderOptions): Promise<void>;
export declare function handleRoute(app: HTMLElement, routes: Route[]): void;
/**
* Attempts to load a file from the Vite src directory using import.meta.glob
* @param {string} filename - e.g. "Main.html" or "views/About.html"
* @returns {Promise<string>} - raw file content
*/
export declare function fallbackImportFromSrc(filename: string): Promise<string>;
export declare function resolveContent(input: string | (() => Promise<string | {
default: string;
}>) | undefined): Promise<string>;
export declare function loadPage(app: HTMLElement, route: Route, params?: Record<string, any>, match?: RegExpMatchArray | null): Promise<void>;
export declare function handleHashChange(app: HTMLElement | Document | any, routes: Route[]): void;
export {};
const e = `<div>\r
<h2>Hello <span data-ref="userName"></span>!</h2>\r
\r
<input\r
type="text"\r
placeholder="Enter name"\r
data-model="userName"\r
/>\r
</div>\r
`;
export {
e as default
};
const n = `<div>\r
<h2>Hello <span data-ref="userName"></span>!</h2>\r
\r
<input\r
type="text"\r
placeholder="Enter name"\r
data-model="userName"\r
/>\r
</div>\r
`;
export {
n as default
};
import { S as b, l as L } from "./basic-Beb9CozU.js";
import { c as T } from "./defineComponent-DzIfUJ1K.js";
import { routes as q } from "./AppRoutes-C2_yRQI1.js";
function x(t) {
if (!(!t?.props || !t?.store)) {
t.bindings || (t.bindings = {});
for (const e of Object.keys(t.props))
e in t.bindings || (t.bindings[e] = (s) => (s !== void 0 && (t.store.state[e] = s), t.store.state[e]));
}
}
const W = async (t, e) => {
const s = /* @__PURE__ */ Object.assign({ "/src/AppRoutes.ts": () => import("./AppRoutes-B3AIMT6f-DAhYpD0r.js"), "/src/main.ts": () => import("./main-CGBgU9q6-CGBgU9q6.js"), "/src/modules/404.ts": () => import("./404-e-t8vB2c-CldZQt_1.js"), "/src/modules/Login/Login.ts": () => Promise.resolve().then(() => N), "/src/modules/about.ts": () => Promise.resolve().then(() => k), "/src/modules/components/childComponentSample.js": () => Promise.resolve().then(() => H), "/src/modules/contact.ts": () => Promise.resolve().then(() => F), "/src/modules/dashboard.ts": () => Promise.resolve().then(() => z), "/src/modules/home.ts": () => Promise.resolve().then(() => R), "/src/vite-env.d.ts": () => Promise.resolve().then(() => D) });
console.log(e);
let o = t;
o.startsWith("/src") || (o = `/src/${o}`), o.endsWith(".js") || (o += ".js");
const a = s[o];
if (!a)
throw console.error("[Framework] Available:", Object.keys(s)), new Error(`[Framework] Cannot find module: ${o}`);
return a();
}, N = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), F = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), R = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" })), D = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null
}, Symbol.toStringTag, { value: "Module" }));
async function v(t, e = {}) {
if (!t || t instanceof HTMLElement && t.dataset.hydrated === "true") return;
t.dataset.hydrated = "true";
const {
store: s,
bindings: o = {},
effects: a = [],
actions: l = {},
props: c = {},
onPropsChange: i
} = e;
console.log("[hydrateComponent] Hydrating element:", t.tagName, { props: c }), s && b(s, t);
for (const n of a)
typeof n == "function" && await n({ element: t, context: e });
if (t.querySelectorAll("[data-bind-text]").forEach((n) => {
const u = n.dataset.bindText, r = o[u];
typeof r == "function" && (n.textContent = r());
}), t.querySelectorAll("[data-bind-html]").forEach((n) => {
const u = n.dataset.bindHtml, r = o[u];
typeof r == "function" && (n.innerHTML = r());
}), t.querySelectorAll("[data-model]").forEach((n) => {
const u = n.dataset.model, r = o[u];
if (typeof r == "function") {
const d = r();
n.value !== d && (n.value = d), n.addEventListener("input", (h) => {
const p = h.target;
r(p.value), typeof i == "function" && i({ props: c, element: t, changed: { [u]: p.value } });
});
}
}), t.querySelectorAll("[data-action]").forEach((n) => {
const u = n.dataset.action, r = n.dataset.eventType || "click", d = l[u];
typeof d == "function" && n.addEventListener(r, (h) => {
h.preventDefault(), d({
event: h,
element: n,
dataset: { ...n.dataset },
props: c,
store: s
});
});
}), typeof i == "function")
try {
await i({ props: c, element: t, changed: c });
} catch (n) {
console.warn("[hydrateComponent] onPropsChange error:", n);
}
}
const I = /* @__PURE__ */ new Set([
"html",
"head",
"body",
"base",
"link",
"meta",
"style",
"title",
"address",
"article",
"aside",
"footer",
"header",
"h1",
"h2",
"h3",
"h4",
"h5",
"main",
"nav",
"section",
"div",
"span",
"a",
"p",
"ul",
"li",
"ol",
"table",
"thead",
"tbody",
"tr",
"th",
"td",
"form",
"input",
"button",
"select",
"option",
"textarea",
"label",
"fieldset",
"legend",
"script",
"noscript",
"template",
"slot",
"img",
"video",
"audio",
"canvas",
"iframe",
"strong",
"em",
"b",
"i",
"u",
"small",
"br",
"hr"
]);
function B(t) {
const e = t.toLowerCase();
return !I.has(e) && (e.includes("-") || /[A-Z]/.test(t));
}
function U(t) {
const e = {};
for (const s of Array.from(t.attributes)) {
let o = s.name;
o.startsWith(":") && (o = o.slice(1)), o = o.replace(/-([a-z])/g, (a, l) => l.toUpperCase()), e[o] = s.value;
}
return e;
}
async function M(t, e = {}) {
const s = [...t.querySelectorAll("*")].filter(
(o) => B(o.tagName)
);
for (const o of s) {
const a = o.tagName.toLowerCase();
try {
const l = T(a);
if (!l) continue;
const c = (await l())?.init;
if (typeof c != "function") continue;
const i = U(o);
console.log(i, "changing...");
const n = await c({
...e,
props: i
});
if (!n) continue;
if (n.store?.state)
for (const [p, m] of Object.entries(i))
typeof n.store.state[p] > "u" && n.store.setState(p, m);
x(n), L({
props: i,
store: n.store,
callback: ({ props: p, state: m }) => {
for (const [f, y] of Object.entries(p))
console.log(i, p, f, y, ".............."), typeof m[f] > "u" && n.store.setState(f, y);
typeof n.onPropsChanged == "function" && n.onPropsChanged({ props: p, state: m });
}
});
const u = document.createElement("div");
u.innerHTML = `<div>${n.template ?? ""}</div>`;
const r = u.firstElementChild;
if (!r) continue;
const d = {
...e,
...n,
props: i,
bindings: n.bindings || {}
};
n.store && b(n.store, r), await v(r, d);
for (const p of Array.from(o.children))
if (p.tagName === "TEMPLATE") {
const m = p.getAttribute("slot"), f = m ? r.querySelector(`slot[name="${m}"]`) : r.querySelector("slot:not([name])");
f && f.replaceWith(p.content.cloneNode(!0));
}
await M(r, d);
const h = Array.from(r.children);
o.replaceWith(...h), h.forEach((p) => {
n.store && b(n.store, p);
}), typeof n.onMount == "function" && requestAnimationFrame(() => {
n.onMount?.({ ...d });
});
} catch (l) {
console.warn(`Failed to load component <${a}>`, l);
}
}
}
const $ = /* @__PURE__ */ new Set(), g = "home";
let O = null;
console.log(O);
function Z() {
const t = decodeURIComponent(location.hash.slice(1)), [e = g, s = ""] = t.split("?"), o = Object.fromEntries(new URLSearchParams(s));
return { path: e, params: o };
}
function G(t, e) {
const s = (l) => {
for (const c of e) {
if (typeof c.path == "string" && c.path === l)
return { route: c, match: null, params: {} };
if (typeof c.path == "string" && c.path.includes(":")) {
const i = [], n = c.path.split("/").map((d) => d.startsWith(":") ? (i.push(d.slice(1)), "([^/]+)") : d).join("/"), u = new RegExp(`^${n}$`), r = l.match(u);
if (r) {
const d = Object.fromEntries(i.map((h, p) => [h, r[p + 1]]));
return { route: c, match: r, params: d };
}
}
if (c.path instanceof RegExp) {
const i = l.match(c.path);
if (i) return { route: c, match: i, params: {} };
}
}
return null;
};
let o = s(t);
if (o) return o;
if (t.endsWith("/")) {
for (const l of [`${t}index`, `${t}home`])
if (o = s(l), o) return o;
}
const a = e.find((l) => l.path === "*");
return a ? { route: a, match: null, params: {} } : null;
}
function J(t, e) {
const s = [...t.children], o = [...e];
for (let a = 0; a < o.length; a++) {
const l = o[a], c = s[a];
c ? l.isEqualNode(c) || t.replaceChild(l, c) : t.appendChild(l);
}
for (let a = o.length; a < s.length; a++)
s[a].remove();
}
function j(t) {
const e = document.createElement("div");
return e.innerHTML = t, e;
}
function S(t, e) {
((s, o) => {
s.querySelectorAll("slot[name]").forEach((l) => {
const c = l.getAttribute("name"), i = o.querySelector(`template[slot="${c}"]`);
if (i) {
const u = i.content.cloneNode(!0);
S(u, o), l.replaceWith(u);
return;
}
const n = o.querySelector(`[slot="${c}"]:not(template)`);
n && l.replaceWith(n.cloneNode(!0));
});
const a = s.querySelector("slot:not([name])");
if (a) {
const l = o.querySelector("template:not([slot])");
if (l) {
const i = l.content.cloneNode(!0);
S(i, o), a.replaceWith(i);
return;
}
const c = [...o.children].filter(
(i) => i.tagName !== "TEMPLATE" && !i.hasAttribute("slot")
);
c.length > 0 && a.replaceWith(...c.map((i) => i.cloneNode(!0)));
}
})(t, e);
}
function K(t, e) {
const s = document.getElementById(e);
s && s.remove();
const o = document.createElement("style");
o.id = e, o.textContent = t, document.head.appendChild(o);
}
async function Q({
app: t,
route: e,
viewHTML: s,
layoutHTML: o,
params: a,
match: l = null
}) {
const c = { ...a }, i = { app: t, params: a, props: c }, n = j(s);
let u = n, r = {}, d;
if (console.log(l), o) {
const p = j(o);
S(p, n), u = p;
}
if (e.styles || e.style) {
const p = Array.isArray(e.styles || e.style) ? e.styles || e.style : [e.style];
for (const m of p) {
const f = await (await fetch(m)).text();
K(f, `scoped-style-${e.path}`);
}
}
const h = async () => {
const p = u.cloneNode(!0);
if (e.script || e.scripts) {
const f = Array.isArray(e.scripts || e.script) ? e.scripts || e.script : [e.script];
if (d = await W(`${f[0]}`, e.scriptBase || "modules"), typeof d.init == "function") {
r = await d.init({ ...i }) || {};
const { template: y } = r;
if (y && typeof y == "string") {
const E = document.createElement("div");
E.innerHTML = y;
for (const w of [...E.children]) {
const _ = w.getAttribute("slot") || null;
await v(w, {
...i,
...r,
props: { ...c }
});
const P = _ ? p.querySelector(`slot[name="${_}"]`) : p.querySelector("slot:not([name])");
P && P.replaceWith(w);
}
}
requestAnimationFrame(() => {
r.onMount?.({ ...i, ...r, props: c }), r.store && b(r.store, t), O = () => r.onDestroy?.();
});
}
}
await v(p, {
...i,
...r,
props: { ...c }
}), await M(p, {
...i,
...r,
props: { ...c }
}), requestAnimationFrame(() => {
J(t, p.children), [...t.children].forEach((f) => {
r.store && b(r.store, f);
});
});
const m = new DOMParser().parseFromString(s, "text/html");
for (const f of m.querySelectorAll("script")) {
const y = document.createElement("script");
if (f.src) {
if ($.has(f.src)) continue;
y.src = f.src, $.add(f.src);
} else
y.textContent = f.textContent;
f.type && (y.type = f.type), document.body.appendChild(y);
}
e.onLoad?.();
};
await h(), L({
props: c,
store: r.store,
callback: async ({ props: p, state: m }) => {
typeof r.onPropsChanged == "function" && await r.onPropsChanged({
props: p,
state: m,
context: { ...i, ...r }
}), console.log("[slotAwareRender] Watch triggered", { newProps: p, state: m }), await h();
}
});
}
function V(t, e) {
if (location.hash === "#") {
history.replaceState(null, "", `#${g}`);
return;
}
const { path: s, params: o } = Z(), a = o.queryParams;
let l = s;
(!location.hash || s === g) && (l = g, location.hash || history.replaceState(null, "", `#${g}`));
const c = G(l, e);
if (c) {
const { route: i, match: n, params: u } = c, r = {
...a || {},
...u || {}
};
Y(t, i, r, n);
} else
t.innerHTML = "<h2>404 - Not Found</h2>";
}
async function X(t) {
const e = t.replace(/^\/+/, ""), s = /* @__PURE__ */ Object.assign({
"/src/modules/Login/components/Login.html": () => import("./Login-DaokiISj-DOK9VfTk.js").then((a) => a.default)
}), o = Object.keys(s).find(
(a) => a.endsWith(`/${e}`) || a.endsWith(e)
);
if (!o)
throw new Error(`[fallbackImportFromSrc] '${t}' not found in src`);
try {
return await s[o]();
} catch (a) {
throw new Error(`[fallbackImportFromSrc] Failed to import '${t}' from '${o}': ${a.message}`);
}
}
async function A(t) {
if (!t) return "";
if (typeof t == "function") {
const e = await t();
return typeof e == "string" ? e : e?.default || "";
}
if (typeof t == "string") {
if (/<\/?[a-z][\s\S]*>/i.test(t.trim())) return t;
try {
const e = await fetch(t);
if (!e.ok) throw new Error("Not found in public");
return await e.text();
} catch {
try {
return await X(t);
} catch (e) {
throw console.error(e.message), new Error(`[resolveContent] Cannot resolve: ${t}`);
}
}
}
return "";
}
async function Y(t, e, s = {}, o = null) {
try {
window.__currentDestroy?.();
const [a, l] = await Promise.all([
A(e.view),
A(e.layout)
]);
await Q({
app: t,
route: e,
viewHTML: a,
layoutHTML: l,
params: s,
match: o
}), console.log("running...");
} catch (a) {
console.error("Render error:", a), t.innerHTML = "<h2>Error loading page</h2>";
}
}
function C(t, e) {
V(t, e);
}
const tt = (t) => ({
surge: (e) => {
window.addEventListener(
"hashchange",
() => C(e, t)
), window.addEventListener(
"DOMContentLoaded",
() => C(e, t)
);
}
}), et = document.getElementById("app");
tt(q).surge(et);
const o = document.getElementById("app");
console.log(o);
import { defineComponent as r } from "./core/components/defineComponent.js";
import { bind as p, setupReactivity as n, usePropsStore as s, useStore as f, watchEffect as i } from "./core/hooks/basic.js";
import { bindPropsToStore as a, syncStoreAndProps as c } from "./core/utils/index.js";
import { bootstrapContainers as x } from "./bootstrap.js";
export {
p as bind,
a as bindPropsToStore,
x as bootstrapContainers,
r as defineComponent,
n as setupReactivity,
c as syncStoreAndProps,
s as usePropsStore,
f as useStore,
i as watchEffect
};
import { hydrateComponent as A } from "./core/hydrations/hydrateComponent.js";
import { watchEffect as N, setupReactivity as $ } from "./core/hooks/basic.js";
import { resolveChildComponents as L } from "./core/components/resolveChildComponent.js";
import { loadModule as R } from "./core/utils/index.js";
const x = /* @__PURE__ */ new Set(), y = "home";
let P = null;
console.log(P);
function v() {
const e = decodeURIComponent(location.hash.slice(1)), [t = y, s = ""] = e.split("?"), r = Object.fromEntries(new URLSearchParams(s));
return { path: t, params: r };
}
function T(e, t) {
const s = (a) => {
for (const n of t) {
if (typeof n.path == "string" && n.path === a)
return { route: n, match: null, params: {} };
if (typeof n.path == "string" && n.path.includes(":")) {
const i = [], l = n.path.split("/").map((p) => p.startsWith(":") ? (i.push(p.slice(1)), "([^/]+)") : p).join("/"), d = new RegExp(`^${l}$`), c = a.match(d);
if (c) {
const p = Object.fromEntries(i.map((g, f) => [g, c[f + 1]]));
return { route: n, match: c, params: p };
}
}
if (n.path instanceof RegExp) {
const i = a.match(n.path);
if (i) return { route: n, match: i, params: {} };
}
}
return null;
};
let r = s(e);
if (r) return r;
if (e.endsWith("/")) {
for (const a of [`${e}index`, `${e}home`])
if (r = s(a), r) return r;
}
const o = t.find((a) => a.path === "*");
return o ? { route: o, match: null, params: {} } : null;
}
function D(e, t) {
const s = [...e.children], r = [...t];
for (let o = 0; o < r.length; o++) {
const a = r[o], n = s[o];
n ? a.isEqualNode(n) || e.replaceChild(a, n) : e.appendChild(a);
}
for (let o = r.length; o < s.length; o++)
s[o].remove();
}
function M(e) {
const t = document.createElement("div");
return t.innerHTML = e, t;
}
function S(e, t) {
((r, o) => {
r.querySelectorAll("slot[name]").forEach((n) => {
const i = n.getAttribute("name"), l = o.querySelector(`template[slot="${i}"]`);
if (l) {
const c = l.content.cloneNode(!0);
S(c, o), n.replaceWith(c);
return;
}
const d = o.querySelector(`[slot="${i}"]:not(template)`);
d && n.replaceWith(d.cloneNode(!0));
});
const a = r.querySelector("slot:not([name])");
if (a) {
const n = o.querySelector("template:not([slot])");
if (n) {
const l = n.content.cloneNode(!0);
S(l, o), a.replaceWith(l);
return;
}
const i = [...o.children].filter(
(l) => l.tagName !== "TEMPLATE" && !l.hasAttribute("slot")
);
i.length > 0 && a.replaceWith(...i.map((l) => l.cloneNode(!0)));
}
})(e, t);
}
function F(e, t) {
const s = document.getElementById(t);
s && s.remove();
const r = document.createElement("style");
r.id = t, r.textContent = e, document.head.appendChild(r);
}
async function O({
app: e,
route: t,
viewHTML: s,
layoutHTML: r,
params: o,
match: a = null
}) {
const n = { ...o }, i = { app: e, params: o, props: n }, l = M(s);
let d = l, c = {}, p;
if (console.log(a), r) {
const f = M(r);
S(f, l), d = f;
}
if (t.styles || t.style) {
const f = Array.isArray(t.styles || t.style) ? t.styles || t.style : [t.style];
for (const u of f) {
const h = await (await fetch(u)).text();
F(h, `scoped-style-${t.path}`);
}
}
const g = async () => {
const f = d.cloneNode(!0);
if (t.script || t.scripts) {
const m = Array.isArray(t.scripts || t.script) ? t.scripts || t.script : [t.script];
if (p = await R(`${m[0]}`, t.scriptBase || "modules"), typeof p.init == "function") {
c = await p.init({ ...i }) || {};
const { template: h } = c;
if (h && typeof h == "string") {
const E = document.createElement("div");
E.innerHTML = h;
for (const w of [...E.children]) {
const C = w.getAttribute("slot") || null;
await A(w, {
...i,
...c,
props: { ...n }
});
const b = C ? f.querySelector(`slot[name="${C}"]`) : f.querySelector("slot:not([name])");
b && b.replaceWith(w);
}
}
requestAnimationFrame(() => {
c.onMount?.({ ...i, ...c, props: n }), c.store && $(c.store, e), P = () => c.onDestroy?.();
});
}
}
await A(f, {
...i,
...c,
props: { ...n }
}), await L(f, {
...i,
...c,
props: { ...n }
}), requestAnimationFrame(() => {
D(e, f.children), [...e.children].forEach((m) => {
c.store && $(c.store, m);
});
});
const u = new DOMParser().parseFromString(s, "text/html");
for (const m of u.querySelectorAll("script")) {
const h = document.createElement("script");
if (m.src) {
if (x.has(m.src)) continue;
h.src = m.src, x.add(m.src);
} else
h.textContent = m.textContent;
m.type && (h.type = m.type), document.body.appendChild(h);
}
t.onLoad?.();
};
await g(), N({
props: n,
store: c.store,
callback: async ({ props: f, state: u }) => {
typeof c.onPropsChanged == "function" && await c.onPropsChanged({
props: f,
state: u,
context: { ...i, ...c }
}), console.log("[slotAwareRender] Watch triggered", { newProps: f, state: u }), await g();
}
});
}
function W(e, t) {
if (location.hash === "#") {
history.replaceState(null, "", `#${y}`);
return;
}
const { path: s, params: r } = v(), o = r.queryParams;
let a = s;
(!location.hash || s === y) && (a = y, location.hash || history.replaceState(null, "", `#${y}`));
const n = T(a, t);
if (n) {
const { route: i, match: l, params: d } = n, c = {
...o || {},
...d || {}
};
k(e, i, c, l);
} else
e.innerHTML = "<h2>404 - Not Found</h2>";
}
async function j(e) {
const t = e.replace(/^\/+/, ""), s = /* @__PURE__ */ Object.assign({
"/src/modules/Login/components/Login.html": () => import("./Login-DaokiISj.js").then((o) => o.default)
}), r = Object.keys(s).find(
(o) => o.endsWith(`/${t}`) || o.endsWith(t)
);
if (!r)
throw new Error(`[fallbackImportFromSrc] '${e}' not found in src`);
try {
return await s[r]();
} catch (o) {
throw new Error(`[fallbackImportFromSrc] Failed to import '${e}' from '${r}': ${o.message}`);
}
}
async function q(e) {
if (!e) return "";
if (typeof e == "function") {
const t = await e();
return typeof t == "string" ? t : t?.default || "";
}
if (typeof e == "string") {
if (/<\/?[a-z][\s\S]*>/i.test(e.trim())) return e;
try {
const s = await fetch(e);
if (!s.ok) throw new Error("Not found in public");
return await s.text();
} catch {
try {
return await j(e);
} catch (s) {
throw console.error(s.message), new Error(`[resolveContent] Cannot resolve: ${e}`);
}
}
}
return "";
}
async function k(e, t, s = {}, r = null) {
try {
window.__currentDestroy?.();
const [o, a] = await Promise.all([
q(t.view),
q(t.layout)
]);
await O({
app: e,
route: t,
viewHTML: o,
layoutHTML: a,
params: s,
match: r
}), console.log("running...");
} catch (o) {
console.error("Render error:", o), e.innerHTML = "<h2>Error loading page</h2>";
}
}
function B(e, t) {
W(e, t);
}
export {
j as fallbackImportFromSrc,
B as handleHashChange,
W as handleRoute,
k as loadPage,
q as resolveContent,
O as slotAwareRender
};