Skip to content

Commit

Permalink
fix: typo(#176)
Browse files Browse the repository at this point in the history
BaseHisotry=>BaseHistory, doTransision=>doTransition, MactedRouteContext=>MatchedRouteContext
  • Loading branch information
wangjinyang authored Aug 30, 2021
1 parent 45aeacd commit 510eee3
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions packages/router-mp/src/mpHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import {
} from '@shuvi/router';
import invariant from '@shuvi/utils/lib/invariant';
import { navigateTo, redirectTo, navigateBack } from './navigateApis';
import BaseHisotry, {
import BaseHistory, {
PushOptions,
ACTION_PUSH,
TransitionOptions
} from '@shuvi/router/lib/history/base';

export class MpHistory extends BaseHisotry {
export class MpHistory extends BaseHistory {
private _entries: Location[] = [];

constructor({
Expand Down Expand Up @@ -89,7 +89,7 @@ export class MpHistory extends BaseHisotry {
) {
const { path } = this.resolve(to, this.location.pathname);
const nextLocation = createLocation(path, { state, redirectedFrom });
this.doTransision(
this.doTransition(
to,
() => {
onTransition({
Expand Down
6 changes: 3 additions & 3 deletions packages/router-react/src/RouterView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { IParams } from '@shuvi/router';
import { joinPaths } from '@shuvi/router/lib/utils';
import { useCurrentRoute } from './hooks';
import { __DEV__ } from './constants';
import { MactedRouteContext } from './contexts';
import { MatchedRouteContext } from './contexts';
import { warningOnce, readOnly } from './utils';

const defaultElement = <RouterView />;
Expand All @@ -13,7 +13,7 @@ export function RouterView(): React.ReactElement | null {
depth,
pathname: parentPathname,
params: parentParams
} = React.useContext(MactedRouteContext);
} = React.useContext(MatchedRouteContext);
const { matches } = useCurrentRoute();

if (!matches) {
Expand Down Expand Up @@ -41,7 +41,7 @@ export function RouterView(): React.ReactElement | null {
: defaultElement;

return (
<MactedRouteContext.Provider
<MatchedRouteContext.Provider
children={element}
value={{
depth: depth + 1,
Expand Down
4 changes: 2 additions & 2 deletions packages/router-react/src/contexts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ if (__DEV__) {
RouterContext.displayName = 'Route';
}

export const MactedRouteContext = React.createContext<IRouteContextObject>({
export const MatchedRouteContext = React.createContext<IRouteContextObject>({
depth: 0,
params: readOnly<IParams>({}),
pathname: '',
route: null
});

if (__DEV__) {
MactedRouteContext.displayName = 'MactedRoute';
MatchedRouteContext.displayName = 'MactedRoute';
}
8 changes: 4 additions & 4 deletions packages/router-react/src/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@shuvi/router';
import invariant from '@shuvi/utils/lib/invariant';
import { __DEV__ } from './constants';
import { RouterContext, RouteContext, MactedRouteContext } from './contexts';
import { RouterContext, RouteContext, MatchedRouteContext } from './contexts';
import { warning } from './utils';
import { INavigateFunction } from './types';

Expand Down Expand Up @@ -103,7 +103,7 @@ export function useNavigate(): INavigateFunction {
);

const { router } = useContext(RouterContext);
const { pathname } = useContext(MactedRouteContext);
const { pathname } = useContext(MatchedRouteContext);

const activeRef = React.useRef(false);
React.useEffect(() => {
Expand Down Expand Up @@ -145,15 +145,15 @@ export function useNavigate(): INavigateFunction {
* URL that were matched by the route path.
*/
export function useParams(): IParams {
return useContext(MactedRouteContext).params;
return useContext(MatchedRouteContext).params;
}

/**
* Resolves the pathname of the given `to` value against the current location.
*/
export function useResolvedPath(to: PathRecord): Path {
const { router } = useContext(RouterContext);
const { pathname } = useContext(MactedRouteContext);
const { pathname } = useContext(MatchedRouteContext);
return React.useMemo(() => router.resolve(to, pathname).path, [to, pathname]);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/router/src/history/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface PushOptions {
export default abstract class BaseHistory {
action: Action = ACTION_POP;
location: Location = createLocation('/');
doTransision: (
doTransition: (
to: PathRecord,
onComplete: Function,
onAbort?: Function
Expand Down Expand Up @@ -123,7 +123,7 @@ export default abstract class BaseHistory {
return;
}

this.doTransision(
this.doTransition(
to,
() => {
onTransition({
Expand Down
4 changes: 2 additions & 2 deletions packages/router/src/history/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import {
addBlocker,
warning
} from '../utils';
import BaseHisotry, { PushOptions, ACTION_POP, ACTION_REPLACE } from './base';
import BaseHistory, { PushOptions, ACTION_POP, ACTION_REPLACE } from './base';

export default class BrowserHistory extends BaseHisotry {
export default class BrowserHistory extends BaseHistory {
private _history: GlobalHistory = window.history;

constructor() {
Expand Down
4 changes: 2 additions & 2 deletions packages/router/src/history/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
pathToString,
warning
} from '../utils';
import BaseHisotry, { PushOptions, ACTION_POP, ACTION_REPLACE } from './base';
import BaseHistory, { PushOptions, ACTION_POP, ACTION_REPLACE } from './base';

function getBaseHref() {
let base = document.querySelector('base');
Expand All @@ -38,7 +38,7 @@ function createHref(to: PathRecord) {
);
}

export default class HashHistory extends BaseHisotry {
export default class HashHistory extends BaseHistory {
private _history: GlobalHistory = window.history;

constructor() {
Expand Down
4 changes: 2 additions & 2 deletions packages/router/src/history/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ResolvedPath
} from '../types';
import { createLocation, resolvePath, pathToString, warning } from '../utils';
import BaseHisotry, { PushOptions, ACTION_POP, ACTION_REPLACE } from './base';
import BaseHistory, { PushOptions, ACTION_POP, ACTION_REPLACE } from './base';

function clamp(n: number, lowerBound: number, upperBound: number) {
return Math.min(Math.max(n, lowerBound), upperBound);
Expand All @@ -23,7 +23,7 @@ export type MemoryHistoryOptions = {
initialIndex?: number;
};

export default class MemoryHistory extends BaseHisotry {
export default class MemoryHistory extends BaseHistory {
private _entries: Location[] = [];

constructor({
Expand Down
2 changes: 1 addition & 1 deletion packages/router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Router<RouteRecord extends IRouteRecord> implements IRouter<RouteRecord> {
this._history = history;
this._routes = createRoutesFromArray(routes);
this._current = START;
this._history.doTransision = this._doTransition.bind(this);
this._history.doTransition = this._doTransition.bind(this);

const setup = () => this._history.setup();
this._history.transitionTo(this._getCurrent(), {
Expand Down
2 changes: 1 addition & 1 deletion packages/shuvi/src/bundler/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ class WebpackBundler {
const serverConfig = serverChain.toConfig();
logger.debug('Server Config');
logger.debug(inspect(serverConfig.module, { depth: 10 }));
//targets.push({ name: BUNDLER_TARGET_SERVER, config: serverConfig });
// targets.push({ name: BUNDLER_TARGET_SERVER, config: serverConfig });

return targets;
}
Expand Down

0 comments on commit 510eee3

Please sign in to comment.