Comparing version 0.0.9 to 0.0.10
@@ -0,0 +0,0 @@ import { IRouteTransitionRedirectOptions } from "./types"; |
@@ -0,0 +0,0 @@ "use strict"; |
import { IHistory, IHistoryNavigateEvent } from "../types"; | ||
export declare class BrowserHistory implements IHistory { | ||
private started; | ||
private onNavigate; | ||
currentPath: string; | ||
readonly currentPath: string; | ||
constructor(onNavigate: IHistoryNavigateEvent); | ||
private navigate(e, path?); | ||
setPath(path: string, replace: boolean): void; | ||
goBack(): void; | ||
goForward(): void; | ||
start(): void; | ||
stop(): void; | ||
} |
@@ -5,12 +5,37 @@ "use strict"; | ||
this.onNavigate = onNavigate; | ||
throw new Error("Not implemented"); | ||
} | ||
Object.defineProperty(BrowserHistory.prototype, "currentPath", { | ||
get: function () { | ||
return location.pathname; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
BrowserHistory.prototype.navigate = function (e, path) { | ||
this.onNavigate(path || this.currentPath); | ||
}; | ||
BrowserHistory.prototype.setPath = function (path, replace) { | ||
if (replace) { | ||
history.pushState(null, null, path); | ||
} | ||
else { | ||
history.replaceState(null, null, path); | ||
} | ||
}; | ||
BrowserHistory.prototype.goBack = function () { | ||
history.back(); | ||
}; | ||
BrowserHistory.prototype.goForward = function () { | ||
history.forward(); | ||
}; | ||
BrowserHistory.prototype.start = function () { | ||
this.started = true; | ||
addEventListener("popstate", this.navigate, false); | ||
}; | ||
BrowserHistory.prototype.stop = function () { | ||
this.started = false; | ||
removeEventListener("popstate", this.navigate, false); | ||
}; | ||
return BrowserHistory; | ||
}()); | ||
exports.BrowserHistory = BrowserHistory; |
import { IHistory, IHistoryNavigateEvent } from "../types"; | ||
export declare class HashHistory implements IHistory { | ||
private started; | ||
private onNavigate; | ||
currentPath: string; | ||
readonly currentPath: string; | ||
constructor(onNavigate: IHistoryNavigateEvent); | ||
private navigate(e, path?); | ||
setPath(path: string, replace: boolean): void; | ||
goBack(): void; | ||
goForward(): void; | ||
start(): void; | ||
stop(): void; | ||
} |
@@ -5,12 +5,40 @@ "use strict"; | ||
this.onNavigate = onNavigate; | ||
throw new Error("Not implemented"); | ||
} | ||
Object.defineProperty(HashHistory.prototype, "currentPath", { | ||
get: function () { | ||
return location.pathname; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
HashHistory.prototype.navigate = function (e, path) { | ||
if (this.started) { | ||
this.onNavigate(path || this.currentPath); | ||
} | ||
}; | ||
HashHistory.prototype.setPath = function (path, replace) { | ||
if (replace) { | ||
var href = location.href.replace(/#.*$/, ""); | ||
location.replace(href + "#" + path); | ||
} | ||
else { | ||
window.location.hash = "#" + path; | ||
} | ||
}; | ||
HashHistory.prototype.goBack = function () { | ||
history.back(); | ||
}; | ||
HashHistory.prototype.goForward = function () { | ||
history.forward(); | ||
}; | ||
HashHistory.prototype.start = function () { | ||
this.started = true; | ||
addEventListener("hashchange", this.navigate, false); | ||
}; | ||
HashHistory.prototype.stop = function () { | ||
this.started = false; | ||
removeEventListener("hashchange", this.navigate, false); | ||
}; | ||
return HashHistory; | ||
}()); | ||
exports.HashHistory = HashHistory; |
@@ -11,2 +11,4 @@ import { IHistory, IHistoryNavigateEvent } from "../types"; | ||
goForward(): void; | ||
start(): void; | ||
stop(): void; | ||
} |
@@ -48,4 +48,8 @@ "use strict"; | ||
}; | ||
VirtualHistory.prototype.start = function () { | ||
}; | ||
VirtualHistory.prototype.stop = function () { | ||
}; | ||
return VirtualHistory; | ||
}()); | ||
exports.VirtualHistory = VirtualHistory; |
@@ -0,0 +0,0 @@ import { IRouteTemplate, IRouteMapper, IRouteParser, IRouteResolver, IRouteConstructable, MappingFunction } from "./types"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IRouteParser, IRouteParseResult } from "./types"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IRoute, IRouteParameters, IRouteInfo, IRouteTransitionPromiseResult, IRouteCancelableTransitionPromiseResult } from "./types"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IRouter, IRoute, IRouteTemplate, RouterContext, MappingFunction, IRouterOptions, IRouterNavigateOptions } from "./types"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { IRoute, ITransitor, TransitionConflictStrategy, ITransition } from "./types"; |
@@ -92,3 +92,3 @@ "use strict"; | ||
this.newRoute.onCancelEnterTransition(reason); | ||
this._promiseResolve(reason); | ||
this._promiseReject(reason); | ||
}; | ||
@@ -218,4 +218,6 @@ Transition.prototype.interceptTransition = function (transitionResult) { | ||
if (this.conflictStrategy !== "notransition") { | ||
transition.promise.then(function () { | ||
_this._currentRoute = transition.newRoute; | ||
transition.promise.then(function (cancelReason) { | ||
if (!cancelReason) { | ||
_this._currentRoute = transition.newRoute; | ||
} | ||
_this.transitionsQueue[0] = undefined; | ||
@@ -222,0 +224,0 @@ }); |
@@ -120,2 +120,4 @@ /** | ||
goForward(): void; | ||
start(): void; | ||
stop(): void; | ||
} |
@@ -0,0 +0,0 @@ /* Router */ |
export declare function normalizePath(path: string): string; |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "steersman", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Lightweight JS router for browsers & node", | ||
@@ -5,0 +5,0 @@ "main": "lib/Router.js", |
@@ -0,0 +0,0 @@ # Steersman |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
103240
37
962