@real-router/core 0.68.0 → 0.68.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/cjs/Router-B_vng8Xg.js +2 -0
  2. package/dist/cjs/Router-B_vng8Xg.js.map +1 -0
  3. package/dist/cjs/api.d.ts +1 -1
  4. package/dist/cjs/api.js +1 -1
  5. package/dist/cjs/api.js.map +1 -1
  6. package/dist/cjs/cloneRouter-B0XcxjC8.js +2 -0
  7. package/dist/cjs/{cloneRouter-d9N0A7BI.js.map → cloneRouter-B0XcxjC8.js.map} +1 -1
  8. package/dist/cjs/esm-B6E99LjJ.js +2 -0
  9. package/dist/cjs/esm-B6E99LjJ.js.map +1 -0
  10. package/dist/cjs/{index-BHYayJAM.d.ts → index-DlHpdGTA.d.ts} +40 -4
  11. package/dist/cjs/index-DlHpdGTA.d.ts.map +1 -0
  12. package/dist/cjs/index.d.ts +1 -1
  13. package/dist/cjs/index.js +1 -1
  14. package/dist/cjs/utils.js +1 -1
  15. package/dist/cjs/utils.js.map +1 -1
  16. package/dist/cjs/validation.d.ts +2 -2
  17. package/dist/cjs/validation.js +1 -1
  18. package/dist/esm/Router-BA0Wn8jU.mjs +2 -0
  19. package/dist/esm/Router-BA0Wn8jU.mjs.map +1 -0
  20. package/dist/esm/api.d.mts +1 -1
  21. package/dist/esm/api.mjs +1 -1
  22. package/dist/esm/api.mjs.map +1 -1
  23. package/dist/esm/cloneRouter-Dk10jp03.mjs +2 -0
  24. package/dist/esm/{cloneRouter-DGKha3Du.mjs.map → cloneRouter-Dk10jp03.mjs.map} +1 -1
  25. package/dist/esm/esm-CQSKkkua.mjs +2 -0
  26. package/dist/esm/esm-CQSKkkua.mjs.map +1 -0
  27. package/dist/esm/{index-BHYayJAM.d.mts → index-DlHpdGTA.d.mts} +40 -4
  28. package/dist/esm/index-DlHpdGTA.d.mts.map +1 -0
  29. package/dist/esm/index.d.mts +1 -1
  30. package/dist/esm/index.mjs +1 -1
  31. package/dist/esm/utils.mjs +1 -1
  32. package/dist/esm/utils.mjs.map +1 -1
  33. package/dist/esm/validation.d.mts +2 -2
  34. package/dist/esm/validation.mjs +1 -1
  35. package/package.json +3 -3
  36. package/dist/cjs/Router-BcWqit3y.js +0 -2
  37. package/dist/cjs/Router-BcWqit3y.js.map +0 -1
  38. package/dist/cjs/cloneRouter-d9N0A7BI.js +0 -2
  39. package/dist/cjs/index-BHYayJAM.d.ts.map +0 -1
  40. package/dist/cjs/internals-DJjgSePy.js +0 -2
  41. package/dist/cjs/internals-DJjgSePy.js.map +0 -1
  42. package/dist/esm/Router-AopZx1bD.mjs +0 -2
  43. package/dist/esm/Router-AopZx1bD.mjs.map +0 -1
  44. package/dist/esm/cloneRouter-DGKha3Du.mjs +0 -2
  45. package/dist/esm/index-BHYayJAM.d.mts.map +0 -1
  46. package/dist/esm/internals-C8mRvTxc.mjs +0 -2
  47. package/dist/esm/internals-C8mRvTxc.mjs.map +0 -1
@@ -1,2 +0,0 @@
1
- import{C as e,h as t,n,t as r,v as i}from"./Router-AopZx1bD.mjs";import{r as a}from"./internals-C8mRvTxc.mjs";function o(t){if(t())throw new n(e.ROUTER_DISPOSED)}function s(t){if(t())throw new n(e.REENTRANT_TREE_MUTATION)}const c=new WeakMap;function l(t){let r=c.get(t);if(r)return r;let i=a(t),s={makeState:(e,t,n,r)=>(i.validator?.state.validateMakeStateArgs(e,t,n),i.makeState(e,t,n,r?.params)),buildState:(e,t)=>{i.validator?.routes.validateStateBuilderArgs(e,t,`buildState`);let{name:n,params:r}=i.forwardState(e,t);return i.buildStateResolved(n,r)},forwardState:(e,t)=>(i.validator?.routes.validateStateBuilderArgs(e,t,`forwardState`),i.forwardState(e,t)),matchPath:e=>(i.validator?.routes.validateMatchPathArgs(e),i.matchPath(e,i.getOptions())),navigateToState:(e,t)=>(o(i.isDisposed),i.validator?.navigation.validateNavigateToStateArgs(e),t!==void 0&&i.validator?.navigation.validateNavigationOptions(t,`navigateToState`),i.navigateToState(e,t)),setRootPath:e=>{o(i.isDisposed),i.validator?.routes.validateSetRootPathArgs(e),i.setRootPath(e)},getRootPath:i.getRootPath,addEventListener:(e,t)=>(o(i.isDisposed),i.validator?.eventBus.validateListenerArgs(e,t),i.addEventListener(e,t)),buildNavigationState:(e,t={})=>{i.validator?.routes.validateStateBuilderArgs(e,t,`buildNavigationState`);let{name:n,params:r}=i.forwardState(e,t),a=i.buildStateResolved(n,r);if(a)return i.makeState(a.name,a.params,i.buildPath(a.name,a.params),a.meta)},getOptions:i.getOptions,getTree:i.getTree,addInterceptor:(e,t)=>{o(i.isDisposed),i.validator?.plugins.validateAddInterceptorArgs(e,t);let n=i.interceptors.get(e);return n||(n=[],i.interceptors.set(e,n)),n.push(t),()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}},getRouteConfig:e=>{let t=i.routeGetStore();if(t.matcher.hasRoute(e))return t.routeCustomFields[e]},extendRouter:r=>{o(i.isDisposed);let a=Object.keys(r);for(let r of a)if(r in t)throw new n(e.PLUGIN_CONFLICT,{message:`Cannot extend router: property "${r}" already exists`});for(let e of a)t[e]=r[e];let s={keys:a};i.routerExtensions.push(s);let c=!1;return()=>{if(c)return;c=!0;for(let e of s.keys)delete t[e];let e=i.routerExtensions.indexOf(s);e!==-1&&i.routerExtensions.splice(e,1)}},emitTransitionError:e=>{o(i.isDisposed),i.emitTransitionError(e)},claimContextNamespace:t=>{if(o(i.isDisposed),i.contextClaimRecords.has(t))throw new n(e.CONTEXT_NAMESPACE_ALREADY_CLAIMED,{message:`Cannot claim context namespace: "${t}" is already claimed by another plugin`});return i.contextClaimRecords.add(t),{write(e,n){e.context[t]=n},release(){i.contextClaimRecords.delete(t)}}}};return c.set(t,s),s}function u(e){let t=a(e),n=t.routeGetStore().lifecycleNamespace;return{addActivateGuard(e,r){o(t.isDisposed),t.validator?.routes.validateRouteName(e,`addActivateGuard`),t.validator?.lifecycle.validateHandler(r,`addActivateGuard`),n.addCanActivate(e,r)},addDeactivateGuard(e,r){o(t.isDisposed),t.validator?.routes.validateRouteName(e,`addDeactivateGuard`),t.validator?.lifecycle.validateHandler(r,`addDeactivateGuard`),n.addCanDeactivate(e,r)},removeActivateGuard(e){o(t.isDisposed),t.validator?.routes.validateRouteName(e,`removeActivateGuard`),n.clearCanActivate(e)},removeDeactivateGuard(e){o(t.isDisposed),t.validator?.routes.validateRouteName(e,`removeDeactivateGuard`),n.clearCanDeactivate(e)}}}function d(o,s){let c=a(o);if(c.isDisposed())throw new n(e.ROUTER_DISPOSED);c.validator?.dependencies.validateCloneArgs(s);let l=c.routeGetStore(),d=i(l.tree),f=l.config,p=l.resolvedForwardMap,m=l.routeCustomFields,{options:h,dependencies:g,pluginFactories:_}=c.getCloneState(),{definition:v,external:y}=l.lifecycleNamespace.getFactoriesByOrigin(),b=new r(d,h,{...g,...s}),x=a(b).routeGetStore(),S=x.lifecycleNamespace,[C,w]=v,[T,E]=y;for(let[e,t]of Object.entries(C))S.addCanDeactivate(e,t,!0);for(let[e,t]of Object.entries(w))S.addCanActivate(e,t,!0);let D=u(b);for(let[e,t]of Object.entries(T))D.addDeactivateGuard(e,t);for(let[e,t]of Object.entries(E))D.addActivateGuard(e,t);return _.length>0&&b.usePlugin(..._),t(x.config,f),Object.assign(x.resolvedForwardMap,p),Object.assign(x.routeCustomFields,m),b}export{s as a,o as i,u as n,l as r,d as t};
2
- //# sourceMappingURL=cloneRouter-DGKha3Du.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-BHYayJAM.d.mts","names":["pattern","RegExp","constraint","urlParams","queryParams","spatParams","paramTypeMap","Readonly","Record","constraintPatterns","ReadonlyMap","ConstraintPattern","pathPattern","name","path","fullName","absolute","children","MatcherInputNode","nonAbsoluteChildren","paramMeta","ParamMeta","parent","CompiledRoute","depth","matchSegments","meta","declaredQueryParams","declaredQueryParamsSet","ReadonlySet","hasTrailingSlash","hasConstraints","buildStaticParts","buildParamSlots","BuildParamSlot","buildParamNamesSet","cachedResult","MatchResult","paramName","encoder","value","isOptional","queryParamsMode","trailingSlash","skipName","staticChildren","SegmentNode","hasChildren","paramChild","node","fork","ForkMeta","splatChild","route","routeIsStrong","slashChildRoute","segments","params","caseSensitive","strictTrailingSlash","strictQueryParams","urlParamsEncoding","URLParamsEncodingType","parseQueryString","queryString","buildQueryString","private","options","ResolvedMatcherOptions","constructor","SegmentMatcherOptions","registerTree","match","buildPath","BuildPathOptions","getSegmentsByName","getMetaByName","hasRoute","arrayFormat","ArrayFormat","booleanFormat","BooleanFormat","nullFormat","NullFormat","numberFormat","NumberFormat","QueryParamPrimitive","Record","QueryParamValue","querystring","removedParams","keptParams","search","Options","opts","path","params","paramsToOmit","OmitResponse","paramsToKeep","KeepResponse","FinalOptions","key","name","path","children","RouteDefinition","absolute","ReadonlyMap","RouteTree","paramMeta","ParamMeta","parent","nonAbsoluteChildren","fullName","paramTypeMap","Readonly","Record","skipFreeze","trailingSlashMode","TrailingSlashMode","queryParamsMode","QueryParamsMode","queryParams","Options","urlParamsEncoding","URLParamsEncodingType","BasePathOptions","ignoreConstraints","strictTrailingSlash","strongMatching","ParamSource","ParamTypeMap","P","RouteParams","segments","params","meta","RouteTreeStateMeta","routes","TreeBuildOptions","options","tree","routeName","node","caseSensitive","strictQueryParams","QueryParamsConfig","SegmentMatcher","CreateMatcherOptions","Matcher","route","methodName","rootNode","parentName","Set","seenNames","Map","seenPathsByParent"],"sources":["../../../path-matcher/dist/esm/index.d.mts","../../../search-params/dist/esm/index.d.mts","../../../route-tree/dist/esm/index.d.mts"],"mappings":";;;;;;;;;;AAuBqB;AAAA;UAZX,iBAAA;;;;;;WAMCA,OAAAA,EAAS,MAAM;EAmDgB;;;;;EAAA,SA7C/BE,UAAAA;AAAAA;;;;UAKD,SAAA;EA8CY;AAAA;AAAA;;;EAAA,SAxCXC,SAAAA;EAkDe;AAAA;;;;EAAA,SA5CfC,WAAAA;EAmD8B;;;;;EAAA,SA7C9BC,UAAAA;EAwCAQ;;;;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CVC,YAAAA,EAAc,QAAA,CAAS,MAAA;AAAA;;;;;;;;;;;KA6K7B,iBAAA,GAAoB,QAAQ,CAAC,OAAA;;;;UAIxB,oBAAA;EAAA,SACC8B,aAAAA;EAAAA,SACAhB,mBAAAA;EAAAA,SACAiB,iBAAAA;EAAAA,SACArB,iBAAAA;EAAAA,SACAF,WAAAA,GAAc,iBAAiB;AAAA;;;;AAxNd;AAAA;;KAgOvB,OAAA,GAAU,cAAc"}
@@ -1,2 +0,0 @@
1
- const e=new WeakMap;function t(t){let n=e.get(t);if(!n)throw TypeError(`[real-router] Invalid router instance — not found in internals registry`);return n}function n(t,n){e.set(t,n)}function r(e,t,n){let r=t;for(let t of e){let e=r;r=(...n)=>t(e,...n)}return r(...n)}function i(e,t,n){return((...i)=>{let a=n.get(e);return!a||a.length===0?t(...i):r(a,t,i)})}function a(e,t,n){return(i,a)=>{let o=n.get(e);return!o||o.length===0?t(i,a):r(o,t,[i,a])}}export{n as i,i as n,t as r,a as t};
2
- //# sourceMappingURL=internals-C8mRvTxc.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internals-C8mRvTxc.mjs","names":[],"sources":["../../src/internals.ts"],"sourcesContent":["import type { DependenciesStore } from \"./namespaces\";\nimport type { RoutesStore } from \"./namespaces/RoutesNamespace\";\nimport type { Router as RouterClass } from \"./Router\";\nimport type { EventMethodMap, PluginFactory } from \"./types\";\nimport type { RouterValidator } from \"./types/RouterValidator\";\nimport type { SerializedRouterState } from \"./utils\";\nimport type {\n DefaultDependencies,\n EventName,\n NavigationOptions,\n Options,\n Params,\n Plugin,\n Router as RouterInterface,\n RouteTreeState,\n SimpleState,\n State,\n TreeChangedEvent,\n Unsubscribe,\n} from \"@real-router/types\";\nimport type { RouteTree } from \"route-tree\";\n\nexport interface RouterInternals<\n D extends DefaultDependencies = DefaultDependencies,\n> {\n readonly makeState: <P extends Params = Params>(\n name: string,\n params?: P,\n path?: string,\n meta?: Record<string, Record<string, \"url\" | \"query\">>,\n ) => State<P>;\n\n readonly forwardState: <P extends Params = Params>(\n routeName: string,\n routeParams: P,\n ) => SimpleState<P>;\n\n readonly buildStateResolved: (\n resolvedName: string,\n resolvedParams: Params,\n ) => RouteTreeState | undefined;\n\n readonly matchPath: <P extends Params = Params>(\n path: string,\n options?: Options,\n ) => State<P> | undefined;\n\n readonly getOptions: () => Options;\n\n readonly addEventListener: <E extends EventName>(\n eventName: E,\n cb: Plugin[EventMethodMap[E]],\n ) => Unsubscribe;\n\n /**\n * Route-tree mutation channel — internal access for the `getRoutesApi`\n * wrapper. A dedicated bridge is required because the public\n * `addEventListener<E extends EventName>` structurally rejects\n * `\"TREE_CHANGED\"` (it is not in the public `EventName` union), is strict on\n * duplicates, and exposes neither `emit` nor `listenerCount`.\n */\n readonly treeChanged: {\n readonly emit: (event: TreeChangedEvent) => void;\n readonly subscribe: (\n handler: (event: TreeChangedEvent) => void,\n ) => Unsubscribe;\n readonly listenerCount: () => number;\n /**\n * True while a `TREE_CHANGED` emit is on the stack — `getRoutesApi` reads it\n * to reject reentrant route-CRUD from a `subscribeChanges` handler (#1032).\n */\n readonly isEmitting: () => boolean;\n };\n\n readonly buildPath: (route: string, params?: Params) => string;\n\n readonly emitTransitionError: (error: Error) => void;\n\n /**\n * Emits `TRANSITION_SUCCESS` directly (no FSM transition) — used by\n * `getRoutesApi().replace()` to notify `router.subscribe` listeners when a\n * structural replace revalidates the active state (#950). Mirrors the success\n * emission `completeTransition` / `navigateToNotFound` perform.\n */\n readonly emitTransitionSuccess: (\n toState: State,\n fromState: State | undefined,\n opts?: NavigationOptions,\n ) => void;\n\n /**\n * Commits the not-found (`UNKNOWN_ROUTE`) state for `path` and emits\n * `TRANSITION_SUCCESS` — the `NavigationNamespace.navigateToNotFound`\n * primitive. `replace()` uses it when a structural replace drops the active\n * route, so subscribers are notified instead of the state silently clearing\n * (#950).\n */\n readonly navigateToNotFound: (path: string) => State;\n\n readonly start: (path: string) => Promise<State>;\n\n /**\n * Plugin-only navigation entry point — delegates to\n * `NavigationNamespace.navigateToState` (`getPluginApi(router).navigateToState`).\n * Hidden from `Router`/`Navigator` to keep the userland surface minimal;\n * see `core-types/src/api.ts` for usage docs.\n */\n readonly navigateToState: (\n state: State,\n options?: NavigationOptions,\n ) => Promise<State>;\n\n /* eslint-disable @typescript-eslint/no-explicit-any -- heterogeneous map: stores different InterceptorFn<M> types under different keys */\n readonly interceptors: Map<\n string,\n ((next: (...args: any[]) => any, ...args: any[]) => any)[]\n >;\n /* eslint-enable @typescript-eslint/no-explicit-any */\n\n readonly setRootPath: (rootPath: string) => void;\n readonly getRootPath: () => string;\n\n readonly getTree: () => RouteTree;\n\n readonly isDisposed: () => boolean;\n\n validator: RouterValidator | null;\n\n // Dependencies (issue #172)\n readonly dependenciesGetStore: () => DependenciesStore<D>;\n\n // Clone support (issue #173, consolidated #964). One accessor for the\n // source-side snapshot a clone carries over besides the route store, so a new\n // clone-relevant subsystem is wired in a single place instead of being spread\n // across separate methods.\n readonly getCloneState: () => {\n options: Options;\n dependencies: Record<string, unknown>;\n pluginFactories: PluginFactory<D>[];\n };\n\n // Consolidated route data store (issue #174 Phase 2)\n readonly routeGetStore: () => RoutesStore<D>;\n\n // Cross-namespace state (issue #174)\n readonly getStateName: () => string | undefined;\n readonly isTransitioning: () => boolean;\n readonly clearState: () => void;\n readonly setState: (state: State) => void;\n readonly routerExtensions: { keys: string[] }[];\n readonly contextClaimRecords: Set<string>;\n\n /**\n * One-shot hydration scratchpad populated by `hydrateRouter` immediately\n * before delegating to `router.start(parsed.path)` and cleared in the\n * matching `finally`. SSR loader plugins read this slot directly via\n * `getInternals(router).hydrationState` to short-circuit their own loader\n * call when the server-resolved namespace value is already present in the\n * parsed state (#596). `null` outside of an active `hydrateRouter`\n * invocation.\n */\n hydrationState: SerializedRouterState | null;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- existential type: stores RouterInternals for all Dependencies types\nconst internals = new WeakMap<object, RouterInternals<any>>();\n\nexport function getInternals<D extends DefaultDependencies>(\n router: RouterInterface<D>,\n): RouterInternals<D> {\n const ctx = internals.get(router);\n\n if (!ctx) {\n throw new TypeError(\n \"[real-router] Invalid router instance — not found in internals registry\",\n );\n }\n\n return ctx as RouterInternals<D>;\n}\n\nexport function registerInternals<D extends DefaultDependencies>(\n router: RouterClass<D>,\n ctx: RouterInternals<D>,\n): void {\n internals.set(router, ctx);\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument -- internal chain execution: type safety enforced at public API boundary (PluginApi.addInterceptor) */\nfunction executeInterceptorChain<T>(\n interceptors: ((next: (...args: any[]) => any, ...args: any[]) => any)[],\n original: (...args: any[]) => T,\n args: any[],\n): T {\n let chain = original as (...args: any[]) => any;\n\n for (const interceptor of interceptors) {\n const prev = chain;\n\n chain = (...chainArgs: any[]) => interceptor(prev, ...chainArgs);\n }\n\n return chain(...args) as T;\n}\n\n/**\n * Variadic interceptor wrapper — wraps a function of any arity, returning the\n * same callable type `T`. Use {@link createBinaryInterceptable} instead when the\n * wrapped method takes exactly two args and the caller needs the precise\n * `(a, b) => r` signature preserved (the variadic form widens args to `any[]`).\n */\nexport function createInterceptable<T extends (...args: any[]) => any>(\n name: string,\n original: T,\n interceptors: Map<\n string,\n ((next: (...args: any[]) => any, ...args: any[]) => any)[]\n >,\n): T {\n return ((...args: any[]) => {\n const chain = interceptors.get(name);\n\n if (!chain || chain.length === 0) {\n return original(...args);\n }\n\n return executeInterceptorChain(chain, original, args);\n }) as T;\n}\n\n/**\n * Two-argument interceptor wrapper — preserves the exact `(a: A, b: B) => R`\n * signature, which the variadic {@link createInterceptable} cannot express\n * (it widens args to `any[]`). Used for the binary interceptable methods\n * `forwardState(routeName, routeParams)` and `buildPath(route, params)`.\n */\nexport function createBinaryInterceptable<A, B, R>(\n name: string,\n original: (a: A, b: B) => R,\n interceptors: Map<\n string,\n ((next: (...args: any[]) => any, ...args: any[]) => any)[]\n >,\n): (a: A, b: B) => R {\n return (arg1: A, arg2: B) => {\n const chain = interceptors.get(name);\n\n if (!chain || chain.length === 0) {\n return original(arg1, arg2);\n }\n\n return executeInterceptorChain(chain, original, [arg1, arg2]);\n };\n}\n/* eslint-enable @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument */\n"],"mappings":"AAqKA,MAAM,EAAY,IAAI,QAEtB,SAAgB,EACd,EACoB,CACpB,IAAM,EAAM,EAAU,IAAI,CAAM,EAEhC,GAAI,CAAC,EACH,MAAU,UACR,yEACF,EAGF,OAAO,CACT,CAEA,SAAgB,EACd,EACA,EACM,CACN,EAAU,IAAI,EAAQ,CAAG,CAC3B,CAGA,SAAS,EACP,EACA,EACA,EACG,CACH,IAAI,EAAQ,EAEZ,IAAK,IAAM,KAAe,EAAc,CACtC,IAAM,EAAO,EAEb,GAAS,GAAG,IAAqB,EAAY,EAAM,GAAG,CAAS,CACjE,CAEA,OAAO,EAAM,GAAG,CAAI,CACtB,CAQA,SAAgB,EACd,EACA,EACA,EAIG,CACH,QAAS,GAAG,IAAgB,CAC1B,IAAM,EAAQ,EAAa,IAAI,CAAI,EAMnC,MAJI,CAAC,GAAS,EAAM,SAAW,EACtB,EAAS,GAAG,CAAI,EAGlB,EAAwB,EAAO,EAAU,CAAI,CACtD,EACF,CAQA,SAAgB,EACd,EACA,EACA,EAImB,CACnB,OAAQ,EAAS,IAAY,CAC3B,IAAM,EAAQ,EAAa,IAAI,CAAI,EAMnC,MAJI,CAAC,GAAS,EAAM,SAAW,EACtB,EAAS,EAAM,CAAI,EAGrB,EAAwB,EAAO,EAAU,CAAC,EAAM,CAAI,CAAC,CAC9D,CACF"}