@mpen/rerouter 0.3.0 → 0.3.1

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.
Files changed (66) hide show
  1. package/README.md +4 -0
  2. package/{src → cli}/bin.test.ts +24 -2
  3. package/{src → cli}/bin.ts +27 -18
  4. package/cli/tsconfig.json +9 -0
  5. package/dist/acorn-k7ED_tOl.js +4968 -0
  6. package/dist/angular--Iqdw9UJ.js +4057 -0
  7. package/dist/babel-hfWAujRY.js +9878 -0
  8. package/dist/bin.d.ts +1 -1
  9. package/dist/bin.js +28 -23
  10. package/dist/estree-C1Zjnvlw.js +7266 -0
  11. package/dist/flow-BaD9LyIP.js +52912 -0
  12. package/dist/glimmer-CvCjW_1V.js +7541 -0
  13. package/dist/graphql-BdtzBuWh.js +1945 -0
  14. package/dist/html-DkZtUVbo.js +7137 -0
  15. package/dist/index.d.ts +19 -6
  16. package/dist/index.js +135 -27
  17. package/dist/markdown-Z8Vrc69e.js +6876 -0
  18. package/dist/meriyah-DeO4stuH.js +7590 -0
  19. package/dist/postcss-BmgGJ0E5.js +6777 -0
  20. package/dist/prettier-BT_F8kIx.js +15629 -0
  21. package/dist/typescript-DtIxStjy.js +22936 -0
  22. package/dist/yaml-CWOPBY0q.js +5281 -0
  23. package/examples/App.tsx +18 -49
  24. package/examples/dist/BlogPost-c10d9w2p.js +1 -0
  25. package/examples/dist/FetchLoading-534mdrgz.js +1 -0
  26. package/examples/dist/FetchLoading-sbxbdkre.js +1 -0
  27. package/examples/dist/Home-a1258p25.js +1 -0
  28. package/examples/dist/KitchenSink-821mjg0h.js +1 -0
  29. package/examples/dist/Login-wywx6bp7.js +1 -0
  30. package/examples/dist/Match-1e72jm5w.js +1 -0
  31. package/examples/dist/NotFound-smxj24jw.js +1 -0
  32. package/examples/dist/SlowLoading-59xxmbfk.js +1 -0
  33. package/examples/dist/index-0d4kj0rv.js +2 -0
  34. package/examples/dist/index-3x197sbt.js +9 -0
  35. package/examples/dist/index-a2hkfx1n.js +9 -0
  36. package/examples/dist/index-d21me1mc.js +9 -0
  37. package/examples/dist/index-ktqdknsn.js +2 -0
  38. package/examples/dist/index-p53qxxzd.js +2 -0
  39. package/examples/dist/index.html +67 -0
  40. package/examples/routes.gen.ts +66 -86
  41. package/examples/routes.ts +2 -2
  42. package/examples/server/serve-dist.ts +33 -0
  43. package/examples/server/tsconfig.json +9 -0
  44. package/package.json +11 -6
  45. package/src/components/Link.tsx +8 -6
  46. package/src/components/Router.test.tsx +183 -0
  47. package/src/components/Router.tsx +161 -29
  48. package/src/lib/routes.ts +2 -0
  49. package/tsconfig.json +3 -2
  50. package/tsdown.config.ts +3 -4
  51. package/dist/hooks-Dlwcb0sV.js +0 -20
  52. package/dist/hooks.d.ts +0 -2
  53. package/dist/hooks.js +0 -2
  54. package/dist/index-BYXpNitc.d.ts +0 -5
  55. /package/{src → cli}/fixtures/bin/kitchen-sink.tsx +0 -0
  56. /package/{src → cli}/fixtures/bin/optional.tsx +0 -0
  57. /package/{src → cli}/fixtures/bin/pages/Home.tsx +0 -0
  58. /package/{src → cli}/fixtures/bin/pages/KitchenSink.tsx +0 -0
  59. /package/{src → cli}/fixtures/bin/pages/Login.tsx +0 -0
  60. /package/{src → cli}/fixtures/bin/pages/Match.tsx +0 -0
  61. /package/{src → cli}/fixtures/bin/pages/NotFound.tsx +0 -0
  62. /package/{src → cli}/fixtures/bin/pages/Optional.tsx +0 -0
  63. /package/{src → cli}/fixtures/bin/regexp-groups.tsx +0 -0
  64. /package/{src → cli}/fixtures/bin/simple.tsx +0 -0
  65. /package/{src → cli}/fixtures/bin/unnamed.tsx +0 -0
  66. /package/dist/{routes-Hpf6cwcZ.js → routes-PW-bNm8e.js} +0 -0
package/examples/App.tsx CHANGED
@@ -1,9 +1,13 @@
1
1
  import { StrictMode } from 'react'
2
2
  import { createRoot } from 'react-dom/client'
3
- import { NavLink, Router, useUrlPath } from '../src'
3
+ import { NavLink, type NavLinkProps, Router, useUrlPath } from '../src'
4
4
  import routes from './routes'
5
5
  import * as routesGen from './routes.gen'
6
6
 
7
+ function PillNavLink(props: Omit<NavLinkProps, 'activeClass' | 'className' | 'match'>) {
8
+ return <NavLink activeClass="active" className="pill" match="prefix" {...props} />
9
+ }
10
+
7
11
  function CurrentPath() {
8
12
  const path = useUrlPath()
9
13
  return (
@@ -23,54 +27,19 @@ function CurrentPath() {
23
27
  </div>
24
28
  </div>
25
29
  <div className="nav">
26
- <NavLink activeClass="active" className="pill" to={routesGen.home()}>
27
- Home
28
- </NavLink>
29
- <NavLink activeClass="active" className="pill" to={routesGen.login()}>
30
- Login
31
- </NavLink>
32
- <NavLink
33
- activeClass="active"
34
- className="pill"
35
- to={routesGen.match({ id: '123' })}
36
- >
37
- Match 123
38
- </NavLink>
39
- <NavLink
40
- activeClass="active"
41
- className="pill"
42
- to={routesGen.match({ id: 'a/b' })}
43
- >
30
+ <PillNavLink to={routesGen.home()}>Home</PillNavLink>
31
+ <PillNavLink to={routesGen.login()}>Login</PillNavLink>
32
+ <PillNavLink to={routesGen.match({ id: '123' })}>Match 123</PillNavLink>
33
+ <PillNavLink to={routesGen.match({ id: 'a/b' })}>
44
34
  Match a/b (encoded)
45
- </NavLink>
46
- <NavLink
47
- activeClass="active"
48
- className="pill"
49
- to={routesGen.blogPost({ id: 123 })}
50
- >
51
- Blog 123
52
- </NavLink>
53
- <NavLink
54
- activeClass="active"
55
- className="pill"
56
- to={routesGen.blogPost({ id: 123, title: 'hello world' })}
57
- >
35
+ </PillNavLink>
36
+ <PillNavLink to={routesGen.blogPost({ id: 123 })}>Blog 123</PillNavLink>
37
+ <PillNavLink to={routesGen.blogPost({ id: 123, title: 'hello world' })}>
58
38
  Blog 123 Title
59
- </NavLink>
60
- <NavLink activeClass="active" className="pill" to={routesGen.slowLoading()}>
61
- Slow Loading
62
- </NavLink>
63
- <NavLink
64
- activeClass="active"
65
- className="pill"
66
- match="prefix"
67
- to={routesGen.fetchLoading()}
68
- >
69
- Fetch Loading
70
- </NavLink>
71
- <NavLink
72
- activeClass="active"
73
- className="pill"
39
+ </PillNavLink>
40
+ <PillNavLink to={routesGen.slowLoading()}>Slow Loading</PillNavLink>
41
+ <PillNavLink to={routesGen.fetchLoading()}>Fetch Loading</PillNavLink>
42
+ <PillNavLink
74
43
  to={routesGen.kitchenSink({
75
44
  foo: 'a/b',
76
45
  baz: 'c',
@@ -78,7 +47,7 @@ function CurrentPath() {
78
47
  })}
79
48
  >
80
49
  KitchenSink
81
- </NavLink>
50
+ </PillNavLink>
82
51
  </div>
83
52
  </div>
84
53
  </div>
@@ -91,7 +60,7 @@ function Layout() {
91
60
  <div className="card">
92
61
  <h1 style={{ margin: 0 }}>rerouter examples</h1>
93
62
  <div style={{ opacity: 0.8, marginTop: 8 }}>
94
- Client-only dev server using <code>bun --hot examples/index.html</code>.
63
+ Client-only production build served from <code>examples/dist</code>.
95
64
  </div>
96
65
  </div>
97
66
 
@@ -0,0 +1 @@
1
+ import{v as o}from"./index-p53qxxzd.js";var e=({id:t,title:i})=>{return o("div",{children:[o("div",{children:["Blog post: ",t]}),o("div",{children:["Title: ",i]})]})},r=e;export{r as default};
@@ -0,0 +1 @@
1
+ import{c as n,e as s,g as m,h as c,n as l}from"./index-0d4kj0rv.js";import{u as t,v as i}from"./index-p53qxxzd.js";s();s();var r=new Map;function g(e){let o=r.get(e);if(!o)o=new Promise((a)=>{setTimeout(()=>{a({id:e,message:`Fetched fake data for item ${e}.`,loadedAt:new Date().toLocaleTimeString()})},2000)}),r.set(e,o);return o}function d({id:e}){let o=n(g(e));return i("div",{children:[t("h2",{style:{marginTop:0},children:"Fetch loading item"}),i("div",{children:["URL param: ",t("code",{children:o.id})]}),t("div",{style:{marginTop:8},children:o.message}),i("div",{style:{marginTop:8,opacity:0.8},children:["Loaded at ",o.loadedAt]})]})}var p=[{pattern:"/fetch-loading/:id",component:async()=>({default:d})}],u=new Promise((e)=>{setTimeout(()=>{e({message:"The route component loaded immediately, then Suspense waited for data.",loadedAt:new Date().toLocaleTimeString()})},2000)});function h(){let e=n(u),o=["abc-123","invoice-456","with/slash"];return i("div",{children:[t("h2",{style:{marginTop:0},children:"Fetch loading page"}),t("div",{children:e.message}),i("div",{style:{marginTop:8,opacity:0.8},children:["Loaded at ",e.loadedAt]}),t("div",{className:"nav",style:{marginTop:16},children:o.map((a)=>i(m,{activeClass:"active",className:"pill",to:l({id:a}),children:["Fetch ",a]},a))}),t("div",{style:{marginTop:16},children:t(c,{routes:p,loading:t("div",{children:"Loading item..."})})})]})}export{h as default};
@@ -0,0 +1 @@
1
+ import{c as n,e as s,g as m,h as c,n as l}from"./index-ktqdknsn.js";import{u as t,v as i}from"./index-p53qxxzd.js";s();s();var r=new Map;function g(e){let o=r.get(e);if(!o)o=new Promise((a)=>{setTimeout(()=>{a({id:e,message:`Fetched fake data for item ${e}.`,loadedAt:new Date().toLocaleTimeString()})},2000)}),r.set(e,o);return o}function d({id:e}){let o=n(g(e));return i("div",{children:[t("h2",{style:{marginTop:0},children:"Fetch loading item"}),i("div",{children:["URL param: ",t("code",{children:o.id})]}),t("div",{style:{marginTop:8},children:o.message}),i("div",{style:{marginTop:8,opacity:0.8},children:["Loaded at ",o.loadedAt]})]})}var p=[{pattern:"/fetch-loading/:id",component:async()=>({default:d})}],u=new Promise((e)=>{setTimeout(()=>{e({message:"The route component loaded immediately, then Suspense waited for data.",loadedAt:new Date().toLocaleTimeString()})},2000)});function h(){let e=n(u),o=["abc-123","invoice-456","with/slash"];return i("div",{children:[t("h2",{style:{marginTop:0},children:"Fetch loading page"}),t("div",{children:e.message}),i("div",{style:{marginTop:8,opacity:0.8},children:["Loaded at ",e.loadedAt]}),t("div",{className:"nav",style:{marginTop:16},children:o.map((a)=>i(m,{activeClass:"active",className:"pill",to:l({id:a}),children:["Fetch ",a]},a))}),t("div",{style:{marginTop:16},children:t(c,{routes:p,loading:t("div",{children:"Loading item..."})})})]})}export{h as default};
@@ -0,0 +1 @@
1
+ import{u as o}from"./index-p53qxxzd.js";function d(){return o("div",{children:"Home"})}export{d as default};
@@ -0,0 +1 @@
1
+ import{v as i}from"./index-p53qxxzd.js";var r=({foo:t,baz:o,splat:n,optional:d,two:v})=>{return i("div",{children:[i("div",{children:["foo: ",t]}),i("div",{children:["baz: ",o]}),i("div",{children:["splat: ",n]}),i("div",{children:["optional: ",d]}),i("div",{children:["two: ",v]})]})},e=r;export{e as default};
@@ -0,0 +1 @@
1
+ import{u as i}from"./index-p53qxxzd.js";function n(){return i("div",{children:"Login"})}export{n as default};
@@ -0,0 +1 @@
1
+ import{v as t}from"./index-p53qxxzd.js";function o({id:a}){return t("div",{children:["Match: ",a]})}export{o as default};
@@ -0,0 +1 @@
1
+ import{u as o}from"./index-p53qxxzd.js";function d(){return o("div",{children:"Not found"})}export{d as default};
@@ -0,0 +1 @@
1
+ import{u as i,v as o}from"./index-p53qxxzd.js";function e(){return o("div",{children:[i("h2",{style:{marginTop:0},children:"Slow loading page"}),i("div",{children:"This page waits 2 seconds before its route component finishes loading."})]})}export{e as default};
@@ -0,0 +1,2 @@
1
+ import{q as Zf,r as bf,s as Ef,u as $}from"./index-p53qxxzd.js";function Y(f,u,r){this.props=f,this.context=u,this.refs=F,this.updater=r||p}function L(){}function D(f,u,r){this.props=f,this.context=u,this.refs=F,this.updater=r||p}function Sf(){}var cf,sf,p,Cf,F,q,A,V,Tf,W,Af,b=function(f){var u=A.T,r={};A.T=r;try{var o=f(),n=A.S;n!==null&&n(r,o),typeof o==="object"&&o!==null&&typeof o.then==="function"&&o.then(Sf,V)}catch(_){V(_)}finally{u!==null&&r.types!==null&&(u.types=r.types),A.T=u}},Rf=function(f){return A.H.use(f)},G=function(f,u){return A.H.useEffect(f,u)},I=function(f,u){return A.H.useMemo(f,u)},U=function(f){return A.H.useState(f)},K=function(f,u,r){return A.H.useSyncExternalStore(f,u,r)},jf="19.2.5";var i=Ef(()=>{cf=Symbol.for("react.strict_mode"),sf=Symbol.for("react.suspense"),p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Cf=Object.assign,F={};Y.prototype.isReactComponent={};Y.prototype.setState=function(f,u){if(typeof f!=="object"&&typeof f!=="function"&&f!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,f,u,"setState")};Y.prototype.forceUpdate=function(f){this.updater.enqueueForceUpdate(this,f,"forceUpdate")};L.prototype=Y.prototype;q=D.prototype=new L;q.constructor=D;Cf(q,Y.prototype);q.isPureReactComponent=!0;A={H:null,A:null,T:null,S:null},V=typeof reportError==="function"?reportError:function(f){if(typeof window==="object"&&typeof window.ErrorEvent==="function"){var u=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof f==="object"&&f!==null&&typeof f.message==="string"?String(f.message):String(f),error:f});if(!window.dispatchEvent(u))return}else if(typeof process==="object"&&typeof process.emit==="function"){process.emit("uncaughtException",f);return}console.error(f)};Tf=cf,W=sf,Af=A});var nf=bf((rf)=>{Object.defineProperty(rf,"__esModule",{value:!0});rf.PathError=rf.TokenData=void 0;rf.parse=X;rf.compile=tf;rf.match=qf;rf.pathToRegexp=ff;rf.stringify=Gf;var Q="/",P=(f)=>f,Yf=/^[$_\p{ID_Start}]$/u,m=/^[$\u200c\u200d\p{ID_Continue}]$/u,If=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u;function Uf(f){return f.replace(/[{}()\[\]+?!:*\\]/g,"\\$&")}function R(f){return f.replace(/[.+*?^${}()[\]|/\\]/g,"\\$&")}class J{constructor(f,u){this.tokens=f,this.originalPath=u}}rf.TokenData=J;class j extends TypeError{constructor(f,u){let r=f;if(u)r+=`: ${u}`;r+="; visit https://git.new/pathToRegexpError for info";super(r);this.originalPath=u}}rf.PathError=j;function X(f,u={}){let{encodePath:r=P}=u,o=[...f],n=0;function _(y){let E=[],w="";function c(){if(!w)return;E.push({type:"text",value:r(w)}),w=""}while(n<o.length){let s=o[n++];if(s===y)return c(),E;if(s==="\\"){if(n===o.length)throw new j(`Unexpected end after \\ at index ${n}`,f);w+=o[n++];continue}if(s===":"||s==="*"){let S=s===":"?"param":"wildcard",C="";if(Yf.test(o[n]))do C+=o[n++];while(m.test(o[n]));else if(o[n]==='"'){let T=n;while(n<o.length){if(o[++n]==='"'){n++,T=0;break}if(o[n]==="\\")n++;C+=o[n]}if(T)throw new j(`Unterminated quote at index ${T}`,f)}if(!C)throw new j(`Missing parameter name at index ${n}`,f);c(),E.push({type:S,name:C});continue}if(s==="{"){c(),E.push({type:"group",tokens:_("}")});continue}if(s==="}"||s==="("||s===")"||s==="["||s==="]"||s==="+"||s==="?"||s==="!")throw new j(`Unexpected ${s} at index ${n-1}`,f);w+=s}if(y)throw new j(`Unexpected end at index ${n}, expected ${y}`,f);return c(),E}return new J(_(""),f)}function tf(f,u={}){let{encode:r=encodeURIComponent,delimiter:o=Q}=u,n=typeof f==="object"?f:X(f,u),_=a(n.tokens,o,r);return function(E={}){let w=[],c=_(E,w);if(w.length)throw TypeError(`Missing parameters: ${w.join(", ")}`);return c}}function a(f,u,r){let o=f.map((n)=>Mf(n,u,r));return(n,_)=>{let y="";for(let E of o)y+=E(n,_);return y}}function Mf(f,u,r){if(f.type==="text")return()=>f.value;if(f.type==="group"){let n=a(f.tokens,u,r);return(_,y)=>{let E=y.length,w=n(_,y);if(y.length===E)return w;return y.length=E,""}}let o=r||P;if(f.type==="wildcard"&&r!==!1)return(n,_)=>{let y=n[f.name];if(y==null)return _.push(f.name),"";if(!Array.isArray(y)||y.length===0)throw TypeError(`Expected "${f.name}" to be a non-empty array`);let E="";for(let w=0;w<y.length;w++){if(typeof y[w]!=="string")throw TypeError(`Expected "${f.name}/${w}" to be a string`);if(w>0)E+=u;E+=o(y[w])}return E};return(n,_)=>{let y=n[f.name];if(y==null)return _.push(f.name),"";if(typeof y!=="string")throw TypeError(`Expected "${f.name}" to be a string`);return o(y)}}function qf(f,u={}){let{decode:r=decodeURIComponent,delimiter:o=Q}=u,{regexp:n,keys:_}=ff(f,u),y=_.map((E)=>{if(r===!1)return P;if(E.type==="param")return r;return(w)=>w.split(o).map(r)});return function(w){let c=n.exec(w);if(!c)return!1;let s=c[0],S=Object.create(null);for(let C=1;C<c.length;C++){if(c[C]===void 0)continue;let T=_[C-1],H=y[C-1];S[T.name]=H(c[C])}return{path:s,params:S}}}function ff(f,u={}){let{delimiter:r=Q,end:o=!0,sensitive:n=!1,trailing:_=!0}=u,y=[],E="",w=0;function c(S){if(Array.isArray(S)){for(let T of S)c(T);return}let C=typeof S==="object"?S:X(S,u);N(C.tokens,0,[],(T)=>{if(w>=256)throw new j("Too many path combinations",C.originalPath);if(w>0)E+="|";E+=Wf(T,r,y,C.originalPath),w++})}c(f);let s=`^(?:${E})`;if(_)s+="(?:"+R(r)+"$)?";return s+=o?"$":"(?="+R(r)+"|$)",{regexp:new RegExp(s,n?"":"i"),keys:y}}function N(f,u,r,o){while(u<f.length){let n=f[u++];if(n.type==="group"){let _=r.length;N(n.tokens,0,r,(y)=>N(f,u,y,o)),r.length=_;continue}r.push(n)}o(r)}function Wf(f,u,r,o){let n="",_="",y="",E=0,w=0,c=0;function s(C,T){while(C<f.length){let H=f[C++];if(H.type===T)return!0;if(H.type==="text"){if(H.value.includes(u))break}}return!1}function S(C){let T="";while(C<f.length){let H=f[C++];if(H.type!=="text")break;T+=H.value}return T}while(c<f.length){let C=f[c++];if(C.type==="text"){if(n+=R(C.value),_+=C.value,E===2)y+=C.value;if(C.value.includes(u))w=0;continue}if(C.type==="param"||C.type==="wildcard"){if(E&&!_)throw new j(`Missing text before "${C.name}" ${C.type}`,o);if(C.type==="param")n+=w&2?`(${O(u,_)}+)`:s(c,"wildcard")?`(${O(u,S(c))}+)`:w&1?`(${O(u,_)}+|${R(_)})`:`(${O(u,"")}+)`,w|=E=1;else n+=w&2?`(${O(_,"")}+)`:y?`(${O(y,"")}+|${O(u,"")}+)`:"([^]+)",y="",w|=E=2;r.push(C),_="";continue}throw TypeError(`Unknown token type: ${C.type}`)}return n}function O(f,u){if(u.length>f.length)return O(u,f);if(f===u)u="";if(u.length>1)return`(?:(?!${R(f)}|${R(u)})[^])`;if(f.length>1)return`(?:(?!${R(f)})[^${R(u)}])`;return`[^${R(f+u)}]`}function uf(f,u){let r="";while(u<f.length){let o=f[u++];if(o.type==="text"){r+=Uf(o.value);continue}if(o.type==="group"){r+="{"+uf(o.tokens,0)+"}";continue}if(o.type==="param"){r+=":"+k(o.name,f[u]);continue}if(o.type==="wildcard"){r+="*"+k(o.name,f[u]);continue}throw TypeError(`Unknown token type: ${o.type}`)}return r}function Gf(f){return uf(f.tokens,0)}function k(f,u){if(!If.test(f))return JSON.stringify(f);if((u===null||u===void 0?void 0:u.type)==="text"&&m.test(u.value[0]))return JSON.stringify(f);return f}});function g(f,u){if(typeof u==="string")return u===""?f:f+(f&&" ")+u;if(typeof u==="number")return f+(f&&" ")+u;if(u==null||typeof u==="boolean")return f;if(Array.isArray(u)){for(let r=0;r<u.length;++r)f=g(f,u[r]);return f}for(let r in u){if(!Object.hasOwn(u,r))continue;if(u[r])f+=(f&&" ")+r}return f}function Hf(f){let u="";for(let r=0;r<f.length;++r)u=g(u,f[r]);return u}function M(...f){return Hf(f)}i();var v=()=>window.location.pathname;function Of(f){let u=()=>f();return window.addEventListener("popstate",u),()=>{window.removeEventListener("popstate",u)}}function t(){return K(Of,v,v)}i();function l(f,u){window.history.pushState(u,"",f),window.dispatchEvent(new PopStateEvent("popstate"))}function h(f,u){window.history.replaceState(u,"",f),window.dispatchEvent(new PopStateEvent("popstate"))}function d(f,u){let r=f.indexOf("#"),o=r!==-1?f.slice(r):"",n=r!==-1?f.slice(0,r):f,_=n.indexOf("?"),y=_!==-1?n.slice(0,_):n,E=_!==-1?n.slice(_+1):"",w=new URLSearchParams(E),c=new URLSearchParams(u);for(let[S,C]of c)w.set(S,C);let s=w.toString();return`${y}${s?"?"+s:""}${o}`}function e({to:f,search:u,children:r,className:o,replace:n,..._}){let y=u?d(f,u):f,E=M(o);return $("a",{..._,className:E||void 0,href:y,onClick:(c)=>{if(c.metaKey||c.ctrlKey||c.shiftKey||c.altKey)return;if(c.button!==0)return;c.preventDefault(),b(()=>{if(n)h(y);else l(y)})},children:r})}function $f(f,u,r){if(f===u)return!0;if(r==="exact")return!1;if(u==="/")return!1;return f.startsWith(`${u}/`)}function yu({activeClass:f,className:u,inactiveClass:r,match:o="exact",to:n,..._}){let y=t(),E=new URL(n,window.location.href),w=$f(y,E.pathname,o),c=M(u,w?f:r);return $(e,{..._,className:c||void 0,to:n})}i();var Z=Zf(nf(),1);function yf(f){if(typeof f!=="string")return f;return new URLPattern({pathname:f})}function xf(f){let u={};for(let[r,o]of Object.entries(f))if(o==null)u[r]=void 0;else u[r]=decodeURIComponent(String(o));return u}function Bf(f,u){let r=1,o=u+1;while(o<f.length&&r>0){let n=f[o];if(n==="\\"){o+=2;continue}if(n==="(")r++;else if(n===")")r--;o++}return o}function zf(f){let u="";for(let r=0;r<f.length;r++){let o=f[r];if(o==="\\"){if(u+=o,r+1<f.length)u+=f[++r];continue}if(o===":"||o==="*"){u+=o;while(r+1<f.length&&/[$_\p{ID_Continue}]/u.test(f[r+1]))u+=f[++r];if(f[r+1]==="(")r=Bf(f,r+1)-1;continue}if(o==="}"&&f[r+1]==="?"){u+=o,r++;continue}u+=o}return u}function _f(f){return f.map((u)=>{let{name:r,pattern:o,component:n}=u;if(typeof o!=="string"){let E=yf(o);return{name:r,pattern:o,component:n,matches(w){let c=E.exec({pathname:w});if(!c)return null;return c.pathname?.groups??{}}}}if(o==="*"||o==="/*")return{name:r,pattern:o,component:n,matches:(E)=>({})};let _,y;try{_=Z.match(o,{decode:decodeURIComponent})}catch{try{y=yf(o)}catch{_=Z.match(zf(o),{decode:decodeURIComponent})}}return{name:r,pattern:o,component:n,matches(E){if(y){let s=y.exec({pathname:E});if(!s)return null;return xf(s.pathname?.groups??{})}if(!_)return null;let w=_(E);if(!w)return null;let c={};for(let[s,S]of Object.entries(w.params))if(S==null)c[s]=void 0;else if(Array.isArray(S))c[s]=S.join("/");else c[s]=String(S);return c}}})}var Vf=400,z=new WeakMap,x=new WeakMap;function pf(f){let u=z.get(f);if(u)return Promise.resolve(u);let r=x.get(f);if(!r)r=f().then((o)=>{return z.set(f,o.default),x.delete(f),o.default}),x.set(f,r);return r}function Ff(f,u){for(let r of f){let o=r.matches(u);if(!o)continue;return{route:r,params:o,pathname:u}}return null}function wf(f){if(!f)return null;let u=z.get(f.route.component);if(!u)return null;return{...f,Component:u}}function B(f){queueMicrotask(()=>{b(f)})}function Lf(f,u){let[r,o]=U(()=>wf(f)),[n,_]=U(!1),[y,E]=U(null);if(G(()=>{if(!f){B(()=>{o(null),_(!1),E(null)});return}let w=wf(f);if(w){B(()=>{o(w),_(!1),E(null)});return}let c=!0,s;if(B(()=>{_(!1)}),u<=0)s=setTimeout(()=>{if(c)_(!0)},0);else s=setTimeout(()=>{if(c)_(!0)},u);return pf(f.route.component).then((S)=>{if(!c)return;if(s)clearTimeout(s);b(()=>{o({...f,Component:S}),_(!1),E(null)})}).catch((S)=>{if(!c)return;E(S)}),()=>{if(c=!1,s)clearTimeout(s)}},[u,f]),y)throw y;return{renderedRoute:r,showLoading:n}}function ju({routes:f,loading:u=null,loadingDelayMs:r=Vf}){let o=t(),n=I(()=>_f(f),[f]),_=I(()=>Ff(n,o),[n,o]),{renderedRoute:y,showLoading:E}=Lf(_,r);if(E)return u;if(!y)return null;let{Component:w,params:c}=y;return $(W,{fallback:u,children:$(w,{...c})})}function Mu(){let f="";return f+="/",f}function qu(f){let u="";if(f.foo==null)throw Error("Missing param: foo");if(f.baz==null)throw Error("Missing param: baz");if(f.splat==null)throw Error("Missing param: splat");if(u+="/hello/",u+=encodeURIComponent(String(f.foo)),u+="/bar/",u+=encodeURIComponent(String(f.baz)),u+="/",u+=Array.from(f.splat,(r)=>encodeURIComponent(String(r))).join("/"),u+="/xxx",f.optional!=null&&f.two!=null)u+="/",u+=encodeURIComponent(String(f.optional)),u+="/lol/",u+=encodeURIComponent(String(f.two));else if(!(f.optional==null&&f.two==null))throw Error('Group requires all-or-none: "optional", "two"');return u}function Wu(f){let u="";if(f.id==null)throw Error("Missing param: id");if(u+="/blog/",u+=encodeURIComponent(String(f.id)),f.title!=null)u+="-",u+=encodeURIComponent(String(f.title));else if(f.title!=null)throw Error('Group requires all-or-none: "title"');return u}function Gu(){let f="";return f+="/slow-loading",f}function Ku(){let f="";return f+="/fetch-loading",f}function Nu(f){let u="";if(f.id==null)throw Error("Missing param: id");return u+="/fetch-loading/",u+=encodeURIComponent(String(f.id)),u}function Qu(){let f="";return f+="/login",f}function Pu(f){let u="";if(f.id==null)throw Error("Missing param: id");return u+="/matches/",u+=encodeURIComponent(String(f.id)),u}
2
+ export{Tf as a,Af as b,Rf as c,jf as d,i as e,t as f,yu as g,ju as h,Mu as i,qu as j,Wu as k,Gu as l,Ku as m,Nu as n,Qu as o,Pu as p};