Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solidjs/router

Package Overview
Dependencies
Maintainers
2
Versions
67
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.10.0-beta.3 to 0.10.0-beta.4

1

dist/components.d.ts

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

base?: string;
actionBase?: string;
root?: Component<RouteSectionProps>;

@@ -17,0 +18,0 @@ children: JSX.Element;

8

dist/components.jsx

@@ -9,10 +9,12 @@ /*@refresh skip*/

let e;
const { source, url, base } = props;
const { source, url, base, actionBase } = props;
const integration = source ||
(isServer
? staticIntegration({ value: url || ((e = getRequestEvent()) && getPath(e.request.url)) || "" })
? staticIntegration({
value: url || ((e = getRequestEvent()) && getPath(e.request.url)) || ""
})
: pathIntegration());
const routeDefs = children(() => props.children);
const branches = createMemo(() => createBranches(props.root ? { component: props.root, children: routeDefs() } : routeDefs(), props.base || ""));
const routerState = createRouterContext(integration, branches, base);
const routerState = createRouterContext(integration, branches, { base, actionBase });
return (<RouterContextObj.Provider value={routerState}>

@@ -19,0 +21,0 @@ <Routes routerState={routerState} branches={branches()}/>

@@ -23,18 +23,18 @@ import { $TRACK, createMemo, createSignal } from "solid-js";

get clear() {
return submissions[0]?.clear;
return submissions[submissions.length - 1]?.clear;
},
get retry() {
return submissions[0]?.retry;
return submissions[submissions.length - 1]?.retry;
},
get url() {
return submissions[0]?.url;
return submissions[submissions.length - 1]?.url;
},
get input() {
return submissions[0]?.input;
return submissions[submissions.length - 1]?.input;
},
get result() {
return submissions[0]?.result;
return submissions[submissions.length - 1]?.result;
},
get pending() {
return submissions[0]?.pending;
return submissions[submissions.length - 1]?.pending;
}

@@ -41,0 +41,0 @@ };

@@ -54,4 +54,5 @@ import { createSignal, getOwner, onCleanup, sharedConfig, startTransition } from "solid-js";

}
let res = cached[1];
if (!isServer && intent === "navigate") {
"then" in cached[1]
res = "then" in cached[1]
? cached[1].then(handleResponse(false), handleResponse(true))

@@ -61,3 +62,3 @@ : handleResponse(false)(cached[1]);

}
return cached[1];
return res;
}

@@ -71,7 +72,2 @@ let res = !isServer && sharedConfig.context && sharedConfig.load

}
if (intent !== "preload") {
"then" in res
? res.then(handleResponse(false), handleResponse(true))
: handleResponse(false)(res);
}
if (cached) {

@@ -88,2 +84,7 @@ cached[0] = now;

cache.set(key, (cached = [now, res, intent, new Set(version ? [version] : [])]));
if (intent !== "preload") {
res = "then" in res
? res.then(handleResponse(false), handleResponse(true))
: handleResponse(false)(res);
}
return res;

@@ -90,0 +91,0 @@ function handleResponse(error) {

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

}
function createRouterContext(integration, getBranches, base = "") {
function createRouterContext(integration, getBranches, options = {}) {
const {

@@ -541,4 +541,4 @@ signal: [source, setSource],

const beforeLeave = utils.beforeLeave || createBeforeLeave();
let submissions = [];
const basePath = resolvePath("", base);
const basePath = resolvePath("", options.base || "");
const actionBase = options.actionBase || "/_server";
if (basePath === undefined) {

@@ -583,3 +583,3 @@ throw new Error(`${basePath} is not a valid base path`);

beforeLeave,
submissions: createSignal(submissions)
submissions: createSignal(initFromFlash(location.query))
};

@@ -673,2 +673,12 @@ function navigateFromRoute(route, to, options) {

}
function initFromFlash(params) {
let param = params.form ? JSON.parse(params.form) : null;
if (!param || !param.result) return [];
const input = new Map(param.entries);
return [{
url: param.url,
result: param.error ? new Error(param.result.message) : param.result,
input: input
}];
}
createRenderEffect(() => {

@@ -778,6 +788,13 @@ const {

let actionRef = evt.submitter && evt.submitter.getAttribute("formaction") || evt.target.action;
if (actionRef && actionRef.startsWith("action:")) {
if (!actionRef) return;
if (!actionRef.startsWith("action:")) {
const url = new URL(actionRef);
actionRef = parsePath(url.pathname + url.search);
if (!actionRef.startsWith(actionBase)) return;
}
const handler = actions.get(actionRef);
if (handler) {
evt.preventDefault();
const data = new FormData(evt.target);
actions.get(actionRef).call(router, data);
evt.preventDefault();
handler.call(router, data);
}

@@ -802,16 +819,2 @@ }

});
} else {
function initFromFlash(params) {
let param = params.form ? JSON.parse(params.form) : null;
if (!param || !param.result) {
return [];
}
const input = new Map(param.entries);
return [{
url: param.url,
result: param.error ? new Error(param.result.message) : param.result,
input: input
}];
}
submissions = initFromFlash(location.query);
}

@@ -862,3 +865,4 @@ return router;

url,
base
base,
actionBase
} = props;

@@ -873,3 +877,6 @@ const integration = source || (isServer ? staticIntegration({

} : routeDefs(), props.base || ""));
const routerState = createRouterContext(integration, branches, base);
const routerState = createRouterContext(integration, branches, {
base,
actionBase
});
return createComponent$1(RouterContextObj.Provider, {

@@ -1124,8 +1131,9 @@ value: routerState,

}
let res = cached[1];
if (!isServer && intent === "navigate") {
"then" in cached[1] ? cached[1].then(handleResponse(false), handleResponse(true)) : handleResponse(false)(cached[1]);
res = "then" in cached[1] ? cached[1].then(handleResponse(false), handleResponse(true)) : handleResponse(false)(cached[1]);
startTransition(() => revalidateSignals(cached[3], cached[0])); // update version
}
return cached[1];
return res;
}

@@ -1139,5 +1147,2 @@ let res = !isServer && sharedConfig.context && sharedConfig.load ? sharedConfig.load(key) // hydrating

}
if (intent !== "preload") {
"then" in res ? res.then(handleResponse(false), handleResponse(true)) : handleResponse(false)(res);
}
if (cached) {

@@ -1152,2 +1157,5 @@ cached[0] = now;

} else cache.set(key, cached = [now, res, intent, new Set(version ? [version] : [])]);
if (intent !== "preload") {
res = "then" in res ? res.then(handleResponse(false), handleResponse(true)) : handleResponse(false)(res);
}
return res;

@@ -1195,18 +1203,18 @@ function handleResponse(error) {

get clear() {
return submissions[0]?.clear;
return submissions[submissions.length - 1]?.clear;
},
get retry() {
return submissions[0]?.retry;
return submissions[submissions.length - 1]?.retry;
},
get url() {
return submissions[0]?.url;
return submissions[submissions.length - 1]?.url;
},
get input() {
return submissions[0]?.input;
return submissions[submissions.length - 1]?.input;
},
get result() {
return submissions[0]?.result;
return submissions[submissions.length - 1]?.result;
},
get pending() {
return submissions[0]?.pending;
return submissions[submissions.length - 1]?.pending;
}

@@ -1213,0 +1221,0 @@ };

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

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

@@ -184,3 +184,3 @@ import { createComponent, createContext, createMemo, createRenderEffect, createSignal, on, onCleanup, untrack, useContext, startTransition, resetErrorBoundaries } from "solid-js";

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

@@ -190,4 +190,4 @@ const parsePath = utils.parsePath || (p => p);

const beforeLeave = utils.beforeLeave || createBeforeLeave();
let submissions = [];
const basePath = resolvePath("", base);
const basePath = resolvePath("", options.base || "");
const actionBase = options.actionBase || "/_server";
if (basePath === undefined) {

@@ -230,3 +230,3 @@ throw new Error(`${basePath} is not a valid base path`);

beforeLeave,
submissions: createSignal(submissions)
submissions: createSignal(initFromFlash(location.query))
};

@@ -307,2 +307,15 @@ function navigateFromRoute(route, to, options) {

}
function initFromFlash(params) {
let param = params.form ? JSON.parse(params.form) : null;
if (!param || !param.result)
return [];
const input = new Map(param.entries);
return [
{
url: param.url,
result: param.error ? new Error(param.result.message) : param.result,
input: input
}
];
}
createRenderEffect(() => {

@@ -429,6 +442,15 @@ const { value, state } = source();

let actionRef = (evt.submitter && evt.submitter.getAttribute("formaction")) || evt.target.action;
if (actionRef && actionRef.startsWith("action:")) {
if (!actionRef)
return;
if (!actionRef.startsWith("action:")) {
const url = new URL(actionRef);
actionRef = parsePath(url.pathname + url.search);
if (!actionRef.startsWith(actionBase))
return;
}
const handler = actions.get(actionRef);
if (handler) {
evt.preventDefault();
const data = new FormData(evt.target);
actions.get(actionRef).call(router, data);
evt.preventDefault();
handler.call(router, data);
}

@@ -453,19 +475,2 @@ }

}
else {
function initFromFlash(params) {
let param = params.form ? JSON.parse(params.form) : null;
if (!param || !param.result) {
return [];
}
const input = new Map(param.entries);
return [
{
url: param.url,
result: param.error ? new Error(param.result.message) : param.result,
input: input
}
];
}
submissions = initFromFlash(location.query);
}
return router;

@@ -472,0 +477,0 @@ }

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

"license": "MIT",
"version": "0.10.0-beta.3",
"version": "0.10.0-beta.4",
"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