Skip to content

Class: RouteMap

Documentation / @xmachines/play-vue-router / RouteMap

Defined in: play-vue-router/src/route-map.ts:14

VueBaseRouteMap — intermediate base class for Vue Router adapters.

Extends BaseRouteMap (bucket-indexed O(k) pattern matching + QuickLRU 500-entry cache) and adds the Vue-specific adapter layer: routeNamestateId bidirectional lookup and optional URL pattern access.

Why a separate base class? Vue Router uses named routes (routeName) rather than URL paths for navigation. BaseRouteMap operates on path strings; VueBaseRouteMap bridges the two by translating RouteMapping entries at construction time — only mappings with a pattern field participate in URL path resolution via BaseRouteMap.

Exported from @xmachines/play-vue-router for consumers who need to extend or test the Vue routing layer directly. Most consumers use RouteMap instead.

Example

import { VueBaseRouteMap } from "@xmachines/play-vue-router";
class MyVueRouteMap extends VueBaseRouteMap {
// add custom resolution logic
}

Extends

Constructors

Constructor

new RouteMap(mappings): RouteMap;

Defined in: play-vue-router/src/vue-base-route-map.ts:32

Parameters

ParameterType
mappingsRouteMapping[]

Returns

RouteMap

Inherited from

VueBaseRouteMap.constructor

Methods

getPathByStateId()

getPathByStateId(stateId): string | null;

Defined in: play-router/dist/base-route-map.d.ts:111

Look up the path pattern registered for a state ID.

Parameters

ParameterTypeDescription
stateIdstringState machine state ID (e.g., "profile", "#settings")

Returns

string | null

The registered path pattern, or null if the state ID is unknown

Example

map.getPathByStateId("profile"); // "/profile/:userId"
map.getPathByStateId("missing"); // null

Inherited from

VueBaseRouteMap.getPathByStateId


getPattern()

getPattern(stateId): string | undefined;

Defined in: play-vue-router/src/vue-base-route-map.ts:58

Get the URL path pattern for a given state ID (e.g. "/profile/:userId").

Parameters

ParameterType
stateIdstring

Returns

string | undefined

Inherited from

VueBaseRouteMap.getPattern


getRouteName()

getRouteName(stateId): string | undefined;

Defined in: play-vue-router/src/vue-base-route-map.ts:48

Get the Vue Router route name for a given state ID.

Parameters

ParameterType
stateIdstring

Returns

string | undefined

Inherited from

VueBaseRouteMap.getRouteName


getStateId()

getStateId(routeName): string | undefined;

Defined in: play-vue-router/src/vue-base-route-map.ts:53

Get the state ID for a given Vue Router route name.

Parameters

ParameterType
routeNamestring

Returns

string | undefined

Inherited from

VueBaseRouteMap.getStateId


getStateIdByPath()

getStateIdByPath(path): string | null;

Defined in: play-router/dist/base-route-map.d.ts:98

Resolve a URL path to its mapped state ID.

Strips query strings and hash fragments before matching. Tries an O(1) exact lookup first, then falls back to bucket-indexed pattern matching. Results are cached after the first pattern match.

Parameters

ParameterTypeDescription
pathstringURL pathname, optionally including query/hash (e.g., "/profile/123?ref=nav")

Returns

string | null

The mapped state ID, or null if no route matches

Example

map.getStateIdByPath("/profile/123"); // "profile"
map.getStateIdByPath("/unknown"); // null

Inherited from

VueBaseRouteMap.getStateIdByPath