Skip to content

Commit

Permalink
DTCPP-1578: Update to 1.3.4 (#1)
Browse files Browse the repository at this point in the history
* initialPathname for createMemorySource should split out search params

* Fix typos in RouteComponent.md

changed "renderd" -> "rendered" and one instance of "it's" -> "its"

* Update Match.md

* Fix typo in Link.md

* Failing test, showing location.search and location.hash aren't parsed out from the url in <ServerLocation /> - all of url is put in pathname

* Implement parsing location.search and location.hash from the url in <ServerLocation />, and also remove them from pathname, to make behaviour same as client. Tests now pass.

* Add new passing test (with snapshot) showing correct client behaviour of parsing out pathname, search & host from url. Other tests' snapshots now fail due to addition of hash to test history util

Forgot to add history.js changes in last commit, test now passes

* update snapshots with expected changes to make failing tests pass

* Fixed bug when `navigate(...)` is called before `LocationProvider` is mounted

* Adds missing quotation mark in error message

* Fix small typo

* fix: escape path in isCurrent check

* Add back functionality to navigate route

* Fix typo in nesting.md

* Pre-populate states

This is to ensure it stays in sync with `stack` as `index` is used for both.  Otherwise, they're always off-by-one.

* Update corresponding jest snapshot.

* Remove hash from ServerLocation

Servers don’t get hashes, so we don’t need this code.

* fixup search string handling in createMemoryHistory

* Add support for fragments

* Run all the tests, thanks :P

* add proptype for link

* Exporting the match helper

* s/due/do

* Typo in nesting.md

* Pin create-react-context due to non open source licence

See: react-navigation/react-navigation#4934 for general gist and: jamiebuilds/create-react-context@392ef2b for the breaking change in a minor version.

Jamiebuilds is acting in bad faith to the open source community and this should not propagate down the line.

* Lint code on TravisCI

* Added a basic guide for use with TypeScript

* Added overview content

* GitHub has a capital H

* fix: pass router location prop to nested paths

* Remove deep on warning

* Link to typescript guide

* Reword a bit

* 1.2.2-0

* 1.3.0-beta.0

* Add server configuration guide

* Add displayName to Link

* Don’t copy everything from history.location

Closes reach#252
Closes reach#264

* Failing test for memory history location.search

Refs reach#251

* Add `?` to location.search in memory history

Fixes reach#251

* Upgrade create-react-context to 0.3.0

This version is back to the MIT license, and avoids the dependency on
fbjs which triggers warnings about unmaintained dependencies.

* Update accessibility.md (reach#317)

* Support for named trailing wildcard (reach#323)

* Add support for named trailing wildcard

* Add tests for Match

* Update doc

* Fix the getProps example (reach#306)

According to https://github.com/reach/router/blob/master/src/index.js#L414 the `getProps` function cannot return `null`.

* Fix/active routes push new state to history (reach#302)

* add shallowCompare function

* prevent Link from pushing new state to history when on same path and with the same state

* Fix failing unit tests (reach#333)

Run prettier and clean up

* remove group role from focus wrapper

* bump to 1.3 in docs

* update snapshots

* Bump lodash from 4.17.10 to 4.17.15 in /website (reach#331)

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.10 to 4.17.15.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.10...4.17.15)

Signed-off-by: dependabot[bot] <[email protected]>

* Bump mixin-deep from 1.3.1 to 1.3.2 in /website (reach#330)

Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2.
- [Release notes](https://github.com/jonschlinkert/mixin-deep/releases)
- [Commits](jonschlinkert/mixin-deep@1.3.1...1.3.2)

Signed-off-by: dependabot[bot] <[email protected]>

* Bump react-dom from 16.4.1 to 16.4.2 (reach#329)

Bumps [react-dom](https://github.com/facebook/react/tree/HEAD/packages/react-dom) from 16.4.1 to 16.4.2.
- [Release notes](https://github.com/facebook/react/releases)
- [Changelog](https://github.com/facebook/react/blob/master/CHANGELOG.md)
- [Commits](https://github.com/facebook/react/commits/v16.4.2/packages/react-dom)

Signed-off-by: dependabot[bot] <[email protected]>

* fix createNamedContext (reach#305)

* Add Hooks APIs (reach#346)

* Add Hooks APIs

* Documenation & change useMatch response to match Match

* add hook API navigation links

* some hooks documentation in the intro

* address comments

* yarn format

* 1.3.0

* useRouteMatch => useMatch, add null context warnings (reach#347)

* Fix reach#348 - Pass href to location (reach#350)

* 1.3.1

* fix MS Edge with encoded characters url (reach#344)

In MS Edge, the `location.pathname` is not url encoded, but other browsers do.
This results in not found route when a url contains a special character.

To fix the issue, we now make sure the `pathname` is always encoded, but we also make sure it's not encoded twice.

* Access `navigate` via `props` in example (reach#355)

* Crash on old android devices fixed. Location pathname does not exist sometimes. (reach#339)

* go method added into MemorySource for best compatibility (reach#307)

* 1.3.3

* Update copyright year

* Support forwarding url params with wildcard paths (reach#311)

* fix for query params in insert params

* fix for query params in insert params

* fix for query params in insert params

* fix for query params in insert params

* adding test for location search

* 1.3.4

* Fixes useNavigate inequality with props.navigate (reach#388)

* tests(useNavigate): useNavigate not equals to props.navigate

* fix(useNavigate): match the useNavigate with props.navigate

* fix(useNavigate): add navigate to BaseContext

* Typo fix "makes sure" 2x (reach#379)

* Fix small typo in Server Configuration docs (reach#378)

* Bump acorn from 5.5.3 to 5.7.4 in /website (reach#376)

Bumps [acorn](https://github.com/acornjs/acorn) from 5.5.3 to 5.7.4.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](acornjs/acorn@5.5.3...5.7.4)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump websocket-extensions from 0.1.3 to 0.1.4 in /website (reach#395)

Bumps [websocket-extensions](https://github.com/faye/websocket-extensions-node) from 0.1.3 to 0.1.4.
- [Release notes](https://github.com/faye/websocket-extensions-node/releases)
- [Changelog](https://github.com/faye/websocket-extensions-node/blob/master/CHANGELOG.md)
- [Commits](faye/websocket-extensions-node@0.1.3...0.1.4)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Intro.md: fix import instructions (reach#380)

* Issue: wrong pathname encoding (reach#390)

* Issue: wrong pathname encoding

The encoding on pathname fails when the URL contains `%2F`, and returns the pathname with `%252F` instead. this is because
`encodeURI(decodeURI('%2F')) === "%252F"`
Also see: https://codesandbox.io/s/reach-router-encoding-issue-pofyo

* fix: Encoded pathname

Encoding can now handle side cases where URLs include both encoded and decoded parts that `encode/decodeURI` can't handle, such as `/folder/a%2Fb`

* Bump http-proxy from 1.17.0 to 1.18.1 in /website (reach#420)

Bumps [http-proxy](https://github.com/http-party/node-http-proxy) from 1.17.0 to 1.18.1.
- [Release notes](https://github.com/http-party/node-http-proxy/releases)
- [Changelog](https://github.com/http-party/node-http-proxy/blob/master/CHANGELOG.md)
- [Commits](http-party/node-http-proxy@1.17.0...1.18.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump serve from 6.5.8 to 10.1.2 in /website (reach#419)

Bumps [serve](https://github.com/zeit/serve) from 6.5.8 to 10.1.2.
- [Release notes](https://github.com/zeit/serve/releases)
- [Commits](vercel/serve@6.5.8...10.1.2)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump prismjs from 1.14.0 to 1.21.0 in /website (reach#411)

Bumps [prismjs](https://github.com/PrismJS/prism) from 1.14.0 to 1.21.0.
- [Release notes](https://github.com/PrismJS/prism/releases)
- [Changelog](https://github.com/PrismJS/prism/blob/master/CHANGELOG.md)
- [Commits](PrismJS/prism@v1.14.0...v1.21.0)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump lodash from 4.17.15 to 4.17.19 in /website (reach#407)

Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](lodash/lodash@4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump prismjs from 1.17.1 to 1.21.0 (reach#412)

Bumps [prismjs](https://github.com/PrismJS/prism) from 1.17.1 to 1.21.0.
- [Release notes](https://github.com/PrismJS/prism/releases)
- [Changelog](https://github.com/PrismJS/prism/blob/master/CHANGELOG.md)
- [Commits](PrismJS/prism@v1.17.1...v1.21.0)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump elliptic from 6.4.0 to 6.5.3 in /website (reach#410)

Bumps [elliptic](https://github.com/indutny/elliptic) from 6.4.0 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](indutny/elliptic@v6.4.0...v6.5.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* DTCPP-1578: Re-add query after merging

* DTCPP-1578: Update build

* DTCPP-1578: Move typing to package to add query to ServerLocation types

Co-authored-by: Jake Richan <[email protected]>
Co-authored-by: Daniel Schlabach <[email protected]>
Co-authored-by: Hu Chen <[email protected]>
Co-authored-by: Eric Jinks <[email protected]>
Co-authored-by: Dave Williams <[email protected]>
Co-authored-by: Michael Tamm <[email protected]>
Co-authored-by: Joel Gallant <[email protected]>
Co-authored-by: Pavel Zastavnitskiy <[email protected]>
Co-authored-by: Stefan Probst <[email protected]>
Co-authored-by: Anna Stasiuk <[email protected]>
Co-authored-by: devisscher <[email protected]>
Co-authored-by: Alexander Trauzzi <[email protected]>
Co-authored-by: Ryan Florence <[email protected]>
Co-authored-by: Kristofer Selbekk <[email protected]>
Co-authored-by: Colin Taylor <[email protected]>
Co-authored-by: SmirnovW <[email protected]>
Co-authored-by: Cameron Matheson <[email protected]>
Co-authored-by: Kuirak <[email protected]>
Co-authored-by: Aaron Haaf <[email protected]>
Co-authored-by: Rouven Weßling <[email protected]>
Co-authored-by: Josh Tynjala <[email protected]>
Co-authored-by: devuxer <[email protected]>
Co-authored-by: David Baumgold <[email protected]>
Co-authored-by: Eric Taylor <[email protected]>
Co-authored-by: rubenmoya <[email protected]>
Co-authored-by: Christophe Coevoet <[email protected]>
Co-authored-by: Blaine Kasten <[email protected]>
Co-authored-by: Mae Capozzi <[email protected]>
Co-authored-by: Kai Hao <[email protected]>
Co-authored-by: Stefano Magni <[email protected]>
Co-authored-by: Johnny Zabala <[email protected]>
Co-authored-by: chancestrickland <[email protected]>
Co-authored-by: Chance Strickland <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex Rohleder <[email protected]>
Co-authored-by: Corentin Ardeois <[email protected]>
Co-authored-by: ray hatfield <[email protected]>
Co-authored-by: Maksim <[email protected]>
Co-authored-by: VariableVasas <[email protected]>
Co-authored-by: Sudhir Mitharwal <[email protected]>
Co-authored-by: Dan Dascalescu <[email protected]>
Co-authored-by: Amr Salama <[email protected]>
Co-authored-by: Sveta Slepner <[email protected]>
  • Loading branch information
Show file tree
Hide file tree
Showing 38 changed files with 6,370 additions and 3,789 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ language: node_js
node_js:
- "8"
- "10"

script:
- yarn lint
- yarn test

branches:
only:
- master
cache: yarn
cache: yarn
192 changes: 192 additions & 0 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
// Type definitions for @reach/router 1.3
// Project: https://github.com/reach/router
// Definitions by: Kingdaro <https://github.com/kingdaro>,
// A.Mokhtar <https://github.com/xMokAx>,
// Awwit <https://github.com/awwit>
// wroughtec <https://github.com/wroughtec>
// O.Jackman <https://github.com/chilledoj>
// Eyas <https://github.com/Eyas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8

import * as React from "react";
import { Location as HLocation, LocationState } from "history";
export type WindowLocation<S = LocationState> = Window["location"] &
HLocation<S>;

export type HistoryActionType = "PUSH" | "POP";
export type HistoryLocation = WindowLocation & { state?: any };
export interface HistoryListenerParameter {
location: HistoryLocation;
action: HistoryActionType;
}
export type HistoryListener = (parameter: HistoryListenerParameter) => void;
export type HistoryUnsubscribe = () => void;

export interface History {
readonly location: HistoryLocation;
readonly transitioning: boolean;
listen: (listener: HistoryListener) => HistoryUnsubscribe;
navigate: NavigateFn;
}

export class Router extends React.Component<
RouterProps & React.HTMLProps<HTMLDivElement>
> {}

export interface RouterProps {
basepath?: string;
primary?: boolean;
location?: WindowLocation;
component?: React.ComponentType | string;
}

export type RouteComponentProps<TParams = {}> = Partial<TParams> & {
path?: string;
default?: boolean;
location?: WindowLocation;
navigate?: NavigateFn;
uri?: string;
};

export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;

export type AnchorProps = Omit<
React.DetailedHTMLProps<
React.AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement
>,
"href" // remove href, as it's ignored by the router
>;

export interface LinkProps<TState> extends AnchorProps {
to: string;
replace?: boolean;
getProps?: (props: LinkGetProps) => {};
state?: TState;
/** @deprecated If using React >= 16.4, use ref instead. */
innerRef?: React.Ref<HTMLAnchorElement>;
}

export interface LinkGetProps {
isCurrent: boolean;
isPartiallyCurrent: boolean;
href: string;
location: WindowLocation;
}

export function Link<TState>(
// TODO: Define this as ...params: Parameters<Link<TState>> when only TypeScript >= 3.1 support is needed.
props: React.PropsWithoutRef<LinkProps<TState>> &
React.RefAttributes<HTMLAnchorElement>
): ReturnType<Link<TState>>;
export interface Link<TState>
extends React.ForwardRefExoticComponent<
React.PropsWithoutRef<LinkProps<TState>> &
React.RefAttributes<HTMLAnchorElement>
> {}

export interface RedirectProps<TState> {
from?: string;
to: string;
noThrow?: boolean;
state?: TState;
replace?: boolean;
}

export class Redirect<TState> extends React.Component<
RouteComponentProps<RedirectProps<TState>>
> {}

export interface MatchProps<TParams> {
path: string;
children: MatchRenderFn<TParams>;
}

export type MatchRenderFn<TParams> = (
props: MatchRenderProps<TParams>
) => React.ReactNode;

export interface MatchRenderProps<TParams> {
match: null | ({ uri: string; path: string } & TParams);
location: WindowLocation;
navigate: NavigateFn;
}

export class Match<TParams> extends React.Component<MatchProps<TParams>> {}

export interface NavigateFn {
(to: string, options?: NavigateOptions<{}>): Promise<void>;
(to: number): Promise<void>;
}

export interface NavigateOptions<TState> {
state?: TState;
replace?: boolean;
}

export interface LocationProps {
children: LocationProviderRenderFn;
}

export class Location extends React.Component<LocationProps> {}

export interface LocationProviderProps {
history?: History;
children?: React.ReactNode | LocationProviderRenderFn;
}

export type LocationProviderRenderFn = (
context: LocationContext
) => React.ReactNode;

export interface LocationContext {
location: WindowLocation;
navigate: NavigateFn;
}

export class LocationProvider extends React.Component<LocationProviderProps> {}

export interface ServerLocationProps {
url: string;
query: string;
}

export class ServerLocation extends React.Component<ServerLocationProps> {}

export const navigate: NavigateFn;

export interface HistorySource {
readonly location: WindowLocation;
addEventListener(name: string, listener: (event: Event) => void): void;
removeEventListener(name: string, listener: (event: Event) => void): void;
history: {
readonly state: any;
pushState(state: any, title: string, uri: string): void;
replaceState(state: any, title: string, uri: string): void;
};
}

export function createHistory(source: HistorySource): History;

export function createMemorySource(initialPath: string): HistorySource;

export interface RedirectRequest {
uri: string;
}

export function isRedirect(error: any): error is RedirectRequest;

export function redirectTo(uri: string): void;

export const globalHistory: History;

export function useLocation(): WindowLocation;

export function useNavigate(): NavigateFn;

export function useParams(): any;

export function useMatch(
pathname: string
): null | { uri: string; path: string; [param: string]: string };
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
## v1.3.4

- d7e4cfc Support forwarding url params with wildcard paths

## v1.3.3

_1.3.2 was a failed publish_

- 8b93694 Fix an encoding issue with browsers who do not encode urls
- d0962d7 Fix a bug on specific vendors that do not ship `location.pathname`
- 244e2bf Improve compatibility for `createMemorySource`

## v1.3.1

- f40ea53 Fix an accidental breaking change not exposing all location properties

## v1.3.0

- 56d4dca Added 4 new Hook APIs!
- `useLocation`
- `useParams`
- `useNavigate`
- `useMatch`
- 15298df Improved displayName for react context
- 11e9ed6 Fixed a bug that pushed to history when a user clicks the same path
- ccfc3c8 Added support for trailing wildcard names e.g., `path="/files/*filePath"`
- ad52cd3 Upgraded create-react-context to an MIT license compatible version
- 0a8af93 Fixed a bug with checking own property on locations
- 28a79e7 Fixed `search` not being prepended with a `?`
- 77fa233 Added displayName to Link

## v1.2.1

- 1f9f908 replace unstable_deferredUpdates with rAF
Expand Down
Loading

0 comments on commit 4676a04

Please sign in to comment.