@solidjs/router 0.12.1 → 0.12.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.
- package/dist/index.js +7 -7
- package/dist/routers/components.jsx +4 -2
- package/dist/routing.d.ts +1 -1
- package/dist/routing.js +3 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isServer, getRequestEvent, createComponent as createComponent$1, delegateEvents, spread, mergeProps as mergeProps$1, template } from 'solid-js/web';
|
|
1
|
+
import { isServer, getRequestEvent, createComponent as createComponent$1, memo, delegateEvents, spread, mergeProps as mergeProps$1, template } from 'solid-js/web';
|
|
2
2
|
import { getOwner, runWithOwner, createMemo, createContext, onCleanup, useContext, untrack, createSignal, createRenderEffect, on, startTransition, resetErrorBoundaries, createComponent, children, mergeProps, createRoot, Show, getListener, sharedConfig, $TRACK, splitProps, createResource } from 'solid-js';
|
|
3
3
|
import { createStore, reconcile, unwrap } from 'solid-js/store';
|
|
4
4
|
|
|
@@ -406,7 +406,7 @@ let intent;
|
|
|
406
406
|
function getIntent() {
|
|
407
407
|
return intent;
|
|
408
408
|
}
|
|
409
|
-
function createRouterContext(integration, getBranches, options = {}) {
|
|
409
|
+
function createRouterContext(integration, getContext, getBranches, options = {}) {
|
|
410
410
|
const {
|
|
411
411
|
signal: [source, setSource],
|
|
412
412
|
utils = {}
|
|
@@ -467,7 +467,6 @@ function createRouterContext(integration, getBranches, options = {}) {
|
|
|
467
467
|
}
|
|
468
468
|
});
|
|
469
469
|
});
|
|
470
|
-
const owner = getOwner();
|
|
471
470
|
return {
|
|
472
471
|
base: baseRoute,
|
|
473
472
|
location,
|
|
@@ -581,7 +580,7 @@ function createRouterContext(integration, getBranches, options = {}) {
|
|
|
581
580
|
const {
|
|
582
581
|
load
|
|
583
582
|
} = route;
|
|
584
|
-
preloadData && load && runWithOwner(
|
|
583
|
+
preloadData && load && runWithOwner(getContext(), () => load({
|
|
585
584
|
params,
|
|
586
585
|
location: {
|
|
587
586
|
pathname: url.pathname,
|
|
@@ -648,7 +647,8 @@ const createRouterComponent = router => props => {
|
|
|
648
647
|
load: props.rootLoad,
|
|
649
648
|
children: routeDefs()
|
|
650
649
|
} : routeDefs(), props.base || ""));
|
|
651
|
-
|
|
650
|
+
let context;
|
|
651
|
+
const routerState = createRouterContext(router, () => context, branches, {
|
|
652
652
|
base,
|
|
653
653
|
singleFlight: props.singleFlight
|
|
654
654
|
});
|
|
@@ -656,12 +656,12 @@ const createRouterComponent = router => props => {
|
|
|
656
656
|
return createComponent$1(RouterContextObj.Provider, {
|
|
657
657
|
value: routerState,
|
|
658
658
|
get children() {
|
|
659
|
-
return createComponent$1(Routes, {
|
|
659
|
+
return [memo(() => (context = getOwner()) && null), createComponent$1(Routes, {
|
|
660
660
|
routerState: routerState,
|
|
661
661
|
get branches() {
|
|
662
662
|
return branches();
|
|
663
663
|
}
|
|
664
|
-
});
|
|
664
|
+
})];
|
|
665
665
|
}
|
|
666
666
|
});
|
|
667
667
|
};
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/*@refresh skip*/
|
|
2
2
|
import { getRequestEvent, isServer } from "solid-js/web";
|
|
3
|
-
import { children, createMemo, createRoot, mergeProps, on, Show } from "solid-js";
|
|
3
|
+
import { children, createMemo, createRoot, getOwner, mergeProps, on, Show } from "solid-js";
|
|
4
4
|
import { createBranches, createRouteContext, createRouterContext, getRouteMatches, RouteContextObj, RouterContextObj } from "../routing.js";
|
|
5
5
|
import { createMemoObject, extractSearchParams } from "../utils.js";
|
|
6
6
|
export const createRouterComponent = (router) => (props) => {
|
|
7
7
|
const { base } = props;
|
|
8
8
|
const routeDefs = children(() => props.children);
|
|
9
9
|
const branches = createMemo(() => createBranches(props.root ? { component: props.root, load: props.rootLoad, children: routeDefs() } : routeDefs(), props.base || ""));
|
|
10
|
-
|
|
10
|
+
let context;
|
|
11
|
+
const routerState = createRouterContext(router, () => context, branches, { base, singleFlight: props.singleFlight });
|
|
11
12
|
router.create && router.create(routerState);
|
|
12
13
|
return (<RouterContextObj.Provider value={routerState}>
|
|
14
|
+
{(context = getOwner()) && null}
|
|
13
15
|
<Routes routerState={routerState} branches={branches()}/>
|
|
14
16
|
</RouterContextObj.Provider>);
|
|
15
17
|
};
|
package/dist/routing.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare function createBranches(routeDef: RouteDefinition | RouteDefiniti
|
|
|
19
19
|
export declare function getRouteMatches(branches: Branch[], location: string): RouteMatch[];
|
|
20
20
|
export declare function createLocation(path: Accessor<string>, state: Accessor<any>): Location;
|
|
21
21
|
export declare function getIntent(): Intent | undefined;
|
|
22
|
-
export declare function createRouterContext(integration: RouterIntegration, getBranches?: () => Branch[], options?: {
|
|
22
|
+
export declare function createRouterContext(integration: RouterIntegration, getContext?: () => any, getBranches?: () => Branch[], options?: {
|
|
23
23
|
base?: string;
|
|
24
24
|
singleFlight?: boolean;
|
|
25
25
|
}): RouterContext;
|
package/dist/routing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { runWithOwner } from "solid-js";
|
|
2
2
|
import { createComponent, createContext, createMemo, createRenderEffect, createSignal, on, onCleanup, untrack, useContext, startTransition, resetErrorBoundaries } from "solid-js";
|
|
3
3
|
import { isServer, getRequestEvent } from "solid-js/web";
|
|
4
4
|
import { createBeforeLeave } from "./lifecycle.js";
|
|
@@ -184,7 +184,7 @@ let intent;
|
|
|
184
184
|
export function getIntent() {
|
|
185
185
|
return intent;
|
|
186
186
|
}
|
|
187
|
-
export function createRouterContext(integration, getBranches, options = {}) {
|
|
187
|
+
export function createRouterContext(integration, getContext, getBranches, options = {}) {
|
|
188
188
|
const { signal: [source, setSource], utils = {} } = integration;
|
|
189
189
|
const parsePath = utils.parsePath || (p => p);
|
|
190
190
|
const renderPath = utils.renderPath || (p => p);
|
|
@@ -237,7 +237,6 @@ export function createRouterContext(integration, getBranches, options = {}) {
|
|
|
237
237
|
}
|
|
238
238
|
});
|
|
239
239
|
});
|
|
240
|
-
const owner = getOwner();
|
|
241
240
|
return {
|
|
242
241
|
base: baseRoute,
|
|
243
242
|
location,
|
|
@@ -336,7 +335,7 @@ export function createRouterContext(integration, getBranches, options = {}) {
|
|
|
336
335
|
const { load } = route;
|
|
337
336
|
preloadData &&
|
|
338
337
|
load &&
|
|
339
|
-
runWithOwner(
|
|
338
|
+
runWithOwner(getContext(), () => load({
|
|
340
339
|
params,
|
|
341
340
|
location: {
|
|
342
341
|
pathname: url.pathname,
|