@argon-router/core 0.2.3 → 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.
package/README.md CHANGED
@@ -0,0 +1,24 @@
1
+ # ☄️ argon-router/core
2
+
3
+ Router without a headache
4
+
5
+ > [!WARNING]
6
+ > argon-router is extermely unstable & maybe buggy. DO NOT USE IN PRODUCTION!
7
+
8
+ ## Documentation
9
+
10
+ For additional information, guides and api reference visit [documentation site](https://movpushmov.dev/argon-router/)
11
+
12
+ ## Packages
13
+
14
+ - [@argon-router/core](https://www.npmjs.com/package/@argon-router/core)
15
+ - [@argon-router/react](https://www.npmjs.com/package/@argon-router/react)
16
+
17
+ ## Installation
18
+
19
+ ```
20
+ npm i @argon-router/core
21
+ ```
22
+
23
+ and then follow this [instructions](https://effector.dev/en/api/effector/babel-plugin/#factories)
24
+ (add `@argon-router/core` in factories list)
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("effector"),se=require("patronum");function L(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 v(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?L(Object(r),!0).forEach(function(n){oe(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):L(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function oe(e,t,r){return(t=ie(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ie(e){var t=ce(e,"string");return typeof t=="symbol"?t:t+""}function ce(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 fe(e){let t;const r=c.createEffect(()=>{var m;return(m=t)===null||m===void 0?void 0:m()},{name:"waitForAsyncBundleFx",sid:"tw7mq7"}),n=c.createEffect(async()=>{for(const d of(m=e.beforeOpen)!==null&&m!==void 0?m:[]){var m;await d()}},{name:"beforeOpenFx",sid:"ls74w9"}),a=c.createEffect(async m=>(await r(),await n(),e.parent&&await e.parent.internal.openFx(v(v({},m??{params:{}}),{},{historyIgnore:!0})),m),{name:"openFx",sid:"-hz9h5i"}),s=c.createStore({},{name:"$params",sid:"fyp6wk"}),o=c.createStore(!1,{name:"$isOpened",sid:"nq2be0"}),i=a.pending,u=c.createEvent({name:"open",sid:"-e84o6b"}),l=c.createEvent({name:"close",sid:"5yq009"}),h=c.createEvent({name:"opened",sid:"28lguv"}),p=c.createEvent({name:"openedOnServer",sid:"-rnqoit"}),w=c.createEvent({name:"openedOnClient",sid:"-rq76gu"}),x=c.createEvent({name:"closed",sid:"-atkmcq"});return c.sample({and:[{clock:u,target:a}],or:{sid:"t5oqwf"}}),c.split({and:[{source:a.doneData,match:()=>typeof window>"u"?"server":"client",cases:{server:p,client:w}}],or:{sid:"t8fpv8"}}),c.sample({and:[{clock:[w,p],target:h}],or:{sid:"tphc9f"}}),c.sample({and:[{clock:h,fn:()=>!0,target:o}],or:{sid:"u3rzot"}}),c.sample({and:[{clock:l,target:x}],or:{sid:"u72r8z"}}),c.sample({and:[{clock:x,fn:()=>!1,target:o}],or:{sid:"ykn3cq"}}),{$params:s,$isOpened:o,$isPending:i,open:u,closed:x,opened:h,openedOnClient:w,openedOnServer:p,internal:v({index:!1,close:l,openFx:a,setAsyncImport:m=>t=m},e),"@@unitShape":()=>({params:s,isPending:i,isOpened:o,onOpen:u})}}var $={};Object.defineProperty($,"__esModule",{value:!0});$.TokenData=void 0;$.parse=U;var ue=$.compile=he,le=$.match=be;$.pathToRegexp=W;$.stringify=Fe;const C="/",T=e=>e,J=/^[$_\p{ID_Start}]$/u,D=/^[$\u200c\u200d\p{ID_Continue}]$/u,A="https://git.new/pathToRegexpError",de={"{":"{","}":"}","(":"(",")":")","[":"[","]":"]","+":"+","?":"?","!":"!"};function pe(e){return e.replace(/[{}()\[\]+?!:*]/g,"\\$&")}function F(e){return e.replace(/[.+*?^${}()[\]|/\\]/g,"\\$&")}function*me(e){const t=[...e];let r=0;function n(){let a="";if(J.test(t[++r]))for(a+=t[r];D.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}: ${A}`)}if(!a)throw new TypeError(`Missing parameter name at ${r}: ${A}`);return a}for(;r<t.length;){const a=t[r],s=de[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 ye{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}: ${A}`)}text(){let t="",r;for(;r=this.tryConsume("CHAR")||this.tryConsume("ESCAPED");)t+=r;return t}}class N{constructor(t){this.tokens=t}}$.TokenData=N;function U(e,t={}){const{encodePath:r=T}=t,n=new ye(me(e));function a(o){const i=[];for(;;){const u=n.text();u&&i.push({type:"text",value:r(u)});const l=n.tryConsume("PARAM");if(l){i.push({type:"param",name:l});continue}const h=n.tryConsume("WILDCARD");if(h){i.push({type:"wildcard",name:h});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=C}=t,a=e instanceof N?e:U(e,t),s=Q(a.tokens,n,r);return function(i={}){const[u,...l]=s(i);if(l.length)throw new TypeError(`Missing parameters: ${l.join(", ")}`);return u}}function Q(e,t,r){const n=e.map(a=>ge(a,t,r));return a=>{const s=[""];for(const o of n){const[i,...u]=o(a);s[0]+=i,s.push(...u)}return s}}function ge(e,t,r){if(e.type==="text")return()=>[e.value];if(e.type==="group"){const a=Q(e.tokens,t,r);return s=>{const[o,...i]=a(s);return i.length?[""]:[o]}}const n=r||T;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 be(e,t={}){const{decode:r=decodeURIComponent,delimiter:n=C}=t,{regexp:a,keys:s}=W(e,t),o=s.map(i=>r===!1?T:i.type==="param"?r:u=>u.split(n).map(r));return function(u){const l=a.exec(u);if(!l)return!1;const h=l[0],p=Object.create(null);for(let w=1;w<l.length;w++){if(l[w]===void 0)continue;const x=s[w-1],m=o[w-1];p[x.name]=m(l[w])}return{path:h,params:p}}}function W(e,t={}){const{delimiter:r=C,end:n=!0,sensitive:a=!1,trailing:s=!0}=t,o=[],i=[],u=a?"":"i",h=(Array.isArray(e)?e:[e]).map(x=>x instanceof N?x:U(x,t));for(const{tokens:x}of h)for(const m of j(x,0,[])){const d=we(m,r,o);i.push(d)}let p=`^(?:${i.join("|")})`;return s&&(p+=`(?:${F(r)}$)?`),p+=n?"$":`(?=${F(r)}|$)`,{regexp:new RegExp(p,u),keys:o}}function*j(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 j(n.tokens,0,a))yield*j(e,t+1,s)}else r.push(n);yield*j(e,t+1,r)}function we(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}": ${A}`);i.type==="param"?n+=`(${xe(t,s?"":a)}+)`:n+="([\\s\\S]+)",r.push(i),a="",s=!1;continue}}return n}function xe(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 Fe(e){return e.tokens.map(function t(r,n,a){if(r.type==="text")return pe(r.value);if(r.type==="group")return`{${r.tokens.map(t).join("")}}`;const o=Se(r.name)&&Ee(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 Se(e){const[t,...r]=e;return J.test(t)?r.every(n=>D.test(n)):!1}function Ee(e){return(e==null?void 0:e.type)!=="text"?!0:!D.test(e.value[0])}const $e=Symbol("any"),Oe=Symbol("number"),je=Symbol("string"),Ae=Symbol("array"),E={any:$e,number:Oe,string:je,array:Ae};function z(e,t){for(const r of e)if(!t.includes(r))return!1;return!0}function B(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:u=>{let{activeRoutes:l,query:h}=u;return(!a||z(a,l))&&B(h,n)},fn:u=>{let{query:l}=u;return Ne(l,n)}}],or:{sid:"-so0f9q"}}),c.sample({and:[{source:{activeRoutes:e,query:t},filter:u=>{let{activeRoutes:l,query:h}=u;return!((!a||z(a,l))&&B(h,n))},target:o}],or:{sid:"-s82e29"}}),{entered:s,exited:o,exit:i,getPayload:u=>Object.entries(u).reduce((l,h)=>{let[p,w]=h;return typeof n[p]=="symbol"?l[p]=w:l[p]=n[p],l},{})}}}const G="%[a-f0-9]{2}",H=new RegExp("("+G+")|([^%]+?)","gi"),V=new RegExp("("+G+")+","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 ve(e){try{return decodeURIComponent(e)}catch{let t=e.match(H)||[];for(let r=1;r<t.length;r++)e=P(t,r).join(""),t=e.match(H)||[];return e}}function Ie(e){const t={"%FE%FF":"��","%FF%FE":"��"};let r=V.exec(e);for(;r;){try{t[r[0]]=decodeURIComponent(r[0])}catch{const a=ve(r[0]);a!==r[0]&&(t[r[0]]=a)}r=V.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 Ie(e)}}function ke(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 X(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 Ce=e=>e==null,Te=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),k=Symbol("encodeFragmentIdentifier");function De(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,[y(t,e),"[",a,"]"].join("")]:[...r,[y(t,e),"[",y(a,e),"]=",y(n,e)].join("")]};case"bracket":return t=>(r,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?r:n===null?[...r,[y(t,e),"[]"].join("")]:[...r,[y(t,e),"[]=",y(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,[y(t,e),":list="].join("")]:[...r,[y(t,e),":list=",y(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?[[y(r,e),t,y(a,e)].join("")]:[[n,y(a,e)].join(e.arrayFormatSeparator)])}default:return t=>(r,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?r:n===null?[...r,y(t,e)]:[...r,[y(t,e),"=",y(n,e)].join("")]}}function Ue(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(u=>S(u,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 Y(e){if(typeof e!="string"||e.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function y(e,t){return t.encode?t.strict?Te(e):encodeURIComponent(e):e}function S(e,t){return t.decode?Pe(e):e}function Z(e){return Array.isArray(e)?e.sort():typeof e=="object"?Z(Object.keys(e)).sort((t,r)=>Number(t)-Number(r)).map(t=>e[t]):e}function ee(e){const t=e.indexOf("#");return t!==-1&&(e=e.slice(0,t)),e}function _e(e){let t="";const r=e.indexOf("#");return r!==-1&&(t=e.slice(r)),t}function K(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 _(e){e=ee(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},Y(t.arrayFormatSeparator);const r=Ue(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]=X(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 u=t.types[a]?t.types[a].replace("[]",""):void 0;s[o]=K(i,t,u)}else typeof s=="object"&&s!==null&&t.types[a]==="string"?n[a]=Object.values(s).join(t.arrayFormatSeparator):n[a]=K(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)?Z(o):o,a},Object.create(null))}function re(e,t){if(!e)return"";t={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...t},Y(t.arrayFormatSeparator);const r=o=>t.skipNull&&Ce(e[o])||t.skipEmptyString&&e[o]==="",n=De(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?y(o,t):Array.isArray(i)?i.length===0&&t.arrayFormat==="bracket-separator"?y(o,t)+"[]":i.reduce(n(o),[]).join("&"):y(o,t)+"="+y(i,t)}).filter(o=>o.length>0).join("&")}function te(e,t){var a;t={decode:!0,...t};let[r,n]=X(e,"#");return r===void 0&&(r=e),{url:((a=r==null?void 0:r.split("?"))==null?void 0:a[0])??"",query:q(_(e),t),...t&&t.parseFragmentIdentifier&&n?{fragmentIdentifier:S(n,t)}:{}}}function ne(e,t){t={encode:!0,strict:!0,[k]:!0,...t};const r=ee(e.url).split("?")[0]||"",n=_(e.url),a={...q(n,{sort:!1}),...e.query};let s=re(a,t);s&&(s=`?${s}`);let o=_e(e.url);if(typeof e.fragmentIdentifier=="string"){const i=new URL(r);i.hash=e.fragmentIdentifier,o=t[k]?i.hash:`#${e.fragmentIdentifier}`}return`${r}${s}${o}`}function ae(e,t,r){r={parseFragmentIdentifier:!0,[k]:!1,...r};const{url:n,query:a,fragmentIdentifier:s}=te(e,r);return ne({url:n,query:ke(a,t),fragmentIdentifier:s},r)}function qe(e,t,r){const n=Array.isArray(t)?a=>!t.includes(a):(a,s)=>!t(a,s);return ae(e,n,r)}const I=Object.freeze(Object.defineProperty({__proto__:null,exclude:qe,extract:_,parse:q,parseUrl:te,pick:ae,stringify:re,stringifyUrl:ne},Symbol.toStringTag,{value:"Module"}));function Me(e){const{base:t="/",routes:r}=e,n=c.createStore(null,{and:{serialize:"ignore"},name:"$history",sid:"ftu36z"}),a=c.createStore([],{and:{serialize:"ignore"},name:"$activeRoutes",sid:"z30ma4"}),s=c.createStore({},{name:"$query",sid:"hkri52"}),o=c.createStore(null,{name:"$path",sid:"-zgnqnj"}),i=c.createEvent({name:"setHistory",sid:"w6xvrg"}),u=c.createEvent({name:"back",sid:"-4mcm91"}),l=c.createEvent({name:"forward",sid:"6nmzsp"}),h=c.createEvent({name:"locationUpdated",sid:"qywvkp"}),p=r.map(d=>{let g=d;const f=[];for(f.unshift(g.internal.path);g.internal.parent;)g=g.internal.parent,g.internal.path!=="/"&&f.unshift(g.internal.path);const b=t==="/"?f.join(""):[t,...f].join("");return{route:d,path:b,toPath:ue(b),fromPath:le(b)}}),w=c.attach({and:{source:{history:n},effect:async(d,g)=>{let{history:f}=d,{path:b,query:R,replace:O}=g;if(!f)throw new Error("history not found");const M={pathname:b,search:"?".concat(I.stringify(R))};O?f.replace(M):f.push(M)}},or:{name:"navigateFx",sid:"qepxid"}}),x=c.createEffect(d=>{const g=c.scopeBind(h);if(g({pathname:d.location.pathname,query:I.parse(d.location.search)}),!d)throw new Error;d.listen(f=>{let{location:b}=f;g({pathname:b.pathname,query:I.parse(b.search)})})},{name:"subscribeHistoryFx",sid:"es8v7q"}),m=c.attach({and:{source:{query:s,path:o},effect:async d=>{let{query:g,path:f}=d;for(const{route:b,fromPath:R}of p){const O=R(f);if(O)await b.internal.openFx({query:g,params:O.params,historyIgnore:!0});else{b.internal.close();continue}}}},or:{name:"openRoutesByPathFx",sid:"bmwb4p"}});for(const{route:d,toPath:g}of p)c.sample({and:[{clock:d.opened,source:a,filter:f=>!f.includes(d),fn:f=>[...f,d],target:a}],or:{sid:"ff1m4n"}}),c.sample({and:[{clock:d.opened,filter:f=>!(f!=null&&f.historyIgnore),fn:f=>{var b;return{path:g(f&&"params"in f?f.params:void 0),query:(b=f==null?void 0:f.query)!==null&&b!==void 0?b:{},replace:f==null?void 0:f.replace}},target:w}],or:{sid:"fuznc4"}}),c.sample({and:[{clock:d.closed,source:a,fn:f=>f.filter(b=>b!==d),target:a}],or:{sid:"ges8p4"}});return c.sample({and:[{clock:i,target:n}],or:{sid:"guq9uv"}}),c.sample({and:[{clock:n,filter:Boolean,target:x}],or:{sid:"gxh8to"}}),c.sample({and:[{clock:h,fn:d=>{var g;return{path:d.pathname,query:(g=d.query)!==null&&g!==void 0?g:{}}},target:[c.withFactory({sid:"-38mmc2",fn:()=>se.spread({targets:{path:o,query:s}}),name:"target",method:"spread"}),m]}],or:{sid:"hcbouf"}}),{$query:s,$path:o,$activeRoutes:a,back:u,forward:l,routes:r,setHistory:i,mappedRoutes:p,trackQuery:Re(a,s),"@@unitShape":()=>({query:s,path:o,activeRoutes:a,onBack:u,onForward:l})}}exports.createRoute=fe;exports.createRouter=Me;exports.parameters=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("effector"),he=require("patronum");function G(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?G(Object(r),!0).forEach(function(n){be(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):G(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function be(e,t,r){return(t=we(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function we(e){var t=Oe(e,"string");return typeof t=="symbol"?t:t+""}function Oe(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 je(e){let t;const r=u.createEffect(()=>{var j;return(j=t)===null||j===void 0?void 0:j()},{name:"waitForAsyncBundleFx",sid:"tw7mq7"}),n=u.createEffect(async()=>{for(const g of(j=e.beforeOpen)!==null&&j!==void 0?j:[]){var j;await g()}},{name:"beforeOpenFx",sid:"ls74w9"}),a=u.createEffect(async j=>{await r(),await n();const g=e.parent;return g&&await g.internal.openFx(B(B({},j??{params:{}}),{},{historyIgnore:!0})),j},{name:"openFx",sid:"-hz9h5i"}),f=u.createStore({},{name:"$params",sid:"rstqrf"}),o=u.createStore(!1,{name:"$isOpened",sid:"-zgx6q9"}),p=a.pending,O=u.createEvent({name:"open",sid:"-cby6lj"}),F=u.createEvent({name:"close",sid:"7uwhl1"}),S=u.createEvent({name:"opened",sid:"44ryfn"}),$=u.createEvent({name:"openedOnServer",sid:"-prk6y1"}),A=u.createEvent({name:"openedOnClient",sid:"-fw2mlz"}),I=u.createEvent({name:"closed",sid:"10jxi5"});u.sample({and:[{clock:O,target:a}],or:{sid:"t7vx9v"}});const _={};return u.sample({and:[{clock:a.doneData,fn:j=>j&&"params"in j?B({},j.params):_,target:f}],or:{sid:"tna5vz"}}),u.split({and:[{source:a.doneData,match:()=>typeof window>"u"?"server":"client",cases:{server:$,client:A}}],or:{sid:"u5fdgw"}}),u.sample({and:[{clock:[A,$],target:S}],or:{sid:"ylqojg"}}),u.sample({and:[{clock:S,fn:()=>!0,target:o}],or:{sid:"yohni9"}}),u.sample({and:[{clock:F,target:I}],or:{sid:"z3c3j0"}}),u.sample({and:[{clock:I,fn:()=>!1,target:o}],or:{sid:"z632ht"}}),{$params:f,$isOpened:o,$isPending:p,open:O,closed:I,opened:S,openedOnClient:A,openedOnServer:$,internal:B({close:F,openFx:a,setAsyncImport:j=>t=j},e),"@@unitShape":()=>({params:f,isPending:p,isOpened:o,onOpen:O})}}function xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var N={},X;function Ee(){if(X)return N;X=1,Object.defineProperty(N,"__esModule",{value:!0}),N.TokenData=void 0,N.parse=$,N.compile=A,N.match=j,N.pathToRegexp=g,N.stringify=M;const e="/",t=c=>c,r=/^[$_\p{ID_Start}]$/u,n=/^[$\u200c\u200d\p{ID_Continue}]$/u,a="https://git.new/pathToRegexpError",f={"{":"{","}":"}","(":"(",")":")","[":"[","]":"]","+":"+","?":"?","!":"!"};function o(c){return c.replace(/[{}()\[\]+?!:*]/g,"\\$&")}function p(c){return c.replace(/[.+*?^${}()[\]|/\\]/g,"\\$&")}function*O(c){const i=[...c];let s=0;function y(){let l="";if(r.test(i[++s]))for(l+=i[s];n.test(i[++s]);)l+=i[s];else if(i[s]==='"'){let d=s;for(;s<i.length;){if(i[++s]==='"'){s++,d=0;break}i[s]==="\\"?l+=i[++s]:l+=i[s]}if(d)throw new TypeError(`Unterminated quote at ${d}: ${a}`)}if(!l)throw new TypeError(`Missing parameter name at ${s}: ${a}`);return l}for(;s<i.length;){const l=i[s],d=f[l];if(d)yield{type:d,index:s++,value:l};else if(l==="\\")yield{type:"ESCAPED",index:s++,value:i[s++]};else if(l===":"){const w=y();yield{type:"PARAM",index:s,value:w}}else if(l==="*"){const w=y();yield{type:"WILDCARD",index:s,value:w}}else yield{type:"CHAR",index:s,value:i[s++]}}return{type:"END",index:s,value:""}}class F{constructor(i){this.tokens=i}peek(){if(!this._peek){const i=this.tokens.next();this._peek=i.value}return this._peek}tryConsume(i){const s=this.peek();if(s.type===i)return this._peek=void 0,s.value}consume(i){const s=this.tryConsume(i);if(s!==void 0)return s;const{type:y,index:l}=this.peek();throw new TypeError(`Unexpected ${y} at ${l}, expected ${i}: ${a}`)}text(){let i="",s;for(;s=this.tryConsume("CHAR")||this.tryConsume("ESCAPED");)i+=s;return i}}class S{constructor(i){this.tokens=i}}N.TokenData=S;function $(c,i={}){const{encodePath:s=t}=i,y=new F(O(c));function l(w){const h=[];for(;;){const v=y.text();v&&h.push({type:"text",value:s(v)});const P=y.tryConsume("PARAM");if(P){h.push({type:"param",name:P});continue}const U=y.tryConsume("WILDCARD");if(U){h.push({type:"wildcard",name:U});continue}if(y.tryConsume("{")){h.push({type:"group",tokens:l("}")});continue}return y.consume(w),h}}const d=l("END");return new S(d)}function A(c,i={}){const{encode:s=encodeURIComponent,delimiter:y=e}=i,l=c instanceof S?c:$(c,i),d=I(l.tokens,y,s);return function(h={}){const[v,...P]=d(h);if(P.length)throw new TypeError(`Missing parameters: ${P.join(", ")}`);return v}}function I(c,i,s){const y=c.map(l=>_(l,i,s));return l=>{const d=[""];for(const w of y){const[h,...v]=w(l);d[0]+=h,d.push(...v)}return d}}function _(c,i,s){if(c.type==="text")return()=>[c.value];if(c.type==="group"){const l=I(c.tokens,i,s);return d=>{const[w,...h]=l(d);return h.length?[""]:[w]}}const y=s||t;return c.type==="wildcard"&&s!==!1?l=>{const d=l[c.name];if(d==null)return["",c.name];if(!Array.isArray(d)||d.length===0)throw new TypeError(`Expected "${c.name}" to be a non-empty array`);return[d.map((w,h)=>{if(typeof w!="string")throw new TypeError(`Expected "${c.name}/${h}" to be a string`);return y(w)}).join(i)]}:l=>{const d=l[c.name];if(d==null)return["",c.name];if(typeof d!="string")throw new TypeError(`Expected "${c.name}" to be a string`);return[y(d)]}}function j(c,i={}){const{decode:s=decodeURIComponent,delimiter:y=e}=i,{regexp:l,keys:d}=g(c,i),w=d.map(h=>s===!1?t:h.type==="param"?s:v=>v.split(y).map(s));return function(v){const P=l.exec(v);if(!P)return!1;const U=P[0],k=Object.create(null);for(let C=1;C<P.length;C++){if(P[C]===void 0)continue;const T=d[C-1],z=w[C-1];k[T.name]=z(P[C])}return{path:U,params:k}}}function g(c,i={}){const{delimiter:s=e,end:y=!0,sensitive:l=!1,trailing:d=!0}=i,w=[],h=[],v=l?"":"i",U=(Array.isArray(c)?c:[c]).map(T=>T instanceof S?T:$(T,i));for(const{tokens:T}of U)for(const z of b(T,0,[])){const ge=m(z,s,w);h.push(ge)}let k=`^(?:${h.join("|")})`;return d&&(k+=`(?:${p(s)}$)?`),k+=y?"$":`(?=${p(s)}|$)`,{regexp:new RegExp(k,v),keys:w}}function*b(c,i,s){if(i===c.length)return yield s;const y=c[i];if(y.type==="group"){const l=s.slice();for(const d of b(y.tokens,0,l))yield*b(c,i+1,d)}else s.push(y);yield*b(c,i+1,s)}function m(c,i,s){let y="",l="",d=!0;for(let w=0;w<c.length;w++){const h=c[w];if(h.type==="text"){y+=p(h.value),l+=h.value,d||(d=h.value.includes(i));continue}if(h.type==="param"||h.type==="wildcard"){if(!d&&!l)throw new TypeError(`Missing text after "${h.name}": ${a}`);h.type==="param"?y+=`(${x(i,d?"":l)}+)`:y+="([\\s\\S]+)",s.push(h),l="",d=!1;continue}}return y}function x(c,i){return i.length<2?c.length<2?`[^${p(c+i)}]`:`(?:(?!${p(c)})[^${p(i)}])`:c.length<2?`(?:(?!${p(i)})[^${p(c)}])`:`(?:(?!${p(i)}|${p(c)})[\\s\\S])`}function M(c){return c.tokens.map(function i(s,y,l){if(s.type==="text")return o(s.value);if(s.type==="group")return`{${s.tokens.map(i).join("")}}`;const w=q(s.name)&&L(l[y+1])?s.name:JSON.stringify(s.name);if(s.type==="param")return`:${w}`;if(s.type==="wildcard")return`*${w}`;throw new TypeError(`Unexpected token: ${s}`)}).join("")}function q(c){const[i,...s]=c;return r.test(i)?s.every(y=>n.test(y)):!1}function L(c){return(c==null?void 0:c.type)!=="text"?!0:!n.test(c.value[0])}return N}var Y=Ee();const Fe=Symbol("any"),Se=Symbol("number"),$e=Symbol("string"),ve=Symbol("array"),D={any:Fe,number:Se,string:$e,array:ve};function Z(e,t){for(const r of e)if(!t.includes(r))return!1;return!0}function ee(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 D.any:{if(!e[r])return!1;break}case D.string:{if(!e[r]||Array.isArray(e[r]))return!1;break}case D.array:{if(!e[r]||!Array.isArray(e[r]))return!1;break}case D.number:{if(!e[r]||Array.isArray(e[r])||isNaN(parseInt(e[r]))&&isNaN(parseFloat(e[r])))return!1;break}}}return!0}function Pe(e,t){const r={};for(const n in t){const a=t[n],f=e[n];if(Array.isArray(a)){r[n]=f==="1"||f==="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(f);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 D.any:case D.string:case D.array:{r[n]=e[n];break}case D.number:{const o=e[n];r[n]=isNaN(parseInt(o))?parseFloat(o):parseInt(o);break}}}return r}function Ae(e,t){return r=>{const{parameters:n,forRoutes:a}=r,f=u.createEvent({name:"entered",sid:"-d3obu6"}),o=u.createEvent({name:"exited",sid:"-xofyk3"}),p=u.createEvent({name:"exit",sid:"-673d76"});return u.sample({and:[{source:{activeRoutes:e,query:t},filter:O=>{let{activeRoutes:F,query:S}=O;return(!a||Z(a,F))&&ee(S,n)},fn:O=>{let{query:F}=O;return Pe(F,n)}}],or:{sid:"-so0f9q"}}),u.sample({and:[{source:{activeRoutes:e,query:t},filter:O=>{let{activeRoutes:F,query:S}=O;return!((!a||Z(a,F))&&ee(S,n))},target:o}],or:{sid:"-s82e29"}}),{entered:f,exited:o,exit:p,getPayload:O=>Object.entries(O).reduce((F,S)=>{let[$,A]=S;return typeof n[$]=="symbol"?F[$]=A:F[$]=n[$],F},{})}}}var H,re;function Ne(){return re||(re=1,H=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,a,f;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(a=n;a--!==0;)if(!e(t[a],r[a]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(f=Object.keys(t),n=f.length,n!==Object.keys(r).length)return!1;for(a=n;a--!==0;)if(!Object.prototype.hasOwnProperty.call(r,f[a]))return!1;for(a=n;a--!==0;){var o=f[a];if(!e(t[o],r[o]))return!1}return!0}return t!==t&&r!==r}),H}var Re=Ne();const De=xe(Re),ie="%[a-f0-9]{2}",te=new RegExp("("+ie+")|([^%]+?)","gi"),ne=new RegExp("("+ie+")+","gi");function K(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([],K(r),K(n))}function Ie(e){try{return decodeURIComponent(e)}catch{let t=e.match(te)||[];for(let r=1;r<t.length;r++)e=K(t,r).join(""),t=e.match(te)||[];return e}}function ke(e){const t={"%FE%FF":"��","%FF%FE":"��"};let r=ne.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=ne.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 Ce(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 Te(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 ce(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 _e=e=>e==null,qe=e=>encodeURIComponent(e).replaceAll(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),J=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,[E(t,e),"[",a,"]"].join("")]:[...r,[E(t,e),"[",E(a,e),"]=",E(n,e)].join("")]};case"bracket":return t=>(r,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?r:n===null?[...r,[E(t,e),"[]"].join("")]:[...r,[E(t,e),"[]=",E(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,[E(t,e),":list="].join("")]:[...r,[E(t,e),":list=",E(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?[[E(r,e),t,E(a,e)].join("")]:[[n,E(a,e)].join(e.arrayFormatSeparator)])}default:return t=>(r,n)=>n===void 0||e.skipNull&&n===null||e.skipEmptyString&&n===""?r:n===null?[...r,E(t,e)]:[...r,[E(t,e),"=",E(n,e)].join("")]}}function Me(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),o=typeof n=="string"&&!f&&R(n,e).includes(e.arrayFormatSeparator);n=o?R(n,e):n;const p=f||o?n.split(e.arrayFormatSeparator).map(O=>R(O,e)):n===null?n:R(n,e);a[r]=p};case"bracket-separator":return(r,n,a)=>{const f=/(\[])$/.test(r);if(r=r.replace(/\[]$/,""),!f){a[r]=n&&R(n,e);return}const o=n===null?[]:R(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 fe(e){if(typeof e!="string"||e.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function E(e,t){return t.encode?t.strict?qe(e):encodeURIComponent(e):e}function R(e,t){return t.decode?Ce(e):e}function ue(e){return Array.isArray(e)?e.sort():typeof e=="object"?ue(Object.keys(e)).sort((t,r)=>Number(t)-Number(r)).map(t=>e[t]):e}function le(e){const t=e.indexOf("#");return t!==-1&&(e=e.slice(0,t)),e}function Le(e){let t="";const r=e.indexOf("#");return r!==-1&&(t=e.slice(r)),t}function ae(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=le(e);const t=e.indexOf("?");return t===-1?"":e.slice(t+1)}function W(e,t){t={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,types:Object.create(null),...t},fe(t.arrayFormatSeparator);const r=Me(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[o,p]=ce(f,"=");o===void 0&&(o=f),p=p===void 0?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?p:R(p,t),r(R(o,t),p,n)}for(const[a,f]of Object.entries(n))if(typeof f=="object"&&f!==null&&t.types[a]!=="string")for(const[o,p]of Object.entries(f)){const O=t.types[a]?t.types[a].replace("[]",""):void 0;f[o]=ae(p,t,O)}else typeof f=="object"&&f!==null&&t.types[a]==="string"?n[a]=Object.values(f).join(t.arrayFormatSeparator):n[a]=ae(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 o=n[f];return a[f]=o&&typeof o=="object"&&!Array.isArray(o)?ue(o):o,a},Object.create(null))}function pe(e,t){if(!e)return"";t={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...t},fe(t.arrayFormatSeparator);const r=o=>t.skipNull&&_e(e[o])||t.skipEmptyString&&e[o]==="",n=Ue(t),a={};for(const[o,p]of Object.entries(e))r(o)||(a[o]=p);const f=Object.keys(a);return t.sort!==!1&&f.sort(t.sort),f.map(o=>{const p=e[o];return p===void 0?"":p===null?E(o,t):Array.isArray(p)?p.length===0&&t.arrayFormat==="bracket-separator"?E(o,t)+"[]":p.reduce(n(o),[]).join("&"):E(o,t)+"="+E(p,t)}).filter(o=>o.length>0).join("&")}function de(e,t){var a;t={decode:!0,...t};let[r,n]=ce(e,"#");return r===void 0&&(r=e),{url:((a=r==null?void 0:r.split("?"))==null?void 0:a[0])??"",query:W(Q(e),t),...t&&t.parseFragmentIdentifier&&n?{fragmentIdentifier:R(n,t)}:{}}}function me(e,t){t={encode:!0,strict:!0,[J]:!0,...t};const r=le(e.url).split("?")[0]||"",n=Q(e.url),a={...W(n,{sort:!1}),...e.query};let f=pe(a,t);f&&(f=`?${f}`);let o=Le(e.url);if(typeof e.fragmentIdentifier=="string"){const p=new URL(r);p.hash=e.fragmentIdentifier,o=t[J]?p.hash:`#${e.fragmentIdentifier}`}return`${r}${f}${o}`}function ye(e,t,r){r={parseFragmentIdentifier:!0,[J]:!1,...r};const{url:n,query:a,fragmentIdentifier:f}=de(e,r);return me({url:n,query:Te(a,t),fragmentIdentifier:f},r)}function Be(e,t,r){const n=Array.isArray(t)?a=>!t.includes(a):(a,f)=>!t(a,f);return ye(e,n,r)}const V=Object.freeze(Object.defineProperty({__proto__:null,exclude:Be,extract:Q,parse:W,parseUrl:de,pick:ye,stringify:pe,stringifyUrl:me},Symbol.toStringTag,{value:"Module"}));function se(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 oe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?se(Object(r),!0).forEach(function(n){ze(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):se(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function ze(e,t,r){return(t=He(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function He(e){var t=Ve(e,"string");return typeof t=="symbol"?t:t+""}function Ve(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 Ke(e){const{base:t="/",routes:r}=e,n=u.createStore(null,{and:{serialize:"ignore"},name:"$history",sid:"3inwxx"}),a=u.createStore([],{and:{serialize:"ignore"},name:"$activeRoutes",sid:"mrug12"}),f=u.createStore({},{name:"$query",sid:"f7je63"}),o=u.createStore(null,{name:"$path",sid:"x787cm"}),p=u.createEvent({name:"setHistory",sid:"ttprsh"}),O=u.createEvent({name:"navigate",sid:"-66otyw"}),F=u.createEvent({name:"back",sid:"-ggh63w"}),S=u.createEvent({name:"forward",sid:"-56hk26"}),$=u.createEvent({name:"locationUpdated",sid:"f4sbpu"}),A=r.map(g=>{let b=g;const m=[];for(m.unshift(b.internal.path);b.internal.parent;)b=b.internal.parent,b.internal.path!=="/"&&m.unshift(b.internal.path);const x=t==="/"?m.join(""):[t,...m].join("");return{route:g,path:x,toPath:Y.compile(x),fromPath:Y.match(x)}}),I=u.attach({and:{source:{history:n},effect:async(g,b)=>{let{history:m}=g,{path:x,query:M,replace:q}=b;if(!m)throw new Error("history not found");const L={pathname:x,search:"?".concat(V.stringify(M))};q?m.replace(L):m.push(L)}},or:{name:"navigateFx",sid:"ekldni"}}),_=u.createEffect(g=>{const b=u.scopeBind($);if(b({pathname:g.location.pathname,query:oe({},V.parse(g.location.search))}),!g)throw new Error;g.listen(m=>{let{location:x}=m;b({pathname:x.pathname,query:oe({},V.parse(x.search))})})},{name:"subscribeHistoryFx",sid:"2y4bcv"}),j=u.attach({and:{source:{query:f,path:o},effect:async g=>{let{query:b,path:m}=g;for(const{route:x,fromPath:M}of A){const q=M(m);if(q)await x.internal.openFx({query:b,params:q.params,historyIgnore:!0});else{x.internal.close();continue}}}},or:{name:"openRoutesByPathFx",sid:"-788q6"}});for(const{route:g,toPath:b}of A)u.sample({and:[{clock:g.opened,source:a,filter:m=>!m.includes(g),fn:m=>[...m,g],target:a}],or:{sid:"f1aram"}}),u.sample({and:[{clock:g.opened,filter:m=>!(m!=null&&m.historyIgnore),fn:m=>{var x;return{path:b(m&&"params"in m?m.params:void 0),query:(x=m==null?void 0:m.query)!==null&&x!==void 0?x:{},replace:m==null?void 0:m.replace}},target:O}],or:{sid:"fh8si3"}}),u.sample({and:[{clock:g.closed,source:a,fn:m=>m.filter(x=>x!==g),target:a}],or:{sid:"gcl2bo"}});return u.sample({and:[{clock:p,target:n}],or:{sid:"gsj3hf"}}),u.sample({and:[{clock:n,filter:Boolean,target:_}],or:{sid:"gva2g8"}}),u.sample({and:[{clock:$,source:{query:f,path:o},filter:(g,b)=>{let{query:m,path:x}=g;return x!==b.pathname||!De(m,b.query)},fn:(g,b)=>({path:b.pathname,query:b.query}),target:[u.withFactory({sid:"-396exf",fn:()=>he.spread({targets:{path:o,query:f}}),name:"target",method:"spread"}),j]}],or:{sid:"ha4igz"}}),u.sample({and:[{clock:O,target:I}],or:{sid:"i87r9d"}}),u.sample({and:[{clock:[f,o],source:{query:f,path:o},fn:g=>g,target:O}],or:{sid:"iayq86"}}),{$query:f,$path:o,$activeRoutes:a,back:F,forward:S,navigate:O,routes:r,setHistory:p,mappedRoutes:A,trackQuery:Ae(a,f),"@@unitShape":()=>({query:f,path:o,activeRoutes:a,onBack:F,onForward:S,onNavigate:O})}}exports.createRoute=je;exports.createRouter=Ke;exports.parameters=D;
package/dist/index.d.ts CHANGED
@@ -24,6 +24,12 @@ export declare function createRoute<T extends string, Params = SafeParams<ParseU
24
24
 
25
25
  export declare function createRouter(config: RouterConfig): Router;
26
26
 
27
+ declare type NavigatePayload = {
28
+ path: string;
29
+ query: Query;
30
+ replace?: boolean;
31
+ };
32
+
27
33
  declare type NumberParameter = typeof numberSymbol;
28
34
 
29
35
  declare const numberSymbol: unique symbol;
@@ -64,7 +70,7 @@ declare type ReadyConfig<T extends RawConfig> = {
64
70
  [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;
65
71
  };
66
72
 
67
- export declare interface Route<T> {
73
+ export declare interface Route<T = void> {
68
74
  $params: Store<T>;
69
75
  $isOpened: Store<boolean>;
70
76
  $isPending: Store<boolean>;
@@ -91,6 +97,7 @@ export declare interface Router {
91
97
  $activeRoutes: Store<Route<any>[]>;
92
98
  back: EventCallable<void>;
93
99
  forward: EventCallable<void>;
100
+ navigate: EventCallable<NavigatePayload>;
94
101
  setHistory: EventCallable<History_2>;
95
102
  routes: Route<any>[];
96
103
  trackQuery: <ParametersConfig extends RawConfig>(config: QueryTrackerConfig<ParametersConfig>) => QueryTracker<ParametersConfig>;
@@ -106,6 +113,7 @@ export declare interface Router {
106
113
  activeRoutes: Store<Route<any>[]>;
107
114
  onBack: EventCallable<void>;
108
115
  onForward: EventCallable<void>;
116
+ onNavigate: EventCallable<NavigatePayload>;
109
117
  };
110
118
  }
111
119