Skip to content

Commit 8117ab2

Browse files
committed
chore: Update readme + docblock references
1 parent f5cb295 commit 8117ab2

File tree

7 files changed

+126
-133
lines changed

7 files changed

+126
-133
lines changed

.prettierignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
.travis.yml
21
package.json
32
package-lock.json

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
All development happens [on GitHub](https://github.com/ReactTraining/history). When [creating a pull request](https://help.github.com/articles/creating-a-pull-request/), please make sure that all of the following apply:
1+
All development happens [on GitHub](https://github.com/remix-run/history). When [creating a pull request](https://help.github.com/articles/creating-a-pull-request/), please make sure that all of the following apply:
22

33
- If you're adding a new feature or "fixing" a bug, please go into detail about your use case and why you think you need that feature or that bug fixed. This library has lots and lots of dependents, and we can't afford to make changes lightly without understanding why.
44
- The tests pass. The test suite will automatically run when you create the PR. All you need to do is wait a few minutes to see the result in the PR.

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1-
# history · [![npm package][npm-badge]][npm] [![Travis][build-badge]][build]
1+
# history · [![npm package][npm-badge]][npm]
22

33
[npm-badge]: https://img.shields.io/npm/v/history.svg?style=flat-square
44
[npm]: https://www.npmjs.org/package/history
5-
[build-badge]: https://img.shields.io/travis/ReactTraining/history/master.svg?style=flat-square
6-
[build]: https://travis-ci.org/ReactTraining/history
75

86
The history library lets you easily manage session history anywhere JavaScript runs. A `history` object abstracts away the differences in various environments and provides a minimal API that lets you manage the history stack, navigate, and persist state between sessions.
97

108
## Documentation
119

1210
Documentation for version 5 can be found in the [docs](docs) directory. This is the current stable release. Version 5 is used in React Router version 6.
1311

14-
Documentation for version 4 can be found [on the v4 branch](https://github.com/ReactTraining/history/tree/v4/docs). Version 4 is used in React Router versions 4 and 5.
12+
Documentation for version 4 can be found [on the v4 branch](https://github.com/remix-run/history/tree/v4/docs). Version 4 is used in React Router versions 4 and 5.
1513

1614
## Changes
1715

18-
To see the changes that were made in a given release, please lookup the tag on [the releases page](https://github.com/ReactTraining/history/releases).
16+
To see the changes that were made in a given release, please lookup the tag on [the releases page](https://github.com/remix-run/history/releases).
1917

20-
For changes released in version 4.6.3 and earlier, please see [the `CHANGES.md` file](https://github.com/ReactTraining/history/blob/845d690c5576c7f55ecbe14babe0092e8e5bc2bb/CHANGES.md).
18+
For changes released in version 4.6.3 and earlier, please see [the `CHANGES.md` file](https://github.com/remix-run/history/blob/845d690c5576c7f55ecbe14babe0092e8e5bc2bb/CHANGES.md).
2119

2220
## Development
2321

24-
Development of the current stable release, version 5, happens on [the `master` branch](https://github.com/ReactTraining/history/tree/master). Please keep in mind that this branch may include some work that has not yet been published as part of an official release. However, since `master` is always stable, you should feel free to build your own working release straight from master at any time.
22+
Development of the current stable release, version 5, happens on [the `main` branch](https://github.com/remix-run/history/tree/main). Please keep in mind that this branch may include some work that has not yet been published as part of an official release. However, since `main` is always stable, you should feel free to build your own working release straight from `main` at any time.
2523

2624
If you're interested in helping out, please read [our contributing guidelines](CONTRIBUTING.md).
2725

docs/api-reference.md

Lines changed: 67 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# history API Reference
44

5-
This is the API reference for [the history JavaScript library](https://github.com/ReactTraining/history).
5+
This is the API reference for [the history JavaScript library](https://github.com/remix-run/history).
66

77
The history library provides an API for tracking application history using [location](#location) objects that contain URLs and state. This reference includes type signatures and return values for the interfaces in the library. Please read the [getting started guide](getting-started.md) if you're looking for explanations about how to use the library to accomplish a specific task.
88

@@ -50,17 +50,17 @@ To prevent the location from changing, use [`history.block`](#history.block). Th
5050

5151
<a name="creating-hrefs"></a>
5252

53-
### Creating Hrefs
53+
### Creating `href` values
5454

5555
If you're building a link, you'll want to use [`history.createHref`](#history.createhref) to get a URL you can use as the value of `<a href>`.
5656

57-
----------
57+
---
5858

5959
<a name="reference"></a>
6060

6161
## Reference
6262

63-
The [source code](https://github.com/ReactTraining/history/tree/master/packages/history) for the history library is written in TypeScript, but it is compiled to JavaScript before publishing. Some of the function signatures in this reference include their TypeScript type annotations, but you can always refer to the original source as well.
63+
The [source code](https://github.com/remix-run/history/tree/main/packages/history) for the history library is written in TypeScript, but it is compiled to JavaScript before publishing. Some of the function signatures in this reference include their TypeScript type annotations, but you can always refer to the original source as well.
6464

6565
<a name="action"></a>
6666

@@ -77,27 +77,41 @@ See [the Getting Started guide](getting-started.md) for more information.
7777
<a name="createbrowserhistory"></a>
7878
<a name="browserhistory"></a>
7979

80-
### `createBrowserHistory`
80+
### `History`
81+
82+
A `History` object represents the shared interface for `BrowserHistory`, `HashHistory`, and `MemoryHistory`.
8183

8284
<details>
8385
<summary>Type declaration</summary>
8486

85-
```tsx
86-
declare createBrowserHistory({ window?: Window }): BrowserHistory;
87-
88-
interface BrowserHistory<S extends State = State> {
87+
```ts
88+
interface History {
8989
readonly action: Action;
90-
readonly location: Location<S>;
90+
readonly location: Location;
9191
createHref(to: To): string;
92-
push(to: To, state?: S): void;
93-
replace(to: To, state?: S): void;
94-
go(n: number): void;
92+
push(to: To, state?: any): void;
93+
replace(to: To, state?: any): void;
94+
go(delta: number): void;
9595
back(): void;
9696
forward(): void;
97-
listen(listener: Listener<S>): () => void;
98-
block(blocker: Blocker<S>): () => void;
97+
listen(listener: Listener): () => void;
98+
block(blocker: Blocker): () => void;
9999
}
100100
```
101+
102+
</details>
103+
104+
### `createBrowserHistory`
105+
106+
<details>
107+
<summary>Type declaration</summary>
108+
109+
```tsx
110+
function createBrowserHistory(options?: { window?: Window }): BrowserHistory;
111+
112+
interface BrowserHistory extends History {}
113+
```
114+
101115
</details>
102116

103117
A browser history object keeps track of the browsing history of an application using the browser's built-in history stack. It is designed to run in modern web browsers that support the HTML5 history interface including `pushState`, `replaceState`, and the `popstate` event.
@@ -121,15 +135,16 @@ See [the Getting Started guide](getting-started.md) for more information.
121135
<summary>Type declaration</summary>
122136

123137
```ts
124-
declare createPath(partialPath: PartialPath): string;
125-
declare parsePath(path: string): PartialPath;
138+
function createPath(partialPath: Partial<Path>): string;
139+
function parsePath(path: string): Partial<Path>;
126140

127-
interface PartialPath {
128-
pathname?: string;
129-
search?: string;
130-
hash?: string;
141+
interface Path {
142+
pathname: string;
143+
search: string;
144+
hash: string;
131145
}
132146
```
147+
133148
</details>
134149

135150
The `createPath` and `parsePath` functions are useful for creating and parsing URL paths.
@@ -148,21 +163,11 @@ parsePath('/login?next=home'); // { pathname: '/login', search: '?next=home' }
148163
<summary>Type declaration</summary>
149164

150165
```ts
151-
declare createHashHistory({ window?: Window }): HashHistory;
166+
createHashHistory({ window?: Window }): HashHistory;
152167

153-
interface HashHistory<S extends State = State> {
154-
readonly action: Action;
155-
readonly location: Location<S>;
156-
createHref(to: To): string;
157-
push(to: To, state?: S): void;
158-
replace(to: To, state?: S): void;
159-
go(n: number): void;
160-
back(): void;
161-
forward(): void;
162-
listen(listener: Listener<S>): () => void;
163-
block(blocker: Blocker<S>): () => void;
164-
}
168+
interface HashHistory extends History {}
165169
```
170+
166171
</details>
167172

168173
A hash history object keeps track of the browsing history of an application using the browser's built-in history stack. It is designed to be run in modern web browsers that support the HTML5 history interface including `pushState`, `replaceState`, and the `popstate` event.
@@ -187,27 +192,18 @@ See [the Getting Started guide](getting-started.md) for more information.
187192
<summary>Type declaration</summary>
188193

189194
```ts
190-
declare createMemoryHistory({
195+
function createMemoryHistory({
191196
initialEntries?: InitialEntry[],
192197
initialIndex?: number
193198
}): MemoryHistory;
194199

195-
type InitialEntry = string | PartialLocation;
200+
type InitialEntry = string | Partial<Location>;
196201

197-
interface MemoryHistory<S extends State = State> {
202+
interface MemoryHistory extends History {
198203
readonly index: number;
199-
readonly action: Action;
200-
readonly location: Location<S>;
201-
createHref(to: To): string;
202-
push(to: To, state?: S): void;
203-
replace(to: To, state?: S): void;
204-
go(n: number): void;
205-
back(): void;
206-
forward(): void;
207-
listen(listener: Listener<S>): () => void;
208-
block(blocker: Blocker<S>): () => void;
209204
}
210205
```
206+
211207
</details>
212208

213209
A memory history object keeps track of the browsing history of an application using an internal array. This makes it ideal in situations where you need complete control over the history stack, like React Native and tests.
@@ -249,16 +245,17 @@ See [the Navigation guide](navigation.md) for more information.
249245
<summary>Type declaration</summary>
250246

251247
```ts
252-
interface Blocker<S extends State = State> {
253-
(tx: Transition<S>): void;
248+
interface Blocker {
249+
(tx: Transition): void;
254250
}
255251

256-
interface Transition<S extends State = State> {
252+
interface Transition {
257253
action: Action;
258-
location: Location<S>;
254+
location: Location;
259255
retry(): void;
260256
}
261257
```
258+
262259
</details>
263260

264261
Prevents changes to the history stack from happening. This is useful when you want to prevent the user navigating away from the current page, for example when they have some unsaved data on the current page.
@@ -316,15 +313,16 @@ The current index in the history stack.
316313
<summary>Type declaration</summary>
317314

318315
```ts
319-
interface Listener<S extends State = State> {
320-
(update: Update<S>): void;
316+
interface Listener {
317+
(update: Update): void;
321318
}
322319

323-
interface Update<S extends State = State> {
320+
interface Update {
324321
action: Action;
325-
location: Location<S>;
322+
location: Location;
326323
}
327324
```
325+
328326
</details>
329327

330328
Starts listening for location changes and calls the given callback with an `Update` when it does.
@@ -351,15 +349,15 @@ Also see [`history.listen`](#history.listen).
351349

352350
<a name="history.push"></a>
353351

354-
### `history.push(to: To, state?: State)`
352+
### `history.push(to: To, state?: any)`
355353

356354
Pushes a new entry onto the stack.
357355

358356
See [the Navigation guide](navigation.md) for more information.
359357

360358
<a name="history.replace"></a>
361359

362-
### `history.replace(to: To, state?: State)`
360+
### `history.replace(to: To, state?: any)`
363361

364362
Replaces the current entry in the stack with a new one.
365363

@@ -373,14 +371,15 @@ See [the Navigation guide](navigation.md) for more information.
373371
<summary>Type declaration</summary>
374372

375373
```ts
376-
interface Location<S extends State = State> {
374+
interface Location {
377375
pathname: string;
378376
search: string;
379377
hash: string;
380-
state: S;
378+
state: unknown;
381379
key: string;
382380
}
383381
```
382+
384383
</details>
385384

386385
A `location` is a particular entry in the history stack, usually analogous to a "page" or "screen" in your app. As the user clicks on links and moves around the app, the current location changes.
@@ -433,15 +432,7 @@ This can be useful in situations where you need to keep track of 2 different sta
433432

434433
### State
435434

436-
<details>
437-
<summary>Type declaration</summary>
438-
439-
```ts
440-
type State = object | null;
441-
```
442-
</details>
443-
444-
A [`State`](https://github.com/ReactTraining/history/blob/0f992736/packages/history/index.ts#L61) value is an object of extra information that is associated with a [`Location`](#location) but that does not appear in the URL. This value is always associated with that location.
435+
A `State` value is an arbitrary value that holds extra information associated with a [`Location`](#location) but does not appear in the URL. This value is always associated with that location.
445436

446437
See [the Navigation guide](navigation.md) for more information.
447438

@@ -453,16 +444,17 @@ See [the Navigation guide](navigation.md) for more information.
453444
<summary>Type declaration</summary>
454445

455446
```ts
456-
type To = string | PartialPath;
447+
type To = string | Partial<Path>;
457448

458-
interface PartialPath {
459-
pathname?: string;
460-
search?: string;
461-
hash?: string;
449+
interface Path {
450+
pathname: string;
451+
search: string;
452+
hash: string;
462453
}
463454
```
455+
464456
</details>
465457

466-
A [`To`](https://github.com/ReactTraining/history/blob/0f992736/packages/history/index.ts#L212) value represents a destination location, but doesn't contain all the information that a normal [`location`](#location) object does. It is primarily used as the first argument to [`history.push`](#history.push) and [`history.replace`](#history.replace).
458+
A [`To`](https://github.com/remix-run/history/blob/main/packages/history/index.ts#L178) value represents a destination location, but doesn't contain all the information that a normal [`location`](#location) object does. It is primarily used as the first argument to [`history.push`](#history.push) and [`history.replace`](#history.replace).
467459

468-
See [the Navigation guide](navigation.md) for more information.
460+
See [the Navigation guide](navigation.md) for more information.

0 commit comments

Comments
 (0)