svelte-spa-history-router 2.2.0-next.0 → 2.2.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -184,9 +184,13 @@ store to detect URL changes (including query string or hash)
184
184
 
185
185
  ## ChangeLog
186
186
 
187
- ### 2.1.0-next.0
187
+ ### 2.2.0-next.1
188
188
 
189
- * [PR12](https://github.com/ykrods/svelte-spa-history-router/pull/12)
189
+ * Fix component type on svelte5 [PR13](https://github.com/ykrods/svelte-spa-history-router/pull/13)
190
+
191
+ ### 2.2.0-next.0
192
+
193
+ * Add the way to get routing params to via props [PR12](https://github.com/ykrods/svelte-spa-history-router/pull/12)
190
194
  * Refactor (changes: [2.1.2...7b7795b](https://github.com/ykrods/svelte-spa-history-router/compare/2.1.2...7b7795b2675c452a1a189d3931c0c4c9abb04c51) )
191
195
 
192
196
  ### 2.1.2 (2024-04-29)
@@ -0,0 +1 @@
1
+ import{j as m,o as i,v as t,$ as o}from"./index-ADyOUHdb.js";var d=t('<main class="admin"><h1>Admin</h1></main>');function s(a){var n=d();m(e=>{o.title="Admin"}),i(a,n)}export{s as default};
@@ -0,0 +1 @@
1
+ import{y as q,z,A as C,B as b,C as $,D as k,E as y,F as D,G as E,H as F,e as G,h as H,j as I,o as m,u as J,v as w,$ as K,I as L,J as M,K as N,w as l,L as O,t as P,q as B,s as Q,M as p,l as R,m as S,n as T,N as U,x as v}from"./index-ADyOUHdb.js";function V(r,o,f,n,d){const u=F;let e,t;function i(s,a){$(c),k(c),y(u);var h=b(()=>s(r,a));return y(null),k(null),$(null),D(),h}const c=q(()=>{if(e!==(e=o()))if(z(e)){const s=e;t&&E(t),s.then(a=>{s===e&&n&&(t=i(n,a))},a=>{})}else n&&(t&&C(t),t=b(()=>n(r,e)))})}var W=w("<li> <a> </a></li>"),X=w('<main class="blog"><h1>Blog</h1> <ul><!></ul></main>');function Z(r,o){G(o,!1),H();var f=X();I(e=>{K.title="Blog"});var n=l(f),d=v(v(n,!0)),u=l(d);V(u,N,null,(e,t)=>{var i=L(),c=O(i);M(c,1,()=>t,U,(s,a,h)=>{var x=W(),g=l(x),_=v(g),A=l(_);P(()=>{B(g,`${Q(p(a).date)} - `),R(_,"href",p(a).url),B(A,p(a).title)}),S(_,j=>T(j)),m(s,x)}),m(e,i)}),m(r,f),J()}export{Z as default};
@@ -0,0 +1 @@
1
+ import{c as g,r as P,g as z,a as A,b as B,p as x,i as j,d as D,e as E,f as F,h as G,j as H,t as u,$ as I,s as J,k as b,l as k,m as N,n as $,o as c,q as y,u as K,v as h,w as f,x as n}from"./index-ADyOUHdb.js";function L(r,a){const e=r.dom;if(j(e)){for(let s=e.length-1;s>=0;s--)if(a.includes(e[s])){e.splice(s,1);break}}else e!==null&&a.includes(e)&&(r.dom=null)}function M(r,a,e,s){var i;const l=r.parentNode!==((i=g)==null?void 0:i.dom)?g:null;let v=D(a);P(()=>{var t=O(r,l,z(v));if(t)return()=>{l!==null&&L(l,j(t)?t:[t]),A(t)}})}function O(r,a,e,s,l){var v=e+"",i=B(v);if(i.childNodes.length===1){var t=i.firstChild;return r.before(t),a!==null&&x(t,a),t}var d=[...i.childNodes];return r.before(i),a!==null&&x(d,a),d}var Q=h("<a>prev</a>"),R=h("<a>next</a>"),S=h('<main class="post"><h1> </h1> <div> </div> <div><!></div> <div><!> <!></div></main>');function U(r,a){E(a,!1);let e=F(a,"article");G();var s=S();H(m=>{u(()=>I.title=`${J(e().title)}`)});var l=f(s),v=f(l),i=n(n(l,!0)),t=f(i),d=n(n(i,!0)),q=f(d);M(q,()=>e().html);var w=n(n(d,!0)),p=f(w);b(p,()=>e().prev,m=>{var o=Q();u(()=>k(o,"href",e().prev)),N(o,_=>$(_)),c(m,o)});var C=n(n(p,!0));b(C,()=>e().next,m=>{var o=R();u(()=>k(o,"href",e().next)),N(o,_=>$(_)),c(m,o)}),u(()=>{y(v,e().title),y(t,e().date)}),c(r,s),K()}export{U as default};
@@ -0,0 +1,2 @@
1
+ (function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const u of o)if(u.type==="childList")for(const s of u.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function t(o){const u={};return o.integrity&&(u.integrity=o.integrity),o.referrerPolicy&&(u.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?u.credentials="include":o.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function r(o){if(o.ep)return;o.ep=!0;const u=t(o);fetch(o.href,u)}})();var fe=Array.isArray,ut=Array.from,it=Object.isFrozen,hn=Object.defineProperty,J=Object.getOwnPropertyDescriptor,st=Object.getOwnPropertyDescriptors,lt=Object.getPrototypeOf;function be(e){return typeof e=="function"}const ne=2,kn=4,de=8,Rn=16,k=32,Ze=64,M=128,R=256,T=512,te=1024,j=2048,oe=4096,ft=8192,Je=16384,at=32768,Ue=Symbol("$state");function Ln(e){return e===this.v}function ct(e,n){return e!=e?n==n:e!==n||e!==null&&typeof e=="object"||typeof e=="function"}function Qe(e){return!ct(e,this.v)}const ae=1,Xe=2,_t=4,$n=8,dt=16,Me=64,pt=1,vt=2,ht=4,mt=8,yt=2,He=Symbol(),mn=["touchstart","touchmove","touchend"];function bt(e){throw new Error("effect_in_teardown")}function gt(){throw new Error("effect_in_unowned_derived")}function wt(e){throw new Error("effect_orphan")}function Et(){throw new Error("effect_update_depth_exceeded")}function At(e){throw new Error("props_invalid_value")}function St(){throw new Error("state_unsafe_mutation")}function ce(e){return{f:0,reactions:null,equals:Ln,v:e,version:0}}function _e(e){var t;const n=ce(e);return n.equals=Qe,b!==null&&b.l!==null&&((t=b.l).s??(t.s=[])).push(n),n}function L(e,n){var t=e.v!==He;return!O&&t&&S!==null&&Be()&&S.f&ne&&St(),e.equals(n)||(e.v=n,e.version++,Be()&&t&&g!==null&&g.f&R&&!(g.f&k)&&(x!==null&&x.includes(e)?(I(g,T),ke(g)):F===null?Nt([e]):F.push(e)),rn(e,T,!0)),n}function xt(e){var n=document.createElement("template");return n.innerHTML=e,n.content}function Pt(e){if(fe(e))for(var n=0;n<e.length;n++){var t=e[n];t.isConnected&&t.remove()}else e.isConnected&&e.remove()}function Nn(e){g===null&&S===null&&wt(),nn&&bt()}function yn(e,n){var t=n.last;t===null?n.last=n.first=e:(t.next=e,e.prev=t,n.last=e)}function pe(e,n,t){var r=(e&Ze)!==0,o={ctx:b,deps:null,dom:null,f:e|T,first:null,fn:n,last:null,next:null,parent:r?null:g,prev:null,teardown:null,transitions:null};if(S!==null&&!r){var u=S.f;u&ne&&(u&M&&gt(),g!==null&&yn(o,g)),yn(o,S)}if(t){var s=X;try{bn(!0),he(o),o.f|=ft}finally{bn(s)}}else ke(o);return o}function ze(e){Nn();var n=g!==null&&(g.f&de)!==0&&b!==null&&!b.m;if(n){var t=b;(t.e??(t.e=[])).push(e)}else{var r=ve(e);return r}}function Ct(e){return Nn(),Ce(e)}function Tt(e){const n=pe(Ze,e,!0);return()=>{Ie(n)}}function ve(e){return pe(kn,e,!1)}function ge(e,n){var t=b,r={effect:null,ran:!1};t.l.r1.push(r),r.effect=Ce(()=>{e(),!r.ran&&(r.ran=!0,L(t.l.r2,!0),Y(n))})}function It(){var e=b;Ce(()=>{if(C(e.l.r2)){for(var n of e.l.r1){var t=n.effect;ue(t)&&he(t),n.ran=!1}e.l.r2.v=!1}})}function Ce(e){return pe(de,e,!0)}function we(e){return Ce(e)}function Te(e,n=0){return pe(de|Rn|n,e,!0)}function re(e){return pe(de|k,e,!0)}function Dn(e){var n=e.teardown;if(n!==null){const t=nn,r=O;gn(!0),wn(!0);try{n.call(null)}finally{gn(t),wn(r)}}}function Ie(e){var n=e.dom;if(n!==null&&Pt(n),tn(e),Oe(e,0),I(e,oe),e.transitions)for(const u of e.transitions)u.stop();Dn(e);var t=e.parent;if(t!==null&&e.f&k&&t.first!==null){var r=e.prev,o=e.next;r!==null?o!==null?(r.next=o,o.prev=r):(r.next=null,t.last=r):o!==null?(o.prev=null,t.first=o):(t.first=null,t.last=null)}e.next=e.prev=e.teardown=e.ctx=e.dom=e.deps=e.parent=e.fn=null}function Ae(e,n){var t=[];en(e,t,!0),qn(t,()=>{Ie(e),n&&n()})}function qn(e,n){var t=e.length;if(t>0){var r=()=>--t||n();for(var o of e)o.out(r)}else n()}function en(e,n,t){if(!(e.f&j)){if(e.f^=j,e.transitions!==null)for(const s of e.transitions)(s.is_global||t)&&n.push(s);for(var r=e.first;r!==null;){var o=r.next,u=(r.f&Je)!==0||(r.f&k)!==0;en(r,n,u?t:!1),r=o}}}function Se(e){Fn(e,!0)}function Fn(e,n){if(e.f&j){e.f^=j,ue(e)&&he(e);for(var t=e.first;t!==null;){var r=t.next,o=(t.f&Je)!==0||(t.f&k)!==0;Fn(t,o?n:!1),t=r}if(e.transitions!==null)for(const u of e.transitions)(u.is_global||n)&&u.in()}}const q=()=>{};function $r(e){return typeof(e==null?void 0:e.then)=="function"}function Ot(e){return e()}function Ve(e){for(var n=0;n<e.length;n++)e[n]()}function xe(e){let n=ne|T;g===null&&(n|=M);const t={deps:null,deriveds:null,equals:Ln,f:n,first:null,fn:e,last:null,reactions:null,v:null,version:0};if(S!==null&&S.f&ne){var r=S;r.deriveds===null?r.deriveds=[t]:r.deriveds.push(t)}return t}function kt(e){const n=xe(e);return n.equals=Qe,n}function Un(e){tn(e);var n=e.deriveds;if(n!==null){e.deriveds=null;for(var t=0;t<n.length;t+=1)Rt(n[t])}}function Mn(e,n){Un(e);var t=zn(e),r=(Q||e.f&M)&&e.deps!==null?te:R;I(e,r);var o=e.equals(t);return o||(e.v=t,rn(e,T,n)),o}function Rt(e){Un(e),Oe(e,0),I(e,oe),e.first=e.last=e.deps=e.reactions=e.fn=null}function Lt(e){throw new Error("lifecycle_outside_component")}const Hn=0,$t=1;let Ee=Hn,Pe=!1,X=!1,nn=!1;function bn(e){X=e}function gn(e){nn=e}function wn(e){O=e}let B=[],ee=0,S=null;function Nr(e){S=e}let g=null;function Dr(e){g=e}let x=null,A=0,F=null;function Nt(e){F=e}let O=!1,Q=!1,b=null;function qr(e){b=e}function Be(){return b!==null&&b.l===null}function ue(e){var a;var n=e.f,t=(n&T)!==0,r=(n&M)!==0;if(t&&!r)return!0;if(n&te||t&&r){var o=e.deps;if(o!==null)for(var u=o.length,s,l=0;l<u;l++){var i=o[l];if(!t&&ue(i)&&(s=Mn(i,!0)),r){var f=i.version;if(f>e.version)return e.version=f,!s;if(!Q&&!((a=i==null?void 0:i.reactions)!=null&&a.includes(e))){var _=i.reactions;_===null?i.reactions=[e]:_.push(e)}}else if(e.f&T)return!0}r||I(e,R)}return t}function Dt(e,n,t){throw e}function zn(e){const n=x,t=A,r=F,o=S,u=Q,s=O;x=null,A=0,F=null,S=e,Q=!X&&(e.f&M)!==0,O=!1;try{let l=(0,e.fn)(),i=e.deps;if(x!==null){let f;if(i!==null){const _=i.length,a=A===0?x:i.slice(0,A).concat(x),c=a.length>16&&_-A>1?new Set(a):null;for(f=A;f<_;f++){const p=i[f];(c!==null?!c.has(p):!a.includes(p))&&Vn(e,p)}}if(i!==null&&A>0)for(i.length=A+x.length,f=0;f<x.length;f++)i[A+f]=x[f];else e.deps=i=x;if(!Q)for(f=A;f<i.length;f++){const _=i[f],a=_.reactions;a===null?_.reactions=[e]:a[a.length-1]!==e&&a.push(e)}}else i!==null&&A<i.length&&(Oe(e,A),i.length=A);return l}finally{x=n,A=t,F=r,S=o,Q=u,O=s}}function Vn(e,n){const t=n.reactions;let r=0;if(t!==null){r=t.length-1;const o=t.indexOf(e);o!==-1&&(r===0?n.reactions=null:(t[o]=t[r],t.pop()))}r===0&&n.f&M&&(I(n,T),Oe(n,0))}function Oe(e,n){const t=e.deps;if(t!==null){const r=n===0?null:t.slice(0,n);let o;for(o=n;o<t.length;o++){const u=t[o];(r===null||!r.includes(u))&&Vn(e,u)}}}function tn(e){let n=e.first;e.first=null,e.last=null;for(var t;n!==null;)t=n.next,Ie(n),n=t}function he(e){var n=e.f;if(!(n&oe)){I(e,R);var t=e.ctx,r=g,o=b;g=e,b=t;try{n&Rn||tn(e),Dn(e);var u=zn(e);e.teardown=typeof u=="function"?u:null}catch(s){Dt(s)}finally{g=r,b=o}}}function Bn(){ee>1e3&&(ee=0,Et()),ee++}function jn(e){Bn();var n=X;X=!0;try{for(var t=0;t<e.length;t++){var r=e[t];if(r.first===null&&!(r.f&k))En([r]);else{var o=[];Yn(r,o),En(o)}}}finally{X=n}}function En(e){var n=e.length;if(n!==0)for(var t=0;t<n;t++){var r=e[t];!(r.f&(oe|j))&&ue(r)&&he(r)}}function qt(){if(Pe=!1,ee>101)return;const e=B;B=[],jn(e),Pe||(ee=0)}function ke(e){Ee===Hn&&(Pe||(Pe=!0,queueMicrotask(qt)));for(var n=e;n.parent!==null;){n=n.parent;var t=n.f;if(t&k){if(!(t&R))return;I(n,te)}}B.push(n)}function Yn(e,n){var t=e.first,r=[];e:for(;t!==null;){var o=t.f,u=(o&(oe|j))===0,s=o&k,l=(o&R)!==0,i=t.first;if(u&&(!s||!l)){if(s&&I(t,R),o&de){if(!s&&ue(t)&&(he(t),i=t.first),i!==null){t=i;continue}}else if(o&kn)if(s||l){if(i!==null){t=i;continue}}else r.push(t)}var f=t.next;if(f===null){let v=t.parent;for(;v!==null;){if(e===v)break e;var _=v.next;if(_!==null){t=_;continue e}v=v.parent}}t=f}for(var a=0;a<r.length;a++)i=r[a],n.push(i),Yn(i,n)}function Kn(e,n=!0){var t=Ee,r=B;try{Bn();const u=[];Ee=$t,B=u,n&&jn(r);var o=e==null?void 0:e();return(B.length>0||u.length>0)&&Kn(),ee=0,o}finally{Ee=t,B=r}}function C(e){const n=e.f;if(n&oe)return e.v;if(S!==null&&!(S.f&(k|Ze))&&!O){const t=(S.f&M)!==0,r=S.deps;x===null&&r!==null&&r[A]===e&&!(t&&g!==null)?A++:(r===null||A===0||r[A-1]!==e)&&(x===null?x=[e]:x.push(e)),F!==null&&g!==null&&g.f&R&&!(g.f&k)&&F.includes(e)&&(I(g,T),ke(g))}return n&ne&&ue(e)&&Mn(e,!1),e.v}function rn(e,n,t){var r=e.reactions;if(r!==null)for(var o=Be(),u=r.length,s=0;s<u;s++){var l=r[s],i=l.f;if(!(i&T||(!t||!o)&&l===g)){I(l,n);var f=(i&te)!==0,_=(i&M)!==0;(i&R||f&&_)&&(l.f&ne?rn(l,te,t):ke(l))}}}function Y(e){const n=O;try{return O=!0,e()}finally{O=n}}const Ft=~(T|te|R);function I(e,n){e.f=e.f&Ft|n}function Ut(e){return typeof e=="object"&&e!==null&&typeof e.f=="number"}function Re(e,n=!1,t){b={p:b,c:null,e:null,m:!1,s:e,x:null,l:null},n||(b.l={s:null,u:null,r1:[],r2:ce(!1)})}function Le(e){const n=b;if(n!==null){const r=n.e;if(r!==null){n.e=null;for(var t=0;t<r.length;t++)ve(r[t])}b=n.p,n.m=!0}return{}}function Gn(e){if(!(typeof e!="object"||!e||e instanceof EventTarget)){if(Ue in e)je(e);else if(!Array.isArray(e))for(let n in e){const t=e[n];typeof t=="object"&&t&&Ue in t&&je(t)}}}function je(e,n=new Set){if(typeof e=="object"&&e!==null&&!(e instanceof EventTarget)&&!n.has(e)){n.add(e),e instanceof Date&&e.getTime();for(let r in e)try{je(e[r],n)}catch{}const t=lt(e);if(t!==Object.prototype&&t!==Array.prototype&&t!==Map.prototype&&t!==Set.prototype&&t!==Date.prototype){const r=st(t);for(let o in r){const u=r[o].get;if(u)try{u.call(e)}catch{}}}}}function An(e){return Ut(e)?C(e):e}var H,W,Sn,Wn,on,Zn,Jn,un;function Mt(){H===void 0&&(H=Node.prototype,W=Element.prototype,Sn=Text.prototype,H.appendChild,Wn=H.cloneNode,un=document,W.__click=void 0,Sn.__nodeValue=" ",W.__className="",W.__attributes=null,W.__e=void 0,on=J(H,"firstChild").get,Zn=J(H,"nextSibling").get,Jn=J(H,"textContent").set,J(W,"className").set)}function Ht(e,n){return Wn.call(e,n)}function me(){return document.createTextNode("")}function $(e){return on.call(e)}function zt(e,n){return on.call(e)}function P(e,n=!1){return Zn.call(e)}function Vt(e){Jn.call(e,"")}function Bt(e){for(var n=0;n<e.length;n++)Xn.add(e[n]);for(var t of Ye)t(e)}function xn(e,n){var a;var t=e.ownerDocument,r=n.type,o=((a=n.composedPath)==null?void 0:a.call(n))||[],u=o[0]||n.target;n.target!==u&&hn(n,"target",{configurable:!0,value:u});var s=0,l=n.__root;if(l){var i=o.indexOf(l);if(i!==-1&&(e===document||e===window)){n.__root=e;return}var f=o.indexOf(e);if(f===-1)return;i<=f&&(s=i+1)}u=o[s]||n.target,hn(n,"currentTarget",{configurable:!0,get(){return u||t}});function _(v){u=v;var c=v.parentNode||v.host||null;try{var p=v["__"+r];if(p!==void 0&&!v.disabled)if(fe(p)){var[d,...h]=p;d.apply(v,[n,...h])}else p.call(v,n)}finally{!n.cancelBubble&&c!==e&&c!==null&&v!==e&&_(c)}}try{_(u)}finally{n.__root=e,u=e}}function Qn(e){var n;n=document.head.appendChild(me());try{Te(()=>e(n))}finally{}}const Xn=new Set,Ye=new Set;function ie(e,n){const t=e.__nodeValue,r=V(n);t!==r&&(e.nodeValue=r,e.__nodeValue=r)}function V(e){return typeof e=="string"?e:e==null?"":e+""}function jt(e,n){const t=n.anchor??n.target.appendChild(me());return Kn(()=>Yt(e,{...n,anchor:t}),!1)}function Yt(e,{target:n,anchor:t,props:r={},events:o,context:u,intro:s=!1}){Mt();const l=new Set,i=xn.bind(null,n),f=xn.bind(null,document),_=c=>{for(let p=0;p<c.length;p++){const d=c[p];l.has(d)||(l.add(d),n.addEventListener(d,i,mn.includes(d)?{passive:!0}:void 0),document.addEventListener(d,f,mn.includes(d)?{passive:!0}:void 0))}};_(ut(Xn)),Ye.add(_);let a;const v=Tt(()=>(re(()=>{if(u){Re({});var c=b;c.c=u}o&&(r.$$events=o),a=e(t,r)||{},u&&Le()}),()=>{for(const c of l)n.removeEventListener(c,i);Ye.delete(_),Pn.delete(a)}));return Pn.set(a,v),a}let Pn=new WeakMap;function Kt(e,n,t,r=null,o=!1){var u=null,s=null,l=null,i=o?Je:0;Te(()=>{l!==(l=!!n())&&(l?(u?Se(u):u=re(()=>t(e)),s&&Ae(s,()=>{s=null})):(s?Se(s):r&&(s=re(()=>r(e))),u&&Ae(u,()=>{u=null})))},i)}function sn(e,n=g){var t=n.dom;return t===null?n.dom=e:(fe(t)||(t=n.dom=[t]),fe(e)?t.push(...e):t.push(e)),e}function K(e,n){var t=(n&yt)!==0,r;return()=>{r||(r=xt(e),r=r.firstChild);var o=t?document.importNode(r,!0):Ht(r,!0);return sn(o),o}}function Gt(){var e=document.createDocumentFragment(),n=me();return e.append(n),sn([n]),e}function U(e,n){e.before(n)}let qe=null;function Wt(e,n){return n}function Zt(e,n,t){for(var r=[],o=e.length,u=0;u<o;u++)en(e[u].e,r,!0);if(o>0&&r.length===0&&n!==null){var s=n.parentNode;Vt(s),s.append(n)}qn(r,()=>{for(var l=0;l<o;l++)Ie(e[l].e);t!==void 0&&t()})}function Jt(e,n,t,r,o,u=null){var s={flags:n,items:new Map,next:null},l=(n&$n)!==0;if(l){var i=e;e=i.appendChild(me())}var f=null;Te(()=>{var _=t(),a=fe(_)?_:_==null?[]:Array.from(_),v=a.length,c=s.flags;c&Me&&!it(a)&&!(Ue in a)&&(c^=Me,c&_t&&!(c&ae)&&(c^=ae)),Qt(a,s,e,o,c,r),u!==null&&(v===0?f?Se(f):f=re(()=>u(e)):f!==null&&Ae(f,()=>{f=null}))})}function Qt(e,n,t,r,o,u){var _n,dn,pn,vn;var s=(o&dt)!==0,l=(o&(ae|Xe))!==0,i=e.length,f=n.items,_=n.next,a=_,v=new Set,c=n,p=new Set,d=[],h=[],w,y,m,E;if(s)for(E=0;E<i;E+=1)w=e[E],y=u(w,E),m=f.get(y),m!==void 0&&((_n=m.a)==null||_n.measure(),p.add(m));for(E=0;E<i;E+=1){if(w=e[E],y=u(w,E),m=f.get(y),m===void 0){var fn=sn(me()),an=a?a.o:t;an.before(fn),c=er(fn,an,c,c.next,w,y,E,r,o),f.set(y,c),d=[],h=[],a=c.next;continue}if(l&&Xt(m,w,E,o),m.e.f&j&&(Se(m.e),s&&((dn=m.a)==null||dn.unfix(),p.delete(m))),m!==a){if(v.has(m)){if(d.length<h.length){var ye=h[0],N;c=ye.prev;var cn=d[0],Ne=d[d.length-1];for(N=0;N<d.length;N+=1)Cn(d[N],ye,t);for(N=0;N<h.length;N+=1)v.delete(h[N]);z(cn.prev,Ne.next),z(c,cn),z(Ne,ye),a=ye,c=Ne,E-=1,d=[],h=[]}else v.delete(m),Cn(m,a,t),z(m.prev,m.next),z(m,c.next),z(c,m),c=m;continue}for(d=[],h=[];a!==null&&a.k!==y;)v.add(a),h.push(a),a=a.next;if(a===null)continue;m=a}d.push(m),c=m,a=m.next}const D=Array.from(v);for(;a;)D.push(a),a=a.next;var ot=o&$n&&i===0?t:null;if(s){for(E=0;E<D.length;E+=1)(pn=D[E].a)==null||pn.measure();for(E=0;E<D.length;E+=1)(vn=D[E].a)==null||vn.fix()}Zt(D,ot,()=>{for(var G=0;G<D.length;G+=1){var De=D[G];f.delete(De.k),z(De.prev,De.next)}}),s&&ve(()=>{Y(()=>{var G;for(m of p)(G=m.a)==null||G.apply()})})}function Xt(e,n,t,r){r&ae&&L(e.v,n),r&Xe?L(e.i,t):e.i=t}function er(e,n,t,r,o,u,s,l,i){var f=qe;try{var _=(i&ae)!==0,a=(i&Me)===0,v=_?a?_e(o):ce(o):o,c=i&Xe?ce(s):s,p={i:c,v,k:u,a:null,e:null,o:e,prev:t,next:r};return t.next=p,r!==null&&(r.prev=p),qe=p,p.e=re(()=>l(n,v,c)),p}finally{qe=f}}function Cn(e,n,t){for(var r=e.next?e.next.o:t,o=n?n.o:t,u=e.o;u!==r;){var s=u.nextSibling;o.before(u),u=s}}function z(e,n){e.next=n,n!==null&&(n.prev=e)}function nr(e,n,t){let r,o;Te(()=>{r!==(r=n())&&(o&&(Ae(o),o=null),r&&(o=re(()=>t(r))))})}function se(e,n,t){ve(()=>{var r=Y(()=>n(e,t==null?void 0:t())||{});if(r!=null&&r.destroy)return()=>r.destroy()})}function tr(e,n,t){t=t==null?null:t+"";var r=e.__attributes??(e.__attributes={});r[n]!==(r[n]=t)&&(t===null?e.removeAttribute(n):e.setAttribute(n,t))}function rr(){const e=b,n=e.l.u;n&&(n.b.length&&Ct(()=>{Tn(e),Ve(n.b)}),ze(()=>{const t=Y(()=>n.m.map(Ot));return()=>{for(const r of t)typeof r=="function"&&r()}}),n.a.length&&ze(()=>{Tn(e),Ve(n.a)}))}function Tn(e){if(e.l.s)for(const n of e.l.s)C(n);Gn(e.s)}const or={get(e,n){let t=e.props.length;for(;t--;){let r=e.props[t];if(be(r)&&(r=r()),typeof r=="object"&&r!==null&&n in r)return r[n]}},getOwnPropertyDescriptor(e,n){let t=e.props.length;for(;t--;){let r=e.props[t];if(be(r)&&(r=r()),typeof r=="object"&&r!==null&&n in r)return J(r,n)}},has(e,n){for(let t of e.props)if(be(t)&&(t=t()),t!=null&&n in t)return!0;return!1},ownKeys(e){const n=[];for(let t of e.props){be(t)&&(t=t());for(const r in t)n.includes(r)||n.push(r)}return n}};function ur(...e){return new Proxy({props:e},or)}function ir(e,n,t,r){var w;var o=(t&pt)!==0,u=(t&vt)!==0,s=(t&mt)!==0,l=e[n],i=(w=J(e,n))==null?void 0:w.set,f=r,_=!0,a=()=>(s&&_&&(_=!1,f=Y(r)),f);l===void 0&&r!==void 0&&(i&&u&&At(),l=a(),i&&i(l));var v;if(u)v=()=>{var y=e[n];return y===void 0?a():(_=!0,y)};else{var c=(o?xe:kt)(()=>e[n]);c.f|=at,v=()=>{var y=C(c);return y!==void 0&&(f=void 0),y===void 0?f:y}}if(!(t&ht))return v;if(i)return function(y){return arguments.length===1?(i(y),y):v()};var p=!1,d=_e(l),h=xe(()=>{var y=v(),m=C(d);return p?(p=!1,m):d.v=y});return o||(h.equals=Qe),function(y){var m=C(h);return arguments.length>0?(h.equals(y)||(p=!0,L(d,y),C(h)),y):m}}function et(e,n,t){if(e==null)return n(void 0),t&&t(void 0),q;const r=e.subscribe(n,t);return r.unsubscribe?()=>r.unsubscribe():r}function Ke(e,n,t){let r=t[n];const o=r===void 0;o&&(r={store:null,last_value:null,value:_e(He),unsubscribe:q},t[n]=r),(o||r.store!==e)&&(r.unsubscribe(),r.store=e??null,r.unsubscribe=sr(e,r.value));const u=C(r.value);return u===He?r.last_value:u}function sr(e,n){return e==null?(L(n,void 0),q):et(e,t=>L(n,t))}function nt(e){lr(()=>{let n;for(n in e)e[n].unsubscribe()})}function lr(e){ve(()=>()=>Y(e))}function fr(e){b===null&&Lt(),b.l!==null?ar(b).m.push(e):ze(()=>{const n=Y(e);if(typeof n=="function")return n})}function ar(e){var n=e.l;return n.u??(n.u={a:[],b:[],m:[]})}const cr="modulepreload",_r=function(e){return"/"+e},In={},Fe=function(n,t,r){let o=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),s=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));o=Promise.all(t.map(l=>{if(l=_r(l),l in In)return;In[l]=!0;const i=l.endsWith(".css"),f=i?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${f}`))return;const _=document.createElement("link");if(_.rel=i?"stylesheet":cr,i||(_.as="script",_.crossOrigin=""),_.href=l,s&&_.setAttribute("nonce",s),document.head.appendChild(_),i)return new Promise((a,v)=>{_.addEventListener("load",a),_.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${l}`)))})}))}return o.then(()=>n()).catch(u=>{const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=u,window.dispatchEvent(s),!s.defaultPrevented)throw u})},dr="5";typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(dr);const Z=[];function pr(e,n){return{subscribe:$e(e,n).subscribe}}function vr(e,n){return e!=e?n==n:e!==n||e&&typeof e=="object"||typeof e=="function"}function $e(e,n=q){let t=null;const r=new Set;function o(l){if(vr(e,l)&&(e=l,t)){const i=!Z.length;for(const f of r)f[1](),Z.push(f,e);if(i){for(let f=0;f<Z.length;f+=2)Z[f][0](Z[f+1]);Z.length=0}}}function u(l){o(l(e))}function s(l,i=q){const f=[l,i];return r.add(f),r.size===1&&(t=n(o,u)||q),l(e),()=>{r.delete(f),r.size===0&&t&&(t(),t=null)}}return{set:o,update:u,subscribe:s}}function hr(e,n,t){const r=!Array.isArray(e),o=r?[e]:e;if(!o.every(Boolean))throw new Error("derived() expects stores as input, got a falsy value");const u=n.length<2;return pr(t,(s,l)=>{let i=!1;const f=[];let _=0,a=q;const v=()=>{if(_)return;a();const p=n(r?f[0]:f,s,l);u?s(p):a=typeof p=="function"?p:q},c=o.map((p,d)=>et(p,h=>{f[d]=h,_&=~(1<<d),i&&v()},()=>{_|=1<<d}));return i=!0,v(),function(){Ve(c),a(),i=!1}})}const Ge=$e(window.location.pathname),We=$e(null),mr=hr(We,e=>(e&&e.params)??{}),tt=(()=>{function e(){return new URL(window.location.href)}const{subscribe:n,set:t}=$e(e());return{subscribe:n,set(r){t(r)},setCurrent(){t(e())}}})();function ln(e){window.history.pushState({},"",e);const n=new URL(e,window.location.origin);Ge.set(n.pathname),tt.set(n)}function yr(e,n){Re(n,!1);const t={};nt(t);const r=()=>Ke(Ge,"$currentPath",t),o=()=>Ke(We,"$routeState",t),u=_e(),s=_e();let l=ir(n,"routes",8,()=>[]);fr(()=>{const c=()=>{Ge.set(window.location.pathname),tt.setCurrent()};return window.addEventListener("popstate",c),()=>{window.removeEventListener("popstate",c)}});async function i(c){const{route:p,params:d}=f(c),h=await _(p,d);if(typeof h=="string"){ln(h);return}We.set(h)}function f(c){for(const p of l()){const d=new RegExp(`^${p.path}$`,"i"),h=c.match(d);if(h)return{route:p,params:h.groups??{}}}throw new Error(`No route for ${c} exists.`)}async function _(c,p){let d=c.component;const h={};if(typeof c.resolver=="function"){const w=await Promise.resolve(c.resolver({path:c.path,params:p,props:h}));if(Reflect.has(w,"redirect"))return w.redirect;Reflect.has(w,"default")?d=w.default:d=w}if(!d)throw new Error("Component is not specified");return Object.keys(p).length!==0&&(h.params=p),{params:p,component:d,props:h}}ge(()=>Gn(l()),()=>{if(Array.isArray(l())===!1)throw new Error(`routes should be Array, given: ${typeof l()}`)}),ge(()=>r(),()=>{i(r())}),ge(()=>o(),()=>{L(u,(o()&&o().component)??null)}),ge(()=>o(),()=>{L(s,(o()&&o().props)??{})}),It(),rr();var a=Gt(),v=zt(a);nr(v,()=>C(u),c=>{c(v,ur(()=>C(s)))}),U(e,a),Le()}function le(e){function n(t){t.preventDefault();const r=e.getAttribute("href");r&&ln(r)}return e.addEventListener("click",n),{destroy(){e.removeEventListener("click",n)}}}function br(e){return{redirect:e}}var gr=K('<main class="home"><h1>Home</h1></main>');function wr(e){var n=gr();Qn(t=>{un.title="Home"}),U(e,n)}var Er=K("<li><a> </a></li>"),Ar=K('<main class="guide"><h1> </h1> <p class="routeParams"> </p> <p class="params"> </p> <ul></ul></main>');function Sr(e,n){Re(n,!0);const t={};nt(t);const r=()=>Ke(mr,"$routeParams",t),o=xe(()=>parseInt(n.params.guideId));var u=Ar();Qn(c=>{we(()=>un.title=`Guide ${V(C(o))}`)});var s=$(u),l=$(s),i=P(P(s,!0)),f=$(i),_=P(P(i,!0)),a=$(_),v=P(P(_,!0));Jt(v,73,()=>[1,2,3],Wt,(c,p,d)=>{var h=Er(),w=$(h),y=$(w);we(()=>{tr(w,"href",`/guide/${An(p)}`),ie(y,`guide(${V(An(p))})`)}),se(w,m=>le(m)),U(c,h)}),we(()=>{ie(l,`Guide ${V(C(o))}`),ie(f,`routeParams: ${V(r().guideId)}`),ie(a,`params: ${V(n.params.guideId)}`)}),U(e,u),Le()}var xr=K("<h1>Not Found</h1>");function On(e){var n=xr();U(e,n)}const Pr=e=>new Promise(n=>setTimeout(n,e)),rt=[{id:"2024/03/01/baz",title:"baz",date:"2024-03-01",html:"<p>baz!</p>",url:"/blog/posts/2024/03/01/baz",prev:"/blog/posts/2024/02/01/bar"},{id:"2024/02/01/bar",title:"bar",date:"2024-02-01",html:"<p>bar!</p>",previous:"",url:"/blog/posts/2024/02/01/bar",next:"/blog/posts/2024/03/01/baz",prev:"/blog/posts/2024/01/01/foo"},{id:"2024/01/01/foo",title:"foo",date:"2024-01-01",html:"<p>foo!</p>",url:"/blog/posts/2024/01/01/foo",next:"/blog/posts/2024/02/01/bar"}];async function Fr(){return await Pr(100),rt}async function Cr(e){return rt.find(n=>n.id===e)}var Tr=(e,n)=>{L(n,"admin")},Ir=K("<button>login</button>"),Or=(e,n,t)=>{L(n,"anonymous"),t("/")},kr=K("<button>logout</button>"),Rr=K('<div><header><nav><a href="/">home</a> | <a href="/blog">blog</a> | <a href="/guide/1">guide(1)</a> | <a href="/admin">admin</a> <!></nav></header> <!></div>');function Lr(e,n){Re(n,!0);let t=ce("anonymous");async function r({params:d,props:h}){const w=await Cr(d.postId);return w?(h.article=w,Fe(()=>import("./Post-DkdqlSq4.js"),[])):On}const o=[{path:"/",component:wr},{path:"/blog",resolver:()=>Fe(()=>import("./Blog-seinfUgf.js"),[])},{path:"/blog/posts/(?<postId>.*)",resolver:r},{path:"/guide/(?<guideId>\\d+)",component:Sr},{path:"/admin",resolver:()=>C(t)==="anonymous"?br("/"):Fe(()=>import("./Admin-DoyP5Bto.js"),[])},{path:".*",component:On}];var u=Rr(),s=$(u),l=$(s),i=$(l),f=P(P(i,!0)),_=P(P(f,!0)),a=P(P(_,!0)),v=P(a,!0),c=P(v);Kt(c,()=>C(t)==="anonymous",d=>{var h=Ir();h.__click=[Tr,t],U(d,h)},d=>{var h=kr();h.__click=[Or,t,ln],U(d,h)});var p=P(P(s,!0));yr(p,{routes:o}),we(()=>ie(v,` |
2
+ user: ${V(C(t))} `)),se(i,d=>le(d)),se(f,d=>le(d)),se(_,d=>le(d)),se(a,d=>le(d)),U(e,u),Le()}Bt(["click"]);jt(Lr,{target:document.getElementById("app")});export{un as $,Ie as A,re as B,Dr as C,Nr as D,qr as E,Kn as F,Ae as G,b as H,Gt as I,Jt as J,Fr as K,zt as L,An as M,Wt as N,Pt as a,xt as b,g as c,xe as d,Re as e,ir as f,C as g,rr as h,fe as i,Qn as j,Kt as k,tr as l,se as m,le as n,U as o,sn as p,ie as q,Ce as r,V as s,we as t,Le as u,K as v,$ as w,P as x,Te as y,$r as z};
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite + Svelte</title>
8
+ <!--app-head-->
9
+ <script type="module" crossorigin src="/assets/index-ADyOUHdb.js"></script>
10
+ </head>
11
+ <body>
12
+ <div id="app"><!--app-html--></div>
13
+ </body>
14
+ </html>
@@ -13,17 +13,21 @@
13
13
  "@sveltejs/vite-plugin-svelte": "^3.1.0",
14
14
  "@types/node": "^20.12.12",
15
15
  "playwright": "^1.44.0",
16
- "svelte": "^5.0.0-next.136",
16
+ "svelte": "^5.0.0-next.144",
17
17
  "svelte-spa-history-router": "file:../..",
18
18
  "vite": "^5.2.11"
19
19
  }
20
20
  },
21
21
  "../..": {
22
- "version": "2.1.2",
22
+ "version": "2.2.0-next.0",
23
23
  "dev": true,
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "prettier": "3.2.1"
26
+ "prettier": "3.2.1",
27
+ "svelte": "4.2.17"
28
+ },
29
+ "peerDependencies": {
30
+ "svelte": "*"
27
31
  }
28
32
  },
29
33
  "node_modules/@ampproject/remapping": {
@@ -1066,10 +1070,11 @@
1066
1070
  }
1067
1071
  },
1068
1072
  "node_modules/svelte": {
1069
- "version": "5.0.0-next.136",
1070
- "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.0.0-next.136.tgz",
1071
- "integrity": "sha512-M3jHAIfWZ7K+hjZdvu2p53ZtWE843yubxJfjxeQw9XiwMYG5z6quCA5u8r23GrxAp20JBl36B6ucbZvLUf0Z/g==",
1073
+ "version": "5.0.0-next.144",
1074
+ "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.0.0-next.144.tgz",
1075
+ "integrity": "sha512-akjtRBHzaLa1XdMv9tBGkXE5N2JaRc3gL+ZIctjc9Gew9DF7NxGTlxXq+HR9yUV7Lsg4o9ltMfkxz8H3K7piNQ==",
1072
1076
  "dev": true,
1077
+ "license": "MIT",
1073
1078
  "dependencies": {
1074
1079
  "@ampproject/remapping": "^2.2.1",
1075
1080
  "@jridgewell/sourcemap-codec": "^1.4.15",
@@ -15,7 +15,7 @@
15
15
  "@sveltejs/vite-plugin-svelte": "^3.1.0",
16
16
  "@types/node": "^20.12.12",
17
17
  "playwright": "^1.44.0",
18
- "svelte": "^5.0.0-next.136",
18
+ "svelte": "^5.0.0-next.144",
19
19
  "svelte-spa-history-router": "file:../..",
20
20
  "vite": "^5.2.11"
21
21
  },
@@ -1,5 +1,7 @@
1
1
  <script lang="ts">
2
- import type { ResolverArgs } from "svelte-spa-history-router";
2
+ import type { Component } from "svelte";
3
+
4
+ import type { Route, AsyncResolver } from "svelte-spa-history-router";
3
5
  import { Router, push, link, redirect } from "svelte-spa-history-router";
4
6
 
5
7
  import Home from "./pages/Home.svelte";
@@ -10,11 +12,8 @@
10
12
 
11
13
  let user = $state("anonymous");
12
14
 
13
- /**
14
- * FIXME: better to Use AsyncResolver type, but ComponentType cause error on currently svelte build
15
- */
16
- async function prefetchArticle({ params, props }: ResolverArgs) {
17
- const article = await getArticle(params.postId);
15
+ const prefetchArticle: AsyncResolver<Component<any, any, any>> = async ({ params, props }) => {
16
+ const article = await getArticle(params.postId ?? "");
18
17
  if (article) {
19
18
  props.article = article;
20
19
  return import("./pages/Post.svelte");
@@ -23,7 +22,7 @@
23
22
  }
24
23
  }
25
24
 
26
- const routes = [
25
+ const routes: Route<Component<any, any, any>>[] = [
27
26
  { path: "/", component: Home },
28
27
  { path: "/blog", resolver: () => import("./pages/Blog.svelte") },
29
28
  {
@@ -2,8 +2,7 @@ import { mount } from "svelte";
2
2
 
3
3
  import App from './App.svelte';
4
4
 
5
- const target = document.getElementById('app');
6
- if (!target) throw new Error("cannot find #app");
5
+ const target = /** @type {HTMLElement} */(document.getElementById('app'));
7
6
 
8
7
  const app = mount(App, { target });
9
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-spa-history-router",
3
- "version": "2.2.0-next.0",
3
+ "version": "2.2.0-next.2",
4
4
  "description": "History base router for Svelte SPA",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/Router.svelte CHANGED
@@ -1,7 +1,5 @@
1
1
  <script>
2
2
  /**
3
- * @typedef { import("svelte").ComponentType } ComponentType
4
- *
5
3
  * @typedef { import("./types").ComponentModule } ComponentModule
6
4
  * @typedef { import("./types").Route } Route
7
5
  * @typedef { import("./types").Redirection } Redirection
@@ -91,7 +89,7 @@
91
89
  if (Reflect.has(resolved, "default")) {
92
90
  component = /** @type {ComponentModule} */(resolved).default;
93
91
  } else {
94
- component = /** @type {ComponentType} */(resolved);
92
+ component = /** @type {ComponentModule["default"]} */(resolved);
95
93
  }
96
94
  }
97
95
  if (!component) throw new Error("Component is not specified");
package/src/types.ts CHANGED
@@ -10,8 +10,8 @@ export type RouteProps = {
10
10
  [key: string]: any
11
11
  }
12
12
 
13
- export type ComponentModule = {
14
- default: ComponentType,
13
+ export type ComponentModule<T = ComponentType> = {
14
+ default: T,
15
15
  }
16
16
 
17
17
  export type Redirection = {
@@ -23,8 +23,8 @@ export interface CurrentURL extends Readable<URL> {
23
23
  setCurrent: () => void
24
24
  }
25
25
 
26
- export type RouteState = {
27
- component: ComponentType,
26
+ export type RouteState<T = ComponentType> = {
27
+ component: T,
28
28
  params: RouteParams,
29
29
  props: RouteProps,
30
30
  }
@@ -35,16 +35,16 @@ export type ResolverArgs = {
35
35
  props: RouteProps,
36
36
  }
37
37
 
38
- export type SyncResolver = (
38
+ export type SyncResolver<T = ComponentType> = (
39
39
  args: ResolverArgs
40
- ) => ComponentType | Redirection
40
+ ) => T | Redirection
41
41
 
42
- export type AsyncResolver = (
42
+ export type AsyncResolver<T = ComponentType> = (
43
43
  args: ResolverArgs
44
- ) => Promise<ComponentType | ComponentModule | Redirection>
44
+ ) => Promise<T | ComponentModule<T> | Redirection>
45
45
 
46
- export type Route = {
46
+ export type Route<T = ComponentType> = {
47
47
  path: string,
48
- component?: ComponentType,
49
- resolver?: SyncResolver | AsyncResolver,
48
+ component?: T,
49
+ resolver?: SyncResolver<T> | AsyncResolver<T>,
50
50
  }
package/src/scratch.js DELETED
@@ -1,12 +0,0 @@
1
- let re = /(?<pref>.+[都|道|府|県])(?<ward>.+[市|区|町|村])/;
2
- re = /静岡/;
3
- let str = "静岡県磐田市気子島";
4
-
5
- const match = str.match(re);
6
- let params;
7
-
8
- if (match) {
9
- params = match.groups || {};
10
- }
11
-
12
- console.log(params);