forked from remix-run/history
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
176 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<base href="/the/base" /> | ||
<script> | ||
window.addEventListener('hashchange', () => { | ||
console.log('hashchange', window.location.hash); | ||
}); | ||
|
||
function handleClick(link) { | ||
const href = link.getAttribute('href'); | ||
history.pushState(null, null, href); | ||
return false; // preventDefault | ||
} | ||
</script> | ||
</head> | ||
<body> | ||
<a href="/hash-click">home</a> | ||
<a href="/hash-click#one">#one</a> | ||
<a href="/hash-click#one" onclick="return handleClick(this)" | ||
>#one w pushState</a | ||
> | ||
<a href="/hash-click#two">#two</a> | ||
<a href="/hash-click#two" onclick="return handleClick(this)" | ||
>#two w pushState</a | ||
> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script> | ||
console.log(window.history.length); | ||
</script> | ||
</head> | ||
<body> | ||
<a href="/hash-history-length">home</a> | ||
<a href="/hash-history-length#one">#one</a> | ||
<a href="/hash-history-length#two">#two</a> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<!doctype html> | ||
<html> | ||
<body> | ||
<script type="module"> | ||
import { createBrowserHistory } from 'https://unpkg.com/history@next/history.production.min.js'; | ||
let history = createBrowserHistory(); | ||
console.log(history); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"name": "history-packages", | ||
"private": true, | ||
"scripts": { | ||
"build": "node ./scripts/build.js", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { History } from 'history'; | ||
|
||
declare const _default: History; | ||
|
||
export default _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { History } from 'history'; | ||
|
||
declare const _default: History; | ||
|
||
export default _default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
export type Action = "POP" | "PUSH" | "REPLACE"; | ||
|
||
export type Path = string; | ||
export type PathPieces = { | ||
pathname?: string; | ||
search?: string; | ||
hash?: string; | ||
}; | ||
|
||
export type State = object; | ||
export interface Location<S extends State = State> extends PathPieces { | ||
pathname: string; | ||
search: string; | ||
hash: string; | ||
state?: S; | ||
key?: string; | ||
} | ||
|
||
export interface Update<S extends State = State> { | ||
action: Action; | ||
location: Location<S>; | ||
} | ||
export interface Listener<S extends State = State> { | ||
(update: Update<S>): void; | ||
} | ||
export type Unlistener = () => void; | ||
|
||
export interface Transaction<S extends State = State> extends Update { | ||
retry(): void; | ||
} | ||
export interface Blocker<S extends State = State> { | ||
(tx: Transaction<S>): void; | ||
} | ||
export type Unblocker = () => void; | ||
|
||
export interface History<S extends State = State> { | ||
action: Action; | ||
location: Location<S>; | ||
createHref(to: Path | PathPieces): string; | ||
push(to: Path | PathPieces, state?: State): void; | ||
replace(to: Path | PathPieces, state?: State): void; | ||
go(n: number): void; | ||
back(): void; | ||
forward(): void; | ||
listen(listener: Listener<S>): Unlistener; | ||
block(blocker: Blocker<S>): Unblocker; | ||
} | ||
export interface MemoryHistory<S extends State = State> extends History<S> { | ||
index: number; | ||
} | ||
|
||
export function createBrowserHistory(options?: { window?: Window }): History; | ||
export function createHashHistory(options?: { window?: Window }): History; | ||
|
||
type InitialEntry = Path | PathPieces; | ||
export function createMemoryHistory(options?: { | ||
initialEntries?: InitialEntry[]; | ||
initialIndex?: number; | ||
}): MemoryHistory; | ||
|
||
export function createPath(pieces: PathPieces): Path; | ||
export function parsePath(path: Path): PathPieces; |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters