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.15.0 to 5.15.1

5

changelog.md

@@ -0,1 +1,6 @@

# [5.15.1](https://github.com/TehShrike/abstract-state-router/releases/tag/v5.15.1)
- updated hash-brown-router [#93](https://github.com/TehShrike/abstract-state-router/pull/93)
- compatibility: switched from `requre('events').EventEmitter` to `requre('events')` for better Rollup compatibility. [c861f5ab](https://github.com/TehShrike/abstract-state-router/commit/c861f5ab2d0c5d34915c6344fc8ef2d5a7982db2)
# [5.15.0](https://github.com/TehShrike/abstract-state-router/releases/tag/v5.15.0)

@@ -2,0 +7,0 @@

8

index.js

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

var EventEmitter = require('events').EventEmitter
var EventEmitter = require('events')
var extend = require('xtend')

@@ -21,3 +21,3 @@ var newHashBrownRouter = require('hash-brown-router')

var expectedPropertiesOfAddState = ['name', 'route', 'defaultChild', 'data', 'template', 'resolve', 'activate', 'querystringParameters', 'defaultQuerystringParameters', 'defaultParameters']
var expectedPropertiesOfAddState = [ 'name', 'route', 'defaultChild', 'data', 'template', 'resolve', 'activate', 'querystringParameters', 'defaultQuerystringParameters', 'defaultParameters' ]

@@ -39,3 +39,3 @@ module.exports = function StateProvider(makeRenderer, rootElement, stateRouterOptions) {

stateRouterOptions.router.setDefault(function(route, parameters) {
stateRouterOptions.router.on('not found', function(route, parameters) {
stateProviderEmitter.emit('routeNotFound', route, parameters)

@@ -398,3 +398,3 @@ })

var resolves = Promise.all(statesWithResolveFunctions.map(function(state) {
return new Promise(function (resolve, reject) {
return new Promise(function(resolve, reject) {
function resolveCb(err, content) {

@@ -401,0 +401,0 @@ err ? reject(err) : resolve(content)

{
"name": "abstract-state-router",
"version": "5.15.0",
"description": "The basics of a client-side state router ala the AngularJS ui-router, but without any DOM interactions",
"version": "5.15.1",
"description": "Like ui-router, but without all the Angular. The best way to structure a single-page webapp.",
"main": "index.js",

@@ -30,11 +30,11 @@ "scripts": {

"combine-arrays": "~1.0.2",
"hash-brown-router": "~1.5.0",
"hash-brown-router": "~3.0.2",
"native-promise-only": "0.8.1",
"page-path-builder": "~1.0.3",
"path-to-regexp-with-reversible-keys": "~1.0.3",
"then-denodeify": "1.0.0",
"then-denodeify": "1.0.1",
"xtend": "^4.0.0"
},
"devDependencies": {
"browserify": "13.1.1",
"browserify": "14.0.0",
"browserstack-runner": "TehShrike/browserstack-runner#fixing-json-borking",

@@ -47,5 +47,5 @@ "browserstack-tape-reporter": "~1.1.0",

"tape-catch": "1.0.6",
"watchify": "3.7.0",
"watchify": "3.9.0",
"webpack": "^1.12.14"
}
}

@@ -1,9 +0,7 @@

[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.
abstract-state-router lets you build single-page webapps using nested routes/states. Your code doesn't reference routes directly, like `/app/users/josh`, but by name and properties, like `app.user` + `{ name: 'josh' }`.
But I don't want to use AngularJS - I want to use *[my favorite templating/dom manipulation libraries here]*.
To find out why you should be using this kind of router, read [Why Your Webapp Needs a State-Based Router](http://joshduff.com/#!/post/2015-06-why-you-need-a-state-router.md).
Thus, this library! Written to work with [browserify](https://github.com/substack/node-browserify), it lets you create nested "states" that correspond to different parts of the url path.
abstract-state-router is heavily inspired by [ui-router](https://github.com/angular-ui/ui-router/wiki). The biggest difference is: you can use abstract-state-router with whatever templating/component library you like.
If you've never used AngularJS's ui-router before, check out this post: [Why your webapp needs a state-based router](http://joshduff.com/#!/post/2015-06-why-you-need-a-state-router.md).
To see an example app implemented with a couple of different browser rendering libraries, [click here to visit the state-router-example on Github Pages](http://tehshrike.github.io/state-router-example).

@@ -19,4 +17,5 @@

- [Knockout](https://github.com/crissdev/knockout-state-renderer)
- [Svelte](https://github.com/TehShrike/svelte-state-renderer)
If you want to use the state router with some other templating/dom manipulation library, [read these docs](https://github.com/TehShrike/abstract-state-router/blob/master/renderer.md)! It's not too bad to get started.
If you want to use the state router with any other templating/dom manipulation library, [read these docs](https://github.com/TehShrike/abstract-state-router/blob/master/renderer.md)! It's not too bad to get started.

@@ -29,3 +28,3 @@ # Install

npm install abstract-state-router
npm install abstract-state-router -S

@@ -55,3 +54,3 @@ ```

- `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).
- `router` defaults to an instance of a [hash brown router@3.x](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.

@@ -67,4 +66,6 @@

`defaultChild` is a string (or a function that returns a string) of the default child's name. If you attempt to go directly to a state that has a default child, you will be directed to the default child. (For example, you could set 'list' to be the default child of 'contacts'. Then doing `state.go('contacts')` will actually do `state.go('contacts.list')`. Likewise, browsing to '/tehshrike/contacts' would bring you to '/tehshrike/contacts/list'.)
`defaultChild` is a string (or a function that returns a string) of the default child's name. Use the short name (`list`), not the fully qualified name with all its parents (`contacts.list`).
If the viewer navigates to a state that has a default child, the router will redirect to the default child. (For example, if 'list' is the default child of 'contacts', `state.go('contacts')` will actually be equivalent to `state.go('contacts.list')`. Likewise, browsing to '/tehshrike/contacts' would take the viewer to '/tehshrike/contacts/list'.)
`data` is an object that can hold whatever you want - it will be passed in to the resolve and activate functions.

@@ -92,2 +93,17 @@

If you want to redirect with promises, return a rejected promise with an object containing a `redirectTo` property with `name` and `params` values for the state to redirect to.
```js
function resolve(data, parameters) {
return Promise.reject({
redirectTo: {
name: 'otherCoolState',
params: {
extraCool: true
}
}
})
}
```
### activate(context)

@@ -94,0 +110,0 @@

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