driftjs-router 0.0.17 → 0.0.18
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.js +1 -1
- package/dist/index-es.js +37 -36
- package/package.json +5 -5
package/dist/index-cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);let t=require("driftjs-shared");function n(e){if(!e||e===`/`)return`/`;let t=e.replace(/\/+/g,`/`);return t.startsWith(`/`)||(t=`/`+t),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}function r(e){if(!e)return``;let t=e.trim();return t.startsWith(`/`)||(t=`/`+t),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t===`/`?``:t}function i(e,t){if(!t)return e;if(e.startsWith(t)){let n=e.slice(t.length);return n.startsWith(`/`)?n:`/`+n}return e}function a(e,t){let n=t.startsWith(`/`)?t:`/`+t;return e?e+n:n}function o(e,t){let n=t.startsWith(`/`)?t:`/`+t;return(e||``)+`#`+n}function s(){let e=[];return{get list(){return e},listen(t){return e.push(t),()=>{let n=e.indexOf(t);n!==-1&&e.splice(n,1)}},notify(t,n,r){for(let i of e)i(t,n,r)},clear(){e.length=0}}}function c(e){if(typeof window>`u`)return null;let t=e??window.history.state;if(!t||typeof t!=`object`)return t??null;let{__drift_pos:n,__drift_has_data:r,...i}=t;return Object.keys(i).length>0||r?i:null}function l(e,t){return{...e||{},__drift_pos:t,...e===void 0?{}:{__drift_has_data:!0}}}function u(e=``){let t=r(e),n=s(),o=()=>typeof window>`u`?`/`:window.location.pathname+window.location.search+window.location.hash,u=()=>i(o(),t)||`/`,d=u(),f=typeof window<`u`&&window.history.state&&typeof window.history.state.__drift_pos==`number`?window.history.state.__drift_pos:0;if(typeof window<`u`&&(window.history.state==null||typeof window.history.state.__drift_pos!=`number`)){let e=window.history.state||{};window.history.replaceState({...e,__drift_pos:f},``,a(t,d))}let p=e=>{let t=d,r=u();d=r;let i=typeof window<`u`&&window.history.state||e.state||null,a=i&&typeof i.__drift_pos==`number`?i.__drift_pos:f,o=a-f;f=a;let s={direction:o>0?`forward`:o<0?`back`:`unknown`,delta:o,type:`pop`};n.notify(r,t,s)};return typeof window<`u`&&window.addEventListener(`popstate`,p),{get base(){return t},get location(){return u()},get state(){return c(window.history.state)},listen(e){return n.listen(e)},push(e,n){if(typeof window>`u`)return;f++;let r=a(t,e),i=l(n,f);window.history.pushState(i,``,r),d=e},replace(e,n){if(typeof window>`u`)return;let r=a(t,e),i=l(n,f);window.history.replaceState(i,``,r),d=e},go(e){typeof window<`u`&&window.history.go(e)},destroy(){typeof window<`u`&&window.removeEventListener(`popstate`,p),n.clear()}}}function d(e=``){let t=r(e),n=s(),i=()=>{if(typeof window>`u`)return`/`;let e=window.location.hash;if(!e||e===`#`)return`/`;let t=e.startsWith(`#`)?e.slice(1):e;return t.startsWith(`/`)?t:`/`+t},a=i(),u=typeof window<`u`&&window.history.state&&typeof window.history.state.__drift_pos==`number`?window.history.state.__drift_pos:0;if(typeof window<`u`&&(window.history.state==null||typeof window.history.state.__drift_pos!=`number`)){let e=window.history.state||{};window.history.replaceState({...e,__drift_pos:u},``,o(t,a))}let d=e=>{let t=i();if(t===a)return;let r=a;a=t;let o=typeof window<`u`&&window.history.state||null,s=o&&typeof o.__drift_pos==`number`?o.__drift_pos:u,c=s-u;u=s;let l={direction:c>0?`forward`:c<0?`back`:`unknown`,delta:c,type:`pop`};n.notify(t,r,l)};return typeof window<`u`&&(window.addEventListener(`popstate`,d),window.addEventListener(`hashchange`,d)),{get base(){return t},get location(){return i()},get state(){return c(window.history.state)},listen(e){return n.listen(e)},push(e,n){if(typeof window>`u`)return;u++;let r=o(t,e),i=l(n,u);window.history.pushState(i,``,r),a=e},replace(e,n){if(typeof window>`u`)return;let r=o(t,e),i=l(n,u);window.history.replaceState(i,``,r),a=e},go(e){typeof window<`u`&&window.history.go(e)},destroy(){typeof window<`u`&&(window.removeEventListener(`popstate`,d),window.removeEventListener(`hashchange`,d)),n.clear()}}}function f(e=`/`,t=``){let n=r(t),a=[i(e.startsWith(`/`)?e:`/`+e,n)||`/`],o=[null],s=0,c=[];return{get base(){return n},get location(){return a[s]??`/`},get state(){return o[s]??null},listen(e){return c.push(e),()=>{let t=c.indexOf(e);t!==-1&&c.splice(t,1)}},push(e,t){let n=e.startsWith(`/`)?e:`/`+e;a.splice(s+1),o.splice(s+1),a.push(n),o.push(t||null),s++},replace(e,t){let n=e.startsWith(`/`)?e:`/`+e;a[s]=n,o[s]=t||null},go(e){let t=a[s]??`/`,n=s+e;if(n>=0&&n<a.length){s=n;let r=a[s]??`/`,i={direction:e>0?`forward`:e<0?`back`:`unknown`,delta:e,type:`pop`};for(let e of c)e(r,t,i)}},destroy(){c.length=0,a.length=0,o.length=0,s=0}}}var p=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PathError=e.TokenData=void 0,e.compile=l,e.pathToRegexp=f;var t=`/`,n=e=>e,r=/^[$_\p{ID_Start}]$/u,i=/^[$\u200c\u200d\p{ID_Continue}]$/u;function a(e){return e.replace(/[.+*?^${}()[\]|/\\]/g,`\\$&`)}var o=class{constructor(e,t){this.tokens=e,this.originalPath=t}};e.TokenData=o;var s=class extends TypeError{constructor(e,t){let n=e;t&&(n+=`: ${t}`),n+=`; visit https://git.new/pathToRegexpError for info`,super(n),this.originalPath=t}};e.PathError=s;function c(e,t={}){let{encodePath:a=n}=t,c=[...e],l=0;function u(t){let n=[],o=``;function d(){o&&=(n.push({type:`text`,value:a(o)}),``)}for(;l<c.length;){let a=c[l++];if(a===t)return d(),n;if(a===`\\`){if(l===c.length)throw new s(`Unexpected end after \\ at index ${l}`,e);o+=c[l++];continue}if(a===`:`||a===`*`){let t=a===`:`?`param`:`wildcard`,o=``;if(r.test(c[l]))do o+=c[l++];while(i.test(c[l]));else if(c[l]===`"`){let t=l;for(;l<c.length;){if(c[++l]===`"`){l++,t=0;break}c[l]===`\\`&&l++,o+=c[l]}if(t)throw new s(`Unterminated quote at index ${t}`,e)}if(!o)throw new s(`Missing parameter name at index ${l}`,e);d(),n.push({type:t,name:o});continue}if(a===`{`){d(),n.push({type:`group`,tokens:u(`}`)});continue}if(a===`}`||a===`(`||a===`)`||a===`[`||a===`]`||a===`+`||a===`?`||a===`!`)throw new s(`Unexpected ${a} at index ${l-1}`,e);o+=a}if(t)throw new s(`Unexpected end at index ${l}, expected ${t}`,e);return d(),n}return new o(u(``),e)}function l(e,n={}){let{encode:r=encodeURIComponent,delimiter:i=t}=n,a=u((typeof e==`object`?e:c(e,n)).tokens,i,r);return function(e={}){let t=[],n=a(e,t);if(t.length)throw TypeError(`Missing parameters: ${t.join(`, `)}`);return n}}function u(e,t,n){let r=e.map(e=>d(e,t,n));return(e,t)=>{let n=``;for(let i of r)n+=i(e,t);return n}}function d(e,t,r){if(e.type===`text`)return()=>e.value;if(e.type===`group`){let n=u(e.tokens,t,r);return(e,t)=>{let r=t.length,i=n(e,t);return t.length===r?i:(t.length=r,``)}}let i=r||n;return e.type===`wildcard`&&r!==!1?(n,r)=>{let a=n[e.name];if(a==null)return r.push(e.name),``;if(!Array.isArray(a)||a.length===0)throw TypeError(`Expected "${e.name}" to be a non-empty array`);let o=``;for(let n=0;n<a.length;n++){if(typeof a[n]!=`string`)throw TypeError(`Expected "${e.name}/${n}" to be a string`);n>0&&(o+=t),o+=i(a[n])}return o}:(t,n)=>{let r=t[e.name];if(r==null)return n.push(e.name),``;if(typeof r!=`string`)throw TypeError(`Expected "${e.name}" to be a string`);return i(r)}}function f(e,n={}){let{delimiter:r=t,end:i=!0,sensitive:o=!1,trailing:l=!0}=n,u=[],d=``,f=0;function h(e){if(Array.isArray(e)){for(let t of e)h(t);return}let t=typeof e==`object`?e:c(e,n);p(t.tokens,0,[],e=>{if(f>=256)throw new s(`Too many path combinations`,t.originalPath);f>0&&(d+=`|`),d+=m(e,r,u,t.originalPath),f++})}h(e);let g=`^(?:${d})`;return l&&(g+=`(?:`+a(r)+`$)?`),g+=i?`$`:`(?=`+a(r)+`|$)`,{regexp:new RegExp(g,o?``:`i`),keys:u}}function p(e,t,n,r){for(;t<e.length;){let i=e[t++];if(i.type===`group`){let a=n.length;p(i.tokens,0,n,n=>p(e,t,n,r)),n.length=a;continue}n.push(i)}r(n)}function m(e,t,n,r){let i=``,o=``,c=``,l=0,u=0,d=0;function f(n,r){for(;n<e.length;){let i=e[n++];if(i.type===r)return!0;if(i.type===`text`&&i.value.includes(t))break}return!1}function p(t){let n=``;for(;t<e.length;){let r=e[t++];if(r.type!==`text`)break;n+=r.value}return n}for(;d<e.length;){let m=e[d++];if(m.type===`text`){i+=a(m.value),o+=m.value,l===2&&(c+=m.value),m.value.includes(t)&&(u=0);continue}if(m.type===`param`||m.type===`wildcard`){if(l&&!o)throw new s(`Missing text before "${m.name}" ${m.type}`,r);m.type===`param`?(i+=u&2?`(${h(t,o)}+)`:f(d,`wildcard`)?`(${h(t,p(d))}+)`:u&1?`(${h(t,o)}+|${a(o)})`:`(${h(t,``)}+)`,u|=l=1):(i+=u&2?`(${h(o,``)}+)`:c?`(${h(c,``)}+|${h(t,``)}+)`:`([^]+)`,c=``,u|=l=2),n.push(m),o=``;continue}throw TypeError(`Unknown token type: ${m.type}`)}return i}function h(e,t){return t.length>e.length?h(t,e):(e===t&&(t=``),t.length>1?`(?:(?!${a(e)}|${a(t)})[^])`:e.length>1?`(?:(?!${a(e)})[^${a(t)}])`:`[^${a(e+t)}]`)}}))();function m(e){try{return decodeURIComponent(e)}catch{return e}}function h(e){let t=Object.create(null);if(!e)return t;let n=e.startsWith(`?`)?e.slice(1):e;if(!n)return t;let r=new URLSearchParams(n),i=new Set;for(let e of r.keys()){if(e===`__proto__`||e===`constructor`||e===`prototype`||i.has(e))continue;i.add(e);let n=r.getAll(e);t[e]=n.length>1?n:n[0]??null}for(let e of n.split(`&`))if(e&&e.indexOf(`=`)===-1)try{let n=decodeURIComponent(e);n!==`__proto__`&&n!==`constructor`&&n!==`prototype`&&t[n]===``&&(t[n]=null)}catch{e!==`__proto__`&&e!==`constructor`&&e!==`prototype`&&t[e]===``&&(t[e]=null)}return t}function g(e){let t=Object.keys(e);if(t.length===0)return``;let n=[];for(let r of t){if(r===`__proto__`)continue;let t=e[r];if(t===void 0)continue;let i=encodeURIComponent(r);if(t===null)n.push(i);else if(Array.isArray(t))for(let e of t)e==null?n.push(i):n.push(`${i}=${encodeURIComponent(e)}`);else n.push(`${i}=${encodeURIComponent(t)}`)}return n.length>0?`?`+n.join(`&`):``}function _(e){let t=e.replace(/:([a-zA-Z0-9_$]+)\(\.\*\)\*?/g,`*$1`);t=t.replace(/\/\*$/,`/*pathMatch`),t=t.replace(/\/(:[a-zA-Z0-9_$]+)\?/g,`{/$1}`);let n=[],r=``,i=0;for(;i<t.length;)if(t[i]===`:`&&/[a-zA-Z0-9_$]/.test(t[i+1]||``)){let e=``;for(i++;i<t.length&&/[a-zA-Z0-9_$]/.test(t[i]);)e+=t[i],i++;if(r+=`:`+e,t[i]===`(`){let e=1,r=``;for(i++;i<t.length&&e>0;){if(t[i]===`\\`){r+=t[i]+(t[i+1]||``),i+=2;continue}if(t[i]===`(`)e++;else if(t[i]===`)`&&(e--,e===0)){i++;break}r+=t[i],i++}r&&n.push(r.replace(/(^|[^\\])\((?!\?)/g,`$1(?:`))}}else r+=t[i],i++;return{normalized:r,patterns:n}}function v(e,t){let n={};for(let[e,r]of Object.entries(t))r!=null&&(n[e]=Array.isArray(r)?r.join(`/`):String(r));let{normalized:r}=_(e);try{return(0,p.compile)(r,{encode:!1})(n)}catch{let e=r;for(let[t,r]of Object.entries(n))e=e.replace(RegExp(`:${t}\\b`,`g`),String(r)),e=e.replace(RegExp(`\\*${t}\\b`,`g`),String(r));return e=e.replace(/\{(\/[^}]+)\}/g,``),e}}function y(e){if(e===`/`||e===``)return{regex:/^\/?$/,paramNames:[],score:1e3};let{normalized:t,patterns:n}=_(e),{regexp:r,keys:i}=(0,p.pathToRegexp)(t,{sensitive:!1,end:!0}),a=r.source;for(let e of n)a=a.replace(`([^\\/]+)`,`(${e})`);let o=n.length>0?new RegExp(a,r.flags):r,s=i.map(e=>typeof e.name==`number`?`pathMatch`:String(e.name)),c=0;for(let t of e.split(`/`).filter(Boolean))t===`*`||t.includes(`(.*)`)||t.startsWith(`*`)?c+=1:t.includes(`:`)?t.includes(`(`)?c+=30:t.includes(`?`)?c+=15:c+=20:c+=100;return{regex:o,paramNames:s,score:c}}function b(e,t){let r=e.path;r=t?e.path.startsWith(`/`)?n(e.path):n(`${t.path===`/`?``:t.path}/${e.path}`):n(e.path);let{regex:i,paramNames:a,score:o}=y(r),s={};e.components?Object.assign(s,e.components):e.component&&(s.default=e.component);let c=e.beforeEnter?Array.isArray(e.beforeEnter)?e.beforeEnter:[e.beforeEnter]:void 0,l={};typeof e.props==`boolean`||typeof e.props==`function`?l.default=e.props:e.props&&typeof e.props==`object`&&(l=e.props);let u={path:r,name:e.name,components:s,children:[],meta:e.meta||{},beforeEnter:c,props:l,parent:t,regex:i,paramNames:a,score:o,redirect:e.redirect};return e.children&&e.children.length>0&&(u.children=e.children.map(e=>b(e,u))),u}function x(e){let t=[],r=new Map,i=[];function a(e,t){t.push(e),e.name&&r.set(e.name,e);for(let n of e.children)a(n,t)}function o(){r.clear();let e=[];for(let t of i)a(t,e);t=e.sort((e,t)=>{let n=e.score??0;return(t.score??0)-n})}for(let t of e)i.push(b(t));o();function s(e){let r=n(e);for(let e of t){let t=r.match(e.regex);if(t){let n={};for(let r=0;r<e.paramNames.length;r++){let i=e.paramNames[r],a=t[r+1];n[i]=a===void 0?``:m(a)}return{record:e,params:n}}}return{record:null,params:{}}}function c(e,t){let i=`/`,a={},o=``,c={},l;if(typeof e==`string`){let t=e.indexOf(`#`),n=e;t!==-1&&(o=e.slice(t),n=e.slice(0,t));let r=n.indexOf(`?`);r===-1?i=n:(a=h(n.slice(r)),i=n.slice(0,r))}else{if(e.name){l=e.name;let t=r.get(l);t&&(i=t.path,c={...e.params||{}},i=v(i,c))}else e.path&&(i=e.path);e.query&&(a={...e.query}),e.hash&&(o=e.hash.startsWith(`#`)?e.hash:`#`+e.hash),e.params&&(c={...c,...e.params})}i=n(i);let{record:u,params:d}=s(i),f={...d,...c},p=[];if(u){let e=u;for(;e;)p.unshift(e),e=e.parent}let m=g(a),_=i+m+o;return{path:i,fullPath:_,query:a,hash:o,params:f,name:u?.name||l,matched:p,meta:u?.meta||{},href:_}}return{resolve:c,addRoute(e,t){if(typeof e==`string`&&t){let n=r.get(e);if(n){let e=b(t,n);return n.children.push(e),o(),()=>{let t=n.children.indexOf(e);t!==-1&&(n.children.splice(t,1),o())}}}else if(typeof e==`object`){let t=b(e);return i.push(t),o(),()=>{let e=i.indexOf(t);e!==-1&&(i.splice(e,1),o())}}return()=>{}},removeRoute(e){let t=r.get(e);if(t){if(t.parent){let e=t.parent.children.indexOf(t);e!==-1&&t.parent.children.splice(e,1)}else{let e=i.indexOf(t);e!==-1&&i.splice(e,1)}o()}},hasRoute(e){return r.has(e)},getRoutes(){return[...t]}}}var S=function(e){return e[e.aborted=4]=`aborted`,e[e.cancelled=8]=`cancelled`,e[e.duplicated=16]=`duplicated`,e}({}),C=(0,t.createContext)(void 0,`DriftRouter`),w=(0,t.createContext)(void 0,`DriftRoute`),T=(0,t.createContext)(0,`DriftRouterDepth`),E=Object.freeze({path:`/`,fullPath:`/`,query:{},hash:``,params:{},name:void 0,matched:[],meta:{},href:`/`});function D(e,t,n,r){let i=`Navigation failed`;e===S.aborted?i=`Navigation aborted from "${t.fullPath}" to "${n.fullPath}" via a navigation guard.`:e===S.cancelled?i=`Navigation cancelled from "${t.fullPath}" to "${n.fullPath}" with a newer navigation.`:e===S.duplicated&&(i=`Avoided redundant navigation to current location: "${n.fullPath}".`);let a=Error(r||i);return a.name=`NavigationFailure`,a.type=e,a.from=t,a.to=n,a}function O(e,t){return!e||typeof e!=`object`||e.name!==`NavigationFailure`||typeof e.type!=`number`?!1:t===void 0||e.type===t}async function k(e){for(let t of e)for(let e of Object.keys(t.components)){let n=t.components[e];if(typeof n==`function`&&!(`__drift_fn__`in n)&&!n.bytecode)try{let r=await n();t.components[e]=r?.default||r}catch(e){throw console.error(`[DriftRouter] Failed to resolve async route component for path "${t.path}":`,e),e}}}async function A(e,t,n){for(let r of e){let e;try{let i=r(t,n);e=i instanceof Promise?await i:i}catch(e){return e instanceof Error?e:Error(String(e))}if(e!==void 0&&e!==!0)return e}return!0}function j(e){let{history:t,routes:n,scrollBehavior:r,linkActiveClass:i,linkExactActiveClass:a}=e,o=x(n),s=[],c=[],l=[],u=[],d=[],f=E,p=null,m=null,h=null;p=new Promise((e,t)=>{m=e,h=t});let g=0;function _(e){if(u.length>0)for(let t of u)t(e)}function v(e,t,n){if(typeof window<`u`&&r)try{let i=r(e,t,n);if(!i)return;let a=e=>{if(`el`in e){let t=typeof e.el==`string`?document.querySelector(e.el):e.el;t&&t.scrollIntoView({behavior:e.behavior||`auto`})}else window.scrollTo({left:e.left??window.scrollX,top:e.top??window.scrollY,behavior:e.behavior||`auto`})};i instanceof Promise?i.then(e=>{e&&a(e)}):a(i)}catch{}}async function y(e,n=!1,r=!1,i=0){if(i>20){let t=o.resolve(e,f);return D(S.aborted,f,t,`Infinite redirect loop detected`)}let a=o.resolve(e,f),u=f;if(a.matched.length>0){let e=a.matched[a.matched.length-1];if(e.redirect)return y(typeof e.redirect==`function`?e.redirect(a):e.redirect,!0,r,i+1)}if(u.fullPath===a.fullPath&&u!==E)return D(S.duplicated,u,a);let p=++g,m=[...s];for(let e of a.matched)e.beforeEnter&&m.push(...e.beforeEnter);let h=await A(m,a,u);if(p!==g)return D(S.cancelled,u,a);if(h===!1)return D(S.aborted,u,a);if(h instanceof Error)return _(h),D(S.aborted,u,a,h.message);if(typeof h==`string`||typeof h==`object`&&h)return y(h,n,r,i+1);try{await k(a.matched)}catch(e){return _(e),D(S.aborted,u,a,String(e))}if(p!==g)return D(S.cancelled,u,a);if(c.length>0){let e=await A(c,a,u);if(p!==g)return D(S.cancelled,u,a);if(e===!1)return D(S.aborted,u,a);if(e instanceof Error)return _(e),D(S.aborted,u,a,e.message);if(typeof e==`string`||typeof e==`object`&&e)return y(e,n,r,i+1)}r||(n?t.replace(a.fullPath):t.push(a.fullPath));let b=f;f=Object.freeze(a),v(f,b,t.state);for(let e of l)try{e(f,b)}catch(e){_(e)}for(let e of d)try{e(f,b)}catch(e){_(e)}}let b=t.listen(async(e,n,r)=>{let i=await y(e,!1,r.type===`pop`);i&&O(i,S.aborted)&&r.delta&&t.go(-r.delta)});return y(t.location||`/`,!0,!0).then(e=>{e&&e.type===S.aborted?(h&&h(e),_(e)):m&&m()}).catch(e=>{h&&h(e),_(e)}),{get currentRoute(){return f},get options(){return e},push(e){return y(e,!1)},replace(e){return y(e,!0)},go(e){t.go(e)},back(){t.go(-1)},forward(){t.go(1)},beforeEach(e){return s.push(e),()=>{let t=s.indexOf(e);t!==-1&&s.splice(t,1)}},beforeResolve(e){return c.push(e),()=>{let t=c.indexOf(e);t!==-1&&c.splice(t,1)}},afterEach(e){return l.push(e),()=>{let t=l.indexOf(e);t!==-1&&l.splice(t,1)}},onError(e){return u.push(e),()=>{let t=u.indexOf(e);t!==-1&&u.splice(t,1)}},isReady(){return p},resolve(e,t){return o.resolve(e,t||f)},addRoute(e,t){return o.addRoute(e,t)},removeRoute(e){o.removeRoute(e)},hasRoute(e){return o.hasRoute(e)},getRoutes(){return o.getRoutes()},subscribe(e){return d.push(e),()=>{let t=d.indexOf(e);t!==-1&&d.splice(t,1)}},destroy(){b(),s.length=0,c.length=0,l.length=0,u.length=0,d.length=0,t.destroy()}}}var M={bytecode:new Uint32Array([6,0,12,0,1,1,1,5,1,2,3,0,13,1,6,4,255,5,4,0,1]),constants:[{__drift_fn__:(e,t,n,r,i,a,o)=>{if(typeof o==`function`&&e?o(e,`router`,a(e,`RouterContext`).inject()):(e||{}).router=a(e,`RouterContext`).inject(),typeof o==`function`&&e?o(e,`depth`,a(e,`RouterDepthContext`).inject(0)):(e||{}).depth=a(e,`RouterDepthContext`).inject(0),typeof o==`function`&&e?o(e,`CurrentComponent`,null):(e||{}).CurrentComponent=null,a(e,`RouterDepthContext`).provide(a(e,`depth`)+1),(e||{}).updateCurrentComponent=function(){if(!a(e,`router`)||!a(e,`router`).currentRoute||!a(e,`router`).currentRoute.matched||!a(e,`router`).currentRoute.matched[a(e,`depth`)]){a(e,`CurrentComponent`)!==null&&(typeof n==`function`?n(e,`CurrentComponent`,null):(e||{}).CurrentComponent=null);return}a(e,`CurrentComponent`)!==(a(e,`router`).currentRoute.matched[a(e,`depth`)].components?.default||a(e,`router`).currentRoute.matched[a(e,`depth`)].component||null)&&(typeof n==`function`?n(e,`CurrentComponent`,a(e,`router`).currentRoute.matched[a(e,`depth`)].components?.default||a(e,`router`).currentRoute.matched[a(e,`depth`)].component||null):(e||{}).CurrentComponent=a(e,`router`).currentRoute.matched[a(e,`depth`)].components?.default||a(e,`router`).currentRoute.matched[a(e,`depth`)].component||null)},a(e,`updateCurrentComponent`)(),a(e,`router`)&&typeof a(e,`router`).subscribe==`function`){let t=a(e,`router`).subscribe((()=>{a(e,`updateCurrentComponent`)()}));typeof a(e,`onUnmount`)==`function`&&a(e,`onUnmount`)((()=>{t()}))}}},`div`,`class`,`drift-router-view`,{bytecode:[6,0,15,1,0,255,0,4,0,1],constants:[`CurrentComponent`],reactiveBindings:[]},[`CurrentComponent`],{__drift_fn__:(e,t,n,r,i,a)=>a(e,`CurrentComponent`)}],reactiveBindings:[],declaredVars:[`RouterContext`,`RouterDepthContext`,`onUnmount`,`router`,`depth`,`CurrentComponent`,`updateCurrentComponent`],derived:[],effects:[],scope:{RouterContext:C,RouterDepthContext:T,onUnmount:t.onUnmount}},N={bytecode:new Uint32Array([6,0,12,0,1,1,1,5,1,2,3,1,0,5,1,4,5,1,0,5,1,6,7,1,0,5,1,8,9,1,0,5,1,10,11,1,0,7,2,12,0,4,1,2,4,0,1]),constants:[{__drift_fn__:(e,t,n,r,i,a,o)=>{if(typeof o==`function`&&e?o(e,`router`,a(e,`RouterContext`).inject()):(e||{}).router=a(e,`RouterContext`).inject(),typeof o==`function`&&e?o(e,`to`,a(e,`props`).to||`/`):(e||{}).to=a(e,`props`).to||`/`,typeof o==`function`&&e?o(e,`replace`,a(e,`props`).replace||!1):(e||{}).replace=a(e,`props`).replace||!1,typeof o==`function`&&e?o(e,`target`,a(e,`props`).target||`_self`):(e||{}).target=a(e,`props`).target||`_self`,typeof o==`function`&&e?o(e,`rel`,a(e,`props`).rel||``):(e||{}).rel=a(e,`props`).rel||``,typeof o==`function`&&e?o(e,`customClass`,a(e,`props`).class||``):(e||{}).customClass=a(e,`props`).class||``,typeof o==`function`&&e?o(e,`label`,a(e,`props`).label||a(e,`props`).title||``):(e||{}).label=a(e,`props`).label||a(e,`props`).title||``,typeof o==`function`&&e?o(e,`currentPath`,a(e,`router`)&&a(e,`router`).currentRoute?a(e,`router`).currentRoute.path:``):(e||{}).currentPath=a(e,`router`)&&a(e,`router`).currentRoute?a(e,`router`).currentRoute.path:``,(e||{}).getHref=function(e,t){let n=e||`/`;return t?t.resolve(n).href:typeof n==`string`?n:n&&n.path?n.path:`#`},(e||{}).getActiveClass=function(e,t,n,r,i,a){let o=n||``;if(!t)return o;let s=e||`/`,c=t.resolve(s).path,l=t.currentRoute.path,u=r||t.options&&t.options.linkActiveClass||`router-link-active`,d=i||t.options&&t.options.linkExactActiveClass||`router-link-exact-active`;return l===c?(o?o+` `:``)+u+` `+d:c!==`/`&&l.startsWith(c.endsWith(`/`)?c:c+`/`)?(o?o+` `:``)+u:o},a(e,`router`)&&typeof a(e,`router`).subscribe==`function`){let t=a(e,`router`).subscribe((()=>{typeof n==`function`?n(e,`currentPath`,a(e,`router`).currentRoute.path):(e||{}).currentPath=a(e,`router`).currentRoute.path,typeof a(e,`__drift_mark_dirty__`)==`function`&&a(e,`__drift_mark_dirty__`)(`currentPath`)}));typeof a(e,`onUnmount`)==`function`&&a(e,`onUnmount`)((()=>{t()}))}(e||{}).handleClick=function(t){if(t.defaultPrevented||t.button!==0)return;let n=a(e,`props`).target||a(e,`target`);if(n&&n!==`_self`||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||(t.preventDefault(),!a(e,`router`)))return;let r=a(e,`props`).to||a(e,`to`)||`/`;a(e,`props`).replace||a(e,`replace`)?a(e,`router`).replace(r):a(e,`router`).push(r)}}},`a`,`href`,{__drift_fn__:(e,t,n,r,i,a)=>a(e,`getHref`)(a(e,`props`).to||a(e,`to`),a(e,`router`))},`class`,{__drift_fn__:(e,t,n,r,i,a)=>a(e,`getActiveClass`)(a(e,`props`).to||a(e,`to`),a(e,`router`),a(e,`props`).class||a(e,`customClass`),a(e,`props`).activeClass,a(e,`props`).exactActiveClass,a(e,`currentPath`))},`target`,{__drift_fn__:(e,t,n,r,i,a)=>a(e,`props`).target||a(e,`target`)},`rel`,{__drift_fn__:(e,t,n,r,i,a)=>a(e,`props`).rel||a(e,`rel`)},`onclick`,{__drift_fn__:(e,t,n,r,i,a)=>a(e,`handleClick`)},{__drift_fn__:(e,t,n,r,i,a)=>a(e,`props`).label||a(e,`props`).title||a(e,`label`)}],reactiveBindings:[{variable:`getHref`,positions:[7]},{variable:`to`,positions:[7,13]},{variable:`router`,positions:[7,13]},{variable:`getActiveClass`,positions:[13]},{variable:`customClass`,positions:[13]},{variable:`currentPath`,positions:[13]},{variable:`target`,positions:[19]},{variable:`rel`,positions:[25]},{variable:`handleClick`,positions:[31]},{variable:`label`,positions:[37]}],declaredVars:[`RouterContext`,`onUnmount`,`router`,`to`,`replace`,`target`,`rel`,`customClass`,`label`,`currentPath`,`getHref`,`getActiveClass`,`handleClick`],derived:[],effects:[],scope:{RouterContext:C,onUnmount:t.onUnmount}};exports.Link=N,exports.RouteContext=w,exports.RouterContext=C,exports.RouterDepthContext=T,exports.RouterView=M,exports.START_LOCATION_NORMALIZED=E,exports.buildHistoryState=l,exports.compilePathToRegex=y,exports.createHistoryListeners=s,exports.createHref=a,exports.createMatcher=x,exports.createMemoryHistory=f,exports.createNavigationFailure=D,exports.createRouter=j,exports.createWebHashHistory=d,exports.createWebHistory=u,exports.extractHistoryState=c,exports.formatHashHref=o,exports.isNavigationFailure=O,exports.normalizeBase=r,exports.normalizePath=n,exports.normalizeRouteRecord=b,exports.parseQuery=h,exports.stringifyQuery=g,exports.stripBase=i;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports);let t=require("driftjs-shared");function n(e){if(!e)return``;let t=e.trim();return t.startsWith(`/`)||(t=`/`+t),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t===`/`?``:t}function r(e,t){if(!t)return e;if(e.startsWith(t)){let n=e.slice(t.length);return n.startsWith(`/`)?n:`/`+n}return e}function i(e,t){let n=t.startsWith(`/`)?t:`/`+t;return e?e+n:n}function a(e,t){let n=t.startsWith(`/`)?t:`/`+t;return(e||``)+`#`+n}function o(){let e=[];return{get list(){return e},listen(t){return e.push(t),()=>{let n=e.indexOf(t);n!==-1&&e.splice(n,1)}},notify(t,n,r){for(let i of e)i(t,n,r)},clear(){e.length=0}}}function s(e){if(typeof window>`u`)return null;let t=e??window.history.state;if(!t||typeof t!=`object`)return t??null;let{__drift_pos:n,__drift_has_data:r,...i}=t;return Object.keys(i).length>0||r?i:null}function c(e,t){return{...e||{},__drift_pos:t,...e===void 0?{}:{__drift_has_data:!0}}}function l(e=``){let t=n(e),a=o(),l=()=>typeof window>`u`?`/`:window.location.pathname+window.location.search+window.location.hash,u=()=>r(l(),t)||`/`,d=u(),f=typeof window<`u`&&window.history.state&&typeof window.history.state.__drift_pos==`number`?window.history.state.__drift_pos:0;if(typeof window<`u`&&(window.history.state==null||typeof window.history.state.__drift_pos!=`number`)){let e=window.history.state||{};window.history.replaceState({...e,__drift_pos:f},``,i(t,d))}let p=e=>{let t=d,n=u();d=n;let r=typeof window<`u`&&window.history.state||e.state||null,i=r&&typeof r.__drift_pos==`number`?r.__drift_pos:f,o=i-f;f=i;let s={direction:o>0?`forward`:o<0?`back`:`unknown`,delta:o,type:`pop`};a.notify(n,t,s)};return typeof window<`u`&&window.addEventListener(`popstate`,p),{get base(){return t},get location(){return u()},get state(){return s(window.history.state)},listen(e){return a.listen(e)},push(e,n){if(typeof window>`u`)return;f++;let r=i(t,e),a=c(n,f);window.history.pushState(a,``,r),d=e},replace(e,n){if(typeof window>`u`)return;let r=i(t,e),a=c(n,f);window.history.replaceState(a,``,r),d=e},go(e){typeof window<`u`&&window.history.go(e)},destroy(){typeof window<`u`&&window.removeEventListener(`popstate`,p),a.clear()}}}function u(e=``){let t=n(e),r=o(),i=()=>{if(typeof window>`u`)return`/`;let e=window.location.hash;if(!e||e===`#`)return`/`;let t=e.startsWith(`#`)?e.slice(1):e;return t.startsWith(`/`)?t:`/`+t},l=i(),u=typeof window<`u`&&window.history.state&&typeof window.history.state.__drift_pos==`number`?window.history.state.__drift_pos:0;if(typeof window<`u`&&(window.history.state==null||typeof window.history.state.__drift_pos!=`number`)){let e=window.history.state||{};window.history.replaceState({...e,__drift_pos:u},``,a(t,l))}let d=e=>{let t=i();if(t===l)return;let n=l;l=t;let a=typeof window<`u`&&window.history.state||null,o=a&&typeof a.__drift_pos==`number`?a.__drift_pos:u,s=o-u;u=o;let c={direction:s>0?`forward`:s<0?`back`:`unknown`,delta:s,type:`pop`};r.notify(t,n,c)};return typeof window<`u`&&(window.addEventListener(`popstate`,d),window.addEventListener(`hashchange`,d)),{get base(){return t},get location(){return i()},get state(){return s(window.history.state)},listen(e){return r.listen(e)},push(e,n){if(typeof window>`u`)return;u++;let r=a(t,e),i=c(n,u);window.history.pushState(i,``,r),l=e},replace(e,n){if(typeof window>`u`)return;let r=a(t,e),i=c(n,u);window.history.replaceState(i,``,r),l=e},go(e){typeof window<`u`&&window.history.go(e)},destroy(){typeof window<`u`&&(window.removeEventListener(`popstate`,d),window.removeEventListener(`hashchange`,d)),r.clear()}}}function d(e=`/`,t=``){let i=n(t),a=[r(e.startsWith(`/`)?e:`/`+e,i)||`/`],o=[null],s=0,c=[];return{get base(){return i},get location(){return a[s]??`/`},get state(){return o[s]??null},listen(e){return c.push(e),()=>{let t=c.indexOf(e);t!==-1&&c.splice(t,1)}},push(e,t){let n=e.startsWith(`/`)?e:`/`+e;a.splice(s+1),o.splice(s+1),a.push(n),o.push(t||null),s++},replace(e,t){let n=e.startsWith(`/`)?e:`/`+e;a[s]=n,o[s]=t||null},go(e){let t=a[s]??`/`,n=s+e;if(n>=0&&n<a.length){s=n;let r=a[s]??`/`,i={direction:e>0?`forward`:e<0?`back`:`unknown`,delta:e,type:`pop`};for(let e of c)e(r,t,i)}},destroy(){c.length=0,a.length=0,o.length=0,s=0}}}var f=e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.PathError=e.TokenData=void 0,e.compile=l,e.pathToRegexp=f;var t=`/`,n=e=>e,r=/^[$_\p{ID_Start}]$/u,i=/^[$\u200c\u200d\p{ID_Continue}]$/u;function a(e){return e.replace(/[.+*?^${}()[\]|/\\]/g,`\\$&`)}var o=class{constructor(e,t){this.tokens=e,this.originalPath=t}};e.TokenData=o;var s=class extends TypeError{constructor(e,t){let n=e;t&&(n+=`: ${t}`),n+=`; visit https://git.new/pathToRegexpError for info`,super(n),this.originalPath=t}};e.PathError=s;function c(e,t={}){let{encodePath:a=n}=t,c=[...e],l=0;function u(t){let n=[],o=``;function d(){o&&=(n.push({type:`text`,value:a(o)}),``)}for(;l<c.length;){let a=c[l++];if(a===t)return d(),n;if(a===`\\`){if(l===c.length)throw new s(`Unexpected end after \\ at index ${l}`,e);o+=c[l++];continue}if(a===`:`||a===`*`){let t=a===`:`?`param`:`wildcard`,o=``;if(r.test(c[l]))do o+=c[l++];while(i.test(c[l]));else if(c[l]===`"`){let t=l;for(;l<c.length;){if(c[++l]===`"`){l++,t=0;break}c[l]===`\\`&&l++,o+=c[l]}if(t)throw new s(`Unterminated quote at index ${t}`,e)}if(!o)throw new s(`Missing parameter name at index ${l}`,e);d(),n.push({type:t,name:o});continue}if(a===`{`){d(),n.push({type:`group`,tokens:u(`}`)});continue}if(a===`}`||a===`(`||a===`)`||a===`[`||a===`]`||a===`+`||a===`?`||a===`!`)throw new s(`Unexpected ${a} at index ${l-1}`,e);o+=a}if(t)throw new s(`Unexpected end at index ${l}, expected ${t}`,e);return d(),n}return new o(u(``),e)}function l(e,n={}){let{encode:r=encodeURIComponent,delimiter:i=t}=n,a=u((typeof e==`object`?e:c(e,n)).tokens,i,r);return function(e={}){let t=[],n=a(e,t);if(t.length)throw TypeError(`Missing parameters: ${t.join(`, `)}`);return n}}function u(e,t,n){let r=e.map(e=>d(e,t,n));return(e,t)=>{let n=``;for(let i of r)n+=i(e,t);return n}}function d(e,t,r){if(e.type===`text`)return()=>e.value;if(e.type===`group`){let n=u(e.tokens,t,r);return(e,t)=>{let r=t.length,i=n(e,t);return t.length===r?i:(t.length=r,``)}}let i=r||n;return e.type===`wildcard`&&r!==!1?(n,r)=>{let a=n[e.name];if(a==null)return r.push(e.name),``;if(!Array.isArray(a)||a.length===0)throw TypeError(`Expected "${e.name}" to be a non-empty array`);let o=``;for(let n=0;n<a.length;n++){if(typeof a[n]!=`string`)throw TypeError(`Expected "${e.name}/${n}" to be a string`);n>0&&(o+=t),o+=i(a[n])}return o}:(t,n)=>{let r=t[e.name];if(r==null)return n.push(e.name),``;if(typeof r!=`string`)throw TypeError(`Expected "${e.name}" to be a string`);return i(r)}}function f(e,n={}){let{delimiter:r=t,end:i=!0,sensitive:o=!1,trailing:l=!0}=n,u=[],d=``,f=0;function h(e){if(Array.isArray(e)){for(let t of e)h(t);return}let t=typeof e==`object`?e:c(e,n);p(t.tokens,0,[],e=>{if(f>=256)throw new s(`Too many path combinations`,t.originalPath);f>0&&(d+=`|`),d+=m(e,r,u,t.originalPath),f++})}h(e);let g=`^(?:${d})`;return l&&(g+=`(?:`+a(r)+`$)?`),g+=i?`$`:`(?=`+a(r)+`|$)`,{regexp:new RegExp(g,o?``:`i`),keys:u}}function p(e,t,n,r){for(;t<e.length;){let i=e[t++];if(i.type===`group`){let a=n.length;p(i.tokens,0,n,n=>p(e,t,n,r)),n.length=a;continue}n.push(i)}r(n)}function m(e,t,n,r){let i=``,o=``,c=``,l=0,u=0,d=0;function f(n,r){for(;n<e.length;){let i=e[n++];if(i.type===r)return!0;if(i.type===`text`&&i.value.includes(t))break}return!1}function p(t){let n=``;for(;t<e.length;){let r=e[t++];if(r.type!==`text`)break;n+=r.value}return n}for(;d<e.length;){let m=e[d++];if(m.type===`text`){i+=a(m.value),o+=m.value,l===2&&(c+=m.value),m.value.includes(t)&&(u=0);continue}if(m.type===`param`||m.type===`wildcard`){if(l&&!o)throw new s(`Missing text before "${m.name}" ${m.type}`,r);m.type===`param`?(i+=u&2?`(${h(t,o)}+)`:f(d,`wildcard`)?`(${h(t,p(d))}+)`:u&1?`(${h(t,o)}+|${a(o)})`:`(${h(t,``)}+)`,u|=l=1):(i+=u&2?`(${h(o,``)}+)`:c?`(${h(c,``)}+|${h(t,``)}+)`:`([^]+)`,c=``,u|=l=2),n.push(m),o=``;continue}throw TypeError(`Unknown token type: ${m.type}`)}return i}function h(e,t){return t.length>e.length?h(t,e):(e===t&&(t=``),t.length>1?`(?:(?!${a(e)}|${a(t)})[^])`:e.length>1?`(?:(?!${a(e)})[^${a(t)}])`:`[^${a(e+t)}]`)}}))();function p(e){try{return decodeURIComponent(e)}catch{return e}}function m(e){let t=Object.create(null);if(!e)return t;let n=e.startsWith(`?`)?e.slice(1):e;if(!n)return t;let r=new URLSearchParams(n),i=new Set;for(let e of r.keys()){if(e===`__proto__`||e===`constructor`||e===`prototype`||i.has(e))continue;i.add(e);let n=r.getAll(e);t[e]=n.length>1?n:n[0]??null}for(let e of n.split(`&`))if(e&&e.indexOf(`=`)===-1)try{let n=decodeURIComponent(e);n!==`__proto__`&&n!==`constructor`&&n!==`prototype`&&t[n]===``&&(t[n]=null)}catch{e!==`__proto__`&&e!==`constructor`&&e!==`prototype`&&t[e]===``&&(t[e]=null)}return t}function h(e){let t=Object.keys(e);if(t.length===0)return``;let n=[];for(let r of t){if(r===`__proto__`)continue;let t=e[r];if(t===void 0)continue;let i=encodeURIComponent(r);if(t===null)n.push(i);else if(Array.isArray(t))for(let e of t)e==null?n.push(i):n.push(`${i}=${encodeURIComponent(e)}`);else n.push(`${i}=${encodeURIComponent(t)}`)}return n.length>0?`?`+n.join(`&`):``}function g(e){let t=e.replace(/:([a-zA-Z0-9_$]+)\(\.\*\)\*?/g,`*$1`);t=t.replace(/\/\*$/,`/*pathMatch`),t=t.replace(/\/(:[a-zA-Z0-9_$]+)\?/g,`{/$1}`);let n=[],r=``,i=0;for(;i<t.length;)if(t[i]===`:`&&/[a-zA-Z0-9_$]/.test(t[i+1]||``)){let e=``;for(i++;i<t.length&&/[a-zA-Z0-9_$]/.test(t[i]);)e+=t[i],i++;if(r+=`:`+e,t[i]===`(`){let e=1,r=``;for(i++;i<t.length&&e>0;){if(t[i]===`\\`){r+=t[i]+(t[i+1]||``),i+=2;continue}if(t[i]===`(`)e++;else if(t[i]===`)`&&(e--,e===0)){i++;break}r+=t[i],i++}r&&n.push(r.replace(/(^|[^\\])\((?!\?)/g,`$1(?:`))}}else r+=t[i],i++;return{normalized:r,patterns:n}}function _(e,t){let n={};for(let[e,r]of Object.entries(t))r!=null&&(n[e]=Array.isArray(r)?r.join(`/`):String(r));let{normalized:r}=g(e);try{return(0,f.compile)(r,{encode:!1})(n)}catch{let e=r;for(let[t,r]of Object.entries(n))e=e.replace(RegExp(`:${t}\\b`,`g`),String(r)),e=e.replace(RegExp(`\\*${t}\\b`,`g`),String(r));return e=e.replace(/\{(\/[^}]+)\}/g,``),e}}function v(e){if(e===`/`||e===``)return{regex:/^\/?$/,paramNames:[],score:1e3};let{normalized:t,patterns:n}=g(e),{regexp:r,keys:i}=(0,f.pathToRegexp)(t,{sensitive:!1,end:!0}),a=r.source;for(let e of n)a=a.replace(`([^\\/]+)`,`(${e})`);let o=n.length>0?new RegExp(a,r.flags):r,s=i.map(e=>typeof e.name==`number`?`pathMatch`:String(e.name)),c=0;for(let t of e.split(`/`).filter(Boolean))t===`*`||t.includes(`(.*)`)||t.startsWith(`*`)?c+=1:t.includes(`:`)?t.includes(`(`)?c+=30:t.includes(`?`)?c+=15:c+=20:c+=100;return{regex:o,paramNames:s,score:c}}function y(e,n){let r=e.path;if(n){if(e.path.startsWith(`/`))r=(0,t.normalizePath)(e.path);else{let i=n.path===`/`?``:n.path;r=(0,t.normalizePath)(`${i}/${e.path}`)}}else r=(0,t.normalizePath)(e.path);let{regex:i,paramNames:a,score:o}=v(r),s={};e.components?Object.assign(s,e.components):e.component&&(s.default=e.component);let c=e.beforeEnter?Array.isArray(e.beforeEnter)?e.beforeEnter:[e.beforeEnter]:void 0,l={};typeof e.props==`boolean`||typeof e.props==`function`?l.default=e.props:e.props&&typeof e.props==`object`&&(l=e.props);let u={path:r,name:e.name,components:s,children:[],meta:e.meta||{},beforeEnter:c,props:l,parent:n,regex:i,paramNames:a,score:o,redirect:e.redirect};return e.children&&e.children.length>0&&(u.children=e.children.map(e=>y(e,u))),u}function b(e){let n=[],r=new Map,i=[];function a(e,t){t.push(e),e.name&&r.set(e.name,e);for(let n of e.children)a(n,t)}function o(){r.clear();let e=[];for(let t of i)a(t,e);n=e.sort((e,t)=>{let n=e.score??0;return(t.score??0)-n})}for(let t of e)i.push(y(t));o();function s(e){let r=(0,t.normalizePath)(e);for(let e of n){let t=r.match(e.regex);if(t){let n={};for(let r=0;r<e.paramNames.length;r++){let i=e.paramNames[r],a=t[r+1];n[i]=a===void 0?``:p(a)}return{record:e,params:n}}}return{record:null,params:{}}}function c(e,n){let i=`/`,a={},o=``,c={},l;if(typeof e==`string`){let t=e.indexOf(`#`),n=e;t!==-1&&(o=e.slice(t),n=e.slice(0,t));let r=n.indexOf(`?`);r===-1?i=n:(a=m(n.slice(r)),i=n.slice(0,r))}else{if(e.name){l=e.name;let t=r.get(l);t&&(i=t.path,c={...e.params||{}},i=_(i,c))}else e.path&&(i=e.path);e.query&&(a={...e.query}),e.hash&&(o=e.hash.startsWith(`#`)?e.hash:`#`+e.hash),e.params&&(c={...c,...e.params})}i=(0,t.normalizePath)(i);let{record:u,params:d}=s(i),f={...d,...c},p=[];if(u){let e=u;for(;e;)p.unshift(e),e=e.parent}let g=h(a),v=i+g+o;return{path:i,fullPath:v,query:a,hash:o,params:f,name:u?.name||l,matched:p,meta:u?.meta||{},href:v}}return{resolve:c,addRoute(e,t){if(typeof e==`string`&&t){let n=r.get(e);if(n){let e=y(t,n);return n.children.push(e),o(),()=>{let t=n.children.indexOf(e);t!==-1&&(n.children.splice(t,1),o())}}}else if(typeof e==`object`){let t=y(e);return i.push(t),o(),()=>{let e=i.indexOf(t);e!==-1&&(i.splice(e,1),o())}}return()=>{}},removeRoute(e){let t=r.get(e);if(t){if(t.parent){let e=t.parent.children.indexOf(t);e!==-1&&t.parent.children.splice(e,1)}else{let e=i.indexOf(t);e!==-1&&i.splice(e,1)}o()}},hasRoute(e){return r.has(e)},getRoutes(){return[...n]}}}var x=function(e){return e[e.aborted=4]=`aborted`,e[e.cancelled=8]=`cancelled`,e[e.duplicated=16]=`duplicated`,e}({}),S=(0,t.createContext)(void 0,`DriftRouter`),C=(0,t.createContext)(void 0,`DriftRoute`),w=(0,t.createContext)(0,`DriftRouterDepth`),T=Object.freeze({path:`/`,fullPath:`/`,query:{},hash:``,params:{},name:void 0,matched:[],meta:{},href:`/`});function E(e,t,n,r){let i=`Navigation failed`;e===x.aborted?i=`Navigation aborted from "${t.fullPath}" to "${n.fullPath}" via a navigation guard.`:e===x.cancelled?i=`Navigation cancelled from "${t.fullPath}" to "${n.fullPath}" with a newer navigation.`:e===x.duplicated&&(i=`Avoided redundant navigation to current location: "${n.fullPath}".`);let a=Error(r||i);return a.name=`NavigationFailure`,a.type=e,a.from=t,a.to=n,a}function D(e,t){return!e||typeof e!=`object`||e.name!==`NavigationFailure`||typeof e.type!=`number`?!1:t===void 0||e.type===t}async function O(e){for(let t of e)for(let e of Object.keys(t.components)){let n=t.components[e];if(typeof n==`function`&&!(`__drift_fn__`in n)&&!n.bytecode)try{let r=await n();t.components[e]=r?.default||r}catch(e){throw console.error(`[DriftRouter] Failed to resolve async route component for path "${t.path}":`,e),e}}}async function k(e,t,n){for(let r of e){let e;try{let i=r(t,n);e=i instanceof Promise?await i:i}catch(e){return e instanceof Error?e:Error(String(e))}if(e!==void 0&&e!==!0)return e}return!0}function A(e){let{history:t,routes:n,scrollBehavior:r,linkActiveClass:i,linkExactActiveClass:a}=e,o=b(n),s=[],c=[],l=[],u=[],d=[],f=T,p=null,m=null,h=null;p=new Promise((e,t)=>{m=e,h=t});let g=0;function _(e){if(u.length>0)for(let t of u)t(e)}function v(e,t,n){if(typeof window<`u`&&r)try{let i=r(e,t,n);if(!i)return;let a=e=>{if(`el`in e){let t=typeof e.el==`string`?document.querySelector(e.el):e.el;t&&t.scrollIntoView({behavior:e.behavior||`auto`})}else window.scrollTo({left:e.left??window.scrollX,top:e.top??window.scrollY,behavior:e.behavior||`auto`})};i instanceof Promise?i.then(e=>{e&&a(e)}):a(i)}catch{}}async function y(e,n=!1,r=!1,i=0){if(i>20){let t=o.resolve(e,f);return E(x.aborted,f,t,`Infinite redirect loop detected`)}let a=o.resolve(e,f),u=f;if(a.matched.length>0){let e=a.matched[a.matched.length-1];if(e.redirect)return y(typeof e.redirect==`function`?e.redirect(a):e.redirect,!0,r,i+1)}if(u.fullPath===a.fullPath&&u!==T)return E(x.duplicated,u,a);let p=++g,m=[...s];for(let e of a.matched)e.beforeEnter&&m.push(...e.beforeEnter);let h=await k(m,a,u);if(p!==g)return E(x.cancelled,u,a);if(h===!1)return E(x.aborted,u,a);if(h instanceof Error)return _(h),E(x.aborted,u,a,h.message);if(typeof h==`string`||typeof h==`object`&&h)return y(h,n,r,i+1);try{await O(a.matched)}catch(e){return _(e),E(x.aborted,u,a,String(e))}if(p!==g)return E(x.cancelled,u,a);if(c.length>0){let e=await k(c,a,u);if(p!==g)return E(x.cancelled,u,a);if(e===!1)return E(x.aborted,u,a);if(e instanceof Error)return _(e),E(x.aborted,u,a,e.message);if(typeof e==`string`||typeof e==`object`&&e)return y(e,n,r,i+1)}r||(n?t.replace(a.fullPath):t.push(a.fullPath));let b=f;f=Object.freeze(a),v(f,b,t.state);for(let e of l)try{e(f,b)}catch(e){_(e)}for(let e of d)try{e(f,b)}catch(e){_(e)}}let S=t.listen(async(e,n,r)=>{let i=await y(e,!1,r.type===`pop`);i&&D(i,x.aborted)&&r.delta&&t.go(-r.delta)});return y(t.location||`/`,!0,!0).then(e=>{e&&e.type===x.aborted?(h&&h(e),_(e)):m&&m()}).catch(e=>{h&&h(e),_(e)}),{get currentRoute(){return f},get options(){return e},push(e){return y(e,!1)},replace(e){return y(e,!0)},go(e){t.go(e)},back(){t.go(-1)},forward(){t.go(1)},beforeEach(e){return s.push(e),()=>{let t=s.indexOf(e);t!==-1&&s.splice(t,1)}},beforeResolve(e){return c.push(e),()=>{let t=c.indexOf(e);t!==-1&&c.splice(t,1)}},afterEach(e){return l.push(e),()=>{let t=l.indexOf(e);t!==-1&&l.splice(t,1)}},onError(e){return u.push(e),()=>{let t=u.indexOf(e);t!==-1&&u.splice(t,1)}},isReady(){return p},resolve(e,t){return o.resolve(e,t||f)},addRoute(e,t){return o.addRoute(e,t)},removeRoute(e){o.removeRoute(e)},hasRoute(e){return o.hasRoute(e)},getRoutes(){return o.getRoutes()},subscribe(e){return d.push(e),()=>{let t=d.indexOf(e);t!==-1&&d.splice(t,1)}},destroy(){S(),s.length=0,c.length=0,l.length=0,u.length=0,d.length=0,t.destroy()}}}var j={bytecode:new Uint32Array([6,0,12,0,1,1,1,5,1,2,3,0,13,1,6,4,255,5,4,0,1]),constants:[{__drift_fn__:(e,t,n,r,i,a,o)=>{if(typeof o==`function`&&e?o(e,`router`,a(e,`RouterContext`).inject()):(e||{}).router=a(e,`RouterContext`).inject(),typeof o==`function`&&e?o(e,`depth`,a(e,`RouterDepthContext`).inject(0)):(e||{}).depth=a(e,`RouterDepthContext`).inject(0),typeof o==`function`&&e?o(e,`CurrentComponent`,null):(e||{}).CurrentComponent=null,a(e,`RouterDepthContext`).provide(a(e,`depth`)+1),(e||{}).updateCurrentComponent=function(){if(!a(e,`router`)||!a(e,`router`).currentRoute||!a(e,`router`).currentRoute.matched||!a(e,`router`).currentRoute.matched[a(e,`depth`)]){a(e,`CurrentComponent`)!==null&&(typeof n==`function`?n(e,`CurrentComponent`,null):(e||{}).CurrentComponent=null);return}a(e,`CurrentComponent`)!==(a(e,`router`).currentRoute.matched[a(e,`depth`)].components?.default||a(e,`router`).currentRoute.matched[a(e,`depth`)].component||null)&&(typeof n==`function`?n(e,`CurrentComponent`,a(e,`router`).currentRoute.matched[a(e,`depth`)].components?.default||a(e,`router`).currentRoute.matched[a(e,`depth`)].component||null):(e||{}).CurrentComponent=a(e,`router`).currentRoute.matched[a(e,`depth`)].components?.default||a(e,`router`).currentRoute.matched[a(e,`depth`)].component||null)},a(e,`updateCurrentComponent`)(),a(e,`router`)&&typeof a(e,`router`).subscribe==`function`){let t=a(e,`router`).subscribe((()=>{a(e,`updateCurrentComponent`)()}));typeof a(e,`onUnmount`)==`function`&&a(e,`onUnmount`)((()=>{t()}))}}},`div`,`class`,`drift-router-view`,{bytecode:[6,0,15,1,0,255,0,4,0,1],constants:[`CurrentComponent`],reactiveBindings:[]},[`CurrentComponent`],{__drift_fn__:(e,t,n,r,i,a)=>a(e,`CurrentComponent`)}],reactiveBindings:[],declaredVars:[`RouterContext`,`RouterDepthContext`,`onUnmount`,`router`,`depth`,`CurrentComponent`,`updateCurrentComponent`],derived:[],effects:[],scope:{RouterContext:S,RouterDepthContext:w,onUnmount:t.onUnmount}},M={bytecode:new Uint32Array([6,0,12,0,1,1,1,5,1,2,3,1,0,5,1,4,5,1,0,5,1,6,7,1,0,5,1,8,9,1,0,5,1,10,11,1,0,7,2,12,0,4,1,2,4,0,1]),constants:[{__drift_fn__:(e,t,n,r,i,a,o)=>{if(typeof o==`function`&&e?o(e,`router`,a(e,`RouterContext`).inject()):(e||{}).router=a(e,`RouterContext`).inject(),typeof o==`function`&&e?o(e,`to`,a(e,`props`).to||`/`):(e||{}).to=a(e,`props`).to||`/`,typeof o==`function`&&e?o(e,`replace`,a(e,`props`).replace||!1):(e||{}).replace=a(e,`props`).replace||!1,typeof o==`function`&&e?o(e,`target`,a(e,`props`).target||`_self`):(e||{}).target=a(e,`props`).target||`_self`,typeof o==`function`&&e?o(e,`rel`,a(e,`props`).rel||``):(e||{}).rel=a(e,`props`).rel||``,typeof o==`function`&&e?o(e,`customClass`,a(e,`props`).class||``):(e||{}).customClass=a(e,`props`).class||``,typeof o==`function`&&e?o(e,`label`,a(e,`props`).label||a(e,`props`).title||``):(e||{}).label=a(e,`props`).label||a(e,`props`).title||``,typeof o==`function`&&e?o(e,`currentPath`,a(e,`router`)&&a(e,`router`).currentRoute?a(e,`router`).currentRoute.path:``):(e||{}).currentPath=a(e,`router`)&&a(e,`router`).currentRoute?a(e,`router`).currentRoute.path:``,(e||{}).getHref=function(e,t){let n=e||`/`;return t?t.resolve(n).href:typeof n==`string`?n:n&&n.path?n.path:`#`},(e||{}).getActiveClass=function(e,t,n,r,i,a){let o=n||``;if(!t)return o;let s=e||`/`,c=t.resolve(s).path,l=t.currentRoute.path,u=r||t.options&&t.options.linkActiveClass||`router-link-active`,d=i||t.options&&t.options.linkExactActiveClass||`router-link-exact-active`;return l===c?(o?o+` `:``)+u+` `+d:c!==`/`&&l.startsWith(c.endsWith(`/`)?c:c+`/`)?(o?o+` `:``)+u:o},a(e,`router`)&&typeof a(e,`router`).subscribe==`function`){let t=a(e,`router`).subscribe((()=>{typeof n==`function`?n(e,`currentPath`,a(e,`router`).currentRoute.path):(e||{}).currentPath=a(e,`router`).currentRoute.path,typeof a(e,`__drift_mark_dirty__`)==`function`&&a(e,`__drift_mark_dirty__`)(`currentPath`)}));typeof a(e,`onUnmount`)==`function`&&a(e,`onUnmount`)((()=>{t()}))}(e||{}).handleClick=function(t){if(t.defaultPrevented||t.button!==0)return;let n=a(e,`props`).target||a(e,`target`);if(n&&n!==`_self`||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey||(t.preventDefault(),!a(e,`router`)))return;let r=a(e,`props`).to||a(e,`to`)||`/`;a(e,`props`).replace||a(e,`replace`)?a(e,`router`).replace(r):a(e,`router`).push(r)}}},`a`,`href`,{__drift_fn__:(e,t,n,r,i,a)=>a(e,`getHref`)(a(e,`props`).to||a(e,`to`),a(e,`router`))},`class`,{__drift_fn__:(e,t,n,r,i,a)=>a(e,`getActiveClass`)(a(e,`props`).to||a(e,`to`),a(e,`router`),a(e,`props`).class||a(e,`customClass`),a(e,`props`).activeClass,a(e,`props`).exactActiveClass,a(e,`currentPath`))},`target`,{__drift_fn__:(e,t,n,r,i,a)=>a(e,`props`).target||a(e,`target`)},`rel`,{__drift_fn__:(e,t,n,r,i,a)=>a(e,`props`).rel||a(e,`rel`)},`onclick`,{__drift_fn__:(e,t,n,r,i,a)=>a(e,`handleClick`)},{__drift_fn__:(e,t,n,r,i,a)=>a(e,`props`).label||a(e,`props`).title||a(e,`label`)}],reactiveBindings:[{variable:`getHref`,positions:[7]},{variable:`to`,positions:[7,13]},{variable:`router`,positions:[7,13]},{variable:`getActiveClass`,positions:[13]},{variable:`customClass`,positions:[13]},{variable:`currentPath`,positions:[13]},{variable:`target`,positions:[19]},{variable:`rel`,positions:[25]},{variable:`handleClick`,positions:[31]},{variable:`label`,positions:[37]}],declaredVars:[`RouterContext`,`onUnmount`,`router`,`to`,`replace`,`target`,`rel`,`customClass`,`label`,`currentPath`,`getHref`,`getActiveClass`,`handleClick`],derived:[],effects:[],scope:{RouterContext:S,onUnmount:t.onUnmount}};exports.Link=M,exports.RouteContext=C,exports.RouterContext=S,exports.RouterDepthContext=w,exports.RouterView=j,exports.START_LOCATION_NORMALIZED=T,exports.buildHistoryState=c,exports.compilePathToRegex=v,exports.createHistoryListeners=o,exports.createHref=i,exports.createMatcher=b,exports.createMemoryHistory=d,exports.createNavigationFailure=E,exports.createRouter=A,exports.createWebHashHistory=u,exports.createWebHistory=l,exports.extractHistoryState=s,exports.formatHashHref=a,exports.isNavigationFailure=D,exports.normalizeBase=n,Object.defineProperty(exports,"normalizePath",{enumerable:!0,get:function(){return t.normalizePath}}),exports.normalizeRouteRecord=y,exports.parseQuery=m,exports.stringifyQuery=h,exports.stripBase=r;
|
package/dist/index-es.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import { createContext as e,
|
|
1
|
+
import { createContext as e, normalizePath as t, onUnmount as n } from "driftjs-shared";
|
|
2
2
|
//#region \0rolldown/runtime.js
|
|
3
|
-
var
|
|
3
|
+
var r = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports);
|
|
4
4
|
//#endregion
|
|
5
5
|
//#region src/path.ts
|
|
6
|
-
function r(e) {
|
|
7
|
-
if (!e || e === "/") return "/";
|
|
8
|
-
let t = e.replace(/\/+/g, "/");
|
|
9
|
-
return t.startsWith("/") || (t = "/" + t), t.length > 1 && t.endsWith("/") && (t = t.slice(0, -1)), t;
|
|
10
|
-
}
|
|
11
6
|
function i(e) {
|
|
12
7
|
if (!e) return "";
|
|
13
8
|
let t = e.trim();
|
|
@@ -224,7 +219,7 @@ function p(e = "/", t = "") {
|
|
|
224
219
|
}
|
|
225
220
|
//#endregion
|
|
226
221
|
//#region src/matcher.ts
|
|
227
|
-
var m = (/* @__PURE__ */
|
|
222
|
+
var m = (/* @__PURE__ */ r(((e) => {
|
|
228
223
|
Object.defineProperty(e, "__esModule", { value: !0 }), e.PathError = e.TokenData = void 0, e.compile = l, e.pathToRegexp = f;
|
|
229
224
|
var t = "/", n = (e) => e, r = /^[$_\p{ID_Start}]$/u, i = /^[$\u200c\u200d\p{ID_Continue}]$/u;
|
|
230
225
|
function a(e) {
|
|
@@ -514,22 +509,28 @@ function b(e) {
|
|
|
514
509
|
score: c
|
|
515
510
|
};
|
|
516
511
|
}
|
|
517
|
-
function x(e,
|
|
518
|
-
let
|
|
519
|
-
|
|
520
|
-
|
|
512
|
+
function x(e, n) {
|
|
513
|
+
let r = e.path;
|
|
514
|
+
if (n) {
|
|
515
|
+
if (e.path.startsWith("/")) r = t(e.path);
|
|
516
|
+
else {
|
|
517
|
+
let i = n.path === "/" ? "" : n.path;
|
|
518
|
+
r = t(`${i}/${e.path}`);
|
|
519
|
+
}
|
|
520
|
+
} else r = t(e.path);
|
|
521
|
+
let { regex: i, paramNames: a, score: o } = b(r), s = {};
|
|
521
522
|
e.components ? Object.assign(s, e.components) : e.component && (s.default = e.component);
|
|
522
523
|
let c = e.beforeEnter ? Array.isArray(e.beforeEnter) ? e.beforeEnter : [e.beforeEnter] : void 0, l = {};
|
|
523
524
|
typeof e.props == "boolean" || typeof e.props == "function" ? l.default = e.props : e.props && typeof e.props == "object" && (l = e.props);
|
|
524
525
|
let u = {
|
|
525
|
-
path:
|
|
526
|
+
path: r,
|
|
526
527
|
name: e.name,
|
|
527
528
|
components: s,
|
|
528
529
|
children: [],
|
|
529
530
|
meta: e.meta || {},
|
|
530
531
|
beforeEnter: c,
|
|
531
532
|
props: l,
|
|
532
|
-
parent:
|
|
533
|
+
parent: n,
|
|
533
534
|
regex: i,
|
|
534
535
|
paramNames: a,
|
|
535
536
|
score: o,
|
|
@@ -538,16 +539,16 @@ function x(e, t) {
|
|
|
538
539
|
return e.children && e.children.length > 0 && (u.children = e.children.map((e) => x(e, u))), u;
|
|
539
540
|
}
|
|
540
541
|
function S(e) {
|
|
541
|
-
let
|
|
542
|
+
let n = [], r = /* @__PURE__ */ new Map(), i = [];
|
|
542
543
|
function a(e, t) {
|
|
543
|
-
t.push(e), e.name &&
|
|
544
|
+
t.push(e), e.name && r.set(e.name, e);
|
|
544
545
|
for (let n of e.children) a(n, t);
|
|
545
546
|
}
|
|
546
547
|
function o() {
|
|
547
|
-
|
|
548
|
+
r.clear();
|
|
548
549
|
let e = [];
|
|
549
550
|
for (let t of i) a(t, e);
|
|
550
|
-
|
|
551
|
+
n = e.sort((e, t) => {
|
|
551
552
|
let n = e.score ?? 0;
|
|
552
553
|
return (t.score ?? 0) - n;
|
|
553
554
|
});
|
|
@@ -555,9 +556,9 @@ function S(e) {
|
|
|
555
556
|
for (let t of e) i.push(x(t));
|
|
556
557
|
o();
|
|
557
558
|
function s(e) {
|
|
558
|
-
let
|
|
559
|
-
for (let e of
|
|
560
|
-
let t =
|
|
559
|
+
let r = t(e);
|
|
560
|
+
for (let e of n) {
|
|
561
|
+
let t = r.match(e.regex);
|
|
561
562
|
if (t) {
|
|
562
563
|
let n = {};
|
|
563
564
|
for (let r = 0; r < e.paramNames.length; r++) {
|
|
@@ -575,7 +576,7 @@ function S(e) {
|
|
|
575
576
|
params: {}
|
|
576
577
|
};
|
|
577
578
|
}
|
|
578
|
-
function c(e,
|
|
579
|
+
function c(e, n) {
|
|
579
580
|
let i = "/", a = {}, o = "", c = {}, l;
|
|
580
581
|
if (typeof e == "string") {
|
|
581
582
|
let t = e.indexOf("#"), n = e;
|
|
@@ -585,7 +586,7 @@ function S(e) {
|
|
|
585
586
|
} else {
|
|
586
587
|
if (e.name) {
|
|
587
588
|
l = e.name;
|
|
588
|
-
let t =
|
|
589
|
+
let t = r.get(l);
|
|
589
590
|
t && (i = t.path, c = { ...e.params || {} }, i = y(i, c));
|
|
590
591
|
} else e.path && (i = e.path);
|
|
591
592
|
e.query && (a = { ...e.query }), e.hash && (o = e.hash.startsWith("#") ? e.hash : "#" + e.hash), e.params && (c = {
|
|
@@ -593,7 +594,7 @@ function S(e) {
|
|
|
593
594
|
...e.params
|
|
594
595
|
});
|
|
595
596
|
}
|
|
596
|
-
i =
|
|
597
|
+
i = t(i);
|
|
597
598
|
let { record: u, params: d } = s(i), f = {
|
|
598
599
|
...d,
|
|
599
600
|
...c
|
|
@@ -619,12 +620,12 @@ function S(e) {
|
|
|
619
620
|
resolve: c,
|
|
620
621
|
addRoute(e, t) {
|
|
621
622
|
if (typeof e == "string" && t) {
|
|
622
|
-
let
|
|
623
|
-
if (
|
|
624
|
-
let e = x(t,
|
|
625
|
-
return
|
|
626
|
-
let t =
|
|
627
|
-
t !== -1 && (
|
|
623
|
+
let n = r.get(e);
|
|
624
|
+
if (n) {
|
|
625
|
+
let e = x(t, n);
|
|
626
|
+
return n.children.push(e), o(), () => {
|
|
627
|
+
let t = n.children.indexOf(e);
|
|
628
|
+
t !== -1 && (n.children.splice(t, 1), o());
|
|
628
629
|
};
|
|
629
630
|
}
|
|
630
631
|
} else if (typeof e == "object") {
|
|
@@ -637,7 +638,7 @@ function S(e) {
|
|
|
637
638
|
return () => {};
|
|
638
639
|
},
|
|
639
640
|
removeRoute(e) {
|
|
640
|
-
let t =
|
|
641
|
+
let t = r.get(e);
|
|
641
642
|
if (t) {
|
|
642
643
|
if (t.parent) {
|
|
643
644
|
let e = t.parent.children.indexOf(t);
|
|
@@ -650,10 +651,10 @@ function S(e) {
|
|
|
650
651
|
}
|
|
651
652
|
},
|
|
652
653
|
hasRoute(e) {
|
|
653
|
-
return
|
|
654
|
+
return r.has(e);
|
|
654
655
|
},
|
|
655
656
|
getRoutes() {
|
|
656
|
-
return [...
|
|
657
|
+
return [...n];
|
|
657
658
|
}
|
|
658
659
|
};
|
|
659
660
|
}
|
|
@@ -941,7 +942,7 @@ var N = {
|
|
|
941
942
|
scope: {
|
|
942
943
|
RouterContext: w,
|
|
943
944
|
RouterDepthContext: E,
|
|
944
|
-
onUnmount:
|
|
945
|
+
onUnmount: n
|
|
945
946
|
}
|
|
946
947
|
}, P = {
|
|
947
948
|
bytecode: new Uint32Array([
|
|
@@ -1093,8 +1094,8 @@ var N = {
|
|
|
1093
1094
|
effects: [],
|
|
1094
1095
|
scope: {
|
|
1095
1096
|
RouterContext: w,
|
|
1096
|
-
onUnmount:
|
|
1097
|
+
onUnmount: n
|
|
1097
1098
|
}
|
|
1098
1099
|
};
|
|
1099
1100
|
//#endregion
|
|
1100
|
-
export { P as Link, T as RouteContext, w as RouterContext, E as RouterDepthContext, N as RouterView, D as START_LOCATION_NORMALIZED, u as buildHistoryState, b as compilePathToRegex, c as createHistoryListeners, o as createHref, S as createMatcher, p as createMemoryHistory, O as createNavigationFailure, M as createRouter, f as createWebHashHistory, d as createWebHistory, l as extractHistoryState, s as formatHashHref, k as isNavigationFailure, i as normalizeBase,
|
|
1101
|
+
export { P as Link, T as RouteContext, w as RouterContext, E as RouterDepthContext, N as RouterView, D as START_LOCATION_NORMALIZED, u as buildHistoryState, b as compilePathToRegex, c as createHistoryListeners, o as createHref, S as createMatcher, p as createMemoryHistory, O as createNavigationFailure, M as createRouter, f as createWebHashHistory, d as createWebHistory, l as extractHistoryState, s as formatHashHref, k as isNavigationFailure, i as normalizeBase, t as normalizePath, x as normalizeRouteRecord, g as parseQuery, _ as stringifyQuery, a as stripBase };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "driftjs-router",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "Client-side SPA router for DriftJS with history, hash, and memory drivers, dynamic route parameters, nested routes/outlets, scroll restoration, and navigation guards.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"driftjs",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"path-to-regexp": "8.4.2",
|
|
33
|
-
"driftjs-
|
|
34
|
-
"driftjs-
|
|
33
|
+
"driftjs-shared": "0.0.18",
|
|
34
|
+
"driftjs-dom": "0.0.18"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"typescript": "7.0.2",
|
|
38
38
|
"vite": "8.3.1",
|
|
39
39
|
"vitest": "5.0.2",
|
|
40
|
-
"driftjs-
|
|
41
|
-
"driftjs-
|
|
40
|
+
"driftjs-unplugin": "0.0.18",
|
|
41
|
+
"driftjs-compiler": "0.0.18"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "vite build",
|