@real-router/core 0.168.0 → 0.170.0
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/cjs/{Router-DeHYRyDZ.js → Router-DWKUgVpc.js} +2 -2
- package/dist/cjs/Router-DWKUgVpc.js.map +1 -0
- package/dist/cjs/Router.d.ts.map +1 -1
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/index.d.ts +1 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/{internals-uqL8CMgp.js → internals-C-m8EvAR.js} +2 -2
- package/dist/cjs/{internals-uqL8CMgp.js.map → internals-C-m8EvAR.js.map} +1 -1
- package/dist/cjs/internals.d.ts +2 -7
- package/dist/cjs/internals.d.ts.map +1 -1
- package/dist/cjs/pipeline/port.d.ts +22 -22
- package/dist/cjs/types/api.d.ts +32 -4
- package/dist/cjs/types/api.d.ts.map +1 -1
- package/dist/cjs/validation.d.ts +1 -2
- package/dist/cjs/validation.js +1 -1
- package/dist/esm/{Router-6q_fZKZ1.mjs → Router-CNyRuEhQ.mjs} +2 -2
- package/dist/esm/Router-CNyRuEhQ.mjs.map +1 -0
- package/dist/esm/Router.d.mts.map +1 -1
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/index.d.mts +1 -2
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/{internals-C--qkbIk.mjs → internals-CATE9FGw.mjs} +2 -2
- package/dist/esm/{internals-C--qkbIk.mjs.map → internals-CATE9FGw.mjs.map} +1 -1
- package/dist/esm/internals.d.mts +2 -7
- package/dist/esm/internals.d.mts.map +1 -1
- package/dist/esm/pipeline/port.d.mts +22 -22
- package/dist/esm/types/api.d.mts +32 -4
- package/dist/esm/types/api.d.mts.map +1 -1
- package/dist/esm/validation.d.mts +1 -2
- package/dist/esm/validation.mjs +1 -1
- package/package.json +1 -1
- package/dist/cjs/Router-DeHYRyDZ.js.map +0 -1
- package/dist/cjs/types/RouterValidator.d.ts +0 -40
- package/dist/cjs/types/RouterValidator.d.ts.map +0 -1
- package/dist/esm/Router-6q_fZKZ1.mjs.map +0 -1
- package/dist/esm/types/RouterValidator.d.mts +0 -40
- package/dist/esm/types/RouterValidator.d.mts.map +0 -1
package/dist/cjs/Router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","names":["RouterInterface"],"sources":["../../src/Router.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;qBAsHa,OACX,qBAAqB,sBAAsB,gCAChCA,SAAgB;;GAC1B;;;;;;EAgGC,YAAA,SAAQ,MAAM,iBACd,UAAS,QAAQ,QAAQ,gBACzB,eAAc;
|
|
1
|
+
{"version":3,"file":"Router.d.ts","names":["RouterInterface"],"sources":["../../src/Router.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;qBAsHa,OACX,qBAAqB,sBAAsB,gCAChCA,SAAgB;;GAC1B;;;;;;EAgGC,YAAA,SAAQ,MAAM,iBACd,UAAS,QAAQ,QAAQ,gBACzB,eAAc;EA8sBhB,cACE,cACA,SAAS,QACT,SAAS,cACT,0BACA;EA8CF,UAAU,eAAe,SAAS,QAAQ,SAAS;EAyDnD,SAAS,UAAU,SAAS,WAAW,MAAM;EAI7C,oBAAoB;EAIpB,eACE,QAAQ,mBACR,QAAQ,mBACR;EAaF,iBACE,oBACE,SAAS,OAAO,YAAY;EAgBhC;;;;;;;;;;;;;;EAiBA,MAAM,oBAAoB,QAAQ;EAQlC;EAyBA;EAwDA,cAAc,cAAc,SAAS,QAAQ,SAAS;EAkKtD,aACK,UAAU,cAAc,8CAC1B;EA4CH,UAAU,UAAU,cAAc;EAMlC,eAAe,UAAU,UAAU;EAMnC;EAQA,SACE,QAAQ,kBACR,UAAU,oBACT,QAAQ;EACX,SACE,mBACA,cAAc,QACd,cAAc,cACd,UAAU,oBACT,QAAQ;EA+EX,kBAAkB,UAAU,oBAAoB,QAAQ;EAoBxD,mBAAmB,gBAAgB"}
|
package/dist/cjs/api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-CfUevk4y.js"),t=require("./internals-uqL8CMgp.js"),n=require("./Router-DeHYRyDZ.js"),r=e.C(`router`);function i(t,n){if(t())throw r.code(e.z.REENTRANT_TREE_MUTATION)`cannot mutate the route tree from inside a subscribeChanges handler — the mutation would run while a TREE_CHANGED emit is on the stack and the tree must stay atomic. Defer it: queueMicrotask(() => routes.add(...)) or await.`;if(n())throw r.code(e.z.REENTRANT_TREE_MUTATION)`cannot mutate the route tree from inside replace()'s revalidation — the tree would move under a state that has not been revalidated yet. Defer it: queueMicrotask(() => routes.replace(...)) or await.`}function a(e,t,n){if(t){let r=t===e;if(r||t.startsWith(`${e}.`)){let i=r?``:` (current: "${t}")`;return n.warn(`router.removeRoute`,`Cannot remove route "${e}" — it is currently active${i}. Navigate away first.`),!1}}return!0}function o(e,t){t.warn(`router.removeRoute`,`Route "${e}" removed while navigation is in progress. Removing a route the router is navigating to (or an ancestor of it) fails that navigation with "ROUTE_NOT_FOUND" — the rejected navigate() promise and onTransitionError carry the same code, and onTransitionCancel never fires. The committed state is not affected either way.`)}function s(e){let t=e.indexOf(`?`);return t===-1?e:e.slice(0,t)}function c(e,t,n,r){return n&&s(e)!==s(t)?(r.error(`router.setRootPath`,"Cannot change the root PATH while navigation is in progress — it moves every route's path, including the one being navigated to. Wait for navigation to complete. (Changing only the `?`-declared query names is allowed here: it moves no paths.)"),!1):!0}const l=e.C(`router`,`claimContextNamespace`),u=e.C(`router`,`extendRouter`),d=Object.freeze,f=Object.keys,p=new WeakMap;function m(r){let a=p.get(r);if(a)return a;let o=t.o(r),s={makeState:(e,t,n,r)=>o.makeState(e,t,n,r),forwardState:(e,n,r)=>(t.l(o.checks,t.n[`forwardState:entry`],e,n,r),o.forwardState(e,n,r)),matchPath:e=>o.matchPath(e,o.getOptions()),navigateToState:(e,t)=>o.navigateToState(e,t),setRootPath:e=>{if(t.u(o.isDisposed),i(o.routeGetStore().treeChanged.isEmitting,()=>o.routeGetStore().revalidating),!c(o.getRootPath(),e,o.isTransitioning(),o.logger))return!1;let n=o.getRootPath();return o.setRootPath(e),n!==e&&o.routeGetStore().treeChanged.emit({op:`rootPath`,previous:n,next:e}),!0},getRootPath:o.getRootPath,addEventListener:(e,t)=>o.addEventListener(e,t),buildNavigationState:(r,i={},a={})=>{t.d(o,`buildNavigationState`,r,i);let s=e.t(i);t.l(o.checks,t.n[`buildNavigationState:state`],r,s,a);let c=n.E(o.port(),r,s,a,{diagnoseUndeclared:!0});if(!o.buildStateResolved(c.name,c.path))return;t.w(`buildNavigationState`,c.name,c.path,o.port().queryNames(c.name));let l=n.w(c,n.T(c,o.port()));return o.port().reportCodecRoundTrip?.(l),l},buildPathResolved:(e,t,n)=>o.buildPathResolved(e,t,n),getAdoptedOrigins:o.getAdoptedOrigins,logger:d({log:(e,t,...n)=>{o.logger.log(e,t,...n)},warn:(e,t,...n)=>{o.logger.warn(e,t,...n)},error:(e,t,...n)=>{o.logger.error(e,t,...n)}}),getDeclaredQueryNames:e=>o.getDeclaredQueryNames(e),getUrlParams:e=>n.C(o.routeGetStore(),e),getForwardMap:()=>{let t=e.E();return e.T(t,o.routeGetStore().config.forwardMap),d(t)},getResolvedLimits:()=>o.dependenciesGetStore().limits,getDependencyKeys:()=>d(f(o.dependenciesGetStore().dependencies)),getExternalGuardNames:()=>{let[e,t]=o.routeGetStore().lifecycleNamespace.getFactoriesByOrigin().external;return d([...new Set([...f(e),...f(t)])])},getOptions:o.getOptions,getTree:o.getTree,addInterceptor:(e,r)=>{t.u(o.isDisposed),n.P(e,r);let i=o.interceptors.get(e);i||(i=[],o.interceptors.set(e,i)),i.push(r);let a=!1;return()=>{a||(a=!0,i.splice(i.indexOf(r),1))}},subscribeDiagnostic:o.subscribeDiagnostic,addCheck:(e,r)=>{t.u(o.isDisposed),n.j(e,r);let i=o.checks.get(e);i||(i=[],o.checks.set(e,i)),i.push(r);let a=!1;return()=>{a||(a=!0,i.splice(i.indexOf(r),1))}},getRouteConfig:e=>{let t=o.routeGetStore();if(t.matcher.hasRoute(e))return t.routeCustomFields[e]},extendRouter:i=>{t.u(o.isDisposed),n.M(i);let a=f(i);for(let t of a)if(t in r)throw u.code(e.z.PLUGIN_CONFLICT)`Cannot extend router: property "${t}" already exists`;let s=a.map(e=>i[e]),c={keys:a};for(let[e,t]of a.entries())r[t]=s[e];o.routerExtensions.push(c);let l=!1;return()=>{if(l)return;l=!0;for(let e of c.keys)delete r[e];let e=o.routerExtensions.indexOf(c);e!==-1&&o.routerExtensions.splice(e,1)}},emitTransitionError:e=>{t.u(o.isDisposed),o.emitTransitionError(e)},claimContextNamespace:n=>{if(t.u(o.isDisposed),typeof n!=`string`||n===``)throw l.type`namespace must be a non-empty string, got ${typeof n==`string`?`an empty string`:typeof n}`;if(o.contextClaimRecords.has(n))throw l.code(e.z.CONTEXT_NAMESPACE_ALREADY_CLAIMED)`Cannot claim context namespace: "${n}" is already claimed by another plugin`;let r={write(t,i){o.contextClaimRecords.get(n)===r&&e.O(t.context,n,i)},release(){o.contextClaimRecords.get(n)===r&&o.contextClaimRecords.delete(n)}};return o.contextClaimRecords.set(n,r),r}},m=d(s);return p.set(r,m),m}const h=e.C(`router`,`clear`),g=Object.freeze,_=Object.keys,v=Object.freeze({replace:!0,revalidate:!0}),y=Object.freeze([]);function b(e,t,r,i){let a=t=>e.has(t);n.x(t.decoders,a),n.x(t.encoders,a),n.x(t.defaultParams,a),n.x(t.defaultSearch,a),n.x(t.forwardMap,a),n.x(t.forwardFnMap,a),n.x(r,a),n.x(t.forwardMap,e=>a(t.forwardMap[e]));let[o,s]=i.getFactories();for(let e of _(s))a(e)&&i.clearCanActivate(e,`both`);for(let e of _(o))a(e)&&i.clearCanDeactivate(e,`both`)}function x(e,t,n,r){let i=n.forwardFnMap[t],a=n.forwardMap[t];i===void 0?a!==void 0&&(e.forwardTo=a):e.forwardTo=i,t in n.defaultParams&&(e.defaultParams=n.defaultParams[t]),t in n.defaultSearch&&(e.defaultSearch=n.defaultSearch[t]),t in n.decoders&&(e.decodeParams=n.decoders[t]),t in n.encoders&&(e.encodeParams=n.encoders[t]);let[o,s]=r;return t in s&&(e.canActivate=s[t]),t in o&&(e.canDeactivate=o[t]),e}function S(t,n,r,i){let a={name:t.name,path:t.path};return x(a,n,r,i),t.children&&e.O(a,`children`,t.children.map(e=>S(e,`${n}.${e.name}`,r,i))),a}function C(e,t,n,r){let i={name:e,path:t};return x(i,e,n,r),g(i)}function w(e,t){let n=new Map,r=e.lifecycleNamespace.getFactories(),i=(a,o)=>{for(let s of a){let a=o?`${o}.${s.name}`:s.name;t(a)&&n.set(a,C(a,s.path,e.config,r)),s.children&&i(s.children,a)}};return i(e.definitions,``),n}function T(e,t){let n=w(e,e=>t.has(e));return g([...n.values()])}function E(e,t,n){let r=n.lifecycleNamespace.getFactories(),i=[],a=(e,t)=>{for(let o of e){let e=t?`${t}.${o.name}`:o.name;i.push(C(e,o.path,n.config,r)),o.children&&a(o.children,e)}};return a(e,t??``),g(i)}function D(e,t){let n=[],r=[];for(let[r,i]of e)t.has(r)||n.push(i);for(let[n,i]of t)e.has(n)||r.push(i);return{removed:g(n),added:g(r)}}function O(e){let t={};return e.forwardTo!==void 0&&(t.forwardTo=e.forwardTo),e.defaultParams!==void 0&&(t.defaultParams=e.defaultParams),e.defaultSearch!==void 0&&(t.defaultSearch=e.defaultSearch),e.encodeParams!==void 0&&(t.encodeParams=e.encodeParams),e.decodeParams!==void 0&&(t.decodeParams=e.decodeParams),g(t)}function k(e,t,r,i){n.a(e,t,r);let a=n.f(e,t,r,i);n.y(a.matcher,a.config,`addRoute`),e.lifecycleNamespace.preflightHandlerLimit(a.pendingCanActivate.keys(),a.pendingCanDeactivate.keys(),!1),n.i(e,a)}function A(e,t,n){e.systemCommit(t,n,v)}function j(e,r,i,a,o){n.l(r,`addRoute`),n.d(r,`addRoute`),n.o(r,`addRoute`),n.s(r,``,`addRoute`),n.c(r,``,`addRoute`);let s=n.p(r,e.rootPath,e.matcherOptions,i.logger);n.y(s.matcher,s.config,`addRoute`),e.lifecycleNamespace.preflightHandlerLimit(s.pendingCanActivate.keys(),s.pendingCanDeactivate.keys(),!0);let c=n.g(s,e.depsStore);e.lifecycleNamespace.clearDefinitionGuards(),n.i(e,s,c),t.u(i.isDisposed),e.revalidating=!0;let l=a();try{if(o?.(),l!==void 0){let t=i.matchPath(l.path,i.getOptions());if(t){if(t.name===l.name)A(i,{...t,context:l.context,transition:l.transition},l);else{let{toDeactivate:r,toActivate:a,intersection:o}=n.n(t,l,i.getMetaForState);if(e.lifecycleNamespace.canNavigateTo([],a,t,l,`replace`)){let e={phase:`activating`,from:l.name,reason:`success`,replace:!0,segments:{deactivated:r,activated:a,intersection:o}};A(i,{...t,transition:e},l)}else i.revalidateToNotFound(l.path)}}else i.revalidateToNotFound(l.path)}}finally{e.revalidating=!1}}function M(e,t,r){let i=e.definitions,a=n.S(i,t);if(a===void 0)return;let o=r?T(e,a):y;return b(a,e.config,e.routeCustomFields,e.lifecycleNamespace),n.h(e,i),o}function N(e,t){let r=e.matcher.getSegmentsByName(t);if(!r)return;let i=r.at(-1),a=n.z(i),o=e.lifecycleNamespace.getFactories();return S(a,t,e.config,o)}const P=new WeakMap;function F(r){let s=P.get(r);if(s)return s;let c=t.o(r),l=c.routeGetStore(),u=e=>{l.treeChanged.emit(e)},d=g({add:(e,r)=>{t.u(c.isDisposed),i(l.treeChanged.isEmitting,()=>l.revalidating);let a=Array.isArray(e)?e:[e],o=r?.parent,s=n.L(a);if(t.l(c.checks,t.n[`addRoute:batch`],s,o),k(l,s,o,c.logger),t.u(c.isDisposed),l.treeChanged.listenerCount()>0){let e=E(s,o,l);u(o===void 0?{op:`add`,added:e}:{op:`add`,added:e,parent:o})}},remove:e=>{if(t.u(c.isDisposed),i(l.treeChanged.isEmitting,()=>l.revalidating),t.l(c.checks,t.n[`removeRoute:entry`],e),n.u(e,`removeRoute`),!a(e,c.getStateName(),c.logger))return;let r=l.treeChanged.listenerCount()>0,s=M(l,e,r);s===void 0?c.logger.warn(`router.removeRoute`,`Route "${e}" not found. No changes made.`):(c.isTransitioning()&&o(e,c.logger),r&&u({op:`remove`,name:e,removedSubtree:s}))},update:(e,r)=>{if(t.u(c.isDisposed),i(l.treeChanged.isEmitting,()=>l.revalidating),t.l(c.checks,t.n[`updateRoute:entry`],e,r),n.u(e,`updateRoute`),!l.matcher.hasRoute(e))return;c.isTransitioning()&&c.logger.error(`router.updateRoute`,`Updating route "${e}" while navigation is in progress. This may cause unexpected behavior.`);let a=l.lifecycleNamespace,o=n.m(l,a,e,r);if(t.u(c.isDisposed),l.treeChanged.listenerCount()>0){let t=O(o);_(t).length>0&&u({op:`update`,name:e,patch:t})}},clear:()=>{if(t.u(c.isDisposed),i(l.treeChanged.isEmitting,()=>l.revalidating),c.getStateName()!==void 0)throw h.code(e.z.ROUTER_NOT_STOPPED)`Cannot clear routes while a state is committed. Use replace(routes) to swap the tree on a running router, or stop() first.`;if(c.isTransitioning()){c.logger.error(`router.clear`,`Cannot clear routes while navigation is in progress. Wait for navigation to complete.`);return}let r=l.treeChanged.listenerCount()>0?g([...w(l,()=>!0).values()]):void 0;n._(l),l.lifecycleNamespace.clearAll(),r!==void 0&&u({op:`clear`,removed:r})},has:e=>(t.l(c.checks,t.n[`hasRoute:entry`],e),l.matcher.hasRoute(e)),get:e=>(t.l(c.checks,t.n[`getRoute:entry`],e),N(l,e)),replace:e=>{t.u(c.isDisposed),i(l.treeChanged.isEmitting,()=>l.revalidating);let a=Array.isArray(e)?e:[e];if(c.isTransitioning()){c.logger.error(`router.replace`,`Cannot replace routes while navigation is in progress. Wait for navigation to complete.`);return}let o=n.L(a);t.l(c.checks,t.n[`replaceRoutes:batch`],o);let s=l.treeChanged.listenerCount()>0?w(l,()=>!0):void 0;j(l,o,c,()=>r.getState(),s===void 0?void 0:()=>{let e=w(l,()=>!0),{removed:t,added:n}=D(s,e);u({op:`replace`,removed:t,added:n})})},subscribeChanges:e=>(n.I(e),l.treeChanged.subscribe(e))});return P.set(r,d),d}const I=Object.hasOwn,L=Object.keys,R=e=>typeof e==`symbol`?e:String(e),z=[];function B(e,n,r,i){if(i===void 0)return;let a=e.dependencies,o=R(r),{diagnostics:s}=e,c=t.s(n,t.n[`setDependency:count`])||s.listenerCount(t.t.SET_DEPENDENCY_COUNT)>0||s.listenerCount(t.t.SET_DEPENDENCY_OVERWRITE)>0?L(a):z;if(c.includes(o)){let e=a[o];e!==i&&!(Number.isNaN(e)&&Number.isNaN(i))&&s.emit(t.t.SET_DEPENDENCY_OVERWRITE,String(o))}else t.l(n,t.n[`setDependency:count`],c.length,e.limits.maxDependencies),s.emit(t.t.SET_DEPENDENCY_COUNT,c.length,e.limits.maxDependencies);a[o]=i}function V(e,r,i){let a=[],o=e.dependencies,{diagnostics:s}=e,c=new Set(t.s(r,t.n[`setDependencies:count`])||s.listenerCount(t.t.SET_DEPENDENCIES_COUNT)>0||s.listenerCount(t.t.SET_DEPENDENCIES_OVERWRITE)>0?L(o):z);n.R(i,(i,l)=>{c.has(i)?a.push(i):(t.l(r,t.n[`setDependencies:count`],c.size,e.limits.maxDependencies),s.emit(t.t.SET_DEPENDENCIES_COUNT,c.size,e.limits.maxDependencies),c.add(i)),n.A(o,i,l)}),a.length>0&&s.emit(t.t.SET_DEPENDENCIES_OVERWRITE,a)}function H(e){let r=t.o(e);return{get:e=>{t.l(r.checks,t.n[`getDependency:entry`],e);let i=r.dependenciesGetStore(),a=n.O(i,e);return t.l(r.checks,t.n[`getDependency:value`],e,a),a},getAll:()=>n.k(r.dependenciesGetStore()),set:(e,n)=>{t.u(r.isDisposed),t.l(r.checks,t.n[`setDependency:entry`],e,n),t.u(r.isDisposed),B(r.dependenciesGetStore(),r.checks,e,n),t.u(r.isDisposed)},setAll:e=>{t.u(r.isDisposed),t.l(r.checks,t.n[`setDependencies:entry`],e),t.u(r.isDisposed),V(r.dependenciesGetStore(),r.checks,e),t.u(r.isDisposed)},remove:e=>{t.u(r.isDisposed),t.l(r.checks,t.n[`removeDependency:entry`],e);let n=r.dependenciesGetStore(),i=R(e);I(n.dependencies,i)||n.diagnostics.emit(t.t.REMOVE_DEPENDENCY_MISSING,i),delete n.dependencies[i],t.u(r.isDisposed)},reset:()=>{t.u(r.isDisposed),n.D(r.dependenciesGetStore())},has:e=>(t.l(r.checks,t.n[`hasDependency:entry`],e),I(r.dependenciesGetStore().dependencies,e))}}function U(e){let r=t.o(e),i=r.routeGetStore().lifecycleNamespace;return{addActivateGuard(e,a){t.u(r.isDisposed),n.F(e,`addActivateGuard`),n.N(e,`addActivateGuard`),t.l(r.checks,t.n[`addActivateGuard:entry`],e,a),i.addCanActivate(e,a,!1),t.u(r.isDisposed)},addDeactivateGuard(e,a){t.u(r.isDisposed),n.F(e,`addDeactivateGuard`),n.N(e,`addDeactivateGuard`),t.l(r.checks,t.n[`addDeactivateGuard:entry`],e,a),i.addCanDeactivate(e,a,!1),t.u(r.isDisposed)},removeActivateGuard(e){t.u(r.isDisposed),n.F(e,`removeActivateGuard`),t.l(r.checks,t.n[`removeActivateGuard:entry`],e),i.clearCanActivate(e,`external`)},removeDeactivateGuard(e){t.u(r.isDisposed),n.F(e,`removeDeactivateGuard`),t.l(r.checks,t.n[`removeDeactivateGuard:entry`],e),i.clearCanDeactivate(e,`external`)}}}const W=Object.entries,G=Object.hasOwn,K=e.C(`cloneRouter`);function q(r,i,a){let o=t.o(r),s=()=>{if(o.isDisposed())throw K.code(e.z.ROUTER_DISPOSED)`cannot clone a disposed router — dispose() is terminal`};s(),t.l(o.checks,t.n[`cloneRouter:entry`],i);let c=o.routeGetStore(),l=n.B(c.tree),u=c.config,d=c.resolvedForwardMap,f=c.routeCustomFields,{options:p,dependencies:m,pluginFactories:h,loggerConfig:g,limits:_,limitKeys:v}=o.getCloneState(),{definition:y,external:b}=c.lifecycleNamespace.getFactoriesByOrigin(),x={...m};i!==void 0&&n.R(i,(t,n)=>{e.O(x,t,n)});let S=a?.logger,C=S?{...g,...S}:g;s();let w=new n.t(l,{...p,...c.matcherOptions?.queryParams!==void 0&&{queryParams:c.matcherOptions.queryParams},logger:C,...v!==void 0&&{limits:Object.fromEntries(v.filter(e=>G(_,e)).map(e=>[e,_[e]]))},...c.matcherOptions?.urlParamsEncoding!==void 0&&{urlParamsEncoding:c.matcherOptions.urlParamsEncoding}},x),T=t.o(w),E=T.routeGetStore(),D=E.lifecycleNamespace;n.b(E.config,u),n.r(E,Object.assign(E.resolvedForwardMap,d)),Object.assign(E.routeCustomFields,f),c.rootPath!==``&&T.setRootPath(c.rootPath);let[O,k]=y,[A,j]=b;for(let[e,t]of W(O))D.addCanDeactivate(e,t,!0);for(let[e,t]of W(k))D.addCanActivate(e,t,!0);let M=U(w);for(let[e,t]of W(A))M.addDeactivateGuard(e,t);for(let[e,t]of W(j))M.addActivateGuard(e,t);let N=new Set(T.getCloneState().pluginFactories),P=h.filter(e=>!N.has(e));return P.length>0&&w.usePlugin(...P),w}exports.cloneRouter=q,exports.getDependenciesApi=H,exports.getLifecycleApi=U,exports.getPluginApi=m,exports.getRoutesApi=F;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-CfUevk4y.js"),t=require("./internals-C-m8EvAR.js"),n=require("./Router-DWKUgVpc.js"),r=e.C(`router`);function i(t,n){if(t())throw r.code(e.z.REENTRANT_TREE_MUTATION)`cannot mutate the route tree from inside a subscribeChanges handler — the mutation would run while a TREE_CHANGED emit is on the stack and the tree must stay atomic. Defer it: queueMicrotask(() => routes.add(...)) or await.`;if(n())throw r.code(e.z.REENTRANT_TREE_MUTATION)`cannot mutate the route tree from inside replace()'s revalidation — the tree would move under a state that has not been revalidated yet. Defer it: queueMicrotask(() => routes.replace(...)) or await.`}function a(e,t,n){if(t){let r=t===e;if(r||t.startsWith(`${e}.`)){let i=r?``:` (current: "${t}")`;return n.warn(`router.removeRoute`,`Cannot remove route "${e}" — it is currently active${i}. Navigate away first.`),!1}}return!0}function o(e,t){t.warn(`router.removeRoute`,`Route "${e}" removed while navigation is in progress. Removing a route the router is navigating to (or an ancestor of it) fails that navigation with "ROUTE_NOT_FOUND" — the rejected navigate() promise and onTransitionError carry the same code, and onTransitionCancel never fires. The committed state is not affected either way.`)}function s(e){let t=e.indexOf(`?`);return t===-1?e:e.slice(0,t)}function c(e,t,n,r){return n&&s(e)!==s(t)?(r.error(`router.setRootPath`,"Cannot change the root PATH while navigation is in progress — it moves every route's path, including the one being navigated to. Wait for navigation to complete. (Changing only the `?`-declared query names is allowed here: it moves no paths.)"),!1):!0}const l=e.C(`router`,`claimContextNamespace`),u=e.C(`router`,`extendRouter`),d=Object.freeze,f=Object.keys,p=new WeakMap;function m(r){let a=p.get(r);if(a)return a;let o=t.o(r),s={makeState:(e,t,n,r)=>o.makeState(e,t,n,r),forwardState:(e,n,r)=>(t.l(o.checks,t.n[`forwardState:entry`],e,n,r),o.forwardState(e,n,r)),matchPath:e=>o.matchPath(e,o.getOptions()),navigateToState:(e,t)=>o.navigateToState(e,t),setRootPath:e=>{if(t.u(o.isDisposed),i(o.routeGetStore().treeChanged.isEmitting,()=>o.routeGetStore().revalidating),!c(o.getRootPath(),e,o.isTransitioning(),o.logger))return!1;let n=o.getRootPath();return o.setRootPath(e),n!==e&&o.routeGetStore().treeChanged.emit({op:`rootPath`,previous:n,next:e}),!0},getRootPath:o.getRootPath,addEventListener:(e,t)=>o.addEventListener(e,t),buildNavigationState:(r,i={},a={})=>{t.d(o,`buildNavigationState`,r,i);let s=e.t(i);t.l(o.checks,t.n[`buildNavigationState:state`],r,s,a);let c=n.E(o.port(),r,s,a,{diagnoseUndeclared:!0});if(!o.buildStateResolved(c.name,c.path))return;t.w(`buildNavigationState`,c.name,c.path,o.port().queryNames(c.name));let l=n.w(c,n.T(c,o.port()));return o.port().reportCodecRoundTrip?.(l),l},buildPathResolved:(e,t,n)=>o.buildPathResolved(e,t,n),getAdoptedOrigins:o.getAdoptedOrigins,logger:d({log:(e,t,...n)=>{o.logger.log(e,t,...n)},warn:(e,t,...n)=>{o.logger.warn(e,t,...n)},error:(e,t,...n)=>{o.logger.error(e,t,...n)}}),getDeclaredQueryNames:e=>o.getDeclaredQueryNames(e),getUrlParams:e=>n.C(o.routeGetStore(),e),getForwardMap:()=>{let t=e.E();return e.T(t,o.routeGetStore().config.forwardMap),d(t)},getResolvedLimits:()=>o.dependenciesGetStore().limits,getDependencyKeys:()=>d(f(o.dependenciesGetStore().dependencies)),getExternalGuardNames:()=>{let[e,t]=o.routeGetStore().lifecycleNamespace.getFactoriesByOrigin().external;return d([...new Set([...f(e),...f(t)])])},getOptions:o.getOptions,getTree:o.getTree,addInterceptor:(e,r)=>{t.u(o.isDisposed),n.P(e,r);let i=o.interceptors.get(e);i||(i=[],o.interceptors.set(e,i)),i.push(r);let a=!1;return()=>{a||(a=!0,i.splice(i.indexOf(r),1))}},subscribeDiagnostic:o.subscribeDiagnostic,addCheck:(e,r)=>{t.u(o.isDisposed),n.j(e,r);let i=o.checks.get(e);i||(i=[],o.checks.set(e,i)),i.push(r);let a=!1;return()=>{a||(a=!0,i.splice(i.indexOf(r),1))}},getRouteConfig:e=>{let t=o.routeGetStore();if(t.matcher.hasRoute(e))return t.routeCustomFields[e]},extendRouter:i=>{t.u(o.isDisposed),n.M(i);let a=f(i);for(let t of a)if(t in r)throw u.code(e.z.PLUGIN_CONFLICT)`Cannot extend router: property "${t}" already exists`;let s=a.map(e=>i[e]),c={keys:a};for(let[e,t]of a.entries())r[t]=s[e];o.routerExtensions.push(c);let l=!1;return()=>{if(l)return;l=!0;for(let e of c.keys)delete r[e];let e=o.routerExtensions.indexOf(c);e!==-1&&o.routerExtensions.splice(e,1)}},emitTransitionError:e=>{t.u(o.isDisposed),o.emitTransitionError(e)},claimContextNamespace:n=>{if(t.u(o.isDisposed),typeof n!=`string`||n===``)throw l.type`namespace must be a non-empty string, got ${typeof n==`string`?`an empty string`:typeof n}`;if(o.contextClaimRecords.has(n))throw l.code(e.z.CONTEXT_NAMESPACE_ALREADY_CLAIMED)`Cannot claim context namespace: "${n}" is already claimed by another plugin`;let r={write(t,i){o.contextClaimRecords.get(n)===r&&e.O(t.context,n,i)},release(){o.contextClaimRecords.get(n)===r&&o.contextClaimRecords.delete(n)}};return o.contextClaimRecords.set(n,r),r}},m=d(s);return p.set(r,m),m}const h=e.C(`router`,`clear`),g=Object.freeze,_=Object.keys,v=Object.freeze({replace:!0,revalidate:!0}),y=Object.freeze([]);function b(e,t,r,i){let a=t=>e.has(t);n.x(t.decoders,a),n.x(t.encoders,a),n.x(t.defaultParams,a),n.x(t.defaultSearch,a),n.x(t.forwardMap,a),n.x(t.forwardFnMap,a),n.x(r,a),n.x(t.forwardMap,e=>a(t.forwardMap[e]));let[o,s]=i.getFactories();for(let e of _(s))a(e)&&i.clearCanActivate(e,`both`);for(let e of _(o))a(e)&&i.clearCanDeactivate(e,`both`)}function x(e,t,n,r){let i=n.forwardFnMap[t],a=n.forwardMap[t];i===void 0?a!==void 0&&(e.forwardTo=a):e.forwardTo=i,t in n.defaultParams&&(e.defaultParams=n.defaultParams[t]),t in n.defaultSearch&&(e.defaultSearch=n.defaultSearch[t]),t in n.decoders&&(e.decodeParams=n.decoders[t]),t in n.encoders&&(e.encodeParams=n.encoders[t]);let[o,s]=r;return t in s&&(e.canActivate=s[t]),t in o&&(e.canDeactivate=o[t]),e}function S(t,n,r,i){let a={name:t.name,path:t.path};return x(a,n,r,i),t.children&&e.O(a,`children`,t.children.map(e=>S(e,`${n}.${e.name}`,r,i))),a}function C(e,t,n,r){let i={name:e,path:t};return x(i,e,n,r),g(i)}function w(e,t){let n=new Map,r=e.lifecycleNamespace.getFactories(),i=(a,o)=>{for(let s of a){let a=o?`${o}.${s.name}`:s.name;t(a)&&n.set(a,C(a,s.path,e.config,r)),s.children&&i(s.children,a)}};return i(e.definitions,``),n}function T(e,t){let n=w(e,e=>t.has(e));return g([...n.values()])}function E(e,t,n){let r=n.lifecycleNamespace.getFactories(),i=[],a=(e,t)=>{for(let o of e){let e=t?`${t}.${o.name}`:o.name;i.push(C(e,o.path,n.config,r)),o.children&&a(o.children,e)}};return a(e,t??``),g(i)}function D(e,t){let n=[],r=[];for(let[r,i]of e)t.has(r)||n.push(i);for(let[n,i]of t)e.has(n)||r.push(i);return{removed:g(n),added:g(r)}}function O(e){let t={};return e.forwardTo!==void 0&&(t.forwardTo=e.forwardTo),e.defaultParams!==void 0&&(t.defaultParams=e.defaultParams),e.defaultSearch!==void 0&&(t.defaultSearch=e.defaultSearch),e.encodeParams!==void 0&&(t.encodeParams=e.encodeParams),e.decodeParams!==void 0&&(t.decodeParams=e.decodeParams),g(t)}function k(e,t,r,i){n.a(e,t,r);let a=n.f(e,t,r,i);n.y(a.matcher,a.config,`addRoute`),e.lifecycleNamespace.preflightHandlerLimit(a.pendingCanActivate.keys(),a.pendingCanDeactivate.keys(),!1),n.i(e,a)}function A(e,t,n){e.systemCommit(t,n,v)}function j(e,r,i,a,o){n.l(r,`addRoute`),n.d(r,`addRoute`),n.o(r,`addRoute`),n.s(r,``,`addRoute`),n.c(r,``,`addRoute`);let s=n.p(r,e.rootPath,e.matcherOptions,i.logger);n.y(s.matcher,s.config,`addRoute`),e.lifecycleNamespace.preflightHandlerLimit(s.pendingCanActivate.keys(),s.pendingCanDeactivate.keys(),!0);let c=n.g(s,e.depsStore);e.lifecycleNamespace.clearDefinitionGuards(),n.i(e,s,c),t.u(i.isDisposed),e.revalidating=!0;let l=a();try{if(o?.(),l!==void 0){let t=i.matchPath(l.path,i.getOptions());if(t){if(t.name===l.name)A(i,{...t,context:l.context,transition:l.transition},l);else{let{toDeactivate:r,toActivate:a,intersection:o}=n.n(t,l,i.getMetaForState);if(e.lifecycleNamespace.canNavigateTo([],a,t,l,`replace`)){let e={phase:`activating`,from:l.name,reason:`success`,replace:!0,segments:{deactivated:r,activated:a,intersection:o}};A(i,{...t,transition:e},l)}else i.revalidateToNotFound(l.path)}}else i.revalidateToNotFound(l.path)}}finally{e.revalidating=!1}}function M(e,t,r){let i=e.definitions,a=n.S(i,t);if(a===void 0)return;let o=r?T(e,a):y;return b(a,e.config,e.routeCustomFields,e.lifecycleNamespace),n.h(e,i),o}function N(e,t){let r=e.matcher.getSegmentsByName(t);if(!r)return;let i=r.at(-1),a=n.z(i),o=e.lifecycleNamespace.getFactories();return S(a,t,e.config,o)}const P=new WeakMap;function F(r){let s=P.get(r);if(s)return s;let c=t.o(r),l=c.routeGetStore(),u=e=>{l.treeChanged.emit(e)},d=g({add:(e,r)=>{t.u(c.isDisposed),i(l.treeChanged.isEmitting,()=>l.revalidating);let a=Array.isArray(e)?e:[e],o=r?.parent,s=n.L(a);if(t.l(c.checks,t.n[`addRoute:batch`],s,o),k(l,s,o,c.logger),t.u(c.isDisposed),l.treeChanged.listenerCount()>0){let e=E(s,o,l);u(o===void 0?{op:`add`,added:e}:{op:`add`,added:e,parent:o})}},remove:e=>{if(t.u(c.isDisposed),i(l.treeChanged.isEmitting,()=>l.revalidating),t.l(c.checks,t.n[`removeRoute:entry`],e),n.u(e,`removeRoute`),!a(e,c.getStateName(),c.logger))return;let r=l.treeChanged.listenerCount()>0,s=M(l,e,r);s===void 0?c.logger.warn(`router.removeRoute`,`Route "${e}" not found. No changes made.`):(c.isTransitioning()&&o(e,c.logger),r&&u({op:`remove`,name:e,removedSubtree:s}))},update:(e,r)=>{if(t.u(c.isDisposed),i(l.treeChanged.isEmitting,()=>l.revalidating),t.l(c.checks,t.n[`updateRoute:entry`],e,r),n.u(e,`updateRoute`),!l.matcher.hasRoute(e))return;c.isTransitioning()&&c.logger.error(`router.updateRoute`,`Updating route "${e}" while navigation is in progress. This may cause unexpected behavior.`);let a=l.lifecycleNamespace,o=n.m(l,a,e,r);if(t.u(c.isDisposed),l.treeChanged.listenerCount()>0){let t=O(o);_(t).length>0&&u({op:`update`,name:e,patch:t})}},clear:()=>{if(t.u(c.isDisposed),i(l.treeChanged.isEmitting,()=>l.revalidating),c.getStateName()!==void 0)throw h.code(e.z.ROUTER_NOT_STOPPED)`Cannot clear routes while a state is committed. Use replace(routes) to swap the tree on a running router, or stop() first.`;if(c.isTransitioning()){c.logger.error(`router.clear`,`Cannot clear routes while navigation is in progress. Wait for navigation to complete.`);return}let r=l.treeChanged.listenerCount()>0?g([...w(l,()=>!0).values()]):void 0;n._(l),l.lifecycleNamespace.clearAll(),r!==void 0&&u({op:`clear`,removed:r})},has:e=>(t.l(c.checks,t.n[`hasRoute:entry`],e),l.matcher.hasRoute(e)),get:e=>(t.l(c.checks,t.n[`getRoute:entry`],e),N(l,e)),replace:e=>{t.u(c.isDisposed),i(l.treeChanged.isEmitting,()=>l.revalidating);let a=Array.isArray(e)?e:[e];if(c.isTransitioning()){c.logger.error(`router.replace`,`Cannot replace routes while navigation is in progress. Wait for navigation to complete.`);return}let o=n.L(a);t.l(c.checks,t.n[`replaceRoutes:batch`],o);let s=l.treeChanged.listenerCount()>0?w(l,()=>!0):void 0;j(l,o,c,()=>r.getState(),s===void 0?void 0:()=>{let e=w(l,()=>!0),{removed:t,added:n}=D(s,e);u({op:`replace`,removed:t,added:n})})},subscribeChanges:e=>(n.I(e),l.treeChanged.subscribe(e))});return P.set(r,d),d}const I=Object.hasOwn,L=Object.keys,R=e=>typeof e==`symbol`?e:String(e),z=[];function B(e,n,r,i){if(i===void 0)return;let a=e.dependencies,o=R(r),{diagnostics:s}=e,c=t.s(n,t.n[`setDependency:count`])||s.listenerCount(t.t.SET_DEPENDENCY_COUNT)>0||s.listenerCount(t.t.SET_DEPENDENCY_OVERWRITE)>0?L(a):z;if(c.includes(o)){let e=a[o];e!==i&&!(Number.isNaN(e)&&Number.isNaN(i))&&s.emit(t.t.SET_DEPENDENCY_OVERWRITE,String(o))}else t.l(n,t.n[`setDependency:count`],c.length,e.limits.maxDependencies),s.emit(t.t.SET_DEPENDENCY_COUNT,c.length,e.limits.maxDependencies);a[o]=i}function V(e,r,i){let a=[],o=e.dependencies,{diagnostics:s}=e,c=new Set(t.s(r,t.n[`setDependencies:count`])||s.listenerCount(t.t.SET_DEPENDENCIES_COUNT)>0||s.listenerCount(t.t.SET_DEPENDENCIES_OVERWRITE)>0?L(o):z);n.R(i,(i,l)=>{c.has(i)?a.push(i):(t.l(r,t.n[`setDependencies:count`],c.size,e.limits.maxDependencies),s.emit(t.t.SET_DEPENDENCIES_COUNT,c.size,e.limits.maxDependencies),c.add(i)),n.A(o,i,l)}),a.length>0&&s.emit(t.t.SET_DEPENDENCIES_OVERWRITE,a)}function H(e){let r=t.o(e);return{get:e=>{t.l(r.checks,t.n[`getDependency:entry`],e);let i=r.dependenciesGetStore(),a=n.O(i,e);return t.l(r.checks,t.n[`getDependency:value`],e,a),a},getAll:()=>n.k(r.dependenciesGetStore()),set:(e,n)=>{t.u(r.isDisposed),t.l(r.checks,t.n[`setDependency:entry`],e,n),t.u(r.isDisposed),B(r.dependenciesGetStore(),r.checks,e,n),t.u(r.isDisposed)},setAll:e=>{t.u(r.isDisposed),t.l(r.checks,t.n[`setDependencies:entry`],e),t.u(r.isDisposed),V(r.dependenciesGetStore(),r.checks,e),t.u(r.isDisposed)},remove:e=>{t.u(r.isDisposed),t.l(r.checks,t.n[`removeDependency:entry`],e);let n=r.dependenciesGetStore(),i=R(e);I(n.dependencies,i)||n.diagnostics.emit(t.t.REMOVE_DEPENDENCY_MISSING,i),delete n.dependencies[i],t.u(r.isDisposed)},reset:()=>{t.u(r.isDisposed),n.D(r.dependenciesGetStore())},has:e=>(t.l(r.checks,t.n[`hasDependency:entry`],e),I(r.dependenciesGetStore().dependencies,e))}}function U(e){let r=t.o(e),i=r.routeGetStore().lifecycleNamespace;return{addActivateGuard(e,a){t.u(r.isDisposed),n.F(e,`addActivateGuard`),n.N(e,`addActivateGuard`),t.l(r.checks,t.n[`addActivateGuard:entry`],e,a),i.addCanActivate(e,a,!1),t.u(r.isDisposed)},addDeactivateGuard(e,a){t.u(r.isDisposed),n.F(e,`addDeactivateGuard`),n.N(e,`addDeactivateGuard`),t.l(r.checks,t.n[`addDeactivateGuard:entry`],e,a),i.addCanDeactivate(e,a,!1),t.u(r.isDisposed)},removeActivateGuard(e){t.u(r.isDisposed),n.F(e,`removeActivateGuard`),t.l(r.checks,t.n[`removeActivateGuard:entry`],e),i.clearCanActivate(e,`external`)},removeDeactivateGuard(e){t.u(r.isDisposed),n.F(e,`removeDeactivateGuard`),t.l(r.checks,t.n[`removeDeactivateGuard:entry`],e),i.clearCanDeactivate(e,`external`)}}}const W=Object.entries,G=Object.hasOwn,K=e.C(`cloneRouter`);function q(r,i,a){let o=t.o(r),s=()=>{if(o.isDisposed())throw K.code(e.z.ROUTER_DISPOSED)`cannot clone a disposed router — dispose() is terminal`};s(),t.l(o.checks,t.n[`cloneRouter:entry`],i);let c=o.routeGetStore(),l=n.B(c.tree),u=c.config,d=c.resolvedForwardMap,f=c.routeCustomFields,{options:p,dependencies:m,pluginFactories:h,loggerConfig:g,limits:_,limitKeys:v}=o.getCloneState(),{definition:y,external:b}=c.lifecycleNamespace.getFactoriesByOrigin(),x={...m};i!==void 0&&n.R(i,(t,n)=>{e.O(x,t,n)});let S=a?.logger,C=S?{...g,...S}:g;s();let w=new n.t(l,{...p,...c.matcherOptions?.queryParams!==void 0&&{queryParams:c.matcherOptions.queryParams},logger:C,...v!==void 0&&{limits:Object.fromEntries(v.filter(e=>G(_,e)).map(e=>[e,_[e]]))},...c.matcherOptions?.urlParamsEncoding!==void 0&&{urlParamsEncoding:c.matcherOptions.urlParamsEncoding}},x),T=t.o(w),E=T.routeGetStore(),D=E.lifecycleNamespace;n.b(E.config,u),n.r(E,Object.assign(E.resolvedForwardMap,d)),Object.assign(E.routeCustomFields,f),c.rootPath!==``&&T.setRootPath(c.rootPath);let[O,k]=y,[A,j]=b;for(let[e,t]of W(O))D.addCanDeactivate(e,t,!0);for(let[e,t]of W(k))D.addCanActivate(e,t,!0);let M=U(w);for(let[e,t]of W(A))M.addDeactivateGuard(e,t);for(let[e,t]of W(j))M.addActivateGuard(e,t);let N=new Set(T.getCloneState().pluginFactories),P=h.filter(e=>!N.has(e));return P.length>0&&w.usePlugin(...P),w}exports.cloneRouter=q,exports.getDependenciesApi=H,exports.getLifecycleApi=U,exports.getPluginApi=m,exports.getRoutesApi=F;
|
|
2
2
|
//# sourceMappingURL=api.js.map
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -8,10 +8,9 @@ import { TreeChangedAdd, TreeChangedClear, TreeChangedEvent, TreeChangedRemove,
|
|
|
8
8
|
import { CheckFn, CheckPositionMap, ContextNamespaceClaim, DependenciesApi, DiagnosticEventMap, InterceptableMethodMap, InterceptorFn, LifecycleApi, PluginApi, RoutesApi } from "./types/api.js";
|
|
9
9
|
import { NavigationOptions, StateContext } from "./types.js";
|
|
10
10
|
import { Router } from "./Router.js";
|
|
11
|
-
import { RouterValidator } from "./types/RouterValidator.js";
|
|
12
11
|
import { Constants, ErrorCodes, UNKNOWN_ROUTE, constants, errorCodes, events } from "./constants.js";
|
|
13
12
|
import { RouterError } from "./RouterError.js";
|
|
14
13
|
import { createRouter } from "./createRouter.js";
|
|
15
14
|
import { getNavigator } from "./getNavigator.js";
|
|
16
15
|
import { resolveForwardChain } from "./namespaces/RoutesNamespace/forwardChain.js";
|
|
17
|
-
export { type AdoptedOrigins, type AnyOptions, type CheckFn, type CheckPositionMap, type Constants, type ContextNamespaceClaim, type DefaultDependencies, type DefaultParamsCallback, type DefaultRouteCallback, type DefaultSearchCallback, type DependenciesApi, type DiagnosticEventMap, type ErrorCodeKeys, type ErrorCodeToValueMap, type ErrorCodeValues, type ErrorCodes, type EventMethodMap, type EventName, type EventToNameMap, type EventToPluginMap, type EventsKeys, type ForwardToCallback, type GuardFn, type GuardFnFactory, type InterceptableMethodMap, type InterceptorFn, type LeaveFn, type LeaveState, type LifecycleApi, type LimitsConfig, type Listener, type LogCallback, type LogLevel, type LogLevelConfig, type LoggerConfig, type NavigationOptions, type NavigationTarget, type Navigator, type Options, type ParamValue, type Params, type ParamsSearch, type Plugin, type PluginApi, type PluginFactory, type PluginMethod, type QueryParamsMode, type QueryParamsOptions, type ReadonlyRoute, type Route, type RouteConfigUpdate, type RouteParams, type RouteTree, type RouteTreeState, Router, RouterError, type RouterLogger, type
|
|
16
|
+
export { type AdoptedOrigins, type AnyOptions, type CheckFn, type CheckPositionMap, type Constants, type ContextNamespaceClaim, type DefaultDependencies, type DefaultParamsCallback, type DefaultRouteCallback, type DefaultSearchCallback, type DependenciesApi, type DiagnosticEventMap, type ErrorCodeKeys, type ErrorCodeToValueMap, type ErrorCodeValues, type ErrorCodes, type EventMethodMap, type EventName, type EventToNameMap, type EventToPluginMap, type EventsKeys, type ForwardToCallback, type GuardFn, type GuardFnFactory, type InterceptableMethodMap, type InterceptorFn, type LeaveFn, type LeaveState, type LifecycleApi, type LimitsConfig, type Listener, type LogCallback, type LogLevel, type LogLevelConfig, type LoggerConfig, type NavigationOptions, type NavigationTarget, type Navigator, type Options, type ParamValue, type Params, type ParamsSearch, type Plugin, type PluginApi, type PluginFactory, type PluginMethod, type QueryParamsMode, type QueryParamsOptions, type ReadonlyRoute, type Route, type RouteConfigUpdate, type RouteParams, type RouteTree, type RouteTreeState, Router, RouterError, type RouterLogger, type RoutesApi, type SearchParamPrimitive, type SearchParamValue, type SearchParams, type SerializedRouterState, type SimpleState, type State, type StateContext, type SubscribeFn, type SubscribeState, type Subscription, type TransitionMeta, type TransitionPhase, type TransitionReason, type TreeChangedAdd, type TreeChangedClear, type TreeChangedEvent, type TreeChangedRemove, type TreeChangedReplace, type TreeChangedUpdate, type TreeStructuralPatch, UNKNOWN_ROUTE, type Unsubscribe, type UrlChannels, constants, createRouter, errorCodes, events, getNavigator, resolveForwardChain };
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-CfUevk4y.js"),t=require("./Router-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-CfUevk4y.js"),t=require("./Router-DWKUgVpc.js"),n=(e=[],n={},r={})=>new t.t(e,n,r),r=Object.freeze,i=new WeakMap,a=e=>{let t=i.get(e);return t||(t=r({navigate:e.navigate,getState:e.getState,isActiveRoute:e.isActiveRoute,canNavigateTo:e.canNavigateTo,subscribe:e.subscribe,subscribeLeave:e.subscribeLeave,isLeaveApproved:e.isLeaveApproved}),i.set(e,t)),t};exports.Router=t.t,exports.RouterError=e.b,exports.UNKNOWN_ROUTE=e.I,exports.constants=e.R,exports.createRouter=n,exports.errorCodes=e.z,exports.events=e.B,exports.getNavigator=a,exports.resolveForwardChain=t.v;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("./helpers-CfUevk4y.js"),t=Object.hasOwn;function n(e,n){if(n.length!==0&&e!=null)for(let r of n){if(!t(e,r))continue;let n;try{n=e[r]}catch{return}if(n!==void 0)return r}}function r(t,r,i,o,s,c){let l=n(i,o);if(l!==void 0)throw e.C(`router`,t).type`${a(r,l,typeof s==`function`?s():s,c)}`}function i(e,t,n,i){r(e,t,n,i,"the `params` bag this call is about to ship — the channel check above it read a different value, so the caller's object answered differently between the two reads")}function a(e,t,n="the `params` argument",r="Pass it in `search` instead"){return`Route "${e}" declares \`${t}\` as a query param, but it was given in ${n} — the path channel. ${r}; the two channels are separate since RFC-4 M2 and the router never moves a key between them.`}const o=e=>e===58||e===42;function s(e){let t=[],n=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===47&&(t.push(e.slice(n,r)),n=r+1);return t.push(e.slice(n)),t}function c(e){let t=e.length;if(t===0)return{kind:`static`,text:``};if(!o(e.charCodeAt(0))){for(let n=0;n<t;n+=1){let r=e.charCodeAt(n);if(r===60||r===62)return{error:`constraint-removed`};if(o(r)&&n+1<t)return{error:`fused-marker`}}return e.charCodeAt(t-1)===63?{error:`name-less`}:{kind:`static`,text:e}}let n=e.charCodeAt(0)===42,r=1;for(;r<t;){let t=e.charCodeAt(r);if(t===60||t===62||t===63)break;r+=1}let i=e.slice(1,r);return i.length===0?{error:`name-less`}:o(i.charCodeAt(i.length-1))?{error:`trailing-marker`}:r<t?e.charCodeAt(r)===63?{error:`optional-removed`}:{error:`constraint-removed`}:n?{kind:`splat`,name:i}:{kind:`param`,name:i}}function l(e){for(let t of s(e)){let e=c(t);if(`error`in e)return e.error}}function u(e){let t=s(e);for(let e=0;e<t.length;e+=1){let n=c(t[e]);if(`error`in n){if(n.error===`optional-removed`){let n=t[e],r=[...t];return r[e]=n.slice(0,n.indexOf(`?`)),{code:`optional-removed`,segment:n,withoutSegment:t.filter((t,n)=>n!==e).join(`/`),requiredForm:r.join(`/`)}}return n.error===`constraint-removed`?{code:`constraint-removed`,segment:t[e]}:void 0}}}const d=/[<>]/u;function f(e){for(let t=0;t<e.length;t+=1){if(e.codePointAt(t)!==63)continue;let n=t+1<e.length?e.codePointAt(t+1):-1;if(n!==-1&&n!==47&&n!==63&&n!==60)return t}return-1}const p=Object.freeze([]),m=Object.freeze({}),h=Object.freeze({urlParams:p,queryParams:p,paramTypeMap:m,pathPattern:``});function g(e,t,n){for(let r of s(e)){if(r.length===0)continue;let e=c(r);`error`in e||e.kind===`static`||(t.push(e.name),n[e.name]=`url`)}}function _(t){let n=[],r=[],i=e.E(),a=f(t);if(a!==-1){let e=t.slice(a+1).split(`&`);for(let t of e){let e=t.trim();e.length>0&&(r.push(e),i[e]=`query`)}t=t.slice(0,a)}return g(t,n,i),v(n,r,e.D(i),t)}function v(e,t,n,r){return{urlParams:e.length===0?p:e,queryParams:t.length===0?p:t,paramTypeMap:e.length===0&&t.length===0?m:n,pathPattern:r}}const y=/^[A-Z_a-z][\w-]*$/,b=/\S/,x=1e4;function S(t,n){if(t===``)throw e.C(`router`,n).type`Route name cannot be empty`}function C(t,n){if(!b.test(t))throw e.C(`router`,n).type`Route name cannot contain only whitespace`}function w(t,n){if(t.length>x)throw e.C(`router`,n).type`Route name exceeds maximum length of ${x} characters`}function T(t,n){if(t.includes(`.`))throw e.C(`router`,n).type`Route name "${t}" cannot contain dots. Use children array or { parent } option in addRoute() instead.`}function E(t,n){if(!y.test(t))throw e.C(`router`,n).type`Invalid route name "${t}". Name must start with a letter or underscore, followed by letters, numbers, underscores, or hyphens.`}function D(t,n){return e.C(`router`,t).type`${n}`}function ee(e,t,n,r){let i=new Set;for(let a of e){if(i.has(a))throw D(n,`Invalid path for route "${t}": duplicate parameter name ':${a}' in "${r}" (a param name must be unique within a route — the second binding would overwrite the first)`);i.add(a)}}function te(e,t,n,r){for(let i of e)if(d.test(i))throw D(n,`Invalid path for route "${t}": invalid query-param name "${i}" in "${r}" (a query-param name cannot contain '<' or '>' — it would never round-trip; rename the query param)`)}function O(e){let t=!0,n=!1;for(let r of e)if(r===`/`)t=!0;else if(t&&=(n=r===`:`||r===`*`,!1),!n&&r.codePointAt(0)>=128)return!0;return!1}function k(e,t,n){switch(e){case`name-less`:case`trailing-marker`:return`Invalid path for route "${t}": parameter marker (':' or '*') without a name in "${n}"`;case`fused-marker`:return`Invalid path for route "${t}": parameter marker (':' or '*') must begin a segment, but "${n}" fuses one to a static prefix (use a boundary marker like "/a/:b")`}}function A(e,t){return e.code===`optional-removed`?`Invalid path for route "${t}": optional params are not supported — "${e.segment}". Declare two sibling routes instead: "${e.withoutSegment}" and "${e.requiredForm}" (the route hierarchy already expresses optionality)`:`Invalid path for route "${t}": regex constraints are not supported — '<' and '>' are reserved in path segments ("${e.segment}"). Match the segment as a plain string and validate the value in a guard (canActivate) or app code`}function j(e,t,n,r){if(typeof e!=`string`){let t;throw t=e===null?`null`:Array.isArray(e)?`array`:typeof e,D(n,`Route path must be a string, got ${t}`)}if(e===``)return;if(/\s/.test(e))throw D(n,`Invalid path for route "${t}": whitespace not allowed in "${e}"`);if(!/^([/?~]|[^/]+$)/.test(e))throw D(n,`Route "${t}" has invalid path format: "${e}". Path should start with '/', '~', '?' or be a relative segment.`);if(e.includes(`//`))throw D(n,`Invalid path for route "${t}": double slashes not allowed in "${e}"`);let{pathPattern:i,urlParams:a,queryParams:o}=_(e);ee(a,t,n,e),te(o,t,n,e);let s=u(i);if(s!==void 0)throw D(n,A(s,t));let c=l(i);if(c!==void 0)throw D(n,k(c,t,e));if(O(i))throw D(n,`Invalid path for route "${t}": non-ASCII static segment in "${e}" — match compares static segments raw and rejects non-ASCII input, so this route would never match. Percent-encode it (e.g. '/caf%C3%A9') or use a param`);let d=r&&r.paramMeta.urlParams.length>0;if(e.startsWith(`~`)&&d)throw D(n,`Absolute path "${e}" cannot be used under parent route with URL parameters`)}const M=Object.getOwnPropertyDescriptor,N=Object.keys,P=Object.getPrototypeOf;function F(e){if(e===null)return`null`;if(typeof e==`object`){try{let t=e.constructor;if(typeof t==`function`){let e=t.name;if(typeof e==`string`&&e!==``&&e!==`Object`)return e}}catch{}return`object`}return typeof e}function I(e){for(let t of N(e)){let n=M(e,t);if(n&&(n.get||n.set))return!0}return!1}function L(t,n){if(!t||typeof t!=`object`)throw e.C(`router`,n).type`Route must be an object, got ${F(t)}`;let r=P(t);if(r!==Object.prototype&&r!==null)throw e.C(`router`,n).type`Route must be a plain object, got ${F(t)}`;if(I(t))throw e.C(`router`,n).type`Route must not have getters or setters`}function R(t,n,r,i){if(typeof n!=`function`)throw e.C(`router`,i).type`Route "${r}" ${t} must be a function`}function z(e,t,n,r){t!==void 0&&R(e,t,n,r)}function B(t,n){if(typeof t.name!=`string`)throw e.C(`router`,n).type`Route name must be a string, got ${F(t.name)}`;let r=t.name;S(r,n),C(r,n),w(r,n),!r.startsWith(`@@`)&&(T(r,n),E(r,n))}function V(e,t){if(!t.includes(`.`))return e.children.get(t);let n=e;for(let e of t.split(`.`))if(n=n.children.get(e),!n)return;return n}function H(t,n,r){if(V(t,n))throw e.C(`router`,r).plain`Route "${n}" already exists`}function U(t,n,r){if(t.has(n))throw e.C(`router`,r).plain`Duplicate route "${n}" in batch`;t.add(n)}function ne(t,n,r,i){let a=n===``?t:V(t,n);if(a){for(let t of a.children.values())if(t.path===r)throw e.C(`router`,i).plain`Path "${r}" is already defined`}}function W(t,n,r,i){let a=t.get(n);if(a?.has(r))throw e.C(`router`,i).plain`Path "${r}" is already defined`;a?a.add(r):t.set(n,new Set([r]))}function G(t,n,r,i=``,a,o){L(t,n);let s=t;B(s,n),j(s.path,s.name,n,r);let c=s.name,l=i?`${i}.${c}`:c;z(`encodeParams`,s.encodeParams,l,n),z(`decodeParams`,s.decodeParams,l,n),r&&l&&H(r,l,n),a&&U(a,l,n);let u=s.path,d=i;if(r&&ne(r,d,u,n),o&&W(o,d,u,n),s.children!==void 0){if(!Array.isArray(s.children))throw e.C(`router`,n).type`Route "${c}" children must be an array, got ${F(s.children)}`;for(let e of s.children)G(e,n,r,l,a,o)}}function K(e,t){let n=e?.then;return typeof n==`function`&&(new Promise((t,r)=>{Reflect.apply(n,e,[t,r])}).catch(t),!0)}const q=new WeakMap,J=Symbol.for(`real-router.router`);function Y(e){try{return e?.[J]===!0}catch{return!1}}function X(e){let t=q.get(e);if(!t)throw TypeError(Y(e)?"[real-router] This IS a router, but not one this copy of @real-router/core built. Core identifies a router by object identity, so it is either wrapped in a Proxy (Vue `reactive()` / Pinia — store it with `markRaw`), or your dependency tree holds two copies of @real-router/core — dedupe it to one.":`[real-router] Invalid router instance — not found in internals registry`);return t}function Z(e,t,n,i){r(t,n,i,e.getDeclaredQueryNames(n))}function re(t){if(t())throw e.x(new e.b(e.z.ROUTER_DISPOSED,{message:`[router] this router is disposed — dispose() is terminal`}))}function ie(e,t){q.set(e,t),Object.defineProperty(e,J,{value:!0})}function Q(e,t,n,r){let i=t;for(let t of e){let e=i,n=r===void 0?e:(...t)=>r(e(...t));i=(...e)=>t(n,...e)}return i(...n)}const ae={start:`start`,forwardState:`forwardState`},oe={PLUGIN_AFTER_START:`PLUGIN_AFTER_START`,SET_DEPENDENCY_COUNT:`SET_DEPENDENCY_COUNT`,SET_DEPENDENCIES_COUNT:`SET_DEPENDENCIES_COUNT`,SET_DEPENDENCY_OVERWRITE:`SET_DEPENDENCY_OVERWRITE`,SET_DEPENDENCIES_OVERWRITE:`SET_DEPENDENCIES_OVERWRITE`,REMOVE_DEPENDENCY_MISSING:`REMOVE_DEPENDENCY_MISSING`,USE_PLUGIN_COUNT:`USE_PLUGIN_COUNT`,USE_PLUGIN_DUPLICATE_IN_BATCH:`USE_PLUGIN_DUPLICATE_IN_BATCH`,USE_PLUGIN_HOOK_NOT_FUNCTION:`USE_PLUGIN_HOOK_NOT_FUNCTION`,CAN_ACTIVATE_COUNT:`CAN_ACTIVATE_COUNT`,CAN_DEACTIVATE_COUNT:`CAN_DEACTIVATE_COUNT`,CAN_ACTIVATE_OVERWRITE:`CAN_ACTIVATE_OVERWRITE`,CAN_DEACTIVATE_OVERWRITE:`CAN_DEACTIVATE_OVERWRITE`,SYNC_GUARD_THENABLE:`SYNC_GUARD_THENABLE`,SYNC_GUARD_NON_BOOLEAN:`SYNC_GUARD_NON_BOOLEAN`,GUARD_NON_BOOLEAN:`GUARD_NON_BOOLEAN`,LISTENER_COUNT:`LISTENER_COUNT`,NAVIGATE_TO_DEFAULT:`NAVIGATE_TO_DEFAULT`,BUILD_PATH:`BUILD_PATH`,IS_ACTIVE_ROUTE:`IS_ACTIVE_ROUTE`},$={"buildPath:params":`buildPath:params`,"buildPathResolved:params":`buildPathResolved:params`,"canNavigateTo:entry":`canNavigateTo:entry`,"canNavigateTo:params":`canNavigateTo:params`,"navigate:entry":`navigate:entry`,"navigate:params":`navigate:params`,"addRoute:batch":`addRoute:batch`,"replaceRoutes:batch":`replaceRoutes:batch`,"removeRoute:entry":`removeRoute:entry`,"updateRoute:entry":`updateRoute:entry`,"hasRoute:entry":`hasRoute:entry`,"getRoute:entry":`getRoute:entry`,"forwardState:entry":`forwardState:entry`,"buildNavigationState:state":`buildNavigationState:state`,"addActivateGuard:entry":`addActivateGuard:entry`,"addDeactivateGuard:entry":`addDeactivateGuard:entry`,"removeActivateGuard:entry":`removeActivateGuard:entry`,"removeDeactivateGuard:entry":`removeDeactivateGuard:entry`,"getDependency:entry":`getDependency:entry`,"getDependency:value":`getDependency:value`,"setDependency:entry":`setDependency:entry`,"setDependency:count":`setDependency:count`,"setDependencies:entry":`setDependencies:entry`,"setDependencies:count":`setDependencies:count`,"removeDependency:entry":`removeDependency:entry`,"hasDependency:entry":`hasDependency:entry`,"cloneRouter:entry":`cloneRouter:entry`,"usePlugin:count":`usePlugin:count`,"usePlugin:entry":`usePlugin:entry`,"usePlugin:plugin":`usePlugin:plugin`,"canActivate:count":`canActivate:count`,"canDeactivate:count":`canDeactivate:count`,"navigateToState:entry":`navigateToState:entry`,"setRootPath:entry":`setRootPath:entry`,"navigateToDefault:entry":`navigateToDefault:entry`,"navigateToDefault:route":`navigateToDefault:route`,"start:entry":`start:entry`,"buildPath:entry":`buildPath:entry`,"buildPathResolved:entry":`buildPathResolved:entry`,"isActiveRoute:entry":`isActiveRoute:entry`,"areStatesEqual:entry":`areStatesEqual:entry`,"shouldUpdateNode:entry":`shouldUpdateNode:entry`,"matchPath:entry":`matchPath:entry`,"matchPath:decoded":`matchPath:decoded`,"makeState:state":`makeState:state`,"navigate:state":`navigate:state`},se=e.C(`router`),ce=()=>void 0;function le(e,t,...n){let r=e.get(t);if(r===void 0)return;let i=r.length;for(let e=0;e<i&&e<r.length;e++)if(K(r[e](...n),ce))throw se.type`Async checks are not supported: the check at "${t}" returned a thenable. A check refuses by throwing synchronously.`}function ue(e,t){return(e.get(t)?.length??0)>0}function de(e,t,n){return((...r)=>{let i=n.get(e);return!i||i.length===0?t(...r):Q(i,t,r)})}function fe(e,t,n,r,i){return(a,o,s)=>{let c=n.get(e);return!c||c.length===0?t(a,o,s):Q(c,t,i(a,o,s),r)}}Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return d}});
|
|
2
|
-
//# sourceMappingURL=internals-
|
|
1
|
+
const e=require("./helpers-CfUevk4y.js"),t=Object.hasOwn;function n(e,n){if(n.length!==0&&e!=null)for(let r of n){if(!t(e,r))continue;let n;try{n=e[r]}catch{return}if(n!==void 0)return r}}function r(t,r,i,o,s,c){let l=n(i,o);if(l!==void 0)throw e.C(`router`,t).type`${a(r,l,typeof s==`function`?s():s,c)}`}function i(e,t,n,i){r(e,t,n,i,"the `params` bag this call is about to ship — the channel check above it read a different value, so the caller's object answered differently between the two reads")}function a(e,t,n="the `params` argument",r="Pass it in `search` instead"){return`Route "${e}" declares \`${t}\` as a query param, but it was given in ${n} — the path channel. ${r}; the two channels are separate since RFC-4 M2 and the router never moves a key between them.`}const o=e=>e===58||e===42;function s(e){let t=[],n=0;for(let r=0;r<e.length;r+=1)e.charCodeAt(r)===47&&(t.push(e.slice(n,r)),n=r+1);return t.push(e.slice(n)),t}function c(e){let t=e.length;if(t===0)return{kind:`static`,text:``};if(!o(e.charCodeAt(0))){for(let n=0;n<t;n+=1){let r=e.charCodeAt(n);if(r===60||r===62)return{error:`constraint-removed`};if(o(r)&&n+1<t)return{error:`fused-marker`}}return e.charCodeAt(t-1)===63?{error:`name-less`}:{kind:`static`,text:e}}let n=e.charCodeAt(0)===42,r=1;for(;r<t;){let t=e.charCodeAt(r);if(t===60||t===62||t===63)break;r+=1}let i=e.slice(1,r);return i.length===0?{error:`name-less`}:o(i.charCodeAt(i.length-1))?{error:`trailing-marker`}:r<t?e.charCodeAt(r)===63?{error:`optional-removed`}:{error:`constraint-removed`}:n?{kind:`splat`,name:i}:{kind:`param`,name:i}}function l(e){for(let t of s(e)){let e=c(t);if(`error`in e)return e.error}}function u(e){let t=s(e);for(let e=0;e<t.length;e+=1){let n=c(t[e]);if(`error`in n){if(n.error===`optional-removed`){let n=t[e],r=[...t];return r[e]=n.slice(0,n.indexOf(`?`)),{code:`optional-removed`,segment:n,withoutSegment:t.filter((t,n)=>n!==e).join(`/`),requiredForm:r.join(`/`)}}return n.error===`constraint-removed`?{code:`constraint-removed`,segment:t[e]}:void 0}}}const d=/[<>]/u;function f(e){for(let t=0;t<e.length;t+=1){if(e.codePointAt(t)!==63)continue;let n=t+1<e.length?e.codePointAt(t+1):-1;if(n!==-1&&n!==47&&n!==63&&n!==60)return t}return-1}const p=Object.freeze([]),m=Object.freeze({}),h=Object.freeze({urlParams:p,queryParams:p,paramTypeMap:m,pathPattern:``});function g(e,t,n){for(let r of s(e)){if(r.length===0)continue;let e=c(r);`error`in e||e.kind===`static`||(t.push(e.name),n[e.name]=`url`)}}function _(t){let n=[],r=[],i=e.E(),a=f(t);if(a!==-1){let e=t.slice(a+1).split(`&`);for(let t of e){let e=t.trim();e.length>0&&(r.push(e),i[e]=`query`)}t=t.slice(0,a)}return g(t,n,i),v(n,r,e.D(i),t)}function v(e,t,n,r){return{urlParams:e.length===0?p:e,queryParams:t.length===0?p:t,paramTypeMap:e.length===0&&t.length===0?m:n,pathPattern:r}}const y=/^[A-Z_a-z][\w-]*$/,b=/\S/,x=1e4;function S(t,n){if(t===``)throw e.C(`router`,n).type`Route name cannot be empty`}function C(t,n){if(!b.test(t))throw e.C(`router`,n).type`Route name cannot contain only whitespace`}function w(t,n){if(t.length>x)throw e.C(`router`,n).type`Route name exceeds maximum length of ${x} characters`}function T(t,n){if(t.includes(`.`))throw e.C(`router`,n).type`Route name "${t}" cannot contain dots. Use children array or { parent } option in addRoute() instead.`}function E(t,n){if(!y.test(t))throw e.C(`router`,n).type`Invalid route name "${t}". Name must start with a letter or underscore, followed by letters, numbers, underscores, or hyphens.`}function D(t,n){return e.C(`router`,t).type`${n}`}function ee(e,t,n,r){let i=new Set;for(let a of e){if(i.has(a))throw D(n,`Invalid path for route "${t}": duplicate parameter name ':${a}' in "${r}" (a param name must be unique within a route — the second binding would overwrite the first)`);i.add(a)}}function te(e,t,n,r){for(let i of e)if(d.test(i))throw D(n,`Invalid path for route "${t}": invalid query-param name "${i}" in "${r}" (a query-param name cannot contain '<' or '>' — it would never round-trip; rename the query param)`)}function O(e){let t=!0,n=!1;for(let r of e)if(r===`/`)t=!0;else if(t&&=(n=r===`:`||r===`*`,!1),!n&&r.codePointAt(0)>=128)return!0;return!1}function k(e,t,n){switch(e){case`name-less`:case`trailing-marker`:return`Invalid path for route "${t}": parameter marker (':' or '*') without a name in "${n}"`;case`fused-marker`:return`Invalid path for route "${t}": parameter marker (':' or '*') must begin a segment, but "${n}" fuses one to a static prefix (use a boundary marker like "/a/:b")`}}function A(e,t){return e.code===`optional-removed`?`Invalid path for route "${t}": optional params are not supported — "${e.segment}". Declare two sibling routes instead: "${e.withoutSegment}" and "${e.requiredForm}" (the route hierarchy already expresses optionality)`:`Invalid path for route "${t}": regex constraints are not supported — '<' and '>' are reserved in path segments ("${e.segment}"). Match the segment as a plain string and validate the value in a guard (canActivate) or app code`}function j(e,t,n,r){if(typeof e!=`string`){let t;throw t=e===null?`null`:Array.isArray(e)?`array`:typeof e,D(n,`Route path must be a string, got ${t}`)}if(e===``)return;if(/\s/.test(e))throw D(n,`Invalid path for route "${t}": whitespace not allowed in "${e}"`);if(!/^([/?~]|[^/]+$)/.test(e))throw D(n,`Route "${t}" has invalid path format: "${e}". Path should start with '/', '~', '?' or be a relative segment.`);if(e.includes(`//`))throw D(n,`Invalid path for route "${t}": double slashes not allowed in "${e}"`);let{pathPattern:i,urlParams:a,queryParams:o}=_(e);ee(a,t,n,e),te(o,t,n,e);let s=u(i);if(s!==void 0)throw D(n,A(s,t));let c=l(i);if(c!==void 0)throw D(n,k(c,t,e));if(O(i))throw D(n,`Invalid path for route "${t}": non-ASCII static segment in "${e}" — match compares static segments raw and rejects non-ASCII input, so this route would never match. Percent-encode it (e.g. '/caf%C3%A9') or use a param`);let d=r&&r.paramMeta.urlParams.length>0;if(e.startsWith(`~`)&&d)throw D(n,`Absolute path "${e}" cannot be used under parent route with URL parameters`)}const M=Object.getOwnPropertyDescriptor,N=Object.keys,P=Object.getPrototypeOf;function F(e){if(e===null)return`null`;if(typeof e==`object`){try{let t=e.constructor;if(typeof t==`function`){let e=t.name;if(typeof e==`string`&&e!==``&&e!==`Object`)return e}}catch{}return`object`}return typeof e}function I(e){for(let t of N(e)){let n=M(e,t);if(n&&(n.get||n.set))return!0}return!1}function L(t,n){if(!t||typeof t!=`object`)throw e.C(`router`,n).type`Route must be an object, got ${F(t)}`;let r=P(t);if(r!==Object.prototype&&r!==null)throw e.C(`router`,n).type`Route must be a plain object, got ${F(t)}`;if(I(t))throw e.C(`router`,n).type`Route must not have getters or setters`}function R(t,n,r,i){if(typeof n!=`function`)throw e.C(`router`,i).type`Route "${r}" ${t} must be a function`}function z(e,t,n,r){t!==void 0&&R(e,t,n,r)}function B(t,n){if(typeof t.name!=`string`)throw e.C(`router`,n).type`Route name must be a string, got ${F(t.name)}`;let r=t.name;S(r,n),C(r,n),w(r,n),!r.startsWith(`@@`)&&(T(r,n),E(r,n))}function V(e,t){if(!t.includes(`.`))return e.children.get(t);let n=e;for(let e of t.split(`.`))if(n=n.children.get(e),!n)return;return n}function H(t,n,r){if(V(t,n))throw e.C(`router`,r).plain`Route "${n}" already exists`}function U(t,n,r){if(t.has(n))throw e.C(`router`,r).plain`Duplicate route "${n}" in batch`;t.add(n)}function ne(t,n,r,i){let a=n===``?t:V(t,n);if(a){for(let t of a.children.values())if(t.path===r)throw e.C(`router`,i).plain`Path "${r}" is already defined`}}function W(t,n,r,i){let a=t.get(n);if(a?.has(r))throw e.C(`router`,i).plain`Path "${r}" is already defined`;a?a.add(r):t.set(n,new Set([r]))}function G(t,n,r,i=``,a,o){L(t,n);let s=t;B(s,n),j(s.path,s.name,n,r);let c=s.name,l=i?`${i}.${c}`:c;z(`encodeParams`,s.encodeParams,l,n),z(`decodeParams`,s.decodeParams,l,n),r&&l&&H(r,l,n),a&&U(a,l,n);let u=s.path,d=i;if(r&&ne(r,d,u,n),o&&W(o,d,u,n),s.children!==void 0){if(!Array.isArray(s.children))throw e.C(`router`,n).type`Route "${c}" children must be an array, got ${F(s.children)}`;for(let e of s.children)G(e,n,r,l,a,o)}}function K(e,t){let n=e?.then;return typeof n==`function`&&(new Promise((t,r)=>{Reflect.apply(n,e,[t,r])}).catch(t),!0)}const q=new WeakMap,J=Symbol.for(`real-router.router`);function Y(e){try{return e?.[J]===!0}catch{return!1}}function X(e){let t=q.get(e);if(!t)throw TypeError(Y(e)?"[real-router] This IS a router, but not one this copy of @real-router/core built. Core identifies a router by object identity, so it is either wrapped in a Proxy (Vue `reactive()` / Pinia — store it with `markRaw`), or your dependency tree holds two copies of @real-router/core — dedupe it to one.":`[real-router] Invalid router instance — not found in internals registry`);return t}function Z(e,t,n,i){r(t,n,i,e.getDeclaredQueryNames(n))}function re(t){if(t())throw e.x(new e.b(e.z.ROUTER_DISPOSED,{message:`[router] this router is disposed — dispose() is terminal`}))}function ie(e,t){q.set(e,t),Object.defineProperty(e,J,{value:!0})}function Q(e,t,n,r){let i=t;for(let t of e){let e=i,n=r===void 0?e:(...t)=>r(e(...t));i=(...e)=>t(n,...e)}return i(...n)}const ae={start:`start`,forwardState:`forwardState`},oe={PLUGIN_AFTER_START:`PLUGIN_AFTER_START`,SET_DEPENDENCY_COUNT:`SET_DEPENDENCY_COUNT`,SET_DEPENDENCIES_COUNT:`SET_DEPENDENCIES_COUNT`,SET_DEPENDENCY_OVERWRITE:`SET_DEPENDENCY_OVERWRITE`,SET_DEPENDENCIES_OVERWRITE:`SET_DEPENDENCIES_OVERWRITE`,REMOVE_DEPENDENCY_MISSING:`REMOVE_DEPENDENCY_MISSING`,USE_PLUGIN_COUNT:`USE_PLUGIN_COUNT`,USE_PLUGIN_DUPLICATE_IN_BATCH:`USE_PLUGIN_DUPLICATE_IN_BATCH`,USE_PLUGIN_HOOK_NOT_FUNCTION:`USE_PLUGIN_HOOK_NOT_FUNCTION`,CAN_ACTIVATE_COUNT:`CAN_ACTIVATE_COUNT`,CAN_DEACTIVATE_COUNT:`CAN_DEACTIVATE_COUNT`,CAN_ACTIVATE_OVERWRITE:`CAN_ACTIVATE_OVERWRITE`,CAN_DEACTIVATE_OVERWRITE:`CAN_DEACTIVATE_OVERWRITE`,SYNC_GUARD_THENABLE:`SYNC_GUARD_THENABLE`,SYNC_GUARD_NON_BOOLEAN:`SYNC_GUARD_NON_BOOLEAN`,GUARD_NON_BOOLEAN:`GUARD_NON_BOOLEAN`,LISTENER_COUNT:`LISTENER_COUNT`,NAVIGATE_TO_DEFAULT:`NAVIGATE_TO_DEFAULT`,BUILD_PATH:`BUILD_PATH`,IS_ACTIVE_ROUTE:`IS_ACTIVE_ROUTE`,DROPPED_QUERY_KEY:`DROPPED_QUERY_KEY`,UNDECLARED_PARAM_KEY:`UNDECLARED_PARAM_KEY`,CODEC_ROUND_TRIP:`CODEC_ROUND_TRIP`},$={"buildPath:params":`buildPath:params`,"buildPathResolved:params":`buildPathResolved:params`,"canNavigateTo:entry":`canNavigateTo:entry`,"canNavigateTo:params":`canNavigateTo:params`,"navigate:entry":`navigate:entry`,"navigate:params":`navigate:params`,"addRoute:batch":`addRoute:batch`,"replaceRoutes:batch":`replaceRoutes:batch`,"removeRoute:entry":`removeRoute:entry`,"updateRoute:entry":`updateRoute:entry`,"hasRoute:entry":`hasRoute:entry`,"getRoute:entry":`getRoute:entry`,"forwardState:entry":`forwardState:entry`,"buildNavigationState:state":`buildNavigationState:state`,"addActivateGuard:entry":`addActivateGuard:entry`,"addDeactivateGuard:entry":`addDeactivateGuard:entry`,"removeActivateGuard:entry":`removeActivateGuard:entry`,"removeDeactivateGuard:entry":`removeDeactivateGuard:entry`,"getDependency:entry":`getDependency:entry`,"getDependency:value":`getDependency:value`,"setDependency:entry":`setDependency:entry`,"setDependency:count":`setDependency:count`,"setDependencies:entry":`setDependencies:entry`,"setDependencies:count":`setDependencies:count`,"removeDependency:entry":`removeDependency:entry`,"hasDependency:entry":`hasDependency:entry`,"cloneRouter:entry":`cloneRouter:entry`,"usePlugin:count":`usePlugin:count`,"usePlugin:entry":`usePlugin:entry`,"usePlugin:plugin":`usePlugin:plugin`,"canActivate:count":`canActivate:count`,"canDeactivate:count":`canDeactivate:count`,"navigateToState:entry":`navigateToState:entry`,"setRootPath:entry":`setRootPath:entry`,"navigateToDefault:entry":`navigateToDefault:entry`,"navigateToDefault:route":`navigateToDefault:route`,"start:entry":`start:entry`,"buildPath:entry":`buildPath:entry`,"buildPathResolved:entry":`buildPathResolved:entry`,"isActiveRoute:entry":`isActiveRoute:entry`,"areStatesEqual:entry":`areStatesEqual:entry`,"shouldUpdateNode:entry":`shouldUpdateNode:entry`,"matchPath:entry":`matchPath:entry`,"matchPath:decoded":`matchPath:decoded`,"makeState:state":`makeState:state`,"navigate:state":`navigate:state`},se=e.C(`router`),ce=()=>void 0;function le(e,t,...n){let r=e.get(t);if(r===void 0)return;let i=r.length;for(let e=0;e<i&&e<r.length;e++)if(K(r[e](...n),ce))throw se.type`Async checks are not supported: the check at "${t}" returned a thenable. A check refuses by throwing synchronously.`}function ue(e,t){return(e.get(t)?.length??0)>0}function de(e,t,n){return((...r)=>{let i=n.get(e);return!i||i.length===0?t(...r):Q(i,t,r)})}function fe(e,t,n,r,i){return(a,o,s)=>{let c=n.get(e);return!c||c.length===0?t(a,o,s):Q(c,t,i(a,o,s),r)}}Object.defineProperty(exports,"C",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"E",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"S",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"T",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"_",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"b",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return K}}),Object.defineProperty(exports,"g",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"h",{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,"m",{enumerable:!0,get:function(){return G}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return X}}),Object.defineProperty(exports,"p",{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,"v",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"w",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"x",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"y",{enumerable:!0,get:function(){return d}});
|
|
2
|
+
//# sourceMappingURL=internals-C-m8EvAR.js.map
|