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

abstract-state-router

Package Overview
Dependencies
Maintainers
1
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 5.4.0 to 5.5.0

.npmignore

5

index.js

@@ -22,3 +22,4 @@ var StateState = require('./lib/state-state')

stateRouterOptions = extend({
throwOnError: true
throwOnError: true,
pathPrefix: '#'
}, stateRouterOptions)

@@ -272,3 +273,3 @@

stateProviderEmitter.makePath = function makePathAndPrependHash(stateName, parameters) {
return '#' + makePath(stateName, parameters)
return stateRouterOptions.pathPrefix + makePath(stateName, parameters)
}

@@ -275,0 +276,0 @@ stateProviderEmitter.stateIsActive = function stateIsActive(stateName, opts) {

18

package.json
{
"name": "abstract-state-router",
"version": "5.4.0",
"version": "5.5.0",
"description": "The basics of a client-side state router ala the AngularJS ui-router, but without any DOM interactions",
"main": "index.js",
"scripts": {
"zuul": "zuul -- test/*.js",
"test": "tape test/*.js | faucet",
"coverage": "covert test/*.js"
"coverage": "covert test/*.js",
"browserwatch": "watchify test-browser/add-color.js test/*.js -o test-browser/build.js -d",
"browserstackbuild": "browserify test-browser/add-color.js test/*.js node_modules/browserstack-tape-reporter/index.js -o test-browser/build.js",
"browserstack": "npm run browserstackbuild && browserstack-runner"
},

@@ -37,8 +39,12 @@ "repository": {

"devDependencies": {
"browserify": "11.0.1",
"browserstack-runner": "0.3.7",
"browserstack-tape-reporter": "1.0.2",
"covert": "^1.1.0",
"faucet": "0.0.1",
"tape": "^4.0.0",
"tape-catch": "^1.0.4",
"zuul": "^3.0.0"
"tap-browser-color": "0.1.2",
"tape": "^4.1.0",
"tape-catch": "1.0.4",
"watchify": "3.4.0"
}
}

@@ -33,5 +33,6 @@ [ui-router](https://github.com/angular-ui/ui-router/wiki) is fantastic, and I would use it in all of my projects if it wasn't tied to AngularJS.

`options` are mostly to override some defaults while testing. You shouldn't need to change any of the defaults while developing. Possible properties are:
Possible properties of the `options` object are:
- `router` defaults to an instance of a [hash brown router](https://github.com/TehShrike/hash-brown-router/). The abstract-state-router unit tests use the [hash brown router stub](https://github.com/TehShrike/hash-brown-router/#testability).
- `pathPrefix` defaults to `'#'`. If you're using HTML5 routing/pushState, you'll most likely want to set this to an empty string.
- `router` defaults to an instance of a [hash brown router](https://github.com/TehShrike/hash-brown-router/). The abstract-state-router unit tests use the [hash brown router stub](https://github.com/TehShrike/hash-brown-router/#testability). To use pushState, pass in a hash brown router created with [sausage-router](https://github.com/TehShrike/sausage-router).
- `throwOnError` defaults to true, because you get way better stack traces in Chrome when you throw than if you `console.log(err)` or emit `'error'` events. The unit tests disable this.

@@ -170,2 +171,17 @@

# Testing/development
To run the unit tests:
- clone this repository
- run `npm install`
- run `npm test`
Automated browser testing provided by [Browserstack](https://www.browserstack.com/).
Tested in Chrome, Firefox, Safari, and IE10+ (IE9 doesn't support [replace](https://developer.mozilla.org/en-US/docs/Web/API/Location/replace)).
[![Build Status](https://travis-ci.org/TehShrike/abstract-state-router.svg?branch=master)](https://travis-ci.org/TehShrike/abstract-state-router)
# State change flow

@@ -192,4 +208,12 @@

- [Support for hash-less paths using HTML5/pushState?](https://github.com/TehShrike/abstract-state-router/issues/39)
- [Support for hash-less paths using HTML5/pushState](https://github.com/TehShrike/abstract-state-router/issues/39)
## "Universal JavaScript"
A future goal is to make it possible to generate HTML for routes on the server-side, at least for the templating libraries like Ractive that do not require a DOM to generate HTML.
This requires supporting HTML5 routing (see issue linked above), and some way for the results of the initial `resolve` values to be included with JSONP so that when the client-side abstract-state-router code does eventually start running, it doesn't have to re-fetch all the initial state.
I don't think this should be a huge change, but I haven't gotten around to it yet. Feel free to check out the issue above if you want to get started on it yourself.
# Maintainers

@@ -203,3 +227,1 @@

[WTFPL](http://wtfpl2.com)
[![Build Status](https://travis-ci.org/TehShrike/abstract-state-router.svg?branch=master)](https://travis-ci.org/TehShrike/abstract-state-router)

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tape-catch')
var getTestState = require('./helpers/test-state-factory')

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tape-catch')
var assertingRendererFactory = require('./helpers/asserting-renderer-factory')

@@ -14,3 +14,3 @@ var getTestState = require('./helpers/test-state-factory')

var stateRouter = state.stateRouter
var assertsBelow = 4
var assertsBelow = 2
var renderAsserts = renderer.expectedAssertions

@@ -22,3 +22,2 @@

var parentDestroyed = false
var grandparentDestroyed = false

@@ -34,6 +33,2 @@ stateRouter.addState({

context.on('destroy', function () {
grandparentDestroyed = true
t.ok(parentDestroyed, 'grandparent gets destroyed after parent')
t.ok(childDestroyed, 'grandparent gets destroyed after child')
t.fail('grandparent should not be destroyed')

@@ -54,3 +49,2 @@ })

context.on('destroy', function () {
t.notOk(grandparentDestroyed, 'parent gets destroyed before grandparent')
parentDestroyed = true

@@ -71,3 +65,2 @@ t.ok(childDestroyed, 'parent gets destroyed after child')

context.on('destroy', function () {
t.notOk(grandparentDestroyed, 'child gets destroyed before grandparent')
t.notOk(parentDestroyed, 'child gets destroyed before parent')

@@ -74,0 +67,0 @@ childDestroyed = true

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tape-catch')
var getTestState = require('./helpers/test-state-factory')

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tape-catch')
var assertingRendererFactory = require('./helpers/asserting-renderer-factory')

@@ -3,0 +3,0 @@ var getTestState = require('./helpers/test-state-factory')

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tape-catch')
var getTestState = require('./helpers/test-state-factory')

@@ -3,0 +3,0 @@

@@ -5,10 +5,11 @@ var hashRouterFactory = require('hash-brown-router')

var mockRenderFn = require('./renderer-mock')
var extend = require('extend')
module.exports = function getTestState(t, renderFn) {
module.exports = function getTestState(t, renderFn, options) {
var location = hashLocationMockFactory()
var hashRouter = hashRouterFactory(location)
var stateRouter = stateRouterFactory(renderFn || mockRenderFn, 'body', {
var stateRouter = stateRouterFactory(renderFn || mockRenderFn, 'body', extend({
router: hashRouter,
throwOnError: false
})
}, options))
hashRouter.setDefault(function noop() {})

@@ -15,0 +16,0 @@

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tape-catch')

@@ -3,0 +3,0 @@ var interpretStateChange = require('../lib/state-change-logic')

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tape-catch')
var getTestState = require('./helpers/test-state-factory')

@@ -42,5 +42,2 @@

template: {},
resolve: function(data, params, cb) {
setTimeout(cb, 100)
},
activate: function() {

@@ -47,0 +44,0 @@ t.fail('should not activate')

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tape-catch')
var assertingRendererFactory = require('./helpers/asserting-renderer-factory')

@@ -3,0 +3,0 @@ var getTestState = require('./helpers/test-state-factory')

@@ -1,5 +0,5 @@

var test = require('tape')
var test = require('tape-catch')
var getTestState = require('./helpers/test-state-factory')
test('test redirector chain', function(t) {
test('test redirecting activating the correct states', function(t) {
function startTest(t) {

@@ -21,3 +21,3 @@ var state = getTestState(t)

activate: function() {
t.notOk(parentActivated, 'Should only activate once')
t.notOk(parentActivated, 'The parent should only activate once')
parentActivated = true

@@ -85,3 +85,3 @@ }

test('test redirector chain', function(t) {
test('only one cancel happens if multiple redirects are called', function(t) {
function startTest(t) {

@@ -121,5 +121,2 @@ var state = getTestState(t)

template: {},
resolve: function(data, params, cb) {
setTimeout(cb, 100, null)
},
activate: function() {

@@ -126,0 +123,0 @@ t.fail('should not activate')

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tape-catch')
var StateState = require('../lib/state-state.js')

@@ -3,0 +3,0 @@ var stateComparison = require('../lib/state-comparison.js')

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tape-catch')
var StateState = require('../lib/state-state')

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tape-catch')
var parse = require('../lib/state-string-parser')

@@ -3,0 +3,0 @@

@@ -1,2 +0,2 @@

var test = require('tape')
var test = require('tape-catch')
var assertingRendererFactory = require('./helpers/asserting-renderer-factory')

@@ -249,34 +249,2 @@ var getTestState = require('./helpers/test-state-factory')

test('makePath', function(t) {
var stateRouter = getTestState(t).stateRouter
t.plan(2)
stateRouter.addState({
name: 'parent',
template: '',
route: '/parent',
})
stateRouter.addState({
name: 'parent.child1',
template: '',
route: '/child1',
})
stateRouter.addState({
name: 'parent.child2',
template: '',
route: '/child2',
})
t.equal('#/parent/child1?param=value', stateRouter.makePath('parent.child1', { param: 'value' }))
t.throws(function() {
stateRouter.makePath('parent.doesnotexist')
}, /doesnotexist/)
t.end()
})
test('stateIsActive', function(t) {

@@ -283,0 +251,0 @@ var stateRouter = getTestState(t).stateRouter

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