@shuvi/router-react 0.0.1-pre.1 → 0.0.1-pre.10

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/esm/Link.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ import { State, PathRecord } from '@shuvi/router';
3
+ /**
4
+ * The public API for rendering a history-aware <a>.
5
+ */
6
+ export declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
7
+ export interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href'> {
8
+ replace?: boolean;
9
+ state?: State;
10
+ to: PathRecord;
11
+ }
package/esm/Link.js ADDED
@@ -0,0 +1,66 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import * as React from 'react';
13
+ import PropTypes from 'prop-types';
14
+ import { useHref, useNavigate, useResolvedPath } from '.';
15
+ import { pathToString } from '@shuvi/router';
16
+ import { __DEV__ } from './constants';
17
+ import { useCurrentRoute } from './hooks';
18
+ function isModifiedEvent(event) {
19
+ return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
20
+ }
21
+ /**
22
+ * The public API for rendering a history-aware <a>.
23
+ */
24
+ export const Link = React.forwardRef(function LinkWithRef(_a, ref) {
25
+ var { onClick, replace: replaceProp = false, state, target, to } = _a, rest = __rest(_a, ["onClick", "replace", "state", "target", "to"]);
26
+ let href = useHref(to);
27
+ let navigate = useNavigate();
28
+ const location = useCurrentRoute();
29
+ let path = useResolvedPath(to);
30
+ function handleClick(event) {
31
+ if (onClick)
32
+ onClick(event);
33
+ if (!event.defaultPrevented && // onClick prevented default
34
+ event.button === 0 && // Ignore everything but left clicks
35
+ (!target || target === '_self') && // Let browser handle "target=_blank" etc.
36
+ !isModifiedEvent(event) // Ignore clicks with modifier keys
37
+ ) {
38
+ event.preventDefault();
39
+ // If the URL hasn't changed, a regular <a> will do a replace instead of
40
+ // a push, so do the same here.
41
+ let replace = !!replaceProp || pathToString(location) === pathToString(path);
42
+ navigate(to, { replace, state });
43
+ }
44
+ }
45
+ return (
46
+ // @ts-ignore
47
+ React.createElement("a", Object.assign({}, rest, { href: href, onClick: handleClick, ref: ref, target: target })));
48
+ });
49
+ if (__DEV__) {
50
+ Link.displayName = 'Link';
51
+ Link.propTypes = {
52
+ onClick: PropTypes.func,
53
+ replace: PropTypes.bool,
54
+ state: PropTypes.object,
55
+ target: PropTypes.string,
56
+ // @ts-ignore proptypes's bug?
57
+ to: PropTypes.oneOfType([
58
+ PropTypes.string,
59
+ PropTypes.shape({
60
+ pathname: PropTypes.string,
61
+ search: PropTypes.string,
62
+ hash: PropTypes.string
63
+ })
64
+ ]).isRequired
65
+ };
66
+ }
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { IMemoryRouterProps } from './types';
4
+ /**
5
+ * A <Router> that stores all entries in memory.
6
+ */
7
+ export declare function MemoryRouter({ basename, children, routes, initialEntries, initialIndex }: IMemoryRouterProps): React.ReactElement;
8
+ export declare namespace MemoryRouter {
9
+ var displayName: string;
10
+ var propTypes: {
11
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
12
+ routes: PropTypes.Requireable<(object | null | undefined)[]>;
13
+ initialEntries: PropTypes.Requireable<(string | PropTypes.InferProps<{
14
+ pathname: PropTypes.Requireable<string>;
15
+ search: PropTypes.Requireable<string>;
16
+ hash: PropTypes.Requireable<string>;
17
+ state: PropTypes.Requireable<object>;
18
+ key: PropTypes.Requireable<string>;
19
+ }> | null | undefined)[]>;
20
+ initialIndex: PropTypes.Requireable<number>;
21
+ };
22
+ }
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { createMemoryHistory, createRouter } from '@shuvi/router';
4
+ import { Router } from './Router';
5
+ import { __DEV__ } from './constants';
6
+ /**
7
+ * A <Router> that stores all entries in memory.
8
+ */
9
+ export function MemoryRouter({ basename, children, routes, initialEntries, initialIndex }) {
10
+ let routerRef = React.useRef();
11
+ if (routerRef.current == null) {
12
+ routerRef.current = createRouter({
13
+ basename,
14
+ routes: routes || [],
15
+ history: createMemoryHistory({ initialEntries, initialIndex })
16
+ });
17
+ }
18
+ return React.createElement(Router, { children: children, router: routerRef.current });
19
+ }
20
+ if (__DEV__) {
21
+ MemoryRouter.displayName = 'MemoryRouter';
22
+ MemoryRouter.propTypes = {
23
+ children: PropTypes.node,
24
+ routes: PropTypes.arrayOf(PropTypes.object),
25
+ initialEntries: PropTypes.arrayOf(PropTypes.oneOfType([
26
+ PropTypes.string,
27
+ PropTypes.shape({
28
+ pathname: PropTypes.string,
29
+ search: PropTypes.string,
30
+ hash: PropTypes.string,
31
+ state: PropTypes.object,
32
+ key: PropTypes.string
33
+ })
34
+ ])),
35
+ initialIndex: PropTypes.number
36
+ };
37
+ }
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { IRouterProps } from './types';
4
+ /**
5
+ * Provides location context for the rest of the app.
6
+ *
7
+ * Note: You usually won't render a <Router> directly. Instead, you'll render a
8
+ * router that is more specific to your environment such as a <BrowserRouter>
9
+ * in web browsers or a <StaticRouter> for server rendering.
10
+ */
11
+ export declare function Router({ children, static: staticProp, router }: IRouterProps): React.ReactElement;
12
+ export declare namespace Router {
13
+ var displayName: string;
14
+ var propTypes: {
15
+ children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
16
+ router: PropTypes.Requireable<object>;
17
+ static: PropTypes.Requireable<boolean>;
18
+ };
19
+ }
package/esm/Router.js ADDED
@@ -0,0 +1,43 @@
1
+ import React, { useRef, useReducer } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import invariant from '@shuvi/utils/lib/invariant';
4
+ import { RouterContext, RouteContext } from './contexts';
5
+ import { useInRouterContext } from './hooks';
6
+ import { __DEV__ } from './constants';
7
+ import { useIsomorphicEffect } from './utils';
8
+ /**
9
+ * Provides location context for the rest of the app.
10
+ *
11
+ * Note: You usually won't render a <Router> directly. Instead, you'll render a
12
+ * router that is more specific to your environment such as a <BrowserRouter>
13
+ * in web browsers or a <StaticRouter> for server rendering.
14
+ */
15
+ export function Router({ children = null, static: staticProp = false, router }) {
16
+ invariant(!useInRouterContext(), `You cannot render a <Router> inside another <Router>.` +
17
+ ` You never need more than one.`);
18
+ const contextVal = React.useMemo(() => {
19
+ return {
20
+ static: staticProp,
21
+ router: router
22
+ };
23
+ }, [staticProp, router]);
24
+ const unmount = useRef(false);
25
+ const forceupdate = useReducer(s => s * -1, 1)[1];
26
+ useIsomorphicEffect(() => () => (unmount.current = true), []);
27
+ useIsomorphicEffect(() => router.listen(() => {
28
+ if (unmount.current) {
29
+ return;
30
+ }
31
+ forceupdate();
32
+ }), [router]);
33
+ return (React.createElement(RouterContext.Provider, { value: contextVal },
34
+ React.createElement(RouteContext.Provider, { children: children, value: router.current })));
35
+ }
36
+ if (__DEV__) {
37
+ Router.displayName = 'Router';
38
+ Router.propTypes = {
39
+ children: PropTypes.node,
40
+ router: PropTypes.object,
41
+ static: PropTypes.bool
42
+ };
43
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare function RouterView(): React.ReactElement | null;
3
+ export declare namespace RouterView {
4
+ var displayName: string;
5
+ }
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { joinPaths } from '@shuvi/router/lib/utils';
3
+ import { useCurrentRoute } from './hooks';
4
+ import { __DEV__ } from './constants';
5
+ import { MatchedRouteContext } from './contexts';
6
+ import { warningOnce, readOnly } from './utils';
7
+ const defaultElement = React.createElement(RouterView, null);
8
+ export function RouterView() {
9
+ let { depth, pathname: parentPathname, params: parentParams } = React.useContext(MatchedRouteContext);
10
+ const { matches } = useCurrentRoute();
11
+ if (!matches) {
12
+ return null;
13
+ }
14
+ // Otherwise render an element.
15
+ const matched = matches[depth];
16
+ if (!matched) {
17
+ if (__DEV__) {
18
+ warningOnce(parentPathname, false, `Use <RouterView/> under path "${parentPathname}", but it has no children routes.` +
19
+ `\n\n` +
20
+ `Please remove the <RouterView/>.`);
21
+ }
22
+ return null;
23
+ }
24
+ const { route, params, pathname } = matched;
25
+ const element = route.component
26
+ ? React.createElement(route.component, route.props)
27
+ : defaultElement;
28
+ return (React.createElement(MatchedRouteContext.Provider, { children: element, value: {
29
+ depth: depth + 1,
30
+ params: readOnly(Object.assign(Object.assign({}, parentParams), params)),
31
+ pathname: joinPaths([parentPathname, pathname]),
32
+ route
33
+ } }));
34
+ }
35
+ if (__DEV__) {
36
+ RouterView.displayName = 'RouterView';
37
+ }
@@ -0,0 +1 @@
1
+ export declare const __DEV__: boolean;
@@ -0,0 +1 @@
1
+ export const __DEV__ = process.env.NODE_ENV !== 'production';
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { IRoute } from '@shuvi/router';
3
+ import { IRouterContextObject, IRouteContextObject } from './types';
4
+ export declare const RouterContext: React.Context<IRouterContextObject>;
5
+ export declare const RouteContext: React.Context<IRoute<import("@shuvi/router").IRouteRecord<any>>>;
6
+ export declare const MatchedRouteContext: React.Context<IRouteContextObject>;
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+ import { readOnly } from './utils';
3
+ import { __DEV__ } from './constants';
4
+ export const RouterContext = React.createContext(null);
5
+ if (__DEV__) {
6
+ RouterContext.displayName = 'Router';
7
+ }
8
+ export const RouteContext = React.createContext(null);
9
+ if (__DEV__) {
10
+ RouterContext.displayName = 'Route';
11
+ }
12
+ export const MatchedRouteContext = React.createContext({
13
+ depth: 0,
14
+ params: readOnly({}),
15
+ pathname: '',
16
+ route: null
17
+ });
18
+ if (__DEV__) {
19
+ MatchedRouteContext.displayName = 'MatchedRoute';
20
+ }
package/esm/hooks.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { IParams, IPathMatch, Blocker, Path, PathRecord, IRouter, IPathPattern } from '@shuvi/router';
2
+ import { INavigateFunction } from './types';
3
+ export declare function useCurrentRoute(): import("@shuvi/router").IRoute<import("@shuvi/router").IRouteRecord<any>>;
4
+ /**
5
+ * Blocks all navigation attempts. This is useful for preventing the page from
6
+ * changing until some condition is met, like saving form data.
7
+ */
8
+ export declare function useBlocker(blocker: Blocker, when?: boolean): void;
9
+ /**
10
+ * Returns the full href for the given "to" value. This is useful for building
11
+ * custom links that are also accessible and preserve right-click behavior.
12
+ */
13
+ export declare function useHref(to: PathRecord): string;
14
+ /**
15
+ * Returns true if this component is a descendant of a <Router>.
16
+ */
17
+ export declare function useInRouterContext(): boolean;
18
+ /**
19
+ * Returns true if the URL for the given "to" value matches the current URL.
20
+ * This is useful for components that need to know "active" state, e.g.
21
+ * <NavLink>.
22
+ */
23
+ export declare function useMatch(pattern: IPathPattern): IPathMatch | null;
24
+ /**
25
+ * Returns an imperative method for changing the location. Used by <Link>s, but
26
+ * may also be used by other elements to change the location.
27
+ */
28
+ export declare function useNavigate(): INavigateFunction;
29
+ /**
30
+ * Returns an object of key/value pairs of the dynamic params from the current
31
+ * URL that were matched by the route path.
32
+ */
33
+ export declare function useParams(): IParams;
34
+ /**
35
+ * Resolves the pathname of the given `to` value against the current location.
36
+ */
37
+ export declare function useResolvedPath(to: PathRecord): Path;
38
+ /**
39
+ * Returns the current router object
40
+ */
41
+ export declare function useRouter(): IRouter;
package/esm/hooks.js ADDED
@@ -0,0 +1,108 @@
1
+ import React, { useContext } from 'react';
2
+ import { matchPathname } from '@shuvi/router';
3
+ import invariant from '@shuvi/utils/lib/invariant';
4
+ import { RouterContext, RouteContext, MatchedRouteContext } from './contexts';
5
+ import { warning } from './utils';
6
+ export function useCurrentRoute() {
7
+ return useContext(RouteContext);
8
+ }
9
+ /**
10
+ * Blocks all navigation attempts. This is useful for preventing the page from
11
+ * changing until some condition is met, like saving form data.
12
+ */
13
+ export function useBlocker(blocker, when = true) {
14
+ invariant(useInRouterContext(), `useBlocker() may be used only in the context of a <Router> component.`);
15
+ const { router } = useContext(RouterContext);
16
+ React.useEffect(() => {
17
+ if (!when)
18
+ return;
19
+ let unblock = router.block((tx) => {
20
+ let autoUnblockingTx = Object.assign(Object.assign({}, tx), { retry() {
21
+ // Automatically unblock the transition so it can play all the way
22
+ // through before retrying it. TODO: Figure out how to re-enable
23
+ // this block if the transition is cancelled for some reason.
24
+ unblock();
25
+ tx.retry();
26
+ } });
27
+ blocker(autoUnblockingTx);
28
+ });
29
+ return unblock;
30
+ }, [router, blocker, when]);
31
+ }
32
+ /**
33
+ * Returns the full href for the given "to" value. This is useful for building
34
+ * custom links that are also accessible and preserve right-click behavior.
35
+ */
36
+ export function useHref(to) {
37
+ invariant(useInRouterContext(), `useHref() may be used only in the context of a <Router> component.`);
38
+ const { router } = useContext(RouterContext);
39
+ const path = useResolvedPath(to);
40
+ return router.resolve(path).href;
41
+ }
42
+ /**
43
+ * Returns true if this component is a descendant of a <Router>.
44
+ */
45
+ export function useInRouterContext() {
46
+ return useContext(RouterContext) != null;
47
+ }
48
+ /**
49
+ * Returns true if the URL for the given "to" value matches the current URL.
50
+ * This is useful for components that need to know "active" state, e.g.
51
+ * <NavLink>.
52
+ */
53
+ export function useMatch(pattern) {
54
+ invariant(useInRouterContext(), `useMatch() may be used only in the context of a <Router> component.`);
55
+ const { pathname } = useCurrentRoute();
56
+ return matchPathname(pattern, pathname);
57
+ }
58
+ /**
59
+ * Returns an imperative method for changing the location. Used by <Link>s, but
60
+ * may also be used by other elements to change the location.
61
+ */
62
+ export function useNavigate() {
63
+ invariant(useInRouterContext(), `useNavigate() may be used only in the context of a <Router> component.`);
64
+ const { router } = useContext(RouterContext);
65
+ const { pathname } = useContext(MatchedRouteContext);
66
+ const activeRef = React.useRef(false);
67
+ React.useEffect(() => {
68
+ activeRef.current = true;
69
+ });
70
+ let navigate = React.useCallback((to, options = {}) => {
71
+ if (activeRef.current) {
72
+ if (typeof to === 'number') {
73
+ router.go(to);
74
+ }
75
+ else {
76
+ let { path } = router.resolve(to, pathname);
77
+ (!!options.replace ? router.replace : router.push).call(router, path, options.state);
78
+ }
79
+ }
80
+ else {
81
+ warning(false, `You should call navigate() in a useEffect, not when ` +
82
+ `your component is first rendered.`);
83
+ }
84
+ }, [router, pathname]);
85
+ return navigate;
86
+ }
87
+ /**
88
+ * Returns an object of key/value pairs of the dynamic params from the current
89
+ * URL that were matched by the route path.
90
+ */
91
+ export function useParams() {
92
+ return useContext(MatchedRouteContext).params;
93
+ }
94
+ /**
95
+ * Resolves the pathname of the given `to` value against the current location.
96
+ */
97
+ export function useResolvedPath(to) {
98
+ const { router } = useContext(RouterContext);
99
+ const { pathname } = useContext(MatchedRouteContext);
100
+ return React.useMemo(() => router.resolve(to, pathname).path, [to, pathname]);
101
+ }
102
+ /**
103
+ * Returns the current router object
104
+ */
105
+ export function useRouter() {
106
+ invariant(useInRouterContext(), `useRouter() may be used only in the context of a <Router> component.`);
107
+ return useContext(RouterContext).router;
108
+ }
package/esm/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ export { generatePath } from './utils';
2
+ export { MemoryRouter } from './MemoryRouter';
3
+ export { RouterView } from './RouterView';
4
+ export { Router } from './Router';
5
+ export { Link } from './Link';
6
+ export { withRouter } from './withRouter';
7
+ export * from './hooks';
8
+ export * from './types';
package/esm/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export { generatePath } from './utils';
2
+ export { MemoryRouter } from './MemoryRouter';
3
+ export { RouterView } from './RouterView';
4
+ export { Router } from './Router';
5
+ export { Link } from './Link';
6
+ export { withRouter } from './withRouter';
7
+ export * from './hooks';
8
+ export * from './types';
package/esm/types.d.ts ADDED
@@ -0,0 +1,47 @@
1
+ /// <reference types="react" />
2
+ import { IParams, InitialEntry, State, PathRecord, IRouteRecord as IOriginRouteRecord, IPartialRouteRecord as IOriginalRouteRecord, IRouter } from '@shuvi/router';
3
+ export declare type IRouteRecord = IOriginRouteRecord<React.ReactNode>;
4
+ export declare type IPartialRouteRecord = IOriginalRouteRecord;
5
+ export interface IRouterContextObject {
6
+ static: boolean;
7
+ router: IRouter;
8
+ }
9
+ export interface IRouteContextObject {
10
+ depth: number;
11
+ params: IParams;
12
+ pathname: string;
13
+ route: IRouteRecord | null;
14
+ }
15
+ export interface IMemoryRouterProps {
16
+ basename?: string;
17
+ children?: React.ReactNode;
18
+ routes?: IRouteRecord[];
19
+ initialEntries?: InitialEntry[];
20
+ initialIndex?: number;
21
+ }
22
+ export interface INavigateProps {
23
+ to: PathRecord;
24
+ replace?: boolean;
25
+ state?: State;
26
+ }
27
+ export interface IOutletProps {
28
+ }
29
+ export interface IRouterProps {
30
+ children?: React.ReactNode;
31
+ static?: boolean;
32
+ router: IRouter;
33
+ }
34
+ export interface IRoutesProps {
35
+ basename?: string;
36
+ children?: React.ReactNode;
37
+ }
38
+ /**
39
+ * The interface for the navigate() function returned from useNavigate().
40
+ */
41
+ export interface INavigateFunction {
42
+ (to: PathRecord, options?: {
43
+ replace?: boolean;
44
+ state?: State;
45
+ }): void;
46
+ (delta: number): void;
47
+ }
package/esm/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/esm/utils.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { IParams } from '@shuvi/router';
2
+ export declare function useIsomorphicEffect(cb: any, deps: any): void;
3
+ export declare const readOnly: <T extends unknown>(obj: T) => T;
4
+ export declare function warning(cond: boolean, message: string): void;
5
+ export declare function warningOnce(key: string, cond: boolean, message: string): void;
6
+ /**
7
+ * Returns a path with params interpolated.
8
+ */
9
+ export declare function generatePath(path: string, params?: IParams): string;
package/esm/utils.js ADDED
@@ -0,0 +1,42 @@
1
+ import { matchStringify } from '@shuvi/router';
2
+ import { useLayoutEffect, useEffect } from 'react';
3
+ import { __DEV__ } from './constants';
4
+ export function useIsomorphicEffect(cb, deps) {
5
+ if (typeof window !== 'undefined') {
6
+ useLayoutEffect(cb, deps);
7
+ }
8
+ else {
9
+ useEffect(cb, deps);
10
+ }
11
+ }
12
+ export const readOnly = __DEV__
13
+ ? obj => Object.freeze(obj)
14
+ : obj => obj;
15
+ export function warning(cond, message) {
16
+ if (!cond) {
17
+ if (typeof console !== 'undefined')
18
+ console.warn(message);
19
+ try {
20
+ // Welcome to debugging React Router!
21
+ //
22
+ // This error is thrown as a convenience so you can more easily
23
+ // find the source for a warning that appears in the console by
24
+ // enabling "pause on exceptions" in your JavaScript debugger.
25
+ throw new Error(message);
26
+ }
27
+ catch (e) { }
28
+ }
29
+ }
30
+ const alreadyWarned = {};
31
+ export function warningOnce(key, cond, message) {
32
+ if (!cond && !alreadyWarned[key]) {
33
+ alreadyWarned[key] = true;
34
+ warning(false, message);
35
+ }
36
+ }
37
+ /**
38
+ * Returns a path with params interpolated.
39
+ */
40
+ export function generatePath(path, params = {}) {
41
+ return matchStringify(path, params);
42
+ }
@@ -0,0 +1,8 @@
1
+ import { IRouter } from '@shuvi/router';
2
+ import { Runtime } from '@shuvi/service';
3
+ import React from 'react';
4
+ export declare type WithRouterProps = {
5
+ router: IRouter;
6
+ };
7
+ export declare type ExcludeRouterProps<P> = Pick<P, Exclude<keyof P, keyof WithRouterProps>>;
8
+ export declare function withRouter<P extends WithRouterProps>(ComposedComponent: Runtime.IRouteComponent<React.ComponentType<P>, any>): Runtime.IRouteComponent<React.ComponentType<ExcludeRouterProps<P>>, any>;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { useRouter } from './hooks';
3
+ export function withRouter(ComposedComponent) {
4
+ function WithRouterWrapper(props) {
5
+ return React.createElement(ComposedComponent, Object.assign({ router: useRouter() }, props));
6
+ }
7
+ WithRouterWrapper.getInitialProps = ComposedComponent.getInitialProps;
8
+ if (process.env.NODE_ENV !== 'production') {
9
+ const name = ComposedComponent.displayName || ComposedComponent.name || 'Unknown';
10
+ WithRouterWrapper.displayName = `withRouter(${name})`;
11
+ }
12
+ return WithRouterWrapper;
13
+ }
package/lib/Link.js CHANGED
@@ -1,4 +1,23 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
2
21
  var __rest = (this && this.__rest) || function (s, e) {
3
22
  var t = {};
4
23
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -10,17 +29,11 @@ var __rest = (this && this.__rest) || function (s, e) {
10
29
  }
11
30
  return t;
12
31
  };
13
- var __importStar = (this && this.__importStar) || function (mod) {
14
- if (mod && mod.__esModule) return mod;
15
- var result = {};
16
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
17
- result["default"] = mod;
18
- return result;
19
- };
20
32
  var __importDefault = (this && this.__importDefault) || function (mod) {
21
33
  return (mod && mod.__esModule) ? mod : { "default": mod };
22
34
  };
23
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Link = void 0;
24
37
  const React = __importStar(require("react"));
25
38
  const prop_types_1 = __importDefault(require("prop-types"));
26
39
  const _1 = require(".");
@@ -35,10 +48,10 @@ function isModifiedEvent(event) {
35
48
  */
36
49
  exports.Link = React.forwardRef(function LinkWithRef(_a, ref) {
37
50
  var { onClick, replace: replaceProp = false, state, target, to } = _a, rest = __rest(_a, ["onClick", "replace", "state", "target", "to"]);
38
- let href = _1.useHref(to);
39
- let navigate = _1.useNavigate();
40
- const location = hooks_1.useCurrentRoute();
41
- let path = _1.useResolvedPath(to);
51
+ let href = (0, _1.useHref)(to);
52
+ let navigate = (0, _1.useNavigate)();
53
+ const location = (0, hooks_1.useCurrentRoute)();
54
+ let path = (0, _1.useResolvedPath)(to);
42
55
  function handleClick(event) {
43
56
  if (onClick)
44
57
  onClick(event);
@@ -50,7 +63,7 @@ exports.Link = React.forwardRef(function LinkWithRef(_a, ref) {
50
63
  event.preventDefault();
51
64
  // If the URL hasn't changed, a regular <a> will do a replace instead of
52
65
  // a push, so do the same here.
53
- let replace = !!replaceProp || router_1.pathToString(location) === router_1.pathToString(path);
66
+ let replace = !!replaceProp || (0, router_1.pathToString)(location) === (0, router_1.pathToString)(path);
54
67
  navigate(to, { replace, state });
55
68
  }
56
69
  }
@@ -65,6 +78,7 @@ if (constants_1.__DEV__) {
65
78
  replace: prop_types_1.default.bool,
66
79
  state: prop_types_1.default.object,
67
80
  target: prop_types_1.default.string,
81
+ // @ts-ignore proptypes's bug?
68
82
  to: prop_types_1.default.oneOfType([
69
83
  prop_types_1.default.string,
70
84
  prop_types_1.default.shape({
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MemoryRouter = void 0;
6
7
  const react_1 = __importDefault(require("react"));
7
8
  const prop_types_1 = __importDefault(require("prop-types"));
8
9
  const router_1 = require("@shuvi/router");
@@ -14,10 +15,10 @@ const constants_1 = require("./constants");
14
15
  function MemoryRouter({ basename, children, routes, initialEntries, initialIndex }) {
15
16
  let routerRef = react_1.default.useRef();
16
17
  if (routerRef.current == null) {
17
- routerRef.current = router_1.createRouter({
18
+ routerRef.current = (0, router_1.createRouter)({
18
19
  basename,
19
20
  routes: routes || [],
20
- history: router_1.createMemoryHistory({ initialEntries, initialIndex })
21
+ history: (0, router_1.createMemoryHistory)({ initialEntries, initialIndex })
21
22
  });
22
23
  }
23
24
  return react_1.default.createElement(Router_1.Router, { children: children, router: routerRef.current });
package/lib/Router.js CHANGED
@@ -1,15 +1,28 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
2
14
  var __importStar = (this && this.__importStar) || function (mod) {
3
15
  if (mod && mod.__esModule) return mod;
4
16
  var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
7
19
  return result;
8
20
  };
9
21
  var __importDefault = (this && this.__importDefault) || function (mod) {
10
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
23
  };
12
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.Router = void 0;
13
26
  const react_1 = __importStar(require("react"));
14
27
  const prop_types_1 = __importDefault(require("prop-types"));
15
28
  const invariant_1 = __importDefault(require("@shuvi/utils/lib/invariant"));
@@ -25,7 +38,7 @@ const utils_1 = require("./utils");
25
38
  * in web browsers or a <StaticRouter> for server rendering.
26
39
  */
27
40
  function Router({ children = null, static: staticProp = false, router }) {
28
- invariant_1.default(!hooks_1.useInRouterContext(), `You cannot render a <Router> inside another <Router>.` +
41
+ (0, invariant_1.default)(!(0, hooks_1.useInRouterContext)(), `You cannot render a <Router> inside another <Router>.` +
29
42
  ` You never need more than one.`);
30
43
  const contextVal = react_1.default.useMemo(() => {
31
44
  return {
@@ -33,10 +46,10 @@ function Router({ children = null, static: staticProp = false, router }) {
33
46
  router: router
34
47
  };
35
48
  }, [staticProp, router]);
36
- const unmount = react_1.useRef(false);
37
- const forceupdate = react_1.useReducer(s => s * -1, 1)[1];
38
- utils_1.useIsomorphicEffect(() => () => (unmount.current = true), []);
39
- utils_1.useIsomorphicEffect(() => router.listen(() => {
49
+ const unmount = (0, react_1.useRef)(false);
50
+ const forceupdate = (0, react_1.useReducer)(s => s * -1, 1)[1];
51
+ (0, utils_1.useIsomorphicEffect)(() => () => (unmount.current = true), []);
52
+ (0, utils_1.useIsomorphicEffect)(() => router.listen(() => {
40
53
  if (unmount.current) {
41
54
  return;
42
55
  }
package/lib/RouterView.js CHANGED
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RouterView = void 0;
6
7
  const react_1 = __importDefault(require("react"));
7
8
  const utils_1 = require("@shuvi/router/lib/utils");
8
9
  const hooks_1 = require("./hooks");
@@ -12,7 +13,7 @@ const utils_2 = require("./utils");
12
13
  const defaultElement = react_1.default.createElement(RouterView, null);
13
14
  function RouterView() {
14
15
  let { depth, pathname: parentPathname, params: parentParams } = react_1.default.useContext(contexts_1.MatchedRouteContext);
15
- const { matches } = hooks_1.useCurrentRoute();
16
+ const { matches } = (0, hooks_1.useCurrentRoute)();
16
17
  if (!matches) {
17
18
  return null;
18
19
  }
@@ -20,7 +21,7 @@ function RouterView() {
20
21
  const matched = matches[depth];
21
22
  if (!matched) {
22
23
  if (constants_1.__DEV__) {
23
- utils_2.warningOnce(parentPathname, false, `Use <RouterView/> under path "${parentPathname}", but it has no children routes.` +
24
+ (0, utils_2.warningOnce)(parentPathname, false, `Use <RouterView/> under path "${parentPathname}", but it has no children routes.` +
24
25
  `\n\n` +
25
26
  `Please remove the <RouterView/>.`);
26
27
  }
@@ -32,8 +33,8 @@ function RouterView() {
32
33
  : defaultElement;
33
34
  return (react_1.default.createElement(contexts_1.MatchedRouteContext.Provider, { children: element, value: {
34
35
  depth: depth + 1,
35
- params: utils_2.readOnly(Object.assign(Object.assign({}, parentParams), params)),
36
- pathname: utils_1.joinPaths([parentPathname, pathname]),
36
+ params: (0, utils_2.readOnly)(Object.assign(Object.assign({}, parentParams), params)),
37
+ pathname: (0, utils_1.joinPaths)([parentPathname, pathname]),
37
38
  route
38
39
  } }));
39
40
  }
package/lib/constants.js CHANGED
@@ -1,3 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.__DEV__ = void 0;
3
4
  exports.__DEV__ = process.env.NODE_ENV !== 'production';
package/lib/contexts.js CHANGED
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MatchedRouteContext = exports.RouteContext = exports.RouterContext = void 0;
6
7
  const react_1 = __importDefault(require("react"));
7
8
  const utils_1 = require("./utils");
8
9
  const constants_1 = require("./constants");
@@ -16,7 +17,7 @@ if (constants_1.__DEV__) {
16
17
  }
17
18
  exports.MatchedRouteContext = react_1.default.createContext({
18
19
  depth: 0,
19
- params: utils_1.readOnly({}),
20
+ params: (0, utils_1.readOnly)({}),
20
21
  pathname: '',
21
22
  route: null
22
23
  });
package/lib/hooks.js CHANGED
@@ -1,22 +1,35 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
2
14
  var __importStar = (this && this.__importStar) || function (mod) {
3
15
  if (mod && mod.__esModule) return mod;
4
16
  var result = {};
5
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6
- result["default"] = mod;
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
7
19
  return result;
8
20
  };
9
21
  var __importDefault = (this && this.__importDefault) || function (mod) {
10
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
23
  };
12
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.useRouter = exports.useResolvedPath = exports.useParams = exports.useNavigate = exports.useMatch = exports.useInRouterContext = exports.useHref = exports.useBlocker = exports.useCurrentRoute = void 0;
13
26
  const react_1 = __importStar(require("react"));
14
27
  const router_1 = require("@shuvi/router");
15
28
  const invariant_1 = __importDefault(require("@shuvi/utils/lib/invariant"));
16
29
  const contexts_1 = require("./contexts");
17
30
  const utils_1 = require("./utils");
18
31
  function useCurrentRoute() {
19
- return react_1.useContext(contexts_1.RouteContext);
32
+ return (0, react_1.useContext)(contexts_1.RouteContext);
20
33
  }
21
34
  exports.useCurrentRoute = useCurrentRoute;
22
35
  /**
@@ -24,8 +37,8 @@ exports.useCurrentRoute = useCurrentRoute;
24
37
  * changing until some condition is met, like saving form data.
25
38
  */
26
39
  function useBlocker(blocker, when = true) {
27
- invariant_1.default(useInRouterContext(), `useBlocker() may be used only in the context of a <Router> component.`);
28
- const { router } = react_1.useContext(contexts_1.RouterContext);
40
+ (0, invariant_1.default)(useInRouterContext(), `useBlocker() may be used only in the context of a <Router> component.`);
41
+ const { router } = (0, react_1.useContext)(contexts_1.RouterContext);
29
42
  react_1.default.useEffect(() => {
30
43
  if (!when)
31
44
  return;
@@ -48,8 +61,8 @@ exports.useBlocker = useBlocker;
48
61
  * custom links that are also accessible and preserve right-click behavior.
49
62
  */
50
63
  function useHref(to) {
51
- invariant_1.default(useInRouterContext(), `useHref() may be used only in the context of a <Router> component.`);
52
- const { router } = react_1.useContext(contexts_1.RouterContext);
64
+ (0, invariant_1.default)(useInRouterContext(), `useHref() may be used only in the context of a <Router> component.`);
65
+ const { router } = (0, react_1.useContext)(contexts_1.RouterContext);
53
66
  const path = useResolvedPath(to);
54
67
  return router.resolve(path).href;
55
68
  }
@@ -58,7 +71,7 @@ exports.useHref = useHref;
58
71
  * Returns true if this component is a descendant of a <Router>.
59
72
  */
60
73
  function useInRouterContext() {
61
- return react_1.useContext(contexts_1.RouterContext) != null;
74
+ return (0, react_1.useContext)(contexts_1.RouterContext) != null;
62
75
  }
63
76
  exports.useInRouterContext = useInRouterContext;
64
77
  /**
@@ -67,9 +80,9 @@ exports.useInRouterContext = useInRouterContext;
67
80
  * <NavLink>.
68
81
  */
69
82
  function useMatch(pattern) {
70
- invariant_1.default(useInRouterContext(), `useMatch() may be used only in the context of a <Router> component.`);
83
+ (0, invariant_1.default)(useInRouterContext(), `useMatch() may be used only in the context of a <Router> component.`);
71
84
  const { pathname } = useCurrentRoute();
72
- return router_1.matchPathname(pattern, pathname);
85
+ return (0, router_1.matchPathname)(pattern, pathname);
73
86
  }
74
87
  exports.useMatch = useMatch;
75
88
  /**
@@ -77,9 +90,9 @@ exports.useMatch = useMatch;
77
90
  * may also be used by other elements to change the location.
78
91
  */
79
92
  function useNavigate() {
80
- invariant_1.default(useInRouterContext(), `useNavigate() may be used only in the context of a <Router> component.`);
81
- const { router } = react_1.useContext(contexts_1.RouterContext);
82
- const { pathname } = react_1.useContext(contexts_1.MatchedRouteContext);
93
+ (0, invariant_1.default)(useInRouterContext(), `useNavigate() may be used only in the context of a <Router> component.`);
94
+ const { router } = (0, react_1.useContext)(contexts_1.RouterContext);
95
+ const { pathname } = (0, react_1.useContext)(contexts_1.MatchedRouteContext);
83
96
  const activeRef = react_1.default.useRef(false);
84
97
  react_1.default.useEffect(() => {
85
98
  activeRef.current = true;
@@ -95,7 +108,7 @@ function useNavigate() {
95
108
  }
96
109
  }
97
110
  else {
98
- utils_1.warning(false, `You should call navigate() in a useEffect, not when ` +
111
+ (0, utils_1.warning)(false, `You should call navigate() in a useEffect, not when ` +
99
112
  `your component is first rendered.`);
100
113
  }
101
114
  }, [router, pathname]);
@@ -107,15 +120,15 @@ exports.useNavigate = useNavigate;
107
120
  * URL that were matched by the route path.
108
121
  */
109
122
  function useParams() {
110
- return react_1.useContext(contexts_1.MatchedRouteContext).params;
123
+ return (0, react_1.useContext)(contexts_1.MatchedRouteContext).params;
111
124
  }
112
125
  exports.useParams = useParams;
113
126
  /**
114
127
  * Resolves the pathname of the given `to` value against the current location.
115
128
  */
116
129
  function useResolvedPath(to) {
117
- const { router } = react_1.useContext(contexts_1.RouterContext);
118
- const { pathname } = react_1.useContext(contexts_1.MatchedRouteContext);
130
+ const { router } = (0, react_1.useContext)(contexts_1.RouterContext);
131
+ const { pathname } = (0, react_1.useContext)(contexts_1.MatchedRouteContext);
119
132
  return react_1.default.useMemo(() => router.resolve(to, pathname).path, [to, pathname]);
120
133
  }
121
134
  exports.useResolvedPath = useResolvedPath;
@@ -123,7 +136,7 @@ exports.useResolvedPath = useResolvedPath;
123
136
  * Returns the current router object
124
137
  */
125
138
  function useRouter() {
126
- invariant_1.default(useInRouterContext(), `useRouter() may be used only in the context of a <Router> component.`);
127
- return react_1.useContext(contexts_1.RouterContext).router;
139
+ (0, invariant_1.default)(useInRouterContext(), `useRouter() may be used only in the context of a <Router> component.`);
140
+ return (0, react_1.useContext)(contexts_1.RouterContext).router;
128
141
  }
129
142
  exports.useRouter = useRouter;
package/lib/index.js CHANGED
@@ -1,18 +1,27 @@
1
1
  "use strict";
2
- function __export(m) {
3
- for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4
- }
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
5
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.withRouter = exports.Link = exports.Router = exports.RouterView = exports.MemoryRouter = exports.generatePath = void 0;
6
14
  var utils_1 = require("./utils");
7
- exports.generatePath = utils_1.generatePath;
15
+ Object.defineProperty(exports, "generatePath", { enumerable: true, get: function () { return utils_1.generatePath; } });
8
16
  var MemoryRouter_1 = require("./MemoryRouter");
9
- exports.MemoryRouter = MemoryRouter_1.MemoryRouter;
17
+ Object.defineProperty(exports, "MemoryRouter", { enumerable: true, get: function () { return MemoryRouter_1.MemoryRouter; } });
10
18
  var RouterView_1 = require("./RouterView");
11
- exports.RouterView = RouterView_1.RouterView;
19
+ Object.defineProperty(exports, "RouterView", { enumerable: true, get: function () { return RouterView_1.RouterView; } });
12
20
  var Router_1 = require("./Router");
13
- exports.Router = Router_1.Router;
21
+ Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return Router_1.Router; } });
14
22
  var Link_1 = require("./Link");
15
- exports.Link = Link_1.Link;
23
+ Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return Link_1.Link; } });
16
24
  var withRouter_1 = require("./withRouter");
17
- exports.withRouter = withRouter_1.withRouter;
18
- __export(require("./hooks"));
25
+ Object.defineProperty(exports, "withRouter", { enumerable: true, get: function () { return withRouter_1.withRouter; } });
26
+ __exportStar(require("./hooks"), exports);
27
+ __exportStar(require("./types"), exports);
package/lib/utils.js CHANGED
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generatePath = exports.warningOnce = exports.warning = exports.readOnly = exports.useIsomorphicEffect = void 0;
3
4
  const router_1 = require("@shuvi/router");
4
5
  const react_1 = require("react");
5
6
  const constants_1 = require("./constants");
6
7
  function useIsomorphicEffect(cb, deps) {
7
8
  if (typeof window !== 'undefined') {
8
- react_1.useLayoutEffect(cb, deps);
9
+ (0, react_1.useLayoutEffect)(cb, deps);
9
10
  }
10
11
  else {
11
- react_1.useEffect(cb, deps);
12
+ (0, react_1.useEffect)(cb, deps);
12
13
  }
13
14
  }
14
15
  exports.useIsomorphicEffect = useIsomorphicEffect;
@@ -43,6 +44,6 @@ exports.warningOnce = warningOnce;
43
44
  * Returns a path with params interpolated.
44
45
  */
45
46
  function generatePath(path, params = {}) {
46
- return router_1.matchStringify(path, params);
47
+ return (0, router_1.matchStringify)(path, params);
47
48
  }
48
49
  exports.generatePath = generatePath;
package/lib/withRouter.js CHANGED
@@ -3,11 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.withRouter = void 0;
6
7
  const react_1 = __importDefault(require("react"));
7
8
  const hooks_1 = require("./hooks");
8
9
  function withRouter(ComposedComponent) {
9
10
  function WithRouterWrapper(props) {
10
- return react_1.default.createElement(ComposedComponent, Object.assign({ router: hooks_1.useRouter() }, props));
11
+ return react_1.default.createElement(ComposedComponent, Object.assign({ router: (0, hooks_1.useRouter)() }, props));
11
12
  }
12
13
  WithRouterWrapper.getInitialProps = ComposedComponent.getInitialProps;
13
14
  if (process.env.NODE_ENV !== 'production') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/router-react",
3
- "version": "0.0.1-pre.1",
3
+ "version": "0.0.1-pre.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -12,7 +12,8 @@
12
12
  "module": "esm/index.js",
13
13
  "types": "lib/index.d.ts",
14
14
  "files": [
15
- "lib"
15
+ "lib",
16
+ "esm"
16
17
  ],
17
18
  "scripts": {
18
19
  "dev": "run-p watch:*",
@@ -27,8 +28,8 @@
27
28
  "node": ">= 12.0.0"
28
29
  },
29
30
  "dependencies": {
30
- "@shuvi/router": "0.0.1-pre.1",
31
- "@shuvi/service": "0.0.1-pre.1"
31
+ "@shuvi/router": "0.0.1-pre.10",
32
+ "@shuvi/service": "0.0.1-pre.10"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@types/react": "^16.9.43",
@@ -38,5 +39,5 @@
38
39
  "peerDependencies": {
39
40
  "react": ">=16.8"
40
41
  },
41
- "gitHead": "0bc0bc76e72ca5a339341e8b71d6bb6bb41409e8"
42
+ "gitHead": "a7309b27916427de62ba66c8cd6eb6db0f19dee9"
42
43
  }