author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
580,240
08.01.2018 16:37:18
21,600
4212a0530b74ed4d97050b0b11fc9b72f23bd2f3
feat(router5-helpers): Add type definitions
[ { "change_type": "ADD", "old_path": null, "new_path": "packages/router5-helpers/index.d.ts", "diff": "+declare module 'router5-helpers' {\n+ import { ActivationFnFactory, Params, State } from 'router5'\n+\n+ export type ApplySegmentFn = (segment: string) => boolean\n+ export type RedirectToFn = (\n+ toRouteName: string,\n+ toRouteParams?: Params | ToRouteParamsFn\n+ ) => ActivationFnFactory\n+ export type ToRouteParamsFn = (params: Params) => Params\n+\n+ export function redirect(\n+ fromRouteName: string,\n+ toRouteName: string,\n+ toRouteParams?: Params | ToRouteParamsFn\n+ ): ActivationFnFactory\n+ export function redirect(fromRouteName: string): RedirectToFn\n+\n+ export function startsWithSegment(\n+ route: string | State,\n+ segment: string\n+ ): boolean\n+ export function startsWithSegment(route: string | State): ApplySegmentFn\n+\n+ export function endsWithSegment(\n+ route: string | State,\n+ segment: string\n+ ): boolean\n+ export function endsWithSegment(route: string | State): ApplySegmentFn\n+\n+ export function includesSegment(\n+ route: string | State,\n+ segment: string\n+ ): boolean\n+ export function includesSegment(route: string | State): ApplySegmentFn\n+}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5-helpers/test/main.js", "new_path": "packages/router5-helpers/test/main.js", "diff": "import { expect } from 'chai'\nimport * as helpers from '../modules'\n+import tt from 'typescript-definition-tester'\ndescribe('router5-helpers', function() {\ndescribe('.startsWithSegment()', function() {\n@@ -65,4 +66,17 @@ describe('router5-helpers', function() {\n})\n})\n})\n+\n+ describe('TypeScript definitions', function() {\n+ it('should compile examples against index.d.ts', function(done) {\n+ this.timeout(10000)\n+\n+ tt.compileDirectory(\n+ `${__dirname}/typescript`,\n+ filename => filename.match(/\\.ts$/),\n+ { lib: ['lib.es2015.d.ts'] },\n+ () => done()\n+ )\n+ })\n+ })\n})\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/router5-helpers/test/typescript/index.ts", "diff": "+/// <reference path=\"../../../router5/index.d.ts\" />\n+/// <reference path=\"../../index.d.ts\" />\n+\n+import createRouter, { State } from 'router5'\n+import {\n+ redirect,\n+ startsWithSegment,\n+ endsWithSegment,\n+ includesSegment\n+} from 'router5-helpers'\n+\n+const router = createRouter([])\n+const state: State = { name: 'a.b', params: {}, path: '/a/b' }\n+\n+redirect('a', 'b', {})\n+redirect('a')('b', {})\n+redirect('a', 'b')\n+redirect('a')('b')\n+\n+redirect('a', 'b', {})\n+redirect('a', 'b')(router)(state, null, () => {})\n+\n+let res: boolean\n+\n+res = startsWithSegment('a.b', 'a')\n+res = startsWithSegment(state, 'a')\n+res = startsWithSegment('a.b')('a')\n+res = startsWithSegment(state)('a')\n+\n+res = endsWithSegment('a.b', 'a')\n+res = endsWithSegment(state, 'a')\n+res = endsWithSegment('a.b')('a')\n+res = endsWithSegment(state)('a')\n+\n+res = includesSegment('a.b', 'a')\n+res = includesSegment(state, 'a')\n+res = includesSegment('a.b')('a')\n+res = includesSegment(state)('a')\n" } ]
TypeScript
MIT License
router5/router5
feat(router5-helpers): Add type definitions
580,249
09.01.2018 09:12:37
0
33c6ac5a614e157dc2a8fc00cc97fdac1df050e2
chore: link typings
[ { "change_type": "MODIFY", "old_path": "packages/router5-helpers/package.json", "new_path": "packages/router5-helpers/package.json", "diff": "\"bugs\": {\n\"url\": \"https://github.com/router5/router5/issues\"\n},\n- \"homepage\": \"https://router5.github.io\"\n+ \"homepage\": \"https://router5.github.io\",\n+ \"typings\": \"./index.d.ts\"\n}\n" } ]
TypeScript
MIT License
router5/router5
chore: link typings
580,249
26.12.2017 11:52:01
0
8af7a6ed1dbfa291dd214f0cc8caf6b5efd65660
fix: fix clone function to include route specific config like forwardTo
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/clone.js", "new_path": "packages/router5/modules/core/clone.js", "diff": "@@ -17,6 +17,7 @@ export default function withCloning(router, createRouter) {\nclonedRouter.useMiddleware(...router.getMiddlewareFactories())\nclonedRouter.usePlugin(...router.getPlugins())\n+ clonedRouter.config = router.config\nconst [\ncanDeactivateFactories,\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/navigation.js", "new_path": "packages/router5/modules/core/navigation.js", "diff": "@@ -6,7 +6,7 @@ const noop = function() {}\nexport default function withNavigation(router) {\nlet cancelCurrentTransition\n- router.forwardMap = {}\n+ router.config.forwardMap = {}\nrouter.navigate = navigate\nrouter.navigateToDefault = navigateToDefault\nrouter.transitionToState = transitionToState\n@@ -33,7 +33,7 @@ export default function withNavigation(router) {\n* @param {String} toRoute The route params\n*/\nfunction forward(fromRoute, toRoute) {\n- router.forwardMap[fromRoute] = toRoute\n+ router.config.forwardMap[fromRoute] = toRoute\nreturn router\n}\n@@ -47,7 +47,7 @@ export default function withNavigation(router) {\n* @return {Function} A cancel function\n*/\nfunction navigate(...args) {\n- const name = router.forwardMap[args[0]] || args[0]\n+ const name = router.config.forwardMap[args[0]] || args[0]\nconst lastArg = args[args.length - 1]\nconst done = typeof lastArg === 'function' ? lastArg : noop\nconst params = typeof args[1] === 'object' ? args[1] : {}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/utils.js", "new_path": "packages/router5/modules/core/utils.js", "diff": "@@ -127,7 +127,7 @@ export default function withUtils(router) {\noptions.useTrailingSlash === undefined\n? path\n: router.buildPath(name, params)\n- const routeName = router.forwardMap[name] || name\n+ const routeName = router.config.forwardMap[name] || name\nreturn router.makeState(routeName, params, builtPath, _meta, source)\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/create-router.js", "new_path": "packages/router5/modules/create-router.js", "diff": "@@ -34,6 +34,7 @@ function createRouter(routes, opts = {}, deps = {}) {\nObject.keys(opts).forEach(opt => setOption(opt, opts[opt]))\nconst router = {\n+ config: {},\nrootNode,\ngetOptions,\nsetOption,\n" } ]
TypeScript
MIT License
router5/router5
fix: fix clone function to include route specific config like forwardTo
580,249
24.01.2018 21:02:45
0
092c44a012ecb76260a7dbce38c11b1e17fba678
feat: add support for routing state params encoders and decoders
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/utils.js", "new_path": "packages/router5/modules/core/utils.js", "diff": "@@ -97,7 +97,11 @@ export default function withUtils(router) {\n}\nconst { useTrailingSlash, strictQueryParams } = options\n- return router.rootNode.buildPath(route, params, {\n+ const encodedParams = router.config.encoders[route]\n+ ? router.config.encoders[route](params)\n+ : params\n+\n+ return router.rootNode.buildPath(route, encodedParams, {\ntrailingSlash: useTrailingSlash,\nstrictQueryParams\n})\n@@ -123,13 +127,22 @@ export default function withUtils(router) {\nif (match) {\nconst { name, params, _meta } = match\n+ const decodedParams = router.config.decoders[name]\n+ ? router.config.decoders[name](params)\n+ : params\n+ const routeName = router.config.forwardMap[name] || name\nconst builtPath =\noptions.useTrailingSlash === undefined\n? path\n- : router.buildPath(name, params)\n- const routeName = router.config.forwardMap[name] || name\n-\n- return router.makeState(routeName, params, builtPath, _meta, source)\n+ : router.buildPath(routeName, decodedParams)\n+\n+ return router.makeState(\n+ routeName,\n+ decodedParams,\n+ builtPath,\n+ _meta,\n+ source\n+ )\n}\nreturn null\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/create-router.js", "new_path": "packages/router5/modules/create-router.js", "diff": "@@ -34,7 +34,10 @@ function createRouter(routes, opts = {}, deps = {}) {\nObject.keys(opts).forEach(opt => setOption(opt, opts[opt]))\nconst router = {\n- config: {},\n+ config: {\n+ decoders: {},\n+ encoders: {}\n+ },\nrootNode,\ngetOptions,\nsetOption,\n@@ -110,6 +113,12 @@ function createRouter(routes, opts = {}, deps = {}) {\nif (route.canActivate) router.canActivate(route.name, route.canActivate)\nif (route.forwardTo) router.forward(route.name, route.forwardTo)\n+\n+ if (route.decodeParams)\n+ router.config.decoders[route.name] = route.decodeParams\n+\n+ if (route.encodeParams)\n+ router.config.encoders[route.name] = route.encodeParams\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/_create-router.js", "new_path": "packages/router5/test/_create-router.js", "diff": "@@ -21,8 +21,21 @@ const profileRoute = new RouteNode('profile', '/profile', [\n{ name: 'user', path: '/:userId' }\n])\n+const otherRoute = {\n+ name: 'withEncoder',\n+ path: '/encoded/:param1/:param2',\n+ encodeParams: ({ one, two }) => ({\n+ param1: one,\n+ param2: two\n+ }),\n+ decodeParams: ({ param1, param2 }) => ({\n+ one: param1,\n+ two: param2\n+ })\n+}\n+\nexport default function createTestRouter(options) {\n- return createRouter([usersRoute, sectionRoute, profileRoute], {\n+ return createRouter([usersRoute, sectionRoute, profileRoute, otherRoute], {\ndefaultRoute: 'home',\n...options\n})\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/core/navigation.js", "new_path": "packages/router5/test/core/navigation.js", "diff": "@@ -187,4 +187,15 @@ describe('core/navigation', function() {\ndone()\n})\n})\n+\n+ it('should encode params to path', done => {\n+ router.navigate(\n+ 'withEncoder',\n+ { one: 'un', two: 'deux' },\n+ (err, state) => {\n+ expect(state.path).to.eql('/encoded/un/deux')\n+ done()\n+ }\n+ )\n+ })\n})\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/core/utils.js", "new_path": "packages/router5/test/core/utils.js", "diff": "@@ -50,6 +50,17 @@ describe('core/utils', () => {\nexpect(router.isActive('users.view', { id: 123 })).to.equal(false)\n})\n+ it('should decode path params on match', () => {\n+ expect(omitMeta(router.matchPath('/encoded/hello/123'))).to.eql({\n+ name: 'withEncoder',\n+ params: {\n+ one: 'hello',\n+ two: '123'\n+ },\n+ path: '/encoded/hello/123'\n+ })\n+ })\n+\nit('should match deep `/` routes', function() {\nrouter.setOption('useTrailingSlash', false)\nexpect(omitMeta(router.matchPath('/profile'))).to.eql({\n" } ]
TypeScript
MIT License
router5/router5
feat: add support for routing state params encoders and decoders
580,249
24.01.2018 21:47:38
0
64fd71b31f41a056c45cea7f1b1b209e5870d805
feat: add support for route default params
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/navigation.js", "new_path": "packages/router5/modules/core/navigation.js", "diff": "@@ -75,7 +75,7 @@ export default function withNavigation(router) {\nconst toState = router.makeState(\nroute.name,\nroute.params,\n- router.buildPath(name, params),\n+ router.buildPath(name, route.params),\nroute._meta\n)\nconst sameStates = router.getState()\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/utils.js", "new_path": "packages/router5/modules/core/utils.js", "diff": "@@ -108,7 +108,12 @@ export default function withUtils(router) {\n}\nfunction buildState(route, params) {\n- return router.rootNode.buildState(route, params)\n+ const finalParams = {\n+ ...router.config.defaultParams[route],\n+ ...params\n+ }\n+\n+ return router.rootNode.buildState(route, finalParams)\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/create-router.js", "new_path": "packages/router5/modules/create-router.js", "diff": "@@ -36,7 +36,8 @@ function createRouter(routes, opts = {}, deps = {}) {\nconst router = {\nconfig: {\ndecoders: {},\n- encoders: {}\n+ encoders: {},\n+ defaultParams: {}\n},\nrootNode,\ngetOptions,\n@@ -119,6 +120,9 @@ function createRouter(routes, opts = {}, deps = {}) {\nif (route.encodeParams)\nrouter.config.encoders[route.name] = route.encodeParams\n+\n+ if (route.defaultParams)\n+ router.config.defaultParams[route.name] = route.defaultParams\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/_create-router.js", "new_path": "packages/router5/test/_create-router.js", "diff": "@@ -21,6 +21,14 @@ const profileRoute = new RouteNode('profile', '/profile', [\n{ name: 'user', path: '/:userId' }\n])\n+const routeWithDefaultParams = {\n+ name: 'withDefaultParam',\n+ path: '/with-default/:param',\n+ defaultParams: {\n+ param: 'hello'\n+ }\n+}\n+\nconst otherRoute = {\nname: 'withEncoder',\npath: '/encoded/:param1/:param2',\n@@ -35,10 +43,19 @@ const otherRoute = {\n}\nexport default function createTestRouter(options) {\n- return createRouter([usersRoute, sectionRoute, profileRoute, otherRoute], {\n+ return createRouter(\n+ [\n+ usersRoute,\n+ sectionRoute,\n+ profileRoute,\n+ otherRoute,\n+ routeWithDefaultParams\n+ ],\n+ {\ndefaultRoute: 'home',\n...options\n- })\n+ }\n+ )\n.add(ordersRoute)\n.addNode('index', '/')\n.addNode('home', '/home')\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/core/navigation.js", "new_path": "packages/router5/test/core/navigation.js", "diff": "@@ -198,4 +198,12 @@ describe('core/navigation', function() {\n}\n)\n})\n+\n+ it('should extend default params', () => {\n+ router.navigate('withDefaultParam', (err, state) => {\n+ expect(state.params).to.eql({\n+ param: 'hello'\n+ })\n+ })\n+ })\n})\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/router/create-router.js", "new_path": "packages/router5/test/router/create-router.js", "diff": "import { expect } from 'chai'\nimport { spy } from 'sinon'\n-import createRouter, { RouteNode } from '../../modules'\n+import createRouter from '../../modules'\nconst canActivate = () => () => true\nconst routes = [\n" } ]
TypeScript
MIT License
router5/router5
feat: add support for route default params
580,249
25.01.2018 20:30:40
0
724126a27591459d9f7fb0bb912570c7834ebe1f
refactor: use default params on match after decoding
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/utils.js", "new_path": "packages/router5/modules/core/utils.js", "diff": "@@ -135,15 +135,19 @@ export default function withUtils(router) {\nconst decodedParams = router.config.decoders[name]\n? router.config.decoders[name](params)\n: params\n+ const finalParams = {\n+ ...router.config.defaultParams[name],\n+ ...decodedParams\n+ }\nconst routeName = router.config.forwardMap[name] || name\nconst builtPath =\noptions.useTrailingSlash === undefined\n? path\n- : router.buildPath(routeName, decodedParams)\n+ : router.buildPath(routeName, finalParams)\nreturn router.makeState(\nrouteName,\n- decodedParams,\n+ finalParams,\nbuiltPath,\n_meta,\nsource\n" } ]
TypeScript
MIT License
router5/router5
refactor: use default params on match after decoding
580,256
08.02.2018 08:50:53
-25,200
38cc67ef83529413b0f17773be46994e4a2fc877
fix: Fixed state ID generation to not duplicate on rehydration
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/create-router.js", "new_path": "packages/router5/modules/create-router.js", "diff": "@@ -186,6 +186,10 @@ function createRouter(routes, opts = {}, deps = {}) {\n*/\nfunction setState(state) {\nrouterState = state\n+\n+ if(state && state.meta && typeof state.meta.id === 'number'){\n+ stateId = state.meta.id\n+ }\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/core/router-lifecycle.js", "new_path": "packages/router5/test/core/router-lifecycle.js", "diff": "@@ -7,7 +7,7 @@ const homeState = {\nname: 'home',\nparams: {},\npath: '/home',\n- meta: { params: { home: {} } }\n+ meta: { id: 1, params: { home: {} } }\n}\ndescribe('core/router-lifecycle', function() {\n@@ -167,6 +167,17 @@ describe('core/router-lifecycle', function() {\n})\n})\n+ it('should not reuse id when starting with provided state', function(done) {\n+ router.stop()\n+ expect(homeState.meta.id).to.eql(1)\n+ router.start(homeState, function(err, state) {\n+ router.navigate('users', function(err, state) {\n+ expect(state.meta.id).to.not.eql(1)\n+ done()\n+ });\n+ })\n+ })\n+\nit('should return an error if default route access is not found', function(\ndone\n) {\n" } ]
TypeScript
MIT License
router5/router5
fix: Fixed state ID generation to not duplicate on rehydration
580,249
13.02.2018 23:10:10
0
b14647543ab6dd356bc812cd070f8f9222fe8103
fix: when forwarding, apply default params from initial and final routes
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/navigation.js", "new_path": "packages/router5/modules/core/navigation.js", "diff": "@@ -47,7 +47,7 @@ export default function withNavigation(router) {\n* @return {Function} A cancel function\n*/\nfunction navigate(...args) {\n- const name = router.config.forwardMap[args[0]] || args[0]\n+ const name = args[0]\nconst lastArg = args[args.length - 1]\nconst done = typeof lastArg === 'function' ? lastArg : noop\nconst params = typeof args[1] === 'object' ? args[1] : {}\n@@ -75,7 +75,7 @@ export default function withNavigation(router) {\nconst toState = router.makeState(\nroute.name,\nroute.params,\n- router.buildPath(name, route.params),\n+ router.buildPath(route.name, route.params),\nroute._meta\n)\nconst sameStates = router.getState()\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/utils.js", "new_path": "packages/router5/modules/core/utils.js", "diff": "@@ -107,13 +107,24 @@ export default function withUtils(router) {\n})\n}\n- function buildState(route, params) {\n- const finalParams = {\n- ...router.config.defaultParams[route],\n- ...params\n+ function forwardState(routeName, routeParams) {\n+ const name = router.config.forwardMap[routeName] || routeName\n+ const params = {\n+ ...router.config.defaultParams[routeName],\n+ ...router.config.defaultParams[name],\n+ ...routeParams\n+ }\n+\n+ return {\n+ name,\n+ params\n+ }\n}\n- return router.rootNode.buildState(route, finalParams)\n+ function buildState(routeName, routeParams) {\n+ const { name, params } = forwardState(routeName, routeParams)\n+\n+ return router.rootNode.buildState(name, params)\n}\n/**\n@@ -135,19 +146,18 @@ export default function withUtils(router) {\nconst decodedParams = router.config.decoders[name]\n? router.config.decoders[name](params)\n: params\n- const finalParams = {\n- ...router.config.defaultParams[name],\n- ...decodedParams\n- }\n- const routeName = router.config.forwardMap[name] || name\n+ const { name: routeName, params: routeParams } = forwardState(\n+ name,\n+ decodedParams\n+ )\nconst builtPath =\noptions.useTrailingSlash === undefined\n? path\n- : router.buildPath(routeName, finalParams)\n+ : router.buildPath(routeName, routeParams)\nreturn router.makeState(\nrouteName,\n- finalParams,\n+ routeParams,\nbuiltPath,\n_meta,\nsource\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/core/navigation.js", "new_path": "packages/router5/test/core/navigation.js", "diff": "import { expect } from 'chai'\n-import { constants, errorCodes } from '../../modules'\n+import { constants, errorCodes, createRouter } from '../../modules'\nimport createTestRouter from '../_create-router'\nimport { omitMeta } from '../_helpers'\nimport sinon, { spy } from 'sinon'\n@@ -182,6 +182,34 @@ describe('core/navigation', function() {\n})\n})\n+ it('should forward a route to another route on start', done => {\n+ const routerTest = createRouter([\n+ { name: 'app', path: '?:showVersion' },\n+ { name: 'app.ip', path: '/ip' },\n+ { name: 'app.ip.list', path: '/?:sort?:page' },\n+ {\n+ name: 'app.ip.item',\n+ path: '/:id',\n+ forwardTo: 'app.ip.item.view'\n+ },\n+ { name: 'app.ip.item.edit', path: '/edit' },\n+ {\n+ name: 'app.ip.item.view',\n+ path: '/:version',\n+ defaultParams: { version: 'active' }\n+ }\n+ ])\n+\n+ routerTest.start('/ip/2', (err, state) => {\n+ expect(state.name).to.equal('app.ip.item.view')\n+ expect(state.params).to.eql({\n+ id: '2',\n+ version: 'active'\n+ })\n+ done()\n+ })\n+ })\n+\nit('should encode params to path', done => {\nrouter.navigate(\n'withEncoder',\n" } ]
TypeScript
MIT License
router5/router5
fix: when forwarding, apply default params from initial and final routes
580,249
13.02.2018 23:17:14
0
4c4f9fb2a097ec13249897f2827142772dd7586e
test: update forwarding with default params test
[ { "change_type": "MODIFY", "old_path": "packages/router5/test/core/navigation.js", "new_path": "packages/router5/test/core/navigation.js", "diff": "@@ -182,29 +182,28 @@ describe('core/navigation', function() {\n})\n})\n- it('should forward a route to another route on start', done => {\n+ it('should forward a route to another with default params', done => {\nconst routerTest = createRouter([\n- { name: 'app', path: '?:showVersion' },\n- { name: 'app.ip', path: '/ip' },\n- { name: 'app.ip.list', path: '/?:sort?:page' },\n{\n- name: 'app.ip.item',\n- path: '/:id',\n- forwardTo: 'app.ip.item.view'\n+ name: 'app',\n+ path: '/app',\n+ forwardTo: 'app.version',\n+ defaultParams: {\n+ lang: 'en'\n+ }\n},\n- { name: 'app.ip.item.edit', path: '/edit' },\n{\n- name: 'app.ip.item.view',\n+ name: 'app.version',\npath: '/:version',\n- defaultParams: { version: 'active' }\n+ defaultParams: { version: 'v1' }\n}\n])\n- routerTest.start('/ip/2', (err, state) => {\n- expect(state.name).to.equal('app.ip.item.view')\n+ routerTest.start('/app', (err, state) => {\n+ expect(state.name).to.equal('app.version')\nexpect(state.params).to.eql({\n- id: '2',\n- version: 'active'\n+ version: 'v1',\n+ lang: 'en'\n})\ndone()\n})\n" } ]
TypeScript
MIT License
router5/router5
test: update forwarding with default params test
580,249
05.03.2018 09:22:02
0
38b9426b298d17fe51f1e6fe697b4cc73eb0fa8f
fix: update route-node to latest version (5.0.3)
[ { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "},\n\"homepage\": \"http://router5.github.io\",\n\"dependencies\": {\n- \"route-node\": \"2.0.2\",\n+ \"route-node\": \"2.0.3\",\n\"router5-transition-path\": \"^5.1.1\"\n},\n\"typings\": \"./index.d.ts\"\n" } ]
TypeScript
MIT License
router5/router5
fix: update route-node to latest version (5.0.3)
580,249
05.03.2018 10:08:38
0
d35c4d0463c7620ed809d77849c20695a5056ee2
chore: update router5 version
[ { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "{\n\"name\": \"router5\",\n- \"version\": \"5.8.2\",\n+ \"version\": \"5.8.3\",\n\"description\": \"A simple, powerful, view-agnostic, modular and extensible router\",\n\"main\": \"index.js\",\n\"jsnext:main\": \"dist/es/index.js\",\n" } ]
TypeScript
MIT License
router5/router5
chore: update router5 version
580,249
05.03.2018 10:10:33
0
2b22ccaafdf533da995b9b7dfde8bcb842497cc4
chore: revert version bump (will be done by lerna)
[ { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "{\n\"name\": \"router5\",\n- \"version\": \"5.8.3\",\n+ \"version\": \"5.8.2\",\n\"description\": \"A simple, powerful, view-agnostic, modular and extensible router\",\n\"main\": \"index.js\",\n\"jsnext:main\": \"dist/es/index.js\",\n" } ]
TypeScript
MIT License
router5/router5
chore: revert version bump (will be done by lerna)
580,249
06.03.2018 14:03:51
0
a1ec3c13b15b59dc387f32945a67ce5ab8afe4e9
feat: add successCallback and errorCallback props to React links
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/BaseLink.js", "new_path": "packages/react-router5/modules/BaseLink.js", "diff": "@@ -15,6 +15,7 @@ class BaseLink extends Component {\nthis.isActive = this.isActive.bind(this)\nthis.clickHandler = this.clickHandler.bind(this)\n+ this.callback = this.callback.bind(this)\nthis.state = { active: this.isActive() }\n}\n@@ -35,6 +36,16 @@ class BaseLink extends Component {\n)\n}\n+ callback(err, state) {\n+ if (!err && this.props.successCallback) {\n+ this.props.successCallback(state)\n+ }\n+\n+ if (err && this.props.errorCallback) {\n+ this.props.errorCallback(err)\n+ }\n+ }\n+\nclickHandler(evt) {\nif (this.props.onClick) {\nthis.props.onClick(evt)\n@@ -52,7 +63,8 @@ class BaseLink extends Component {\nthis.router.navigate(\nthis.props.routeName,\nthis.props.routeParams,\n- this.props.routeOptions\n+ this.props.routeOptions,\n+ this.callback\n)\n}\n}\n@@ -105,7 +117,9 @@ BaseLink.propTypes = {\nactiveClassName: PropTypes.string,\nactiveStrict: PropTypes.bool,\nonClick: PropTypes.func,\n- onMouseOver: PropTypes.func\n+ onMouseOver: PropTypes.func,\n+ successCallback: PropTypes.func,\n+ errorCallback: PropTypes.func\n}\nBaseLink.defaultProps = {\n" } ]
TypeScript
MIT License
router5/router5
feat: add successCallback and errorCallback props to React links
580,249
06.03.2018 14:20:10
0
f6371a888d6a2143b548f0a7838c90b2c3d409a2
fix: don't pass new callback prorps to underlying hyperlink
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/BaseLink.js", "new_path": "packages/react-router5/modules/BaseLink.js", "diff": "@@ -83,6 +83,8 @@ class BaseLink extends Component {\nrouter,\nchildren,\nonClick,\n+ successCallback,\n+ errorCallback,\n...linkProps\n} = this.props\n/* eslint-enable */\n" } ]
TypeScript
MIT License
router5/router5
fix: don't pass new callback prorps to underlying hyperlink
580,240
06.03.2018 17:03:33
21,600
ec55c14f898cd3b0e02a11a6d7daf05d46994879
feat(react-router5): Update type definitions This adds the `successCallback` and `errorCallback` properties to `BaseLink`.
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/index.d.ts", "new_path": "packages/react-router5/index.d.ts", "diff": "@@ -29,6 +29,8 @@ declare module 'react-router5' {\nactiveStrict?: boolean\nonClick?: MouseEventHandler<HTMLAnchorElement>\nonMouseOver?: MouseEventHandler<HTMLAnchorElement>\n+ successCallback?(state: State): void\n+ errorCallback?(err: any): void\n}\nexport const BaseLink: ComponentClass<BaseLinkProps>\n" } ]
TypeScript
MIT License
router5/router5
feat(react-router5): Update type definitions This adds the `successCallback` and `errorCallback` properties to `BaseLink`.
580,249
14.03.2018 17:46:34
0
692bc375333bb28fed7f21bd879df4a91fb83d1b
refactor: change makeState signature BREAKING CHANGE: private method router.makeState signature has changed
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/navigation.js", "new_path": "packages/router5/modules/core/navigation.js", "diff": "@@ -76,7 +76,7 @@ export default function withNavigation(router) {\nroute.name,\nroute.params,\nrouter.buildPath(route.name, route.params),\n- route._meta\n+ { params: route._meta }\n)\nconst sameStates = router.getState()\n? router.areStatesEqual(router.getState(), toState, false)\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/utils.js", "new_path": "packages/router5/modules/core/utils.js", "diff": "@@ -155,13 +155,10 @@ export default function withUtils(router) {\n? path\n: router.buildPath(routeName, routeParams)\n- return router.makeState(\n- routeName,\n- routeParams,\n- builtPath,\n- _meta,\n+ return router.makeState(routeName, routeParams, builtPath, {\n+ params: _meta,\nsource\n- )\n+ })\n}\nreturn null\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/create-router.js", "new_path": "packages/router5/modules/create-router.js", "diff": "@@ -135,7 +135,7 @@ function createRouter(routes, opts = {}, deps = {}) {\n* @param {Number} [forceId] The ID to use in meta (incremented by default)\n* @return {Object} The state object\n*/\n- function makeState(name, params, path, metaParams, source, forceId) {\n+ function makeState(name, params, path, meta, forceId) {\nconst state = {}\nconst setProp = (key, value) =>\nObject.defineProperty(state, key, { value, enumerable: true })\n@@ -143,7 +143,7 @@ function createRouter(routes, opts = {}, deps = {}) {\nsetProp('params', params)\nsetProp('path', path)\n- if (metaParams || source) {\n+ if (meta) {\nlet finalStateId\nif (forceId === undefined) {\n@@ -153,11 +153,7 @@ function createRouter(routes, opts = {}, deps = {}) {\nfinalStateId = forceId\n}\n- const meta = { params: metaParams, id: finalStateId }\n-\n- if (source) meta.source = source\n-\n- setProp('meta', meta)\n+ setProp('meta', { ...meta, id: finalStateId })\n}\nreturn state\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/plugins/browser/index.js", "new_path": "packages/router5/modules/plugins/browser/index.js", "diff": "@@ -70,8 +70,7 @@ function browserPluginFactory(opts = {}, browser = safeBrowser) {\nevt.state.name,\nevt.state.params,\nevt.state.path,\n- evt.state.meta.params,\n- source,\n+ { ...evt.state.meta, source },\nevt.state.meta.id\n)\nconst { defaultRoute, defaultParams } = routerOptions\n" } ]
TypeScript
MIT License
router5/router5
refactor: change makeState signature BREAKING CHANGE: private method router.makeState signature has changed
580,249
15.03.2018 13:55:59
0
418c09e5236c054f46bbdb387cb64aebd07c56df
feat: add navigation options to state meta
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/navigation.js", "new_path": "packages/router5/modules/core/navigation.js", "diff": "@@ -76,7 +76,7 @@ export default function withNavigation(router) {\nroute.name,\nroute.params,\nrouter.buildPath(route.name, route.params),\n- { params: route._meta }\n+ { params: route._meta, options: opts }\n)\nconst sameStates = router.getState()\n? router.areStatesEqual(router.getState(), toState, false)\n@@ -109,7 +109,12 @@ export default function withNavigation(router) {\nif (err.redirect) {\nconst { name, params } = err.redirect\n- navigate(name, params, { ...opts, force: true }, done)\n+ navigate(\n+ name,\n+ params,\n+ { ...opts, force: true, redirected: true },\n+ done\n+ )\n} else {\ndone(err)\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/router-lifecycle.js", "new_path": "packages/router5/modules/core/router-lifecycle.js", "diff": "@@ -80,7 +80,7 @@ export default function withRouterLifecycle(router) {\nrouter.navigate(\nroute.name,\nroute.params,\n- { replace: true, reload: true },\n+ { replace: true, reload: true, redirected: true },\ndone\n)\nconst transitionToState = state => {\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/plugins/browser/index.js", "new_path": "packages/router5/modules/plugins/browser/index.js", "diff": "@@ -105,7 +105,8 @@ function browserPluginFactory(opts = {}, browser = safeBrowser) {\nrouter.navigate(name, params, {\n...transitionOptions,\nreplace: true,\n- force: true\n+ force: true,\n+ redirected: true\n})\n} else if (err.code === errorCodes.CANNOT_DEACTIVATE) {\nconst url = router.buildUrl(\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/transition/resolve.js", "new_path": "packages/router5/modules/transition/resolve.js", "diff": "@@ -12,27 +12,43 @@ export default function resolve(\nobj.name !== undefined &&\nobj.params !== undefined &&\nobj.path !== undefined\n- const hasStateChanged = state =>\n- state.name !== toState.name ||\n- state.params !== toState.params ||\n- state.path !== toState.path\n+ const hasStateChanged = (toState, fromState) =>\n+ fromState.name !== toState.name ||\n+ fromState.params !== toState.params ||\n+ fromState.path !== toState.path\n- const processFn = done => {\n- if (!remainingFunctions.length) return true\n+ const mergeStates = (toState, fromState) => ({\n+ ...fromState,\n+ ...toState,\n+ meta: {\n+ ...fromState.meta,\n+ ...toState.meta\n+ }\n+ })\n- const isMapped = typeof remainingFunctions[0] === 'string'\n- const errBase =\n- errorKey && isMapped ? { [errorKey]: remainingFunctions[0] } : {}\n- let stepFn = isMapped\n- ? functions[remainingFunctions[0]]\n- : remainingFunctions[0]\n+ const processFn = (stepFn, errBase, state, _done) => {\n+ const done = (err, newState) => {\n+ if (err) {\n+ _done(err)\n+ } else if (newState && newState !== state && isState(newState)) {\n+ if (hasStateChanged(newState, state)) {\n+ console.error(\n+ '[router5][transition] Warning: state values (name, params, path) were changed during transition process.'\n+ )\n+ }\n- // const len = stepFn.length;\n+ _done(null, mergeStates(newState, state))\n+ } else {\n+ _done(null, state)\n+ }\n+ }\nconst res = stepFn.call(null, toState, fromState, done)\nif (isCancelled()) {\ndone(null)\n} else if (typeof res === 'boolean') {\ndone(res ? null : errBase)\n+ } else if (isState(res)) {\n+ done(null, res)\n} else if (res && typeof res.then === 'function') {\nres.then(\nresVal => {\n@@ -55,36 +71,32 @@ export default function resolve(\n)\n}\n// else: wait for done to be called\n-\n- return false\n}\n- const iterate = (err, val) => {\n+ const next = (err, state) => {\nif (isCancelled()) {\ncallback()\n} else if (err) {\ncallback(err)\n} else {\n- if (val && isState(val)) {\n- if (hasStateChanged(val))\n- console.error(\n- '[router5][transition] Warning: state values changed during transition process.'\n- )\n- toState = val\n- }\n+ if (!remainingFunctions.length) {\n+ callback(null, state)\n+ } else {\n+ const isMapped = typeof remainingFunctions[0] === 'string'\n+ const errBase =\n+ errorKey && isMapped\n+ ? { [errorKey]: remainingFunctions[0] }\n+ : {}\n+ let stepFn = isMapped\n+ ? functions[remainingFunctions[0]]\n+ : remainingFunctions[0]\n+\nremainingFunctions = remainingFunctions.slice(1)\n- next()\n- }\n- }\n- const next = () => {\n- if (isCancelled()) {\n- callback()\n- } else {\n- const finished = processFn(iterate)\n- if (finished) callback(null, toState)\n+ processFn(stepFn, errBase, state, next)\n+ }\n}\n}\n- next()\n+ next(null, toState)\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/core/navigation.js", "new_path": "packages/router5/test/core/navigation.js", "diff": "@@ -227,4 +227,11 @@ describe('core/navigation', function() {\n})\n})\n})\n+\n+ it('should add navitation options to meta', () => {\n+ const options = { reload: true, replace: true, customOption: 'abc' }\n+ router.navigate('profile', {}, options, (err, state) => {\n+ expect(state.meta.options).to.eql(options)\n+ })\n+ })\n})\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/plugins/listeners.js", "new_path": "packages/router5/test/plugins/listeners.js", "diff": "@@ -30,7 +30,11 @@ describe('listenersPlugin', function() {\nrouter.start(function(err, state) {\nexpect(state).to.eql({\n- meta: { id: 1, params: { home: {} } },\n+ meta: {\n+ id: 1,\n+ options: { replace: true },\n+ params: { home: {} }\n+ },\nname: 'home',\npath: '/home',\nparams: {}\n" } ]
TypeScript
MIT License
router5/router5
feat: add navigation options to state meta
580,249
15.03.2018 14:25:56
0
2d3dc1d22cf1b5517030e4ed3a95a947d40f50b2
fix: support URL changes in IE11 when 'useHash' is true
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/plugins/browser/browser.js", "new_path": "packages/router5/modules/plugins/browser/browser.js", "diff": "@@ -16,15 +16,30 @@ const isBrowser = typeof window !== 'undefined' && window.history\n*/\nconst getBase = () => window.location.pathname.replace(/\\/$/, '')\n+const supportsPopStateOnHashChange = () =>\n+ window.navigator.userAgent.indexOf('Trident') === -1\n+\nconst pushState = (state, title, path) =>\nwindow.history.pushState(state, title, path)\nconst replaceState = (state, title, path) =>\nwindow.history.replaceState(state, title, path)\n-const addPopstateListener = fn => window.addEventListener('popstate', fn)\n+const addPopstateListener = fn => {\n+ window.addEventListener('popstate', fn)\n+\n+ if (!supportsPopStateOnHashChange()) {\n+ window.addEventListeners('hashchange', fn)\n+ }\n+}\n-const removePopstateListener = fn => window.removeEventListener('popstate', fn)\n+const removePopstateListener = fn => {\n+ window.removeEventListener('popstate', fn)\n+\n+ if (!supportsPopStateOnHashChange()) {\n+ window.removeEventListener('hashchange', fn)\n+ }\n+}\nconst getLocation = opts => {\nconst path = opts.useHash\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/plugins/browser/index.js", "new_path": "packages/router5/modules/plugins/browser/index.js", "diff": "@@ -60,7 +60,7 @@ function browserPluginFactory(opts = {}, browser = safeBrowser) {\nelse browser.pushState(finalState, '', url)\n}\n- function onPopState(evt) {\n+ function onPopState(evt = {}) {\nconst routerState = router.getState()\n// Do nothing if no state or if last know state is poped state (it should never happen)\nconst newState = !evt.state || !evt.state.name\n" } ]
TypeScript
MIT License
router5/router5
fix: support URL changes in IE11 when 'useHash' is true
580,249
15.03.2018 22:05:29
0
98e553e4a18819be698f1a9ca36730aa0a9c0347
test: add middleware chaining tests
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/transition/resolve.js", "new_path": "packages/router5/modules/transition/resolve.js", "diff": "@@ -42,7 +42,7 @@ export default function resolve(\n_done(null, state)\n}\n}\n- const res = stepFn.call(null, toState, fromState, done)\n+ const res = stepFn.call(null, state, fromState, done)\nif (isCancelled()) {\ndone(null)\n} else if (typeof res === 'boolean') {\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/core/middleware.js", "new_path": "packages/router5/test/core/middleware.js", "diff": "@@ -103,4 +103,26 @@ describe('core/middleware', () => {\n})\n})\n})\n+\n+ it('should pass state from middleware to middleware', () => {\n+ const m1 = () => (toState, fromState, done) => {\n+ done(null, { ...toState, m1: true })\n+ }\n+ const m2 = () => toState =>\n+ Promise.resolve({ ...toState, m2: toState.m1 })\n+\n+ const m3 = () => (toState, fromState, done) => {\n+ done(null, { ...toState, m3: toState.m3 })\n+ }\n+ router.clearMiddleware()\n+ router.useMiddleware(m1, m2, m3)\n+\n+ router.start('', () => {\n+ router.navigate('users', function(err, state) {\n+ expect(state.m1).to.equal(true)\n+ expect(state.m2).to.equal(true)\n+ expect(state.m3).to.equal(true)\n+ })\n+ })\n+ })\n})\n" } ]
TypeScript
MIT License
router5/router5
test: add middleware chaining tests
580,249
15.03.2018 22:21:41
0
e2e09b4056ea29d3211473be1c643a38cbfb981d
refacto: update doc blocks
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/create-router.js", "new_path": "packages/router5/modules/create-router.js", "diff": "@@ -130,8 +130,7 @@ function createRouter(routes, opts = {}, deps = {}) {\n* @param {String} name The state name\n* @param {Object} params The state params\n* @param {String} path The state path\n- * @param {Object} [metaParams] Description of the state params\n- * @param {String} [source] The source of the routing state\n+ * @param {Object} [meta] The meta object\n* @param {Number} [forceId] The ID to use in meta (incremented by default)\n* @return {Object} The state object\n*/\n@@ -162,6 +161,7 @@ function createRouter(routes, opts = {}, deps = {}) {\n/**\n* Build a not found state for a given path\n* @param {String} path The unmatched path\n+ * @param {Object} [options] The navigation options\n* @return {Object} The not found state object\n*/\nfunction makeNotFoundState(path, options) {\n" } ]
TypeScript
MIT License
router5/router5
refacto: update doc blocks
580,249
03.04.2018 20:52:21
-3,600
39ef295be6f8b0b322a7fa404ac88a4bd2972cf1
refactor: update to route-node v3
[ { "change_type": "MODIFY", "old_path": "packages/router5/index.d.ts", "new_path": "packages/router5/index.d.ts", "diff": "@@ -97,6 +97,11 @@ declare module 'router5/constants' {\ndeclare module 'router5/create-router' {\nimport { ActivationFnFactory } from 'router5/core/route-lifecycle'\nimport { Options as NavigationOptions } from 'router5/core/navigation'\n+ import {\n+ TrailingSlashMode,\n+ QueryParamsMode,\n+ QueryParamsOptions\n+ } from 'route-node'\nexport interface Dependencies {\n[key: string]: any\n@@ -133,14 +138,16 @@ declare module 'router5/create-router' {\n}\nexport interface Options {\n- defaultRoute: string\n- defaultParams: Params\n- trailingSlash: boolean\n- useTrailingSlash: boolean\n- autoCleanUp: boolean\n- strictQueryParams: boolean\n- allowNotFound: boolean\n- strongMatching: boolean\n+ defaultRoute?: string\n+ defaultParams?: Params\n+ strictTrailingSlash?: boolean\n+ trailingSlashMode?: TrailingSlashMode\n+ queryParamsMode?: QueryParamsMode\n+ autoCleanUp?: boolean\n+ allowNotFound?: boolean\n+ strongMatching?: boolean\n+ rewritePathOnMatch?: boolean\n+ queryParams?: QueryParamsOptions\n}\nexport interface Router {\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/navigation.js", "new_path": "packages/router5/modules/core/navigation.js", "diff": "@@ -76,7 +76,7 @@ export default function withNavigation(router) {\nroute.name,\nroute.params,\nrouter.buildPath(route.name, route.params),\n- { params: route._meta, options: opts }\n+ { params: route.meta, options: opts }\n)\nconst sameStates = router.getState()\n? router.areStatesEqual(router.getState(), toState, false)\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/router-lifecycle.js", "new_path": "packages/router5/modules/core/router-lifecycle.js", "diff": "@@ -4,7 +4,6 @@ const noop = function() {}\nexport default function withRouterLifecycle(router) {\nlet started = false\n- const options = router.getOptions()\nrouter.isStarted = isStarted\nrouter.start = start\n@@ -25,6 +24,7 @@ export default function withRouterLifecycle(router) {\n* @return {Object} The router instance\n*/\nfunction start(...args) {\n+ const options = router.getOptions()\nconst lastArg = args[args.length - 1]\nconst done = typeof lastArg === 'function' ? lastArg : noop\nconst startPathOrState =\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/utils.js", "new_path": "packages/router5/modules/core/utils.js", "diff": "import constants from '../constants'\nexport default function withUtils(router) {\n- const options = router.getOptions()\n-\nrouter.isActive = isActive\nrouter.areStatesEqual = areStatesEqual\nrouter.areStatesDescendants = areStatesDescendants\n@@ -96,14 +94,19 @@ export default function withUtils(router) {\nreturn params.path\n}\n- const { useTrailingSlash, strictQueryParams } = options\n+ const {\n+ trailingSlashMode,\n+ queryParamsMode,\n+ queryParams\n+ } = router.getOptions()\nconst encodedParams = router.config.encoders[route]\n? router.config.encoders[route](params)\n: params\nreturn router.rootNode.buildPath(route, encodedParams, {\n- trailingSlash: useTrailingSlash,\n- strictQueryParams\n+ trailingSlashMode,\n+ queryParamsMode,\n+ queryParams\n})\n}\n@@ -134,15 +137,11 @@ export default function withUtils(router) {\n* @return {Object} The matched state (null if unmatched)\n*/\nfunction matchPath(path, source) {\n- const { trailingSlash, strictQueryParams, strongMatching } = options\n- const match = router.rootNode.matchPath(path, {\n- trailingSlash,\n- strictQueryParams,\n- strongMatching\n- })\n+ const options = router.getOptions()\n+ const match = router.rootNode.matchPath(path, options)\nif (match) {\n- const { name, params, _meta } = match\n+ const { name, params, meta } = match\nconst decodedParams = router.config.decoders[name]\n? router.config.decoders[name](params)\n: params\n@@ -151,12 +150,12 @@ export default function withUtils(router) {\ndecodedParams\n)\nconst builtPath =\n- options.useTrailingSlash === undefined\n+ options.rewritePathOnMatch === false\n? path\n: router.buildPath(routeName, routeParams)\nreturn router.makeState(routeName, routeParams, builtPath, {\n- params: _meta,\n+ params: meta,\nsource\n})\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/create-router.js", "new_path": "packages/router5/modules/create-router.js", "diff": "@@ -9,12 +9,13 @@ import withCloning from './core/clone'\nimport constants from './constants'\nconst defaultOptions = {\n- trailingSlash: 0,\n- useTrailingSlash: undefined,\n+ trailingSlashMode: 'default',\n+ queryParamsMode: 'default',\n+ strictTrailingSlash: false,\nautoCleanUp: true,\n- strictQueryParams: false,\nallowNotFound: false,\n- strongMatching: true\n+ strongMatching: true,\n+ rewritePathOnMatch: true\n}\n/**\n@@ -203,9 +204,6 @@ function createRouter(routes, opts = {}, deps = {}) {\n* @return {Object} The router instance\n*/\nfunction setOption(option, value) {\n- if (option === 'useTrailingSlash' && value !== undefined) {\n- options.trailingSlash = true\n- }\noptions[option] = value\nreturn router\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/plugins/browser/index.js", "new_path": "packages/router5/modules/plugins/browser/index.js", "diff": "@@ -56,6 +56,7 @@ function browserPluginFactory(opts = {}, browser = safeBrowser) {\noptions.mergeState === true\n? { ...browser.getState(), ...trimmedState }\n: trimmedState\n+\nif (replace) browser.replaceState(finalState, '', url)\nelse browser.pushState(finalState, '', url)\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "},\n\"homepage\": \"http://router5.github.io\",\n\"dependencies\": {\n- \"route-node\": \"2.0.3\",\n+ \"route-node\": \"3.0.2\",\n\"router5-transition-path\": \"^5.1.1\"\n},\n\"typings\": \"./index.d.ts\"\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/_create-router.js", "new_path": "packages/router5/test/_create-router.js", "diff": "@@ -13,7 +13,7 @@ const ordersRoute = new RouteNode('orders', '/orders', [\nconst sectionRoute = new RouteNode('section', '/:section<section[\\\\d]+>', [\nnew RouteNode('view', '/view/:id'),\n- new RouteNode('query', '/query?param1[]&param2&param3')\n+ new RouteNode('query', '/query?param1&param2&param3')\n])\nconst profileRoute = new RouteNode('profile', '/profile', [\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/core/router-lifecycle.js", "new_path": "packages/router5/test/core/router-lifecycle.js", "diff": "@@ -20,7 +20,7 @@ describe('core/router-lifecycle', function() {\nexpect(router.getState()).to.equal(null)\nexpect(router.isActive('home')).to.equal(false)\n- router.start('', function() {\n+ router.start('/not-existing', function() {\nexpect(router.isStarted()).to.equal(true)\nexpect(omitMeta(router.getState())).to.eql({\nname: 'home',\n@@ -55,14 +55,14 @@ describe('core/router-lifecycle', function() {\nit('should start with the start route if matched', function(done) {\nrouter.stop()\n- router.start('/section123/query?param1[]=1__1&param1[]=2__2', function(\n+ router.start('/section123/query?param1=1__1&param1=2__2', function(\nerr,\nstate\n) {\nexpect(omitMeta(state)).to.eql({\nname: 'section.query',\nparams: { section: 'section123', param1: ['1__1', '2__2'] },\n- path: '/section123/query?param1[]=1__1&param1[]=2__2'\n+ path: '/section123/query?param1=1__1&param1=2__2'\n})\ndone()\n})\n@@ -117,31 +117,31 @@ describe('core/router-lifecycle', function() {\nit('should start with a not found error if no matched start state and no default route', function(done) {\nrouter.stop()\nrouter.setOption('defaultRoute', null)\n- router.start('', function(err) {\n+ router.start('/not-existing', function(err) {\nexpect(err.code).to.equal(errorCodes.ROUTE_NOT_FOUND)\ndone()\n})\n})\nit('should not match an URL with extra trailing slashes', function(done) {\n+ router.setOption('strictTrailingSlash', true)\nrouter.stop()\nrouter.start('/users/list/', function(err, state) {\nexpect(err.code).to.equal(errorCodes.ROUTE_NOT_FOUND)\nexpect(state).to.equal(null)\n+ router.setOption('strictTrailingSlash', false)\ndone()\n})\n})\nit('should match an URL with extra trailing slashes', function(done) {\n- router.setOption('trailingSlash', 1)\nrouter.stop()\nrouter.start('/users/list/', function(err, state) {\nexpect(omitMeta(state)).to.eql({\nname: 'users.list',\nparams: {},\n- path: '/users/list/'\n+ path: '/users/list'\n})\n- router.setOption('trailingSlash', 0)\ndone()\n})\n})\n@@ -170,7 +170,7 @@ describe('core/router-lifecycle', function() {\nrouter.stop()\nrouter.setOption('defaultRoute', 'fake.route')\n- router.start('', function(err, state) {\n+ router.start('/not-existing', function(err, state) {\nexpect(err.code).to.equal(errorCodes.ROUTE_NOT_FOUND)\ndone()\n})\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/core/utils.js", "new_path": "packages/router5/test/core/utils.js", "diff": "@@ -62,14 +62,14 @@ describe('core/utils', () => {\n})\nit('should match deep `/` routes', function() {\n- router.setOption('useTrailingSlash', false)\n+ router.setOption('trailingSlashMode', 'never')\nexpect(omitMeta(router.matchPath('/profile'))).to.eql({\nname: 'profile.me',\nparams: {},\npath: '/profile'\n})\n- router.setOption('useTrailingSlash', true)\n+ router.setOption('trailingSlashMode', 'always')\nexpect(omitMeta(router.matchPath('/profile'))).to.eql({\nname: 'profile.me',\nparams: {},\n@@ -78,10 +78,10 @@ describe('core/utils', () => {\n})\n})\n- context('without strictQueryParams', () => {\n+ context('without strict query params mode', () => {\nbefore(\n() =>\n- (router = createTestRouter({ strictQueryParams: false })\n+ (router = createTestRouter({ queryParamsMode: 'loose' })\n.clone()\n.start())\n)\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/plugins/browser.js", "new_path": "packages/router5/test/plugins/browser.js", "diff": "@@ -9,14 +9,18 @@ const base = window.location.pathname\nlet router\nconst hashPrefix = '!'\n+let currentHistoryState\nconst mockedBrowser = {\n...browser,\ngetBase: () => base,\n- pushState: spy(),\n- replaceState: spy(),\n+ pushState: state => (currentHistoryState = state),\n+ replaceState: state => (currentHistoryState = state),\naddPopstateListener: spy(),\n- removePopstateListener: spy()\n+ removePopstateListener: spy(),\n+ getState: () => currentHistoryState\n}\n+spy(mockedBrowser, 'pushState')\n+spy(mockedBrowser, 'replaceState')\nfunction withoutMeta(state) {\nif (!state.meta.id) {\n@@ -46,9 +50,8 @@ function test(useHash) {\ndescribe(useHash ? 'With hash' : 'Without hash', function() {\nbefore(function() {\n- // window.history.replaceState({}, '', base);\n- if (router) router.stop()\nrouter = createTestRouter()\n+ currentHistoryState = undefined\nrouter.usePlugin(\nbrowserPlugin({ base, useHash, hashPrefix }, mockedBrowser)\n)\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/typescript/create-router.ts", "new_path": "packages/router5/test/typescript/create-router.ts", "diff": "@@ -11,10 +11,10 @@ const routes: Route[] = [\nconst options: Options = {\ndefaultRoute: 'home',\ndefaultParams: { lang: 'en' },\n- trailingSlash: false,\n- useTrailingSlash: false,\n+ strictTrailingSlash: false,\n+ trailingSlashMode: 'never',\nautoCleanUp: true,\n- strictQueryParams: false,\n+ queryParamsMode: 'default',\nallowNotFound: false,\nstrongMatching: true\n}\n@@ -26,7 +26,10 @@ const router = createRouter([])\nlet r: Router\nr = createRouter(routes)\nr = createRouter(routes, options)\n-r = createRouter(routes, { trailingSlash: true, strictQueryParams: true })\n+r = createRouter(routes, {\n+ strictTrailingSlash: true,\n+ queryParamsMode: 'strict'\n+})\nr = createRouter(routes, options, deps)\nlet s: State\n@@ -45,7 +48,7 @@ const _o: Options = router.getOptions()\nr = router.setOption('defaultRoute', 'home')\nr = router.setOption('defaultParams', { lang: 'en' })\n-r = router.setOption('strictQueryParams', true)\n+r = router.setOption('queryParamsMode', 'strict')\nr = router.setDependency('store', {})\nr = router.setDependency('counter', 0)\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/yarn.lock", "new_path": "packages/router5/yarn.lock", "diff": "# yarn lockfile v1\[email protected]:\n- version \"3.0.1\"\n- resolved \"https://registry.yarnpkg.com/path-parser/-/path-parser-3.0.1.tgz#90abf7d98af74b1f7da6d312786591a51c887619\"\[email protected]:\n+ version \"4.0.3\"\n+ resolved \"https://registry.yarnpkg.com/path-parser/-/path-parser-4.0.3.tgz#237ad649aad0d850ff58ac83335909b579035592\"\ndependencies:\n- search-params \"~1.3.0\"\n+ search-params \"2.1.2\"\[email protected]:\n- version \"2.0.3\"\n- resolved \"https://registry.yarnpkg.com/route-node/-/route-node-2.0.3.tgz#f1da1fb058313820994086df984aa6103abdbc9e\"\[email protected]:\n+ version \"3.0.2\"\n+ resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.0.2.tgz#fd41729ab0ba644369b08cad0ac4c3e0e282fb92\"\ndependencies:\n- path-parser \"3.0.1\"\n- search-params \"~1.3.0\"\n+ path-parser \"4.0.3\"\n+ search-params \"2.1.2\"\n-search-params@~1.3.0:\n- version \"1.3.0\"\n- resolved \"https://registry.yarnpkg.com/search-params/-/search-params-1.3.0.tgz#ba1e1c01dcbd8a2e41a25236f602f2cbf710d688\"\[email protected]:\n+ version \"2.1.2\"\n+ resolved \"https://registry.yarnpkg.com/search-params/-/search-params-2.1.2.tgz#e0107b7e6f2e973d7991b8fbffc8b6664bc96edd\"\n" } ]
TypeScript
MIT License
router5/router5
refactor: update to route-node v3
580,249
04.04.2018 22:54:25
-3,600
0ced8e32f7e570b31869c720786b726d2b67e235
feat: add RouteProvider and Route components, using React's new context API
[ { "change_type": "MODIFY", "old_path": ".eslintrc", "new_path": ".eslintrc", "diff": "{\n- \"extends\": \"eslint:recommended\",\n+ \"extends\": [\n+ \"eslint:recommended\"\n+ ],\n// Parser\n\"parser\": \"babel-eslint\",\n+ \"plugins\": [\n+ \"react\"\n+ ],\n// ECMA Features\n\"parserOptions\": {\n\"ecmaVersion\": 6,\n\"destructuring\": true,\n\"modules\": true,\n\"objectLiteralComputedProperties\": true,\n- \"templateStrings\": true\n+ \"templateStrings\": true,\n+ \"jsx\": true\n}\n},\n\"rules\": {\n\"no-var\": 2,\n\"no-this-before-super\": 2,\n\"object-shorthand\": 2,\n+ // React\n+ \"react/jsx-uses-react\": 2,\n+ \"react/jsx-uses-vars\": 2,\n+ \"react/react-in-jsx-scope\": 2\n},\n\"env\": {\n\"node\": true,\n" }, { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"enzyme\": \"~2.8.2\",\n\"eslint\": \"~4.0.0\",\n\"eslint-config-prettier\": \"^2.7.0\",\n- \"eslint-plugin-react\": \"~7.1.0\",\n+ \"eslint-plugin-react\": \"~7.7.0\",\n\"express\": \"~4.15.3\",\n\"html-loader\": \"~0.4.5\",\n\"html-webpack-plugin\": \"~2.28.0\",\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/react-router5/modules/RouteProvider.js", "diff": "+import React from 'react'\n+import PropTypes from 'prop-types'\n+import transitionPath from 'router5-transition-path'\n+import { ifNot } from './utils'\n+\n+const emptyCreateContext = () => ({\n+ Provider: _ => _,\n+ Consumer: () => null\n+})\n+const createContext = React.createContext || emptyCreateContext\n+\n+const { Provider, Consumer: Route } = createContext({\n+ route: null,\n+ previousRoute: null\n+})\n+\n+class RouteProvider extends React.PureComponent {\n+ constructor(props) {\n+ super(props)\n+ const { router } = props\n+\n+ this.state = {\n+ route: router.getState()\n+ }\n+ this.listener = this.listener.bind(this)\n+ }\n+\n+ listener(toState, fromState) {\n+ this.setState({\n+ route: toState,\n+ previousRoute: fromState\n+ })\n+ }\n+\n+ componentDidMount() {\n+ ifNot(\n+ this.router.hasPlugin('LISTENERS_PLUGIN'),\n+ '[react-router5][RouteProvider] missing listeners plugin'\n+ )\n+\n+ this.listener = (toState, fromState) =>\n+ this.setState({ previousRoute: fromState, route: toState })\n+ this.router.addListener(this.listener)\n+ }\n+\n+ componentWillUnmount() {\n+ this.router.removeListener(this.listener)\n+ }\n+\n+ render() {\n+ return (\n+ <Provider value={this.state.route}>{this.props.children}</Provider>\n+ )\n+ }\n+}\n+\n+class RouteNodeConsumer extends React.Component {\n+ shouldComponentUpdate(nextProps) {\n+ const { intersection } = transitionPath(\n+ nextProps.routeContext.route,\n+ nextProps.routeContext.previousRoute\n+ )\n+\n+ return intersection === nextProps.nodeName\n+ }\n+\n+ render() {\n+ return this.props.children(this.props.routeContext)\n+ }\n+}\n+\n+RouteNodeConsumer.propTypes = {\n+ nodeName: PropTypes.string.isRequired,\n+ children: PropTypes.function.isRequired\n+}\n+\n+function RouteNode(props) {\n+ return (\n+ <Route>\n+ {routeContext => (\n+ <RouteNodeConsumer {...props} routeContext={routeContext} />\n+ )}\n+ </Route>\n+ )\n+}\n+\n+RouteProvider.propTypes = {\n+ router: PropTypes.object.isRequired,\n+ children: PropTypes.node.isRequired\n+}\n+\n+export { RouteProvider, Route, RouteNode }\n" }, { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/index.js", "new_path": "packages/react-router5/modules/index.js", "diff": "@@ -2,7 +2,17 @@ import BaseLink from './BaseLink'\nimport routeNode from './routeNode'\nimport RouterProvider from './RouterProvider'\nimport withRoute from './withRoute'\n+import { RouteProvider, Route, RouteNode } from './RouteProvider'\nconst Link = withRoute(BaseLink)\n-export { BaseLink, routeNode, RouterProvider, withRoute, Link }\n+export {\n+ BaseLink,\n+ routeNode,\n+ RouterProvider,\n+ withRoute,\n+ Link,\n+ RouteProvider,\n+ Route,\n+ RouteNode\n+}\n" }, { "change_type": "MODIFY", "old_path": "packages/react-router5/package.json", "new_path": "packages/react-router5/package.json", "diff": "\"router5\": \"^5.0.1\"\n},\n\"dependencies\": {\n- \"prop-types\": \"~15.5.10\"\n+ \"prop-types\": \"~15.5.10\",\n+ \"router5-transition-path\": \"^5.0.0\"\n},\n\"typings\": \"./index.d.ts\"\n}\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "@@ -163,6 +163,13 @@ array-ify@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece\"\n+array-includes@^3.0.3:\n+ version \"3.0.3\"\n+ resolved \"https://registry.yarnpkg.com/array-includes/-/array-includes-3.0.3.tgz#184b48f62d92d7452bb31b323165c7f8bd02266d\"\n+ dependencies:\n+ define-properties \"^1.1.2\"\n+ es-abstract \"^1.7.0\"\n+\narray-union@^1.0.1:\nversion \"1.0.2\"\nresolved \"https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39\"\n@@ -1733,6 +1740,12 @@ doctrine@^2.0.0:\nesutils \"^2.0.2\"\nisarray \"^1.0.0\"\n+doctrine@^2.0.2:\n+ version \"2.1.0\"\n+ resolved \"https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d\"\n+ dependencies:\n+ esutils \"^2.0.2\"\n+\ndom-converter@~0.1:\nversion \"0.1.4\"\nresolved \"https://registry.yarnpkg.com/dom-converter/-/dom-converter-0.1.4.tgz#a45ef5727b890c9bffe6d7c876e7b19cb0e17f3b\"\n@@ -1894,6 +1907,16 @@ es-abstract@^1.4.3, es-abstract@^1.6.1:\nis-callable \"^1.1.3\"\nis-regex \"^1.0.3\"\n+es-abstract@^1.7.0:\n+ version \"1.11.0\"\n+ resolved \"https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.11.0.tgz#cce87d518f0496893b1a30cd8461835535480681\"\n+ dependencies:\n+ es-to-primitive \"^1.1.1\"\n+ function-bind \"^1.1.1\"\n+ has \"^1.0.1\"\n+ is-callable \"^1.1.3\"\n+ is-regex \"^1.0.4\"\n+\nes-to-primitive@^1.1.1:\nversion \"1.1.1\"\nresolved \"https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.1.1.tgz#45355248a88979034b6792e19bb81f2b7975dd0d\"\n@@ -1934,13 +1957,14 @@ eslint-config-prettier@^2.7.0:\ndependencies:\nget-stdin \"^5.0.1\"\n-eslint-plugin-react@~7.1.0:\n- version \"7.1.0\"\n- resolved \"https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.1.0.tgz#27770acf39f5fd49cd0af4083ce58104eb390d4c\"\n+eslint-plugin-react@~7.7.0:\n+ version \"7.7.0\"\n+ resolved \"https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.7.0.tgz#f606c719dbd8a1a2b3d25c16299813878cca0160\"\ndependencies:\n- doctrine \"^2.0.0\"\n+ doctrine \"^2.0.2\"\nhas \"^1.0.1\"\n- jsx-ast-utils \"^1.4.1\"\n+ jsx-ast-utils \"^2.0.1\"\n+ prop-types \"^15.6.0\"\neslint-scope@^3.7.1:\nversion \"3.7.1\"\n@@ -2185,6 +2209,18 @@ faye-websocket@~0.11.0:\ndependencies:\nwebsocket-driver \">=0.5.1\"\n+fbjs@^0.8.16:\n+ version \"0.8.16\"\n+ resolved \"https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db\"\n+ dependencies:\n+ core-js \"^1.0.0\"\n+ isomorphic-fetch \"^2.1.1\"\n+ loose-envify \"^1.0.0\"\n+ object-assign \"^4.1.0\"\n+ promise \"^7.1.1\"\n+ setimmediate \"^1.0.5\"\n+ ua-parser-js \"^0.7.9\"\n+\nfbjs@^0.8.9:\nversion \"0.8.12\"\nresolved \"https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04\"\n@@ -2361,6 +2397,10 @@ function-bind@^1.0.2, function-bind@^1.1.0:\nversion \"1.1.0\"\nresolved \"https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.0.tgz#16176714c801798e4e8f2cf7f7529467bb4a5771\"\n+function-bind@^1.1.1:\n+ version \"1.1.1\"\n+ resolved \"https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d\"\n+\nfunction.prototype.name@^1.0.0:\nversion \"1.0.0\"\nresolved \"https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.0.0.tgz#5f523ca64e491a5f95aba80cc1e391080a14482e\"\n@@ -3045,7 +3085,7 @@ is-property@^1.0.0:\nversion \"1.0.2\"\nresolved \"https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84\"\n-is-regex@^1.0.3:\n+is-regex@^1.0.3, is-regex@^1.0.4:\nversion \"1.0.4\"\nresolved \"https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491\"\ndependencies:\n@@ -3266,9 +3306,11 @@ jsprim@^1.2.2:\njson-schema \"0.2.3\"\nverror \"1.3.6\"\n-jsx-ast-utils@^1.4.1:\n- version \"1.4.1\"\n- resolved \"https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz#3867213e8dd79bf1e8f2300c0cfc1efb182c0df1\"\n+jsx-ast-utils@^2.0.1:\n+ version \"2.0.1\"\n+ resolved \"https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz#e801b1b39985e20fffc87b40e3748080e2dcac7f\"\n+ dependencies:\n+ array-includes \"^3.0.3\"\nkind-of@^3.0.2:\nversion \"3.2.2\"\n@@ -4363,6 +4405,14 @@ prop-types@^15.5.10, prop-types@^15.5.4:\nfbjs \"^0.8.9\"\nloose-envify \"^1.3.1\"\n+prop-types@^15.6.0:\n+ version \"15.6.1\"\n+ resolved \"https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.1.tgz#36644453564255ddda391191fb3a125cbdf654ca\"\n+ dependencies:\n+ fbjs \"^0.8.16\"\n+ loose-envify \"^1.3.1\"\n+ object-assign \"^4.1.1\"\n+\nproxy-addr@~1.1.4:\nversion \"1.1.4\"\nresolved \"https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.4.tgz#27e545f6960a44a627d9b44467e35c1b6b4ce2f3\"\n" } ]
TypeScript
MIT License
router5/router5
feat: add RouteProvider and Route components, using React's new context API
580,249
04.04.2018 23:29:53
-3,600
35d9a98729309a43ec066354dbbfc34cc5f9b602
refactor: use old context APi in RouteProvider to keep compatibility with links
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/RouteProvider.js", "new_path": "packages/react-router5/modules/RouteProvider.js", "diff": "@@ -47,6 +47,10 @@ class RouteProvider extends React.PureComponent {\nthis.router.removeListener(this.listener)\n}\n+ getChildContext() {\n+ return { router: this.router }\n+ }\n+\nrender() {\nreturn (\n<Provider value={this.state.route}>{this.props.children}</Provider>\n@@ -54,6 +58,15 @@ class RouteProvider extends React.PureComponent {\n}\n}\n+RouteProvider.childContextTypes = {\n+ router: PropTypes.object.isRequired\n+}\n+\n+RouteProvider.propTypes = {\n+ router: PropTypes.object.isRequired,\n+ children: PropTypes.node.isRequired\n+}\n+\nclass RouteNodeConsumer extends React.Component {\nshouldComponentUpdate(nextProps) {\nconst { intersection } = transitionPath(\n@@ -71,7 +84,7 @@ class RouteNodeConsumer extends React.Component {\nRouteNodeConsumer.propTypes = {\nnodeName: PropTypes.string.isRequired,\n- children: PropTypes.function.isRequired\n+ children: PropTypes.func.isRequired\n}\nfunction RouteNode(props) {\n@@ -84,9 +97,4 @@ function RouteNode(props) {\n)\n}\n-RouteProvider.propTypes = {\n- router: PropTypes.object.isRequired,\n- children: PropTypes.node.isRequired\n-}\n-\nexport { RouteProvider, Route, RouteNode }\n" }, { "change_type": "MODIFY", "old_path": "packages/react-router5/yarn.lock", "new_path": "packages/react-router5/yarn.lock", "diff": "@@ -64,12 +64,6 @@ object-assign@^4.1.0:\nversion \"4.1.1\"\nresolved \"https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863\"\[email protected]:\n- version \"2.0.2\"\n- resolved \"https://registry.yarnpkg.com/path-parser/-/path-parser-2.0.2.tgz#ab90ed1053b682681d1120a69208f6f6a6a734c2\"\n- dependencies:\n- search-params \"~1.3.0\"\n-\npromise@^7.1.1:\nversion \"7.3.1\"\nresolved \"https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf\"\n@@ -83,27 +77,9 @@ prop-types@~15.5.10:\nfbjs \"^0.8.9\"\nloose-envify \"^1.3.1\"\[email protected]:\n- version \"1.8.2\"\n- resolved \"https://registry.yarnpkg.com/route-node/-/route-node-1.8.2.tgz#0e10c324b00ad9bc9b398bbfb97466fad1f9c422\"\n- dependencies:\n- path-parser \"2.0.2\"\n- search-params \"~1.3.0\"\n-\[email protected]:\n- version \"4.0.1\"\n- resolved \"https://registry.yarnpkg.com/router5.transition-path/-/router5.transition-path-4.0.1.tgz#6d61d6b78e233aeff2e68f3b91b9a83338c2f723\"\n-\n-router5@~4.5.2:\n- version \"4.5.2\"\n- resolved \"https://registry.yarnpkg.com/router5/-/router5-4.5.2.tgz#2d44e2ec5fae31d1953c7f2e7a68da399b2f5bb4\"\n- dependencies:\n- route-node \"1.8.2\"\n- router5.transition-path \"4.0.1\"\n-\n-search-params@~1.3.0:\n- version \"1.3.0\"\n- resolved \"https://registry.yarnpkg.com/search-params/-/search-params-1.3.0.tgz#ba1e1c01dcbd8a2e41a25236f602f2cbf710d688\"\n+router5-transition-path@^5.0.0:\n+ version \"5.1.1\"\n+ resolved \"https://registry.yarnpkg.com/router5-transition-path/-/router5-transition-path-5.1.1.tgz#89698deeaedcf0831a5c3393d8ae16c9f06a9744\"\nsetimmediate@^1.0.5:\nversion \"1.0.5\"\n" } ]
TypeScript
MIT License
router5/router5
refactor: use old context APi in RouteProvider to keep compatibility with links
580,249
07.04.2018 16:42:57
-3,600
58af72e1c176a89cdc5027f080667465dd0baba4
feat: add RouteNode component, using React new context API
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/RouteProvider.js", "new_path": "packages/react-router5/modules/RouteProvider.js", "diff": "@@ -7,12 +7,10 @@ const emptyCreateContext = () => ({\nProvider: _ => _,\nConsumer: () => null\n})\n+\nconst createContext = React.createContext || emptyCreateContext\n-const { Provider, Consumer: Route } = createContext({\n- route: null,\n- previousRoute: null\n-})\n+const { Provider, Consumer: Route } = createContext({})\nclass RouteProvider extends React.PureComponent {\nconstructor(props) {\n@@ -20,8 +18,11 @@ class RouteProvider extends React.PureComponent {\nconst { router } = props\nthis.state = {\n- route: router.getState()\n+ route: router.getState(),\n+ previousRoute: null,\n+ router\n}\n+\nthis.listener = this.listener.bind(this)\n}\n@@ -38,8 +39,6 @@ class RouteProvider extends React.PureComponent {\n'[react-router5][RouteProvider] missing listeners plugin'\n)\n- this.listener = (toState, fromState) =>\n- this.setState({ previousRoute: fromState, route: toState })\nthis.router.addListener(this.listener)\n}\n@@ -48,13 +47,11 @@ class RouteProvider extends React.PureComponent {\n}\ngetChildContext() {\n- return { router: this.router }\n+ return { router: this.props.router }\n}\nrender() {\n- return (\n- <Provider value={this.state.route}>{this.props.children}</Provider>\n- )\n+ return <Provider value={this.state}>{this.props.children}</Provider>\n}\n}\n@@ -67,34 +64,28 @@ RouteProvider.propTypes = {\nchildren: PropTypes.node.isRequired\n}\n-class RouteNodeConsumer extends React.Component {\n- shouldComponentUpdate(nextProps) {\n+class RouteNode extends React.Component {\n+ renderOnRouteNodeChange = routeContext => {\nconst { intersection } = transitionPath(\n- nextProps.routeContext.route,\n- nextProps.routeContext.previousRoute\n+ routeContext.route,\n+ routeContext.previousRoute\n)\n- return intersection === nextProps.nodeName\n+ if (!this.memoizedResult || intersection === this.props.nodeName) {\n+ this.memoizedResult = this.props.children(routeContext)\n+ }\n+\n+ return this.memoizedResult\n}\nrender() {\n- return this.props.children(this.props.routeContext)\n+ return <Route>{this.renderOnRouteNodeChange}</Route>\n}\n}\n-RouteNodeConsumer.propTypes = {\n+RouteNode.propTypes = {\nnodeName: PropTypes.string.isRequired,\nchildren: PropTypes.func.isRequired\n}\n-function RouteNode(props) {\n- return (\n- <Route>\n- {routeContext => (\n- <RouteNodeConsumer {...props} routeContext={routeContext} />\n- )}\n- </Route>\n- )\n-}\n-\nexport { RouteProvider, Route, RouteNode }\n" } ]
TypeScript
MIT License
router5/router5
feat: add RouteNode component, using React new context API
580,249
09.04.2018 10:19:18
-3,600
df291f7c8120fed10c198f05d9d7988eab0da2da
chore: use now npm deploys
[ { "change_type": "DELETE", "old_path": "packages/docs/Dockerfile", "new_path": null, "diff": "-FROM node:8\n-\n-WORKDIR /app\n-\n-COPY package.json .\n-COPY yarn.lock .\n-\n-COPY server .\n-\n-RUN yarn\n-\n-EXPOSE 8081\n-CMD [ \"npm\", \"start\" ]\n" }, { "change_type": "MODIFY", "old_path": "packages/docs/package.json", "new_path": "packages/docs/package.json", "diff": "\"private\": true,\n\"scripts\": {\n\"dev\": \"NODE_ENV=development webpack-dev-server\",\n- \"build\": \"NODE_ENV=production webpack\",\n- \"start\": \"node server/index.js\"\n+ \"bundle\": \"NODE_ENV=production webpack\",\n+ \"start\": \"node server/index.js\",\n+ \"deploy\": \"now --npm --public -e NODE_ENV='production' && now alias\"\n+ },\n+ \"now\": {\n+ \"alias\": \"router5\"\n},\n\"dependencies\": {\n- \"express\": \"~4.16.3\",\n+ \"express\": \"~4.16.3\"\n+ },\n+ \"devDependencies\": {\n\"fela\": \"~6.1.7\",\n+ \"html-webpack-plugin\": \"~3.2.0\",\n\"react\": \"~16.3.1\",\n\"react-dom\": \"~16.3.1\",\n\"react-fela\": \"~7.2.0\",\n\"react-router5\": \"~5.5.2\",\n- \"router5\": \"~5.8.3\"\n- },\n- \"devDependencies\": {\n- \"html-webpack-plugin\": \"~3.2.0\",\n+ \"router5\": \"~5.8.3\",\n\"webpack\": \"~4.5.0\",\n\"webpack-cli\": \"~2.0.14\",\n\"webpack-dev-server\": \"~3.1.3\"\n" } ]
TypeScript
MIT License
router5/router5
chore: use now npm deploys
580,249
15.04.2018 21:12:41
-3,600
3219b827933984acbe924617391b2d10f67d868b
docs: update react-router5 docs
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/README.md", "new_path": "packages/react-router5/README.md", "diff": "> Higher-order components and components for React when using [router5](https://github.com/router5/router5).\n-\n### Installation\n```sh\n@@ -18,95 +17,95 @@ npm install --save react-router5\n### Requirements\n-- react >= __0.14.0__\n-- router5 >= __2.0.0__\n+* react >= **0.14.0**\n+* router5 >= **2.0.0**\n### What does this package export?\n-- `RouterProvider`: component\n-- `Link`: component\n-- `routeNode`: higher-order component\n-- `BaseLink`: component\n-- `withRoute`: higher-order component\n-\n+* `RouterProvider`: component\n+* `Link`: component\n+* `routeNode`: higher-order component\n+* `BaseLink`: component\n+* `withRoute`: higher-order component\n### How it works\n![With React](https://cdn.rawgit.com/router5/router5.github.io/master/img/router-view.png)\n+### Available components\n-### RouterProvider\n-\n-It will add your router instance in context.\n+* **RouterProvier**: adds your router instance in context.\n```javascript\n-import React from 'react';\n-import ReactDOM from 'react-dom';\n-import { RouterProvider } from 'react-router5';\n-import App from './App';\n-import router from './router';\n-\n-ReactDOM.render(\n- <RouterProvider router={ router }><App /></RouterProvider>,\n- document.getElementById('app')\n-);\n+const AppWithRouter = (\n+ <RouterProvider router={router}>\n+ <App />\n+ </RouterProvider>\n+)\n```\n-### routeNode HOC\n-\n-__routeNode(nodeName)__: higher-order component to wrap a route node component.\n-\n-- Specify your component node name (`''` if root node)\n-\n-__Note:__ your router needs to use `listenersPlugin` from `router5`.\n+* **withRoute(BaseComponent)**: HoC injecting your router instance (from context) and the current route to the wrapped component. Any route change will trigger a re-render, and requires the use of the listeners plugin.\n+* **routeNode(nodeName)(BaseComponent)**: like above, expect it only re-renders when the given route node is the transition node. When using `routeNode` components, make sure to key the ones which can render the same components but with different route params.\n```javascript\n-import React from 'react';\n-import { routeNode } from 'react-router5';\n-import { UserView, UserList, NotFound } from './components';\n+import React from 'react'\n+import { routeNode } from 'react-router5'\n+import { UserView, UserList, NotFound } from './components'\nfunction Users(props) {\n- const { previousRoute, route } = props;\n+ const { previousRoute, route } = props\nswitch (route.name) {\ncase 'users.list':\n- return <UserList/>;\n+ return <UserList />\ncase 'users.view':\n- return <UserView/>;\n+ return <UserView />\ndefault:\n- return <NotFound/>;\n- };\n+ return <NotFound />\n+ }\n}\n-export default routeNode('users')(Users);\n-\n+export default routeNode('users')(Users)\n```\n-### Link component\n+**The `Link`component is `BaseLink` and `withRoute` composed together**\n+\n+* **Link**: a component to render hyperlinks. For a full list of supported props, check the source!\n+* **BaseLink**: same as `Link`, except it won't re-render on a route change.\n```javascript\n-import React from 'react';\n-import { Link } from 'react-router5';\n+import React from 'react'\n+import { Link } from 'react-router5'\nfunction Menu(props) {\nreturn (\n<nav>\n- <Link routeName='home' routeOptions={{reload: true}}>Home</Link>\n+ <Link routeName=\"home\">Home</Link>\n- <Link routeName='about' routeOptions={{reload: true}}>About</Link>\n+ <Link routeName=\"about\">About</Link>\n</nav>\n- );\n+ )\n}\n-export default Menu;\n+export default Menu\n```\n-__The `Link `component is `BaseLink` and `withRoute` composed together__\n+### New React context components (React >= 16.3.0)\n-### BaseLink component\n+Three new components have been published to leverage React's new context API. Those components are still in development and won't replace existing ones: instead `react-router5` will offer higher-order components and components acception render functions.\n-Same as `Link`, except it won't mark it-self dirty (and re-render) on a route change. `BaseLink` needs to be passed your router instance.\n+* `RouteProvider`\n+* `Route`\n+* `RouteNode`\n-### withRoute HOC\n+Both `Route` and `RouteNode` pass to their chilren an object containing `route`, `previousRoute` and `router`.\n-Will create a new component, injecting your router instance (from context) and the current route to the wrapped component. Any route change will trigger a re-render.\n+```js\n+const App = (\n+ <RouteProvider router={router}>\n+ <RouteNode nodeName=\"\">\n+ {({ route, previousRoute, router }) => <div>Route</div>}\n+ </RouteNode>\n+ </RouteProvider>\n+)\n+```\n" } ]
TypeScript
MIT License
router5/router5
docs: update react-router5 docs
580,249
18.04.2018 21:16:58
-3,600
2dc9bec3b9799c8ea80642ca9967f61eb2060b50
refactor: correct type definitions
[ { "change_type": "MODIFY", "old_path": "packages/router5/index.d.ts", "new_path": "packages/router5/index.d.ts", "diff": "@@ -23,10 +23,6 @@ declare module 'router5' {\nActivationFn,\nActivationFnFactory\n} from 'router5/core/route-lifecycle'\n- import {\n- ActivationFn as RouterActivationHandler,\n- ActivationFnFactory as RouterActivationHandlerFactory\n- } from 'router5/core/route-lifecycle'\nimport loggerPlugin from 'router5/plugins/loggers'\nimport transitionPath from 'router5-transition-path'\n@@ -56,10 +52,7 @@ declare module 'router5' {\nRouter,\nRouterOptions,\nState,\n- StateMeta,\n- // compatibility\n- RouterActivationHandler,\n- RouterActivationHandlerFactory\n+ StateMeta\n}\nexport default createRouter\n@@ -138,15 +131,15 @@ declare module 'router5/create-router' {\n}\nexport interface Options {\n- defaultRoute?: string\n- defaultParams?: Params\n- strictTrailingSlash?: boolean\n- trailingSlashMode?: TrailingSlashMode\n- queryParamsMode?: QueryParamsMode\n- autoCleanUp?: boolean\n- allowNotFound?: boolean\n- strongMatching?: boolean\n- rewritePathOnMatch?: boolean\n+ defaultRoute: string\n+ defaultParams: Params\n+ strictTrailingSlash: boolean\n+ trailingSlashMode: TrailingSlashMode\n+ queryParamsMode: QueryParamsMode\n+ autoCleanUp: boolean\n+ allowNotFound: boolean\n+ strongMatching: boolean\n+ rewritePathOnMatch: boolean\nqueryParams?: QueryParamsOptions\n}\n" } ]
TypeScript
MIT License
router5/router5
refactor: correct type definitions
580,249
19.04.2018 09:28:58
-3,600
a2880188e2154ed36c388f2f658217655a284bcd
feat: add caseSensitive option
[ { "change_type": "MODIFY", "old_path": "CHANGELOG.md", "new_path": "CHANGELOG.md", "diff": "-## [email protected] (2018-04-18)\n+## [email protected] (2018-04-19)\n#### Feature\n* `router5`\n* Navigation options are now added to state objects (in `meta`)\n* You can now specify your custom navigation options: they will be added to state objects and are usable by your custom plugins and middlewares\n* New `queryParams` option to configure how query parameters are built, and how they are parsed\n+ * New `caseSensitive` option (default to `false`)\n* `react-router5`\n- * Alternative components using a rendering function have been added in addition to the higher-order components. Those components require a new provider, because they leverage React new context API (React >= 16.3, see https://github.com/router5/router5/tree/master/packages/react-router5). Higher-order components won't be deprecated, and will evolve to use React new context API once deprecated.\n+ * Alternative components using a render function have been added in addition to the higher-order components. Those components require a new provider, because they leverage React new context API (React >= 16.3, see https://github.com/router5/router5/tree/master/packages/react-router5). Higher-order components won't be deprecated, and will evolve to use React new context API once deprecated.\n#### Bug fix\n* `router5`\n### Breaking changes\n+* Path matching used to be case sensitive and it is now case insensitive by default (new `caseSensitive` option)\n* Query parameters in paths can no longer be defined with `[]` (brackets should be removed)\n* Option `trailingSlash` has been renamed to `strictTrailingSlash`: by default it is `false`\n* Option `useTrailingSlash` has been renamed to `trailingSlashMode` with value being `'default'`, `'never'` or `'always'`\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/index.d.ts", "new_path": "packages/router5/index.d.ts", "diff": "@@ -141,6 +141,7 @@ declare module 'router5/create-router' {\nstrongMatching: boolean\nrewritePathOnMatch: boolean\nqueryParams?: QueryParamsOptions\n+ caseSensitive: boolean\n}\nexport interface Router {\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/create-router.js", "new_path": "packages/router5/modules/create-router.js", "diff": "@@ -15,7 +15,8 @@ const defaultOptions = {\nautoCleanUp: true,\nallowNotFound: false,\nstrongMatching: true,\n- rewritePathOnMatch: true\n+ rewritePathOnMatch: true,\n+ caseSensitive: false\n}\n/**\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "},\n\"homepage\": \"http://router5.github.io\",\n\"dependencies\": {\n- \"route-node\": \"3.0.3\",\n+ \"route-node\": \"3.1.0\",\n\"router5-transition-path\": \"^5.1.1\"\n},\n\"typings\": \"./index.d.ts\"\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/typescript/create-router.ts", "new_path": "packages/router5/test/typescript/create-router.ts", "diff": "@@ -16,7 +16,8 @@ const options: Partial<Options> = {\nautoCleanUp: true,\nqueryParamsMode: 'default',\nallowNotFound: false,\n- strongMatching: true\n+ strongMatching: true,\n+ caseSensitive: false\n}\nconst deps: Dependencies = { store: {} }\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/yarn.lock", "new_path": "packages/router5/yarn.lock", "diff": "@@ -8,17 +8,13 @@ [email protected]:\ndependencies:\nsearch-params \"2.1.2\"\[email protected]:\n- version \"3.0.3\"\n- resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.0.3.tgz#aab468bbefff6ca982904d195bd008c11b3c9461\"\[email protected]:\n+ version \"3.1.0\"\n+ resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.1.0.tgz#7ced7ebd01a84cd7d84bd94ca831288200a7a0d4\"\ndependencies:\npath-parser \"4.0.4\"\nsearch-params \"2.1.2\"\n-router5-transition-path@^5.1.1:\n- version \"5.1.1\"\n- resolved \"https://registry.yarnpkg.com/router5-transition-path/-/router5-transition-path-5.1.1.tgz#89698deeaedcf0831a5c3393d8ae16c9f06a9744\"\n-\[email protected]:\nversion \"2.1.2\"\nresolved \"https://registry.yarnpkg.com/search-params/-/search-params-2.1.2.tgz#e0107b7e6f2e973d7991b8fbffc8b6664bc96edd\"\n" } ]
TypeScript
MIT License
router5/router5
feat: add caseSensitive option
580,249
19.04.2018 15:11:19
-3,600
6f822607a332026fbe6bd097a83afcb317f36726
chore: add homepage links
[ { "change_type": "MODIFY", "old_path": "packages/deku-router5/package.json", "new_path": "packages/deku-router5/package.json", "diff": "\"bugs\": {\n\"url\": \"https://github.com/router5/router5/issues\"\n},\n- \"homepage\": \"http://router5.github.com\",\n+ \"homepage\": \"https://github.com/router5/router5/tree/master/packages/deku-router5\",\n\"peerDependencies\": {\n\"deku\": \"~0.5.0 || ^1.0.0\",\n\"router5\": \"^5.0.0 || ^6.0.0\"\n" }, { "change_type": "MODIFY", "old_path": "packages/react-router5/package.json", "new_path": "packages/react-router5/package.json", "diff": "\"bugs\": {\n\"url\": \"https://github.com/router5/router5/issues\"\n},\n- \"homepage\": \"http://router5.github.com\",\n+ \"homepage\": \"https://github.com/router5/router5/tree/master/packages/react-router5\",\n\"peerDependencies\": {\n\"react\": \"^0.14.0 || ^15.0.0 || ^16.0.0\",\n\"router5\": \"^5.0.0 || ^6.0.0\"\n" }, { "change_type": "MODIFY", "old_path": "packages/router5-helpers/package.json", "new_path": "packages/router5-helpers/package.json", "diff": "\"bugs\": {\n\"url\": \"https://github.com/router5/router5/issues\"\n},\n- \"homepage\": \"https://router5.github.io\",\n+ \"homepage\": \"https://github.com/router5/router5/tree/master/packages/router5-helpers\",\n\"typings\": \"./index.d.ts\"\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5-transition-path/package.json", "new_path": "packages/router5-transition-path/package.json", "diff": "\"bugs\": {\n\"url\": \"https://github.com/router5/router5/issues\"\n},\n- \"homepage\": \"https://router5.github.io\",\n+ \"homepage\": \"https://github.com/router5/router5/tree/master/packages/router5-transition-path\",\n\"peerDependencies\": {\n\"router5\": \"^5.0.0 || ^6.0.0\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/rxjs-router5/package.json", "new_path": "packages/rxjs-router5/package.json", "diff": "\"bugs\": {\n\"url\": \"https://github.com/router5/router5/issues\"\n},\n- \"homepage\": \"http://router5.github.io\",\n+ \"homepage\": \"https://github.com/router5/router5/tree/master/packages/rxjs-router5\",\n\"dependencies\": {\n\"router5-transition-path\": \"^5.1.1\",\n\"rxjs\": \"~5.4.3\"\n" }, { "change_type": "MODIFY", "old_path": "packages/xstream-router5/package.json", "new_path": "packages/xstream-router5/package.json", "diff": "\"bugs\": {\n\"url\": \"https://github.com/router5/router5/issues\"\n},\n- \"homepage\": \"http://router5.github.io\",\n+ \"homepage\": \"https://github.com/router5/router5/tree/master/packages/xstream-router5\",\n\"dependencies\": {\n\"router5-transition-path\": \"^5.1.1\",\n\"xstream\": \"^10.0.0\"\n" } ]
TypeScript
MIT License
router5/router5
chore: add homepage links
580,249
19.04.2018 23:19:32
-3,600
f5289bab13572b29cb55f932dfe4fd8d473db720
feat: add shouldUpdateNode function
[ { "change_type": "MODIFY", "old_path": "packages/router5-transition-path/index.d.ts", "new_path": "packages/router5-transition-path/index.d.ts", "diff": "@@ -9,6 +9,10 @@ declare module 'router5-transition-path' {\ntoActivate: string[]\n}\n+ export function shouldUpdateNode(\n+ nodeName: string\n+ ): (toState: State, fromState?: State) => Boolean\n+\nexport default function transitionPath(\ntoState: State,\nfromState?: State\n" }, { "change_type": "MODIFY", "old_path": "packages/router5-transition-path/modules/index.js", "new_path": "packages/router5-transition-path/modules/index.js", "diff": "-export function nameToIDs(name) {\n- return name.split('.').reduce(function(ids, name) {\n- return ids.concat(ids.length ? ids[ids.length - 1] + '.' + name : name)\n- }, [])\n-}\n+import transitionPath, { nameToIDs } from './transitionPath'\n+import shouldUpdateNode from './shouldUpdateNode'\n-function exists(val) {\n- return val !== undefined && val !== null\n-}\n-\n-function hasMetaParams(state) {\n- return state && state.meta && state.meta.params\n-}\n-\n-function extractSegmentParams(name, state) {\n- if (!exists(state.meta.params[name])) return {}\n-\n- return Object.keys(state.meta.params[name]).reduce((params, p) => {\n- params[p] = state.params[p]\n- return params\n- }, {})\n-}\n-\n-function transitionPath(toState, fromState) {\n- const fromStateIds = fromState ? nameToIDs(fromState.name) : []\n- const toStateIds = nameToIDs(toState.name)\n- const maxI = Math.min(fromStateIds.length, toStateIds.length)\n-\n- function pointOfDifference() {\n- let i\n- for (i = 0; i < maxI; i += 1) {\n- const left = fromStateIds[i]\n- const right = toStateIds[i]\n-\n- if (left !== right) return i\n-\n- const leftParams = extractSegmentParams(left, toState)\n- const rightParams = extractSegmentParams(right, fromState)\n-\n- if (leftParams.length !== rightParams.length) return i\n- if (leftParams.length === 0) continue\n-\n- const different = Object.keys(leftParams).some(\n- p => rightParams[p] !== leftParams[p]\n- )\n- if (different) {\n- return i\n- }\n- }\n-\n- return i\n- }\n-\n- let i\n- if (!fromState) {\n- i = 0\n- } else if (!hasMetaParams(fromState) && !hasMetaParams(toState)) {\n- console.warn(\n- '[router5-transition-path] Some states are missing metadata, reloading all segments'\n- )\n- i = 0\n- } else {\n- i = pointOfDifference()\n- }\n-\n- const toDeactivate = fromStateIds.slice(i).reverse()\n- const toActivate = toStateIds.slice(i)\n-\n- const intersection = fromState && i > 0 ? fromStateIds[i - 1] : ''\n-\n- return {\n- intersection,\n- toDeactivate,\n- toActivate\n- }\n-}\n+export { shouldUpdateNode, nameToIDs }\nexport default transitionPath\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/router5-transition-path/modules/shouldUpdateNode.js", "diff": "+import transitionPath from './transitionPath'\n+\n+export default function shouldUpdateNode(nodeName) {\n+ return (toState, fromSate) => {\n+ const {\n+ intersection,\n+ toActivate,\n+ toDeactivate: toDeactivateReversed\n+ } = transitionPath(toState, fromSate)\n+\n+ const toDeactivate = [...toDeactivateReversed].reverse()\n+\n+ if (nodeName === intersection) {\n+ return true\n+ }\n+\n+ if (toActivate.indexOf(nodeName) === -1) {\n+ return false\n+ }\n+\n+ let matching = true\n+\n+ for (let i = 0; i < toActivate.length; i += 1) {\n+ const activatedSegment = toActivate[i]\n+ const sameLevelDeactivatedSegment = toDeactivate[i]\n+\n+ matching = activatedSegment === sameLevelDeactivatedSegment\n+\n+ if (matching && activatedSegment === nodeName) {\n+ return true\n+ }\n+\n+ if (!matching) {\n+ return false\n+ }\n+ }\n+\n+ // Should never be reached\n+ return false\n+ }\n+}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/router5-transition-path/modules/transitionPath.js", "diff": "+export function nameToIDs(name) {\n+ return name.split('.').reduce(function(ids, name) {\n+ return ids.concat(ids.length ? ids[ids.length - 1] + '.' + name : name)\n+ }, [])\n+}\n+\n+function exists(val) {\n+ return val !== undefined && val !== null\n+}\n+\n+function hasMetaParams(state) {\n+ return state && state.meta && state.meta.params\n+}\n+\n+function extractSegmentParams(name, state) {\n+ if (!exists(state.meta.params[name])) return {}\n+\n+ return Object.keys(state.meta.params[name]).reduce((params, p) => {\n+ params[p] = state.params[p]\n+ return params\n+ }, {})\n+}\n+\n+export default function transitionPath(toState, fromState) {\n+ const fromStateIds = fromState ? nameToIDs(fromState.name) : []\n+ const toStateIds = nameToIDs(toState.name)\n+ const maxI = Math.min(fromStateIds.length, toStateIds.length)\n+\n+ function pointOfDifference() {\n+ let i\n+ for (i = 0; i < maxI; i += 1) {\n+ const left = fromStateIds[i]\n+ const right = toStateIds[i]\n+\n+ if (left !== right) return i\n+\n+ const leftParams = extractSegmentParams(left, toState)\n+ const rightParams = extractSegmentParams(right, fromState)\n+\n+ if (leftParams.length !== rightParams.length) return i\n+ if (leftParams.length === 0) continue\n+\n+ const different = Object.keys(leftParams).some(\n+ p => rightParams[p] !== leftParams[p]\n+ )\n+ if (different) {\n+ return i\n+ }\n+ }\n+\n+ return i\n+ }\n+\n+ let i\n+ if (!fromState) {\n+ i = 0\n+ } else if (!hasMetaParams(fromState) && !hasMetaParams(toState)) {\n+ i = 0\n+ } else {\n+ i = pointOfDifference()\n+ }\n+\n+ const toDeactivate = fromStateIds.slice(i).reverse()\n+ const toActivate = toStateIds.slice(i)\n+\n+ const intersection = fromState && i > 0 ? fromStateIds[i - 1] : ''\n+\n+ return {\n+ intersection,\n+ toDeactivate,\n+ toActivate\n+ }\n+}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5-transition-path/test/main.js", "new_path": "packages/router5-transition-path/test/main.js", "diff": "-import transitionPath from '../modules'\n+import transitionPath, { shouldUpdateNode } from '../modules'\nimport { expect } from 'chai'\nimport tt from 'typescript-definition-tester'\n@@ -67,6 +67,55 @@ describe('router5-transition-path', function() {\n).to.equal('a.b.c')\n})\n+ describe('shouldUpdateNode', () => {\n+ const meta = {\n+ params: {\n+ a: {},\n+ 'a.b': { p1: 'url' },\n+ 'a.b.c': { p2: 'url' },\n+ 'a.b.c.d': { p3: 'url' },\n+ 'a.b.c.e': { p4: 'url' }\n+ }\n+ }\n+\n+ it('should tell intersection node to update', () => {\n+ const shouldUpdate = shouldUpdateNode('a')(\n+ { name: 'a.b.c.d', params: { p1: 0, p2: 2, p3: 3 }, meta },\n+ { name: 'a.b.c.d', params: { p1: 1, p2: 2, p3: 3 }, meta }\n+ )\n+\n+ expect(shouldUpdate).to.equal(true)\n+ })\n+\n+ it('should tell node above intersection to not update', () => {\n+ const shouldUpdate = shouldUpdateNode('')(\n+ { name: 'a.b.c.d', params: { p1: 0, p2: 2, p3: 3 }, meta },\n+ { name: 'a.b.c.d', params: { p1: 1, p2: 2, p3: 3 }, meta }\n+ )\n+\n+ expect(shouldUpdate).to.equal(false)\n+ })\n+\n+ it('should tell node below intersection to update if not deactivated', () => {\n+ const fromState = {\n+ name: 'a.b.c.d',\n+ params: { p1: 0, p2: 2, p3: 3 },\n+ meta\n+ }\n+ const toState = {\n+ name: 'a.b.c.e',\n+ params: { p1: 1, p2: 2, p4: 3 },\n+ meta\n+ }\n+\n+ expect(shouldUpdateNode('a.b')(toState, fromState)).to.equal(true)\n+ expect(shouldUpdateNode('a.b.c')(toState, fromState)).to.equal(true)\n+ expect(shouldUpdateNode('a.b.c.e')(toState, fromState)).to.equal(\n+ false\n+ )\n+ })\n+ })\n+\ndescribe('TypeScript definitions', function() {\nit('should compile examples against index.d.ts', function(done) {\nthis.timeout(10000)\n" }, { "change_type": "MODIFY", "old_path": "packages/router5-transition-path/test/typescript/index.ts", "new_path": "packages/router5-transition-path/test/typescript/index.ts", "diff": "import transitionPath, {\nnameToIDs,\n- TransitionPath\n+ TransitionPath,\n+ shouldUpdateNode\n} from 'router5-transition-path'\nconst _ids: string[] = nameToIDs('a.b.c')\n@@ -14,3 +15,13 @@ tp = transitionPath(\n{ name: 'a.b.d', params: {}, path: '/a/b/d' }\n)\ntp = transitionPath({ name: 'a.b.c', params: {}, path: '/a/b/c' })\n+\n+let shouldUpdate = shouldUpdateNode('a')(\n+ { name: 'a.b.c', params: {}, path: '/a/b/c' },\n+ { name: 'a.b.d', params: {}, path: '/a/b/d' }\n+)\n+shouldUpdate = shouldUpdateNode('a')({\n+ name: 'a.b.c',\n+ params: {},\n+ path: '/a/b/c'\n+})\n" } ]
TypeScript
MIT License
router5/router5
feat: add shouldUpdateNode function
580,249
20.04.2018 10:52:40
-3,600
ad72bc5058102599af3f72bb4b1e6ee4afc2a291
feat: add subscribe function and observable compatibility, without the need to add a plugin
[ { "change_type": "MODIFY", "old_path": "packages/router5/index.d.ts", "new_path": "packages/router5/index.d.ts", "diff": "@@ -17,6 +17,7 @@ declare module 'router5' {\nCancelFn,\nOptions as NavigationOptions\n} from 'router5/core/navigation'\n+ import { SubscribeFn, SubscribeState } from 'router5/core/observable'\nimport { Middleware, MiddlewareFactory } from 'router5/core/middleware'\nimport { Plugin, PluginFactory } from 'router5/core/plugins'\nimport {\n@@ -52,7 +53,9 @@ declare module 'router5' {\nRouter,\nRouterOptions,\nState,\n- StateMeta\n+ StateMeta,\n+ SubscribeFn,\n+ SubscribeState\n}\nexport default createRouter\n@@ -246,6 +249,22 @@ declare module 'router5/core/navigation' {\n}\n}\n+declare module 'router5/core/observable' {\n+ import { State } from 'router5'\n+\n+ export interface SubscribeState {\n+ route: State\n+ previousRoute: State\n+ }\n+ export type SubscribeFn = (state: SubscribeState) => void\n+\n+ module 'router5/create-router' {\n+ interface Router {\n+ subscribe(cb: SubscribeFn): void\n+ }\n+ }\n+}\n+\ndeclare module 'router5/core/plugins' {\nimport { Dependencies, Router, State } from 'router5/create-router'\nimport { NavigationOptions } from 'router5/core/navigation'\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/router5/modules/core/observable.js", "diff": "+import $$observable from 'symbol-observable'\n+\n+function observerPlugin(router) {\n+ let listeners = []\n+\n+ function unsubscribe(listener) {\n+ if (listener) {\n+ listeners = listeners.filter(l => l !== listener)\n+ }\n+ }\n+\n+ function subscribe(listener) {\n+ listeners.concat(listener)\n+\n+ return unsubscribe(listener)\n+ }\n+\n+ function observable() {\n+ return {\n+ subscribe(observer) {\n+ if (typeof observer !== 'object' || observer === null) {\n+ throw new TypeError(\n+ 'Expected the observer to be an object.'\n+ )\n+ }\n+\n+ function listener() {\n+ if (observer.next) {\n+ observer.next(router.getState())\n+ }\n+ }\n+\n+ listener()\n+ const unsubscribe = subscribe(listener)\n+ return { unsubscribe }\n+ },\n+\n+ [$$observable]() {\n+ return this\n+ }\n+ }\n+ }\n+\n+ router.subscribe = subscribe\n+ router[$$observable] = observable\n+\n+ return {\n+ onTransitionSuccess: (toState, fromState) => {\n+ listeners.forEach(listener =>\n+ listener({\n+ route: toState,\n+ previousRoute: fromState\n+ })\n+ )\n+ }\n+ }\n+}\n+\n+observerPlugin.pluginName = 'OBSERVABLE_PLUGIN'\n+\n+export default function withObservablePlugin(router) {\n+ router.usePlugin(observerPlugin)\n+}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "\"homepage\": \"http://router5.github.io\",\n\"dependencies\": {\n\"route-node\": \"3.1.0\",\n- \"router5-transition-path\": \"^5.1.1\"\n+ \"router5-transition-path\": \"^5.1.1\",\n+ \"symbol-observable\": \"1.2.0\"\n},\n\"typings\": \"./index.d.ts\"\n}\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/router5/test/typescript/core/observable.ts", "diff": "+/// <reference path=\"../../../index.d.ts\" />\n+\n+import createRouter, { SubscribeFn } from 'router5'\n+\n+let router = createRouter([])\n+\n+const subscribeFn: SubscribeFn = ({ route, previousRoute }) => {}\n+router.subscribe(subscribeFn)\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/yarn.lock", "new_path": "packages/router5/yarn.lock", "diff": "@@ -15,6 +15,14 @@ [email protected]:\npath-parser \"4.0.4\"\nsearch-params \"2.1.2\"\n+router5-transition-path@^5.1.1:\n+ version \"5.2.0\"\n+ resolved \"https://registry.yarnpkg.com/router5-transition-path/-/router5-transition-path-5.2.0.tgz#25ae7f75a12a17044f7766a180eb7377f372493c\"\n+\[email protected]:\nversion \"2.1.2\"\nresolved \"https://registry.yarnpkg.com/search-params/-/search-params-2.1.2.tgz#e0107b7e6f2e973d7991b8fbffc8b6664bc96edd\"\n+\n+symbol-observable@~1.2.0:\n+ version \"1.2.0\"\n+ resolved \"https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804\"\n" } ]
TypeScript
MIT License
router5/router5
feat: add subscribe function and observable compatibility, without the need to add a plugin
580,249
20.04.2018 11:12:34
-3,600
8447a9cb53a0dcf4ec524096ab4d5c921d1fd5d7
chore: use observable
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/create-router.js", "new_path": "packages/router5/modules/create-router.js", "diff": "@@ -3,6 +3,7 @@ import withUtils from './core/utils'\nimport withRouterLifecycle from './core/router-lifecycle'\nimport withNavigation from './core/navigation'\nimport withMiddleware from './core/middleware'\n+import withObservable from './core/observable'\nimport withPlugins from './core/plugins'\nimport withRouteLifecycle from './core/route-lifecycle'\nimport withCloning from './core/clone'\n@@ -98,6 +99,7 @@ function createRouter(routes, opts = {}, deps = {}) {\nwithUtils(router)\nwithPlugins(router)\nwithMiddleware(router)\n+ withObservable(router)\nwithRouteLifecycle(router)\nwithRouterLifecycle(router)\nwithNavigation(router)\n" } ]
TypeScript
MIT License
router5/router5
chore: use observable
580,249
20.04.2018 11:11:46
-3,600
4d40fe55f850c951b35ede279ccdbd7eb2b09d90
feat: remove need for listeners plugin with React, smarter route node update
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/RouteProvider.js", "new_path": "packages/react-router5/modules/RouteProvider.js", "diff": "import React from 'react'\nimport PropTypes from 'prop-types'\n-import transitionPath from 'router5-transition-path'\n-import { ifNot } from './utils'\n+import { shouldUpdateNode } from 'router5-transition-path'\nconst emptyCreateContext = () => ({\nProvider: ({ children }) => children,\n@@ -23,28 +22,20 @@ class RouteProvider extends React.PureComponent {\npreviousRoute: null,\nrouter\n}\n-\n- this.listener = this.listener.bind(this)\n}\n- listener(toState, fromState) {\n+ componentDidMount() {\n+ const listener = (toState, fromState) => {\nthis.setState({\nroute: toState,\npreviousRoute: fromState\n})\n}\n-\n- componentDidMount() {\n- ifNot(\n- this.router.hasPlugin('LISTENERS_PLUGIN'),\n- '[react-router5][RouteProvider] missing listeners plugin'\n- )\n-\n- this.router.addListener(this.listener)\n+ this.unsubscribe = this.router.subscribe(listener)\n}\ncomponentWillUnmount() {\n- this.router.removeListener(this.listener)\n+ this.unsubscribe()\n}\ngetChildContext() {\n@@ -73,12 +64,12 @@ class RouteNode extends React.Component {\n}\nrenderOnRouteNodeChange(routeContext) {\n- const { intersection } = transitionPath(\n+ const shouldUpdate = shouldUpdateNode(this.props.nodeName)(\nrouteContext.route,\nrouteContext.previousRoute\n)\n- if (!this.memoizedResult || intersection === this.props.nodeName) {\n+ if (!this.memoizedResult || shouldUpdate) {\nthis.memoizedResult = this.props.children(routeContext)\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/routeNode.js", "new_path": "packages/react-router5/modules/routeNode.js", "diff": "import { Component, createElement } from 'react'\n-import { getDisplayName, ifNot } from './utils'\n+import { getDisplayName } from './utils'\nimport PropTypes from 'prop-types'\n+import { shouldUpdateNode } from 'router5-transition-path'\nfunction routeNode(nodeName) {\nreturn function routeNodeWrapper(RouteSegment) {\n@@ -12,27 +13,22 @@ function routeNode(nodeName) {\npreviousRoute: null,\nroute: this.router.getState()\n}\n- this.nodeListener = this.nodeListener.bind(this)\n}\n- nodeListener(toState, fromState) {\n+ componentDidMount() {\n+ const listener = ({ route, previousRoute }) => {\n+ if (shouldUpdateNode(nodeName)(route, previousRoute)) {\nthis.setState({\n- previousRoute: fromState,\n- route: toState\n+ previousRoute,\n+ route\n})\n}\n-\n- componentDidMount() {\n- ifNot(\n- this.router.hasPlugin('LISTENERS_PLUGIN'),\n- '[react-router5][routeNode] missing listeners plugin'\n- )\n-\n- this.router.addNodeListener(nodeName, this.nodeListener)\n+ }\n+ this.unsubscribe = this.router.subscribe(listener)\n}\ncomponentWillUnmount() {\n- this.router.removeNodeListener(nodeName, this.nodeListener)\n+ this.unsubscribe()\n}\nrender() {\n" }, { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/withRoute.js", "new_path": "packages/react-router5/modules/withRoute.js", "diff": "import { Component, createElement } from 'react'\n-import { ifNot, getDisplayName } from './utils'\n+import { getDisplayName } from './utils'\nimport PropTypes from 'prop-types'\nfunction withRoute(BaseComponent) {\n@@ -11,39 +11,20 @@ function withRoute(BaseComponent) {\npreviousRoute: null,\nroute: this.router.getState()\n}\n- this.listener = this.listener.bind(this)\n}\ncomponentDidMount() {\n- ifNot(\n- this.router.hasPlugin('LISTENERS_PLUGIN'),\n- '[react-router5][withRoute] missing listeners plugin'\n- )\n-\n- this.listener = (toState, fromState) =>\n- this.setState({ previousRoute: fromState, route: toState })\n- this.router.addListener(this.listener)\n+ const listener = ({ route, previousRoute }) => {\n+ this.setState({ route, previousRoute })\n}\n-\n- componentWillUnmount() {\n- this.router.removeListener(this.listener)\n+ this.unsubscribe = this.router.subscribe(listener)\n}\n- listener(toState, fromState) {\n- this.setState({\n- previousRoute: fromState,\n- route: toState\n- })\n+ componentWillUnmount() {\n+ this.unsubscribe()\n}\nrender() {\n- ifNot(\n- !this.props.router &&\n- !this.props.route &&\n- !this.props.previousRoute,\n- '[react-router5] prop names `router`, `route` and `previousRoute` are reserved.'\n- )\n-\nreturn createElement(BaseComponent, {\n...this.props,\n...this.state,\n" } ]
TypeScript
MIT License
router5/router5
feat: remove need for listeners plugin with React, smarter route node update
580,249
20.04.2018 11:26:15
-3,600
7a39976b993f4995775f08430e447ef74a8d06d9
fix: don't removing trailing slash from pathname when using hash
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/plugins/browser/browser.js", "new_path": "packages/router5/modules/plugins/browser/browser.js", "diff": "@@ -14,7 +14,7 @@ const isBrowser = typeof window !== 'undefined' && window.history\n/**\n* Browser functions needed by router5\n*/\n-const getBase = () => window.location.pathname.replace(/\\/$/, '')\n+const getBase = () => window.location.pathname\nconst supportsPopStateOnHashChange = () =>\nwindow.navigator.userAgent.indexOf('Trident') === -1\n" } ]
TypeScript
MIT License
router5/router5
fix: don't removing trailing slash from pathname when using hash
580,249
20.04.2018 11:35:17
-3,600
5ea5ab10ad00b94f139e255ae79962e342d8c74e
feat: smarter route node selector updates
[ { "change_type": "MODIFY", "old_path": "packages/redux-router5/modules/lib/routeNodeSelector.js", "new_path": "packages/redux-router5/modules/lib/routeNodeSelector.js", "diff": "-import transitionPath from 'router5-transition-path'\n+import { shouldUpdateNode } from 'router5-transition-path'\nfunction routeNodeSelector(routeNode, reducerKey = 'router') {\nconst routerStateSelector = state =>\n@@ -7,15 +7,15 @@ function routeNodeSelector(routeNode, reducerKey = 'router') {\nreturn function(state) {\nconst { route, previousRoute } = routerStateSelector(state)\n- const intersection = route\n- ? transitionPath(route, previousRoute).intersection\n- : ''\n+ const shouldUpdate = !route\n+ ? true\n+ : shouldUpdateNode(routeNode)(route, previousRoute)\nif (!lastReturnedValue) {\nlastReturnedValue = { route, previousRoute }\n} else if (\n!previousRoute ||\n- (previousRoute !== route && intersection === routeNode)\n+ (previousRoute !== route && shouldUpdate)\n) {\nlastReturnedValue = { route, previousRoute }\n}\n" } ]
TypeScript
MIT License
router5/router5
feat: smarter route node selector updates
580,249
20.04.2018 13:51:13
-3,600
6b20007314ead420bbdf2575fbf870cd77c250b0
chore: update dependency mapping prior to releasing
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/package.json", "new_path": "packages/react-router5/package.json", "diff": "\"homepage\": \"https://github.com/router5/router5/tree/master/packages/react-router5\",\n\"peerDependencies\": {\n\"react\": \"^0.14.0 || ^15.0.0 || ^16.0.0\",\n- \"router5\": \"^5.0.0 || ^6.0.0\"\n+ \"router5\": \">= 6.1.0 < 7.0.0\"\n},\n\"dependencies\": {\n\"prop-types\": \"~15.5.10\",\n- \"router5-transition-path\": \"^5.0.0\"\n+ \"router5-transition-path\": \"5.2.0\"\n},\n\"typings\": \"./index.d.ts\",\n\"devDependencies\": {\n" }, { "change_type": "MODIFY", "old_path": "packages/redux-router5/package.json", "new_path": "packages/redux-router5/package.json", "diff": "\"immutable\": \"^3.0.0\"\n},\n\"dependencies\": {\n- \"router5-transition-path\": \"^5.1.1\"\n+ \"router5-transition-path\": \"5.2.0\"\n},\n\"typings\": \"./index.d.ts\"\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "\"homepage\": \"http://router5.github.io\",\n\"dependencies\": {\n\"route-node\": \"3.1.0\",\n- \"router5-transition-path\": \"^5.1.1\",\n+ \"router5-transition-path\": \"5.2.0\",\n\"symbol-observable\": \"1.2.0\"\n},\n\"typings\": \"./index.d.ts\"\n" }, { "change_type": "MODIFY", "old_path": "packages/rxjs-router5/package.json", "new_path": "packages/rxjs-router5/package.json", "diff": "},\n\"homepage\": \"https://github.com/router5/router5/tree/master/packages/rxjs-router5\",\n\"dependencies\": {\n- \"router5-transition-path\": \"^5.1.1\",\n+ \"router5-transition-path\": \"5.2.0\",\n\"rxjs\": \"~5.4.3\"\n},\n\"peerDependencies\": {\n" }, { "change_type": "MODIFY", "old_path": "packages/xstream-router5/package.json", "new_path": "packages/xstream-router5/package.json", "diff": "},\n\"homepage\": \"https://github.com/router5/router5/tree/master/packages/xstream-router5\",\n\"dependencies\": {\n- \"router5-transition-path\": \"^5.1.1\",\n+ \"router5-transition-path\": \"5.2.0\",\n\"xstream\": \"^10.0.0\"\n},\n\"peerDependencies\": {\n" } ]
TypeScript
MIT License
router5/router5
chore: update dependency mapping prior to releasing
580,249
20.04.2018 15:25:10
-3,600
92933d430e7149b29543e5e972d8461ba5552763
docs: copy readme
[ { "change_type": "MODIFY", "old_path": "packages/router5/README.md", "new_path": "packages/router5/README.md", "diff": "router5 is a **framework and view library agnostic router**.\n* **view / state separation**: router5 processes routing **instructions** and outputs **state** updates.\n-* **univseral**: works client-side and server-side\n+* **universal**: works client-side and server-side\n* **simple**: define your routes, start to listen to route changes\n* **flexible**: you have control over transitions and what happens on transitions\n```js\nimport createRouter from 'router5'\nimport browserPlugin from 'router5/plugins/browser'\n-import listenersPlugin from 'router5/plugins/listeners'\nconst routes = [\n{ name: 'home', path: '/' },\n@@ -26,7 +25,6 @@ const routes = [\nconst router = createRouter(routes)\n.usePlugin(browserPlugin())\n- .userPlugin(listenersPlugin())\nrouter.start()\n```\n@@ -60,6 +58,18 @@ ReactDOM.render(\n)\n```\n+**With observables**\n+\n+Your router instance is compatible with most observable libraries.\n+\n+```js\n+import { from } from 'rxjs/observable/from'\n+\n+from(router).map(({ route }) => {\n+ /* happy routing */\n+})\n+```\n+\n### Guides\n" } ]
TypeScript
MIT License
router5/router5
docs: copy readme
580,249
20.04.2018 20:27:50
-3,600
434e70d35a6f9be038f47f13ed387185e2fd460b
chore: update react-router5 peer dependency
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/package.json", "new_path": "packages/react-router5/package.json", "diff": "\"homepage\": \"https://github.com/router5/router5/tree/master/packages/react-router5\",\n\"peerDependencies\": {\n\"react\": \"^0.14.0 || ^15.0.0 || ^16.0.0\",\n- \"router5\": \"^5.0.0 || ^6.0.0\"\n+ \"router5\": \">= 6.1.0 < 7.0.0\"\n},\n\"dependencies\": {\n\"prop-types\": \"~15.5.10\",\n" } ]
TypeScript
MIT License
router5/router5
chore: update react-router5 peer dependency
580,249
01.05.2018 10:52:47
-3,600
a580f1431da686c3876cd617f850c80fc9346aeb
fix: update route-node to latest version
[ { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "},\n\"homepage\": \"http://router5.github.io\",\n\"dependencies\": {\n- \"route-node\": \"3.1.0\",\n+ \"route-node\": \"3.1.1\",\n\"router5-transition-path\": \"^5.3.0\",\n\"symbol-observable\": \"1.2.0\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/yarn.lock", "new_path": "packages/router5/yarn.lock", "diff": "@@ -8,21 +8,17 @@ [email protected]:\ndependencies:\nsearch-params \"2.1.2\"\[email protected]:\n- version \"3.1.0\"\n- resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.1.0.tgz#7ced7ebd01a84cd7d84bd94ca831288200a7a0d4\"\[email protected]:\n+ version \"3.1.1\"\n+ resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.1.1.tgz#c7b33c9a9044918f131b9c31a7afc48de375044d\"\ndependencies:\npath-parser \"4.0.4\"\nsearch-params \"2.1.2\"\n-router5-transition-path@^5.1.1:\n- version \"5.2.0\"\n- resolved \"https://registry.yarnpkg.com/router5-transition-path/-/router5-transition-path-5.2.0.tgz#25ae7f75a12a17044f7766a180eb7377f372493c\"\n-\[email protected]:\nversion \"2.1.2\"\nresolved \"https://registry.yarnpkg.com/search-params/-/search-params-2.1.2.tgz#e0107b7e6f2e973d7991b8fbffc8b6664bc96edd\"\n-symbol-observable@~1.2.0:\[email protected]:\nversion \"1.2.0\"\nresolved \"https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804\"\n" } ]
TypeScript
MIT License
router5/router5
fix: update route-node to latest version
580,249
01.05.2018 11:00:28
-3,600
edc6926efad076eea4c27153a66d71ff8bb05574
fix: upgrade router5 transition path in yarn lock file
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/yarn.lock", "new_path": "packages/react-router5/yarn.lock", "diff": "@@ -226,9 +226,9 @@ react-test-renderer@^16.0.0-0:\nprop-types \"^15.6.0\"\nreact-is \"^16.3.1\"\n-router5-transition-path@^5.0.0:\n- version \"5.1.1\"\n- resolved \"https://registry.yarnpkg.com/router5-transition-path/-/router5-transition-path-5.1.1.tgz#89698deeaedcf0831a5c3393d8ae16c9f06a9744\"\n+router5-transition-path@^5.3.0:\n+ version \"5.3.0\"\n+ resolved \"https://registry.yarnpkg.com/router5-transition-path/-/router5-transition-path-5.3.0.tgz#113f7e09dffee5e22c7275c20fe25969c0bc1599\"\nsetimmediate@^1.0.5:\nversion \"1.0.5\"\n" } ]
TypeScript
MIT License
router5/router5
fix: upgrade router5 transition path in yarn lock file
580,249
01.05.2018 15:46:58
-3,600
1a2f5fd184116b2aa1f895947ba4fb0dd01b3f47
refactor: add hashchange event on IE11 only if useHash is true
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/plugins/browser/browser.js", "new_path": "packages/router5/modules/plugins/browser/browser.js", "diff": "@@ -25,21 +25,24 @@ const pushState = (state, title, path) =>\nconst replaceState = (state, title, path) =>\nwindow.history.replaceState(state, title, path)\n-const addPopstateListener = fn => {\n+const addPopstateListener = (fn, opts) => {\n+ const shouldAddHashChangeListener =\n+ opts.useHash && !supportsPopStateOnHashChange()\n+\nwindow.addEventListener('popstate', fn)\n- if (!supportsPopStateOnHashChange()) {\n+ if (shouldAddHashChangeListener) {\nwindow.addEventListener('hashchange', fn)\n}\n-}\n-const removePopstateListener = fn => {\n+ return () => {\nwindow.removeEventListener('popstate', fn)\n- if (!supportsPopStateOnHashChange()) {\n+ if (shouldAddHashChangeListener) {\nwindow.removeEventListener('hashchange', fn)\n}\n}\n+}\nconst getLocation = opts => {\nconst path = opts.useHash\n@@ -62,7 +65,6 @@ if (isBrowser) {\npushState,\nreplaceState,\naddPopstateListener,\n- removePopstateListener,\ngetLocation,\ngetState,\ngetHash\n@@ -74,7 +76,6 @@ if (isBrowser) {\npushState: noop,\nreplaceState: noop,\naddPopstateListener: noop,\n- removePopstateListener: noop,\ngetLocation: identity(''),\ngetState: identity(null),\ngetHash: identity('')\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/plugins/browser/index.js", "new_path": "packages/router5/modules/plugins/browser/index.js", "diff": "@@ -19,6 +19,7 @@ function browserPluginFactory(opts = {}, browser = safeBrowser) {\nforceDeactivate: options.forceDeactivate,\nsource\n}\n+ let removePopStateListener\nfunction browserPlugin(router) {\nconst routerOptions = router.getOptions()\n@@ -147,11 +148,16 @@ function browserPluginFactory(opts = {}, browser = safeBrowser) {\noptions.base = browser.getBase()\n}\n- browser.addPopstateListener(onPopState)\n+ removePopStateListener = browser.addPopstateListener(\n+ onPopState,\n+ options\n+ )\n}\nfunction onStop() {\n- browser.removePopstateListener(onPopState)\n+ if (removePopStateListener) {\n+ removePopStateListener()\n+ }\n}\nfunction onTransitionSuccess(toState, fromState, opts) {\n" } ]
TypeScript
MIT License
router5/router5
refactor: add hashchange event on IE11 only if useHash is true
580,249
12.05.2018 21:26:07
-3,600
9bd943580692b567019383193b25a351f775edec
refactor: enhance stream library compatibility
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"lint-staged\": \"~3.6.1\",\n\"mocha\": \"~3.4.2\",\n\"mocha-lcov-reporter\": \"~1.3.0\",\n+ \"most\": \"~1.7.3\",\n\"prettier\": \"~1.10.2\",\n\"react\": \"~16.3.0\",\n\"react-addons-test-utils\": \"~15.6.2\",\n\"rollup-plugin-commonjs\": \"~9.1.0\",\n\"rollup-plugin-node-resolve\": \"~3.3.0\",\n\"rollup-plugin-uglify\": \"~3.0.0\",\n+ \"rxjs\": \"~6.1.0\",\n\"sinon\": \"~2.3.4\",\n\"sinon-chai\": \"~2.11.0\",\n\"typescript\": \"^2.6.1\",\n\"webpack\": \"~4.5.0\",\n\"webpack-dev-middleware\": \"~3.1.2\",\n\"webpack-dev-server\": \"~3.1.3\",\n+ \"xstream\": \"~11.2.0\",\n\"yargs\": \"~11.1.0\"\n},\n\"dependencies\": {}\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/observable.js", "new_path": "packages/router5/modules/core/observable.js", "diff": "@@ -10,14 +10,16 @@ function observerPlugin(router) {\n}\nfunction subscribe(listener) {\n- const finalListener =\n- typeof listener === 'object'\n- ? listener.next.bind(listener)\n- : listener\n+ const isObject = typeof listener === 'object'\n+ const finalListener = isObject ? listener.next.bind(listener) : listener\nlisteners = listeners.concat(finalListener)\n- return () => unsubscribe(finalListener)\n+ const unsubscribeHandler = unsubscribe(finalListener)\n+\n+ return isObject\n+ ? { unsubscribe: unsubscribeHandler }\n+ : unsubscribeHandler\n}\nfunction observable() {\n@@ -28,9 +30,7 @@ function observerPlugin(router) {\n'Expected the observer to be an object.'\n)\n}\n- const unsubscribe = subscribe(observer)\n-\n- return { unsubscribe }\n+ return subscribe(observer)\n},\n[$$observable]() {\n" }, { "change_type": "ADD", "old_path": null, "new_path": "packages/router5/test/core/observable.js", "diff": "+import { expect } from 'chai'\n+import { from } from 'rxjs'\n+import { from as mostFrom } from 'most'\n+import xs from 'xstream'\n+import createTestRouter from '../_create-router'\n+\n+describe('core/observable', function() {\n+ let router\n+\n+ before(\n+ () =>\n+ (router = createTestRouter()\n+ .clone()\n+ .start())\n+ )\n+ after(() => router.stop())\n+\n+ it('should be compatible with rxjs', function() {\n+ const observable = from(router)\n+\n+ expect(observable.subscribe).to.exist\n+ })\n+\n+ it('should be compatible with xstream', function() {\n+ expect(xs.from(router)).not.to.throw\n+\n+ const observable = xs.fromObservable(router)\n+\n+ expect(observable.subscribe).to.exist\n+ })\n+\n+ it('should be compatible with most', function() {\n+ const observable = mostFrom(router)\n+\n+ expect(observable.subscribe).to.exist\n+ })\n+})\n" }, { "change_type": "MODIFY", "old_path": "yarn.lock", "new_path": "yarn.lock", "diff": "# yarn lockfile v1\n+\"@most/multicast@^1.2.5\":\n+ version \"1.3.0\"\n+ resolved \"https://registry.yarnpkg.com/@most/multicast/-/multicast-1.3.0.tgz#e01574840df634478ac3fabd164c6e830fb3b966\"\n+ dependencies:\n+ \"@most/prelude\" \"^1.4.0\"\n+\n+\"@most/prelude@^1.4.0\":\n+ version \"1.7.0\"\n+ resolved \"https://registry.yarnpkg.com/@most/prelude/-/prelude-1.7.0.tgz#0956ed464ad03e7fc95143eac0c6dd028498d975\"\n+\n\"@types/[email protected]\":\nversion \"0.0.38\"\nresolved \"https://registry.yarnpkg.com/@types/estree/-/estree-0.0.38.tgz#c1be40aa933723c608820a99a373a16d215a1ca2\"\n@@ -4483,6 +4493,14 @@ moment@^2.6.0:\nversion \"2.22.1\"\nresolved \"https://registry.yarnpkg.com/moment/-/moment-2.22.1.tgz#529a2e9bf973f259c9643d237fda84de3a26e8ad\"\n+most@~1.7.3:\n+ version \"1.7.3\"\n+ resolved \"https://registry.yarnpkg.com/most/-/most-1.7.3.tgz#406c31a66d73aa16957816fdf96965e27df84f1a\"\n+ dependencies:\n+ \"@most/multicast\" \"^1.2.5\"\n+ \"@most/prelude\" \"^1.4.0\"\n+ symbol-observable \"^1.0.2\"\n+\nmove-concurrently@^1.0.1:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92\"\n@@ -5743,6 +5761,12 @@ rxjs@^5.0.0-beta.11:\ndependencies:\nsymbol-observable \"1.0.1\"\n+rxjs@~6.1.0:\n+ version \"6.1.0\"\n+ resolved \"https://registry.yarnpkg.com/rxjs/-/rxjs-6.1.0.tgz#833447de4e4f6427b9cec3e5eb9f56415cd28315\"\n+ dependencies:\n+ tslib \"^1.9.0\"\n+\[email protected], safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:\nversion \"5.1.1\"\nresolved \"https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853\"\n@@ -6296,6 +6320,10 @@ [email protected]:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4\"\[email protected], symbol-observable@^1.0.2:\n+ version \"1.2.0\"\n+ resolved \"https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804\"\n+\nsymbol-tree@^3.2.1:\nversion \"3.2.2\"\nresolved \"https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6\"\n@@ -6453,6 +6481,10 @@ trim-right@^1.0.1:\nversion \"1.0.1\"\nresolved \"https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003\"\n+tslib@^1.9.0:\n+ version \"1.9.0\"\n+ resolved \"https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8\"\n+\[email protected]:\nversion \"0.0.0\"\nresolved \"https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6\"\n@@ -6933,6 +6965,12 @@ xml-name-validator@^2.0.1:\nversion \"2.0.1\"\nresolved \"https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-2.0.1.tgz#4d8b8f1eccd3419aa362061becef515e1e559635\"\n+xstream@~11.2.0:\n+ version \"11.2.0\"\n+ resolved \"https://registry.yarnpkg.com/xstream/-/xstream-11.2.0.tgz#4acb83211fa2edcd890e36f7a7ed02caee2339b5\"\n+ dependencies:\n+ symbol-observable \"1.2.0\"\n+\nxtend@^4.0.0, xtend@~4.0.1:\nversion \"4.0.1\"\nresolved \"https://registry.yarnpkg.com/xtend/-/xtend-4.0.1.tgz#a5c6d532be656e23db820efb943a1f04998d63af\"\n" } ]
TypeScript
MIT License
router5/router5
refactor: enhance stream library compatibility
580,249
12.05.2018 21:37:22
-3,600
0c402b0bcb67f4bf1cc2620bb9f45fe3f2a4e8d6
test: add unsubscribe handler tests
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/core/observable.js", "new_path": "packages/router5/modules/core/observable.js", "diff": "@@ -15,7 +15,7 @@ function observerPlugin(router) {\nlisteners = listeners.concat(finalListener)\n- const unsubscribeHandler = unsubscribe(finalListener)\n+ const unsubscribeHandler = () => unsubscribe(finalListener)\nreturn isObject\n? { unsubscribe: unsubscribeHandler }\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/test/core/observable.js", "new_path": "packages/router5/test/core/observable.js", "diff": "@@ -15,6 +15,20 @@ describe('core/observable', function() {\n)\nafter(() => router.stop())\n+ it('should accept a listener function', () => {\n+ const unsubscribe = router.subscribe(() => {})\n+\n+ expect(typeof unsubscribe).to.equal('function')\n+ })\n+\n+ it('should accept a listener object', () => {\n+ const subscription = router.subscribe({\n+ next: () => {}\n+ })\n+\n+ expect(typeof subscription.unsubscribe).to.equal('function')\n+ })\n+\nit('should be compatible with rxjs', function() {\nconst observable = from(router)\n" } ]
TypeScript
MIT License
router5/router5
test: add unsubscribe handler tests
580,249
14.05.2018 10:05:42
-3,600
627f8c69c419d291d29f1ffe0809694d18c70e17
fix: make sure pipe characters are encoded (Firefox issue)
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/plugins/browser/browser.js", "new_path": "packages/router5/modules/plugins/browser/browser.js", "diff": "@@ -48,7 +48,11 @@ const getLocation = opts => {\nconst path = opts.useHash\n? window.location.hash.replace(new RegExp('^#' + opts.hashPrefix), '')\n: window.location.pathname.replace(new RegExp('^' + opts.base), '')\n- return (path || '/') + window.location.search\n+\n+ // Fix Frefox issue with non encoded pipe characters\n+ const correctedPath = path.replace(/\\|/g, '%7C')\n+\n+ return (correctedPath || '/') + window.location.search\n}\nconst getState = () => window.history.state\n" } ]
TypeScript
MIT License
router5/router5
fix: make sure pipe characters are encoded (Firefox issue)
580,249
14.05.2018 12:29:52
-3,600
2e8d553d8a5cb0a28bf46c437ac83d2531085677
chore: update route-node to latest patch
[ { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "},\n\"homepage\": \"http://router5.github.io\",\n\"dependencies\": {\n- \"route-node\": \"3.1.1\",\n+ \"route-node\": \"3.2.0\",\n\"router5-transition-path\": \"^5.3.0\",\n\"symbol-observable\": \"1.2.0\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/yarn.lock", "new_path": "packages/router5/yarn.lock", "diff": "# yarn lockfile v1\[email protected]:\n- version \"4.0.4\"\n- resolved \"https://registry.yarnpkg.com/path-parser/-/path-parser-4.0.4.tgz#ba9cb1d9b38d924a640bec2d93b403050d060fe6\"\[email protected]:\n+ version \"4.1.0\"\n+ resolved \"https://registry.yarnpkg.com/path-parser/-/path-parser-4.1.0.tgz#41e4c69aa88c6b28c6f6e1200e9aebe9acc3da9e\"\ndependencies:\nsearch-params \"2.1.2\"\[email protected]:\n- version \"3.1.1\"\n- resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.1.1.tgz#c7b33c9a9044918f131b9c31a7afc48de375044d\"\[email protected]:\n+ version \"3.2.0\"\n+ resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.2.0.tgz#643de314d600b2e19be723851500aa646c5d3a9d\"\ndependencies:\n- path-parser \"4.0.4\"\n+ path-parser \"4.1.0\"\nsearch-params \"2.1.2\"\nrouter5-transition-path@^5.3.0:\n" } ]
TypeScript
MIT License
router5/router5
chore: update route-node to latest patch
580,249
16.05.2018 11:35:39
-3,600
c4c4ea0e1da4a6141c147b972e2f0306efdf9825
fix: fix subscribe method typings
[ { "change_type": "MODIFY", "old_path": "packages/router5/index.d.ts", "new_path": "packages/router5/index.d.ts", "diff": "@@ -17,7 +17,11 @@ declare module 'router5' {\nCancelFn,\nOptions as NavigationOptions\n} from 'router5/core/navigation'\n- import { SubscribeFn, SubscribeState } from 'router5/core/observable'\n+ import {\n+ SubscribeFn,\n+ UnsubscribeFn,\n+ SubscribeState\n+ } from 'router5/core/observable'\nimport { Middleware, MiddlewareFactory } from 'router5/core/middleware'\nimport { Plugin, PluginFactory } from 'router5/core/plugins'\nimport {\n@@ -55,6 +59,7 @@ declare module 'router5' {\nState,\nStateMeta,\nSubscribeFn,\n+ UnsubscribeFn,\nSubscribeState\n}\n@@ -257,10 +262,11 @@ declare module 'router5/core/observable' {\npreviousRoute: State\n}\nexport type SubscribeFn = (state: SubscribeState) => void\n+ export type UnsubscribeFn = () => void\nmodule 'router5/create-router' {\ninterface Router {\n- subscribe(cb: SubscribeFn): void\n+ subscribe(cb: SubscribeFn): UnsubscribeFn\n}\n}\n}\n" } ]
TypeScript
MIT License
router5/router5
fix: fix subscribe method typings
580,249
20.05.2018 17:56:28
-3,600
8fdd8e1e41acd930107ea7b4a2347ae8db4f816a
docs: add why router5
[ { "change_type": "ADD", "old_path": null, "new_path": "docs/introduction/why-router5.md", "diff": "+# Why router5?\n+\n+`router5` is part of a new generation of routers: instead of rendering \"views\" or \"pages\", router5 outputs its state. The main idea behind router5 is to treat routing state like any other application data or state.\n+\n+\"Traditional\" routing has been heavily influenced by server-side routing, which is stateless, while client-side routing is stateful. Watch my talk at ReactiveConf 2016: \"Past and future of client-side routing\", it gives a great overview of what routing is, and what router5 does:\n+\n+<div style=\"width: 100%; margin: 0 auto; text-align: center\">\n+ <iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/hblXdstrAg0\" frameborder=\"0\" allowfullscreen></iframe>\n+</div>\n+\n+For more in-depth description of router5, look at [Understanding router5](/docs/understanding-router5.html).\n" } ]
TypeScript
MIT License
router5/router5
docs: add why router5
580,249
20.05.2018 19:10:55
-3,600
d2e1c94ac9fc64bd6439d7481292d29dd3b57959
docs: correctly add youtube video link
[ { "change_type": "MODIFY", "old_path": "docs/introduction/why-router5.md", "new_path": "docs/introduction/why-router5.md", "diff": "\"Traditional\" routing has been heavily influenced by server-side routing, which is stateless, while client-side routing is stateful. Watch my talk at ReactiveConf 2016: \"Past and future of client-side routing\", it gives a great overview of what routing is, and what router5 does:\n+{% youtube %}\nhttps://www.youtube.com/watch?v=hblXdstrAg0\n+{% endyoutube %}\nFor more in-depth description of router5, look at [Understanding router5](/docs/understanding-router5.html).\n" } ]
TypeScript
MIT License
router5/router5
docs: correctly add youtube video link
580,249
21.05.2018 12:16:08
-3,600
1a6a16987910a1665673fac655d6964eba6c81a1
docs: add ohter introductory pages
[ { "change_type": "ADD", "old_path": null, "new_path": "docs/SUMMARY.md", "diff": "+# Table of Contents\n+\n+* [Read Me](../README.md)\n+* [Introduction](introduction/README.md)\n+ * [Why router5?](introduction/why-router5.md)\n+ * [Getting Started](introduction/getting-started.md)\n+ * [Ecosystem](introduction/ecosystem.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/introduction/Ecosystem.md", "diff": "+# Ecosystem\n+\n+> A list of repositories and links related to router5. If you want to add an item to the list, raise an issue [https://github.com/router5/router5.github.io/issues](https://github.com/router5/router5/issues)\n+\n+\n+## Middleware, plugins, bindings, components, etc...\n+\n+- [react-router5](https://github.com/router5/router5/tree/master/packages/react-router5) integration with react\n+- [redux-router5](https://github.com/router5/router5/tree/master/packages/redux-router5) integration with redux\n+- [mobx-router5](https://github.com/LeonardoGentile/mobx-router5): integration with MobX\n+- [react-mobx-router5](https://github.com/LeonardoGentile/react-mobx-router5): integration with Mobx and React\n+- [deku-router5](https://github.com/router5/router5/tree/master/packages/deku-router5) integration with deku\n+- [router5-link-interceptor](https://github.com/jas-chen/router5-link-interceptor) link interceptor\n+- [cycle-router5](https://github.com/axefrog/cycle-router5) integration with cyclejs (out of date)\n+\n+\n+## Examples\n+\n+- [Examples](https://github.com/router5/examples)\n+- [redux-examples](https://github.com/StevenIseki/redux-examples) contains a router5 example\n+- [router5-example](https://github.com/DavidStrada/router5-example) an example using jspm and jQuery\n+\n+\n+## Boilerplate\n+\n+- [router5-boilerplate](https://github.com/sitepack/router5-boilerplate)\n+- [universal-react-redux-hapi](https://github.com/nanopx/universal-react-redux-hapi)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/introduction/getting-started.md", "diff": "+# Getting started\n+\n+> _router5_ is available in all major formats: __ES6__, __CommonJS__, and __UMD__.\n+\n+It can be installed using __npm__ or __yarn__. Alternatively, you can download a specific version\n+from [github](https://github.com/router5/router5/releases).\n+\n+\n+## Installation\n+\n+```sh\n+# yarn\n+yarn add router5\n+# npm\n+npm install router5\n+```\n+\n+## Include _router5_ in your application\n+\n+__CommonJS__\n+\n+\n+```javascript\n+// ES2015+\n+import createRouter, { RouteNode, errorCodes, transitionPath, loggerPlugin, constants } from 'router5';\n+\n+import browserPlugin from 'router5/plugins/browser';\n+import listenersPlugin from 'router5/plugins/listeners';\n+import persistentParamsPlugin from 'router5/plugins/persistentParams';\n+\n+// ES5\n+var router5 = require('router5');\n+\n+var createRouter = router5.default;\n+var RouteNode = router5.RouteNode;\n+var errorCodes = router5.errorCodes;\n+var constants = router5.constants;\n+var transitionPath = router5.transitionPath;\n+var loggerPlugin = router5.loggerPlugin;\n+var constants = router5.constants;\n+\n+var browserPlugin = require('router5/plugins/browser');\n+var listenersPlugin = require('router5/plugins/listeners');\n+var persistentParamsPlugin = require('router5/plugins/persistentParams');\n+```\n+\n+__UMD__\n+\n+A UMD bundle is available in `/dist/umd`, and it should be used for AMD or globals. The bundle contains all _router5_ dependencies (_route-node_ and _path-parser_), but doesn't contain plugins.\n+\n+Plugins are packaged separately and available in `/dist/umd`:\n+- `browserPlugin` UMD module is named `router5BrowserPlugin`\n+- `listenersPlugin` UMD module is named `router5ListenersPlugin`\n+- `persistentParamsPlugin` UMD module is named `router5PersistentParamsPlugin`\n+bundle is named `router5ListenersPlugin`.\n" }, { "change_type": "MODIFY", "old_path": "docs/introduction/why-router5.md", "new_path": "docs/introduction/why-router5.md", "diff": "-# Why router5?\n+# Why router5\n`router5` is part of a new generation of routers: instead of rendering \"views\" or \"pages\", router5 outputs its state. The main idea behind router5 is to treat routing state like any other application data or state.\n" } ]
TypeScript
MIT License
router5/router5
docs: add ohter introductory pages
580,249
21.05.2018 12:26:43
-3,600
605d56c202dd15ec112a6a35e58a4a90f8a3fbbb
docs: add migration pages
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "# Table of Contents\n* [Read Me](../README.md)\n-* [Introduction](introduction/README.md)\n+* Introduction\n* [Why router5?](introduction/why-router5.md)\n* [Getting Started](introduction/getting-started.md)\n* [Ecosystem](introduction/ecosystem.md)\n+* Migration\n+ * [Migrating from 5.x to 6.x](migration/to-v6.md)\n+ * [Migrating from 4.x to 5.x](migration/to-v5.md)\n+ * [Migrating from 3.x to 4.x](migration/to-v4.md)\n+ * [Migrating from 2.x to 3.x](migration/to-v3.md)\n+ * [Migrating from 1.x to 2.x](migration/to-v2.md)\n+ * [Migrating from 0.x to 1.x](migration/to-v1.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/migration/to-v1.md", "diff": "+# Getting started\n+\n+> _router5_ is available in all major formats: __ES6__, __CommonJS__, and __UMD__.\n+\n+It can be installed using __npm__ or __yarn__. Alternatively, you can download a specific version\n+from [github](https://github.com/router5/router5/releases).\n+\n+\n+## Installation\n+\n+```sh\n+# yarn\n+yarn add router5\n+# npm\n+npm install router5\n+```\n+\n+## Include _router5_ in your application\n+\n+__CommonJS__\n+\n+\n+```javascript\n+// ES2015+\n+import createRouter, { RouteNode, errorCodes, transitionPath, loggerPlugin, constants } from 'router5';\n+\n+import browserPlugin from 'router5/plugins/browser';\n+import listenersPlugin from 'router5/plugins/listeners';\n+import persistentParamsPlugin from 'router5/plugins/persistentParams';\n+\n+// ES5\n+var router5 = require('router5');\n+\n+var createRouter = router5.default;\n+var RouteNode = router5.RouteNode;\n+var errorCodes = router5.errorCodes;\n+var constants = router5.constants;\n+var transitionPath = router5.transitionPath;\n+var loggerPlugin = router5.loggerPlugin;\n+var constants = router5.constants;\n+\n+var browserPlugin = require('router5/plugins/browser');\n+var listenersPlugin = require('router5/plugins/listeners');\n+var persistentParamsPlugin = require('router5/plugins/persistentParams');\n+```\n+\n+__UMD__\n+\n+A UMD bundle is available in `/dist/umd`, and it should be used for AMD or globals. The bundle contains all _router5_ dependencies (_route-node_ and _path-parser_), but doesn't contain plugins.\n+\n+Plugins are packaged separately and available in `/dist/umd`:\n+- `browserPlugin` UMD module is named `router5BrowserPlugin`\n+- `listenersPlugin` UMD module is named `router5ListenersPlugin`\n+- `persistentParamsPlugin` UMD module is named `router5PersistentParamsPlugin`\n+bundle is named `router5ListenersPlugin`.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/migration/to-v2.md", "diff": "+# Migrating from 1.x to 2.x\n+\n+\n+## New features\n+\n+* You can now pass to `router.add()` objects containing `canActivate` functions and those functions will be registered. No need to call for each route `addNode` or `canActivate`.\n+* Persistent parameters plugin now available.\n+\n+## Breaking change\n+\n+* `router.registerComponent` and `router.deregisterComponent` have been removed in favour of `canDeactivate`\n+* Additional arguments now apply to middleware functions.\n+* Context has been removed from middleware functions.\n+* Middleware functions are now a function taking a router instance and returning a function called on each transition.\n+* Plugins, like middleware functions, are now a function taking a router instance and returning an object of methods (which doesn't contain an `init` function anymore).\n+* `autoCleanUp` is no longer shared with _router5-listeners_. If you need to turn off automatic deregistration of node listeners, pass `{ autoCleanUp: false }` to the listeners plugin.\n+* `router5` package now exports `Router5` as default, and `RouteNode`, `loggerPlugin`, `errCodes` and `transitionPath` as named exports\n+\n+## Code example\n+\n+__ES2015+__\n+\n+```javascript\n+import Router5, { loggerPlugin } from 'router5';\n+import historyPlugin from 'router5-history';\n+import listenersPlugin from 'router5-listeners';\n+\n+const router = new Router5()\n+ .add([{\n+ name: 'home',\n+ path: '/home'\n+ }])\n+ .usePlugin(historyPlugin())\n+ .usePlugin(listenersPlugin())\n+ // Development helper\n+ .usePlugin(loggerPlugin())\n+ .start();\n+```\n+\n+__ES5__\n+\n+```javascript\n+var router5 = require('router5');\n+var Router5 = router5.default;\n+var loggerPlugin = router5.loggerPlugin;\n+\n+var historyPlugin = require('router5-history');\n+var listenersPlugin = require('router5-listeners');\n+\n+var router = new Router5()\n+ .add([{\n+ name: 'home',\n+ path: '/home'\n+ }])\n+ .usePlugin(historyPlugin())\n+ .usePlugin(listenersPlugin())\n+ // Development helper\n+ .usePlugin(loggerPlugin())\n+ .start();\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/migration/to-v3.md", "diff": "+# Migrating from 2.x to 3.x\n+\n+\n+## New features\n+\n+* When a transition fails (either in a `canActivate`, `canDeactivate` or middleware function), a custom error can be returned containing a `redirect` property.\n+* Persistent parameters plugin now available.\n+\n+## Breaking change\n+\n+There are no breaking changes.\n+\n+## Code example\n+\n+Redirecting to a login page if the current user is not logged in:\n+\n+```javascript\n+// With promises\n+router.canActivate(\n+ 'profile',\n+ () => isLoggedIn()\n+ .catch(() => ({ redirect: { name: 'login' } }))\n+);\n+\n+// With callbacks\n+router.canActivate(\n+ 'profile',\n+ (toState, fromState, done) => {\n+ isLoggedIn()\n+ .then(() => done(null, toState))\n+ .catch(() => done(({ redirect: { name: 'login' } })))\n+ }\n+);\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/migration/to-v4.md", "diff": "+# Migrating from 3.x to 4.x\n+\n+\n+With version 4.0.0, _router5_ has been refactored. API for plugins, middleware functions, `canActivate` and `canDeactivate` functions are now consistent.\n+\n+## Router instanciation\n+\n+_router5_ default export is now a `createRouter` function as opposed to a `Router5` class. The API is identical between `createRouter(routes, options)` and `new Router5(routes, options)`.\n+\n+```js\n+import createRouter from 'router5';\n+\n+const router = createRouter(routes, options);\n+```\n+\n+## Plugins moved\n+\n+`router5-history`, `router5-persistent-params` and `router5-listeners` have been moved to router5 main repository. They are no longer individual modules but are distributed with router5 module.\n+\n+```js\n+import browserPlugin from 'router5/plugins/browser';\n+import listenersPlugin from 'router5/plugins/listeners';\n+import persistentParamsPlugin from 'router5/plugins/persistentParams';\n+```\n+\n+The history plugin has been renamed 'browser plugin', to better describe its responsabilities. It deals with any URL related options and methods, to make router5 fully runtime environment agnostic:\n+- `useHash`, `hashPrefix` and `base` options need to be passed to `browserPlugin`, not router5\n+- `buildUrl`, `matchUrl` and `urlToPath` methods are no longer present by default and are added to your router instance by `browserPlugin`.\n+\n+```js\n+import browserPlugin from 'router5/plugins/browser';\n+\n+router.usePlugin(browserPlugin({\n+ useHash: true\n+}));\n+```\n+\n+## Dependency injection reworked\n+\n+Dependency injection has been reworked: `setAdditionalArgs` has been renamed to `setDependencies` / `setDependency` and `getAdditionalArgs` has been renamed to `getDependencies`.\n+\n+```js\n+router.setDependency('store', store);\n+// Or\n+router.setDependencies({ store });\n+\n+router.getDependencies(); // => { store: store }\n+```\n+\n+Dependencies are no longer injected before `toState` in middleware, canActivate and canDeactivate functions. Instead, they are injected alongside `router`, and are now available in plugins too. They are passed as an object of key / value pairs: it will now be easier to share code, plugins, middleware without sharing the exact same dependencies.\n+\n+\n+## Middleware and route lifecycle functions alignment\n+\n+canActivate and canDeactivate functions have been reworked to be aligned with middleware functions.\n+\n+```js\n+function isAdmin(router, dependencies) {\n+ return function (toState, fromState, done) {\n+ /* boolean, promise or call done */\n+ }\n+}\n+\n+router.canActivate('admin', isAdmin);\n+```\n+\n+Boolean shortcuts are still supported (`canActivate('admin', isAdmin)`).\n+\n+More importantly, they are now __thunks__: they are executed when added, and their returned functions will be executed when required by the router. It enables the use of __closures__.\n+\n+\n+## Unknown routes (not found) supported\n+\n+A new `allowNotFound` option available, to give a new strategy to deal with unkown routes.\n+\n+If `defaultRoute` option is not supplied and a path cannot be matched by the router, then the router will emit an `ROUTE_NOT_FOUND` error unless `allowNotFound` is set to true. In that case, the router will allow the transition to happen and will generate a state like the following one (given a User tried to navigate to an unknown URL `/route-not-found`):\n+\n+```js\n+import { constants } from 'router5';\n+\n+{\n+ name: constants.UNKNOWN_ROUTE\n+ params: { path: '/route-not-found' },\n+ path: '/route-not-found'\n+}\n+```\n+\n+## Other notable changes\n+\n+* AMD and globals bundle are no longer distributed, use the UMD bundle instead\n+* `usePlugin` and `useMiddleware` behave the same: you can supply one or more argument, and calling them thereafter will add more plugins / middleware functions (`useMiddleware` used to overwrite middleware functions)\n+* `errCodes` has been renamed to `errorCodes`\n+* Route parameters and transition options are now optional in `navigate`, allowing users to only supply a route name and a done callback (`router.navigate('home', () => { /* ... */ })`)\n+* A new `setRootNodePath` function has been added to configure the path of the root node. It can be used for example to list a number of allowed query parameters for all routes if `strictQueryParams` option is set to `true`.\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/migration/to-v5.md", "diff": "+# Migrating from 4.x to 5.x\n+\n+\n+With version 5.0.0, `router5` is now a monorepo: all repos have been imported into https://github.com/router5/router5. This will make maintenance and release of new versions easier.\n+\n+## Bug fixes\n+\n+Not found state is now passed to middleware functions on start: if you use `allowNotFound` option and have custom middleware functions, make sure they still work.\n+\n+## Default options\n+\n+* router `strictQueryParams` option is now `false` by default: if you currently don't specify that option, you need to explicitely set it to `true` to keep the same behaviour.\n+* browser plugin option `preserveHash` is now `true` by default\n+\n+## Packages renamed\n+\n+* `router5.helpers` package has been renamed to `router5-helpers`\n+* `router5.transition-path` package has been renamed to `router5-transition-path`\n" } ]
TypeScript
MIT License
router5/router5
docs: add migration pages
580,249
21.05.2018 12:45:39
-3,600
e6482b3c0a94aeed02d2add1b244aa963dda2d68
docs: add overview section
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "# Table of Contents\n-* [Read Me](../README.md)\n* Introduction\n* [Why router5?](introduction/why-router5.md)\n* [Getting Started](introduction/getting-started.md)\n* [Ecosystem](introduction/ecosystem.md)\n+* Overview\n+ * [Core concepts](overview/core-concepts.md)\n+ * [Transition phase](overview/transition.md)\n* Migration\n* [Migrating from 5.x to 6.x](migration/to-v6.md)\n* [Migrating from 4.x to 5.x](migration/to-v5.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/overview/core-conepts.md", "diff": "+# Core Concepts\n+\n+> The main idea behind router5 is to treat routes like any other application data / state. This guide aims to take you through router5's key concepts.\n+\n+In \"traditional\" routing, a specific route is associated with a _route handler_. Such handlers would return your application tree or would link your route to a specific view / component. With router5 it is reversed: rather than the router updating the view, it is up to the view to listen / bind / subscribe to route changes in order to update itself.\n+\n+{% youtube %}\n+https://www.youtube.com/watch?v=hblXdstrAg0\n+{% endyoutube %}\n+\n+\n+## The state\n+\n+[router5](https://github.com/router5/router5) is the core repository. Once you have defined your routes and started your router, it only does one thing: it takes navigation instructions and output state updates.\n+\n+![Router](./router.png)\n+\n+Updating your browser history or listening to URL changes is considered a side-effect, because they are specific to an environment where your application might run (the browser). You can use the browser plugin to update the browser URL and translate popstate events to routing instructions.\n+\n+A state object will contain:\n+- The `name` of the route\n+- The parameters (`params`) of the route\n+- The `path` of the route\n+\n+\n+### Tree of routes\n+\n+Your routes are organised in a tree, made of segments and nodes. At the top will always be an unnamed root node (its name is an empty string `''`). It gives you the ability to have nested routes, each node of the tree (except the root node) is a valid route of your application.\n+\n+For the rest of this article, we will use the following simple example of a few nested routes:\n+\n+![Tree of routes](./routes-tree.png)\n+\n+\n+### Transition\n+\n+During a transition phase, the router will follow a __transition path__: it will deactivate some segments and activate some new ones. The intersection node between deactivated and activated segments is the __transition node__. The __transition node__ is very important for your view, as we are about to discover.\n+\n+Using the tree of routes shown above, let's consider we transition from `home` to `admin.users`: the transition node will be _the unamed root node_, we will deactivate `home` and activate `admin` and `admin.users`.\n+\n+![Transition example #1](./routes-tree-transition-1.png)\n+\n+Now let's see another example: a transition from `admin.roles` to `admin.users`. The transition node will be `admin`, and the admin segment will remain activated. `admin.roles` will be deactivated and `admin.users` will be activated.\n+\n+![Transition example #1](./routes-tree-transition-2.png)\n+\n+\n+## The view\n+\n+> The router is unaware of your view and you need to bind your view to your router's state updates.\n+\n+This is where you need to forget about route handlers and linking routes to components. On the left you have state updates coming from your router, and on the right you have your application view. Your application view is already in a certain state, and will now have to update to reflect the latest state updates.\n+\n+On a route change, you only need to re-render a portion of your app. Depending on where you come from, for the same given route, a smaller or larger part of your application view will need to be re-rendered. This is why route handlers are not helpful: routing is not about mapping a route to a component, it is about going from A to B.\n+\n+\n+### Binding to route changes\n+\n+Your view will need to subscribe to route updates, or specific route updates. There are three types of events you might want to react to, depending on what information you are after:\n+\n+- The router has navigated to a route (any route)\n+- The router has navigated to a specified route\n+- A specified node is the transition node\n+\n+The last point is the main one. We have seen your routes are organised in a tree. Your components are also organised in a tree, like DOM elements of a page are. In your application, each route node (when active) will have a corresponding component node. Those components should be re-rendered if their associated node is a transition node of a route change.\n+\n+Below is an example of associated route and component nodes, when `admin.users` is active:\n+\n+![Transition nodes](./routes-tree-components.png)\n+\n+The current route is `admin.users`. If we were to navigate to `home`, `Main` would be the component associated to the route node `''`. It would re-render to output a `Home` component instance rather than an `Admin` one, discarding the whole admin view.\n+\n+> The __transition node__ (as explained above), _is_ the node to re-render your view from.\n+\n+The __listeners plugin__ makes possible to register those three types of listeners: _\"any change\"_ listener, route listener and node listener. Note that `listenersPlugin` has a limit of one node listener per node (_listenersPlugin_ uses [router5-transition-path](https://github.com/router5/router5/tree/master/packages/router5-transition-path) to compute the transition path between two router5 states).\n+\n+![Relation between router and view](./router-view.png)\n+\n+In slightly more complicated cases, you might have other parts of your screen to re-render. For example, you might have a header, a main menu or a side panel to update on a route change: in that case you can listen to any route change or a specific route change, and re-render that specific portion of a screen. Keep transition nodes for your \"main\" content update.\n+\n+\n+## What is router5 best suited for?\n+\n+Router 5 is best suited for trees of components, where components can easily be composed together. It works best with React, deku, cyclejs, etc...\n+\n+It also works very well with state containers like [Redux](http://redux.js.org/): your state container is placed between your view and your router, and your view subscribes to state updates (rather than directly subscribing to route updates). In that case you don't need to use the listeners plugin.\n+\n+- [react-router5](https://github.com/router5/router5/tree/master/packages/react-router5) and [deku-router5](https://github.com/router5/router5/tree/master/packages/deku-router5) both provide a `routeNode(nodeName)(BaseComponent)` higher-order component for re-rendering from a node down when the given node is the transition node.\n+- [redux-router5](https://github.com/router5/router5/tree/master/packages/redux-router5) provides a selector `routeNode(nodeName)` which will release the new router state object when the specified node is the transition node. When combined with react or deku, you use it with `connect` from [react-redux](https://github.com/rackt/react-redux) or [deku-redux](https://github.com/troch/deku-redux).\n" }, { "change_type": "ADD", "old_path": "docs/overview/flow-graph.png", "new_path": "docs/overview/flow-graph.png", "diff": "Binary files /dev/null and b/docs/overview/flow-graph.png differ\n" }, { "change_type": "ADD", "old_path": "docs/overview/flow-transition.png", "new_path": "docs/overview/flow-transition.png", "diff": "Binary files /dev/null and b/docs/overview/flow-transition.png differ\n" }, { "change_type": "ADD", "old_path": "docs/overview/router-view.png", "new_path": "docs/overview/router-view.png", "diff": "Binary files /dev/null and b/docs/overview/router-view.png differ\n" }, { "change_type": "ADD", "old_path": "docs/overview/router.png", "new_path": "docs/overview/router.png", "diff": "Binary files /dev/null and b/docs/overview/router.png differ\n" }, { "change_type": "ADD", "old_path": "docs/overview/routes-tree-components.png", "new_path": "docs/overview/routes-tree-components.png", "diff": "Binary files /dev/null and b/docs/overview/routes-tree-components.png differ\n" }, { "change_type": "ADD", "old_path": "docs/overview/routes-tree-transition-1.png", "new_path": "docs/overview/routes-tree-transition-1.png", "diff": "Binary files /dev/null and b/docs/overview/routes-tree-transition-1.png differ\n" }, { "change_type": "ADD", "old_path": "docs/overview/routes-tree-transition-2.png", "new_path": "docs/overview/routes-tree-transition-2.png", "diff": "Binary files /dev/null and b/docs/overview/routes-tree-transition-2.png differ\n" }, { "change_type": "ADD", "old_path": "docs/overview/routes-tree.png", "new_path": "docs/overview/routes-tree.png", "diff": "Binary files /dev/null and b/docs/overview/routes-tree.png differ\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/overview/transition.md", "diff": "+# Transition\n+\n+> The following flowchart illustrates a transition process between two states.\n+\n+![Going from 'users.view' to 'orders.view'](./flow-graph.png)\n+\n+![Transition flow chart](./flow-transition.png)\n" } ]
TypeScript
MIT License
router5/router5
docs: add overview section
580,249
21.05.2018 12:55:14
-3,600
aadf734e5f0598b8a65f4ce9148b79ddb2116e6c
docs: add defining routes and router options pages
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "# Table of Contents\n+* [Read Me](../README.md)\n* Introduction\n* [Why router5?](introduction/why-router5.md)\n* [Getting Started](introduction/getting-started.md)\n* Overview\n* [Core concepts](overview/core-concepts.md)\n* [Transition phase](overview/transition.md)\n+* Guides\n+ * [Defining routes](guides/defining-routes.md)\n+ * [Router options](guides/router-options.md)\n* Migration\n* [Migrating from 5.x to 6.x](migration/to-v6.md)\n* [Migrating from 4.x to 5.x](migration/to-v5.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/guides/defining-routes.md", "diff": "+# Defining routes\n+\n+There are a few ways to add routes to your router. You can specify your routes when creating a router instance and / or use chainable `add` and `addNode` methods to add routes.\n+\n+## With plain objects\n+\n+You can define your routes as a flat array or nested array of routes. When using a flat array of routes, nested route names need to have their full name specified.\n+\n+Route objects optionally accept the following properties:\n+- `canActivate`: a method to control whether or not the route node can be activated (see [Preventing navigation](./preventing-navigation.html))\n+- `forwardTo`: if specified, the router will transition to the forwarded route instead. It is useful for defaulting to a child route\n+- `defaultParams`: an object of default params to extend when navigating and when matching a path\n+- `encodeParams(stateParams)`: a function of state params returning path params. Used when building a path given a route name and params (typically on start and navigation).\n+- `encodeParams(pathParams)`: a function of path params returning params. Used when matching a path to map path params to state params.\n+\n+Note on `encodeParams` and `decodeParams`: one can't be used without another, and applying one after another should be equivalent to an identity function.\n+\n+__encodeParams(stateParams: Object): Object__\n+\n+A function taking state params and returning path params.\n+\n+__decodedParams\n+\n+__Flat array of routes__\n+\n+```javascript\n+const routes = [\n+ { name: 'users', path: '/users'},\n+ { name: 'users.view', path: '/view'},\n+ { name: 'users.list', path: '/list'}\n+];\n+```\n+\n+__Nested arrays of routes__\n+\n+\n+```javascript\n+const routes = [\n+ { name: 'users', path: '/users', children: [\n+ { name: 'view', path: '/view'},\n+ { name: 'list', path: '/list'}\n+ ]}\n+];\n+```\n+\n+\n+__Nested arrays of routes__\n+\n+## Adding routes\n+\n+You can add all your routes at once using `createRouter` or `router.add`.\n+\n+__createRouter(routes, options)__\n+\n+```javascript\n+const router = createRouter(routes, options);\n+```\n+\n+__add(routes)__\n+\n+`.add()` accepts single nodes, flat or nested arrays.\n+\n+```javascript\n+myRouter.add({ name: 'about', path: '/about' });\n+// Or\n+myRouter.add([\n+ {name: 'about', path: '/about'},\n+ {name: 'contact', path: '/contact'},\n+]);\n+```\n+\n+__addNode(name, path[, canActivate])__\n+\n+You can add routes node by node, specifying a node name and its segment path.\n+\n+```javascript\n+var router = createRouter()\n+ .addNode('users', '/users')\n+ .addNode('users.view', '/view/:id')\n+ .addNode('users.list', '/list');\n+```\n+\n+## Configuring the root node path\n+\n+At the top of your tree of routes, there is an unamed node called the root node. Its path is empty and can be configured using `router.setRootPath(path)`. It can be used for example to list a number of allowed query parameters for all routes in strict query parameters mode (`router.setRootPath('?param1&param2')`).\n" }, { "change_type": "MODIFY", "old_path": "docs/introduction/Ecosystem.md", "new_path": "docs/introduction/Ecosystem.md", "diff": "# Ecosystem\n-> A list of repositories and links related to router5. If you want to add an item to the list, raise an issue [https://github.com/router5/router5.github.io/issues](https://github.com/router5/router5/issues)\n+A list of repositories and links related to router5. If you want to add an item to the list, raise an issue [https://github.com/router5/router5.github.io/issues](https://github.com/router5/router5/issues)\n## Middleware, plugins, bindings, components, etc...\n" }, { "change_type": "MODIFY", "old_path": "docs/introduction/getting-started.md", "new_path": "docs/introduction/getting-started.md", "diff": "# Getting started\n-> _router5_ is available in all major formats: __ES6__, __CommonJS__, and __UMD__.\n-\n-It can be installed using __npm__ or __yarn__. Alternatively, you can download a specific version\n+_router5_ is available in all major formats: __ES6__, __CommonJS__, and __UMD__. It can be installed using __npm__ or __yarn__. Alternatively, you can download a specific version\nfrom [github](https://github.com/router5/router5/releases).\n" }, { "change_type": "MODIFY", "old_path": "docs/introduction/why-router5.md", "new_path": "docs/introduction/why-router5.md", "diff": "https://www.youtube.com/watch?v=hblXdstrAg0\n{% endyoutube %}\n-For more in-depth description of router5, look at [Understanding router5](/docs/understanding-router5.html).\n+For more in-depth description of router5, look at [Understanding router5](../docs/understanding-router5.html).\n" }, { "change_type": "MODIFY", "old_path": "docs/overview/core-conepts.md", "new_path": "docs/overview/core-conepts.md", "diff": "# Core Concepts\n-> The main idea behind router5 is to treat routes like any other application data / state. This guide aims to take you through router5's key concepts.\n+The main idea behind router5 is to treat routes like any other application data / state. This guide aims to take you through router5's key concepts.\nIn \"traditional\" routing, a specific route is associated with a _route handler_. Such handlers would return your application tree or would link your route to a specific view / component. With router5 it is reversed: rather than the router updating the view, it is up to the view to listen / bind / subscribe to route changes in order to update itself.\n" }, { "change_type": "MODIFY", "old_path": "docs/overview/transition.md", "new_path": "docs/overview/transition.md", "diff": "# Transition\n-> The following flowchart illustrates a transition process between two states.\n+The following flowchart illustrates a transition process between two states.\n![Going from 'users.view' to 'orders.view'](./flow-graph.png)\n" } ]
TypeScript
MIT License
router5/router5
docs: add defining routes and router options pages
580,249
21.05.2018 13:04:53
-3,600
ff1744e3f68ee47813555cf5296eae92692c0335
docs: update defining routes
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [Transition phase](overview/transition.md)\n* Guides\n* [Defining routes](guides/defining-routes.md)\n+ * [Path Syntax](guides/path-syntax.md)\n* [Router options](guides/router-options.md)\n* Migration\n* [Migrating from 5.x to 6.x](migration/to-v6.md)\n" }, { "change_type": "MODIFY", "old_path": "docs/guides/defining-routes.md", "new_path": "docs/guides/defining-routes.md", "diff": "@@ -4,24 +4,23 @@ There are a few ways to add routes to your router. You can specify your routes w\n## With plain objects\n-You can define your routes as a flat array or nested array of routes. When using a flat array of routes, nested route names need to have their full name specified.\n+You can define your routes using plain objects:\n+- `name`: the route name\n+- `path`: the route path, relative to its parent\nRoute objects optionally accept the following properties:\n- `canActivate`: a method to control whether or not the route node can be activated (see [Preventing navigation](./preventing-navigation.html))\n- `forwardTo`: if specified, the router will transition to the forwarded route instead. It is useful for defaulting to a child route\n- `defaultParams`: an object of default params to extend when navigating and when matching a path\n- `encodeParams(stateParams)`: a function of state params returning path params. Used when building a path given a route name and params (typically on start and navigation).\n-- `encodeParams(pathParams)`: a function of path params returning params. Used when matching a path to map path params to state params.\n+- `decodeParams(pathParams)`: a function of path params returning params. Used when matching a path to map path params to state params.\nNote on `encodeParams` and `decodeParams`: one can't be used without another, and applying one after another should be equivalent to an identity function.\n-__encodeParams(stateParams: Object): Object__\n-A function taking state params and returning path params.\n+### Flat route list\n-__decodedParams\n-\n-__Flat array of routes__\n+You can define your routes using a flat list, in which case route names must be specified in full.\n```javascript\nconst routes = [\n@@ -31,8 +30,9 @@ const routes = [\n];\n```\n-__Nested arrays of routes__\n+### Tree of routes\n+You can define your routes using a tree (making use of `children`), in which case route names are relative to their parent.\n```javascript\nconst routes = [\n@@ -44,21 +44,19 @@ const routes = [\n```\n-__Nested arrays of routes__\n-\n## Adding routes\nYou can add all your routes at once using `createRouter` or `router.add`.\n-__createRouter(routes, options)__\n+### When creating your router\n```javascript\nconst router = createRouter(routes, options);\n```\n-__add(routes)__\n+### After creating your router\n-`.add()` accepts single nodes, flat or nested arrays.\n+`.add()` accepts single or multiple nodes, flat or nested.\n```javascript\nmyRouter.add({ name: 'about', path: '/about' });\n@@ -69,16 +67,6 @@ myRouter.add([\n]);\n```\n-__addNode(name, path[, canActivate])__\n-\n-You can add routes node by node, specifying a node name and its segment path.\n-\n-```javascript\n-var router = createRouter()\n- .addNode('users', '/users')\n- .addNode('users.view', '/view/:id')\n- .addNode('users.list', '/list');\n-```\n## Configuring the root node path\n" } ]
TypeScript
MIT License
router5/router5
docs: update defining routes
580,249
21.05.2018 13:10:04
-3,600
b3baeed6ec7337c485b02cac5c533756306b7f10
docs: add path syntax doc
[ { "change_type": "ADD", "old_path": null, "new_path": "docs/guides/path-syntax.md", "diff": "+# Path syntax\n+\n+{% hint %}\n+_router5_ uses [path-parser](https://github.com/troch/path-parser) for parsing, matching and generating URLs\n+{% endhint %}\n+\n+## Defining parameters\n+\n+Four parameter types are supported:\n+\n+- `:param`: url parameters\n+- `;matrix`: matrix parameters\n+- `*splat`: for parameters spanning over multiple segments. Splat parameters are greedy and could swallow a\n+large part of your URL. It is recommended to handle with care and to ONLY use on routes without children.\n+- `?param1&param2` or `?:param1&:param2`: query parameters\n+\n+\n+## Constrained parameters\n+\n+Url and matrix parameters can be constrained with a regular expression. Backslashes need to be escaped.\n+\n+- `:param<\\\\d+>` will match numbers only for parameter param\n+- `;id<[a-fA-F0-9]{8}>` will match 8 characters hexadecimal strings for parameter id\n+\n+Constraints are also applied when building paths: when passing incorrect params to `.navigate()`,\n+an error will be thrown.\n+\n+\n+## Absolute nested paths\n+\n+You can define absolute nested paths (not concatenated with their parent's paths). Note that absolute paths are not allowed if any parent of a node has parameters.\n+\n+```js\n+const router = createRouter([\n+ { name: 'admin', path: '/admin' },\n+ { name: 'admin.users', path: '~/users' }\n+]);\n+\n+router.buildPath('admin.users'); // '/users'\n+```\n" } ]
TypeScript
MIT License
router5/router5
docs: add path syntax doc
580,249
21.05.2018 13:15:12
-3,600
67987516cca533615b6a46268d5fa093eca4714f
docs: add navigatiing guide
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [Defining routes](guides/defining-routes.md)\n* [Path Syntax](guides/path-syntax.md)\n* [Router options](guides/router-options.md)\n+ * [Navigating](guides/navigating.md)\n* Migration\n* [Migrating from 5.x to 6.x](migration/to-v6.md)\n* [Migrating from 4.x to 5.x](migration/to-v5.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/guides/navigating.md", "diff": "+# Navigating\n+\n+After configuring your routes, you need to enable navigation by starting your router instance.\n+\n+\n+## Starting your router\n+\n+```javascript\n+const myRouter = createRouter([\n+ { name: 'home', path: '/home' },\n+ { name: 'about', path: '/about' },\n+ { name: 'contact', path: '/contact' }\n+]);\n+\n+myRouter.start('/home');\n+```\n+\n+> When using `.start()`, you should supply a starting path or state except if you use the browser plugin (the current URL will automatically be used).\n+\n+Invoking the `.start(startPathOrState[, done])` function will:\n+\n+- Attempt to navigate to `startPathOrState`\n+- Attempt to match the current URL if no `startPathOrState` was provided, or navigation failed\n+- Attempt to navigate to the default route if it could not match the provided start path or if `startPathOrState` was not provided / failed\n+\n+And will:\n+\n+- Enable navigation\n+\n+Providing a starting state is designed to be used for universal JavaScript applications: see [universal applications](./universal-applications.md).\n+\n+\n+## Defining a default route\n+\n+A default route can be set in `createRouter` options. The following example will cause your application to navigate\n+to `/about`:\n+\n+```javascript\n+var myRouter = createRouter([\n+ { name: 'home', path: '/home' },\n+ { name: 'section', path: '/:section' }\n+ ], {\n+ defaultRoute: 'section'\n+ defaultParams: {section: 'about'}\n+ })\n+ .start(function (err, state) {\n+ /* ... */\n+ });\n+```\n+\n+A callback can be passed to start and will be invoked once the router has transitioned to the default route.\n+\n+\n+## Navigating to a specific route\n+\n+Router5 exposes the following method: `navigate(routeName, routeParams, opts)`. This method has to be\n+called for navigating to a different route: __clicks on links won't be intercepted by the router__.\n+\n+```javascript\n+myRouter.navigate('section', {section: 'contact'});\n+// Will navigate to '/contact'\n+```\n+\n+### Forcing a reload\n+\n+When trying to navigate to the current route nothing will happen unless `reload` is set to `true`.\n+\n+```javascript\n+myRouter.navigate('section', {section: 'contact'}, {reload: true});\n+```\n+\n+### Replacing current state\n+\n+Set `replace` to true for replacing the current state in history when navigating to a new route. Default\n+behaviour is to add an entry in history.\n+\n+```javascript\n+myRouter.navigate('section', {section: 'contact'}, {replace: true});\n+```\n+\n+### Custom options\n+\n+You can pass any option to `navigate`: those options will be added to the state of your router (under `meta`).\n+\n+\n+### Navigate callback\n+\n+Like for `.start()`, `.navigate()` accepts a callback (last argument):\n+\n+```javascript\n+myRouter.navigate('route', function (err, state) {\n+ /* ... */\n+})\n+```\n+\n+## Stopping your router\n+\n+At any time you can stop (pause) a router and it will prevent any navigation. To resume, simply invoke `.start()` again.\n+\n+```javascript\n+myRouter.stop();\n+```\n" }, { "change_type": "MODIFY", "old_path": "docs/guides/router-options.md", "new_path": "docs/guides/router-options.md", "diff": "@@ -18,7 +18,6 @@ var router = createRouter([], {\nstrictTrailingSlash: false,\ncaseSensitive: false\n})\n- .setOption('strictQueryParams', false)\n```\n### Default route\n" } ]
TypeScript
MIT License
router5/router5
docs: add navigatiing guide
580,249
21.05.2018 13:22:11
-3,600
2b91d117f4661b5dfdff190bd70a3a3ddc97711d
docs: add observability page
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [Path Syntax](guides/path-syntax.md)\n* [Router options](guides/router-options.md)\n* [Navigating](guides/navigating.md)\n+ * [Observability](guides/observability.md)\n* Migration\n* [Migrating from 5.x to 6.x](migration/to-v6.md)\n* [Migrating from 4.x to 5.x](migration/to-v5.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/guides/observability.md", "diff": "+# Observability\n+\n+\n+From [email protected] and onwards, your router instance is compatible with most observable libraries.\n+\n+\n+## Subscribing to state changes\n+\n+You can subscribe to route changes using `router.subscribe()`, and will receive an object containing `route` and `previousRoute`.\n+Alternatively, you can use the listeners plugin.\n+\n+\n+## Observing state changes\n+\n+Router instances are observables. You can use most stream libraries out there and create a stream from your router instance:\n+- RxJS (`Rx.Observable.from(router)`)\n+- xstream (`xs.fromObservable(router)`)\n+- most (`most.from(router)`)\n+- etc...\n" } ]
TypeScript
MIT License
router5/router5
docs: add observability page
580,249
21.05.2018 13:24:10
-3,600
4707390ceafe457355df7f059fb9a6f462206ed6
docs: add browser plugin page
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [Router options](guides/router-options.md)\n* [Navigating](guides/navigating.md)\n* [Observability](guides/observability.md)\n+ * [In the browser](guides/browser.md)\n* Migration\n* [Migrating from 5.x to 6.x](migration/to-v6.md)\n* [Migrating from 4.x to 5.x](migration/to-v5.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/guides/browser.md", "diff": "+# In the browser\n+\n+\n+The browser plugin will automatically update your browser URL and state on route changes. It will also listen to popstate events (triggered by back and forward buttons and manual URL changes).\n+\n+## Using the browser plugin\n+\n+This plugin uses HTML5 history API and therefore is not compatible with browsers which don't support it. Refer to [caniuse.com](http://caniuse.com/#search=history) for browser compatibility.\n+\n+It adds a bunch of functions to work with full URLs: `router.buildUrl(routeName, routeParams)` and `router.matchUrl(url)`. It also decorates the start function so you don't have to supply any start path (it extracts it from the current URL).\n+\n+\n+```javascript\n+import browserPlugin from 'router5/plugins/browser';\n+\n+const router = createRouter()\n+ .usePlugin(browserPlugin({\n+ useHash: true\n+ }))\n+ .start();\n+```\n+\n+\n+## Plugin options\n+\n+- `forceDeactivate`: default to `true`, meaning `canDeactivate` handlers won't get called on popstate events. It is not recommended to set it to `false`.\n+- `useHash`\n+- `hashPrefix`\n+- `base`: the base of your application (the part to add / preserve between your domain and your route paths).\n+- `preserveHash`: whether to preserve the initial hash value on page load (default to `true`, only if `useHash` is `false`)\n+- `mergeState`: whether to keep any value added in history state by a 3rd party or not (default to `false`)\n" } ]
TypeScript
MIT License
router5/router5
docs: add browser plugin page
580,249
21.05.2018 13:28:33
-3,600
d08b473baee10e3d1cc9bc3ec7db094642398646
docs: update observability state change
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [Path Syntax](guides/path-syntax.md)\n* [Router options](guides/router-options.md)\n* [Navigating](guides/navigating.md)\n- * [Observability](guides/observability.md)\n* [In the browser](guides/browser.md)\n+ * [Observing state](guides/observability.md)\n* Migration\n* [Migrating from 5.x to 6.x](migration/to-v6.md)\n* [Migrating from 4.x to 5.x](migration/to-v5.md)\n" }, { "change_type": "MODIFY", "old_path": "docs/guides/observability.md", "new_path": "docs/guides/observability.md", "diff": "-# Observability\n+# Observing state\nFrom [email protected] and onwards, your router instance is compatible with most observable libraries.\n" } ]
TypeScript
MIT License
router5/router5
docs: update observability state change
580,249
21.05.2018 15:01:57
-3,600
1fe65f8ec7bfc42e9ea56a4ac9a358fe0b1da007
docs: add prevent navigation and redirecting pages
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [Navigating](guides/navigating.md)\n* [In the browser](guides/browser.md)\n* [Observing state](guides/observability.md)\n+* Advanced\n+ * [Preventing navigation](advanced/preventing-navigation.md)\n+ * [Errors and redirections](advanced/errors-redirections.md)\n* Migration\n* [Migrating from 5.x to 6.x](migration/to-v6.md)\n* [Migrating from 4.x to 5.x](migration/to-v5.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/advanced/errors-redirections.md", "diff": "+# Errors and redirecting\n+\n+When failing a transition function (canActivate, canDeactivate, middleware) custom errors can be returned. Custom errors can be a string or an object and will be added to the error object and passed to `start` and `navigate` callbacks).\n+\n+\n+## Custom errors\n+\n+Custom errors can be a string (error code) or an object. They can be passed using the first argument of `done` callbacks or encapsulated in failed promises.\n+\n+### A string\n+\n+```js\n+router.canActivate('profile', (router) => (toState, fromState, done) => {\n+ done('my custom error');\n+});\n+\n+router.navigate('profile', (err, state) => {\n+ /* Error:\n+ {\n+ code: 'CANNOT_ACTIVATE',\n+ segment: 'profile',\n+ error: 'my custom error'\n+ }\n+ /*\n+})\n+```\n+\n+### An object\n+\n+```js\n+router.canActivate('profile', (router) => (toState, fromState, done) => {\n+ done({\n+ why: 'because'\n+ });\n+});\n+\n+router.navigate('profile', (err, state) => {\n+ /* Error:\n+ {\n+ code: 'CANNOT_ACTIVATE',\n+ segment: 'profile',\n+ why: 'because'\n+ }\n+ */\n+})\n+```\n+\n+## Redirecting after an error\n+\n+When you fail a transition, you can pass a `redirect` property to specify what the router should do next. `redirect` must be an object containing the route name you want to redirect to (`name`) and optionally can contain params (`params`).\n+\n+```js\n+router.canActivate('profile', (router) => (toState, fromState, done) => {\n+ return isUserLoggedIn()\n+ .catch(() => Promise.reject({ redirect: { name: 'login' }}));\n+});\n+\n+router.navigate('profile', (err, state) => {\n+ // err is null\n+ state.name === 'login';\n+});\n+```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/advanced/preventing-navigation.md", "diff": "+# Preventing navigation\n+\n+It is a common case to want to allow / prevent navigation away from a view or component: if a User is in the middle of completing a form and data has not been saved, you might want to warn them about data being lost or prevent them to leave the current view until data has been saved.\n+\n+\n+## Using lifecycle functions\n+\n+Router5 supports `canActivate` and `canDeactivate` functions for route segments:\n+- `canActivate` functions are called on segments which will become active as a result of a route change\n+- `canDeactivate` functions are called on segments which will become inactive as a result of a route change\n+\n+Both functions have the same signature than middleware functions. Their result can be synchronous (returning a boolean) or asynchronous (returning a promise or calling `done(err, result)`).\n+\n+{% hint %}\n+if a canActivate or canDeactivate function doesn't return a boolean, a promise or doesn't call back, the transition will not proceed.\n+{% endhint %}\n+\n+```javascript\n+const canActivate = (router) => (toState, fromState) => {\n+ return true;\n+}\n+\n+router.canActivate('admin', canActivate);\n+```\n+\n+`canActivate` functions are called from top to bottom on newly activated segments. `canDeactivate` methods are invoked from bottom to top.\n+\n+\n+### Using middleware functions\n+\n+Middleware functions behave like `canActivate` and `canDeactivate`. Read more about [middleware](./middleware.md).\n" } ]
TypeScript
MIT License
router5/router5
docs: add prevent navigation and redirecting pages
580,249
21.05.2018 16:09:58
-3,600
5403d2c983cfa9ab18315ac34ad5d5591d278390
docs: add async data doc
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* Advanced\n* [Preventing navigation](advanced/preventing-navigation.md)\n* [Errors and redirections](advanced/errors-redirections.md)\n+ * [Loading async data](advanced/async-data.md)\n* Migration\n* [Migrating from 5.x to 6.x](migration/to-v6.md)\n* [Migrating from 4.x to 5.x](migration/to-v5.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/advanced/async-data.md", "diff": "+# Loading async data\n+\n+Loading async data is always an important task of a web application. Very often, data and routes are tied to your application business logic. Therefore, loading data on a route change is very common.\n+\n+The way data loading can work with routing depends on what you might call your \"routing strategy\":\n+- Do you want a route transition to wait for data to be loaded?\n+- Do you want a route transition to fail if data cannot be loaded?\n+- How do you bind your view to data?\n+\n+There are many ways to handle data coming from a router and from an API:\n+- your components can receive them both at the same time\n+- your components can receive a route update first and then a data update later\n+- your components can receive a route update first and decide to load data\n+- etc...\n+\n+Router5 doesn't provide an opinionated way of handling async data, instead this article demonstrates the tools router5 can provide to help you loading data. You shouldn't view those examples as _the_ way to load data, their purpose is purely illustrative and they don't cover every case (error handling, server-side data loading, etc...). Instead you should aim to do things and organise your code the way you think is best for you and your application.\n+\n+## Using a middleware\n+\n+> You can use your router state objects as a container for route-specific data.\n+\n+You can use a middleware if you want your router to wait for data updates and/or prevent a route transition to happen if data loading fails.\n+When doing so, you can use `toState` state object as a container for your route-specific data: the listeners plugin will pass it to your view (with the data you attached to it). You shouldn't mutate `toState` if you don't explicitly ask the router to wait by either calling a `done` callback or by returning a promise.\n+\n+First, we need to define what data need to be loaded for which route segment:\n+\n+```javascript\n+const routes = [\n+ {\n+ name: 'home',\n+ path: '/home'\n+ },\n+ {\n+ name: 'users',\n+ path: '/users',\n+ onActivate: (params) => fetch('/users').then(data => ({ users: data.users }))\n+ },\n+ {\n+ name: 'users.user',\n+ path: '/:id',\n+ onActivate: (params) => fetch(`/users/${params.id}`).then(data => ({ user: data.user }))\n+ }\n+]\n+```\n+\n+Then we create a middleware function which will invoke data for the activated segments on a route change. In this example, data are loaded in parallel using `Promise.all`. You can proceed differently by loading data in series, or by implementing dependencies between your `onActivate` handlers.\n+\n+```javascript\n+import transitionPath from 'router5.transition-path';\n+\n+const dataMiddlewareFactory = (routes) => (router) => (toState, fromState) => {\n+ const { toActivate } = transitionPath(toState, fromState);\n+ const onActivateHandlers =\n+ toActivate\n+ .map(segment => routes.find(r => r.name === segment).onActivate)\n+ .filter(Boolean)\n+\n+ return Promise\n+ .all(onActivateHandlers)\n+ .then(data => {\n+ const routeData = data.reduce((accData, rData) => Object.assign(accData, rData), {});\n+ return { ...toState, data: routeData };\n+ });\n+};\n+```\n+\n+And when configuring your router:\n+\n+```javascript\n+import { routes } from './routes';\n+\n+const router = createRouter(routes);\n+/* ... configure your router */\n+\n+/* data middleware */\n+router.useMiddleware(dataMiddlewareFactory(routes));\n+```\n+\n+In the case you don't want a route transition to wait for data to be loaded, you cannot use the router state object as a data container. Instead, you should load data from your components or use a state container like [redux](https://redux.js.org).\n+\n+\n+## Using a state container (redux)\n+\n+> Using a state container like redux gives you a lot more flexibility with your routing strategy.\n+\n+Using a state container like redux gives you a lot more flexibility with your routing strategy. Because all data ends up in the same bucket that your components can listen to, data loading doesn't need to block route transitions. The only thing it needs is a reference to your store so actions can be dispatched. As a result, your view can represent with greater details the state of your application: for example your UI can be a lot more explicit about displaying loading feedback. Not blocking route transitions also means immediate URL updates (history), making your app feel more responsive.\n+\n+The following example assumes the use a redux store configured with a `redux-thunk` middleware.\n+\n+```javascript\n+import { loadUsers, loadUser } from './actionCreators';\n+\n+const routes = [\n+ {\n+ name: 'home',\n+ path: '/home'\n+ },\n+ {\n+ name: 'users',\n+ path: '/users',\n+ onActivate: (params) => (dispatch) =>\n+ fetch('/users').then(data => dispatch(loadUsers(data.users)))\n+ },\n+ {\n+ name: 'users.user',\n+ path: '/:id',\n+ onActivate: (params) => (dispatch) =>\n+ fetch(`/users/${params.id}`).then(data => dispatch(loadUser(data.user)))\n+ }\n+]\n+```\n+\n+You need to create your store and router, and pass your store to your router instance (with `.setDependency()`):\n+\n+```javascript\n+router.setDependency('store', store);\n+```\n+\n+Then we create a router5 middleware for data which will load data on a transition success.\n+\n+```javascript\n+import { actionTypes } from 'redux-router5';\n+import transitionPath from 'router5.transition-path';\n+\n+const onRouteActivateMiddleware = (routes) => (router, dependencies) => (toState, fromState, done) => {\n+ const { toActivate } = transitionPath(toState, fromState);\n+\n+ toActivate.forEach(segment => {\n+ const routeSegment = routes.find(r => r.name === segment);\n+\n+ if (routeSegment && routeSegment.onActivate) {\n+ dependencies.store.dispatch(routeSegment.onActivate(toState.params));\n+ }\n+ });\n+\n+ done();\n+};\n+```\n+\n+Finally, just create your store and include `onRouteActivateMiddleware(routes)` middleware.\n+\n+## Async data loading and universal applications\n+\n+The two examples above show two different techniques of loading data with a router5 middleware. One is blocking, one is non-blocking. But what about universal applications?\n+\n+The answer is very simple: block on the server-side, and choose to block or not on the client-side! For the example with example, you would need dispatch to return promises (with redux-thunk, your thunks need to return promises for their async operations).\n+\n+\n+## Chunk loading\n+\n+Chunk loading (loading code asynchronoulsy) is similar to data loading, since one can consider code is a form of data. With middlewares, you can call a done callback or return a promise, making them perfectly usable with `require.ensure` or `System.import`. Like examples above, you can implement similar techniques with, let's say, a `loadComponent` route property.\n+\n+```js\n+const routes = {\n+ name: 'users',\n+ path: '/users',\n+ onActivate: (params) => (dispatch) =>\n+ fetch('/users').then(data => dispatch(loadUsers(data.users))),\n+ loadComponent: () => import('./views/UsersList')\n+ },\n+};\n+```\n+\n+Then what you need is a middleware triggering `loadComponent`.\n+\n+There are also emerging techniques of anticipated loading rather than lazy loading (i.e. from a specific view / component, chunks are loaded in anticipation of where a user is likely to go next). We could implement a `relatedComponents` property.\n+\n+\n+```js\n+const routes = [\n+ {\n+ name: 'home',\n+ path: '/home',\n+ loadComponent: () => import('./views/Home'),\n+ relatedComponents: [ 'users' ]\n+ },\n+ {\n+ name: 'users',\n+ path: '/users',\n+ onActivate: (params) => (dispatch) =>\n+ fetch('/users').then(data => dispatch(loadUsers(data.users))),\n+ loadComponent: () => import('./views/UsersList'),\n+ relatedComponents: [ 'home' ]\n+ },\n+};\n+```\n+\n+Then on a transition, what you might want to consider this strategy:\n+- Load data and component (chunk)\n+- Once done, request idle callback to start loading sibling components\n" } ]
TypeScript
MIT License
router5/router5
docs: add async data doc
580,249
21.05.2018 16:23:39
-3,600
cafd5beedcf6b8c96237dca33d34921035c0ceb1
docs: add universal routing doc
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [Preventing navigation](advanced/preventing-navigation.md)\n* [Errors and redirections](advanced/errors-redirections.md)\n* [Loading async data](advanced/async-data.md)\n+ * [Universal routing](advanced/universal-routing.md)\n* Migration\n* [Migrating from 5.x to 6.x](migration/to-v6.md)\n* [Migrating from 4.x to 5.x](migration/to-v5.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/advanced/universal-routing.md", "diff": "+# Universal routing\n+\n+_Router5_ is capable to run on the server and in clients. This enables you to reuse the same routes for both client-side navigation and server-side pre-rendering. This is essentially done via two steps:\n+\n+ 1. **Server-side** - Pass to your router the current URL (using `start`), and pass the resolved state to your client.\n+ 2. **Client-side** - Pass to your router the starting state received from the server and pass it to your router, so it can start with the provided state (and won't run the transition to the already activated page).\n+\n+\n+## Create your router (client & server)\n+\n+You can use the same code for configuring your router on both client and server sides. The history plugin, for example, can be safely used on Node.js and in browsers.\n+\n+```js\n+const createRouter = require( 'router5' ).default;\n+const listenersPlugin = require( 'router5/plugins/listeners' );\n+const browserPlugin = require( 'router5/plugins/browser' );\n+\n+function createRouter() {\n+ return createRouter([\n+ { name: 'home', path: '/home' },\n+ { name: 'about', path: '/about' },\n+ { name: 'contact', path: '/contact' },\n+ { name: '404', path: '/404' }\n+ ], {\n+ trailingSlash: true,\n+ defaultRoute: '404'\n+ })\n+ .usePlugin(browserPlugin({\n+ useHash: false\n+ }))\n+}\n+\n+export default createRouter\n+```\n+\n+## Server-side Routing\n+\n+> This example is an [Express](http://expressjs.com/) with [Swig](http://paularmstrong.github.io/swig/) application. Make changes where needed to suit your preferred frameworks.\n+\n+For universal applications, you need to:\n+- Create a new router instance for each request, using the request URL\n+- Send the state to the client and start your router with this initial state\n+\n+**`server.js`**\n+```javascript\n+import express from 'express';\n+import createRouter from 'router5';\n+import swig from 'swig';\n+\n+const app = express();\n+\n+// Swig is used for templating in this example\n+// Use what you are comfortable with\n+app.engine( 'html', swig.renderFile );\n+app.set( 'view engine', 'html' );\n+app.set( 'views', './views' );\n+\n+app.get( '*', ( req, res ) => {\n+ // Create a new router for each request\n+ const router = createRouter();\n+\n+ router.start( req.originalUrl, function done( error, state ) {\n+ if ( error ) {\n+ res.status( 500 ).send( error );\n+ } else {\n+ res.send(/* Use your router state, send some HTML! */ );\n+ }\n+ });\n+\n+} );\n+\n+app.listen( 8080, function logServerStart() {\n+ console.log( 'Server is listening on port 8080...' );\n+} );\n+```\n+\n+**`base.html`**\n+```html\n+<!doctype html>\n+<html lang=\"en-US\">\n+ <head>\n+ <title>Example Server-side Routing</title>\n+ </head>\n+\n+ <body>\n+ <script src=\"/js/router.js\"></script>\n+ <script type=\"text/javascript\">\n+ /**\n+ * Load the App's inital state from the server\n+ * @type {JSON}\n+ */\n+ var initialState = JSON.parse('{{ initialState | safe }}');\n+\n+\n+ /**\n+ * Start our Router\n+ * @param {Error} error Router start error\n+ * @param {Object} state State Object\n+ * @return {undefined}\n+ */\n+ app.router.start(initialState, function(error, state) {\n+ if (error) console.error('router error', error);\n+ });\n+ </script>\n+ </body>\n+\n+</html>\n+\n+```\n+\n+From here forth, you can continue to use router5 as if it was a regular Single-Page Application.\n+\n+\n+## Performance\n+\n+A new router has to be created server-side on each request. If your app is large (containing dozens of routes), the creation of your router will take up to a couple of hundred milliseconds.\n+\n+Instead of creating a new router for each request, router5 includes a cloning mechanism: create a base router, and clone it for each request.\n+\n+{% hint %}\n+A user reported a gain from 300ms to 10ms per request for creating a new router, with cloning.\n+{% endhint %}\n+\n+```js\n+const baseRouter = createRouter(/* ... */);\n+\n+const router = baseRouter.clone(dependencies);\n+```\n" } ]
TypeScript
MIT License
router5/router5
docs: add universal routing doc
580,249
21.05.2018 16:28:32
-3,600
7b334caee338d77f02e29897ed5a5f4698da1278
docs: add middleware and plugins pages
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [In the browser](guides/browser.md)\n* [Observing state](guides/observability.md)\n* Advanced\n+ * [Plugins](advanced/plugins.md)\n+ * [Middleware](advanced/middleware.md)\n* [Preventing navigation](advanced/preventing-navigation.md)\n* [Errors and redirections](advanced/errors-redirections.md)\n* [Loading async data](advanced/async-data.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/advanced/middleware.md", "diff": "+# Middleware\n+\n+Multiple middleware functions can be registered with a router instance. They are invoked in series after the router has made sure active\n+route segments can be deactivated and future active route segments can be activated. Middleware functions are for example a great way to load data for your routes.\n+\n+## Registering middleware functions\n+\n+A middleware is a function taking a router instance and registered dependencies (like lifecycle methods and plugins) and returning a function which will be called on each transition (unless a transition failed at the _canActivate_ or _canDeactivate_ state).\n+\n+A middleware function can return a boolean for synchronous results, a promise or call\n+a done callback for asynchronous operations. If it returns false, a rejected promise or a callback with an error, it will fail the transition.\n+\n+This type of function is ideal to remove data loading logic from components, and is a good fit\n+for applications aiming at having a centralised state object.\n+\n+```javascript\n+const mware1 = (router) => (toState, fromState, done) => {\n+ // Let's fetch data and call done\n+ done();\n+};\n+\n+const mware2 = (router) => (toState, fromState, done) => {\n+ // Let's fetch data and call done\n+ done();\n+};\n+\n+router.useMiddleware(mware1, mware2);\n+```\n+\n+`useMiddleware` can be called multiple times, but keep in mind that registration order matters. You can clear all your middleware functions by using `router.clearMiddleware()`.\n+\n+## Adding data to state\n+\n+It is possible to mutate the `toState` object by adding properties, or to pass a new state object in callbacks or promises.\n+When passing a new object, the router will ignore it if initial state properties (`name`, `params` and `path`) are changed.\n+\n+```javascript\n+import { getData } from './dataApi';\n+\n+const dataLoader = router =>\n+ (toState, fromState) =>\n+ // toState object will be extended with data values\n+ getData().then(data => ({ ...toState, ...data }));\n+```\n+\n+## Custom errors\n+\n+When failing a transition in a middleware function, custom errors can be returned. Custom errors can be a string or an object:\n+- when a string, the router will return ```{ code: 'TRANSITION_ERR', error: '<your string>'}```\n+- when an object, the returned error object will be extended with your error object ```{ code: 'TRANSITION_ERR', ...errorObject }```\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/advanced/plugins.md", "diff": "+# Plugins\n+\n+router5 is extensible with the use of plugins. Plugins can decorate a route instance and do things on specific router and transition events.\n+\n+\n+## Plugin requirements\n+\n+A plugin is a function taking a router instance and returning an object with a name and at least one of the following methods:\n+\n+- `onStart()`: invoked when `router.start()` is called\n+- `onStop()`: invoked when `router.stop()` is called\n+- `onTransitionStart(toState, fromState)`\n+- `onTransitionCancel(toState, fromState)`\n+- `onTransitionError(toState, fromState, err)`\n+- `onTransitionSuccess(toState, fromState, opts)` (options contains `replace` and `reload` boolean flags)\n+\n+\n+## Registering a plugin\n+\n+```javascript\n+function myPlugin(router, dependencies) {\n+ return {\n+ onTransitionSuccess: (toState, fromState) => {\n+ console.log('Yippee, navigation to ' + toState.name + ' was successful!');\n+ }\n+ };\n+\n+myPlugin.pluginName = 'MY_PLUGIN';\n+\n+const router = createRouter()\n+ .usePlugin(myPlugin);\n+\n+router.hasPlugin('MY_PLUGIN'); // => true\n+```\n+\n+\n+## Plugin examples\n+\n+- [Browser plugin](https://github.com/router5/router5/blob/master/packages/router5/modules/plugins/browser/index.js)\n+- [Persistent params plugin](https://github.com/router5/router5/blob/master/packages/router5/modules/plugins/persistentParams/index.js)\n+- [Logger](https://github.com/router5/router5/blob/master/packages/router5/modules/plugins/logger/index.js)\n+\n+Router5 includes a logging plugin that you can use to help development\n+\n+```javascript\n+import createRouter, { loggerPlugin } from 'router5';\n+\n+const router = createRouter()\n+ .usePlugin(loggerPlugin);\n+```\n" } ]
TypeScript
MIT License
router5/router5
docs: add middleware and plugins pages
580,249
21.05.2018 16:30:00
-3,600
09c45a98eb25146c3f585ea1e6f208e3e2fda985
docs: add dependency injection docs
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [Middleware](advanced/middleware.md)\n* [Preventing navigation](advanced/preventing-navigation.md)\n* [Errors and redirections](advanced/errors-redirections.md)\n+ * [Dependency injection](advanced/dependency-injection.md)\n* [Loading async data](advanced/async-data.md)\n* [Universal routing](advanced/universal-routing.md)\n* Migration\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/advanced/dependency-injection.md", "diff": "+# Dependency injection\n+\n+When using lifecycle methods (`canActivate`, `canDeactivate`), middleware or plugins, you might need to access specific objects from your application: a store, a specific API, etc... You can pass their reference to router5 and they will be passed alongside your router instance.\n+\n+You can register all dependencies at once, or one by one.\n+\n+```js\n+const router = createRouter(routes, options, dependencies);\n+```\n+\n+```js\n+router.setDependencies({ store, api });\n+// or\n+router.setDependency('store', store);\n+router.setDependency('api', api);\n+```\n+\n+You can retrieve your current dependencies references using `getDependencies()`.\n+\n+Lifecycle methods (`canActivate`, `canDeactivate`), middleware or plugins will be called with them:\n+\n+```js\n+const plugin = (router, dependencies) => ({\n+ /*\n+ onStart() {},\n+ onStop() {},\n+ onTransitionStart() {},\n+ ...\n+ */\n+});\n+```\n+\n+```js\n+const canActivate = (router, dependencies) =>\n+ (toState, fromState, done) {\n+ /* ... */\n+ }\n+```\n+\n+\n+```js\n+const middleware = (router, dependencies) =>\n+ (toState, fromState, done) {\n+ /* ... */\n+ }\n+```\n" } ]
TypeScript
MIT License
router5/router5
docs: add dependency injection docs
580,249
21.05.2018 16:35:55
-3,600
a4b4dac75e65a8dfe93df6eebe7a05a9a2c0400b
docs: add with React and with Redux pages
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [Navigating](guides/navigating.md)\n* [In the browser](guides/browser.md)\n* [Observing state](guides/observability.md)\n+ * [With React](guides/with-react.md)\n+ * [With Redux](guides/with-redux.md)\n* Advanced\n* [Plugins](advanced/plugins.md)\n* [Middleware](advanced/middleware.md)\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/guides/with-react.md", "diff": "+# With React\n" }, { "change_type": "ADD", "old_path": null, "new_path": "docs/guides/with-redux.md", "diff": "+# With Redux\n" } ]
TypeScript
MIT License
router5/router5
docs: add with React and with Redux pages
580,249
21.05.2018 16:38:40
-3,600
984711113952d2f4bb6ce2315134440c545f7de3
docs: move overview into introduction
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [Why router5?](introduction/why-router5.md)\n* [Getting Started](introduction/getting-started.md)\n* [Ecosystem](introduction/ecosystem.md)\n-* Overview\n- * [Core concepts](overview/core-concepts.md)\n- * [Transition phase](overview/transition.md)\n+ * [Core concepts](introduction/core-concepts.md)\n+ * [Transition phase](introduction/transition.md)\n* Guides\n* [Defining routes](guides/defining-routes.md)\n* [Path Syntax](guides/path-syntax.md)\n" }, { "change_type": "RENAME", "old_path": "docs/overview/core-concepts.md", "new_path": "docs/introduction/core-concepts.md", "diff": "" }, { "change_type": "RENAME", "old_path": "docs/overview/flow-graph.png", "new_path": "docs/introduction/flow-graph.png", "diff": "" }, { "change_type": "RENAME", "old_path": "docs/overview/flow-transition.png", "new_path": "docs/introduction/flow-transition.png", "diff": "" }, { "change_type": "RENAME", "old_path": "docs/overview/router-view.png", "new_path": "docs/introduction/router-view.png", "diff": "" }, { "change_type": "RENAME", "old_path": "docs/overview/router.png", "new_path": "docs/introduction/router.png", "diff": "" }, { "change_type": "RENAME", "old_path": "docs/overview/routes-tree-components.png", "new_path": "docs/introduction/routes-tree-components.png", "diff": "" }, { "change_type": "RENAME", "old_path": "docs/overview/routes-tree-transition-1.png", "new_path": "docs/introduction/routes-tree-transition-1.png", "diff": "" }, { "change_type": "RENAME", "old_path": "docs/overview/routes-tree-transition-2.png", "new_path": "docs/introduction/routes-tree-transition-2.png", "diff": "" }, { "change_type": "RENAME", "old_path": "docs/overview/routes-tree.png", "new_path": "docs/introduction/routes-tree.png", "diff": "" }, { "change_type": "RENAME", "old_path": "docs/overview/transition.md", "new_path": "docs/introduction/transition.md", "diff": "" } ]
TypeScript
MIT License
router5/router5
docs: move overview into introduction
580,249
21.05.2018 21:06:12
-3,600
98d5be429999fd2d8b8a9404be8acf9092a662e0
docs: add with redux docs and redux-router5 readme
[ { "change_type": "MODIFY", "old_path": "docs/guides/with-redux.md", "new_path": "docs/guides/with-redux.md", "diff": "# With Redux\n+\n+\n+## Demo and example with Redux\n+\n+* [https://stackblitz.com/edit/react-redux-router5](https://stackblitz.com/edit/react-redux-router5)\n+\n+\n+## How to use\n+\n+You have two ways to use redux-router5, depending on how you want to navigate:\n+- Using the router5 plugin (named `reduxPlugin`)\n+- Using the redux middleware (named `router5Middleware`)\n+\n+In both cases, __use the provided reducer (`router5Reducer`).__\n+\n+\n+## Using the router plugin\n+\n+If you choose to not use the middleware, you need to add `reduxPlugin` to your router. The plugin simply syncs the router state with redux. To navigate, you will need to invoke `router.navigate`. If you use React, you can use `BaseLink` from `react-router5`.\n+\n+```js\n+import { reduxPlugin } from 'redux-router5';\n+\n+// You need a router instance and a store instance\n+router.usePlugin(reduxPlugin(store.dispatch));\n+```\n+\n+\n+## Using the redux middleware\n+\n+The redux middleware automatically adds the redux plugin to the provided router instance. It will convert a set of redux actions to routing instructions. The available action creators are:\n+\n+- `navigateTo(routeName, routeParams = {}, routeOptions = {})`\n+- `cancelTransition()`\n+- `clearErrors()`\n+- `canActivate(routeName, true | false)`\n+- `canDeactivate(routeName, true | false)`\n+\n+```javascript\n+import { actions } from 'redux-router5'\n+```\n+\n+Use `router5Middleware` alongside your other middlewares:\n+\n+```javascript\n+import { createStore, applyMiddleware } from 'redux';\n+import { router5Middleware } from 'redux-router5';\n+\n+const createStoreWithMiddleware = applyMiddleware(\n+ router5Middleware(router)\n+)(createStore)\n+```\n+\n+\n+## Reducer\n+\n+This packages exposes a reducer (`router5Reducer`) that you can add to your application. It contains four properties:\n+- `route`\n+- `previousRoute`\n+- `transitionRoute` (the current transitioning route)\n+- `transitionError` (the last error which occured)\n+\n+```js\n+import { combineReducers } from 'redux'\n+import { router5Reducer } from 'redux-router5'\n+\n+const reducers = combineReducers({\n+ router: router5Reducer,\n+ // ...add your other reducers\n+})\n+```\n+\n+\n+## Route node selector\n+\n+{% hint %}\n+In order to use routeNodeSelector efficiently, you need react-redux >= 4.4.0 to be able to perform per component instance memoization.__\n+{% endhint %}\n+\n+`routeNodeSelector` is a selector creator designed to be used on a route node and works with `connect` higher-order component from `react-redux`.\n+\n+If your routes are nested, you'll have a few route nodes in your application. On each route change, not all components need to be re-rendered. `routeNodeSelector` will only output a new state value if the provided node is concerned by a route change.\n+\n+\n+```javascript\n+import { connect } from 'react-redux';\n+import { routeNodeSelector } from 'redux-router5';\n+import { Home, About, Contact } from './components';\n+import { startsWithSegment } from 'router5-helpers';\n+\n+function Root({ route }) {\n+ const { params, name } = route;\n+ const testRoute = startsWithSegment(name);\n+\n+ if (testRoute('home')) {\n+ return <Home params={ params } />;\n+ } else if (testRoute('about')) {\n+ return <About params={ params } />;\n+ } else if (testRoute('contact')) {\n+ return <Contact params={ params } />;\n+ }\n+\n+ return null\n+}\n+\n+export default connect(routeNodeSelector(''))(Root);\n+```\n+\n+Using `routeNodeSelector` with other connect properties:\n+\n+```js\n+export default connect(state => {\n+ const selector = routeNodeSelector('');\n+\n+ return (state) => ({\n+ a: state.a,\n+ b: state.b,\n+ ...selector(state)\n+ })\n+)(Root);\n+```\n+\n+\n+## With immutable-js\n+\n+If you are using [immutable-js](https://github.com/facebook/immutable-js) and [redux-immutable](https://github.com/gajus/redux-immutable) simply use the reducer from 'redux-router5/immutable/reducer'\n+\n+```javascript\n+import router5Reducer from 'redux-router5/immutable/reducer';\n+```\n" }, { "change_type": "MODIFY", "old_path": "packages/redux-router5/README.md", "new_path": "packages/redux-router5/README.md", "diff": "# redux-router5\n-> Router5 integration with redux. If you develop with React, use this package with __[react-redux](https://github.com/reactjs/react-redux)__\n-and __[react-router5](../react-router5)__. Using router5 with redux removes the need to include _router5-listeners_.\n-__[Example](../examples/apps/react-redux)__ | __[Demo](http://router5.github.io/docs/with-react-redux.html)__ | __[Learn router5](http://router5.github.io)__\n+## Demo and example with Redux\n-## Requirements\n+* [https://stackblitz.com/edit/react-redux-router5](https://stackblitz.com/edit/react-redux-router5)\n-- __router5 >= 4.0.0__\n-- __redux >= 3.0.0__\n## How to use\n-- Create and configure your router instance\n-- Create and configure your store including `router5Middleware` and `router5Reducer`\n-- If you don't use the middleware, add `reduxPlugin` to your router instance\n-- Use `routeNodeSelector` on route nodes in your component tree\n-- Use provided actions to perform routing or use your router instance directly\n+You have two ways to use redux-router5, depending on how you want to navigate:\n+- Using the router5 plugin (named `reduxPlugin`)\n+- Using the redux middleware (named `router5Middleware`)\n-### How it works\n+In both cases, __use the provided reducer (`router5Reducer`).__\n-![With redux](https://github.com/router5/router5.github.io/blob/master/img/router-redux.png)\n-__Breaking change from 4.x__: the middleware doesn't pass the store to your router instance (using `.inject()`). If you want to use your store in `canActivate`, `canDeactivate`, middlewares and plugins, use `router.inject(store)`.\n+## Using the router plugin\n-### With React\n-\n-```javascript\n-import { ReactDOM } from 'react-dom';\n-import { RouterProvider } from 'react-router5';\n-import { Provider } from 'react-redux';\n-import React from 'react';\n-import App from './app';\n-import createRouter from './create-router';\n-import configureStore from './store';\n-\n-const router = createRouter();\n-const store = configureStore(router);\n-\n-router.start(() => {\n- ReactDOM.render(\n- (\n- <Provider store={ store }>\n- <RouterProvider router={ router }>\n- <App />\n- </RouterProvider>\n- </Provider>\n- ),\n- document.getElementById('app')\n- );\n-});\n-```\n-\n-__Note:__ `RouterProvider` comes from `react-router5`. It simply adds your router instance in your application context, which is required. Alternatively, you can use `withContext()` from [recompose](https://github.com/acdlite/recompose). __You also may not need it__: having your router in context gives you access router methods like `buildUrl`, `isActive`, etc... If you don't use those methods, then you don't need your router instance in context.\n+If you choose to not use the middleware, you need to add `reduxPlugin` to your router. The plugin simply syncs the router state with redux. To navigate, you will need to invoke `router.navigate`. If you use React, you can use `BaseLink` from `react-router5`.\n+```js\n+import { reduxPlugin } from 'redux-router5';\n-## router5Middleware\n+// You need a router instance and a store instance\n+router.usePlugin(reduxPlugin(store.dispatch));\n+```\n-```javascript\n-import createRouter from './create-router';\n-import { compose, createStore, applyMiddleware, combineReducers } from 'redux';\n-import { router5Middleware, router5Reducer } from 'redux-router5';\n-function configureStore(router, initialState = {}) {\n- const createStoreWithMiddleware = applyMiddleware(router5Middleware(router))(createStore);\n+## Using the redux middleware\n- const store = createStoreWithMiddleware(combineReducers({\n- router: router5Reducer,\n- /* your reducers */\n- }), initialState);\n+The redux middleware automatically adds the redux plugin to the provided router instance. It will convert a set of redux actions to routing instructions. The available action creators are:\n- return store;\n-}\n+- `navigateTo(routeName, routeParams = {}, routeOptions = {})`\n+- `cancelTransition()`\n+- `clearErrors()`\n+- `canActivate(routeName, true | false)`\n+- `canDeactivate(routeName, true | false)`\n-const router = createRouter();\n-const store = configureStore(router, { router: { route: state }});\n-\n-router.start();\n+```javascript\n+import { actions } from 'redux-router5'\n```\n-Under the hood, it simply adds a plugin to your router instance so your router\n-dispatches actions on transition start, error, success and cancel (You can read more about router5 plugins [here](http://router5.github.io/docs/plugins.html)).\n-It also relay `navigateTo` actions to the router.\n-\n-If you are using [immutable-js](https://github.com/facebook/immutable-js) and [redux-immutable](https://github.com/gajus/redux-immutable) simply use the reducer from 'redux-router5/immutable/reducer'\n+Use `router5Middleware` alongside your other middlewares:\n```javascript\n+import { createStore, applyMiddleware } from 'redux';\nimport { router5Middleware } from 'redux-router5';\n-import router5Reducer from 'redux-router5/immutable/reducer';\n-```\n-## Router5 reduxPlugin\n-\n-__`router5Middleware` redux middleware is optional__.\n-\n-The sole purpose of the redux middleware `router5Middleware` is to translate actions to router instructions (`navigate`, `cancel`, `canActivate` and `canDeactivate`. __You may not need it__: for instance, if you use React and have your router instance in context, you can call `router.navigate()` directly.\n-\n-In that case, register `reduxPlugin` with your router instance (when you use the middleware, that plugin is added for you).\n-\n-```js\n-import { reduxPlugin } from 'redux-router5';\n-\n-// You need a router instance and a store instance\n-router.usePlugin(reduxPlugin(store.dispatch));\n+const createStoreWithMiddleware = applyMiddleware(\n+ router5Middleware(router)\n+)(createStore)\n```\n-## router5Reducer\n-\n-A simple reducer which is added by `router5Middleware`. __Note:__ use `router` for your reducer key name, other names are not yet supported.\n-`router5Reducer` will manage a piece of your state containing the following data attributes:\n-\n-- route\n-- previousRoute\n-- transitionRoute (the current transitioning route)\n-- transitionError (the last error which occured)\n+## Reducer\n-`route` and `previousRoute` have a `name`, `params` and `path` properties.\n+This packages exposes a reducer (`router5Reducer`) that you can add to your application. It contains four properties:\n+- `route`\n+- `previousRoute`\n+- `transitionRoute` (the current transitioning route)\n+- `transitionError` (the last error which occured)\n-## Actions\n-\n-Available actions (you can use your router instance directly instead)\n-\n-- __navigateTo(routeName, routeParams = {}, routeOptions = {})__\n-- __cancelTransition()__\n-- __clearErrors()__\n-- __canActivate(routeName, true | false)__\n-- __canDeactivate(routeName, true | false)__\n+```js\n+import { combineReducers } from 'redux'\n+import { router5Reducer } from 'redux-router5'\n-```javascript\n-import { actions } from 'redux-router5';\n+const reducers = combineReducers({\n+ router: router5Reducer,\n+ // ...add your other reducers\n+})\n```\n-## routeNodeSelector\n-__In order to use routeNodeSelector efficiently, you need react-redux >= 4.4.0 to be able to perform per component instance memoization.__\n+## Route node selector\n-`routeNodeSelector` is a selector designed to be used on a route node and works with `connect` higher-order component from `react-redux`.\n+> In order to use routeNodeSelector efficiently, you need react-redux >= 4.4.0 to be able to perform per component instance memoization.__\n-If your routes are nested, you'll have a few route nodes in your application. On each route change, only _one_ route node needs to be re-rendered.\n-That route node is the highest common node between your previous route and your current route. `routeNodeSelector` will only trigger a re-render\n-when it needs to.\n+`routeNodeSelector` is a selector creator designed to be used on a route node and works with `connect` higher-order component from `react-redux`.\n-Then it is just a matter of returning the right component depending on the current route. Your virtual tree will react to route changes, all of that\n-by simply __leveraging the power of connect and reselect__!\n+If your routes are nested, you'll have a few route nodes in your application. On each route change, not all components need to be re-rendered. `routeNodeSelector` will only output a new state value if the provided node is concerned by a route change.\n-[router5-helpers](../router5-helpers) provides\n-a set of functions to help making those decisions (useful if you have nested routes).\n```javascript\nimport { connect } from 'react-redux';\nimport { routeNodeSelector } from 'redux-router5';\n-import { Home, About, Contact, Admin, NotFound } from './components';\n+import { Home, About, Contact } from './components';\nimport { startsWithSegment } from 'router5-helpers';\nfunction Root({ route }) {\nconst { params, name } = route;\n-\nconst testRoute = startsWithSegment(name);\nif (testRoute('home')) {\n@@ -167,17 +99,15 @@ function Root({ route }) {\nreturn <About params={ params } />;\n} else if (testRoute('contact')) {\nreturn <Contact params={ params } />;\n- } else if (testRoute('admin')) {\n- return <Admin params={ params } />;\n- } else {\n- return <NotFound />;\n}\n+\n+ return null\n}\n-export default connect(state => routeNodeSelector(''))(Root);\n+export default connect(routeNodeSelector(''))(Root);\n```\n-When using `routeNodeSelector` with other connect properties:\n+Using `routeNodeSelector` with other connect properties:\n```js\nexport default connect(state => {\n@@ -190,3 +120,12 @@ export default connect(state => {\n})\n)(Root);\n```\n+\n+\n+## With immutable-js\n+\n+If you are using [immutable-js](https://github.com/facebook/immutable-js) and [redux-immutable](https://github.com/gajus/redux-immutable) simply use the reducer from 'redux-router5/immutable/reducer'\n+\n+```javascript\n+import router5Reducer from 'redux-router5/immutable/reducer';\n+```\n" } ]
TypeScript
MIT License
router5/router5
docs: add with redux docs and redux-router5 readme
580,249
21.05.2018 21:10:29
-3,600
105bc8209894a49ad12428082acb5f97be8962fe
docs: move react and redux section
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [Navigating](guides/navigating.md)\n* [In the browser](guides/browser.md)\n* [Observing state](guides/observability.md)\n- * [With React](guides/with-react.md)\n- * [With Redux](guides/with-redux.md)\n+* Integration\n+ * [With React](integration/with-react.md)\n+ * [With Redux](integration/with-redux.md)\n* Advanced\n* [Plugins](advanced/plugins.md)\n* [Middleware](advanced/middleware.md)\n" }, { "change_type": "RENAME", "old_path": "docs/guides/with-react.md", "new_path": "docs/integration/with-react.md", "diff": "" }, { "change_type": "RENAME", "old_path": "docs/guides/with-redux.md", "new_path": "docs/integration/with-redux.md", "diff": "" } ]
TypeScript
MIT License
router5/router5
docs: move react and redux section
580,249
21.05.2018 22:15:27
-3,600
9ba861970979f87a74509bf330c1de4b1ac55e3e
docs: add listeners plugin page
[ { "change_type": "MODIFY", "old_path": "docs/SUMMARY.md", "new_path": "docs/SUMMARY.md", "diff": "* [Dependency injection](advanced/dependency-injection.md)\n* [Loading async data](advanced/async-data.md)\n* [Universal routing](advanced/universal-routing.md)\n+ * [Listeners plugin](advanced/listeners-plugin.md)\n* [API Reference](./api-reference.md)\n* Migration\n* [Migrating from 5.x to 6.x](migration/to-v6.md)\n" }, { "change_type": "MODIFY", "old_path": "docs/advanced/async-data.md", "new_path": "docs/advanced/async-data.md", "diff": "@@ -20,7 +20,7 @@ Router5 doesn't provide an opinionated way of handling async data, instead this\n> You can use your router state objects as a container for route-specific data.\nYou can use a middleware if you want your router to wait for data updates and/or prevent a route transition to happen if data loading fails.\n-When doing so, you can use `toState` state object as a container for your route-specific data: the listeners plugin will pass it to your view (with the data you attached to it). You shouldn't mutate `toState` if you don't explicitly ask the router to wait by either calling a `done` callback or by returning a promise.\n+When doing so, you can use `toState` state object as a container for your route-specific data: your router will emit the mutated state.\nFirst, we need to define what data need to be loaded for which route segment:\n" }, { "change_type": "MODIFY", "old_path": "docs/advanced/universal-routing.md", "new_path": "docs/advanced/universal-routing.md", "diff": "@@ -12,7 +12,6 @@ You can use the same code for configuring your router on both client and server\n```js\nconst createRouter = require( 'router5' ).default;\n-const listenersPlugin = require( 'router5/plugins/listeners' );\nconst browserPlugin = require( 'router5/plugins/browser' );\nfunction createRouter() {\n" }, { "change_type": "MODIFY", "old_path": "docs/guides/observability.md", "new_path": "docs/guides/observability.md", "diff": "@@ -7,7 +7,6 @@ From [email protected] and onwards, your router instance is compatible with most obs\n## Subscribing to state changes\nYou can subscribe to route changes using `router.subscribe()`, and will receive an object containing `route` and `previousRoute`.\n-Alternatively, you can use the listeners plugin.\n## Observing state changes\n" }, { "change_type": "MODIFY", "old_path": "docs/introduction/core-concepts.md", "new_path": "docs/introduction/core-concepts.md", "diff": "@@ -72,18 +72,7 @@ The current route is `admin.users`. If we were to navigate to `home`, `Main` wou\n> The __transition node__ (as explained above), _is_ the node to re-render your view from.\n-The __listeners plugin__ makes possible to register those three types of listeners: _\"any change\"_ listener, route listener and node listener. Note that `listenersPlugin` has a limit of one node listener per node (_listenersPlugin_ uses [router5-transition-path](https://github.com/router5/router5/tree/master/packages/router5-transition-path) to compute the transition path between two router5 states).\n![Relation between router and view](./router-view.png)\nIn slightly more complicated cases, you might have other parts of your screen to re-render. For example, you might have a header, a main menu or a side panel to update on a route change: in that case you can listen to any route change or a specific route change, and re-render that specific portion of a screen. Keep transition nodes for your \"main\" content update.\n-\n-\n-## What is router5 best suited for?\n-\n-Router 5 is best suited for trees of components, where components can easily be composed together. It works best with React, deku, cyclejs, etc...\n-\n-It also works very well with state containers like [Redux](http://redux.js.org/): your state container is placed between your view and your router, and your view subscribes to state updates (rather than directly subscribing to route updates). In that case you don't need to use the listeners plugin.\n-\n-- [react-router5](https://github.com/router5/router5/tree/master/packages/react-router5) and [deku-router5](https://github.com/router5/router5/tree/master/packages/deku-router5) both provide a `routeNode(nodeName)(BaseComponent)` higher-order component for re-rendering from a node down when the given node is the transition node.\n-- [redux-router5](https://github.com/router5/router5/tree/master/packages/redux-router5) provides a selector `routeNode(nodeName)` which will release the new router state object when the specified node is the transition node. When combined with react or deku, you use it with `connect` from [react-redux](https://github.com/rackt/react-redux) or [deku-redux](https://github.com/troch/deku-redux).\n" }, { "change_type": "MODIFY", "old_path": "docs/introduction/why-router5.md", "new_path": "docs/introduction/why-router5.md", "diff": "# Why router5\n+\n`router5` is part of a new generation of routers: instead of rendering \"views\" or \"pages\", router5 outputs its state. The main idea behind router5 is to treat routing state like any other application data or state.\n-\"Traditional\" routing has been heavily influenced by server-side routing, which is stateless, while client-side routing is stateful. Watch my talk at ReactiveConf 2016: \"Past and future of client-side routing\", it gives a great overview of what routing is, and what router5 does:\n+\"Traditional\" routing has been heavily influenced by server-side routing, which is stateless, while client-side routing is stateful. For more in-depth description of router5, look at [Understanding router5](./core-concepts.md).\n+\n+\n+## What is router5 best suited for?\n+\n+Router 5 is best suited for component-based architectures, where components can easily be composed together. It works best with React, Preact, Inferno, Cycle.js, etc...\n+\n+It also works very well with state containers like [Redux](http://redux.js.org/): your state container is placed between your view and your router, and your view subscribes to state updates (rather than directly subscribing to route updates).\n+\n+See available integrations:\n+- [With React](../integration/with-react.md)\n+- [With Redux](../integration/with-redux.md)\n+\n+\n+## ReactiveConf 2016 talk\n+\n+Watch my talk at ReactiveConf 2016: \"Past and future of client-side routing\", it gives a great overview of what routing is, and what router5 does:\n{% youtube %}\nhttps://www.youtube.com/watch?v=hblXdstrAg0\n{% endyoutube %}\n-\n-For more in-depth description of router5, look at [Understanding router5](../docs/understanding-router5.html).\n" } ]
TypeScript
MIT License
router5/router5
docs: add listeners plugin page
580,249
21.05.2018 22:25:30
-3,600
370752c7aeaa1c1b0f60d5741b6b3691fe27485e
docs: update router5 docs URL
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "[![Join the chat at https://gitter.im/router5/router5](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/router5/router5?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n-> Official website: [router5.js.org](router5.js.org)\n+> Official website: [router5.js.org](https://router5.js.org)\n# router5\n" }, { "change_type": "MODIFY", "old_path": "packages/deku-router5/README.md", "new_path": "packages/deku-router5/README.md", "diff": "This package replaces `router5-deku` which is deprecated.\n-### Example\n-\n-[Code](../examples/apps/deku)\n-[Demo](http://router5.github.io/docs/with-deku.html#/inbox)\n### Requirements\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/README.md", "new_path": "packages/router5/README.md", "diff": "[![Join the chat at https://gitter.im/router5/router5](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/router5/router5?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n-> Official website: [router5.github.io](http://router5.github.io)\n+> Official website: [router5.js.org](https://router5.js.org)\n# router5\n@@ -71,27 +71,38 @@ from(router).map(({ route }) => {\n```\n-### Guides\n-\n-[![\"Past and future of client-side routing\" @ ReactiveConf 2016](https://cloud.githubusercontent.com/assets/1777517/21482220/e9889d74-cb68-11e6-8077-ea2b3c9d6fb1.png)](https://www.youtube.com/watch?v=hblXdstrAg0)\n-\n-* [Configuring routes](http://router5.github.io/docs/configuring-routes.html)\n-* [Router options](http://router5.github.io/docs/router-options.html)\n-* [Path syntax](http://router5.github.io/docs/path-syntax.html)\n-* [Navigation](http://router5.github.io/docs/navigation.html)\n-* [Preventing navigation](http://router5.github.io/docs/preventing-navigation.html)\n-* [Custom errors and redirections](http://router5.github.io/docs/custom-errors.html)\n-* [Middleware functions](http://router5.github.io/docs/middleware.html)\n-* [Transition](http://router5.github.io/docs/transition.html)\n-* [Using plugins](http://router5.github.io/docs/plugins.html)\n-* [Universal applications](http://router5.github.io/docs/universal-applications.html)\n-* [Async data](http://router5.github.io/docs/async-data.html)\n-\n-### Integrations\n-\n-* [react-router5](./packages/react-router5)\n-* [redux-router5](./packages/redux-router5)\n-\n-### API\n-\n-* [API Reference](http://router5.github.io/docs/api-reference.html)\n+## Examples\n+\n+* [With React](https://stackblitz.com/edit/react-router5)\n+* [With React (new context API)](https://stackblitz.com/edit/react-router5-new-context-api)\n+* [With Redux](https://stackblitz.com/edit/react-redux-router5)\n+\n+\n+### Docs\n+\n+* Introduction\n+ * [Why router5?](https://router5.js.org/introduction/why-router5)\n+ * [Getting Started](https://router5.js.org/introduction/getting-started)\n+ * [Ecosystem](https://router5.js.org/introduction/ecosystem)\n+ * [Core concepts](https://router5.js.org/introduction/core-concepts)\n+ * [Transition phase](https://router5.js.org/introduction/transition-phase)\n+* Guides\n+ * [Defining routes](https://router5.js.org/guides/defining-routes)\n+ * [Path Syntax](https://router5.js.org/guides/path-syntax)\n+ * [Router options](https://router5.js.org/guides/router-options)\n+ * [Navigating](https://router5.js.org/guides/navigating)\n+ * [In the browser](https://router5.js.org/guides/in-the-browser)\n+ * [Observing state](https://router5.js.org/guides/observing-state)\n+* Integration\n+ * [With React](https://router5.js.org/integration/with-react)\n+ * [With Redux](https://router5.js.org/integration/with-redux)\n+* Advanced\n+ * [Plugins](https://router5.js.org/advanced/plugins)\n+ * [Middleware](https://router5.js.org/advanced/middleware)\n+ * [Preventing navigation](https://router5.js.org/advanced/preventing-navigation)\n+ * [Errors and redirections](https://router5.js.org/advanced/errors-and-redirections)\n+ * [Dependency injection](https://router5.js.org/advanced/dependency-injection)\n+ * [Loading async data](https://router5.js.org/advanced/loading-async-data)\n+ * [Universal routing](https://router5.js.org/advanced/universal-routing)\n+ * [Listeners plugin](https://router5.js.org/advanced/listeners-plugin)\n+* [API Reference](https://router5.js.org/api-reference)\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "\"bugs\": {\n\"url\": \"https://github.com/router5/router5/issues\"\n},\n- \"homepage\": \"http://router5.github.io\",\n+ \"homepage\": \"https://router5.js.org\",\n\"dependencies\": {\n\"route-node\": \"3.2.0\",\n\"router5-transition-path\": \"^5.3.0\",\n" }, { "change_type": "MODIFY", "old_path": "packages/rxjs-router5/README.md", "new_path": "packages/rxjs-router5/README.md", "diff": "# rxjs-router5\n-[rxjs (RxJS 5+)](http://reactivex.io/rxjs/) integration with [router5](http://router5.github.io)\n+[rxjs (RxJS 5+)](http://reactivex.io/rxjs/) integration with [router5](http://router5.js.org)\n```sh\nnpm install --save rxjs-router5\n@@ -39,7 +39,7 @@ route$.map((route) => { /* ... */ })\n- `route$`: an observable of your application route\n- `transitionRoute$`: an observable of the currently transitioning route\n- `transitionError$`: an observable of transition errors\n-- `routeNode(nodeName)`: a function returning an observable of route updates for the specified node. See [understanding router5](http://router5.github.io/docs/understanding-router5.html).\n+- `routeNode(nodeName)`: a function returning an observable of route updates for the specified node.\n### Related\n" }, { "change_type": "MODIFY", "old_path": "packages/rxjs-router5/index.d.ts", "new_path": "packages/rxjs-router5/index.d.ts", "diff": "@@ -8,7 +8,6 @@ declare module 'rxjs-router5' {\n/**\n* @param nodeName the name of a node\n* @returns an observable of route updates for the specified node.\n- * See understanding router5: http://router5.github.io/docs/understanding-router5.html.\n*/\nrouteNode: (nodeName: string) => Rx.Observable<State>\n" }, { "change_type": "MODIFY", "old_path": "packages/xstream-router5/README.md", "new_path": "packages/xstream-router5/README.md", "diff": "# xstream-router5\n-[xstream](http://staltz.com/xstream/) integration with [router5](http://router5.github.io)\n+[xstream](http://staltz.com/xstream/) integration with [router5](https://router5.js.org)\n```sh\nnpm install --save xstream-router5\n@@ -39,7 +39,7 @@ route$.map((route) => { /* ... */ })\n- `route$`: an observable of your application route\n- `transitionRoute$`: an observable of the currently transitioning route\n- `transitionError$`: an observable of transition errors\n-- `routeNode(nodeName = '')`: a function returning an observable of route updates for the specified node. See [understanding router5](http://router5.github.io/docs/understanding-router5.html).\n+- `routeNode(nodeName = '')`: a function returning an observable of route updates for the specified node\n### Related\n" } ]
TypeScript
MIT License
router5/router5
docs: update router5 docs URL
580,249
22.05.2018 09:22:01
-3,600
7229577ccf0c3f5fe102e04780c49fb7b0821b52
feat: rename routeNodeSelector to createRouteNodeSelector
[ { "change_type": "MODIFY", "old_path": "packages/redux-router5/modules/index.js", "new_path": "packages/redux-router5/modules/index.js", "diff": "import router5Middleware from './lib/router5Middleware'\nimport router5Reducer from './lib/router5Reducer'\n-import routeNodeSelector from './lib/routeNodeSelector'\n+import createRouteNodeSelector from './lib/routeNodeSelector'\nimport * as actions from './lib/actions'\nimport * as actionTypes from './lib/actionTypes'\nimport reduxPlugin from './lib/reduxPlugin'\n@@ -10,6 +10,6 @@ export {\nrouter5Reducer,\nactions,\nactionTypes,\n- routeNodeSelector,\n+ createRouteNodeSelector,\nreduxPlugin\n}\n" }, { "change_type": "MODIFY", "old_path": "packages/redux-router5/modules/lib/routeNodeSelector.js", "new_path": "packages/redux-router5/modules/lib/routeNodeSelector.js", "diff": "import { shouldUpdateNode } from 'router5-transition-path'\n-function routeNodeSelector(routeNode, reducerKey = 'router') {\n+function createRouteNodeSelector(routeNode, reducerKey = 'router') {\nconst routerStateSelector = state =>\nstate[reducerKey] || (state.get && state.get(reducerKey))\nlet lastReturnedValue\n@@ -24,4 +24,4 @@ function routeNodeSelector(routeNode, reducerKey = 'router') {\n}\n}\n-export default routeNodeSelector\n+export default createRouteNodeSelector\n" }, { "change_type": "MODIFY", "old_path": "packages/redux-router5/test/main.js", "new_path": "packages/redux-router5/test/main.js", "diff": "import { expect } from 'chai'\nimport {\n- routeNodeSelector,\n+ createRouteNodeSelector,\nrouter5Reducer,\nactions,\nactionTypes\n@@ -112,10 +112,10 @@ describe('redux-router5', () => {\n})\n})\n- describe('routeNodeSelector', () => {\n+ describe('createRouteNodeSelector', () => {\nit('should memoize routes', () => {\n- const rootSelector = routeNodeSelector('')\n- const aSelector = routeNodeSelector('a')\n+ const rootSelector = createRouteNodeSelector('')\n+ const aSelector = createRouteNodeSelector('a')\nlet router = {\nroute: route1,\n@@ -140,10 +140,10 @@ describe('redux-router5', () => {\n})\n})\n- describe('routeNodeSelector using immutable state', () => {\n+ describe('createRouteNodeSelector using immutable state', () => {\nit('should memoize routes', () => {\n- const rootSelector = routeNodeSelector('')\n- const aSelector = routeNodeSelector('a')\n+ const rootSelector = createRouteNodeSelector('')\n+ const aSelector = createRouteNodeSelector('a')\nlet router = new State({\nroute: route1,\n" } ]
TypeScript
MIT License
router5/router5
feat: rename routeNodeSelector to createRouteNodeSelector
580,249
22.05.2018 09:30:28
-3,600
dd203c90a75480e9a3076e60652402a912f8167d
docs: update docs with createRouteNodeSelector
[ { "change_type": "MODIFY", "old_path": "docs/integration/with-redux.md", "new_path": "docs/integration/with-redux.md", "diff": "@@ -75,17 +75,17 @@ const reducers = combineReducers({\n## Route node selector\n{% hint %}\n-In order to use routeNodeSelector efficiently, you need react-redux >= 4.4.0 to be able to perform per component instance memoization.__\n+__`routeNodeSelector` has been renamed to `createRouteNodeSelector`__. In order to use it efficiently, you need react-redux >= 4.4.0 to be able to perform per component instance memoization.__\n{% endhint %}\n-`routeNodeSelector` is a selector creator designed to be used on a route node and works with `connect` higher-order component from `react-redux`.\n+`createRouteNodeSelector` is a selector creator designed to be used on a route node and works with `connect` higher-order component from `react-redux`.\n-If your routes are nested, you'll have a few route nodes in your application. On each route change, not all components need to be re-rendered. `routeNodeSelector` will only output a new state value if the provided node is concerned by a route change.\n+If your routes are nested, you'll have a few route nodes in your application. On each route change, not all components need to be re-rendered. `createRouteNodeSelector` will only output a new state value if the provided node is concerned by a route change.\n```javascript\nimport { connect } from 'react-redux';\n-import { routeNodeSelector } from 'redux-router5';\n+import { createRouteNodeSelector } from 'redux-router5';\nimport { Home, About, Contact } from './components';\nimport { startsWithSegment } from 'router5-helpers';\n@@ -104,19 +104,19 @@ function Root({ route }) {\nreturn null\n}\n-export default connect(routeNodeSelector(''))(Root);\n+export default connect(createRouteNodeSelector(''))(Root);\n```\n-Using `routeNodeSelector` with other connect properties:\n+Using `createRouteNodeSelector` with other connect properties:\n```js\nexport default connect(state => {\n- const selector = routeNodeSelector('');\n+ const routeNodeSelector = createRouteNodeSelector('');\nreturn (state) => ({\na: state.a,\nb: state.b,\n- ...selector(state)\n+ ...routeNodeSelector(state)\n})\n)(Root);\n```\n" }, { "change_type": "MODIFY", "old_path": "packages/redux-router5/README.md", "new_path": "packages/redux-router5/README.md", "diff": "@@ -76,16 +76,16 @@ const reducers = combineReducers({\n## Route node selector\n-> In order to use routeNodeSelector efficiently, you need react-redux >= 4.4.0 to be able to perform per component instance memoization.__\n+> __routeNodeSelector__ has been renamed to __createRouteNodeSelector__. In order to use createRouteNodeSelector efficiently, you need react-redux >= 4.4.0 to be able to perform per component instance memoization.__\n-`routeNodeSelector` is a selector creator designed to be used on a route node and works with `connect` higher-order component from `react-redux`.\n+`createRouteNodeSelector` is a selector creator designed to be used on a route node and works with `connect` higher-order component from `react-redux`.\n-If your routes are nested, you'll have a few route nodes in your application. On each route change, not all components need to be re-rendered. `routeNodeSelector` will only output a new state value if the provided node is concerned by a route change.\n+If your routes are nested, you'll have a few route nodes in your application. On each route change, not all components need to be re-rendered. `createRouteNodeSelector` will only output a new state value if the provided node is concerned by a route change.\n```javascript\nimport { connect } from 'react-redux';\n-import { routeNodeSelector } from 'redux-router5';\n+import { createRouteNodeSelector } from 'redux-router5';\nimport { Home, About, Contact } from './components';\nimport { startsWithSegment } from 'router5-helpers';\n@@ -104,19 +104,19 @@ function Root({ route }) {\nreturn null\n}\n-export default connect(routeNodeSelector(''))(Root);\n+export default connect(createRouteNodeSelector(''))(Root);\n```\n-Using `routeNodeSelector` with other connect properties:\n+Using `createRouteNodeSelector` with other connect properties:\n```js\nexport default connect(state => {\n- const selector = routeNodeSelector('');\n+ const routeNodeSelector = createRouteNodeSelector('');\nreturn (state) => ({\na: state.a,\nb: state.b,\n- ...selector(state)\n+ ...routeNodeSelector(state)\n})\n)(Root);\n```\n" }, { "change_type": "MODIFY", "old_path": "packages/redux-router5/index.d.ts", "new_path": "packages/redux-router5/index.d.ts", "diff": "@@ -17,10 +17,9 @@ declare module 'redux-router5' {\ndispatch: Dispatch<TState>\n): PluginFactory\n- export function routeNodeSelector<TState extends { router: RouterState }>(\n- routeNode: string,\n- reducerKey?: string\n- ): (state: TState) => RouterState\n+ export function createRouteNodeSelector<\n+ TState extends { router: RouterState }\n+ >(routeNode: string, reducerKey?: string): (state: TState) => RouterState\n// #region actions\n" } ]
TypeScript
MIT License
router5/router5
docs: update docs with createRouteNodeSelector
580,249
22.05.2018 10:59:44
-3,600
d37d3be3defded8f7b3b4bf0b95aac7ef8f1b3f7
docs: add context to breaking change
[ { "change_type": "MODIFY", "old_path": "docs/integration/with-redux.md", "new_path": "docs/integration/with-redux.md", "diff": "@@ -75,7 +75,7 @@ const reducers = combineReducers({\n## Route node selector\n{% hint %}\n-__`routeNodeSelector` has been renamed to `createRouteNodeSelector`__. In order to use it efficiently, you need react-redux >= 4.4.0 to be able to perform per component instance memoization.__\n+__In version 6.0.0, `routeNodeSelector` has been renamed to `createRouteNodeSelector`__. In order to use it efficiently, you need react-redux >= 4.4.0 to be able to perform per component instance memoization.\n{% endhint %}\n`createRouteNodeSelector` is a selector creator designed to be used on a route node and works with `connect` higher-order component from `react-redux`.\n" } ]
TypeScript
MIT License
router5/router5
docs: add context to breaking change
580,233
29.05.2018 11:42:16
14,400
a3e50389b0534039bb71dd9aaa98e8934bae4557
Rename router to payload for accuracy
[ { "change_type": "MODIFY", "old_path": "packages/redux-router5/index.d.ts", "new_path": "packages/redux-router5/index.d.ts", "diff": "@@ -13,7 +13,7 @@ declare module 'redux-router5' {\nexport const router5Reducer: Reducer<RouterState>\n- export function reduxPlugin<TState extends { router: RouterState, type: string }>(\n+ export function reduxPlugin<TState extends { payload: RouterState | null, type: string }>(\ndispatch: Dispatch<TState>\n): PluginFactory\n" } ]
TypeScript
MIT License
router5/router5
Rename router to payload for accuracy
580,248
29.05.2018 13:57:05
10,800
7b0d0cf76aef06f9c2c0a871672b610fc0394eb6
fix logger typo in typescript definitions
[ { "change_type": "MODIFY", "old_path": "dist/reactRouter5.js", "new_path": "dist/reactRouter5.js", "diff": "var emptyFunction_1 = emptyFunction;\n- var emptyFunction$1 = /*#__PURE__*/Object.freeze({\n- default: emptyFunction_1,\n- __moduleExports: emptyFunction_1\n- });\n-\n/**\n* Copyright (c) 2013-present, Facebook, Inc.\n* All rights reserved.\nvar invariant_1 = invariant;\n- var invariant$1 = /*#__PURE__*/Object.freeze({\n- default: invariant_1,\n- __moduleExports: invariant_1\n- });\n-\n- var emptyFunction$2 = ( emptyFunction$1 && emptyFunction_1 ) || emptyFunction$1;\n-\n/**\n* Similar to invariant but only logs a warning if the condition is not met.\n* This can be used to log issues in development environments in critical\n* same logic and follow the same code paths.\n*/\n- var warning = emptyFunction$2;\n+ var warning = emptyFunction_1;\nif (process.env.NODE_ENV !== 'production') {\n(function () {\nvar warning_1 = warning;\n- var warning$1 = /*#__PURE__*/Object.freeze({\n- default: warning_1,\n- __moduleExports: warning_1\n- });\n-\n/**\n* Copyright 2013-present, Facebook, Inc.\n* All rights reserved.\nvar ReactPropTypesSecret_1 = ReactPropTypesSecret;\n- var ReactPropTypesSecret$1 = /*#__PURE__*/Object.freeze({\n- default: ReactPropTypesSecret_1,\n- __moduleExports: ReactPropTypesSecret_1\n- });\n-\n- var require$$0 = ( invariant$1 && invariant_1 ) || invariant$1;\n-\n- var require$$1 = ( warning$1 && warning_1 ) || warning$1;\n-\n- var require$$2 = ( ReactPropTypesSecret$1 && ReactPropTypesSecret_1 ) || ReactPropTypesSecret$1;\n-\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\nreturn typeof obj;\n} : function (obj) {\n};\nif (process.env.NODE_ENV !== 'production') {\n- var invariant$2 = require$$0;\n- var warning$2 = require$$1;\n- var ReactPropTypesSecret$2 = require$$2;\n+ var invariant$1 = invariant_1;\n+ var warning$1 = warning_1;\n+ var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;\nvar loggedTypeFailures = {};\n}\ntry {\n// This is intentionally an invariant that gets caught. It's the same\n// behavior as without this statement except with a better message.\n- invariant$2(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName);\n- error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$2);\n+ invariant$1(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName);\n+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);\n} catch (ex) {\nerror = ex;\n}\n- warning$2(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error === 'undefined' ? 'undefined' : _typeof(error));\n+ warning$1(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error === 'undefined' ? 'undefined' : _typeof(error));\nif (error instanceof Error && !(error.message in loggedTypeFailures)) {\n// Only monitor this failure once because there tends to be a lot of the\n// same error.\nvar stack = getStack ? getStack() : '';\n- warning$2(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');\n+ warning$1(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');\n}\n}\n}\nvar checkPropTypes_1 = checkPropTypes;\n- var checkPropTypes$1 = /*#__PURE__*/Object.freeze({\n- default: checkPropTypes_1,\n- __moduleExports: checkPropTypes_1\n- });\n-\n- var checkPropTypes$2 = ( checkPropTypes$1 && checkPropTypes_1 ) || checkPropTypes$1;\n-\nvar factoryWithTypeCheckers = function factoryWithTypeCheckers(isValidElement, throwOnDirectAccess) {\n/* global Symbol */\nvar ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;\ncomponentName = componentName || ANONYMOUS;\npropFullName = propFullName || propName;\n- if (secret !== require$$2) {\n+ if (secret !== ReactPropTypesSecret_1) {\nif (throwOnDirectAccess) {\n// New behavior only for users of `prop-types` package\n- require$$0(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types');\n+ invariant_1(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use `PropTypes.checkPropTypes()` to call them. ' + 'Read more at http://fb.me/use-check-prop-types');\n} else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {\n// Old behavior for people using React.PropTypes\nvar cacheKey = componentName + ':' + propName;\nif (!manualPropTypeCallCache[cacheKey] &&\n// Avoid spamming the console because they are often not actionable except for lib authors\nmanualPropTypeWarningCount < 3) {\n- require$$1(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName);\n+ warning_1(false, 'You are manually calling a React.PropTypes validation ' + 'function for the `%s` prop on `%s`. This is deprecated ' + 'and will throw in the standalone `prop-types` package. ' + 'You may be seeing this warning due to a third-party PropTypes ' + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', propFullName, componentName);\nmanualPropTypeCallCache[cacheKey] = true;\nmanualPropTypeWarningCount++;\n}\n}\nfunction createAnyTypeChecker() {\n- return createChainableTypeChecker(emptyFunction$2.thatReturnsNull);\n+ return createChainableTypeChecker(emptyFunction_1.thatReturnsNull);\n}\nfunction createArrayOfTypeChecker(typeChecker) {\nreturn new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));\n}\nfor (var i = 0; i < propValue.length; i++) {\n- var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', require$$2);\n+ var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);\nif (error instanceof Error) {\nreturn error;\n}\nfunction createEnumTypeChecker(expectedValues) {\nif (!Array.isArray(expectedValues)) {\n- process.env.NODE_ENV !== 'production' ? require$$1(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;\n- return emptyFunction$2.thatReturnsNull;\n+ process.env.NODE_ENV !== 'production' ? warning_1(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;\n+ return emptyFunction_1.thatReturnsNull;\n}\nfunction validate(props, propName, componentName, location, propFullName) {\n}\nfor (var key in propValue) {\nif (propValue.hasOwnProperty(key)) {\n- var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, require$$2);\n+ var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);\nif (error instanceof Error) {\nreturn error;\n}\nfunction createUnionTypeChecker(arrayOfTypeCheckers) {\nif (!Array.isArray(arrayOfTypeCheckers)) {\n- process.env.NODE_ENV !== 'production' ? require$$1(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;\n- return emptyFunction$2.thatReturnsNull;\n+ process.env.NODE_ENV !== 'production' ? warning_1(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;\n+ return emptyFunction_1.thatReturnsNull;\n}\nfor (var i = 0; i < arrayOfTypeCheckers.length; i++) {\nvar checker = arrayOfTypeCheckers[i];\nif (typeof checker !== 'function') {\n- require$$1(false, 'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' + 'received %s at index %s.', getPostfixForTypeWarning(checker), i);\n- return emptyFunction$2.thatReturnsNull;\n+ warning_1(false, 'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' + 'received %s at index %s.', getPostfixForTypeWarning(checker), i);\n+ return emptyFunction_1.thatReturnsNull;\n}\n}\nfunction validate(props, propName, componentName, location, propFullName) {\nfor (var i = 0; i < arrayOfTypeCheckers.length; i++) {\nvar checker = arrayOfTypeCheckers[i];\n- if (checker(props, propName, componentName, location, propFullName, require$$2) == null) {\n+ if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {\nreturn null;\n}\n}\nif (!checker) {\ncontinue;\n}\n- var error = checker(propValue, key, componentName, location, propFullName + '.' + key, require$$2);\n+ var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);\nif (error) {\nreturn error;\n}\nreturn propValue.constructor.name;\n}\n- ReactPropTypes.checkPropTypes = checkPropTypes$2;\n+ ReactPropTypes.checkPropTypes = checkPropTypes_1;\nReactPropTypes.PropTypes = ReactPropTypes;\nreturn ReactPropTypes;\n};\n- var factoryWithTypeCheckers$1 = /*#__PURE__*/Object.freeze({\n- default: factoryWithTypeCheckers,\n- __moduleExports: factoryWithTypeCheckers\n- });\n-\nvar factoryWithThrowingShims = function factoryWithThrowingShims() {\nfunction shim(props, propName, componentName, location, propFullName, secret) {\n- if (secret === require$$2) {\n+ if (secret === ReactPropTypesSecret_1) {\n// It is still safe when called from React.\nreturn;\n}\n- require$$0(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');\n+ invariant_1(false, 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types');\n} shim.isRequired = shim;\nfunction getShim() {\nreturn shim;\nshape: getShim\n};\n- ReactPropTypes.checkPropTypes = emptyFunction$2;\n+ ReactPropTypes.checkPropTypes = emptyFunction_1;\nReactPropTypes.PropTypes = ReactPropTypes;\nreturn ReactPropTypes;\n};\n- var factoryWithThrowingShims$1 = /*#__PURE__*/Object.freeze({\n- default: factoryWithThrowingShims,\n- __moduleExports: factoryWithThrowingShims\n- });\n-\n- var require$$0$1 = ( factoryWithTypeCheckers$1 && factoryWithTypeCheckers ) || factoryWithTypeCheckers$1;\n-\n- var require$$1$1 = ( factoryWithThrowingShims$1 && factoryWithThrowingShims ) || factoryWithThrowingShims$1;\n-\nvar propTypes = createCommonjsModule(function (module) {\n/**\n* Copyright 2013-present, Facebook, Inc.\n// By explicitly using `prop-types` you are opting into new development behavior.\n// http://fb.me/prop-types-in-prod\nvar throwOnDirectAccess = true;\n- module.exports = require$$0$1(isValidElement, throwOnDirectAccess);\n+ module.exports = factoryWithTypeCheckers(isValidElement, throwOnDirectAccess);\n} else {\n// By explicitly using `prop-types` you are opting into new production behavior.\n// http://fb.me/prop-types-in-prod\n- module.exports = require$$1$1();\n+ module.exports = factoryWithThrowingShims();\n}\n});\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/index.d.ts", "new_path": "packages/router5/index.d.ts", "diff": "@@ -28,7 +28,7 @@ declare module 'router5' {\nActivationFn,\nActivationFnFactory\n} from 'router5/core/route-lifecycle'\n- import loggerPlugin from 'router5/plugins/loggers'\n+ import loggerPlugin from 'router5/plugins/logger'\nimport transitionPath from 'router5-transition-path'\ntype DoneFn = (err?: any, state?: State) => void\n@@ -413,7 +413,7 @@ declare module 'router5/plugins/listeners' {\nexport default listenersPluginFactory\n}\n-declare module 'router5/plugins/loggers' {\n+declare module 'router5/plugins/logger' {\nimport { PluginFactory } from 'router5/core/plugins'\nconst loggerPlugin: PluginFactory\nexport default loggerPlugin\n" } ]
TypeScript
MIT License
router5/router5
fix logger typo in typescript definitions
580,233
29.05.2018 13:33:54
14,400
9972036d53f816e3cf5cfc1d026ac5a57739fd00
Break out transition state type
[ { "change_type": "MODIFY", "old_path": "packages/redux-router5/index.d.ts", "new_path": "packages/redux-router5/index.d.ts", "diff": "@@ -13,7 +13,16 @@ declare module 'redux-router5' {\nexport const router5Reducer: Reducer<RouterState>\n- export function reduxPlugin<TState extends { payload: RouterState | null, type: string }>(\n+ interface TransitionState {\n+ type: string\n+ payload?: {\n+ route: State\n+ previousState?: State\n+ transitionError?: any\n+ }\n+ }\n+\n+ export function reduxPlugin<TState extends TransitionState>(\ndispatch: Dispatch<TState>\n): PluginFactory\n" } ]
TypeScript
MIT License
router5/router5
Break out transition state type
580,236
01.06.2018 11:06:45
14,400
ecf2476bfa9c05c8add109545c12e62b7fe98105
fixing type error received a type error trying to use this library with typescript 2.9.1. it expected `T` and `U` to extend `string | number | symbol`, not just `string`.
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/index.d.ts", "new_path": "packages/react-router5/index.d.ts", "diff": "@@ -7,8 +7,10 @@ declare module 'react-router5' {\n} from 'react'\nimport { Router, Route, State } from 'router5'\n- type Diff<T extends string, U extends string> = ({ [P in T]: P } &\n- { [P in U]: never } & { [x: string]: never })[T]\n+ type Diff<\n+ T extends string | number | symbol,\n+ U extends string | number | symbol\n+ > = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T];\ntype Omit<InputObject, Keys extends keyof InputObject> = Pick<\nInputObject,\n" } ]
TypeScript
MIT License
router5/router5
fixing type error received a type error trying to use this library with typescript 2.9.1. it expected `T` and `U` to extend `string | number | symbol`, not just `string`.
580,249
02.06.2018 08:56:31
-3,600
2a932978adfb9533204b3f5e194fda22bf20a538
chore: delete capitalised md file (Ecosystem)
[ { "change_type": "DELETE", "old_path": "docs/introduction/Ecosystem.md", "new_path": null, "diff": "-# Ecosystem\n-\n-\n-## Provided packages\n-\n-- [react-router5](https://github.com/router5/router5/tree/master/packages/react-router5) integration with react\n-- [redux-router5](https://github.com/router5/router5/tree/master/packages/redux-router5) integration with redux\n-\n-\n-## Community packages\n-\n-- [mobx-router5](https://github.com/LeonardoGentile/mobx-router5): integration with MobX\n-- [react-mobx-router5](https://github.com/LeonardoGentile/react-mobx-router5): integration with Mobx and React\n-\n-\n-## Examples\n-\n-- [With React](https://stackblitz.com/edit/react-router5)\n-- [With React (new context API)](https://stackblitz.com/edit/react-router5-new-context-api)\n-- [With Redux](https://stackblitz.com/edit/react-redux-router5)\n-\n-\n-## Not up to date packages\n-\n-- [rxjs-router5](https://github.com/router5/router5/tree/master/packages/redux-router5) integration with rxjs\n-- [xstream-router5](https://github.com/router5/router5/tree/master/packages/redux-router5) integration with xstream\n-- [deku-router5](https://github.com/router5/router5/tree/master/packages/deku-router5) integration with deku\n-- [router5-link-interceptor](https://github.com/jas-chen/router5-link-interceptor) link interceptor\n-- [router5-boilerplate](https://github.com/sitepack/router5-boilerplate)\n-- [universal-react-redux-hapi](https://github.com/nanopx/universal-react-redux-hapi)\n" } ]
TypeScript
MIT License
router5/router5
chore: delete capitalised md file (Ecosystem)
580,249
02.06.2018 08:58:53
-3,600
e2cda75f2486ac3216395cd7406a7f8bf84186c7
chore: improve middleware TS definition
[ { "change_type": "MODIFY", "old_path": "packages/router5/index.d.ts", "new_path": "packages/router5/index.d.ts", "diff": "@@ -202,7 +202,7 @@ declare module 'router5/core/middleware' {\ntoState: State,\nfromState: State,\ndone: DoneFn\n- ) => boolean | Promise<boolean> | void\n+ ) => boolean | Promise<any> | void\nexport type MiddlewareFactory = (\nrouter: Router,\n" } ]
TypeScript
MIT License
router5/router5
chore: improve middleware TS definition
580,249
02.06.2018 09:13:53
-3,600
9d3428f9853be2ae5ded1b5e9eeeedb7ac4cf50d
chore: add license badge, remove FOSSA
[ { "change_type": "MODIFY", "old_path": "README.md", "new_path": "README.md", "diff": "# Read Me\n-[![npm version](https://badge.fury.io/js/router5.svg)](http://badge.fury.io/js/router5) [![Build Status](https://travis-ci.org/router5/router5.svg)](https://travis-ci.org/router5/router5) [![Join the chat at https://gitter.im/router5/router5](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/router5/router5?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n-[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Frouter5%2Frouter5.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Frouter5%2Frouter5?ref=badge_shield)\n+[![npm version](https://badge.fury.io/js/router5.svg)](http://badge.fury.io/js/router5)\n+[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n+[![Build Status](https://travis-ci.org/router5/router5.svg)](https://travis-ci.org/router5/router5) [![Join the chat at https://gitter.im/router5/router5](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/router5/router5?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n+\n> Official website: [router5.js.org](https://router5.js.org)\n@@ -104,8 +106,3 @@ from(router).map(({ route }) => {\n* [Universal routing](https://router5.js.org/advanced/universal-routing)\n* [Listeners plugin](https://router5.js.org/advanced/listeners-plugin)\n* [API Reference](https://router5.js.org/api-reference)\n-\n-\n-\n-## License\n-[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Frouter5%2Frouter5.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Frouter5%2Frouter5?ref=badge_large)\n\\ No newline at end of file\n" } ]
TypeScript
MIT License
router5/router5
chore: add license badge, remove FOSSA
580,249
05.06.2018 09:41:37
-3,600
40a16d898d42478d9058cd2ead9cc74d6c3a9f21
fix: update route-node to correctly account for query params options
[ { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "},\n\"homepage\": \"https://router5.js.org\",\n\"dependencies\": {\n- \"route-node\": \"3.2.0\",\n+ \"route-node\": \"3.2.1\",\n\"router5-transition-path\": \"^5.3.0\",\n\"symbol-observable\": \"1.2.0\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/yarn.lock", "new_path": "packages/router5/yarn.lock", "diff": "# yarn lockfile v1\[email protected]:\n- version \"4.1.0\"\n- resolved \"https://registry.yarnpkg.com/path-parser/-/path-parser-4.1.0.tgz#41e4c69aa88c6b28c6f6e1200e9aebe9acc3da9e\"\[email protected]:\n+ version \"4.1.1\"\n+ resolved \"https://registry.yarnpkg.com/path-parser/-/path-parser-4.1.1.tgz#2cec1eb1251428aa48774a2ef49dddd46083a18b\"\ndependencies:\n- search-params \"2.1.2\"\n+ search-params \"2.1.3\"\[email protected]:\n- version \"3.2.0\"\n- resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.2.0.tgz#643de314d600b2e19be723851500aa646c5d3a9d\"\[email protected]:\n+ version \"3.2.1\"\n+ resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.2.1.tgz#be0fccbf663be055c8909c1649a004bba22c437b\"\ndependencies:\n- path-parser \"4.1.0\"\n- search-params \"2.1.2\"\n+ path-parser \"4.1.1\"\n+ search-params \"2.1.3\"\nrouter5-transition-path@^5.3.0:\nversion \"5.3.0\"\nresolved \"https://registry.yarnpkg.com/router5-transition-path/-/router5-transition-path-5.3.0.tgz#113f7e09dffee5e22c7275c20fe25969c0bc1599\"\[email protected]:\n- version \"2.1.2\"\n- resolved \"https://registry.yarnpkg.com/search-params/-/search-params-2.1.2.tgz#e0107b7e6f2e973d7991b8fbffc8b6664bc96edd\"\[email protected]:\n+ version \"2.1.3\"\n+ resolved \"https://registry.yarnpkg.com/search-params/-/search-params-2.1.3.tgz#90b98964eaf3d0edef0f73e6e8307d1480020413\"\[email protected]:\nversion \"1.2.0\"\n" } ]
TypeScript
MIT License
router5/router5
fix: update route-node to correctly account for query params options
580,249
05.06.2018 09:46:34
-3,600
75c9a3566520251cd416cdba94ac3f5d4c49bc74
chore: update home page URLs
[ { "change_type": "MODIFY", "old_path": "package.json", "new_path": "package.json", "diff": "\"bugs\": {\n\"url\": \"https://github.com/router5/router5/issues\"\n},\n- \"homepage\": \"http://router5.github.io\",\n+ \"homepage\": \"https://router5.js.org\",\n\"devDependencies\": {\n\"babel-cli\": \"~6.26.0\",\n\"babel-core\": \"~6.26.0\",\n" }, { "change_type": "MODIFY", "old_path": "packages/react-router5/package.json", "new_path": "packages/react-router5/package.json", "diff": "\"bugs\": {\n\"url\": \"https://github.com/router5/router5/issues\"\n},\n- \"homepage\": \"https://github.com/router5/router5/tree/master/packages/react-router5\",\n+ \"homepage\": \"https://router5.js.org\",\n\"peerDependencies\": {\n\"react\": \"^0.14.0 || ^15.0.0 || ^16.0.0\",\n\"router5\": \">= 6.1.0 < 7.0.0\"\n" }, { "change_type": "MODIFY", "old_path": "packages/redux-router5/package.json", "new_path": "packages/redux-router5/package.json", "diff": "\"bugs\": {\n\"url\": \"https://github.com/router5/router5/issues\"\n},\n- \"homepage\": \"http://router5.github.com\",\n+ \"homepage\": \"https://router5.js.org\",\n\"devDependencies\": {\n\"immutable\": \"~3.0.0\"\n},\n" } ]
TypeScript
MIT License
router5/router5
chore: update home page URLs
580,242
06.06.2018 15:36:57
-3,600
8d323e4810fc0f1257096dbc8561a1de3d32d364
fix(BaseLink): ensure activeClassName has higher specificity Avoids need for `!important` to override base styles when selectors have equal specificity
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/BaseLink.js", "new_path": "packages/react-router5/modules/BaseLink.js", "diff": "@@ -91,8 +91,8 @@ class BaseLink extends Component {\nconst active = this.isActive()\nconst href = this.buildUrl(routeName, routeParams)\n- const linkclassName = (className ? className.split(' ') : [])\n- .concat(active ? [activeClassName] : [])\n+ const linkclassName = (active ? [activeClassName] : [])\n+ .concat(className ? className.split(' ') : [])\n.join(' ')\nreturn React.createElement(\n" } ]
TypeScript
MIT License
router5/router5
fix(BaseLink): ensure activeClassName has higher specificity Avoids need for `!important` to override base styles when selectors have equal specificity
580,249
11.07.2018 08:54:08
-3,600
bd01ef9f3f2743157c80f12fca285f8b9a7907df
chore: update route node to v3.3.0
[ { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "},\n\"homepage\": \"https://router5.js.org\",\n\"dependencies\": {\n- \"route-node\": \"3.2.1\",\n+ \"route-node\": \"3.3.0\",\n\"router5-transition-path\": \"^5.3.0\",\n\"symbol-observable\": \"1.2.0\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/yarn.lock", "new_path": "packages/router5/yarn.lock", "diff": "# yarn lockfile v1\[email protected]:\n- version \"4.1.1\"\n- resolved \"https://registry.yarnpkg.com/path-parser/-/path-parser-4.1.1.tgz#2cec1eb1251428aa48774a2ef49dddd46083a18b\"\[email protected]:\n+ version \"4.2.0\"\n+ resolved \"https://registry.yarnpkg.com/path-parser/-/path-parser-4.2.0.tgz#2fbb3df2d49659a9a4cac88be7d8d5f4666814fb\"\ndependencies:\nsearch-params \"2.1.3\"\[email protected]:\n- version \"3.2.1\"\n- resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.2.1.tgz#be0fccbf663be055c8909c1649a004bba22c437b\"\[email protected]:\n+ version \"3.3.0\"\n+ resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.3.0.tgz#df3e4436ae0cc0c3620d43cc28ee9ca098301cbb\"\ndependencies:\n- path-parser \"4.1.1\"\n+ path-parser \"4.2.0\"\nsearch-params \"2.1.3\"\nrouter5-transition-path@^5.3.0:\n" } ]
TypeScript
MIT License
router5/router5
chore: update route node to v3.3.0
580,260
13.07.2018 20:03:59
-10,800
80358db05b0607a07974d5315cd6eb0f397a73d1
Add ignoreQueryParams prop to BaseLink Make use of router5's ability to check or ignore query params when checking whether a route is active.
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/BaseLink.js", "new_path": "packages/react-router5/modules/BaseLink.js", "diff": "@@ -32,7 +32,8 @@ class BaseLink extends Component {\nreturn this.router.isActive(\nthis.props.routeName,\nthis.props.routeParams,\n- this.props.activeStrict\n+ this.props.activeStrict,\n+ this.props.ignoreQueryParams\n)\n}\n@@ -78,6 +79,7 @@ class BaseLink extends Component {\nclassName,\nactiveClassName,\nactiveStrict,\n+ ignoreQueryParams,\nroute,\npreviousRoute,\nrouter,\n@@ -118,6 +120,7 @@ BaseLink.propTypes = {\nrouteOptions: PropTypes.object,\nactiveClassName: PropTypes.string,\nactiveStrict: PropTypes.bool,\n+ ignoreQueryParams: PropTypes.bool,\nonClick: PropTypes.func,\nonMouseOver: PropTypes.func,\nsuccessCallback: PropTypes.func,\n@@ -127,6 +130,7 @@ BaseLink.propTypes = {\nBaseLink.defaultProps = {\nactiveClassName: 'active',\nactiveStrict: false,\n+ ignoreQueryParams: true,\nrouteParams: {},\nrouteOptions: {}\n}\n" } ]
TypeScript
MIT License
router5/router5
Add ignoreQueryParams prop to BaseLink Make use of router5's ability to check or ignore query params when checking whether a route is active.
580,249
05.08.2018 16:23:24
-7,200
ec45cc808b21b75d52150ebc13735dfc5cb3c22f
fix: fix middleware test
[ { "change_type": "MODIFY", "old_path": "packages/router5/test/core/middleware.js", "new_path": "packages/router5/test/core/middleware.js", "diff": "@@ -104,7 +104,7 @@ describe('core/middleware', () => {\n})\n})\n- it('should pass state from middleware to middleware', () => {\n+ it('should pass state from middleware to middleware', done => {\nconst m1 = () => (toState, fromState, done) => {\ndone(null, { ...toState, m1: true })\n}\n@@ -112,7 +112,7 @@ describe('core/middleware', () => {\nPromise.resolve({ ...toState, m2: toState.m1 })\nconst m3 = () => (toState, fromState, done) => {\n- done(null, { ...toState, m3: toState.m3 })\n+ done(null, { ...toState, m3: toState.m2 })\n}\nrouter.clearMiddleware()\nrouter.useMiddleware(m1, m2, m3)\n@@ -122,6 +122,8 @@ describe('core/middleware', () => {\nexpect(state.m1).to.equal(true)\nexpect(state.m2).to.equal(true)\nexpect(state.m3).to.equal(true)\n+\n+ done()\n})\n})\n})\n" } ]
TypeScript
MIT License
router5/router5
fix: fix middleware test
580,249
05.08.2018 16:43:08
-7,200
ba6c55f2b5c9448cb882a7ba0a85e418708f72ba
test: add unknown route listeners test
[ { "change_type": "MODIFY", "old_path": "packages/router5/test/core/navigation.js", "new_path": "packages/router5/test/core/navigation.js", "diff": "@@ -33,13 +33,6 @@ describe('core/navigation', function() {\n})\n})\n- it('should return an error if trying to navigate to an unknown route', function(done) {\n- router.navigate('fake.route', function(err, state) {\n- expect(err.code).to.equal(errorCodes.ROUTE_NOT_FOUND)\n- done()\n- })\n- })\n-\nit('should navigate to same state if reload is set to true', function(done) {\nrouter.navigate('orders.pending', function(err, state) {\nrouter.navigate('orders.pending', function(err, state) {\n" } ]
TypeScript
MIT License
router5/router5
test: add unknown route listeners test
580,249
06.08.2018 13:24:44
-7,200
cd5af896d206973e128418312bf34254e3002d93
perf: update route-node to v3.4.0
[ { "change_type": "MODIFY", "old_path": "packages/router5/package.json", "new_path": "packages/router5/package.json", "diff": "},\n\"homepage\": \"https://router5.js.org\",\n\"dependencies\": {\n- \"route-node\": \"3.3.0\",\n+ \"route-node\": \"3.4.0\",\n\"router5-transition-path\": \"^5.3.0\",\n\"symbol-observable\": \"1.2.0\"\n},\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/yarn.lock", "new_path": "packages/router5/yarn.lock", "diff": "@@ -8,17 +8,13 @@ [email protected]:\ndependencies:\nsearch-params \"2.1.3\"\[email protected]:\n- version \"3.3.0\"\n- resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.3.0.tgz#df3e4436ae0cc0c3620d43cc28ee9ca098301cbb\"\[email protected]:\n+ version \"3.4.0\"\n+ resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.4.0.tgz#6fc581b86d824d1dbe2de4f7dfc2654b10901e4d\"\ndependencies:\npath-parser \"4.2.0\"\nsearch-params \"2.1.3\"\n-router5-transition-path@^5.3.0:\n- version \"5.3.0\"\n- resolved \"https://registry.yarnpkg.com/router5-transition-path/-/router5-transition-path-5.3.0.tgz#113f7e09dffee5e22c7275c20fe25969c0bc1599\"\n-\[email protected]:\nversion \"2.1.3\"\nresolved \"https://registry.yarnpkg.com/search-params/-/search-params-2.1.3.tgz#90b98964eaf3d0edef0f73e6e8307d1480020413\"\n" } ]
TypeScript
MIT License
router5/router5
perf: update route-node to v3.4.0
580,249
07.08.2018 15:01:05
-7,200
31871c14496da63784c9ada5aab77f62026811c6
perf: improve performance of adding routes using add
[ { "change_type": "MODIFY", "old_path": "packages/router5/index.d.ts", "new_path": "packages/router5/index.d.ts", "diff": "@@ -169,7 +169,7 @@ declare module 'router5/create-router' {\nsetDependency(dependencyName: string, dependency: any): Router\nsetDependencies(deps: Dependencies): Router\ngetDependencies(): Dependencies\n- add(routes: Route[] | Route): Router\n+ add(routes: Route[] | Route, finalSort?: boolean): Router\naddNode(\nname: string,\npath: string,\n" }, { "change_type": "MODIFY", "old_path": "packages/router5/modules/create-router.js", "new_path": "packages/router5/modules/create-router.js", "diff": "@@ -256,8 +256,11 @@ function createRouter(routes, opts = {}, deps = {}) {\n* @param {Array} routes A list of routes to add\n* @return {Object} The router instance\n*/\n- function add(routes) {\n- rootNode.add(routes, onRouteAdded)\n+ function add(routes, finalSort = true) {\n+ rootNode.add(routes, onRouteAdded, !finalSort)\n+ if (finalSort) {\n+ rootNode.sortDescendants()\n+ }\nreturn router\n}\n" } ]
TypeScript
MIT License
router5/router5
perf: improve performance of adding routes using add
580,249
19.08.2018 11:31:33
-7,200
b6a449fac047182c21cc7e93e463fe20572852e3
docs: add link to marko integration
[ { "change_type": "MODIFY", "old_path": "docs/introduction/ecosystem.md", "new_path": "docs/introduction/ecosystem.md", "diff": "* [mobx-router5](https://github.com/LeonardoGentile/mobx-router5): integration with MobX\n* [react-mobx-router5](https://github.com/LeonardoGentile/react-mobx-router5): integration with Mobx and React\n+* [marko-router5](https://jesse1983.github.io/marko-router5/#/): integration with MarkoJS\n## Examples\n* [With React \\(new context API\\)](https://stackblitz.com/edit/react-router5-new-context-api)\n* [With Redux](https://stackblitz.com/edit/react-redux-router5)\n-## Not up to date packages\n+## Not up to date\n* [rxjs-router5](https://github.com/router5/router5/tree/master/packages/redux-router5) integration with rxjs\n* [xstream-router5](https://github.com/router5/router5/tree/master/packages/redux-router5) integration with xstream\n" } ]
TypeScript
MIT License
router5/router5
docs: add link to marko integration
580,249
19.08.2018 12:57:19
-7,200
a090c2ad7b31ec6e9ae0e052ec459ce8a8f44ce5
fix: force all nodes to update if reload transition option is true
[ { "change_type": "MODIFY", "old_path": "packages/router5-transition-path/modules/shouldUpdateNode.js", "new_path": "packages/router5-transition-path/modules/shouldUpdateNode.js", "diff": "@@ -10,6 +10,10 @@ export default function shouldUpdateNode(nodeName) {\nconst toDeactivate = [...toDeactivateReversed].reverse()\n+ if (toState.meta.options && toState.meta.options.reload) {\n+ return true\n+ }\n+\nif (nodeName === intersection) {\nreturn true\n}\n" } ]
TypeScript
MIT License
router5/router5
fix: force all nodes to update if reload transition option is true
580,249
21.08.2018 09:31:55
-7,200
77cbf3ea5e6b781afe3208a09d64c1e09b791d75
fix: move route change subscription to constructor (new context)
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/RouteProvider.js", "new_path": "packages/react-router5/modules/RouteProvider.js", "diff": "@@ -22,9 +22,8 @@ class RouteProvider extends React.PureComponent {\npreviousRoute: null,\nrouter\n}\n- }\n- componentDidMount() {\n+ if (typeof window !== 'undefined') {\nconst listener = ({ route, previousRoute }) => {\nthis.setState({\nroute,\n@@ -33,10 +32,13 @@ class RouteProvider extends React.PureComponent {\n}\nthis.unsubscribe = this.router.subscribe(listener)\n}\n+ }\ncomponentWillUnmount() {\n+ if (this.unsubscribe) {\nthis.unsubscribe()\n}\n+ }\ngetChildContext() {\nreturn { router: this.props.router }\n" } ]
TypeScript
MIT License
router5/router5
fix: move route change subscription to constructor (new context)
580,249
21.08.2018 10:00:50
-7,200
b1523167cd3a8a6f4cce3eacb965090a2b94a510
fix: move route change subscription to constructor (old context)
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/routeNode.js", "new_path": "packages/react-router5/modules/routeNode.js", "diff": "@@ -13,9 +13,8 @@ function routeNode(nodeName) {\npreviousRoute: null,\nroute: this.router.getState()\n}\n- }\n- componentDidMount() {\n+ if (typeof window === 'undefined') {\nconst listener = ({ route, previousRoute }) => {\nif (shouldUpdateNode(nodeName)(route, previousRoute)) {\nthis.setState({\n@@ -26,10 +25,13 @@ function routeNode(nodeName) {\n}\nthis.unsubscribe = this.router.subscribe(listener)\n}\n+ }\ncomponentWillUnmount() {\n+ if (this.unsubscribe) {\nthis.unsubscribe()\n}\n+ }\nrender() {\nconst { props, router } = this\n" }, { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/withRoute.js", "new_path": "packages/react-router5/modules/withRoute.js", "diff": "@@ -11,18 +11,20 @@ function withRoute(BaseComponent) {\npreviousRoute: null,\nroute: this.router.getState()\n}\n- }\n- componentDidMount() {\n+ if (typeof window === 'undefined') {\nconst listener = ({ route, previousRoute }) => {\nthis.setState({ route, previousRoute })\n}\nthis.unsubscribe = this.router.subscribe(listener)\n}\n+ }\ncomponentWillUnmount() {\n+ if (this.unsubscribe) {\nthis.unsubscribe()\n}\n+ }\nrender() {\nreturn createElement(BaseComponent, {\n" } ]
TypeScript
MIT License
router5/router5
fix: move route change subscription to constructor (old context)
580,249
22.08.2018 15:57:21
-7,200
455cfcf0c72a1ae9c8364036f37a157a5deb8e7b
fix: fix listeners not registering
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/routeNode.js", "new_path": "packages/react-router5/modules/routeNode.js", "diff": "@@ -14,7 +14,7 @@ function routeNode(nodeName) {\nroute: this.router.getState()\n}\n- if (typeof window === 'undefined') {\n+ if (typeof window !== 'undefined') {\nconst listener = ({ route, previousRoute }) => {\nif (shouldUpdateNode(nodeName)(route, previousRoute)) {\nthis.setState({\n" }, { "change_type": "MODIFY", "old_path": "packages/react-router5/modules/withRoute.js", "new_path": "packages/react-router5/modules/withRoute.js", "diff": "@@ -12,7 +12,7 @@ function withRoute(BaseComponent) {\nroute: this.router.getState()\n}\n- if (typeof window === 'undefined') {\n+ if (typeof window !== 'undefined') {\nconst listener = ({ route, previousRoute }) => {\nthis.setState({ route, previousRoute })\n}\n" } ]
TypeScript
MIT License
router5/router5
fix: fix listeners not registering
580,249
22.08.2018 21:57:07
-7,200
108ee2fa084e7ffcd2febe0573f9c4d02ea3f82a
chore: fix redux example
[ { "change_type": "MODIFY", "old_path": "examples/react-redux/src/components/App.js", "new_path": "examples/react-redux/src/components/App.js", "diff": "@@ -3,7 +3,7 @@ import { connect } from 'react-redux'\nimport Nav from './Nav'\nimport Main from './Main'\n-export default function App({ emails }) {\n+export function App({ emails }) {\nreturn (\n<div className=\"mail-client\">\n<aside>\n" }, { "change_type": "MODIFY", "old_path": "examples/react-redux/src/components/Inbox.js", "new_path": "examples/react-redux/src/components/Inbox.js", "diff": "@@ -2,7 +2,7 @@ import React from 'react'\nimport { connect } from 'react-redux'\nimport InboxList from './InboxList'\nimport Message from './Message'\n-import { routeNodeSelector } from 'redux-router5'\n+import { createRouteNodeSelector } from 'redux-router5'\nfunction Inbox(props) {\nconst { route, emails } = props\n@@ -17,4 +17,4 @@ function Inbox(props) {\n)\n}\n-export default connect(routeNodeSelector('inbox'))(Inbox)\n+export default connect(createRouteNodeSelector('inbox'))(Inbox)\n" }, { "change_type": "MODIFY", "old_path": "examples/react-redux/src/components/Main.js", "new_path": "examples/react-redux/src/components/Main.js", "diff": "import React from 'react'\nimport { connect } from 'react-redux'\n-import { routeNodeSelector } from 'redux-router5'\n+import { createRouteNodeSelector } from 'redux-router5'\nimport Inbox from './Inbox'\nimport Compose from './Compose'\nimport NotFound from './NotFound'\n@@ -19,4 +19,4 @@ function Main({ route, emails }) {\nreturn <NotFound />\n}\n-export default connect(routeNodeSelector(''))(Main)\n+export default connect(createRouteNodeSelector(''))(Main)\n" } ]
TypeScript
MIT License
router5/router5
chore: fix redux example
580,237
24.08.2018 15:45:35
-25,200
abc1ad2c6c99a946105d4ca397778671c0dc8421
Update router-options.md looks like a typo there
[ { "change_type": "MODIFY", "old_path": "docs/guides/router-options.md", "new_path": "docs/guides/router-options.md", "diff": "@@ -81,7 +81,7 @@ Option `trailingSlashMode` can take the following values:\n## Strict trailing slash\n-By default, the router is not in \"strict match\" mode. If you want trailing slashes to not be optional, you can set `strictTailingSlash` to \\`true\\`\\`.\n+By default, the router is not in \"strict match\" mode. If you want trailing slashes to not be optional, you can set `strictTrailingSlash` to \\`true\\`\\`.\n## Automatic clean up\n" } ]
TypeScript
MIT License
router5/router5
Update router-options.md looks like a typo there
580,267
25.08.2018 11:08:33
-10,800
e53bc074bd36552eeb1baa6d962404b6e22d7896
Fix code example in loading-async-data.md Code does not actually call functions with promises. Promise.all receives array of functions, and simply returns its, without calling.
[ { "change_type": "MODIFY", "old_path": "docs/advanced/loading-async-data.md", "new_path": "docs/advanced/loading-async-data.md", "diff": "@@ -57,7 +57,7 @@ const dataMiddlewareFactory = (routes) => (router) => (toState, fromState) => {\n.filter(Boolean)\nreturn Promise\n- .all(onActivateHandlers)\n+ .all(onActivateHandlers.map(callback => callback()))\n.then(data => {\nconst routeData = data.reduce((accData, rData) => Object.assign(accData, rData), {});\nreturn { ...toState, data: routeData };\n" } ]
TypeScript
MIT License
router5/router5
Fix code example in loading-async-data.md Code does not actually call functions with promises. Promise.all receives array of functions, and simply returns its, without calling.
580,250
03.09.2018 16:23:10
-7,200
766da878ac02f9b7b862ed3165af2c07010fe092
Check if state has meta params before extracting segment params
[ { "change_type": "MODIFY", "old_path": "packages/router5-transition-path/modules/transitionPath.js", "new_path": "packages/router5-transition-path/modules/transitionPath.js", "diff": "@@ -13,7 +13,7 @@ function hasMetaParams(state) {\n}\nfunction extractSegmentParams(name, state) {\n- if (!exists(state.meta.params[name])) return {}\n+ if (!hasMetaParams(state) || !exists(state.meta.params[name])) return {}\nreturn Object.keys(state.meta.params[name]).reduce((params, p) => {\nparams[p] = state.params[p]\n" } ]
TypeScript
MIT License
router5/router5
Check if state has meta params before extracting segment params
580,250
04.09.2018 10:13:20
-7,200
c5e93acaa316f4634f4556c6b5e95dcddbac9258
Fix state set in router.replaceHistoryState
[ { "change_type": "MODIFY", "old_path": "packages/router5/modules/plugins/browser/index.js", "new_path": "packages/router5/modules/plugins/browser/index.js", "diff": "@@ -38,7 +38,13 @@ function browserPluginFactory(opts = {}, browser = safeBrowser) {\n}\nrouter.replaceHistoryState = function(name, params = {}) {\n- const state = router.buildState(name, params)\n+ const route = router.buildState(name, params)\n+ const state = router.makeState(\n+ route.name,\n+ route.params,\n+ router.buildPath(route.name, route.params),\n+ { params: route.meta }\n+ )\nconst url = router.buildUrl(name, params)\nrouter.lastKnownState = state\nbrowser.replaceState(state, '', url)\n" } ]
TypeScript
MIT License
router5/router5
Fix state set in router.replaceHistoryState
580,239
04.09.2018 16:31:06
-25,200
553c388205e7d676c17975cf09ca93b39999197b
update broken links in examples/README.md
[ { "change_type": "MODIFY", "old_path": "examples/README.md", "new_path": "examples/README.md", "diff": "# Examples\n-* With React: [`code`](./examples/react) | [`live`](https://stackblitz.com/github/router5/router5/tree/master/examples/react)\n-* With React new context API: [`code`](./examples/react-new-context-api) | [`live`](https://stackblitz.com/github/router5/router5/tree/master/examples/react-new-context-api)\n-* With Redux (and React): [`code`](./examples/react-redux) | [`live`](https://stackblitz.com/github/router5/router5/tree/master/examples/react-redux)\n+* With React: [`code`](./react) | [`live`](https://stackblitz.com/github/router5/router5/tree/master/examples/react)\n+* With React new context API: [`code`](./react-new-context-api) | [`live`](https://stackblitz.com/github/router5/router5/tree/master/examples/react-new-context-api)\n+* With Redux (and React): [`code`](./react-redux) | [`live`](https://stackblitz.com/github/router5/router5/tree/master/examples/react-redux)\n" } ]
TypeScript
MIT License
router5/router5
update broken links in examples/README.md
580,239
05.09.2018 12:19:26
-25,200
7a88a212cefcd3fe8f5b5e77b9b3d0992954d133
upgrade prop-types in react-router5 to v15.6
[ { "change_type": "MODIFY", "old_path": "packages/react-router5/package.json", "new_path": "packages/react-router5/package.json", "diff": "\"router5\": \">= 6.1.0 < 7.0.0\"\n},\n\"dependencies\": {\n- \"prop-types\": \"~15.5.10\",\n+ \"prop-types\": \"^15.6.0\",\n\"router5-transition-path\": \"^5.3.1\"\n},\n\"typings\": \"./index.d.ts\",\n" }, { "change_type": "MODIFY", "old_path": "packages/react-router5/yarn.lock", "new_path": "packages/react-router5/yarn.lock", "diff": "@@ -73,18 +73,6 @@ fbjs@^0.8.16:\nsetimmediate \"^1.0.5\"\nua-parser-js \"^0.7.9\"\n-fbjs@^0.8.9:\n- version \"0.8.12\"\n- resolved \"https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.12.tgz#10b5d92f76d45575fd63a217d4ea02bea2f8ed04\"\n- dependencies:\n- core-js \"^1.0.0\"\n- isomorphic-fetch \"^2.1.1\"\n- loose-envify \"^1.0.0\"\n- object-assign \"^4.1.0\"\n- promise \"^7.1.1\"\n- setimmediate \"^1.0.5\"\n- ua-parser-js \"^0.7.9\"\n-\nforeach@^2.0.5:\nversion \"2.0.5\"\nresolved \"https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99\"\n@@ -190,20 +178,12 @@ promise@^7.1.1:\nasap \"~2.0.3\"\nprop-types@^15.6.0:\n- version \"15.6.1\"\n- resolved \"https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.1.tgz#36644453564255ddda391191fb3a125cbdf654ca\"\n+ version \"15.6.2\"\n+ resolved \"https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102\"\ndependencies:\n- fbjs \"^0.8.16\"\nloose-envify \"^1.3.1\"\nobject-assign \"^4.1.1\"\n-prop-types@~15.5.10:\n- version \"15.5.10\"\n- resolved \"https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154\"\n- dependencies:\n- fbjs \"^0.8.9\"\n- loose-envify \"^1.3.1\"\n-\nreact-is@^16.3.1:\nversion \"16.3.1\"\nresolved \"https://registry.yarnpkg.com/react-is/-/react-is-16.3.1.tgz#ee66e6d8283224a83b3030e110056798488359ba\"\n@@ -226,9 +206,9 @@ react-test-renderer@^16.0.0-0:\nprop-types \"^15.6.0\"\nreact-is \"^16.3.1\"\n-router5-transition-path@^5.3.0:\n- version \"5.3.0\"\n- resolved \"https://registry.yarnpkg.com/router5-transition-path/-/router5-transition-path-5.3.0.tgz#113f7e09dffee5e22c7275c20fe25969c0bc1599\"\n+router5-transition-path@^5.3.1:\n+ version \"5.3.1\"\n+ resolved \"https://registry.yarnpkg.com/router5-transition-path/-/router5-transition-path-5.3.1.tgz#1ab4b707f4cf14460e2cfc0fc38642b34f1d7688\"\nsetimmediate@^1.0.5:\nversion \"1.0.5\"\n" } ]
TypeScript
MIT License
router5/router5
upgrade prop-types in react-router5 to v15.6