@solidjs/router
Advanced tools
Comparing version 0.10.2 to 0.10.3
@@ -7,2 +7,2 @@ export * from "./routers"; | ||
export * from "./data"; | ||
export type { Location, LocationChange, NavigateOptions, Navigator, OutputMatch, Params, RouteSectionProps, RouteLoadFunc, RouteLoadFuncArgs, RouteDefinition, RouterIntegration, RouterOutput, RouterUtils, SetParams, BeforeLeaveEventArgs } from "./types"; | ||
export type { Location, LocationChange, NavigateOptions, Navigator, OutputMatch, Params, RouteSectionProps, RouteLoadFunc, RouteLoadFuncArgs, RouteDefinition, RouterIntegration, RouterUtils, SetParams, BeforeLeaveEventArgs } from "./types"; |
@@ -242,3 +242,4 @@ import { isServer, getRequestEvent, createComponent as createComponent$1, delegateEvents, spread, mergeProps as mergeProps$1, template } from 'solid-js/web'; | ||
load, | ||
children | ||
children, | ||
metadata | ||
} = routeDef; | ||
@@ -249,3 +250,4 @@ const isLeaf = !children || Array.isArray(children) && !children.length; | ||
component, | ||
load | ||
load, | ||
metadata | ||
}; | ||
@@ -617,2 +619,16 @@ return asArray(routeDef.path).reduce((acc, path) => { | ||
const matches = createMemo(() => getRouteMatches(props.branches, props.routerState.location.pathname)); | ||
if (isServer) { | ||
const e = getRequestEvent(); | ||
e && (e.routerMatches || (e.routerMatches = [])).push(matches().map(({ | ||
route, | ||
path, | ||
params | ||
}) => ({ | ||
path: route.originalPath, | ||
pattern: route.pattern, | ||
match: path, | ||
params, | ||
metadata: route.metadata | ||
}))); | ||
} | ||
const params = createMemoObject(() => { | ||
@@ -619,0 +635,0 @@ const m = matches(); |
@@ -15,3 +15,4 @@ import type { Component, JSX } from "solid-js"; | ||
component?: Component; | ||
metadata?: Record<string, any>; | ||
}; | ||
export declare const Route: <S extends string>(props: RouteProps<S>) => JSX.Element; |
/*@refresh skip*/ | ||
import { getRequestEvent, isServer } from "solid-js/web"; | ||
import { children, createMemo, createRoot, mergeProps, on, Show } from "solid-js"; | ||
@@ -17,2 +18,13 @@ import { createBranches, createRouteContext, createRouterContext, getRouteMatches, RouteContextObj, RouterContextObj } from "../routing"; | ||
const matches = createMemo(() => getRouteMatches(props.branches, props.routerState.location.pathname)); | ||
if (isServer) { | ||
const e = getRequestEvent(); | ||
e && | ||
(e.routerMatches || (e.routerMatches = [])).push(matches().map(({ route, path, params }) => ({ | ||
path: route.originalPath, | ||
pattern: route.pattern, | ||
match: path, | ||
params, | ||
metadata: route.metadata | ||
}))); | ||
} | ||
const params = createMemoObject(() => { | ||
@@ -19,0 +31,0 @@ const m = matches(); |
@@ -59,3 +59,3 @@ import { createComponent, createContext, createMemo, createRenderEffect, createSignal, on, onCleanup, untrack, useContext, startTransition, resetErrorBoundaries } from "solid-js"; | ||
export function createRoutes(routeDef, base = "") { | ||
const { component, load, children } = routeDef; | ||
const { component, load, children, metadata } = routeDef; | ||
const isLeaf = !children || (Array.isArray(children) && !children.length); | ||
@@ -65,3 +65,4 @@ const shared = { | ||
component, | ||
load | ||
load, | ||
metadata | ||
}; | ||
@@ -68,0 +69,0 @@ return asArray(routeDef.path).reduce((acc, path) => { |
@@ -5,2 +5,3 @@ import type { Component, JSX, Signal } from "solid-js"; | ||
response?: Response; | ||
routerMatches?: OutputMatch[][]; | ||
routerCache?: Map<any, any>; | ||
@@ -64,2 +65,3 @@ initialSubmission?: Submission<any, any>; | ||
component?: Component<RouteSectionProps<T>>; | ||
metadata?: Record<string, any>; | ||
}; | ||
@@ -79,6 +81,7 @@ export type MatchFilter = readonly string[] | RegExp | ((s: string) => boolean); | ||
export interface OutputMatch { | ||
originalPath: string; | ||
path: string; | ||
pattern: string; | ||
path: string; | ||
match: string; | ||
params: Params; | ||
metadata?: Record<string, any>; | ||
} | ||
@@ -93,2 +96,3 @@ export interface Route { | ||
matchFilters?: MatchFilters; | ||
metadata?: Record<string, any>; | ||
} | ||
@@ -115,12 +119,2 @@ export interface Branch { | ||
} | ||
export interface OutputMatch { | ||
originalPath: string; | ||
pattern: string; | ||
path: string; | ||
params: Params; | ||
} | ||
export interface RouterOutput { | ||
url?: string; | ||
matches: OutputMatch[][]; | ||
} | ||
export interface RouterContext { | ||
@@ -127,0 +121,0 @@ base: RouteContext; |
@@ -9,3 +9,3 @@ { | ||
"license": "MIT", | ||
"version": "0.10.2", | ||
"version": "0.10.3", | ||
"homepage": "https://github.com/solidjs/solid-router#readme", | ||
@@ -12,0 +12,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
146719
3235