@remyyy/velox 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";let u=null,m=0;const C=new Set;function T(e){m++;try{return e()}finally{if(m--,m===0){const t=[...C];C.clear(),t.forEach(n=>n.execute())}}}function A(e){let t=e;const n=new Set;return[()=>(u&&(n.add(u),u.dependencies.add(n)),t),a=>{const s=typeof a=="function"?a(t):a;t!==s&&(t=s,[...n].forEach(c=>{m>0?C.add(c):c.execute()}))}]}function j(e){u&&u.cleanups.push(e)}function y(e){const t={execute(){b(t);const n=u;u=t;try{e()}finally{u=n}},dependencies:new Set,cleanups:[]};return t.execute(),()=>b(t)}function B(e){const[t,n]=A(void 0);return y(()=>n(e())),t}function b(e){e.dependencies.forEach(t=>t.delete(e)),e.dependencies.clear(),e.cleanups.forEach(t=>t()),e.cleanups=[]}let l=[{hydrationPath:"0",routerBase:"",custom:new Map}];function N(e){const t=l[l.length-1];l.push({...t,...e})}function g(){l.pop()}function E(){return l[l.length-1]}function P(e=!1){l=[{hydrationPath:"0",routerBase:"",custom:e&&l.length>0?l[0].custom:new Map}]}let L=!1;function D(e){L=e}const p=Symbol("velox_cleanup");function S(e,t){const n=e;n[p]||(n[p]=[]),n[p].push(t)}function v(e){const t=e;t[p]&&(t[p].forEach(n=>n()),t[p]=void 0),e.hasChildNodes()&&e.childNodes.forEach(n=>v(n))}function I(e,t,...n){const i=t||{};let d=n.flat().filter(a=>a!=null&&a!==!0&&a!==!1);return d.length===0&&i.children&&(d=Array.isArray(i.children)?i.children.flat():[i.children]),{exec:()=>{if(typeof e=="function")return e({...i,children:d}).exec();const s=E().hydrationPath;let c=null;if(L){const o=document.querySelector(`[data-hid="${s}"]`);o&&o.tagName.toLowerCase()===e.toLowerCase()&&(c=o,c.removeAttribute("data-hid"))}c||(c=document.createElement(e));for(const[o,h]of Object.entries(i))if(!(o==="children"||o==="key"))if(o.startsWith("on")&&typeof h=="function"){const x=o.toLowerCase().substring(2);c.addEventListener(x,f=>{T(()=>h(f))})}else if(typeof h=="function"){const x=y(()=>{const f=h();w(c,o,f)});S(c,x)}else w(c,o,h);let r=c.firstChild;for(d.forEach((o,h)=>{const x=`${s}.${h}`;N({hydrationPath:x});let f=null;o&&typeof o=="object"&&"exec"in o?f=o.exec():typeof o=="function"?f=$(o,r):f=M(String(o),r),f&&(r===f?r=r.nextSibling:(f.parentNode,c.insertBefore(f,r))),g()});r;){const o=r.nextSibling;r.parentNode===c&&(v(r),c.removeChild(r)),r=o}return c}}}function $(e,t){let n;t&&t.nodeType===Node.TEXT_NODE?n=t:n=document.createTextNode("");const i=y(()=>{const d=e(),a=String(d??"");n.data!==a&&(n.data=a)});return S(n,i),n}function M(e,t){if(t&&t.nodeType===Node.TEXT_NODE){const n=t;return n.data!==e&&(n.data=e),n}return document.createTextNode(e)}function w(e,t,n){n==null?e.removeAttribute(t):t==="className"||t==="class"?e.className=n:t==="style"&&typeof n=="object"?Object.assign(e.style,n):e.setAttribute(t,String(n))}function O(e,t){P(),t.textContent="";const i=e({}).exec();t.appendChild(i)}const _=e=>({exec:()=>{const n=E().hydrationPath,i=document.createDocumentFragment(),d=e.children||[];return(Array.isArray(d)?d.flat():[d]).forEach((s,c)=>{const r=`${n}.${c}`;N({hydrationPath:r});let o=null;s&&s.exec?o=s.exec():typeof s=="function"?o=$(s,null):o=document.createTextNode(String(s)),o&&i.appendChild(o),g()}),i}});exports.Fragment=_;exports.addNodeCleanup=S;exports.batch=T;exports.createEffect=y;exports.createMemo=B;exports.createSignal=A;exports.dispose=v;exports.getContext=E;exports.h=I;exports.mount=O;exports.onCleanup=j;exports.popContext=g;exports.pushContext=N;exports.resetContext=P;exports.setHydrating=D;
@@ -1,13 +1,13 @@
1
- let u = null, m = 0;
2
- const y = /* @__PURE__ */ new Set();
1
+ let u = null, y = 0;
2
+ const m = /* @__PURE__ */ new Set();
3
3
  function P(e) {
4
- m++;
4
+ y++;
5
5
  try {
6
6
  return e();
7
7
  } finally {
8
- if (m--, m === 0) {
9
- const t = [...y];
10
- y.clear(), t.forEach((n) => n.execute());
8
+ if (y--, y === 0) {
9
+ const t = [...m];
10
+ m.clear(), t.forEach((n) => n.execute());
11
11
  }
12
12
  }
13
13
  }
@@ -17,7 +17,7 @@ function L(e) {
17
17
  return [() => (u && (n.add(u), u.dependencies.add(n)), t), (i) => {
18
18
  const r = typeof i == "function" ? i(t) : i;
19
19
  t !== r && (t = r, [...n].forEach((c) => {
20
- m > 0 ? y.add(c) : c.execute();
20
+ y > 0 ? m.add(c) : c.execute();
21
21
  }));
22
22
  }];
23
23
  }
@@ -98,7 +98,7 @@ function O(e, t, ...n) {
98
98
  }
99
99
  c || (c = document.createElement(e));
100
100
  for (const [o, h] of Object.entries(a))
101
- if (o !== "children")
101
+ if (!(o === "children" || o === "key"))
102
102
  if (o.startsWith("on") && typeof h == "function") {
103
103
  const x = o.toLowerCase().substring(2);
104
104
  c.addEventListener(x, (f) => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime.cjs"),s=require("./dom-DRWrkvYh.cjs");exports.jsx=e.jsx;exports.jsxDEV=e.jsx;exports.jsxs=e.jsxs;exports.Fragment=s.Fragment;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./jsx-runtime.cjs"),s=require("./dom-CNnH2WjC.cjs");exports.jsx=e.jsx;exports.jsxDEV=e.jsx;exports.jsxs=e.jsxs;exports.Fragment=s.Fragment;
@@ -1,5 +1,5 @@
1
1
  import { jsx as r, jsx as j, jsxs as o } from "./jsx-runtime.js";
2
- import { F as e } from "./dom-xZDFYrGn.js";
2
+ import { F as e } from "./dom-CaCdIxfQ.js";
3
3
  export {
4
4
  e as Fragment,
5
5
  r as jsx,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./dom-DRWrkvYh.cjs");function n(o,c,s){const{children:e,...t}=c||{};s!==void 0&&(t.key=s);let r=[];return Array.isArray(e)?r=e:e!==void 0&&(r=[e]),i.h(o,t,...r)}const d=n;exports.Fragment=i.Fragment;exports.jsx=n;exports.jsxs=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./dom-CNnH2WjC.cjs");function n(o,c,s){const{children:e,...t}=c||{};s!==void 0&&(t.key=s);let r=[];return Array.isArray(e)?r=e:e!==void 0&&(r=[e]),i.h(o,t,...r)}const d=n;exports.Fragment=i.Fragment;exports.jsx=n;exports.jsxs=d;
@@ -1,5 +1,5 @@
1
- import { h as n } from "./dom-xZDFYrGn.js";
2
- import { F as m } from "./dom-xZDFYrGn.js";
1
+ import { h as n } from "./dom-CaCdIxfQ.js";
2
+ import { F as m } from "./dom-CaCdIxfQ.js";
3
3
  function f(t, e, o) {
4
4
  const { children: r, ...s } = e || {};
5
5
  o !== void 0 && (s.key = o);
package/dist/velox.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./dom-DRWrkvYh.cjs");function B(e,t){n.setHydrating(!0),n.resetContext();try{const r=e({}).exec();r.parentNode!==t&&(console.warn("Velox: Hydration mismatch. Falling back to client render."),t.textContent="",t.appendChild(r))}catch(o){console.error("Velox: Hydration error",o),t.textContent=""}finally{n.setHydrating(!1)}}const I=n.resetContext,T=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);class y{constructor(t){this.value=t}toString(){return this.value}}function b(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function m(e,t,...o){t=t||{};let r=o.flat().filter(i=>i!=null&&i!==!0&&i!==!1);return r.length===0&&t.children&&(r=Array.isArray(t.children)?t.children.flat():[t.children]),{exec:()=>{if(typeof e=="function"){const l=e({...t,children:r});return l&&l.exec?l.exec():new y(String(l))}const a=n.getContext().hydrationPath,s=e;let c=`<${s} data-hid="${a}"`;for(const[l,u]of Object.entries(t))if(!(l==="children"||l.startsWith("on")))if(l==="className")c+=` class="${b(String(u))}"`;else if(l==="style"&&typeof u=="object"){const h=Object.entries(u).map(([f,x])=>`${f}:${x}`).join(";");c+=` style="${b(h)}"`}else u===!0?c+=` ${l}`:u!==!1&&u!=null&&(c+=` ${l}="${b(String(u))}"`);return T.has(s)?(c+=" />",new y(c)):(c+=">",r.forEach((l,u)=>{const h=`${a}.${u}`;n.pushContext({hydrationPath:h}),c+=F(l),n.popContext()}),c+=`</${s}>`,new y(c))}}}const E=e=>({exec:()=>{const o=n.getContext().hydrationPath;let r="";return(e.children||[]).flat().forEach((a,s)=>{const c=`${o}.${s}`;n.pushContext({hydrationPath:c}),r+=F(a),n.popContext()}),new y(r)}});function F(e){if(e&&e.exec){const t=e.exec();return t instanceof y?t.value:String(t)}if(e instanceof y)return e.value;if(typeof e=="string"||typeof e=="number")return b(String(e));if(typeof e=="function"){const t=e();return t instanceof y?t.value:b(String(t))}return String(e)}function H(e){return n.resetContext(),e({}).exec()}async function _(e){n.resetContext();const t=10;for(let o=0;o<t;o++){o>0&&n.resetContext(!0);const r=new Set;n.pushContext({suspense:r});const a=e({}).exec();if(n.popContext(),r.size===0)return a;await Promise.all(r)}return new y("<!-- Suspense Timeout -->")}const S=typeof window<"u";let P=null;function N(){if(!P){const e=S?window.location.pathname:"/";P=n.createSignal(e)}return P}function V(e){const[t,o]=N();o(e)}S&&window.addEventListener("popstate",()=>{const[e,t]=N();t(window.location.pathname)});const A=e=>(e.url&&V(e.url),S?n.h(n.Fragment,{children:e.children}):m(E,{children:e.children})),O=e=>S?n.h(n.Fragment,{children:e.children}):m(E,{children:e.children}),j=e=>{const{path:t,component:o,exact:r=!0,children:i}=e,[a]=N(),c=n.getContext().routerBase,l=M(c,t);if(!S){const f=a(),x=R(l,f,r);let g=null;if(x&&typeof o=="function"){const d=x.url||l,p=$(i,d);g=m(o,{params:x.params,children:p})}return m("div",{"data-router-outlet":t,style:{display:"contents"}},g)}const u=n.h("div",{"data-router-outlet":t,style:{display:"contents"}}),h=u.exec;return u.exec=()=>{const f=h(),x=n.createEffect(()=>{const g=a();f.childNodes.forEach(p=>n.dispose(p)),f.textContent="";const d=R(l,g,r);if(d&&typeof o=="function"){const p=d.url,w=$(i,p),v=o({params:d.params,children:w}).exec();f.appendChild(v)}});return n.addNodeCleanup(f,x),f},u},D=e=>{const{to:t,children:o,...r}=e,a=n.getContext().routerBase,s=M(a,t),c=l=>{if(l.preventDefault(),S){window.history.pushState({},"",s);const[u,h]=N();h(s)}};return S?n.h("a",{href:s,onClick:c,...r},o):m("a",{href:s,...r},o)};function L(e){if(S){window.history.pushState({},"",e);const[t,o]=N();o(e)}}function M(e,t){if(t.startsWith("/"))return t;const o=e==="/"?"":e,r=t.startsWith("/")?t.slice(1):t;return`${o}/${r}`}function $(e,t){return e.map(o=>o&&o.exec?{exec:()=>{n.pushContext({routerBase:t});const r=o.exec();return n.popContext(),r}}:o)}function R(e,t,o){if(e==="*")return{params:{},url:t};const r=e.split("/").filter(Boolean),i=t.split("/").filter(Boolean);if(o&&r.length!==i.length||!o&&i.length<r.length)return null;const a={};let s="";for(let c=0;c<r.length;c++){const l=r[c],u=i[c];if(l.startsWith(":"))a[l.slice(1)]=u;else if(l!==u)return null}return s="/"+i.slice(0,r.length).join("/"),{params:a,url:s}}const U=typeof window>"u",W=e=>{const t=e.each,o=e.children[0],r=e.key;if(U){const c=(t()||[]).map((l,u)=>o(l,()=>u));return m("div",{style:{display:"contents"}},...c)}const i=n.h("div",{style:{display:"contents"}}),a=i.exec;return i.exec=()=>{const s=a();let c=new Map;const l=n.createEffect(()=>{const u=t()||[],h=new Map,f=new Map;c.forEach((g,d)=>{f.set(d,[...g])});let x=s.firstChild;u.forEach((g,d)=>{const p=r?r(g,d):g;let w=f.get(p),C;if(w&&w.length>0&&(C=w.shift()),!C){const v=o(g,()=>d);v&&v.exec&&(C=v.exec())}C&&(h.has(p)||h.set(p,[]),h.get(p).push(C),C!==x?s.insertBefore(C,x):x=x.nextSibling)}),f.forEach(g=>{g.forEach(d=>{n.dispose(d),d.parentNode===s&&s.removeChild(d)})}),c=h});return n.addNodeCleanup(s,l),s},i};function z(e){const t=Symbol("context");return{id:t,defaultValue:e,Provider:r=>({exec:()=>{const i=n.getContext(),a=new Map(i.custom);a.set(t,r.value),n.pushContext({custom:a});try{return typeof window>"u"?m(E,{children:r.children}).exec():n.h(n.Fragment,{children:r.children}).exec()}finally{n.popContext()}}})}}function q(e){const t=n.getContext();return t.custom.has(e.id)?t.custom.get(e.id):e.defaultValue}const k=Symbol("resource_cache");function X(e,t){const[o,r]=n.createSignal(void 0),i=n.getContext();let a=i.custom.get(k);if(a||(a=new Map,i.custom.set(k,a)),a.has(e))r(a.get(e));else{const s=t().then(c=>(a.set(e,c),r(c),c));i.suspense&&i.suspense.add(s)}return[o]}const G=e=>{const t=e.fallback;return{exec:()=>{const r=n.getContext().suspense,i=new Set;n.pushContext({suspense:i});try{let a;if(typeof window>"u"?a=m(E,{children:e.children}).exec():a=n.h(n.Fragment,{children:e.children}).exec(),i.size>0){if(r&&i.forEach(s=>r.add(s)),typeof window>"u")return t?m(E,{children:t}).exec():new y("");{const c=n.h(n.Fragment,{children:t}).exec();return Promise.all(i).then(()=>{c instanceof Node&&c.parentNode&&c.parentNode.replaceChild(a,c)}),c}}return a}finally{n.popContext()}}}};exports.Fragment=n.Fragment;exports.batch=n.batch;exports.createEffect=n.createEffect;exports.createMemo=n.createMemo;exports.createSignal=n.createSignal;exports.h=n.h;exports.mount=n.mount;exports.onCleanup=n.onCleanup;exports.For=W;exports.Link=D;exports.Outlet=O;exports.Route=j;exports.Router=A;exports.Suspense=G;exports.configureRouter=V;exports.createContext=z;exports.createResource=X;exports.hSSR=m;exports.hydrate=B;exports.navigate=L;exports.renderToString=H;exports.renderToStringAsync=_;exports.resetHydrationId=I;exports.useContext=q;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./dom-CNnH2WjC.cjs");function B(e,t){n.setHydrating(!0),n.resetContext();try{const r=e({}).exec();r.parentNode!==t&&(console.warn("Velox: Hydration mismatch. Falling back to client render."),t.textContent="",t.appendChild(r))}catch(o){console.error("Velox: Hydration error",o),t.textContent=""}finally{n.setHydrating(!1)}}const I=n.resetContext,T=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);class y{constructor(t){this.value=t}toString(){return this.value}}function E(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function m(e,t,...o){t=t||{};let r=o.flat().filter(i=>i!=null&&i!==!0&&i!==!1);return r.length===0&&t.children&&(r=Array.isArray(t.children)?t.children.flat():[t.children]),{exec:()=>{if(typeof e=="function"){const l=e({...t,children:r});return l&&l.exec?l.exec():new y(String(l))}const a=n.getContext().hydrationPath,s=e;let c=`<${s} data-hid="${a}"`;for(const[l,u]of Object.entries(t))if(!(l==="children"||l==="key"||l.startsWith("on")))if(l==="className")c+=` class="${E(String(u))}"`;else if(l==="style"&&typeof u=="object"){const h=Object.entries(u).map(([f,g])=>`${f}:${g}`).join(";");c+=` style="${E(h)}"`}else u===!0?c+=` ${l}`:u!==!1&&u!=null&&(c+=` ${l}="${E(String(u))}"`);return T.has(s)?(c+=" />",new y(c)):(c+=">",r.forEach((l,u)=>{const h=`${a}.${u}`;n.pushContext({hydrationPath:h}),c+=F(l),n.popContext()}),c+=`</${s}>`,new y(c))}}}const P=e=>({exec:()=>{const o=n.getContext().hydrationPath;let r="";return(e.children||[]).flat().forEach((a,s)=>{const c=`${o}.${s}`;n.pushContext({hydrationPath:c}),r+=F(a),n.popContext()}),new y(r)}});function F(e){if(e&&e.exec){const t=e.exec();return t instanceof y?t.value:String(t)}if(e instanceof y)return e.value;if(typeof e=="string"||typeof e=="number")return E(String(e));if(typeof e=="function"){const t=e();return t instanceof y?t.value:E(String(t))}return String(e)}function H(e){return n.resetContext(),e({}).exec()}async function _(e){n.resetContext();const t=10;for(let o=0;o<t;o++){o>0&&n.resetContext(!0);const r=new Set;n.pushContext({suspense:r});const a=e({}).exec();if(n.popContext(),r.size===0)return a;await Promise.all(r)}return new y("<!-- Suspense Timeout -->")}const S=typeof window<"u";let N=null;function w(){if(!N){const e=S?window.location.pathname:"/";N=n.createSignal(e)}return N}function V(e){const[t,o]=w();o(e)}S&&window.addEventListener("popstate",()=>{const[e,t]=w();t(window.location.pathname)});const A=e=>(e.url&&V(e.url),S?n.h(n.Fragment,{children:e.children}):m(P,{children:e.children})),O=e=>S?n.h(n.Fragment,{children:e.children}):m(P,{children:e.children}),j=e=>{const{path:t,component:o,exact:r=!0,children:i}=e,[a]=w(),c=n.getContext().routerBase,l=M(c,t);if(!S){const f=a(),g=k(l,f,r);let p=null;if(g&&typeof o=="function"){const d=g.url||l,x=$(i,d);p=m(o,{params:g.params,children:x})}return m("div",{"data-router-outlet":t,style:{display:"contents"}},p)}const u=n.h("div",{"data-router-outlet":t,style:{display:"contents"}}),h=u.exec;return u.exec=()=>{const f=h(),g=n.createEffect(()=>{const p=a();f.childNodes.forEach(x=>n.dispose(x)),f.textContent="";const d=k(l,p,r);if(d&&typeof o=="function"){const x=d.url,v=$(i,x),b=o({params:d.params,children:v}).exec();f.appendChild(b)}});return n.addNodeCleanup(f,g),f},u},L=e=>{const{to:t,children:o,...r}=e,a=n.getContext().routerBase,s=M(a,t),c=l=>{if(l.preventDefault(),S){window.history.pushState({},"",s);const[u,h]=w();h(s)}};return S?n.h("a",{href:s,onClick:c,...r},o):m("a",{href:s,...r},o)};function D(e){if(S){window.history.pushState({},"",e);const[t,o]=w();o(e)}}function U(){const[e]=w();return{get pathname(){return e()}}}function M(e,t){if(t.startsWith("/"))return t;const o=e==="/"?"":e,r=t.startsWith("/")?t.slice(1):t;return`${o}/${r}`}function $(e,t){return e.map(o=>o&&o.exec?{exec:()=>{n.pushContext({routerBase:t});const r=o.exec();return n.popContext(),r}}:o)}function k(e,t,o){if(e==="*")return{params:{},url:t};const r=e.split("/").filter(Boolean),i=t.split("/").filter(Boolean);if(o&&r.length!==i.length||!o&&i.length<r.length)return null;const a={};let s="";for(let c=0;c<r.length;c++){const l=r[c],u=i[c];if(l.startsWith(":"))a[l.slice(1)]=u;else if(l!==u)return null}return s="/"+i.slice(0,r.length).join("/"),{params:a,url:s}}const W=typeof window>"u",z=e=>{const t=e.each,o=e.children[0],r=e.key;if(W){const c=(t()||[]).map((l,u)=>o(l,()=>u));return m("div",{style:{display:"contents"}},...c)}const i=n.h("div",{style:{display:"contents"}}),a=i.exec;return i.exec=()=>{const s=a();let c=new Map;const l=n.createEffect(()=>{const u=t()||[],h=new Map,f=new Map;c.forEach((p,d)=>{f.set(d,[...p])});let g=s.firstChild;u.forEach((p,d)=>{const x=r?r(p,d):p;let v=f.get(x),C;if(v&&v.length>0&&(C=v.shift()),!C){const b=o(p,()=>d);b&&b.exec&&(C=b.exec())}C&&(h.has(x)||h.set(x,[]),h.get(x).push(C),C!==g?s.insertBefore(C,g):g=g.nextSibling)}),f.forEach(p=>{p.forEach(d=>{n.dispose(d),d.parentNode===s&&s.removeChild(d)})}),c=h});return n.addNodeCleanup(s,l),s},i};function q(e){const t=Symbol("context");return{id:t,defaultValue:e,Provider:r=>({exec:()=>{const i=n.getContext(),a=new Map(i.custom);a.set(t,r.value),n.pushContext({custom:a});try{return typeof window>"u"?m(P,{children:r.children}).exec():n.h(n.Fragment,{children:r.children}).exec()}finally{n.popContext()}}})}}function X(e){const t=n.getContext();return t.custom.has(e.id)?t.custom.get(e.id):e.defaultValue}const R=Symbol("resource_cache");function G(e,t){const[o,r]=n.createSignal(void 0),i=n.getContext();let a=i.custom.get(R);if(a||(a=new Map,i.custom.set(R,a)),a.has(e))r(a.get(e));else{const s=t().then(c=>(a.set(e,c),r(c),c));i.suspense&&i.suspense.add(s)}return[o]}const J=e=>{const t=e.fallback;return{exec:()=>{const r=n.getContext().suspense,i=new Set;n.pushContext({suspense:i});try{let a;if(typeof window>"u"?a=m(P,{children:e.children}).exec():a=n.h(n.Fragment,{children:e.children}).exec(),i.size>0){if(r&&i.forEach(s=>r.add(s)),typeof window>"u")return t?m(P,{children:t}).exec():new y("");{const c=n.h(n.Fragment,{children:t}).exec();return Promise.all(i).then(()=>{c instanceof Node&&c.parentNode&&c.parentNode.replaceChild(a,c)}),c}}return a}finally{n.popContext()}}}};exports.Fragment=n.Fragment;exports.batch=n.batch;exports.createEffect=n.createEffect;exports.createMemo=n.createMemo;exports.createSignal=n.createSignal;exports.h=n.h;exports.mount=n.mount;exports.onCleanup=n.onCleanup;exports.For=z;exports.Link=L;exports.Outlet=O;exports.Route=j;exports.Router=A;exports.Suspense=J;exports.configureRouter=V;exports.createContext=q;exports.createResource=G;exports.hSSR=m;exports.hydrate=B;exports.navigate=D;exports.renderToString=H;exports.renderToStringAsync=_;exports.resetHydrationId=I;exports.useContext=X;exports.useLocation=U;
package/dist/velox.d.ts CHANGED
@@ -100,6 +100,10 @@ export declare const Suspense: (props: any) => any;
100
100
 
101
101
  export declare function useContext<T>(context: Context<T>): T;
102
102
 
103
+ export declare function useLocation(): {
104
+ readonly pathname: string;
105
+ };
106
+
103
107
  declare interface VNode {
104
108
  exec: () => Node;
105
109
  }
package/dist/velox.js CHANGED
@@ -1,7 +1,7 @@
1
- import { r as $, s as I, p as C, g as v, a as b, h as w, F as k, c as A, d as H, b as T, e as j } from "./dom-xZDFYrGn.js";
2
- import { i as ae, f as le, m as ue, o as de } from "./dom-xZDFYrGn.js";
1
+ import { r as k, s as I, p as C, g as v, a as b, h as w, F as V, c as A, d as H, b as T, e as j } from "./dom-CaCdIxfQ.js";
2
+ import { i as le, f as ue, m as de, o as fe } from "./dom-CaCdIxfQ.js";
3
3
  function q(e, t) {
4
- I(!0), $();
4
+ I(!0), k();
5
5
  try {
6
6
  const n = e({}).exec();
7
7
  n.parentNode !== t && (console.warn("Velox: Hydration mismatch. Falling back to client render."), t.textContent = "", t.appendChild(n));
@@ -11,7 +11,7 @@ function q(e, t) {
11
11
  I(!1);
12
12
  }
13
13
  }
14
- const X = $, U = /* @__PURE__ */ new Set([
14
+ const X = k, L = /* @__PURE__ */ new Set([
15
15
  "area",
16
16
  "base",
17
17
  "br",
@@ -27,7 +27,7 @@ const X = $, U = /* @__PURE__ */ new Set([
27
27
  "track",
28
28
  "wbr"
29
29
  ]);
30
- class x {
30
+ class g {
31
31
  constructor(t) {
32
32
  this.value = t;
33
33
  }
@@ -35,69 +35,69 @@ class x {
35
35
  return this.value;
36
36
  }
37
37
  }
38
- function P(e) {
38
+ function $(e) {
39
39
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
40
40
  }
41
- function g(e, t, ...r) {
41
+ function x(e, t, ...r) {
42
42
  t = t || {};
43
43
  let n = r.flat().filter((s) => s != null && s !== !0 && s !== !1);
44
44
  return n.length === 0 && t.children && (n = Array.isArray(t.children) ? t.children.flat() : [t.children]), {
45
45
  exec: () => {
46
46
  if (typeof e == "function") {
47
47
  const a = e({ ...t, children: n });
48
- return a && a.exec ? a.exec() : new x(String(a));
48
+ return a && a.exec ? a.exec() : new g(String(a));
49
49
  }
50
50
  const i = v().hydrationPath, c = e;
51
51
  let o = `<${c} data-hid="${i}"`;
52
52
  for (const [a, l] of Object.entries(t))
53
- if (!(a === "children" || a.startsWith("on")))
53
+ if (!(a === "children" || a === "key" || a.startsWith("on")))
54
54
  if (a === "className")
55
- o += ` class="${P(String(l))}"`;
55
+ o += ` class="${$(String(l))}"`;
56
56
  else if (a === "style" && typeof l == "object") {
57
57
  const f = Object.entries(l).map(([d, h]) => `${d}:${h}`).join(";");
58
- o += ` style="${P(f)}"`;
58
+ o += ` style="${$(f)}"`;
59
59
  } else
60
- l === !0 ? o += ` ${a}` : l !== !1 && l != null && (o += ` ${a}="${P(String(l))}"`);
61
- return U.has(c) ? (o += " />", new x(o)) : (o += ">", n.forEach((a, l) => {
60
+ l === !0 ? o += ` ${a}` : l !== !1 && l != null && (o += ` ${a}="${$(String(l))}"`);
61
+ return L.has(c) ? (o += " />", new g(o)) : (o += ">", n.forEach((a, l) => {
62
62
  const f = `${i}.${l}`;
63
63
  C({ hydrationPath: f }), o += O(a), b();
64
- }), o += `</${c}>`, new x(o));
64
+ }), o += `</${c}>`, new g(o));
65
65
  }
66
66
  };
67
67
  }
68
- const V = (e) => ({
68
+ const B = (e) => ({
69
69
  exec: () => {
70
70
  const r = v().hydrationPath;
71
71
  let n = "";
72
72
  return (e.children || []).flat().forEach((i, c) => {
73
73
  const o = `${r}.${c}`;
74
74
  C({ hydrationPath: o }), n += O(i), b();
75
- }), new x(n);
75
+ }), new g(n);
76
76
  }
77
77
  });
78
78
  function O(e) {
79
79
  if (e && e.exec) {
80
80
  const t = e.exec();
81
- return t instanceof x ? t.value : String(t);
81
+ return t instanceof g ? t.value : String(t);
82
82
  }
83
- if (e instanceof x)
83
+ if (e instanceof g)
84
84
  return e.value;
85
85
  if (typeof e == "string" || typeof e == "number")
86
- return P(String(e));
86
+ return $(String(e));
87
87
  if (typeof e == "function") {
88
88
  const t = e();
89
- return t instanceof x ? t.value : P(String(t));
89
+ return t instanceof g ? t.value : $(String(t));
90
90
  }
91
91
  return String(e);
92
92
  }
93
93
  function G(e) {
94
- return $(), e({}).exec();
94
+ return k(), e({}).exec();
95
95
  }
96
96
  async function J(e) {
97
- $();
97
+ k();
98
98
  const t = 10;
99
99
  for (let r = 0; r < t; r++) {
100
- r > 0 && $(!0);
100
+ r > 0 && k(!0);
101
101
  const n = /* @__PURE__ */ new Set();
102
102
  C({ suspense: n });
103
103
  const i = e({}).exec();
@@ -105,35 +105,35 @@ async function J(e) {
105
105
  return i;
106
106
  await Promise.all(n);
107
107
  }
108
- return new x("<!-- Suspense Timeout -->");
108
+ return new g("<!-- Suspense Timeout -->");
109
109
  }
110
110
  const S = typeof window < "u";
111
111
  let R = null;
112
- function B() {
112
+ function P() {
113
113
  if (!R) {
114
114
  const e = S ? window.location.pathname : "/";
115
115
  R = j(e);
116
116
  }
117
117
  return R;
118
118
  }
119
- function W(e) {
120
- const [t, r] = B();
119
+ function U(e) {
120
+ const [t, r] = P();
121
121
  r(e);
122
122
  }
123
123
  S && window.addEventListener("popstate", () => {
124
- const [e, t] = B();
124
+ const [e, t] = P();
125
125
  t(window.location.pathname);
126
126
  });
127
- const K = (e) => (e.url && W(e.url), S ? w(k, { children: e.children }) : g(V, { children: e.children })), Q = (e) => S ? w(k, { children: e.children }) : g(V, { children: e.children }), Y = (e) => {
128
- const { path: t, component: r, exact: n = !0, children: s } = e, [i] = B(), o = v().routerBase, a = D(o, t);
127
+ const K = (e) => (e.url && U(e.url), S ? w(V, { children: e.children }) : x(B, { children: e.children })), Q = (e) => S ? w(V, { children: e.children }) : x(B, { children: e.children }), Y = (e) => {
128
+ const { path: t, component: r, exact: n = !0, children: s } = e, [i] = P(), o = v().routerBase, a = D(o, t);
129
129
  if (!S) {
130
130
  const d = i(), h = _(a, d, n);
131
131
  let m = null;
132
132
  if (h && typeof r == "function") {
133
133
  const u = h.url || a, p = M(s, u);
134
- m = g(r, { params: h.params, children: p });
134
+ m = x(r, { params: h.params, children: p });
135
135
  }
136
- return g("div", {
136
+ return x("div", {
137
137
  "data-router-outlet": t,
138
138
  style: { display: "contents" }
139
139
  }, m);
@@ -158,19 +158,27 @@ const K = (e) => (e.url && W(e.url), S ? w(k, { children: e.children }) : g(V, {
158
158
  const { to: t, children: r, ...n } = e, i = v().routerBase, c = D(i, t), o = (a) => {
159
159
  if (a.preventDefault(), S) {
160
160
  window.history.pushState({}, "", c);
161
- const [l, f] = B();
161
+ const [l, f] = P();
162
162
  f(c);
163
163
  }
164
164
  };
165
- return S ? w("a", { href: c, onClick: o, ...n }, r) : g("a", { href: c, ...n }, r);
165
+ return S ? w("a", { href: c, onClick: o, ...n }, r) : x("a", { href: c, ...n }, r);
166
166
  };
167
167
  function ee(e) {
168
168
  if (S) {
169
169
  window.history.pushState({}, "", e);
170
- const [t, r] = B();
170
+ const [t, r] = P();
171
171
  r(e);
172
172
  }
173
173
  }
174
+ function te() {
175
+ const [e] = P();
176
+ return {
177
+ get pathname() {
178
+ return e();
179
+ }
180
+ };
181
+ }
174
182
  function D(e, t) {
175
183
  if (t.startsWith("/")) return t;
176
184
  const r = e === "/" ? "" : e, n = t.startsWith("/") ? t.slice(1) : t;
@@ -200,11 +208,11 @@ function _(e, t, r) {
200
208
  }
201
209
  return c = "/" + s.slice(0, n.length).join("/"), { params: i, url: c };
202
210
  }
203
- const z = typeof window > "u", te = (e) => {
211
+ const W = typeof window > "u", ne = (e) => {
204
212
  const t = e.each, r = e.children[0], n = e.key;
205
- if (z) {
213
+ if (W) {
206
214
  const o = (t() || []).map((a, l) => r(a, () => l));
207
- return g("div", { style: { display: "contents" } }, ...o);
215
+ return x("div", { style: { display: "contents" } }, ...o);
208
216
  }
209
217
  const s = w("div", { style: { display: "contents" } }), i = s.exec;
210
218
  return s.exec = () => {
@@ -233,26 +241,26 @@ const z = typeof window > "u", te = (e) => {
233
241
  return T(c, a), c;
234
242
  }, s;
235
243
  };
236
- function ne(e) {
244
+ function re(e) {
237
245
  const t = Symbol("context");
238
246
  return { id: t, defaultValue: e, Provider: (n) => ({
239
247
  exec: () => {
240
248
  const s = v(), i = new Map(s.custom);
241
249
  i.set(t, n.value), C({ custom: i });
242
250
  try {
243
- return typeof window > "u" ? g(V, { children: n.children }).exec() : w(k, { children: n.children }).exec();
251
+ return typeof window > "u" ? x(B, { children: n.children }).exec() : w(V, { children: n.children }).exec();
244
252
  } finally {
245
253
  b();
246
254
  }
247
255
  }
248
256
  }) };
249
257
  }
250
- function re(e) {
258
+ function oe(e) {
251
259
  const t = v();
252
260
  return t.custom.has(e.id) ? t.custom.get(e.id) : e.defaultValue;
253
261
  }
254
262
  const F = Symbol("resource_cache");
255
- function oe(e, t) {
263
+ function ce(e, t) {
256
264
  const [r, n] = j(void 0), s = v();
257
265
  let i = s.custom.get(F);
258
266
  if (i || (i = /* @__PURE__ */ new Map(), s.custom.set(F, i)), i.has(e))
@@ -263,7 +271,7 @@ function oe(e, t) {
263
271
  }
264
272
  return [r];
265
273
  }
266
- const ce = (e) => {
274
+ const se = (e) => {
267
275
  const t = e.fallback;
268
276
  return {
269
277
  exec: () => {
@@ -271,11 +279,11 @@ const ce = (e) => {
271
279
  C({ suspense: s });
272
280
  try {
273
281
  let i;
274
- if (typeof window > "u" ? i = g(V, { children: e.children }).exec() : i = w(k, { children: e.children }).exec(), s.size > 0) {
282
+ if (typeof window > "u" ? i = x(B, { children: e.children }).exec() : i = w(V, { children: e.children }).exec(), s.size > 0) {
275
283
  if (n && s.forEach((c) => n.add(c)), typeof window > "u")
276
- return t ? g(V, { children: t }).exec() : new x("");
284
+ return t ? x(B, { children: t }).exec() : new g("");
277
285
  {
278
- const o = w(k, { children: t }).exec();
286
+ const o = w(V, { children: t }).exec();
279
287
  return Promise.all(s).then(() => {
280
288
  o instanceof Node && o.parentNode && o.parentNode.replaceChild(i, o);
281
289
  }), o;
@@ -289,28 +297,29 @@ const ce = (e) => {
289
297
  };
290
298
  };
291
299
  export {
292
- te as For,
293
- k as Fragment,
300
+ ne as For,
301
+ V as Fragment,
294
302
  Z as Link,
295
303
  Q as Outlet,
296
304
  Y as Route,
297
305
  K as Router,
298
- ce as Suspense,
299
- ae as batch,
300
- W as configureRouter,
301
- ne as createContext,
306
+ se as Suspense,
307
+ le as batch,
308
+ U as configureRouter,
309
+ re as createContext,
302
310
  A as createEffect,
303
- le as createMemo,
304
- oe as createResource,
311
+ ue as createMemo,
312
+ ce as createResource,
305
313
  j as createSignal,
306
314
  w as h,
307
- g as hSSR,
315
+ x as hSSR,
308
316
  q as hydrate,
309
- ue as mount,
317
+ de as mount,
310
318
  ee as navigate,
311
- de as onCleanup,
319
+ fe as onCleanup,
312
320
  G as renderToString,
313
321
  J as renderToStringAsync,
314
322
  X as resetHydrationId,
315
- re as useContext
323
+ oe as useContext,
324
+ te as useLocation
316
325
  };
package/package.json CHANGED
@@ -1,6 +1,20 @@
1
1
  {
2
2
  "name": "@remyyy/velox",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
+ "author": "TheRemyyy",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/TheRemyyy/velox-framework.git",
8
+ "directory": "packages/velox"
9
+ },
10
+ "keywords": [
11
+ "framework",
12
+ "reactivity",
13
+ "signals",
14
+ "performance",
15
+ "zero-copy"
16
+ ],
17
+ "homepage": "https://velox-framework.vercel.app",
4
18
  "type": "module",
5
19
  "publishConfig": {
6
20
  "access": "public"
@@ -1 +0,0 @@
1
- "use strict";let u=null,m=0;const y=new Set;function T(e){m++;try{return e()}finally{if(m--,m===0){const t=[...y];y.clear(),t.forEach(n=>n.execute())}}}function A(e){let t=e;const n=new Set;return[()=>(u&&(n.add(u),u.dependencies.add(n)),t),a=>{const s=typeof a=="function"?a(t):a;t!==s&&(t=s,[...n].forEach(c=>{m>0?y.add(c):c.execute()}))}]}function j(e){u&&u.cleanups.push(e)}function C(e){const t={execute(){b(t);const n=u;u=t;try{e()}finally{u=n}},dependencies:new Set,cleanups:[]};return t.execute(),()=>b(t)}function B(e){const[t,n]=A(void 0);return C(()=>n(e())),t}function b(e){e.dependencies.forEach(t=>t.delete(e)),e.dependencies.clear(),e.cleanups.forEach(t=>t()),e.cleanups=[]}let l=[{hydrationPath:"0",routerBase:"",custom:new Map}];function N(e){const t=l[l.length-1];l.push({...t,...e})}function g(){l.pop()}function E(){return l[l.length-1]}function P(e=!1){l=[{hydrationPath:"0",routerBase:"",custom:e&&l.length>0?l[0].custom:new Map}]}let L=!1;function D(e){L=e}const p=Symbol("velox_cleanup");function S(e,t){const n=e;n[p]||(n[p]=[]),n[p].push(t)}function v(e){const t=e;t[p]&&(t[p].forEach(n=>n()),t[p]=void 0),e.hasChildNodes()&&e.childNodes.forEach(n=>v(n))}function I(e,t,...n){const i=t||{};let d=n.flat().filter(a=>a!=null&&a!==!0&&a!==!1);return d.length===0&&i.children&&(d=Array.isArray(i.children)?i.children.flat():[i.children]),{exec:()=>{if(typeof e=="function")return e({...i,children:d}).exec();const s=E().hydrationPath;let c=null;if(L){const o=document.querySelector(`[data-hid="${s}"]`);o&&o.tagName.toLowerCase()===e.toLowerCase()&&(c=o,c.removeAttribute("data-hid"))}c||(c=document.createElement(e));for(const[o,h]of Object.entries(i))if(o!=="children")if(o.startsWith("on")&&typeof h=="function"){const x=o.toLowerCase().substring(2);c.addEventListener(x,f=>{T(()=>h(f))})}else if(typeof h=="function"){const x=C(()=>{const f=h();w(c,o,f)});S(c,x)}else w(c,o,h);let r=c.firstChild;for(d.forEach((o,h)=>{const x=`${s}.${h}`;N({hydrationPath:x});let f=null;o&&typeof o=="object"&&"exec"in o?f=o.exec():typeof o=="function"?f=$(o,r):f=M(String(o),r),f&&(r===f?r=r.nextSibling:(f.parentNode,c.insertBefore(f,r))),g()});r;){const o=r.nextSibling;r.parentNode===c&&(v(r),c.removeChild(r)),r=o}return c}}}function $(e,t){let n;t&&t.nodeType===Node.TEXT_NODE?n=t:n=document.createTextNode("");const i=C(()=>{const d=e(),a=String(d??"");n.data!==a&&(n.data=a)});return S(n,i),n}function M(e,t){if(t&&t.nodeType===Node.TEXT_NODE){const n=t;return n.data!==e&&(n.data=e),n}return document.createTextNode(e)}function w(e,t,n){n==null?e.removeAttribute(t):t==="className"||t==="class"?e.className=n:t==="style"&&typeof n=="object"?Object.assign(e.style,n):e.setAttribute(t,String(n))}function O(e,t){P(),t.textContent="";const i=e({}).exec();t.appendChild(i)}const _=e=>({exec:()=>{const n=E().hydrationPath,i=document.createDocumentFragment(),d=e.children||[];return(Array.isArray(d)?d.flat():[d]).forEach((s,c)=>{const r=`${n}.${c}`;N({hydrationPath:r});let o=null;s&&s.exec?o=s.exec():typeof s=="function"?o=$(s,null):o=document.createTextNode(String(s)),o&&i.appendChild(o),g()}),i}});exports.Fragment=_;exports.addNodeCleanup=S;exports.batch=T;exports.createEffect=C;exports.createMemo=B;exports.createSignal=A;exports.dispose=v;exports.getContext=E;exports.h=I;exports.mount=O;exports.onCleanup=j;exports.popContext=g;exports.pushContext=N;exports.resetContext=P;exports.setHydrating=D;