Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

boring-router-react

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boring-router-react - npm Package Compare versions

Comparing version 0.3.0-alpha.43 to 0.3.0-alpha.44

115

bld/library/browser-history.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const boring_router_1 = require("boring-router");

@@ -11,3 +10,3 @@ class BrowserHistory extends boring_router_1.AbstractHistory {

this.lastUsedId = 0;
this.onPopState = (event) => tslib_1.__awaiter(this, void 0, void 0, function* () {
this.onPopState = async (event) => {
let { entries: trackedEntries } = this.tracked;

@@ -39,3 +38,3 @@ let { id, data } = event.state;

this.emitChange(snapshot);
});
};
this.prefix = prefix;

@@ -92,71 +91,59 @@ this.hash = hash;

}
back() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
yield this.restoringPromise;
history.back();
});
async back() {
await this.restoringPromise;
history.back();
}
forward() {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
yield this.restoringPromise;
history.forward();
});
async forward() {
await this.restoringPromise;
history.forward();
}
push(ref, data) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
if (ref === this.ref) {
return this.replace(ref, data);
}
yield this.restoringPromise;
let snapshot = this.pushEntry({
id: this.getNextId(),
ref,
data,
});
console.debug('push', snapshot);
this.snapshot = snapshot;
this.emitChange(snapshot);
async push(ref, data) {
if (ref === this.ref) {
return this.replace(ref, data);
}
await this.restoringPromise;
let snapshot = this.pushEntry({
id: this.getNextId(),
ref,
data,
});
console.debug('push', snapshot);
this.snapshot = snapshot;
this.emitChange(snapshot);
}
replace(ref, data) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
yield this.restoringPromise;
let { active: id } = this.tracked;
let snapshot = this.replaceEntry({
id,
ref,
data,
});
console.debug('replace', snapshot);
this.snapshot = snapshot;
this.emitChange(snapshot);
async replace(ref, data) {
await this.restoringPromise;
let { active: id } = this.tracked;
let snapshot = this.replaceEntry({
id,
ref,
data,
});
console.debug('replace', snapshot);
this.snapshot = snapshot;
this.emitChange(snapshot);
}
restore(snapshot) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
console.debug('restore', snapshot);
this.snapshot = snapshot;
if (this.restoring) {
return;
}
console.debug('restore start');
this.restoring = true;
let promise = new Promise(resolve => {
this.restoringPromiseResolver = resolve;
});
this.restoringPromise = promise;
this.stepRestoration();
yield promise;
async restore(snapshot) {
console.debug('restore', snapshot);
this.snapshot = snapshot;
if (this.restoring) {
return;
}
console.debug('restore start');
this.restoring = true;
let promise = new Promise(resolve => {
this.restoringPromiseResolver = resolve;
});
this.restoringPromise = promise;
this.stepRestoration();
await promise;
}
navigate(href) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
let prefix = this.prefix;
if (/^[\w\d]+:\/\//.test(href) || !href.startsWith(prefix)) {
location.href = href;
return;
}
let ref = href.slice(prefix.length);
yield this.push(ref);
});
async navigate(href) {
let prefix = this.prefix;
if (/^[\w\d]+:\/\//.test(href) || !href.startsWith(prefix)) {
location.href = href;
return;
}
let ref = href.slice(prefix.length);
await this.push(ref);
}

@@ -163,0 +150,0 @@ stepRestoration() {

@@ -33,3 +33,3 @@ "use strict";

try {
return to.$router.$(to, params).$href();
return to.$href(params);
}

@@ -41,3 +41,3 @@ catch (error) {

render() {
let _a = this.props, { className, to, params, replace, toggle, onClick } = _a, props = tslib_1.__rest(_a, ["className", "to", "params", "replace", "toggle", "onClick"]);
let { className, to, params, replace, toggle, onClick, ...props } = this.props;
return (react_1.default.createElement("a", Object.assign({ className: className, href: this.href, onClick: _utils_1.composeEventHandler([onClick, this.onClick], true) }, props)));

@@ -44,0 +44,0 @@ }

@@ -10,3 +10,3 @@ "use strict";

render() {
let _a = this.props, { className, activeClassName = 'active', exact } = _a, props = tslib_1.__rest(_a, ["className", "activeClassName", "exact"]);
let { className, activeClassName = 'active', exact, ...props } = this.props;
let { to } = props;

@@ -13,0 +13,0 @@ let matched = exact ? to.$exact : to.$matched;

{
"name": "boring-router-react",
"version": "0.3.0-alpha.43",
"version": "0.3.0-alpha.44",
"description": "A light-weight, type-safe, yet reactive router service using MobX.",

@@ -23,3 +23,4 @@ "repository": {

"src/library/**/*.ts",
"bld/library"
"bld/library",
"!*.tsbuildinfo"
],

@@ -42,3 +43,3 @@ "peerDependencies": {

},
"gitHead": "ec1c0ef3bf5fb384d5c4781e5873a34c7ce780fd"
"gitHead": "d89a558134a3713e2fcc34483cb1fd21bf908aa1"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc