Socket
Socket
Sign inDemoInstall

@solidjs/router

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solidjs/router - npm Package Compare versions

Comparing version 0.13.0 to 0.13.1

51

dist/index.js

@@ -259,3 +259,3 @@ import { isServer, getRequestEvent, createComponent as createComponent$1, memo, delegateEvents, spread, mergeProps as mergeProps$1, template } from 'solid-js/web';

};
const useParams = () => useRoute().params;
const useParams = () => useRouter().params;
const useSearchParams = () => {

@@ -410,3 +410,3 @@ const location = useLocation();

}
function createRouterContext(integration, getContext, getBranches, options = {}) {
function createRouterContext(integration, branches, getContext, options = {}) {
const {

@@ -443,5 +443,13 @@ signal: [source, setSource],

const submissions = createSignal(isServer ? initFromFlash() : []);
const matches = createMemo(() => getRouteMatches(branches(), location.pathname));
const params = createMemoObject(() => {
const m = matches();
const params = {};
for (let i = 0; i < m.length; i++) {
Object.assign(params, m[i].params);
}
return params;
});
const baseRoute = {
pattern: basePath,
params: {},
path: () => basePath,

@@ -476,2 +484,3 @@ outlet: () => null,

location,
params,
isRouting,

@@ -481,2 +490,3 @@ renderPath,

navigatorFactory,
matches,
beforeLeave,

@@ -576,3 +586,3 @@ preloadRoute,

function preloadRoute(url, preloadData) {
const matches = getRouteMatches(getBranches(), url.pathname);
const matches = getRouteMatches(branches(), url.pathname);
const prevIntent = intent;

@@ -609,6 +619,7 @@ intent = "preload";

}
function createRouteContext(router, parent, outlet, match, params) {
function createRouteContext(router, parent, outlet, match) {
const {
base,
location
location,
params
} = router;

@@ -631,3 +642,2 @@ const {

path,
params,
outlet: () => component ? createComponent(component, {

@@ -655,7 +665,6 @@ params,

let context;
const routerState = createRouterContext(router, () => context, branches, {
const routerState = createRouterContext(router, branches, () => context, {
base,
singleFlight: props.singleFlight
});
const location = routerState.location;
router.create && router.create(routerState);

@@ -666,3 +675,3 @@ return createComponent$1(RouterContextObj.Provider, {

return createComponent$1(Root, {
location: location,
routerState: routerState,
get root() {

@@ -687,5 +696,6 @@ return props.root;

function Root(props) {
const location = props.location;
const location = props.routerState.location;
const params = props.routerState.params;
const data = createMemo(() => props.load && untrack(() => props.load({
params: {},
params,
location,

@@ -703,3 +713,3 @@ intent: "preload"

children: Root => createComponent$1(Root, {
params: {},
params: params,
location: location,

@@ -716,3 +726,2 @@ get data() {

function Routes(props) {
const matches = createMemo(() => getRouteMatches(props.branches, props.routerState.location.pathname));
if (isServer) {

@@ -724,3 +733,3 @@ const e = getRequestEvent();

}
e && ((e.router || (e.router = {})).matches || (e.router.matches = matches().map(({
e && ((e.router || (e.router = {})).matches || (e.router.matches = props.routerState.matches().map(({
route,

@@ -737,13 +746,5 @@ path,

}
const params = createMemoObject(() => {
const m = matches();
const params = {};
for (let i = 0; i < m.length; i++) {
Object.assign(params, m[i].params);
}
return params;
});
const disposers = [];
let root;
const routeStates = createMemo(on(matches, (nextMatches, prevMatches, prev) => {
const routeStates = createMemo(on(props.routerState.matches, (nextMatches, prevMatches, prev) => {
let equal = prevMatches && nextMatches.length === prevMatches.length;

@@ -763,3 +764,3 @@ const next = [];

disposers[i] = dispose;
next[i] = createRouteContext(props.routerState, next[i - 1] || props.routerState.base, createOutlet(() => routeStates()[i + 1]), () => matches()[i], params);
next[i] = createRouteContext(props.routerState, next[i - 1] || props.routerState.base, createOutlet(() => routeStates()[i + 1]), () => props.routerState.matches()[i]);
});

@@ -766,0 +767,0 @@ }

@@ -5,3 +5,2 @@ /*@refresh skip*/

import { createBranches, createRouteContext, createRouterContext, getRouteMatches, RouteContextObj, RouterContextObj } from "../routing.js";
import { createMemoObject } from "../utils.js";
export const createRouterComponent = (router) => (props) => {

@@ -12,10 +11,9 @@ const { base } = props;

let context;
const routerState = createRouterContext(router, () => context, branches, {
const routerState = createRouterContext(router, branches, () => context, {
base,
singleFlight: props.singleFlight
});
const location = routerState.location;
router.create && router.create(routerState);
return (<RouterContextObj.Provider value={routerState}>
<Root location={location} root={props.root} load={props.rootLoad}>
<Root routerState={routerState} root={props.root} load={props.rootLoad}>
{(context = getOwner()) && null}

@@ -27,6 +25,7 @@ <Routes routerState={routerState} branches={branches()}/>

function Root(props) {
const location = props.location;
const data = createMemo(() => props.load && untrack(() => props.load({ params: {}, location, intent: "preload" })));
const location = props.routerState.location;
const params = props.routerState.params;
const data = createMemo(() => props.load && untrack(() => props.load({ params, location, intent: "preload" })));
return (<Show when={props.root} keyed fallback={props.children}>
{Root => (<Root params={{}} location={location} data={data()}>
{Root => (<Root params={params} location={location} data={data()}>
{props.children}

@@ -37,3 +36,2 @@ </Root>)}

function Routes(props) {
const matches = createMemo(() => getRouteMatches(props.branches, props.routerState.location.pathname));
if (isServer) {

@@ -47,3 +45,3 @@ const e = getRequestEvent();

((e.router || (e.router = {})).matches ||
(e.router.matches = matches().map(({ route, path, params }) => ({
(e.router.matches = props.routerState.matches().map(({ route, path, params }) => ({
path: route.originalPath,

@@ -56,13 +54,5 @@ pattern: route.pattern,

}
const params = createMemoObject(() => {
const m = matches();
const params = {};
for (let i = 0; i < m.length; i++) {
Object.assign(params, m[i].params);
}
return params;
});
const disposers = [];
let root;
const routeStates = createMemo(on(matches, (nextMatches, prevMatches, prev) => {
const routeStates = createMemo(on(props.routerState.matches, (nextMatches, prevMatches, prev) => {
let equal = prevMatches && nextMatches.length === prevMatches.length;

@@ -83,3 +73,3 @@ const next = [];

disposers[i] = dispose;
next[i] = createRouteContext(props.routerState, next[i - 1] || props.routerState.base, createOutlet(() => routeStates()[i + 1]), () => matches()[i], params);
next[i] = createRouteContext(props.routerState, next[i - 1] || props.routerState.base, createOutlet(() => routeStates()[i + 1]), () => props.routerState.matches()[i]);
});

@@ -86,0 +76,0 @@ }

@@ -22,6 +22,6 @@ import { JSX, Accessor } from "solid-js";

export declare function getIntent(): Intent | undefined;
export declare function createRouterContext(integration: RouterIntegration, getContext?: () => any, getBranches?: () => Branch[], options?: {
export declare function createRouterContext(integration: RouterIntegration, branches: () => Branch[], getContext?: () => any, options?: {
base?: string;
singleFlight?: boolean;
}): RouterContext;
export declare function createRouteContext(router: RouterContext, parent: RouteContext, outlet: () => JSX.Element, match: () => RouteMatch, params: Params): RouteContext;
export declare function createRouteContext(router: RouterContext, parent: RouteContext, outlet: () => JSX.Element, match: () => RouteMatch): RouteContext;

@@ -37,3 +37,3 @@ import { runWithOwner } from "solid-js";

};
export const useParams = () => useRoute().params;
export const useParams = () => useRouter().params;
export const useSearchParams = () => {

@@ -188,3 +188,3 @@ const location = useLocation();

}
export function createRouterContext(integration, getContext, getBranches, options = {}) {
export function createRouterContext(integration, branches, getContext, options = {}) {
const { signal: [source, setSource], utils = {} } = integration;

@@ -216,5 +216,13 @@ const parsePath = utils.parsePath || (p => p);

const submissions = createSignal(isServer ? initFromFlash() : []);
const matches = createMemo(() => getRouteMatches(branches(), location.pathname));
const params = createMemoObject(() => {
const m = matches();
const params = {};
for (let i = 0; i < m.length; i++) {
Object.assign(params, m[i].params);
}
return params;
});
const baseRoute = {
pattern: basePath,
params: {},
path: () => basePath,

@@ -246,2 +254,3 @@ outlet: () => null,

location,
params,
isRouting,

@@ -251,2 +260,3 @@ renderPath,

navigatorFactory,
matches,
beforeLeave,

@@ -332,3 +342,3 @@ preloadRoute,

function preloadRoute(url, preloadData) {
const matches = getRouteMatches(getBranches(), url.pathname);
const matches = getRouteMatches(branches(), url.pathname);
const prevIntent = intent;

@@ -366,4 +376,4 @@ intent = "preload";

}
export function createRouteContext(router, parent, outlet, match, params) {
const { base, location } = router;
export function createRouteContext(router, parent, outlet, match) {
const { base, location, params } = router;
const { pattern, component, load } = match().route;

@@ -379,3 +389,2 @@ const path = createMemo(() => match().path);

path,
params,
outlet: () => component

@@ -382,0 +391,0 @@ ? createComponent(component, {

@@ -117,3 +117,2 @@ import type { Component, JSX, Signal } from "solid-js";

pattern: string;
params: Params;
path: () => string;

@@ -132,4 +131,6 @@ outlet: () => JSX.Element;

location: Location;
params: Params;
navigatorFactory: NavigatorFactory;
isRouting: () => boolean;
matches: () => RouteMatch[];
renderPath(path: string): string;

@@ -136,0 +137,0 @@ parsePath(str: string): string;

@@ -9,3 +9,3 @@ {

"license": "MIT",
"version": "0.13.0",
"version": "0.13.1",
"homepage": "https://github.com/solidjs/solid-router#readme",

@@ -12,0 +12,0 @@ "repository": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc