New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

history-manager

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

history-manager - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

4

CHANGELOG.md
# Changelog
All notable changes to this project will be documented in this file.
## [1.3.0] - 2021-03-11
- add possibility to avoid auto href management (can skip context definition)
- fix bug in HistoryManager::go
## [1.2.1] - 2021-01-31

@@ -5,0 +9,0 @@ - fix NavigationLock.unlock not having instant effect

14

package.json
{
"name": "history-manager",
"version": "1.2.1",
"version": "1.3.0",
"description": "",
"dependencies": {
"path-to-regexp": "^6.2.0",
"query-string": "^6.13.8"
"query-string": "^6.14.1"
},
"devDependencies": {
"@riotjs/compiler": "^5.2.0",
"@riotjs/compiler": "^5.3.1",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.1.1",
"@rollup/plugin-typescript": "^8.1.1",
"rollup": "^2.38.2",
"@rollup/plugin-node-resolve": "^11.2.0",
"@rollup/plugin-typescript": "^8.2.0",
"rollup": "^2.41.1",
"tslib": "^2.1.0",
"typescript": "^4.1.3"
"typescript": "^4.2.3"
},

@@ -18,0 +18,0 @@ "scripts": {},

@@ -11,3 +11,14 @@ /**

let started: boolean = false;
let historyManaged: boolean | null = null;
export function setAutoManagement(value: boolean): void {
if (started) {
throw new Error("HistoryManager already started");
}
historyManaged = !!value;
}
export function getAutoManagement(): boolean {
return historyManaged || false;
}
export interface IWork {

@@ -193,2 +204,5 @@ finish(): void;

}): void {
if (historyManaged === null) {
historyManaged = true;
}
return contextManager.setContext(context);

@@ -198,5 +212,11 @@ }

export function addContextPath(context: string, href: string, isFallback: boolean = false): RegExp {
if (historyManaged === null) {
historyManaged = true;
}
return contextManager.addContextPath(context, href, isFallback);
}
export function setContextDefaultHref(context: string, href: string): void {
if (historyManaged === null) {
historyManaged = true;
}
return contextManager.setContextDefaultHref(context, href);

@@ -216,2 +236,5 @@ }

export function getHREFs(): string[] {
if (!historyManaged) {
throw new Error("can't keep track of hrefs without history management");
}
return contextManager.hrefs();

@@ -237,2 +260,5 @@ }

export function restore(context: string): Promise<void> {
if (!historyManaged) {
throw new Error("can't restore a context without history management");
}
let locksFinished: number = tryUnlock();

@@ -327,3 +353,3 @@ if (locksFinished === -1) {

if (direction === 0) {
throw new Error("direction must be different than 0");
return Promise.resolve();
}

@@ -340,6 +366,14 @@ direction = parseInt(direction as any, 10) + locksFinished;

onWorkFinished(() => {
let index: number = contextManager.index() + direction;
if (index < 0 || index >= contextManager.length()) {
return onlanded();
if (historyManaged === false) {
window.history.go(direction);
promiseResolve();
return;
}
const contextIndex: number = contextManager.index();
let index: number = Math.max(0, Math.min(contextManager.length() - 1, contextIndex + direction));
if (contextIndex === index) {
onlanded();
promiseResolve();
return;
}
workToRelease = createWork();

@@ -358,27 +392,41 @@ onWorkFinished(promiseResolve);

export function start(fallbackContext: string | null = contextManager.getContextNames()[0]): Promise<void> {
export function start(fallbackContext: string | null): Promise<void> {
if (historyManaged === null) {
historyManaged = false;
}
fallbackContext = historyManaged ?
(fallbackContext === void 0 ? contextManager.getContextNames()[0] : fallbackContext)
: null
;
let href: string = URLManager.get();
let context: string | null = contextManager.contextOf(href, false);
let promiseResolve: () => void;
const promise: Promise<void> = new Promise<void>(resolve => { promiseResolve = resolve; });
if (context == null) {
if (!fallbackContext) {
throw new Error("must define a fallback context");
let promiseReject: () => void;
const promise: Promise<void> = new Promise<void>((resolve, reject) => {
promiseResolve = resolve; promiseReject = reject;
});
if (historyManaged) {
let context: string | null = contextManager.contextOf(href, false);
if (context == null) {
if (!fallbackContext) {
throw new Error("must define a fallback context");
}
let defaultHREF: string | null = contextManager.getDefaultOf(fallbackContext);
if (defaultHREF == null) {
throw new Error("must define a default href for the fallback context");
}
started = true;
href = defaultHREF;
workToRelease = createWork();
onCatchPopState(() => { onlanded(); promiseResolve(); }, true);
goTo(defaultHREF, true);
}
let defaultHREF: string | null = contextManager.getDefaultOf(fallbackContext);
if (defaultHREF == null) {
throw new Error("must define a default href for the fallback context");
contextManager.insert(href);
if (context == null) {
promiseReject!();
return promise;
}
started = true;
href = defaultHREF;
workToRelease = createWork();
onCatchPopState(() => { onlanded(); promiseResolve(); }, true);
goTo(defaultHREF, true);
}
contextManager.insert(href);
if (context != null) {
started = true;
onlanded();
promiseResolve!();
}
started = true;
onlanded();
promiseResolve!();
return promise;

@@ -397,3 +445,6 @@ }

function handlePopState(): void {
let options: OptionsManager.Options = OptionsManager.get();
let options: OptionsManager.Options = {
...OptionsManager.get(),
...(historyManaged ? {} : { front: undefined, back: undefined })
};
if (options.locked) {

@@ -475,3 +526,3 @@ onCatchPopState(() => {

let backHref: string = contextManager.get()!;
if (href === backHref) {
if (href === backHref || !historyManaged) {
return onlanded();

@@ -478,0 +529,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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