@argon-router/core 0.3.0 → 0.3.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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("effector"),oe=require("patronum");function B(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function I(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?B(Object(r),!0).forEach(function(n){ie(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):B(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ie(e,t,r){return(t=ce(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ce(e){var t=fe(e,"string");return typeof t=="symbol"?t:t+""}function fe(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ue(e){let t;const r=c.createEffect(()=>{var p;return(p=t)===null||p===void 0?void 0:p()},{name:"waitForAsyncBundleFx",sid:"tw7mq7"}),n=c.createEffect(async()=>{for(const $ of(p=e.beforeOpen)!==null&&p!==void 0?p:[]){var p;await $()}},{name:"beforeOpenFx",sid:"ls74w9"}),a=c.createEffect(async p=>{await r(),await n();const $=e.parent;return $&&await $.internal.openFx(I(I({},p??{params:{}}),{},{historyIgnore:!0})),p},{name:"openFx",sid:"-hz9h5i"}),s=c.createStore({},{name:"$params",sid:"gwsfoy"}),o=c.createStore(!1,{name:"$isOpened",sid:"ym3mgh"}),i=a.pending,f=c.createEvent({name:"open",sid:"-da1fdx"}),l=c.createEvent({name:"close",sid:"6wt8sn"}),y=c.createEvent({name:"opened",sid:"36opn9"}),g=c.createEvent({name:"openedOnServer",sid:"-qpnfqf"}),b=c.createEvent({name:"openedOnClient",sid:"-qs3xog"}),x=c.createEvent({name:"closed",sid:"2gopr"});return c.sample({and:[{clock:f,target:a}],or:{sid:"t6sc35"}}),c.split({and:[{source:a.doneData,match:()=>typeof window>"u"?"server":"client",cases:{server:g,client:b}}],or:{sid:"t9jb1y"}}),c.sample({and:[{clock:[b,g],target:y}],or:{sid:"tqkxg5"}}),c.sample({and:[{clock:y,fn:()=>!0,target:o}],or:{sid:"u4vkvj"}}),c.sample({and:[{clock:l,target:x}],or:{sid:"u86cfp"}}),c.sample({and:[{clock:x,fn:()=>!1,target:o}],or:{sid:"ylqojg"}}),{$params:s,$isOpened:o,$isPending:i,open:f,closed:x,opened:y,openedOnClient:b,openedOnServer:g,internal:I({close:l,openFx:a,setAsyncImport:p=>t=p},e),"@@unitShape":()=>({params:s,isPending:i,isOpened:o,onOpen:f})}}var O={};Object.defineProperty(O,"__esModule",{value:!0});O.TokenData=void 0;O.parse=_;var le=O.compile=he,de=O.match=we;O.pathToRegexp=G;O.stringify=Se;const T="/",D=e=>e,Q=/^[$_\p{ID_Start}]$/u,U=/^[$\u200c\u200d\p{ID_Continue}]$/u,v="https://git.new/pathToRegexpError",pe={"{":"{","}":"}","(":"(",")":")","[":"[","]":"]","+":"+","?":"?","!":"!"};function me(e){return e.replace(/[{}()\[\]+?!:*]/g,"\\$&")}function F(e){return e.replace(/[.+*?^${}()[\]|/\\]/g,"\\$&")}function*ye(e){const t=[...e];let r=0;function n(){let a="";if(Q.test(t[++r]))for(a+=t[r];U.test(t[++r]);)a+=t[r];else if(t[r]==='"'){let s=r;for(;r<t.length;){if(t[++r]==='"'){r++,s=0;break}t[r]==="\\"?a+=t[++r]:a+=t[r]}if(s)throw new TypeError(`Unterminated quote at ${s}: ${v}`)}if(!a)throw new TypeError(`Missing parameter name at ${r}: ${v}`);return a}for(;r<t.length;){const a=t[r],s=pe[a];if(s)yield{type:s,index:r++,value:a};else if(a==="\\")yield{type:"ESCAPED",index:r++,value:t[r++]};else if(a===":"){const o=n();yield{type:"PARAM",index:r,value:o}}else if(a==="*"){const o=n();yield{type:"WILDCARD",index:r,value:o}}else yield{type:"CHAR",index:r,value:t[r++]}}return{type:"END",index:r,value:""}}class ge{constructor(t){this.tokens=t}peek(){if(!this._peek){const t=this.tokens.next();this._peek=t.value}return this._peek}tryConsume(t){const r=this.peek();if(r.type===t)return this._peek=void 0,r.value}consume(t){const r=this.tryConsume(t);if(r!==void 0)return r;const{type:n,index:a}=this.peek();throw new TypeError(`Unexpected ${n} at ${a}, expected ${t}: ${v}`)}text(){let t="",r;for(;r=this.tryConsume("CHAR")||this.tryConsume("ESCAPED");)t+=r;return t}}class N{constructor(t){this.tokens=t}}O.TokenData=N;function _(e,t={}){const{encodePath:r=D}=t,n=new ge(ye(e));function a(o){const i=[];for(;;){const f=n.text();f&&i.push({type:"text",value:r(f)});const l=n.tryConsume("PARAM");if(l){i.push({type:"param",name:l});continue}const y=n.tryConsume("WILDCARD");if(y){i.push({type:"wildcard",name:y});continue}if(n.tryConsume("{")){i.push({type:"group",tokens:a("}")});continue}return n.consume(o),i}}const s=a("END");return new N(s)}function he(e,t={}){const{encode:r=encodeURIComponent,delimiter:n=T}=t,a=e instanceof N?e:_(e,t),s=W(a.tokens,n,r);return function(i={}){const[f,...l]=s(i);if(l.length)throw new TypeError(`Missing parameters: ${l.join(", ")}`);return f}}function W(e,t,r){const n=e.map(a=>be(a,t,r));return a=>{const s=[""];for(const o of n){const[i,...f]=o(a);s[0]+=i,s.push(...f)}return s}}function be(e,t,r){if(e.type==="text")return()=>[e.value];if(e.type==="group"){const a=W(e.tokens,t,r);return s=>{const[o,...i]=a(s);return i.length?[""]:[o]}}const n=r||D;return e.type==="wildcard"&&r!==!1?a=>{const s=a[e.name];if(s==null)return["",e.name];if(!Array.isArray(s)||s.length===0)throw new TypeError(`Expected "${e.name}" to be a non-empty array`);return[s.map((o,i)=>{if(typeof o!="string")throw new TypeError(`Expected "${e.name}/${i}" to be a string`);return n(o)}).join(t)]}:a=>{const s=a[e.name];if(s==null)return["",e.name];if(typeof s!="string")throw new TypeError(`Expected "${e.name}" to be a string`);return[n(s)]}}function we(e,t={}){const{decode:r=decodeURIComponent,delimiter:n=T}=t,{regexp:a,keys:s}=G(e,t),o=s.map(i=>r===!1?D:i.type==="param"?r:f=>f.split(n).map(r));return function(f){const l=a.exec(f);if(!l)return!1;const y=l[0],g=Object.create(null);for(let b=1;b<l.length;b++){if(l[b]===void 0)continue;const x=s[b-1],p=o[b-1];g[x.name]=p(l[b])}return{path:y,params:g}}}function G(e,t={}){const{delimiter:r=T,end:n=!0,sensitive:a=!1,trailing:s=!0}=t,o=[],i=[],f=a?"":"i",y=(Array.isArray(e)?e:[e]).map(x=>x instanceof N?x:_(x,t));for(const{tokens:x}of y)for(const p of A(x,0,[])){const $=xe(p,r,o);i.push($)}let g=`^(?:${i.join("|")})`;return s&&(g+=`(?:${F(r)}$)?`),g+=n?"$":`(?=${F(r)}|$)`,{regexp:new RegExp(g,f),keys:o}}function*A(e,t,r){if(t===e.length)return yield r;const n=e[t];if(n.type==="group"){const a=r.slice();for(const s of A(n.tokens,0,a))yield*A(e,t+1,s)}else r.push(n);yield*A(e,t+1,r)}function xe(e,t,r){let n="",a="",s=!0;for(let o=0;o<e.length;o++){const i=e[o];if(i.type==="text"){n+=F(i.value),a+=i.value,s||(s=i.value.includes(t));continue}if(i.type==="param"||i.type==="wildcard"){if(!s&&!a)throw new TypeError(`Missing text after "${i.name}": ${v}`);i.type==="param"?n+=`(${Fe(t,s?"":a)}+)`:n+="([\\s\\S]+)",r.push(i),a="",s=!1;continue}}return n}function Fe(e,t){return t.length<2?e.length<2?`[^${F(e+t)}]`:`(?:(?!${F(e)})[^${F(t)}])`:e.length<2?`(?:(?!${F(t)})[^${F(e)}])`:`(?:(?!${F(t)}|${F(e)})[\\s\\S])`}function Se(e){return e.tokens.map(function t(r,n,a){if(r.type==="text")return me(r.value);if(r.type==="group")return`{${r.tokens.map(t).join("")}}`;const o=Ee(r.name)&&$e(a[n+1])?r.name:JSON.stringify(r.name);if(r.type==="param")return`:${o}`;if(r.type==="wildcard")return`*${o}`;throw new TypeError(`Unexpected token: ${r}`)}).join("")}function Ee(e){const[t,...r]=e;return Q.test(t)?r.every(n=>U.test(n)):!1}function $e(e){return(e==null?void 0:e.type)!=="text"?!0:!U.test(e.value[0])}const Oe=Symbol("any"),je=Symbol("number"),Ae=Symbol("string"),ve=Symbol("array"),E={any:Oe,number:je,string:Ae,array:ve};function H(e,t){for(const r of e)if(!t.includes(r))return!1;return!0}function V(e,t){for(const r in t){const n=t[r];if(Array.isArray(n)&&(!e[r]||JSON.stringify(n)!==e[r]))return!1;switch(typeof n){case"number":{if(!e[r]||n.toString()!==e[r])return!1;break}case"object":{if(!e[r]||JSON.stringify(n)!==e[r])return!1;break}case"string":{if(!e[r]||n!==e[r])return!1;break}case"boolean":{if(!e[r]||!["0","1","false","true"].includes(e[r]))return!1;break}}switch(n){case E.any:{if(!e[r])return!1;break}case E.string:{if(!e[r]||Array.isArray(e[r]))return!1;break}case E.array:{if(!e[r]||!Array.isArray(e[r]))return!1;break}case E.number:{if(!e[r]||Array.isArray(e[r])||isNaN(parseInt(e[r]))&&isNaN(parseFloat(e[r])))return!1;break}}}return!0}function Ne(e,t){const r={};for(const n in t){const a=t[n],s=e[n];if(Array.isArray(a)){r[n]=s==="1"||s==="true";continue}switch(typeof a){case"number":{const o=e[n];r[n]=isNaN(parseInt(o))?parseFloat(o):parseInt(o);break}case"object":{r[n]=JSON.parse(s);break}case"string":r[n]=e[n];case"boolean":{const o=e[n];r[n]=o==="0"?parseFloat(o):parseInt(o);break}}switch(a){case E.any:case E.string:case E.array:{r[n]=e[n];break}case E.number:{const o=e[n];r[n]=isNaN(parseInt(o))?parseFloat(o):parseInt(o);break}}}return r}function Re(e,t){return r=>{const{parameters:n,forRoutes:a}=r,s=c.createEvent({name:"entered",sid:"-d3obu6"}),o=c.createEvent({name:"exited",sid:"-xofyk3"}),i=c.createEvent({name:"exit",sid:"-673d76"});return c.sample({and:[{source:{activeRoutes:e,query:t},filter:f=>{let{activeRoutes:l,query:y}=f;return(!a||H(a,l))&&V(y,n)},fn:f=>{let{query:l}=f;return Ne(l,n)}}],or:{sid:"-so0f9q"}}),c.sample({and:[{source:{activeRoutes:e,query:t},filter:f=>{let{activeRoutes:l,query:y}=f;return!((!a||H(a,l))&&V(y,n))},target:o}],or:{sid:"-s82e29"}}),{entered:s,exited:o,exit:i,getPayload:f=>Object.entries(f).reduce((l,y)=>{let[g,b]=y;return typeof n[g]=="symbol"?l[g]=b:l[g]=n[g],l},{})}}}const X="%[a-f0-9]{2}",z=new RegExp("("+X+")|([^%]+?)","gi"),K=new RegExp("("+X+")+","gi");function P(e,t){try{return[decodeURIComponent(e.join(""))]}catch{}if(e.length===1)return e;t=t||1;const r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],P(r),P(n))}function Ie(e){try{return decodeURIComponent(e)}catch{let t=e.match(z)||[];for(let r=1;r<t.length;r++)e=P(t,r).join(""),t=e.match(z)||[];return e}}function ke(e){const t={"%FE%FF":"��","%FF%FE":"��"};let r=K.exec(e);for(;r;){try{t[r[0]]=decodeURIComponent(r[0])}catch{const a=Ie(r[0]);a!==r[0]&&(t[r[0]]=a)}r=K.exec(e)}t["%C2"]="�";const n=Object.keys(t);for(const a of n)e=e.replace(new RegExp(a,"g"),t[a]);return e}function Pe(e){if(typeof e!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return ke(e)}}function Ce(e,t){const r={};if(Array.isArray(t))for(const n of t){const a=Object.getOwnPropertyDescriptor(e,n);a!=null&&a.enumerable&&Object.defineProperty(r,n,a)}else for(const n of Reflect.ownKeys(e)){const a=Object.getOwnPropertyDescriptor(e,n);if(a.enumerable){const s=e[n];t(n,s,e)&&Object.defineProperty(r,n,a)}}return r}function Y(e,t){if(!(typeof e=="string"&&typeof t=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e===""||t==="")return[];const r=e.indexOf(t);return r===-1?[]:[e.slice(0,r),e.slice(r+t.length)]}const Te=e=>e==null,De=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),C=Symbol("encodeFragmentIdentifier");function Ue(e){switch(e.arrayFormat){case"index":return t=>(r,n)=>{const a=r.length;return n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?r:n===null?[...r,[m(t,e),"[",a,"]"].join("")]:[...r,[m(t,e),"[",m(a,e),"]=",m(n,e)].join("")]};case"bracket":return t=>(r,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?r:n===null?[...r,[m(t,e),"[]"].join("")]:[...r,[m(t,e),"[]=",m(n,e)].join("")];case"colon-list-separator":return t=>(r,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?r:n===null?[...r,[m(t,e),":list="].join("")]:[...r,[m(t,e),":list=",m(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{const t=e.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(n,a)=>a===void 0||e.skipNull&&a===null||e.skipEmptyString&&a===""?n:(a=a===null?"":a,n.length===0?[[m(r,e),t,m(a,e)].join("")]:[[n,m(a,e)].join(e.arrayFormatSeparator)])}default:return t=>(r,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?r:n===null?[...r,m(t,e)]:[...r,[m(t,e),"=",m(n,e)].join("")]}}function _e(e){let t;switch(e.arrayFormat){case"index":return(r,n,a)=>{if(t=/\[(\d*)]$/.exec(r),r=r.replace(/\[\d*]$/,""),!t){a[r]=n;return}a[r]===void 0&&(a[r]={}),a[r][t[1]]=n};case"bracket":return(r,n,a)=>{if(t=/(\[])$/.exec(r),r=r.replace(/\[]$/,""),!t){a[r]=n;return}if(a[r]===void 0){a[r]=[n];return}a[r]=[...a[r],n]};case"colon-list-separator":return(r,n,a)=>{if(t=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!t){a[r]=n;return}if(a[r]===void 0){a[r]=[n];return}a[r]=[...a[r],n]};case"comma":case"separator":return(r,n,a)=>{const s=typeof n=="string"&&n.includes(e.arrayFormatSeparator),o=typeof n=="string"&&!s&&S(n,e).includes(e.arrayFormatSeparator);n=o?S(n,e):n;const i=s||o?n.split(e.arrayFormatSeparator).map(f=>S(f,e)):n===null?n:S(n,e);a[r]=i};case"bracket-separator":return(r,n,a)=>{const s=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!s){a[r]=n&&S(n,e);return}const o=n===null?[]:S(n,e).split(e.arrayFormatSeparator);if(a[r]===void 0){a[r]=o;return}a[r]=[...a[r],...o]};default:return(r,n,a)=>{if(a[r]===void 0){a[r]=n;return}a[r]=[...[a[r]].flat(),n]}}}function Z(e){if(typeof e!="string"||e.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function m(e,t){return t.encode?t.strict?De(e):encodeURIComponent(e):e}function S(e,t){return t.decode?Pe(e):e}function ee(e){return Array.isArray(e)?e.sort():typeof e=="object"?ee(Object.keys(e)).sort((t,r)=>Number(t)-Number(r)).map(t=>e[t]):e}function re(e){const t=e.indexOf("#");return t!==-1&&(e=e.slice(0,t)),e}function qe(e){let t="";const r=e.indexOf("#");return r!==-1&&(t=e.slice(r)),t}function J(e,t,r){return r==="string"&&typeof e=="string"?e:typeof r=="function"&&typeof e=="string"?r(e):t.parseBooleans&&e!==null&&(e.toLowerCase()==="true"||e.toLowerCase()==="false")?e.toLowerCase()==="true":r==="number"&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""||t.parseNumbers&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""?Number(e):e}function q(e){e=re(e);const t=e.indexOf("?");return t===-1?"":e.slice(t+1)}function M(e,t){t={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...t},Z(t.arrayFormatSeparator);const r=_e(t),n=Object.create(null);if(typeof e!="string"||(e=e.trim().replace(/^[?#&]/,""),!e))return n;for(const a of e.split("&")){if(a==="")continue;const s=t.decode?a.replaceAll("+"," "):a;let[o,i]=Y(s,"=");o===void 0&&(o=s),i=i===void 0?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?i:S(i,t),r(S(o,t),i,n)}for(const[a,s]of Object.entries(n))if(typeof s=="object"&&s!==null&&t.types[a]!=="string")for(const[o,i]of Object.entries(s)){const f=t.types[a]?t.types[a].replace("[]",""):void 0;s[o]=J(i,t,f)}else typeof s=="object"&&s!==null&&t.types[a]==="string"?n[a]=Object.values(s).join(t.arrayFormatSeparator):n[a]=J(s,t,t.types[a]);return t.sort===!1?n:(t.sort===!0?Object.keys(n).sort():Object.keys(n).sort(t.sort)).reduce((a,s)=>{const o=n[s];return a[s]=o&&typeof o=="object"&&!Array.isArray(o)?ee(o):o,a},Object.create(null))}function te(e,t){if(!e)return"";t={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...t},Z(t.arrayFormatSeparator);const r=o=>t.skipNull&&Te(e[o])||t.skipEmptyString&&e[o]==="",n=Ue(t),a={};for(const[o,i]of Object.entries(e))r(o)||(a[o]=i);const s=Object.keys(a);return t.sort!==!1&&s.sort(t.sort),s.map(o=>{const i=e[o];return i===void 0?"":i===null?m(o,t):Array.isArray(i)?i.length===0&&t.arrayFormat==="bracket-separator"?m(o,t)+"[]":i.reduce(n(o),[]).join("&"):m(o,t)+"="+m(i,t)}).filter(o=>o.length>0).join("&")}function ne(e,t){var a;t={decode:!0,...t};let[r,n]=Y(e,"#");return r===void 0&&(r=e),{url:((a=r==null?void 0:r.split("?"))==null?void 0:a[0])??"",query:M(q(e),t),...t&&t.parseFragmentIdentifier&&n?{fragmentIdentifier:S(n,t)}:{}}}function ae(e,t){t={encode:!0,strict:!0,[C]:!0,...t};const r=re(e.url).split("?")[0]||"",n=q(e.url),a={...M(n,{sort:!1}),...e.query};let s=te(a,t);s&&(s=`?${s}`);let o=qe(e.url);if(typeof e.fragmentIdentifier=="string"){const i=new URL(r);i.hash=e.fragmentIdentifier,o=t[C]?i.hash:`#${e.fragmentIdentifier}`}return`${r}${s}${o}`}function se(e,t,r){r={parseFragmentIdentifier:!0,[C]:!1,...r};const{url:n,query:a,fragmentIdentifier:s}=ne(e,r);return ae({url:n,query:Ce(a,t),fragmentIdentifier:s},r)}function Me(e,t,r){const n=Array.isArray(t)?a=>!t.includes(a):(a,s)=>!t(a,s);return se(e,n,r)}const k=Object.freeze(Object.defineProperty({__proto__:null,exclude:Me,extract:q,parse:M,parseUrl:ne,pick:se,stringify:te,stringifyUrl:ae},Symbol.toStringTag,{value:"Module"}));function Le(e){const{base:t="/",routes:r}=e,n=c.createStore(null,{and:{serialize:"ignore"},name:"$history",sid:"31majq"}),a=c.createStore([],{and:{serialize:"ignore"},name:"$activeRoutes",sid:"mastmv"}),s=c.createStore({},{name:"$query",sid:"4sjpht"}),o=c.createStore(null,{name:"$path",sid:"wq6kyf"}),i=c.createEvent({name:"setHistory",sid:"tco5ea"}),f=c.createEvent({name:"navigate",sid:"-6nqgd3"}),l=c.createEvent({name:"back",sid:"-gxisi3"}),y=c.createEvent({name:"forward",sid:"-5nj6gd"}),g=c.createEvent({name:"locationUpdated",sid:"enqpbn"}),b=r.map(d=>{let h=d;const u=[];for(u.unshift(h.internal.path);h.internal.parent;)h=h.internal.parent,h.internal.path!=="/"&&u.unshift(h.internal.path);const w=t==="/"?u.join(""):[t,...u].join("");return{route:d,path:w,toPath:le(w),fromPath:de(w)}}),x=c.attach({and:{source:{history:n},effect:async(d,h)=>{let{history:u}=d,{path:w,query:R,replace:j}=h;if(!u)throw new Error("history not found");const L={pathname:w,search:"?".concat(k.stringify(R))};j?u.replace(L):u.push(L)}},or:{name:"navigateFx",sid:"e3jr9b"}}),p=c.createEffect(d=>{const h=c.scopeBind(g);if(h({pathname:d.location.pathname,query:k.parse(d.location.search)}),!d)throw new Error;d.listen(u=>{let{location:w}=u;h({pathname:w.pathname,query:k.parse(w.search)})})},{name:"subscribeHistoryFx",sid:"2h2oyo"}),$=c.attach({and:{source:{query:s,path:o},effect:async d=>{let{query:h,path:u}=d;for(const{route:w,fromPath:R}of b){const j=R(u);if(j)await w.internal.openFx({query:h,params:j.params,historyIgnore:!0});else{w.internal.close();continue}}}},or:{name:"openRoutesByPathFx",sid:"-o9v4d"}});for(const{route:d,toPath:h}of b)c.sample({and:[{clock:d.opened,source:a,filter:u=>!u.includes(d),fn:u=>[...u,d],target:a}],or:{sid:"f0qyp9"}}),c.sample({and:[{clock:d.opened,filter:u=>!(u!=null&&u.historyIgnore),fn:u=>{var w;return{path:h(u&&"params"in u?u.params:void 0),query:(w=u==null?void 0:u.query)!==null&&w!==void 0?w:{},replace:u==null?void 0:u.replace}},target:f}],or:{sid:"fgozwq"}}),c.sample({and:[{clock:d.closed,source:a,fn:u=>u.filter(w=>w!==d),target:a}],or:{sid:"gc19qb"}});return c.sample({and:[{clock:i,target:n}],or:{sid:"ggfmfh"}}),c.sample({and:[{clock:n,filter:Boolean,target:p}],or:{sid:"guq9uv"}}),c.sample({and:[{clock:g,fn:d=>{var h;return{path:d.pathname,query:(h=d.query)!==null&&h!==void 0?h:{}}},target:[c.withFactory({sid:"-3mx9rg",fn:()=>oe.spread({targets:{path:o,query:s}}),name:"target",method:"spread"}),$]}],or:{sid:"h9kpvm"}}),c.sample({and:[{clock:f,target:x}],or:{sid:"hugwfc"}}),c.sample({and:[{clock:[s,o],source:{query:s,path:o},fn:d=>d,target:f}],or:{sid:"i8rjuq"}}),{$query:s,$path:o,$activeRoutes:a,back:l,forward:y,navigate:f,routes:r,setHistory:i,mappedRoutes:b,trackQuery:Re(a,s),"@@unitShape":()=>({query:s,path:o,activeRoutes:a,onBack:l,onForward:y,onNavigate:f})}}exports.createRoute=ue;exports.createRouter=Le;exports.parameters=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("effector"),ye=require("patronum");function W(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?W(Object(r),!0).forEach(function(n){he(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):W(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function he(e,t,r){return(t=ge(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ge(e){var t=be(e,"string");return typeof t=="symbol"?t:t+""}function be(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function we(e){let t;const r=u.createEffect(()=>{var h;return(h=t)===null||h===void 0?void 0:h()},{name:"waitForAsyncBundleFx",sid:"tw7mq7"}),n=u.createEffect(async()=>{for(const A of(h=e.beforeOpen)!==null&&h!==void 0?h:[]){var h;await A()}},{name:"beforeOpenFx",sid:"ls74w9"}),a=u.createEffect(async h=>{await r(),await n();const A=e.parent;return A&&await A.internal.openFx(B(B({},h??{params:{}}),{},{historyIgnore:!0})),h},{name:"openFx",sid:"-hz9h5i"}),f=u.createStore({},{name:"$params",sid:"rstqrf"}),c=u.createStore(!1,{name:"$isOpened",sid:"-zgx6q9"}),l=a.pending,S=u.createEvent({name:"open",sid:"-cby6lj"}),D=u.createEvent({name:"close",sid:"7uwhl1"}),j=u.createEvent({name:"opened",sid:"44ryfn"}),v=u.createEvent({name:"openedOnServer",sid:"-prk6y1"}),P=u.createEvent({name:"openedOnClient",sid:"-fw2mlz"}),$=u.createEvent({name:"closed",sid:"10jxi5"});u.sample({and:[{clock:S,target:a}],or:{sid:"t7vx9v"}});const E={};return u.sample({and:[{clock:a.doneData,fn:h=>h&&"params"in h?B({},h.params):E,target:f}],or:{sid:"tna5vz"}}),u.split({and:[{source:a.doneData,match:()=>typeof window>"u"?"server":"client",cases:{server:v,client:P}}],or:{sid:"u5fdgw"}}),u.sample({and:[{clock:[P,v],target:j}],or:{sid:"ylqojg"}}),u.sample({and:[{clock:j,fn:()=>!0,target:c}],or:{sid:"yohni9"}}),u.sample({and:[{clock:D,target:$}],or:{sid:"z3c3j0"}}),u.sample({and:[{clock:$,fn:()=>!1,target:c}],or:{sid:"z632ht"}}),{$params:f,$isOpened:c,$isPending:l,open:S,closed:$,opened:j,openedOnClient:P,openedOnServer:v,internal:B({close:D,openFx:a,setAsyncImport:h=>t=h},e),"@@unitShape":()=>({params:f,isPending:l,isOpened:c,onOpen:S})}}var T={},G;function xe(){if(G)return T;G=1,Object.defineProperty(T,"__esModule",{value:!0}),T.TokenData=void 0,T.parse=v,T.compile=P,T.match=h,T.pathToRegexp=A,T.stringify=O;const e="/",t=i=>i,r=/^[$_\p{ID_Start}]$/u,n=/^[$\u200c\u200d\p{ID_Continue}]$/u,a="https://git.new/pathToRegexpError",f={"{":"{","}":"}","(":"(",")":")","[":"[","]":"]","+":"+","?":"?","!":"!"};function c(i){return i.replace(/[{}()\[\]+?!:*]/g,"\\$&")}function l(i){return i.replace(/[.+*?^${}()[\]|/\\]/g,"\\$&")}function*S(i){const o=[...i];let s=0;function m(){let d="";if(r.test(o[++s]))for(d+=o[s];n.test(o[++s]);)d+=o[s];else if(o[s]==='"'){let p=s;for(;s<o.length;){if(o[++s]==='"'){s++,p=0;break}o[s]==="\\"?d+=o[++s]:d+=o[s]}if(p)throw new TypeError(`Unterminated quote at ${p}: ${a}`)}if(!d)throw new TypeError(`Missing parameter name at ${s}: ${a}`);return d}for(;s<o.length;){const d=o[s],p=f[d];if(p)yield{type:p,index:s++,value:d};else if(d==="\\")yield{type:"ESCAPED",index:s++,value:o[s++]};else if(d===":"){const x=m();yield{type:"PARAM",index:s,value:x}}else if(d==="*"){const x=m();yield{type:"WILDCARD",index:s,value:x}}else yield{type:"CHAR",index:s,value:o[s++]}}return{type:"END",index:s,value:""}}class D{constructor(o){this.tokens=o}peek(){if(!this._peek){const o=this.tokens.next();this._peek=o.value}return this._peek}tryConsume(o){const s=this.peek();if(s.type===o)return this._peek=void 0,s.value}consume(o){const s=this.tryConsume(o);if(s!==void 0)return s;const{type:m,index:d}=this.peek();throw new TypeError(`Unexpected ${m} at ${d}, expected ${o}: ${a}`)}text(){let o="",s;for(;s=this.tryConsume("CHAR")||this.tryConsume("ESCAPED");)o+=s;return o}}class j{constructor(o){this.tokens=o}}T.TokenData=j;function v(i,o={}){const{encodePath:s=t}=o,m=new D(S(i));function d(x){const g=[];for(;;){const k=m.text();k&&g.push({type:"text",value:s(k)});const N=m.tryConsume("PARAM");if(N){g.push({type:"param",name:N});continue}const L=m.tryConsume("WILDCARD");if(L){g.push({type:"wildcard",name:L});continue}if(m.tryConsume("{")){g.push({type:"group",tokens:d("}")});continue}return m.consume(x),g}}const p=d("END");return new j(p)}function P(i,o={}){const{encode:s=encodeURIComponent,delimiter:m=e}=o,d=i instanceof j?i:v(i,o),p=$(d.tokens,m,s);return function(g={}){const[k,...N]=p(g);if(N.length)throw new TypeError(`Missing parameters: ${N.join(", ")}`);return k}}function $(i,o,s){const m=i.map(d=>E(d,o,s));return d=>{const p=[""];for(const x of m){const[g,...k]=x(d);p[0]+=g,p.push(...k)}return p}}function E(i,o,s){if(i.type==="text")return()=>[i.value];if(i.type==="group"){const d=$(i.tokens,o,s);return p=>{const[x,...g]=d(p);return g.length?[""]:[x]}}const m=s||t;return i.type==="wildcard"&&s!==!1?d=>{const p=d[i.name];if(p==null)return["",i.name];if(!Array.isArray(p)||p.length===0)throw new TypeError(`Expected "${i.name}" to be a non-empty array`);return[p.map((x,g)=>{if(typeof x!="string")throw new TypeError(`Expected "${i.name}/${g}" to be a string`);return m(x)}).join(o)]}:d=>{const p=d[i.name];if(p==null)return["",i.name];if(typeof p!="string")throw new TypeError(`Expected "${i.name}" to be a string`);return[m(p)]}}function h(i,o={}){const{decode:s=decodeURIComponent,delimiter:m=e}=o,{regexp:d,keys:p}=A(i,o),x=p.map(g=>s===!1?t:g.type==="param"?s:k=>k.split(m).map(s));return function(k){const N=d.exec(k);if(!N)return!1;const L=N[0],_=Object.create(null);for(let q=1;q<N.length;q++){if(N[q]===void 0)continue;const M=p[q-1],z=x[q-1];_[M.name]=z(N[q])}return{path:L,params:_}}}function A(i,o={}){const{delimiter:s=e,end:m=!0,sensitive:d=!1,trailing:p=!0}=o,x=[],g=[],k=d?"":"i",L=(Array.isArray(i)?i:[i]).map(M=>M instanceof j?M:v(M,o));for(const{tokens:M}of L)for(const z of b(M,0,[])){const me=w(z,s,x);g.push(me)}let _=`^(?:${g.join("|")})`;return p&&(_+=`(?:${l(s)}$)?`),_+=m?"$":`(?=${l(s)}|$)`,{regexp:new RegExp(_,k),keys:x}}function*b(i,o,s){if(o===i.length)return yield s;const m=i[o];if(m.type==="group"){const d=s.slice();for(const p of b(m.tokens,0,d))yield*b(i,o+1,p)}else s.push(m);yield*b(i,o+1,s)}function w(i,o,s){let m="",d="",p=!0;for(let x=0;x<i.length;x++){const g=i[x];if(g.type==="text"){m+=l(g.value),d+=g.value,p||(p=g.value.includes(o));continue}if(g.type==="param"||g.type==="wildcard"){if(!p&&!d)throw new TypeError(`Missing text after "${g.name}": ${a}`);g.type==="param"?m+=`(${y(o,p?"":d)}+)`:m+="([\\s\\S]+)",s.push(g),d="",p=!1;continue}}return m}function y(i,o){return o.length<2?i.length<2?`[^${l(i+o)}]`:`(?:(?!${l(i)})[^${l(o)}])`:i.length<2?`(?:(?!${l(o)})[^${l(i)}])`:`(?:(?!${l(o)}|${l(i)})[\\s\\S])`}function O(i){return i.tokens.map(function o(s,m,d){if(s.type==="text")return c(s.value);if(s.type==="group")return`{${s.tokens.map(o).join("")}}`;const x=U(s.name)&&I(d[m+1])?s.name:JSON.stringify(s.name);if(s.type==="param")return`:${x}`;if(s.type==="wildcard")return`*${x}`;throw new TypeError(`Unexpected token: ${s}`)}).join("")}function U(i){const[o,...s]=i;return r.test(o)?s.every(m=>n.test(m)):!1}function I(i){return(i==null?void 0:i.type)!=="text"?!0:!n.test(i.value[0])}return T}var X=xe();const Oe=Symbol("any"),Fe=Symbol("number"),Se=Symbol("string"),$e=Symbol("array"),Ee=Symbol("boolean"),R={any:Oe,number:Fe,string:Se,array:$e,boolean:Ee};function Y(e,t){for(const r of e)if(t.includes(r))return!0;return!1}function Z(e,t){for(const r in t){const n=t[r];if(Array.isArray(n)&&(!e[r]||JSON.stringify(n)!==e[r]))return!1;switch(typeof n){case"number":{if(!e[r]||n.toString()!==e[r])return!1;break}case"object":{if(!e[r]||JSON.stringify(n)!==e[r])return!1;break}case"string":{if(!e[r]||n!==e[r])return!1;break}case"boolean":{if(!e[r]||!["0","1","false","true"].includes(e[r]))return!1;break}}switch(n){case R.any:{if(!e[r])return!1;break}case R.string:{if(!e[r]||Array.isArray(e[r]))return!1;break}case R.array:{if(!e[r]||!Array.isArray(e[r]))return!1;break}case R.number:{if(!e[r]||Array.isArray(e[r])||isNaN(parseInt(e[r]))&&isNaN(parseFloat(e[r])))return!1;break}case R.boolean:{if(!e[r]||Array.isArray(e[r])||!["0","1","false","true"].includes(e[r]))return!1;break}}}return!0}function je(e,t){const r={};for(const n in t){const a=t[n],f=e[n];if(Array.isArray(a)){const c=e[n];r[n]=c;continue}switch(typeof a){case"number":{r[n]=isNaN(parseInt(f))?parseFloat(f):parseInt(f);break}case"object":{r[n]=JSON.parse(f);break}case"string":r[n]=f;case"boolean":{r[n]=f==="1"||f==="true";break}}switch(a){case R.any:case R.string:case R.array:{r[n]=e[n];break}case R.number:{const c=e[n];r[n]=isNaN(parseInt(c))?parseFloat(c):parseInt(c);break}case R.boolean:{const c=e[n];r[n]=c==="1"||c==="true";break}}}return r}function ve(e){let{$activeRoutes:t,$path:r,$query:n,navigateFx:a}=e;return f=>{const{parameters:c,forRoutes:l}=f,S=u.createStore(!1,{name:"$entered",sid:"jh7pkx"}),D=u.createEvent({name:"entered",sid:"-savym4"}),j=u.createEvent({name:"exited",sid:"m5ggn3"}),v=u.createEvent({name:"exit",sid:"-bgcxp1"}),P=u.createEvent({name:"changeEntered",sid:"-2ei1v0"});return u.sample({and:[{clock:P,target:S}],or:{sid:"-hckvl5"}}),u.sample({and:[{source:{activeRoutes:t,query:n},filter:$=>{let{activeRoutes:E,query:h}=$;return(!l||Y(l,E))&&Z(h,c)},fn:$=>{let{query:E}=$;return je(E,c)},target:[D,P.prepend(()=>!0)]}],or:{sid:"-h9twmc"}}),u.sample({and:[{source:{activeRoutes:t,query:n,entered:S},filter:$=>{let{activeRoutes:E,query:h,entered:A}=$;return A&&!((!l||Y(l,E))&&Z(h,c))},target:[j.prepend(()=>{}),P.prepend(()=>!1)]}],or:{sid:"-gtc2ti"}}),u.sample({and:[{clock:v,source:{path:r,query:n},fn:($,E)=>{let{path:h,query:A}=$;if(E&&E.ignoreParams){const b={};for(const w of E.ignoreParams)A[w]&&(b[w]=A[w]);return{query:b,path:h}}return{query:{},path:h}},target:a}],or:{sid:"-fyjlla"}}),{entered:D,exited:j,exit:v}}}const se="%[a-f0-9]{2}",ee=new RegExp("("+se+")|([^%]+?)","gi"),re=new RegExp("("+se+")+","gi");function V(e,t){try{return[decodeURIComponent(e.join(""))]}catch{}if(e.length===1)return e;t=t||1;const r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],V(r),V(n))}function Pe(e){try{return decodeURIComponent(e)}catch{let t=e.match(ee)||[];for(let r=1;r<t.length;r++)e=V(t,r).join(""),t=e.match(ee)||[];return e}}function Ae(e){const t={"%FE%FF":"��","%FF%FE":"��"};let r=re.exec(e);for(;r;){try{t[r[0]]=decodeURIComponent(r[0])}catch{const a=Pe(r[0]);a!==r[0]&&(t[r[0]]=a)}r=re.exec(e)}t["%C2"]="�";const n=Object.keys(t);for(const a of n)e=e.replace(new RegExp(a,"g"),t[a]);return e}function ke(e){if(typeof e!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return decodeURIComponent(e)}catch{return Ae(e)}}function Ne(e,t){const r={};if(Array.isArray(t))for(const n of t){const a=Object.getOwnPropertyDescriptor(e,n);a!=null&&a.enumerable&&Object.defineProperty(r,n,a)}else for(const n of Reflect.ownKeys(e)){const a=Object.getOwnPropertyDescriptor(e,n);if(a.enumerable){const f=e[n];t(n,f,e)&&Object.defineProperty(r,n,a)}}return r}function oe(e,t){if(!(typeof e=="string"&&typeof t=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e===""||t==="")return[];const r=e.indexOf(t);return r===-1?[]:[e.slice(0,r),e.slice(r+t.length)]}const Re=e=>e==null,De=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),K=Symbol("encodeFragmentIdentifier");function Ie(e){switch(e.arrayFormat){case"index":return t=>(r,n)=>{const a=r.length;return n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?r:n===null?[...r,[F(t,e),"[",a,"]"].join("")]:[...r,[F(t,e),"[",F(a,e),"]=",F(n,e)].join("")]};case"bracket":return t=>(r,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?r:n===null?[...r,[F(t,e),"[]"].join("")]:[...r,[F(t,e),"[]=",F(n,e)].join("")];case"colon-list-separator":return t=>(r,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?r:n===null?[...r,[F(t,e),":list="].join("")]:[...r,[F(t,e),":list=",F(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{const t=e.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(n,a)=>a===void 0||e.skipNull&&a===null||e.skipEmptyString&&a===""?n:(a=a===null?"":a,n.length===0?[[F(r,e),t,F(a,e)].join("")]:[[n,F(a,e)].join(e.arrayFormatSeparator)])}default:return t=>(r,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?r:n===null?[...r,F(t,e)]:[...r,[F(t,e),"=",F(n,e)].join("")]}}function Te(e){let t;switch(e.arrayFormat){case"index":return(r,n,a)=>{if(t=/\[(\d*)]$/.exec(r),r=r.replace(/\[\d*]$/,""),!t){a[r]=n;return}a[r]===void 0&&(a[r]={}),a[r][t[1]]=n};case"bracket":return(r,n,a)=>{if(t=/(\[])$/.exec(r),r=r.replace(/\[]$/,""),!t){a[r]=n;return}if(a[r]===void 0){a[r]=[n];return}a[r]=[...a[r],n]};case"colon-list-separator":return(r,n,a)=>{if(t=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!t){a[r]=n;return}if(a[r]===void 0){a[r]=[n];return}a[r]=[...a[r],n]};case"comma":case"separator":return(r,n,a)=>{const f=typeof n=="string"&&n.includes(e.arrayFormatSeparator),c=typeof n=="string"&&!f&&C(n,e).includes(e.arrayFormatSeparator);n=c?C(n,e):n;const l=f||c?n.split(e.arrayFormatSeparator).map(S=>C(S,e)):n===null?n:C(n,e);a[r]=l};case"bracket-separator":return(r,n,a)=>{const f=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!f){a[r]=n&&C(n,e);return}const c=n===null?[]:C(n,e).split(e.arrayFormatSeparator);if(a[r]===void 0){a[r]=c;return}a[r]=[...a[r],...c]};default:return(r,n,a)=>{if(a[r]===void 0){a[r]=n;return}a[r]=[...[a[r]].flat(),n]}}}function ie(e){if(typeof e!="string"||e.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function F(e,t){return t.encode?t.strict?De(e):encodeURIComponent(e):e}function C(e,t){return t.decode?ke(e):e}function ce(e){return Array.isArray(e)?e.sort():typeof e=="object"?ce(Object.keys(e)).sort((t,r)=>Number(t)-Number(r)).map(t=>e[t]):e}function fe(e){const t=e.indexOf("#");return t!==-1&&(e=e.slice(0,t)),e}function Ce(e){let t="";const r=e.indexOf("#");return r!==-1&&(t=e.slice(r)),t}function te(e,t,r){return r==="string"&&typeof e=="string"?e:typeof r=="function"&&typeof e=="string"?r(e):t.parseBooleans&&e!==null&&(e.toLowerCase()==="true"||e.toLowerCase()==="false")?e.toLowerCase()==="true":r==="number"&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""||t.parseNumbers&&!Number.isNaN(Number(e))&&typeof e=="string"&&e.trim()!==""?Number(e):e}function J(e){e=fe(e);const t=e.indexOf("?");return t===-1?"":e.slice(t+1)}function Q(e,t){t={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...t},ie(t.arrayFormatSeparator);const r=Te(t),n=Object.create(null);if(typeof e!="string"||(e=e.trim().replace(/^[?#&]/,""),!e))return n;for(const a of e.split("&")){if(a==="")continue;const f=t.decode?a.replaceAll("+"," "):a;let[c,l]=oe(f,"=");c===void 0&&(c=f),l=l===void 0?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?l:C(l,t),r(C(c,t),l,n)}for(const[a,f]of Object.entries(n))if(typeof f=="object"&&f!==null&&t.types[a]!=="string")for(const[c,l]of Object.entries(f)){const S=t.types[a]?t.types[a].replace("[]",""):void 0;f[c]=te(l,t,S)}else typeof f=="object"&&f!==null&&t.types[a]==="string"?n[a]=Object.values(f).join(t.arrayFormatSeparator):n[a]=te(f,t,t.types[a]);return t.sort===!1?n:(t.sort===!0?Object.keys(n).sort():Object.keys(n).sort(t.sort)).reduce((a,f)=>{const c=n[f];return a[f]=c&&typeof c=="object"&&!Array.isArray(c)?ce(c):c,a},Object.create(null))}function ue(e,t){if(!e)return"";t={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...t},ie(t.arrayFormatSeparator);const r=c=>t.skipNull&&Re(e[c])||t.skipEmptyString&&e[c]==="",n=Ie(t),a={};for(const[c,l]of Object.entries(e))r(c)||(a[c]=l);const f=Object.keys(a);return t.sort!==!1&&f.sort(t.sort),f.map(c=>{const l=e[c];return l===void 0?"":l===null?F(c,t):Array.isArray(l)?l.length===0&&t.arrayFormat==="bracket-separator"?F(c,t)+"[]":l.reduce(n(c),[]).join("&"):F(c,t)+"="+F(l,t)}).filter(c=>c.length>0).join("&")}function le(e,t){var a;t={decode:!0,...t};let[r,n]=oe(e,"#");return r===void 0&&(r=e),{url:((a=r==null?void 0:r.split("?"))==null?void 0:a[0])??"",query:Q(J(e),t),...t&&t.parseFragmentIdentifier&&n?{fragmentIdentifier:C(n,t)}:{}}}function de(e,t){t={encode:!0,strict:!0,[K]:!0,...t};const r=fe(e.url).split("?")[0]||"",n=J(e.url),a={...Q(n,{sort:!1}),...e.query};let f=ue(a,t);f&&(f=`?${f}`);let c=Ce(e.url);if(typeof e.fragmentIdentifier=="string"){const l=new URL(r);l.hash=e.fragmentIdentifier,c=t[K]?l.hash:`#${e.fragmentIdentifier}`}return`${r}${f}${c}`}function pe(e,t,r){r={parseFragmentIdentifier:!0,[K]:!1,...r};const{url:n,query:a,fragmentIdentifier:f}=le(e,r);return de({url:n,query:Ne(a,t),fragmentIdentifier:f},r)}function Ue(e,t,r){const n=Array.isArray(t)?a=>!t.includes(a):(a,f)=>!t(a,f);return pe(e,n,r)}const H=Object.freeze(Object.defineProperty({__proto__:null,exclude:Ue,extract:J,parse:Q,parseUrl:le,pick:pe,stringify:ue,stringifyUrl:de},Symbol.toStringTag,{value:"Module"}));function ne(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ae(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ne(Object(r),!0).forEach(function(n){_e(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ne(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function _e(e,t,r){return(t=qe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function qe(e){var t=Me(e,"string");return typeof t=="symbol"?t:t+""}function Me(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Le(e){const{base:t="/",routes:r}=e,n=u.createStore({skipUpdate:!1},{name:"$meta",sid:"ku65ys"}),a=u.createStore(null,{and:{serialize:"ignore"},name:"$history",sid:"23j1rc"}),f=u.createStore({},{name:"$query",sid:"3deub8"}),c=u.createStore(null,{name:"$path",sid:"ld3nhr"}),l=u.createEvent({name:"setHistory",sid:"hzl7xm"}),S=u.createEvent({name:"navigate",sid:"-82vbjo"}),D=u.createEvent({name:"back",sid:"-icnnoo"}),j=u.createEvent({name:"forward",sid:"-72o1my"}),v=u.createEvent({name:"locationUpdated",sid:"d8lu52"}),P=r.map(b=>{let w=b;const y=[];for(y.unshift(w.internal.path);w.internal.parent;)w=w.internal.parent,w.internal.path!=="/"&&y.unshift(w.internal.path);const O=t==="/"?y.join(""):[t,...y].join("");return{route:b,path:O,toPath:X.compile(O),fromPath:X.match(O)}}),$=c.map(b=>{const w=[];for(const{route:y,fromPath:O}of P)O(b)&&w.push(y);return w}),E=u.attach({and:{source:{history:a,meta:n},effect:async(b,w)=>{let{history:y,meta:O}=b,{path:U,query:I,replace:i}=w;if(!y)throw new Error("history not found");if(O.skipUpdate){O.skipUpdate=!1;return}const o={pathname:U,search:"?".concat(H.stringify(I))};i?y.replace(o):y.push(o,{skipUpdate:!0})}},or:{name:"navigateFx",sid:"sry1hc"}}),h=u.attach({and:{source:n,effect:(b,w)=>{var y;const O=u.scopeBind(v);if(O({pathname:w.location.pathname,query:ae({},H.parse(w.location.search)),state:(y=w.location.state)!==null&&y!==void 0?y:{}}),!w)throw new Error;w.listen(U=>{var I;let{location:i}=U;const o=(I=i.state)!==null&&I!==void 0?I:{};o.skipUpdate&&(b.skipUpdate=!0),O({pathname:i.pathname,query:ae({},H.parse(i.search)),state:o})})}},or:{name:"subscribeHistoryFx",sid:"-9srjw2"}}),A=u.attach({and:{source:{query:f,path:c},effect:async b=>{let{query:w,path:y}=b;for(const{route:O,fromPath:U}of P){const I=U(y);if(I)await O.internal.openFx({query:w,params:I.params,historyIgnore:!0});else{O.internal.close();continue}}}},or:{name:"openRoutesByPathFx",sid:"-ro72fe"}});for(const{route:b,toPath:w}of P)u.sample({and:[{clock:b.opened,filter:y=>!(y!=null&&y.historyIgnore),fn:y=>{var O;return{path:w(y&&"params"in y?y.params:void 0),query:(O=y==null?void 0:y.query)!==null&&O!==void 0?O:{},replace:y==null?void 0:y.replace}},target:S}],or:{sid:"gfvtvu"}});return u.sample({and:[{clock:l,target:a}],or:{sid:"hbrw92"}}),u.sample({and:[{clock:a,filter:Boolean,target:h}],or:{sid:"heiv7v"}}),u.sample({and:[{clock:v,fn:b=>({path:b.pathname,query:b.query}),target:u.withFactory({sid:"-f70n8p",fn:()=>ye.spread({targets:{path:c,query:f}}),name:"target",method:"spread"})}],or:{sid:"htdb8m"}}),u.sample({and:[{clock:v,fn:b=>({path:b.pathname,query:b.query}),target:A}],or:{sid:"icm409"}}),u.sample({and:[{clock:S,target:E}],or:{sid:"sr2036"}}),u.sample({and:[{clock:[f,c],source:{query:f,path:c},fn:b=>b,target:S}],or:{sid:"t5cnik"}}),{$query:f,$path:c,$activeRoutes:$,back:D,forward:j,navigate:S,routes:r,setHistory:l,mappedRoutes:P,trackQuery:ve({$activeRoutes:$,$path:c,$query:f,navigateFx:E}),"@@unitShape":()=>({query:f,path:c,activeRoutes:$,onBack:D,onForward:j,onNavigate:S})}}exports.createRoute=we;exports.createRouter=Le;exports.parameters=R;
package/dist/index.d.ts CHANGED
@@ -14,6 +14,10 @@ declare type ArrayParameter = typeof arraySymbol;
14
14
 
15
15
  declare const arraySymbol: unique symbol;
16
16
 
17
+ declare type BooleanParameter = typeof booleanSymbol;
18
+
19
+ declare const booleanSymbol: unique symbol;
20
+
17
21
  declare interface Config<T> {
18
22
  path: T;
19
23
  parent?: Route<any>;
@@ -41,6 +45,7 @@ declare type Parameters_2 = {
41
45
  number: NumberParameter;
42
46
  string: StringParameter;
43
47
  array: ArrayParameter;
48
+ boolean: BooleanParameter;
44
49
  };
45
50
 
46
51
  declare type PayloadBase = {
@@ -56,7 +61,6 @@ declare interface QueryTracker<ParametersConfig extends RawConfig> {
56
61
  exit: EventCallable<{
57
62
  ignoreParams: string[];
58
63
  } | void>;
59
- getPayload: (config: ReadyConfig<ParametersConfig>) => Record<string, any>;
60
64
  }
61
65
 
62
66
  declare type QueryTrackerConfig<ParametersConfig extends RawConfig> = {
@@ -64,7 +68,7 @@ declare type QueryTrackerConfig<ParametersConfig extends RawConfig> = {
64
68
  parameters: ParametersConfig;
65
69
  };
66
70
 
67
- declare type RawConfig = Record<string, AnyParameter | ArrayParameter | NumberParameter | StringParameter | SupportedPrimitive | SupportedPrimitive[]>;
71
+ declare type RawConfig = Record<string, AnyParameter | ArrayParameter | NumberParameter | StringParameter | BooleanParameter | SupportedPrimitive | SupportedPrimitive[]>;
68
72
 
69
73
  declare type ReadyConfig<T extends RawConfig> = {
70
74
  [K in keyof T]: T[K] extends StringParameter ? string : T[K] extends NumberParameter ? number : T[K] extends ArrayParameter ? string[] : T[K] extends AnyParameter ? string | string[] : never;