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

history-extra

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

history-extra - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

7

CHANGELOG.md
### Changelog
#### 4.0.0 (14 November 2018)
#### [v4.0.1](https://github.com/w33ble/history-extra/compare/v4.0.0...v4.0.1) (14 November 2018)
- fix: use default exports in src [`8bca3b2`](https://github.com/w33ble/history-extra/commit/8bca3b22bde7366ca1fac65bc2c1c6eaf750faf6)
- fix: point to correct dist for main [`6216d9d`](https://github.com/w33ble/history-extra/commit/6216d9db7f3b6ba3967d3da984f564ddd1492733)
- feat: expose esm as module [`a67297b`](https://github.com/w33ble/history-extra/commit/a67297bfe2e3db7f2efed50c56c57a363bb2ba30)
#### v4.0.0 (14 November 2018)
- docs: update readme [`8380de1`](https://github.com/w33ble/history-extra/commit/8380de1d458e0f152600bad8bf67bba2fc23dea1)

@@ -5,0 +10,0 @@ - feat: add history state to replace [`5bcf6fc`](https://github.com/w33ble/history-extra/commit/5bcf6fc1d40e670b91ca75581c26a7fae5b6c4cf)

75

dist/createHashStateHistory.js
/*
* history-extra version 4.0.0
* history-extra version 4.0.1
*

@@ -31,7 +31,24 @@ * The MIT License (MIT)

(global.history = factory(global.LocationUtils,global.PathUtils,global.createTransitionManager,global.DOMUtils));
}(this, (function (LocationUtils,PathUtils,createTransitionManager,DOMUtils) { 'use strict';
}(this, (function (locationUtils,PathUtils,createTransitionManager,DOMUtils) { 'use strict';
locationUtils = locationUtils && locationUtils.hasOwnProperty('default') ? locationUtils['default'] : locationUtils;
PathUtils = PathUtils && PathUtils.hasOwnProperty('default') ? PathUtils['default'] : PathUtils;
createTransitionManager = createTransitionManager && createTransitionManager.hasOwnProperty('default') ? createTransitionManager['default'] : createTransitionManager;
DOMUtils = DOMUtils && DOMUtils.hasOwnProperty('default') ? DOMUtils['default'] : DOMUtils;
/* eslint no-use-before-define: 0 */
var createLocation = locationUtils.createLocation,
locationsAreEqual = locationUtils.locationsAreEqual;
var addLeadingSlash = PathUtils.addLeadingSlash,
stripLeadingSlash = PathUtils.stripLeadingSlash,
stripTrailingSlash = PathUtils.stripTrailingSlash,
hasBasename = PathUtils.hasBasename,
stripBasename = PathUtils.stripBasename,
createPath = PathUtils.createPath;
var canUseDOM = DOMUtils.canUseDOM,
addEventListener = DOMUtils.addEventListener,
removeEventListener = DOMUtils.removeEventListener,
getConfirmation = DOMUtils.getConfirmation,
supportsGoWithoutReloadUsingHash = DOMUtils.supportsGoWithoutReloadUsingHash,
supportsHistory = DOMUtils.supportsHistory;

@@ -64,3 +81,3 @@ function warning(condition, message) {

encodePath: function encodePath(path) {
return path.charAt(0) === '!' ? path : "!/".concat(PathUtils.stripLeadingSlash(path));
return path.charAt(0) === '!' ? path : "!/".concat(stripLeadingSlash(path));
},

@@ -72,8 +89,8 @@ decodePath: function decodePath(path) {

noslash: {
encodePath: PathUtils.stripLeadingSlash,
decodePath: PathUtils.addLeadingSlash
encodePath: stripLeadingSlash,
decodePath: addLeadingSlash
},
slash: {
encodePath: PathUtils.addLeadingSlash,
decodePath: PathUtils.addLeadingSlash
encodePath: addLeadingSlash,
decodePath: addLeadingSlash
}

@@ -101,8 +118,8 @@ };

var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
invariant(DOMUtils.canUseDOM, 'Hash history needs a DOM');
invariant(canUseDOM, 'Hash history needs a DOM');
var globalHistory = window.history;
var canGoWithoutReload = DOMUtils.supportsGoWithoutReloadUsingHash();
var canUseHistory = DOMUtils.supportsHistory();
var canGoWithoutReload = supportsGoWithoutReloadUsingHash();
var canUseHistory = supportsHistory();
var _props$getUserConfirm = props.getUserConfirmation,
getUserConfirmation = _props$getUserConfirm === void 0 ? DOMUtils.getConfirmation : _props$getUserConfirm,
getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
_props$hashType = props.hashType,

@@ -112,3 +129,3 @@ hashType = _props$hashType === void 0 ? 'slash' : _props$hashType,

keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
var basename = props.basename ? PathUtils.stripTrailingSlash(PathUtils.addLeadingSlash(props.basename)) : '';
var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
var _HashPathCoders$hashT = HashPathCoders[hashType],

@@ -124,5 +141,5 @@ encodePath = _HashPathCoders$hashT.encodePath,

var path = decodePath(getHashPath());
warning(!basename || PathUtils.hasBasename(path, basename), "".concat('You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "').concat(path, "\" to begin with \"").concat(basename, "\"."));
if (basename) path = PathUtils.stripBasename(path, basename);
return LocationUtils.createLocation(path, state, key);
warning(!basename || hasBasename(path, basename), "".concat('You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "').concat(path, "\" to begin with \"").concat(basename, "\"."));
if (basename) path = stripBasename(path, basename);
return createLocation(path, state, key);
};

@@ -155,5 +172,5 @@

var prevLocation = history.location;
if (!forceNextPop && LocationUtils.locationsAreEqual(prevLocation, location)) return; // A hashchange doesn't always == location change.
if (!forceNextPop && locationsAreEqual(prevLocation, location)) return; // A hashchange doesn't always == location change.
if (ignorePath === PathUtils.createPath(location)) return; // Ignore this change; we already setState in push/replace.
if (ignorePath === createPath(location)) return; // Ignore this change; we already setState in push/replace.

@@ -189,5 +206,5 @@ ignorePath = null;

var toIndex = allPaths.lastIndexOf(PathUtils.createPath(toLocation));
var toIndex = allPaths.lastIndexOf(createPath(toLocation));
if (toIndex === -1) toIndex = 0;
var fromIndex = allPaths.lastIndexOf(PathUtils.createPath(fromLocation));
var fromIndex = allPaths.lastIndexOf(createPath(fromLocation));
if (fromIndex === -1) fromIndex = 0;

@@ -207,6 +224,6 @@ var delta = toIndex - fromIndex;

var initialLocation = getDOMLocation();
var allPaths = [PathUtils.createPath(initialLocation)]; // Public interface
var allPaths = [createPath(initialLocation)]; // Public interface
var createHref = function createHref(location) {
return "#".concat(encodePath(basename + PathUtils.createPath(location)));
return "#".concat(encodePath(basename + createPath(location)));
}; // eslint-disable-next-line no-shadow

@@ -217,7 +234,7 @@

var action = 'PUSH';
var location = LocationUtils.createLocation(path, state, createKey(), history.location);
var location = createLocation(path, state, createKey(), history.location);
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
if (!ok) return; // eslint-disable-next-line no-shadow
var path = PathUtils.createPath(location); // eslint-disable-next-line no-shadow
var path = createPath(location); // eslint-disable-next-line no-shadow

@@ -247,3 +264,3 @@ var encodedPath = encodePath(basename + path);

var prevIndex = allPaths.lastIndexOf(PathUtils.createPath(history.location));
var prevIndex = allPaths.lastIndexOf(createPath(history.location));
var nextPaths = allPaths.slice(0, prevIndex === -1 ? 0 : prevIndex + 1);

@@ -266,7 +283,7 @@ nextPaths.push(path);

var action = 'REPLACE';
var location = LocationUtils.createLocation(path, state, createKey(), history.location);
var location = createLocation(path, state, createKey(), history.location);
transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
if (!ok) return; // eslint-disable-next-line no-shadow
var path = PathUtils.createPath(location); // eslint-disable-next-line no-shadow
var path = createPath(location); // eslint-disable-next-line no-shadow

@@ -297,3 +314,3 @@ var encodedPath = encodePath(basename + path);

var prevIndex = allPaths.indexOf(PathUtils.createPath(history.location));
var prevIndex = allPaths.indexOf(createPath(history.location));
if (prevIndex !== -1) allPaths[prevIndex] = path;

@@ -326,5 +343,5 @@ setState({

if (listenerCount === 1) {
DOMUtils.addEventListener(window, HashChangeEvent, handleHashChange);
addEventListener(window, HashChangeEvent, handleHashChange);
} else if (listenerCount === 0) {
DOMUtils.removeEventListener(window, HashChangeEvent, handleHashChange);
removeEventListener(window, HashChangeEvent, handleHashChange);
}

@@ -331,0 +348,0 @@ };

{
"name": "history-extra",
"version": "4.0.0",
"version": "4.0.1",
"description": "Extra functionality for the history module",
"main": "dist/index.js",
"main": "dist/createHashStateHistory.js",
"module": "dist/createHashStateHistory.mjs",
"scripts": {

@@ -7,0 +8,0 @@ "lint": "eslint '*.{js,mjs}' 'src/**/*.{js,mjs}'",

@@ -8,3 +8,3 @@ # history-extra

[![npm](https://img.shields.io/npm/v/history-extra.svg)](https://www.npmjs.com/package/history-extra)
[![Project Status](https://img.shields.io/badge/status-experimental-orange.svg)](https://nodejs.org/api/documentation.html#documentation_stability_index)
[![Project Status](https://img.shields.io/badge/status-stable-brightgreen.svg)](https://nodejs.org/api/documentation.html#documentation_stability_index)

@@ -11,0 +11,0 @@ ## Usage

/* eslint no-use-before-define: 0 */
import { createLocation, locationsAreEqual } from 'history/LocationUtils';
import {
import locationUtils from 'history/LocationUtils';
import PathUtils from 'history/PathUtils';
import createTransitionManager from 'history/createTransitionManager';
import DOMUtils from 'history/DOMUtils';
const { createLocation, locationsAreEqual } = locationUtils;
const {
addLeadingSlash,

@@ -10,5 +15,4 @@ stripLeadingSlash,

createPath,
} from 'history/PathUtils';
import createTransitionManager from 'history/createTransitionManager';
import {
} = PathUtils;
const {
canUseDOM,

@@ -20,3 +24,3 @@ addEventListener,

supportsHistory,
} from 'history/DOMUtils';
} = DOMUtils;

@@ -23,0 +27,0 @@ function warning(condition, message) {

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