@real-router/core 0.149.0 → 0.150.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-_0vZHk6R.js +2 -0
- package/dist/cjs/Router-_0vZHk6R.js.map +1 -0
- package/dist/cjs/RouterError-CentZBJj.js.map +1 -1
- package/dist/cjs/RouterError.d.ts +1 -0
- package/dist/cjs/api.js +1 -1
- package/dist/cjs/api.js.map +1 -1
- package/dist/cjs/helpers-B2Zsa5R_.js +2 -0
- package/dist/cjs/{helpers-MqHoQdC_.js.map → helpers-B2Zsa5R_.js.map} +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/internals-C18omEfg.js +2 -0
- package/dist/cjs/{internals-2GhdY5S9.js.map → internals-C18omEfg.js.map} +1 -1
- package/dist/cjs/types/route-node-types.d.ts +1 -0
- package/dist/cjs/types/router.d.ts +1 -0
- package/dist/cjs/utils.js +1 -1
- package/dist/cjs/validation.js +1 -1
- package/dist/esm/Router-DVdK_R0k.mjs +2 -0
- package/dist/esm/Router-DVdK_R0k.mjs.map +1 -0
- package/dist/esm/RouterError-Dy1_FfLa.mjs.map +1 -1
- package/dist/esm/RouterError.d.mts +1 -0
- package/dist/esm/api.mjs +1 -1
- package/dist/esm/api.mjs.map +1 -1
- package/dist/esm/{helpers-Bg_svUPj.mjs → helpers-BnQy9vYH.mjs} +2 -2
- package/dist/esm/{helpers-Bg_svUPj.mjs.map → helpers-BnQy9vYH.mjs.map} +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/internals-CBAb3okL.mjs +2 -0
- package/dist/esm/{internals-CL2IjTt7.mjs.map → internals-CBAb3okL.mjs.map} +1 -1
- package/dist/esm/types/route-node-types.d.mts +1 -0
- package/dist/esm/types/router.d.mts +1 -0
- package/dist/esm/utils.mjs +1 -1
- package/dist/esm/validation.mjs +1 -1
- package/package.json +1 -1
- package/dist/cjs/Router-BA4QK0hW.js +0 -2
- package/dist/cjs/Router-BA4QK0hW.js.map +0 -1
- package/dist/cjs/helpers-MqHoQdC_.js +0 -2
- package/dist/cjs/internals-2GhdY5S9.js +0 -2
- package/dist/esm/Router-B1fN9j6j.mjs +0 -2
- package/dist/esm/Router-B1fN9j6j.mjs.map +0 -1
- package/dist/esm/internals-CL2IjTt7.mjs +0 -2
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{c as e,i as t,n,s as r,t as i,v as a}from"./RouterError-Dy1_FfLa.mjs";const o=Object.hasOwn;function s(e,t){if(t.length!==0&&e!=null)for(let n of t){if(!o(e,n))continue;let t;try{t=e[n]}catch{return}if(t!==void 0)return n}}function c(e,n,r,i,a,o){let c=s(r,i);if(c!==void 0)throw t(`router`,e).type`${u(n,c,typeof a==`function`?a():a,o)}`}function l(e,t,n,r){c(e,t,n,r,"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 u(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 d=e=>e===58||e===42;function f(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 p(e){let t=e.length;if(t===0)return{kind:`static`,text:``};if(!d(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(d(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`}:d(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 m(e){for(let t of f(e)){let e=p(t);if(`error`in e)return e.error}}function ee(e){let t=f(e);for(let e=0;e<t.length;e+=1){let n=p(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 h=/[<>]/u;function g(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 _=Object.freeze([]),v=Object.freeze({}),te=Object.freeze({urlParams:_,queryParams:_,paramTypeMap:v,pathPattern:``});function y(e,t,n){for(let r of f(e)){if(r.length===0)continue;let e=p(r);`error`in e||e.kind===`static`||(t.push(e.name),n[e.name]=`url`)}}function b(t){let n=[],i=[],a=r(),o=g(t);if(o!==-1){let e=t.slice(o+1).split(`&`);for(let t of e){let e=t.trim();e.length>0&&(i.push(e),a[e]=`query`)}t=t.slice(0,o)}return y(t,n,a),x(n,i,e(a),t)}function x(e,t,n,r){return{urlParams:e.length===0?_:e,queryParams:t.length===0?_:t,paramTypeMap:e.length===0&&t.length===0?v:n,pathPattern:r}}const S=/^[A-Z_a-z][\w-]*$/,C=/\S/,w=1e4;function T(e,n){if(e===``)throw t(`router`,n).type`Route name cannot be empty`}function E(e,n){if(!C.test(e))throw t(`router`,n).type`Route name cannot contain only whitespace`}function ne(e,n){if(e.length>w)throw t(`router`,n).type`Route name exceeds maximum length of ${w} characters`}function D(e,n){if(e.includes(`.`))throw t(`router`,n).type`Route name "${e}" cannot contain dots. Use children array or { parent } option in addRoute() instead.`}function re(e,n){if(!S.test(e))throw t(`router`,n).type`Invalid route name "${e}". Name must start with a letter or underscore, followed by letters, numbers, underscores, or hyphens.`}function O(e,n){return t(`router`,e).type`${n}`}function k(e,t,n,r){let i=new Set;for(let a of e){if(i.has(a))throw O(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 A(e,t,n,r){for(let i of e)if(h.test(i))throw O(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 j(e){let t=!0,n=!1;for(let r of e){if(r===`/`){t=!0;continue}if(t&&=(n=r===`:`||r===`*`,!1),!n&&r.codePointAt(0)>=128)return!0}return!1}function M(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 N(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 P(e,t,n,r){if(typeof e!=`string`){let t;throw t=e===null?`null`:Array.isArray(e)?`array`:typeof e,O(n,`Route path must be a string, got ${t}`)}if(e===``)return;if(/\s/.test(e))throw O(n,`Invalid path for route "${t}": whitespace not allowed in "${e}"`);if(!/^([/?~]|[^/]+$)/.test(e))throw O(n,`Route "${t}" has invalid path format: "${e}". Path should start with '/', '~', '?' or be a relative segment.`);if(e.includes(`//`))throw O(n,`Invalid path for route "${t}": double slashes not allowed in "${e}"`);let{pathPattern:i,urlParams:a,queryParams:o}=b(e);k(a,t,n,e),A(o,t,n,e);let s=ee(i);if(s!==void 0)throw O(n,N(s,t));let c=m(i);if(c!==void 0)throw O(n,M(c,t,e));if(j(i))throw O(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 l=r&&r.paramMeta.urlParams.length>0;if(e.startsWith(`~`)&&l)throw O(n,`Absolute path "${e}" cannot be used under parent route with URL parameters`)}const F=Object.getOwnPropertyDescriptor,I=Object.keys,L=Object.getPrototypeOf;function R(e){if(e===null)return`null`;if(typeof e==`object`){try{let t=e.constructor;if(typeof t==`function`&&t.name!==`Object`)return t.name||`object`}catch{}return`object`}return typeof e}function z(e){for(let t of I(e)){let n=F(e,t);if(n&&(n.get||n.set))return!0}return!1}function B(e,n){if(!e||typeof e!=`object`)throw t(`router`,n).type`Route must be an object, got ${R(e)}`;let r=L(e);if(r!==Object.prototype&&r!==null)throw t(`router`,n).type`Route must be a plain object, got ${R(e)}`;if(z(e))throw t(`router`,n).type`Route must not have getters or setters`}function V(e,n,r,i){if(typeof n!=`function`)throw t(`router`,i).type`Route "${r}" ${e} must be a function`}function H(e,t,n,r){t!==void 0&&V(e,t,n,r)}function U(e,n){if(typeof e.name!=`string`)throw t(`router`,n).type`Route name must be a string, got ${R(e.name)}`;let r=e.name;T(r,n),E(r,n),ne(r,n),!r.startsWith(`@@`)&&(D(r,n),re(r,n))}function W(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 G(e,n,r){if(W(e,n))throw t(`router`,r).plain`Route "${n}" already exists`}function K(e,n,r){if(e.has(n))throw t(`router`,r).plain`Duplicate route "${n}" in batch`;e.add(n)}function q(e,n,r,i){let a=n===``?e:W(e,n);if(a){for(let e of a.children.values())if(e.path===r)throw t(`router`,i).plain`Path "${r}" is already defined`}}function J(e,n,r,i){let a=e.get(n);if(a?.has(r))throw t(`router`,i).plain`Path "${r}" is already defined`;a?a.add(r):e.set(n,new Set([r]))}function Y(e,n,r,i=``,a,o){B(e,n);let s=e;U(s,n),P(s.path,s.name,n,r);let c=s.name,l=i?`${i}.${c}`:c;H(`encodeParams`,s.encodeParams,l,n),H(`decodeParams`,s.decodeParams,l,n),r&&l&&G(r,l,n),a&&K(a,l,n);let u=s.path,d=i;if(r&&q(r,d,u,n),o&&J(o,d,u,n),s.children!==void 0){if(!Array.isArray(s.children))throw t(`router`,n).type`Route "${c}" children must be an array, got ${R(s.children)}`;for(let e of s.children)Y(e,n,r,l,a,o)}}const X=new WeakMap,Z=Symbol.for(`real-router.router`);function ie(e){try{return e?.[Z]===!0}catch{return!1}}function ae(e){let t=X.get(e);if(!t)throw TypeError(ie(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 oe(e,t,n,r){c(t,n,r,e.getDeclaredQueryNames(n))}function se(e){if(e())throw n(new i(a.ROUTER_DISPOSED,{message:`[router] this router is disposed — dispose() is terminal`}))}function Q(e,t){X.set(e,t),Object.defineProperty(e,Z,{value:!0})}function $(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 ce={start:`start`,forwardState:`forwardState`},le={PLUGIN_AFTER_START:`PLUGIN_AFTER_START`},ue={"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`};function de(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++)r[e](...n)}function fe(e,t,n){return((...r)=>{let i=n.get(e);return!i||i.length===0?t(...r):$(i,t,r)})}function pe(e,t,n,r,i){return(a,o,s)=>{let c=n.get(e);return!c||c.length===0?t(a,o,s):$(c,t,i(a,o,s),r)}}export{s as C,l as S,h as _,pe as a,f as b,de as c,V as d,Y as f,te as g,T as h,fe as i,se as l,D as m,ue as n,ae as o,B as p,ce as r,Q as s,le as t,oe as u,b as v,u as w,c as x,p as y};
|
|
2
|
-
//# sourceMappingURL=internals-CL2IjTt7.mjs.map
|