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

abstract-state-router

Package Overview
Dependencies
Maintainers
0
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-state-router - npm Package Compare versions

Comparing version 7.5.2 to 7.6.0

94

bundle.js
'use strict';
var require$$2 = require('combine-arrays');
var require$$3 = require('path-to-regexp-with-reversible-keys');
var require$$9 = require('then-denodeify');
var require$$10 = require('eventemitter3');
var require$$11 = require('hash-brown-router');
var require$$13 = require('page-path-builder');
var require$$14 = require('iso-next-tick');
var require$$1 = require('combine-arrays');
var require$$2 = require('path-to-regexp-with-reversible-keys');
var require$$8 = require('then-denodeify');
var require$$9 = require('eventemitter3');
var require$$10 = require('hash-brown-router');
var require$$12 = require('page-path-builder');
var require$$13 = require('iso-next-tick');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
var require$$8__default = /*#__PURE__*/_interopDefaultLegacy(require$$8);
var require$$9__default = /*#__PURE__*/_interopDefaultLegacy(require$$9);
var require$$10__default = /*#__PURE__*/_interopDefaultLegacy(require$$10);
var require$$11__default = /*#__PURE__*/_interopDefaultLegacy(require$$11);
var require$$12__default = /*#__PURE__*/_interopDefaultLegacy(require$$12);
var require$$13__default = /*#__PURE__*/_interopDefaultLegacy(require$$13);
var require$$14__default = /*#__PURE__*/_interopDefaultLegacy(require$$14);

@@ -115,9 +115,6 @@ var stateStringParser$2 = stateString => stateString.split(`.`).reduce((stateNames, latestNameChunk) => {

var extend$2 = (...args) => Object.assign({}, ...args);
const stateStringParser = stateStringParser$2;
const extend$1 = extend$2;
const combine$1 = require$$2__default['default'];
const pathToRegexp = require$$3__default['default'];
const combine$1 = require$$1__default['default'];
const pathToRegexp = require$$2__default['default'];

@@ -127,5 +124,5 @@ var stateComparison_1 = function StateComparison(stateState) {

const parametersChanged = args => parametersThatMatterWereChanged(extend$1(args, { stateState, getPathParameters }));
const parametersChanged = args => parametersThatMatterWereChanged({ ...args, stateState, getPathParameters });
return args => stateComparison(extend$1(args, { parametersChanged }))
return args => stateComparison({ ...args, parametersChanged })
};

@@ -291,10 +288,9 @@

const series = promiseMapSeries;
const extend = extend$2;
const denodeify = require$$9__default['default'];
const EventEmitter = require$$10__default['default'];
const newHashBrownRouter = require$$11__default['default'];
const combine = require$$2__default['default'];
const buildPath = require$$13__default['default'];
const nextTick = require$$14__default['default'];
const denodeify = require$$8__default['default'];
const EventEmitter = require$$9__default['default'];
const newHashBrownRouter = require$$10__default['default'];
const combine = require$$1__default['default'];
const buildPath = require$$12__default['default'];
const nextTick = require$$13__default['default'];

@@ -305,3 +301,2 @@ const getProperty = name => obj => obj[name];

const isThenable = object => object && (typeof object === `object` || typeof object === `function`) && typeof object.then === `function`;
const promiseMe = (fn, ...args) => new Promise(resolve => resolve(fn(...args)));

@@ -320,6 +315,7 @@ const expectedPropertiesOfAddState = [ `name`, `route`, `defaultChild`, `data`, `template`, `resolve`, `activate`, `querystringParameters`, `defaultQuerystringParameters`, `defaultParameters`, `canLeaveState` ];

StateTransitionManager(stateProviderEmitter);
const { throwOnError, pathPrefix } = extend({
const { throwOnError, pathPrefix } = {
throwOnError: true,
pathPrefix: `#`,
}, stateRouterOptions);
...stateRouterOptions,
};

@@ -446,5 +442,14 @@ const router = stateRouterOptions.router || newHashBrownRouter(defaultRouterOptions);

if (state.canLeaveState && typeof state.canLeaveState === 'function') {
const stateChangeAllowed = state.canLeaveState(activeDomApis[stateName]);
const stateChangeAllowed = state.canLeaveState(activeDomApis[stateName], {
name: newStateName,
parameters: newParameters,
});
if (!stateChangeAllowed) {
stateProviderEmitter.emit('stateChangePrevented', stateName);
stateProviderEmitter.emit('stateChangePrevented', {
name: stateName,
parameters: lastState.parameters,
}, {
name: newStateName,
parameters: newParameters,
});
}

@@ -541,3 +546,3 @@ return stateChangeAllowed

return promiseMe(prototypalStateHolder.guaranteeAllStatesExist, newStateName)
return Promise.resolve(prototypalStateHolder.guaranteeAllStatesExist(newStateName))
.then(function applyDefaultParameters() {

@@ -551,3 +556,3 @@ const state = prototypalStateHolder.get(newStateName);

if (needToApplyDefaults) {
throw redirector(newStateName, extend(computeDefaultParams(defaultParams), parameters))
throw redirector(newStateName, { ...computeDefaultParams(defaultParams), ...parameters })
}

@@ -568,3 +573,3 @@ return state

}).then(ifNotCancelled(function resolveDestroyAndActivateStates(stateChanges) {
return resolveStates(getStatesToResolve(stateChanges), extend(parameters)).catch(function onResolveError(e) {
return resolveStates(getStatesToResolve(stateChanges), Object.assign({}, parameters)).catch(function onResolveError(e) {
e.stateChangeError = true;

@@ -581,4 +586,4 @@ throw e

() => {
activeStateResolveContent = extend(activeStateResolveContent, stateResolveResultsObject);
return renderAll(stateChanges.create, extend(parameters)).then(activateAll)
activeStateResolveContent = { ...activeStateResolveContent, ...stateResolveResultsObject };
return renderAll(stateChanges.create, Object.assign({}, parameters)).then(activateAll)
},

@@ -636,3 +641,3 @@ )

if (options && options.inherit) {
parameters = extend(getGuaranteedPreviousState().parameters, parameters);
parameters = { ...(getGuaranteedPreviousState().parameters), ...parameters };
}

@@ -645,3 +650,3 @@

parameters = extend(computeDefaultParams(defaultParams), parameters);
parameters = { ...computeDefaultParams(defaultParams), ...parameters };

@@ -659,9 +664,14 @@ prototypalStateHolder.guaranteeAllStatesExist(destinationStateName);

stateProviderEmitter.go = (newStateName, parameters, options) => {
options = extend(defaultOptions, options);
options = { ...defaultOptions, ...options };
const goFunction = options.replace ? router.replace : router.go;
return promiseMe(makePath, newStateName, parameters, options)
.then(goFunction, err => handleError(`stateChangeError`, err))
return new Promise((resolve, reject) => {
try {
resolve(makePath(newStateName, parameters, options));
} catch (err) {
reject(err);
}
}).then(goFunction, err => handleError(`stateChangeError`, err))
};
stateProviderEmitter.evaluateCurrentRoute = (defaultState, defaultParams) => promiseMe(makePath, defaultState, defaultParams).then(defaultPath => {
stateProviderEmitter.evaluateCurrentRoute = (defaultState, defaultParams) => Promise.resolve(makePath(defaultState, defaultParams)).then(defaultPath => {
router.evaluateCurrent(defaultPath);

@@ -696,3 +706,5 @@ }).catch(err => handleError(`stateError`, err));

.filter(stateName => stateResolveResultsObject[stateName])
.reduce((obj, stateName) => extend(obj, stateResolveResultsObject[stateName]), {})
.reduce((obj, stateName) => {
return { ...obj, ...stateResolveResultsObject[stateName] }
}, {})
}

@@ -699,0 +711,0 @@

{
"name": "abstract-state-router",
"version": "7.5.2",
"version": "7.6.0",
"description": "Like ui-router, but without all the Angular. The best way to structure a single-page webapp.",

@@ -5,0 +5,0 @@ "main": "bundle.js",

@@ -29,3 +29,3 @@ **[Changelog](./changelog.md) • [Join the chat on Discord](https://discord.gg/G8FrErC) • [API documentation](#api)**

If you're supporting really old browsers pre-ES2015 browsers, you'll need polyfills for `Promise` and `Object.assign`. Check out [polyfill.io](https://polyfill.io/) for automatic polyfills, it makes life super-easy.
If you're supporting really old browsers pre-ES2015 browsers, you'll need polyfills for `Promise` and `Object.assign`. Check out [polyfill-fastly.net](https://polyfill-fastly.net/) for automatic polyfills, it makes life super-easy.

@@ -113,3 +113,3 @@ # Current renderer implementations

`canLeaveState` is an optional function with the state's domApi as its sole argument. If it returns `false`, navigation from the state will be prevented. If it is returns `true` or is left `undefined`, state changes will not be prevented.
`canLeaveState` is an optional function that takes two arguments: the state's domApi, and an object with the `name` and `parameters` of the state that the user is attempting to navigate to. It can return either a boolean, or a promise that resolves to a boolean. If `canLeaveState` returns `false`, navigation from the current state will be prevented. If the function returns `true` the state change will continue.

@@ -301,2 +301,3 @@ ### resolve(data, parameters, callback(err, content).redirect(stateName, [stateParameters]))

- `stateChangeEnd(state, parameters, states)` - after all activate functions are called
- `stateChangePrevented(oldState: { name, parameters }, attemptedNavigationState: { name, parameters })`
- `stateChangeError(err)` - emitted if an error occurs while trying to navigate to a new state - including if you try to navigate to a state that doesn't exist

@@ -303,0 +304,0 @@ - `stateError(err)` - emitted if an error occurs in an activation function, or somewhere else that doesn't directly interfere with changing states. Should probably be combined with `stateChangeError` at some point since they're not that different?

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