@cfdez11/vex 0.10.19 → 0.10.20

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.
@@ -1 +1 @@
1
- import{setupLinkInterceptor as s}from"./link-interceptor.js";import{setupPrefetchObserver as f}from"./prefetch.js";import{navigateInternal as m}from"./navigate.js";import{findRouteWithParams as u}from"./router.js";import{createLayoutRenderer as p}from"./create-layouts.js";function g(){let t=null;const n=p();function i(){t&&t.abort()}async function o(r,l=!0){i();const e=new AbortController;t=e;try{await m({path:r,addToHistory:l,controller:e,layoutRenderer:n,onFinish:()=>{t===e&&(t=null)}})}catch(a){a.name!=="AbortError"&&console.error("Navigation error:",a)}}function c(){window.addEventListener("popstate",()=>{o(`${location.pathname}${location.search}${location.hash}`,!1)}),s(o),f(),n.reset();const{route:r}=u(location.pathname);r?.meta?.ssr||o(`${location.pathname}${location.search}${location.hash}`,!1)}return{navigate:o,initialize:c}}export{g as createNavigationRuntime};
1
+ import{setupLinkInterceptor as s}from"./link-interceptor.js";import{setupPrefetchObserver as f}from"./prefetch.js";import{navigateInternal as m}from"./navigate.js";import{findRouteWithParams as u}from"./router.js";import{createLayoutRenderer as p}from"./create-layouts.js";function w(){let t=null;const n=p();function i(){t&&t.abort()}async function o(r,l=!0){i();const e=new AbortController;t=e;try{await m({path:r,addToHistory:l,controller:e,layoutRenderer:n,onFinish:()=>{t===e&&(t=null)}})}catch(a){a.name!=="AbortError"&&console.error("Navigation error:",a)}}function c(){window.addEventListener("popstate",()=>{o(`${location.pathname}${location.search}${location.hash}`,!1)}),s(o),f(),n.reset();const{route:r}=u(location.pathname);r?.meta?.ssr||o(location.pathname,!1)}return{navigate:o,initialize:c}}export{w as createNavigationRuntime};
@@ -1 +1 @@
1
- function a(i){document.addEventListener("click",r=>{const t=r.target.closest("a");if(!t)return;const e=t.getAttribute("href");if(!e||e.startsWith("#"))return;const n=new URL(e,window.location.origin);n.origin!==window.location.origin||t.dataset.reload!==void 0||t.target==="_blank"||t.rel==="external"||n.pathname===window.location.pathname&&n.hash||(r.preventDefault(),i(n.pathname+n.hash))})}export{a as setupLinkInterceptor};
1
+ function i(a){document.addEventListener("click",n=>{const e=n.target.closest("a");if(!e)return;const r=e.getAttribute("href");if(!r||r.startsWith("#"))return;const t=new URL(r,window.location.origin);if(!(t.origin!==window.location.origin||e.dataset.reload!==void 0||e.target==="_blank"||e.rel==="external")){if(t.pathname===window.location.pathname&&t.hash){n.preventDefault(),history.pushState({},"",`${t.pathname}${t.search}${t.hash}`),document.getElementById(t.hash.slice(1))?.scrollIntoView({behavior:"smooth"});return}n.preventDefault(),a(t.pathname+t.search+t.hash)}})}export{i as setupLinkInterceptor};
@@ -1 +1 @@
1
- import{findRouteWithParams as p}from"./router.js";import{routes as d}from"../_routes.js";import{updateRouteParams as P}from"./use-route-params.js";import{renderPage as w}from"./render-page.js";import{renderSSRPage as y}from"./render-ssr.js";async function H({path:i,addToHistory:s,controller:h,layoutRenderer:e,onFinish:c}){const u=`${location.pathname}${location.search}`,l=location.hash,t=new URL(i,window.location.origin),m=t.pathname,r=`${t.pathname}${t.search}`,n=`${r}${t.hash}`,f=u===r&&l!==t.hash;P(n);const{route:g}=p(m),a=g??d.find(o=>o.isNotFound)??null;s&&history.pushState({},"",n);try{if(f)return;if(a?.meta?.ssr){e.reset(),await y(n,h.signal);return}if(a?.meta?.requiresAuth&&!app.Store?.loggedIn){location.href="/account/login";return}if(a?.meta?.guestOnly&&app.Store?.loggedIn){location.href="/account";return}await w({route:a,layoutRenderer:e})}finally{c();const o=t.hash?t.hash.slice(1):null;o&&document.getElementById(o)?.scrollIntoView()}}export{H as navigateInternal};
1
+ import{findRouteWithParams as m}from"./router.js";import{routes as f}from"../_routes.js";import{updateRouteParams as g}from"./use-route-params.js";import{renderPage as d}from"./render-page.js";import{renderSSRPage as h}from"./render-ssr.js";async function O({path:t,addToHistory:r,controller:i,layoutRenderer:n,onFinish:a}){g(t);const s=t.split("?")[0].split("#")[0],c=t.split("#")[0],u=`${location.pathname}${location.search}`===c,{route:l}=m(s),e=l??f.find(o=>o.isNotFound)??null;r&&history.pushState({},"",t);try{if(u)return;if(e?.meta?.ssr){n.reset(),await h(t,i.signal);return}if(e?.meta?.requiresAuth&&!app.Store?.loggedIn){location.href="/account/login";return}if(e?.meta?.guestOnly&&app.Store?.loggedIn){location.href="/account";return}await d({route:e,layoutRenderer:n})}finally{a();const o=t.includes("#")?t.slice(t.indexOf("#")+1):null;o&&document.getElementById(o)?.scrollIntoView()}}export{O as navigateInternal};
@@ -1 +1 @@
1
- import{routes as s}from"../_routes.js";import{prefetchRouteComponent as p}from"../cache.js";function h(){const o=new IntersectionObserver(e=>{e.forEach(n=>{if(!n.isIntersecting)return;const t=n.target;if(!t.hasAttribute("data-prefetch"))return;const c=new URL(t.href,location.origin),r=s.find(f=>f.path===c.pathname);r?.component&&(p(r.path,r.component),o.unobserve(t))})},{rootMargin:"200px"});document.querySelectorAll("a[data-prefetch]").forEach(e=>{e.__prefetchObserved||(e.__prefetchObserved=!0,o.observe(e))})}export{h as setupPrefetchObserver};
1
+ import{prefetchRouteComponent as f}from"../cache.js";import{findRouteWithParams as s}from"./router.js";function p(){const o=new IntersectionObserver(e=>{e.forEach(n=>{if(!n.isIntersecting)return;const t=n.target;if(!t.hasAttribute("data-prefetch"))return;const c=new URL(t.href,location.origin),{route:r}=s(c.pathname);r?.component&&(f(r.path,r.component),o.unobserve(t))})},{rootMargin:"200px"});document.querySelectorAll("a[data-prefetch]").forEach(e=>{e.__prefetchObserved||(e.__prefetchObserved=!0,o.observe(e))})}export{p as setupPrefetchObserver};
@@ -1 +1 @@
1
- function l(r){const o={},s=new URLSearchParams(r);for(const[a,u]of s.entries())o[a]=u;return o}function S(r){const o=new URLSearchParams;for(const s in r)r[s]!=null&&o.set(s,String(r[s]));return o.toString()}function m(r={}){const{schema:o={},replace:s=!1,listen:a=!0}=r,u={};for(const t in o)u[t]=o[t](void 0);let i=l(window.location.search);function h(t){const n={};for(const e in o){const c=o[e];n[e]=c(t[e])}for(const e in t)e in n||(n[e]=t[e]);return n}function d(t){const n={};for(const e in t){const c=t[e];Array.isArray(c)?n[e]=c.join(","):c!=null&&(n[e]=String(c))}return n}function f(t){i=t;const n=S(i),e=window.location.pathname+(n?`?${n}`:"")+window.location.hash;history[s?"replaceState":"pushState"](null,"",e)}function p(t){const n=d(t);f({...i,...n})}function w(...t){const n={...i};t.forEach(e=>delete n[e]),f(n)}function y(){f({})}return a&&window.addEventListener("popstate",()=>{i=l(window.location.search)}),{get params(){return h(i)},get raw(){return{...i}},set:p,remove:w,reset:y}}export{m as useQueryParams};
1
+ function p(r){const o={},s=new URLSearchParams(r);for(const[u,l]of s.entries())o[u]=l;return o}function S(r){const o=new URLSearchParams;for(const s in r)r[s]!=null&&o.set(s,String(r[s]));return o.toString()}function g(r={}){const{schema:o={},replace:s=!1,listen:u=!0}=r,l={};for(const e in o)l[e]=o[e](void 0);let i=p(window.location.search);function d(e){const n={};for(const t in o){const c=o[t];n[t]=c(e[t])}for(const t in e)t in n||(n[t]=e[t]);return n}function h(e){const n={};for(const t in e){const c=e[t];Array.isArray(c)?n[t]=c.join(","):c!=null&&(n[t]=String(c))}return n}function f(e){i=e;const n=S(i),t=window.location.pathname+(n?`?${n}`:"")+window.location.hash;history[s?"replaceState":"pushState"](null,"",t)}function w(e){const n=h(e);f({...i,...n})}function y(...e){const n={...i};e.forEach(t=>delete n[t]),f(n)}function m(){f({})}let a=null;return u&&(a=()=>{i=p(window.location.search)},window.addEventListener("popstate",a)),{get params(){return d(i)},get raw(){return{...i}},set:w,remove:y,reset:m,cleanup(){a&&window.removeEventListener("popstate",a)}}}export{g as useQueryParams};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfdez11/vex",
3
- "version": "0.10.19",
3
+ "version": "0.10.20",
4
4
  "description": "A vanilla JavaScript meta-framework with file-based routing, SSR/CSR/SSG/ISR and Vue-like reactivity",
5
5
  "repository": {
6
6
  "type": "git",