cyclic-router
Advanced tools
Comparing version 5.0.0 to 5.0.1
@@ -0,1 +1,10 @@ | ||
# v5.0.1 (2017-08-09) | ||
## Features | ||
- Add husky and lint-staged (#204) | ||
([fcdecb66](https://github.com/git+https://github.com/cyclejs-community/cyclic-router.git/commits/fcdecb66f7d3aec0e82594e9e515d26029461b89)) | ||
# v5.0.0 (2017-08-08) | ||
@@ -2,0 +11,0 @@ |
{ | ||
"name": "cyclic-router", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "A router driver built for Cycle.js", | ||
"main": "lib/index.js", | ||
"module": "lib/es6/index.js", | ||
"typings": "lib/index.d.ts", | ||
@@ -22,2 +23,6 @@ "directories": { | ||
"email": "ntilwalli@gmail.com" | ||
}, | ||
{ | ||
"name": "Jan van Brügge", | ||
"email": "supermanitu@gmail.com" | ||
} | ||
@@ -49,2 +54,4 @@ ], | ||
"ghooks": "^1.2.1", | ||
"husky": "^0.14.3", | ||
"lint-staged": "^4.0.3", | ||
"mkdirp": "^0.5.1", | ||
@@ -62,9 +69,11 @@ "mocha": "^3.4.2", | ||
}, | ||
"config": { | ||
"ghooks": { | ||
"commit-msg": "node ./node_modules/.bin/validate-commit-msg", | ||
"pre-commit": "npm run format" | ||
} | ||
"lint-staged": { | ||
"{test,src}/**/*.{js,jsx,ts,tsx}": [ | ||
"npm run format", | ||
"git add" | ||
] | ||
}, | ||
"scripts": { | ||
"precommit": "lint-staged", | ||
"commitmsg": "validate-commit-msg $2", | ||
"format": "prettier --tab-width 4 --single-quote --write '{src,test}/**/*.{js,ts,tsx}'", | ||
@@ -79,3 +88,5 @@ "lint": "tslint -c tslint.json src/*.ts src/**/*.ts", | ||
"predist": "rm -rf dist/ && mkdirp dist/", | ||
"lib": "tsc", | ||
"lib": "npm run lib:cjs && npm run lib:es6", | ||
"lib:cjs": "tsc --module commonjs --outDir ./lib", | ||
"lib:es6": "tsc --module es6 --outDir ./lib/es6", | ||
"start": "npm install && npm prune", | ||
@@ -82,0 +93,0 @@ "prerelease": "npm run lib", |
# cyclic-router | ||
cyclic-router is a Router Driver built for Cycle.js | ||
cyclic-router V5 is a routing library built for Cycle.js. Unlike previous versions, cyclic-router V5 is not a driver. It is a `main` function-wrapper (routerify) which relies on @cycle/history for driver source/sink interactions | ||
**Disclaimer** Use v4 for Cycle Unified. v2.x.x is for Cycle and v3 is for Cycle Diversity. | ||
If you are still using @cycle/core please continue to use v1.x.x | ||
For older versions of cyclic-router, V4 and earlier please go to the old [README](https://github.com/cyclejs-community/cyclic-router/blob/master/README_V4.md) | ||
@@ -13,23 +12,13 @@ ## Installation | ||
Versions 3 and 4 requires users to inject the route matcher. We'll use `switch-path` for our examples but other | ||
matching libraries could be adapted to be used here: | ||
Routerify requires you to inject the route matcher. We'll use `switch-path` for our examples but other matching libraries could be adapted to be used here: | ||
$ npm install --save switch-path | ||
Note: Version 2 and below use `switch-path` for the route matcher always and the above library install is not necesssary/done implicitly. | ||
Then with a module bundler like [browserify](http://browserify.org/), use as you would anything else: | ||
```js | ||
// using an ES6 transpiler, like babel | ||
import {makeRouterDriver} from 'cyclic-router' | ||
import {routerify} from 'cyclic-router' | ||
// not using an ES6 transpiler | ||
var makeRouterDriver = require('cyclic-router').makeRouterDriver | ||
var routerify = require('cyclic-router').routerify | ||
``` | ||
## API | ||
For API documentation please visit this link [here](http://cyclejs-community.github.io/cyclic-router/docs/) | ||
## Basic Usage | ||
@@ -39,7 +28,7 @@ | ||
import xs from 'xstream'; | ||
import Cycle from '@cycle/xstream-run'; | ||
import {run} from '@cycle/run'; | ||
import {makeDOMDriver} from '@cycle/dom'; | ||
import {makeRouterDriver} from 'cyclic-router'; | ||
import {createBrowserHistory} from 'history'; | ||
import switchPath from 'switch-path'; // Required in v3, not required in v2 or below | ||
import {routerify} from 'cyclic-router'; | ||
import {makeHistoryDriver} from '@cycle/history'; | ||
import switchPath from 'switch-path'; | ||
@@ -54,3 +43,5 @@ function main(sources) { | ||
return value(Object.assign({}, sources, { | ||
router: sources.router.path(path) | ||
router: sources.router.path(path) // notice use of 'router' source name, | ||
// which proxies raw 'history' source with | ||
// additional functionality | ||
})); | ||
@@ -61,13 +52,34 @@ }); | ||
DOM: page$.map(c => c.DOM).flatten(), | ||
router: xs.of('/other'), | ||
router: xs.of('/other') // Notice use of 'router' sink name, | ||
// which proxies the original 'history' sink | ||
}; | ||
} | ||
Cycle.run(main, { | ||
const mainWithRouting = routerify(main, switchPath) | ||
run(mainWithRouting, { | ||
DOM: makeDOMDriver('#app'), | ||
router: makeRouterDriver(createBrowserHistory(), switchPath) // v3 | ||
// router: makeRouterDriver(createHistory()) // <= v2 | ||
history: makeHistoryDriver() // create history driver as usual, | ||
// but it gets proxied by routerify | ||
}); | ||
``` | ||
### Routerify Options | ||
Routerify accepts an options object like so: `routerify(main, switchPath, options)` | ||
The `options` object conforms to the interface: | ||
``` | ||
interface RouterOptions { | ||
basename?: string; | ||
historyName?: string; | ||
routerName?: string; | ||
omitHistory?: boolean; | ||
} | ||
``` | ||
- `basename` - The root router path, defaults to `/` | ||
- `historyName` - The source/sink name associated with the raw history driver, defaults to `history` | ||
- `routerName` - The source/sink name you want exposed to your app which captures the functionality/streams associated with routerify. Defaults to `router` | ||
- `omitHistory` - Routerify hides the source/sink name associated with the raw history driver (given in the `historyName` option) from your app and only exposes the source/sink name associated with the router (given in the `routerName` option). Defaults to `true`, If you would like your app to have access to both the raw `history` source/sink and the `router` source/sink (injected by routerify), set this option to `false` | ||
### Route Parameters | ||
@@ -74,0 +86,0 @@ |
@@ -9,5 +9,4 @@ { | ||
"suppressImplicitAnyIndexErrors": true, | ||
"module": "commonjs", | ||
"target": "ES5", | ||
"outDir": "lib/" | ||
"moduleResolution": "node", | ||
"target": "ES5" | ||
}, | ||
@@ -14,0 +13,0 @@ "formatCodeOptions": { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
700124
67
2305
125
0
25