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,246 | 06.09.2018 21:01:09 | -10,800 | 4cf4e18ab04b88d7fafeb166944acd3664a8ed76 | Fix BaseLink component when used with target="_blank" | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/BaseLink.js",
"new_path": "packages/react-router5/modules/BaseLink.js",
"diff": "@@ -48,8 +48,10 @@ class BaseLink extends Component {\n}\nclickHandler(evt) {\n- if (this.props.onClick) {\n- this.props.onClick(evt)\n+ const { onClick, target } = this.props\n+\n+ if (onClick) {\n+ onClick(evt)\nif (evt.defaultPrevented) {\nreturn\n@@ -59,7 +61,7 @@ class BaseLink extends Component {\nconst comboKey =\nevt.metaKey || evt.altKey || evt.ctrlKey || evt.shiftKey\n- if (evt.button === 0 && !comboKey) {\n+ if (evt.button === 0 && !comboKey && target !== '_blank') {\nevt.preventDefault()\nthis.router.navigate(\nthis.props.routeName,\n"
}
] | TypeScript | MIT License | router5/router5 | Fix BaseLink component when used with target="_blank" |
580,271 | 10.09.2018 11:07:57 | -7,200 | bce3142e68ca067c978ec00fa3c282bd335df473 | fix: prevent setState() to be called on an unmounted component | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/RouteProvider.js",
"new_path": "packages/react-router5/modules/RouteProvider.js",
"diff": "@@ -16,24 +16,33 @@ class RouteProvider extends React.PureComponent {\nsuper(props)\nconst { router } = props\n+ state = {\n+ mounted: false\n+ }\nthis.router = router\n- this.state = {\n+ this.routeState = {\nroute: router.getState(),\npreviousRoute: null,\n- router\n}\nif (typeof window !== 'undefined') {\nconst listener = ({ route, previousRoute }) => {\n- this.setState({\n+ this.routeState = {\nroute,\npreviousRoute\n- })\n+ }\n+ if (this.state.mounted) {\n+ this.forceUpdate()\n+ }\n}\nthis.unsubscribe = this.router.subscribe(listener)\n}\n}\n+ componentDidMount() {\n+ this.setState({ mounted: true })\n+ }\n+\ncomponentWillUnmount() {\nif (this.unsubscribe) {\nthis.unsubscribe()\n@@ -45,7 +54,11 @@ class RouteProvider extends React.PureComponent {\n}\nrender() {\n- return <Provider value={this.state}>{this.props.children}</Provider>\n+ const value = {\n+ router: this.props.router,\n+ ...this.routeState\n+ }\n+ return <Provider value={value}>{this.props.children}</Provider>\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/routeNode.js",
"new_path": "packages/react-router5/modules/routeNode.js",
"diff": "@@ -9,24 +9,34 @@ function routeNode(nodeName) {\nconstructor(props, context) {\nsuper(props, context)\nthis.router = context.router\n- this.state = {\n+ this.routeState = {\npreviousRoute: null,\nroute: this.router.getState()\n}\n+ this.state = {\n+ mounted: false\n+ }\nif (typeof window !== 'undefined') {\nconst listener = ({ route, previousRoute }) => {\nif (shouldUpdateNode(nodeName)(route, previousRoute)) {\n- this.setState({\n+ this.routeState = {\npreviousRoute,\nroute\n- })\n+ }\n+ if (this.state.mounted) {\n+ this.forceUpdate()\n+ }\n}\n}\nthis.unsubscribe = this.router.subscribe(listener)\n}\n}\n+ componentDidMount() {\n+ this.setState({ mounted: true })\n+ }\n+\ncomponentWillUnmount() {\nif (this.unsubscribe) {\nthis.unsubscribe()\n@@ -35,7 +45,7 @@ function routeNode(nodeName) {\nrender() {\nconst { props, router } = this\n- const { previousRoute, route } = this.state\n+ const { previousRoute, route } = this.routeState\nconst component = createElement(RouteSegment, {\n...props,\nrouter,\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/withRoute.js",
"new_path": "packages/react-router5/modules/withRoute.js",
"diff": "@@ -7,19 +7,29 @@ function withRoute(BaseComponent) {\nconstructor(props, context) {\nsuper(props, context)\nthis.router = context.router\n- this.state = {\n+ this.routeState = {\npreviousRoute: null,\nroute: this.router.getState()\n}\n+ this.state = {\n+ mounted: false\n+ }\nif (typeof window !== 'undefined') {\nconst listener = ({ route, previousRoute }) => {\n- this.setState({ route, previousRoute })\n+ this.routeState({ route, previousRoute })\n+ if (state.mounted) {\n+ this.forceUpdate()\n+ }\n}\nthis.unsubscribe = this.router.subscribe(listener)\n}\n}\n+ componentDidMount() {\n+ this.setState({ mounted: true })\n+ }\n+\ncomponentWillUnmount() {\nif (this.unsubscribe) {\nthis.unsubscribe()\n@@ -29,7 +39,7 @@ function withRoute(BaseComponent) {\nrender() {\nreturn createElement(BaseComponent, {\n...this.props,\n- ...this.state,\n+ ...this.routeState,\nrouter: this.router\n})\n}\n"
}
] | TypeScript | MIT License | router5/router5 | fix: prevent setState() to be called on an unmounted component |
580,250 | 13.09.2018 16:43:45 | -7,200 | e4321b0cff5ef422f7f20171f986b75d3ee33431 | Add title as 3rd parameter of router.replaceHistoryState
Let the person using the router decide if he want to set the `title` using `router.replaceHistoryState`. | [
{
"change_type": "MODIFY",
"old_path": "packages/router5/modules/plugins/browser/index.js",
"new_path": "packages/router5/modules/plugins/browser/index.js",
"diff": "@@ -37,7 +37,7 @@ function browserPluginFactory(opts = {}, browser = safeBrowser) {\nreturn router\n}\n- router.replaceHistoryState = function(name, params = {}) {\n+ router.replaceHistoryState = function(name, params = {}, title = '') {\nconst route = router.buildState(name, params)\nconst state = router.makeState(\nroute.name,\n@@ -47,7 +47,7 @@ function browserPluginFactory(opts = {}, browser = safeBrowser) {\n)\nconst url = router.buildUrl(name, params)\nrouter.lastKnownState = state\n- browser.replaceState(state, '', url)\n+ browser.replaceState(state, title, url)\n}\nfunction updateBrowserState(state, url, replace) {\n"
}
] | TypeScript | MIT License | router5/router5 | Add title as 3rd parameter of router.replaceHistoryState
Let the person using the router decide if he want to set the `title` using `router.replaceHistoryState`. |
580,271 | 17.09.2018 16:37:46 | -7,200 | db86e90ec1f7b41ab528491d6dba46bf604493f1 | fix: avoid using unnecessary re-rendering | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/RouteProvider.js",
"new_path": "packages/react-router5/modules/RouteProvider.js",
"diff": "@@ -15,14 +15,11 @@ class RouteProvider extends React.PureComponent {\nconstructor(props) {\nsuper(props)\nconst { router } = props\n-\n- state = {\n- mounted: false\n- }\n+ this.mounted = false\nthis.router = router\nthis.routeState = {\nroute: router.getState(),\n- previousRoute: null,\n+ previousRoute: null\n}\nif (typeof window !== 'undefined') {\n@@ -31,7 +28,7 @@ class RouteProvider extends React.PureComponent {\nroute,\npreviousRoute\n}\n- if (this.state.mounted) {\n+ if (this.mounted) {\nthis.forceUpdate()\n}\n}\n@@ -40,7 +37,7 @@ class RouteProvider extends React.PureComponent {\n}\ncomponentDidMount() {\n- this.setState({ mounted: true })\n+ this.mounted = true\n}\ncomponentWillUnmount() {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/routeNode.js",
"new_path": "packages/react-router5/modules/routeNode.js",
"diff": "@@ -13,9 +13,7 @@ function routeNode(nodeName) {\npreviousRoute: null,\nroute: this.router.getState()\n}\n- this.state = {\n- mounted: false\n- }\n+ this.mounted = false\nif (typeof window !== 'undefined') {\nconst listener = ({ route, previousRoute }) => {\n@@ -24,7 +22,7 @@ function routeNode(nodeName) {\npreviousRoute,\nroute\n}\n- if (this.state.mounted) {\n+ if (this.mounted) {\nthis.forceUpdate()\n}\n}\n@@ -34,7 +32,7 @@ function routeNode(nodeName) {\n}\ncomponentDidMount() {\n- this.setState({ mounted: true })\n+ this.mounted = true\n}\ncomponentWillUnmount() {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/withRoute.js",
"new_path": "packages/react-router5/modules/withRoute.js",
"diff": "@@ -11,9 +11,7 @@ function withRoute(BaseComponent) {\npreviousRoute: null,\nroute: this.router.getState()\n}\n- this.state = {\n- mounted: false\n- }\n+ this.mounted = false\nif (typeof window !== 'undefined') {\nconst listener = ({ route, previousRoute }) => {\n@@ -21,7 +19,7 @@ function withRoute(BaseComponent) {\nroute,\npreviousRoute\n}\n- if (this.state.mounted) {\n+ if (this.mounted) {\nthis.forceUpdate()\n}\n}\n@@ -30,7 +28,7 @@ function withRoute(BaseComponent) {\n}\ncomponentDidMount() {\n- this.setState({ mounted: true })\n+ this.mounted = true\n}\ncomponentWillUnmount() {\n"
}
] | TypeScript | MIT License | router5/router5 | fix: avoid using unnecessary re-rendering |
580,271 | 17.09.2018 16:54:31 | -7,200 | 40212027000e42d124278894d2aa33ad5f7f8719 | feat(withRouter): add a withRouter component | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/index.js",
"new_path": "packages/react-router5/modules/index.js",
"diff": "@@ -2,6 +2,7 @@ import BaseLink from './BaseLink'\nimport routeNode from './routeNode'\nimport RouterProvider from './RouterProvider'\nimport withRoute from './withRoute'\n+import withRouter from './withRouter'\nimport { RouteProvider, Route, RouteNode } from './RouteProvider'\nconst Link = withRoute(BaseLink)\n@@ -11,6 +12,7 @@ export {\nrouteNode,\nRouterProvider,\nwithRoute,\n+ withRouter,\nLink,\nRouteProvider,\nRoute,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/withRouter.js",
"diff": "+import { Component, createElement } from 'react'\n+import { getDisplayName } from './utils'\n+import PropTypes from 'prop-types'\n+\n+function withRouter(BaseComponent) {\n+ class ComponentWithRouter extends Component {\n+ constructor(props, context) {\n+ super(props, context)\n+ this.router = context.router\n+ }\n+\n+ render() {\n+ return createElement(BaseComponent, {\n+ ...this.props,\n+ router: this.router\n+ })\n+ }\n+ }\n+\n+ ComponentWithRouter.contextTypes = {\n+ router: PropTypes.object.isRequired\n+ }\n+\n+ ComponentWithRouter.displayerName =\n+ 'WithRouter[' + getDisplayName(BaseComponent) + ']'\n+\n+ return ComponentWithRouter\n+}\n+\n+export default withRouter\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/test/main.js",
"new_path": "packages/react-router5/test/main.js",
"diff": "@@ -4,6 +4,7 @@ import { Child, createTestRouter, FnChild, renderWithRouter } from './utils'\nimport {\nRouterProvider,\nwithRoute,\n+ withRouter,\nrouteNode,\nBaseLink,\nLink\n@@ -35,6 +36,25 @@ describe('withRoute hoc', () => {\n})\n})\n+describe('withRouter hoc', () => {\n+ let router\n+\n+ before(() => {\n+ router = createTestRouter()\n+ })\n+\n+ it('should inject the router on the wrapped component props', () => {\n+ const ChildSpy = spy(FnChild)\n+ router.usePlugin(listenersPlugin())\n+\n+ renderWithRouter(router)(withRouter(ChildSpy))\n+\n+ expect(ChildSpy).to.have.been.calledWith({\n+ router\n+ })\n+ })\n+})\n+\ndescribe('routeNode hoc', () => {\nlet router\n"
}
] | TypeScript | MIT License | router5/router5 | feat(withRouter): add a withRouter component |
580,266 | 30.09.2018 23:25:26 | -7,200 | e2684a9c33dfd8957ae6a7de88f49ad52de1e8fd | chore(ts): Add typings for RouteNode component
closes | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/index.d.ts",
"new_path": "packages/react-router5/index.d.ts",
"diff": "@@ -10,7 +10,7 @@ declare module 'react-router5' {\ntype Diff<\nT extends string | number | symbol,\nU extends string | number | symbol\n- > = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T];\n+ > = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]\ntype Omit<InputObject, Keys extends keyof InputObject> = Pick<\nInputObject,\n@@ -62,4 +62,13 @@ declare module 'react-router5' {\n): (\nRouteSegment: ComponentType<TProps>\n) => ComponentClass<Omit<TProps, keyof InjectedRouterNode>>\n+\n+ export type RenderCallback = (args: InjectedRouterNode) => JSX.Element\n+\n+ export const RouteNode: ComponentClass<\n+ Partial<{\n+ nodeName?: string\n+ children: RenderCallback\n+ }>\n+ >\n}\n"
}
] | TypeScript | MIT License | router5/router5 | chore(ts): Add typings for RouteNode component
closes #366 |
580,249 | 02.10.2018 09:36:37 | -3,600 | 01f668eba690d7267d97951d27f8c62cfbe099eb | doc: add to react-router5 README | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/README.md",
"new_path": "packages/react-router5/README.md",
"diff": "@@ -33,6 +33,7 @@ const AppWithRouter = (\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\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+* **withRouter**: HoC injecting your router instance only (from context) to the wrapped component.\n```javascript\nimport React from 'react'\n"
}
] | TypeScript | MIT License | router5/router5 | doc: add to react-router5 README |
580,266 | 02.10.2018 12:59:36 | -7,200 | 491b72245029fb1491754a444d739cabce8f8053 | chore(ts): Add typings for Route, RouteProvider | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/index.d.ts",
"new_path": "packages/react-router5/index.d.ts",
"diff": "@@ -65,10 +65,17 @@ declare module 'react-router5' {\nexport type RenderCallback = (args: InjectedRouterNode) => JSX.Element\n- export const RouteNode: ComponentClass<\n- Partial<{\n- nodeName?: string\n+ export const RouteNode: ComponentClass<{\n+ nodeName: string\nchildren: RenderCallback\n}>\n- >\n+\n+ export const RouteProvider: ComponentClass<{\n+ children?: React.ReactNode\n+ router: Router\n+ }>\n+\n+ export const Route: ComponentClass<{\n+ children: (value: T) => React.ReactNode\n+ }>\n}\n"
}
] | TypeScript | MIT License | router5/router5 | chore(ts): Add typings for Route, RouteProvider |
580,249 | 04.10.2018 14:38:34 | -3,600 | f9c577320609c25e7bcac8a0e1e93711d67dd4dc | chore: lock router5-transition-path versions | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/package.json",
"new_path": "packages/react-router5/package.json",
"diff": "},\n\"dependencies\": {\n\"prop-types\": \"^15.6.0\",\n- \"router5-transition-path\": \"^5.4.0\"\n+ \"router5-transition-path\": \"5.4.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.4.0\"\n+ \"router5-transition-path\": \"5.4.0\"\n},\n\"typings\": \"./index.d.ts\"\n}\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.4.0\",\n+ \"router5-transition-path\": \"5.4.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.4.0\",\n+ \"router5-transition-path\": \"5.4.0\",\n\"xstream\": \"^10.0.0\"\n},\n\"peerDependencies\": {\n"
}
] | TypeScript | MIT License | router5/router5 | chore: lock router5-transition-path versions |
580,249 | 06.10.2018 15:13:06 | -3,600 | 28df464c0873524b0ffc313542265829427a8bea | fix: fix Route type definition | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/index.d.ts",
"new_path": "packages/react-router5/index.d.ts",
"diff": "@@ -76,6 +76,6 @@ declare module 'react-router5' {\n}>\nexport const Route: ComponentClass<{\n- children: (value: T) => React.ReactNode\n+ children: (value: InjectedRouterNode) => React.ReactNode\n}>\n}\n"
}
] | TypeScript | MIT License | router5/router5 | fix: fix Route type definition |
580,249 | 16.10.2018 15:59:22 | -3,600 | 9dbf2a82d57e938017dbaf1fdbb1e9f6b52f7c18 | chore: upgrade route-node | [
{
"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.4.1\",\n+ \"route-node\": \"3.4.2\",\n\"router5-transition-path\": \"5.4.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": "[email protected]:\nversion \"4.2.0\"\nresolved \"https://registry.yarnpkg.com/path-parser/-/path-parser-4.2.0.tgz#2fbb3df2d49659a9a4cac88be7d8d5f4666814fb\"\n+ integrity sha512-MPPZiWTTp2I72VXmGQQfsn2ohrbd9QTbZSLYNS+HXsnQ37VbiLR/szO2R7DHaZA1V1scYxuxgyQerj+6kMTXtA==\ndependencies:\nsearch-params \"2.1.3\"\[email protected]:\n- version \"3.4.1\"\n- resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.4.1.tgz#1b99402fa4d22fb13991a4f818b87e0a6ce19238\"\[email protected]:\n+ version \"3.4.2\"\n+ resolved \"https://registry.yarnpkg.com/route-node/-/route-node-3.4.2.tgz#6481fd5949c34a785bfbb9c3bcdae4d8333bbd46\"\n+ integrity sha512-MDIllr+xwmzSKQh49Ls1g66LIH9JisXh15WXyu4hAYW95mrTSRWr7bqc23hcrjZpehTmSNOb64ZiHBgsHUArog==\ndependencies:\npath-parser \"4.2.0\"\nsearch-params \"2.1.3\"\n@@ -18,7 +20,9 @@ [email protected]:\[email protected]:\nversion \"2.1.3\"\nresolved \"https://registry.yarnpkg.com/search-params/-/search-params-2.1.3.tgz#90b98964eaf3d0edef0f73e6e8307d1480020413\"\n+ integrity sha512-hHxU9ZGWpZ/lrFBIHndSnQae2in7ra+m+tBSoeAahSWDDgOgpZqs4bfaTZpljgNgAgTbjiQoJtZW6FKSsfEcDA==\[email protected]:\nversion \"1.2.0\"\nresolved \"https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804\"\n+ integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==\n"
}
] | TypeScript | MIT License | router5/router5 | chore: upgrade route-node |
580,249 | 23.10.2018 08:32:07 | -3,600 | 1e0a07dcea43d5eab23cab2e022cdbccee78943c | fix: properly handle default params when building paths and states | [
{
"change_type": "MODIFY",
"old_path": "packages/router5/modules/core/utils.js",
"new_path": "packages/router5/modules/core/utils.js",
"diff": "@@ -94,14 +94,19 @@ export default function withUtils(router) {\nreturn params.path\n}\n+ const paramsWithDefault = {\n+ ...router.config.defaultParams[route],\n+ ...params\n+ }\n+\nconst {\ntrailingSlashMode,\nqueryParamsMode,\nqueryParams\n} = router.getOptions()\nconst encodedParams = router.config.encoders[route]\n- ? router.config.encoders[route](params)\n- : params\n+ ? router.config.encoders[route](paramsWithDefault)\n+ : paramsWithDefault\nreturn router.rootNode.buildPath(route, encodedParams, {\ntrailingSlashMode,\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5/modules/create-router.js",
"new_path": "packages/router5/modules/create-router.js",
"diff": "@@ -143,7 +143,10 @@ function createRouter(routes, opts = {}, deps = {}) {\nconst setProp = (key, value) =>\nObject.defineProperty(state, key, { value, enumerable: true })\nsetProp('name', name)\n- setProp('params', params)\n+ setProp('params', {\n+ ...router.config.defaultParams[name],\n+ ...params\n+ })\nsetProp('path', path)\nif (meta) {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5/test/core/utils.js",
"new_path": "packages/router5/test/core/utils.js",
"diff": "@@ -144,4 +144,15 @@ describe('core/utils', () => {\n})\n})\n})\n+\n+ it('should build path with default parameters', () => {\n+ const router = createRouter({\n+ name: 'withDefaults',\n+ defaultParams: { id: '1' },\n+ path: '/with-defaults/:id'\n+ })\n+\n+ expect(router.buildPath('withDefaults')).to.equal('/with-defaults/1')\n+ expect(router.makeState('withDefaults').params).to.eql({ id: '1' })\n+ })\n})\n"
}
] | TypeScript | MIT License | router5/router5 | fix: properly handle default params when building paths and states |
580,249 | 29.11.2018 14:42:29 | 0 | 3e1071c5ae3f35b46103d0b9bf1bf861d899bec3 | chore: add router5-helpers types | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"clean:deps\": \"rimraf packages/*/yarn.lock\",\n\"reset\": \"npm run clean && npm run clean:deps && npm run bootstrap\",\n\"build\": \"node scripts/build && npm run build:router5\",\n- \"build:router5\": \"rollup -c rollup.config.js\",\n- \"postbuild\": \"prettier --write 'packages/*/types/**/*.ts'\",\n+ \"build:pkg\": \"rollup -c rollup.config.js && prettier --write 'packages/*/types/**/*.ts'\",\n\"test\": \"mocha --compilers js:babel-core/register --require test-helper.js --recursive 'packages/*/test/**/*.js'\",\n\"test:router\": \"jest --config packages/router5/jest.config.js\",\n\"lint\": \"eslint packages/*/modules\",\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-helpers/modules/index.ts",
"new_path": "packages/router5-helpers/modules/index.ts",
"diff": "const dotOrEnd = '(\\\\..+$|$)'\nconst dotOrStart = '(^.+\\\\.|^)'\n-interface State {\n+export interface State {\nname: string\nparams?: {\n[key: string]: any\n@@ -40,7 +40,7 @@ const testRouteWithSegment = (start, end) => {\n}\n}\n-interface SegmentTestFunction {\n+export interface SegmentTestFunction {\n(route: string | State, segment: string): boolean\n(route: string | State): (segment: string) => boolean\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-helpers/types/index.d.ts",
"diff": "+export interface State {\n+ name: string\n+ params?: {\n+ [key: string]: any\n+ }\n+ [key: string]: any\n+}\n+export interface SegmentTestFunction {\n+ (route: string | State, segment: string): boolean\n+ (route: string | State): (segment: string) => boolean\n+}\n+export declare const startsWithSegment: SegmentTestFunction\n+export declare const endsWithSegment: SegmentTestFunction\n+export declare const includesSegment: SegmentTestFunction\n"
},
{
"change_type": "MODIFY",
"old_path": "rollup.config.js",
"new_path": "rollup.config.js",
"diff": "@@ -39,7 +39,6 @@ const router5Dependencies = Object.keys(require('./packages/router5/package.json\nconst config = [\nmakeConfig({\npackageName: 'router5',\n- declaration: true,\nfile: 'dist/router5.min.js',\nformat: 'umd',\ncompress: true\n@@ -51,6 +50,7 @@ const config = [\n}),\nmakeConfig({\npackageName: 'router5',\n+ declaration: true,\nformat: 'cjs',\nexternal: router5Dependencies\n}),\n@@ -61,6 +61,7 @@ const config = [\n}),\nmakeConfig({\npackageName: 'router5-Helpers',\n+ declaration: true,\nformat: 'cjs'\n}),\nmakeConfig({\n"
}
] | TypeScript | MIT License | router5/router5 | chore: add router5-helpers types |
580,249 | 29.11.2018 15:04:19 | 0 | b53a0071092155e4361de152f577f2075dd8add5 | refactor: move router5-transition-path to TS, Jest and rollup | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"clean:deps\": \"rimraf packages/*/yarn.lock\",\n\"reset\": \"npm run clean && npm run clean:deps && npm run bootstrap\",\n\"build\": \"rollup -c rollup.config.js && prettier --write 'packages/*/types/**/*.ts'\",\n- \"test\": \"lerna run test\",\n- \"test:router\": \"jest --config packages/router5/jest.config.js\",\n+ \"test\": \"lerna run test --stream\",\n\"lint\": \"eslint packages/*/modules\",\n\"lint:check-conflicts\": \"eslint --print-config .eslintrc | eslint-config-prettier-check\",\n\"format\": \"prettier 'packages/**/*.{js,ts}'\",\n"
},
{
"change_type": "DELETE",
"old_path": "packages/router5-transition-path/index.d.ts",
"new_path": null,
"diff": "-declare module 'router5-transition-path' {\n- import { State } from 'router5'\n-\n- export function nameToIDs(name: string): string[]\n-\n- export interface TransitionPath {\n- intersection: string\n- toDeactivate: string[]\n- toActivate: string[]\n- }\n-\n- export function shouldUpdateNode(\n- nodeName: string\n- ): (toState: State, fromState?: State) => Boolean\n-\n- export default function transitionPath(\n- toState: State,\n- fromState?: State\n- ): TransitionPath\n-}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-transition-path/jest.config.js",
"diff": "+module.exports = {\n+ transform: {\n+ '^.+\\\\.tsx?$': 'ts-jest'\n+ },\n+ moduleFileExtensions: ['ts', 'js'],\n+ preset: 'ts-jest',\n+ testEnvironment: 'node',\n+ globals: {\n+ 'ts-jest': {\n+ tsConfig: '<rootDir>/tsconfig.test.json'\n+ }\n+ }\n+}\n"
},
{
"change_type": "RENAME",
"old_path": "packages/router5-transition-path/test/main.js",
"new_path": "packages/router5-transition-path/modules/__tests__/index.ts",
"diff": "-import transitionPath, { shouldUpdateNode } from '../modules'\n-import { expect } from 'chai'\n-import tt from 'typescript-definition-tester'\n+import transitionPath, { shouldUpdateNode } from '../'\n-describe('router5-transition-path', function() {\n- it('should return a transition path with from null state', function() {\n+describe('router5-transition-path', () => {\n+ it('should return a transition path with from null state', () => {\nexpect(\ntransitionPath({ name: 'a.b.c', params: {}, meta: {} }, null)\n- ).to.eql({\n+ ).toEqual({\nintersection: '',\ntoActivate: ['a', 'a.b', 'a.b.c'],\ntoDeactivate: []\n})\n})\n- it('should return transition path between two states', function() {\n+ it('should return transition path between two states', () => {\nconst meta = {\nparams: {\na: {},\n@@ -28,14 +26,14 @@ describe('router5-transition-path', function() {\n{ name: 'a.b.c.d', params: {}, meta },\n{ name: 'a.b.e.f', params: {}, meta }\n)\n- ).to.eql({\n+ ).toEqual({\nintersection: 'a.b',\ntoActivate: ['a.b.c', 'a.b.c.d'],\ntoDeactivate: ['a.b.e.f', 'a.b.e']\n})\n})\n- it('should return transition path two states with same name but different params', function() {\n+ it('should return transition path two states with same name but different params', () => {\nconst meta = {\nparams: {\na: {},\n@@ -50,21 +48,21 @@ describe('router5-transition-path', function() {\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).intersection\n- ).to.equal('a')\n+ ).toBe('a')\nexpect(\ntransitionPath(\n{ name: 'a.b.c.d', params: { p1: 1, p2: 0, p3: 3 }, meta },\n{ name: 'a.b.c.d', params: { p1: 1, p2: 2, p3: 3 }, meta }\n).intersection\n- ).to.equal('a.b')\n+ ).toBe('a.b')\nexpect(\ntransitionPath(\n{ name: 'a.b.c.d', params: { p1: 1, p2: 2, p3: 0 }, meta },\n{ name: 'a.b.c.d', params: { p1: 1, p2: 2, p3: 3 }, meta }\n).intersection\n- ).to.equal('a.b.c')\n+ ).toBe('a.b.c')\n})\ndescribe('shouldUpdateNode', () => {\n@@ -84,7 +82,7 @@ describe('router5-transition-path', function() {\n{ name: 'a.b.c.d', params: { p1: 1, p2: 2, p3: 3 }, meta }\n)\n- expect(shouldUpdate).to.equal(true)\n+ expect(shouldUpdate).toBe(true)\n})\nit('should tell node above intersection to not update', () => {\n@@ -93,7 +91,7 @@ describe('router5-transition-path', function() {\n{ name: 'a.b.c.d', params: { p1: 1, p2: 2, p3: 3 }, meta }\n)\n- expect(shouldUpdate).to.equal(false)\n+ expect(shouldUpdate).toBe(false)\n})\nit('should tell node below intersection to update if not deactivated', () => {\n@@ -108,24 +106,9 @@ describe('router5-transition-path', function() {\nmeta\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-\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+ expect(shouldUpdateNode('a.b')(toState, fromState)).toBe(true)\n+ expect(shouldUpdateNode('a.b.c')(toState, fromState)).toBe(true)\n+ expect(shouldUpdateNode('a.b.c.e')(toState, fromState)).toBe(false)\n})\n})\n})\n"
},
{
"change_type": "RENAME",
"old_path": "packages/router5-transition-path/modules/index.js",
"new_path": "packages/router5-transition-path/modules/index.ts",
"diff": ""
},
{
"change_type": "RENAME",
"old_path": "packages/router5-transition-path/modules/shouldUpdateNode.js",
"new_path": "packages/router5-transition-path/modules/shouldUpdateNode.ts",
"diff": "import transitionPath from './transitionPath'\n+import { State } from './transitionPath'\n-export default function shouldUpdateNode(nodeName) {\n- return (toState, fromSate) => {\n+export default function shouldUpdateNode(nodeName: string) {\n+ return (toState: State, fromSate: State): boolean => {\nconst {\nintersection,\ntoActivate,\n@@ -39,7 +40,6 @@ export default function shouldUpdateNode(nodeName) {\n}\n}\n- // Should never be reached\nreturn false\n}\n}\n"
},
{
"change_type": "RENAME",
"old_path": "packages/router5-transition-path/modules/transitionPath.js",
"new_path": "packages/router5-transition-path/modules/transitionPath.ts",
"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+export interface SegementParams {\n+ [key: string]: string\n}\n-function exists(val) {\n- return val !== undefined && val !== null\n+export interface State {\n+ name: string\n+ params?: {\n+ [key: string]: any\n+ }\n+ meta?: {\n+ options?: {\n+ [key: string]: boolean\n+ }\n+ params?: {\n+ [key: string]: SegementParams\n+ }\n+ }\n+ [key: string]: any\n}\n-function hasMetaParams(state) {\n- return state && state.meta && state.meta.params\n+export interface TransitionPath {\n+ intersection: string\n+ toDeactivate: string[]\n+ toActivate: string[]\n}\n-function extractSegmentParams(name, state) {\n+export const nameToIDs = (name: string): string[] =>\n+ name\n+ .split('.')\n+ .reduce(\n+ (ids: string[], name: string) =>\n+ ids.concat(\n+ ids.length ? ids[ids.length - 1] + '.' + name : name\n+ ),\n+ []\n+ )\n+\n+const exists = val => val !== undefined && val !== null\n+\n+const hasMetaParams = state => state && state.meta && state.meta.params\n+\n+const extractSegmentParams = (name: string, state: State): SegementParams => {\nif (!hasMetaParams(state) || !exists(state.meta.params[name])) return {}\nreturn Object.keys(state.meta.params[name]).reduce((params, p) => {\n@@ -21,7 +48,10 @@ function extractSegmentParams(name, state) {\n}, {})\n}\n-export default function transitionPath(toState, fromState) {\n+export default function transitionPath(\n+ toState: State,\n+ fromState: State | null\n+): TransitionPath {\nconst fromStateIds = fromState ? nameToIDs(fromState.name) : []\nconst toStateIds = nameToIDs(toState.name)\nconst maxI = Math.min(fromStateIds.length, toStateIds.length)\n@@ -37,8 +67,12 @@ export default function transitionPath(toState, fromState) {\nconst leftParams = extractSegmentParams(left, toState)\nconst rightParams = extractSegmentParams(right, fromState)\n- if (leftParams.length !== rightParams.length) return i\n- if (leftParams.length === 0) continue\n+ if (\n+ Object.keys(leftParams).length !==\n+ Object.keys(rightParams).length\n+ )\n+ return i\n+ if (Object.keys(leftParams).length === 0) continue\nconst different = Object.keys(leftParams).some(\np => rightParams[p] !== leftParams[p]\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-transition-path/package.json",
"new_path": "packages/router5-transition-path/package.json",
"diff": "\"name\": \"router5-transition-path\",\n\"version\": \"5.4.0\",\n\"description\": \"Router5 transition path helper function\",\n- \"main\": \"dist/commonjs/index.js\",\n- \"jsnext:main\": \"dist/es/index.js\",\n- \"module\": \"dist/es/index.js\",\n+ \"main\": \"dist/index.js\",\n+ \"jsnext:main\": \"dist/index.es.js\",\n+ \"module\": \"dist/index.es.js\",\n+ \"sideEffects\": \"false\",\n\"repository\": {\n\"type\": \"git\",\n\"url\": \"git+https://github.com/router5/router5.git\"\n\"peerDependencies\": {\n\"router5\": \"^5.0.0 || ^6.0.0\"\n},\n- \"devDependencies\": {\n- \"babel-plugin-add-module-exports\": \"~0.2.1\"\n+ \"typings\": \"./types/index.d.ts\",\n+ \"scripts\": {\n+ \"test\": \"jest\"\n}\n}\n"
},
{
"change_type": "DELETE",
"old_path": "packages/router5-transition-path/test/typescript/index.ts",
"new_path": null,
"diff": "-/// <reference path=\"../../../router5/index.d.ts\" />\n-/// <reference path=\"../../index.d.ts\" />\n-\n-import transitionPath, {\n- nameToIDs,\n- TransitionPath,\n- shouldUpdateNode\n-} from 'router5-transition-path'\n-\n-const _ids: string[] = nameToIDs('a.b.c')\n-\n-let tp: TransitionPath\n-tp = transitionPath(\n- { name: 'a.b.c', params: {}, path: '/a/b/c' },\n- { name: 'a.b.d', params: {}, path: '/a/b/d' }\n-)\n-tp = 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"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-transition-path/tsconfig.build.json",
"diff": "+{\n+ \"extends\": \"./tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"declaration\": true,\n+ \"declarationDir\": \"./types\",\n+ \"outDir\": \"./dist\"\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-transition-path/tsconfig.json",
"diff": "+{\n+ \"extends\": \"../../tsconfig.base.json\",\n+ \"exclude\": [\"node_modules\", \"modules/__tests__\"],\n+ \"include\": [\"modules\"]\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-transition-path/tsconfig.test.json",
"diff": "+{\n+ \"extends\": \"./tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"allowJs\": true\n+ },\n+ \"include\": [\"./modules/__tests__/**/*.ts\"]\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-transition-path/types/index.d.ts",
"diff": "+import transitionPath, { nameToIDs } from './transitionPath'\n+import shouldUpdateNode from './shouldUpdateNode'\n+export { shouldUpdateNode, nameToIDs }\n+export default transitionPath\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-transition-path/types/shouldUpdateNode.d.ts",
"diff": "+import { State } from './transitionPath'\n+export default function shouldUpdateNode(\n+ nodeName: string\n+): (toState: State, fromSate: State) => boolean\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-transition-path/types/transitionPath.d.ts",
"diff": "+export interface SegementParams {\n+ [key: string]: string\n+}\n+export interface State {\n+ name: string\n+ params?: {\n+ [key: string]: any\n+ }\n+ meta?: {\n+ options?: {\n+ [key: string]: boolean\n+ }\n+ params?: {\n+ [key: string]: SegementParams\n+ }\n+ }\n+ [key: string]: any\n+}\n+export interface TransitionPath {\n+ intersection: string\n+ toDeactivate: string[]\n+ toActivate: string[]\n+}\n+export declare const nameToIDs: (name: string) => string[]\n+export default function transitionPath(\n+ toState: State,\n+ fromState: State | null\n+): TransitionPath\n"
},
{
"change_type": "MODIFY",
"old_path": "rollup.config.js",
"new_path": "rollup.config.js",
"diff": "@@ -67,6 +67,15 @@ const config = [\nmakeConfig({\npackageName: 'router5-Helpers',\nformat: 'es'\n+ }),\n+ makeConfig({\n+ packageName: 'router5-transition-path',\n+ declaration: true,\n+ format: 'cjs'\n+ }),\n+ makeConfig({\n+ packageName: 'router5-transition-path',\n+ format: 'es'\n})\n]\n"
}
] | TypeScript | MIT License | router5/router5 | refactor: move router5-transition-path to TS, Jest and rollup |
580,249 | 29.11.2018 16:49:00 | 0 | bea5765e2d3b09f742d74dd018c17ee7c32d5933 | chore: add logger plugin package | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-logger/README.md",
"diff": "+# Router5 browser plugin\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+```js\n+import browserPlugin from 'router5-plugin-logger';\n+\n+const router = createRouter()\n+ .usePlugin(browserPlugin({\n+ useHash: true\n+ }))\n+ .start();\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"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-logger/modules/index.ts",
"diff": "+import { PluginFactory } from 'router5'\n+\n+const noop = () => {}\n+\n+const loggerPlugin: PluginFactory = () => {\n+ let startGroup, endGroup\n+\n+ if (console.groupCollapsed) {\n+ startGroup = label => console.groupCollapsed(label)\n+ endGroup = () => console.groupEnd()\n+ } else if (console.group) {\n+ startGroup = label => console.group(label)\n+ endGroup = () => console.groupEnd()\n+ } else {\n+ startGroup = noop\n+ endGroup = noop\n+ }\n+\n+ console.info('Router started')\n+\n+ return {\n+ onStop() {\n+ console.info('Router stopped')\n+ },\n+ onTransitionStart(toState, fromState) {\n+ endGroup()\n+ startGroup('Router transition')\n+ console.log('Transition started from state')\n+ console.log(fromState)\n+ console.log('To state')\n+ console.log(toState)\n+ },\n+ onTransitionCancel() {\n+ console.warn('Transition cancelled')\n+ },\n+ onTransitionError(toState, fromState, err) {\n+ console.warn('Transition error with code ' + err.code)\n+ endGroup()\n+ },\n+ onTransitionSuccess() {\n+ console.log('Transition success')\n+ endGroup()\n+ }\n+ }\n+}\n+\n+loggerPlugin.pluginName = 'LOGGER_PLUGIN'\n+\n+export default loggerPlugin\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-logger/package.json",
"diff": "+{\n+ \"name\": \"router5-plugin-logger\",\n+ \"version\": \"0.0.0\",\n+ \"description\": \"Router5 browser plugin\",\n+ \"main\": \"dist/index.js\",\n+ \"jsnext:main\": \"dist/index.es.js\",\n+ \"module\": \"dist/index.es.js\",\n+ \"sideEffects\": false,\n+ \"repository\": {\n+ \"type\": \"git\",\n+ \"url\": \"git+https://github.com/router5/router5.git\"\n+ },\n+ \"keywords\": [\n+ \"router5\",\n+ \"helpers\"\n+ ],\n+ \"author\": \"Thomas Roch <[email protected]>\",\n+ \"license\": \"MIT\",\n+ \"bugs\": {\n+ \"url\": \"https://github.com/router5/router5/issues\"\n+ },\n+ \"devDependencies\": {\n+ \"router5\": \"^6.6.2\"\n+ },\n+ \"peerDependencies\": {\n+ \"router5\": \"^5.0.0 || ^6.0.0\"\n+ },\n+ \"homepage\": \"https://github.com/router5/router5/tree/master/packages/router5-plugin-logger\"\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-logger/tsconfig.build.json",
"diff": "+{\n+ \"extends\": \"./tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"declaration\": true,\n+ \"declarationDir\": \"./types\",\n+ \"outDir\": \"./dist\"\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-logger/tsconfig.json",
"diff": "+{\n+ \"extends\": \"../../tsconfig.base.json\",\n+ \"exclude\": [\"node_modules\", \"modules/__tests__\"],\n+ \"include\": [\"modules\"]\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-logger/types/index.d.ts",
"diff": "+import { PluginFactory } from 'router5'\n+declare const loggerPlugin: PluginFactory\n+export default loggerPlugin\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5/modules/types/router.ts",
"new_path": "packages/router5/modules/types/router.ts",
"diff": "@@ -241,7 +241,7 @@ export type MiddlewareFactory = (\nexport interface PluginFactory {\npluginName: string\n- (router: Router, dependencies?: Dependencies): Plugin\n+ (router?: Router, dependencies?: Dependencies): Plugin\n}\nexport interface SubscribeState {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5/types/types/router.d.ts",
"new_path": "packages/router5/types/types/router.d.ts",
"diff": "@@ -232,7 +232,7 @@ export declare type MiddlewareFactory = (\n) => Middleware\nexport interface PluginFactory {\npluginName: string\n- (router: Router, dependencies?: Dependencies): Plugin\n+ (router?: Router, dependencies?: Dependencies): Plugin\n}\nexport interface SubscribeState {\nroute: State\n"
},
{
"change_type": "MODIFY",
"old_path": "rollup.config.js",
"new_path": "rollup.config.js",
"diff": "@@ -60,12 +60,12 @@ const config = [\nexternal: router5Dependencies\n}),\nmakeConfig({\n- packageName: 'router5-Helpers',\n+ packageName: 'router5-helpers',\ndeclaration: true,\nformat: 'cjs'\n}),\nmakeConfig({\n- packageName: 'router5-Helpers',\n+ packageName: 'router5-helpers',\nformat: 'es'\n}),\nmakeConfig({\n@@ -85,6 +85,15 @@ const config = [\nmakeConfig({\npackageName: 'router5-plugin-browser',\nformat: 'es'\n+ }),\n+ makeConfig({\n+ packageName: 'router5-plugin-logger',\n+ declaration: true,\n+ format: 'cjs'\n+ }),\n+ makeConfig({\n+ packageName: 'router5-plugin-logger',\n+ format: 'es'\n})\n]\n"
}
] | TypeScript | MIT License | router5/router5 | chore: add logger plugin package |
580,249 | 29.11.2018 17:29:56 | 0 | 8b959e587b852b216e092acb45850e81537584a6 | chore: add listeners plugin package | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-listeners/README.md",
"diff": "+# Router5 browser plugin\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+```js\n+import browserPlugin from 'router5-plugin-listeners';\n+\n+const router = createRouter()\n+ .usePlugin(browserPlugin({\n+ useHash: true\n+ }))\n+ .start();\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"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-listeners/jest.config.js",
"diff": "+module.exports = {\n+ transform: {\n+ '^.+\\\\.tsx?$': 'ts-jest'\n+ },\n+ moduleFileExtensions: ['ts', 'js'],\n+ preset: 'ts-jest',\n+ testEnvironment: 'node',\n+ globals: {\n+ 'ts-jest': {\n+ tsConfig: '<rootDir>/tsconfig.test.json'\n+ }\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-listeners/modules/__tests__/index.ts",
"diff": "+import { createRouter } from 'router5'\n+import listenersPlugin from '../'\n+\n+describe('listenersPlugin', () => {\n+ let router\n+ beforeAll(() => {\n+ router = createRouter([\n+ {\n+ name: 'home',\n+ path: '/home'\n+ },\n+ {\n+ name: 'users',\n+ path: '/users',\n+ children: [\n+ {\n+ name: 'view',\n+ path: '/view/:id'\n+ },\n+ {\n+ name: 'list',\n+ path: '/list'\n+ }\n+ ]\n+ },\n+ {\n+ name: 'orders',\n+ path: '/orders',\n+ children: [\n+ { name: 'view', path: '/view/:id' },\n+ { name: 'pending', path: '/pending' },\n+ { name: 'completed', path: '/completed' }\n+ ]\n+ }\n+ ])\n+ router.usePlugin(listenersPlugin())\n+ })\n+\n+ afterAll(() => {\n+ router.stop()\n+ })\n+\n+ it('should be registered', () => {\n+ expect(router.hasPlugin('listenersPlugin')).toBe(true)\n+ })\n+\n+ it('should call root node listener on first transition', function(done) {\n+ router.stop()\n+ router.setOption('defaultRoute', 'home')\n+ const nodeListener = jest.fn()\n+ router.addNodeListener('', nodeListener)\n+\n+ router.start(function(err, state) {\n+ expect(state).toEqual({\n+ meta: {\n+ id: 1,\n+ options: { replace: true },\n+ params: { home: {} }\n+ },\n+ name: 'home',\n+ path: '/home',\n+ params: {}\n+ })\n+ expect(nodeListener).toHaveBeenCalled()\n+ done()\n+ })\n+ })\n+\n+ it('should invoke listeners on navigation', function(done) {\n+ router.navigate('home', {}, {}, () => {\n+ const previousState = router.getState()\n+ const listener = jest.fn()\n+ router.addListener(listener)\n+\n+ router.navigate('orders.pending', {}, {}, () => {\n+ expect(listener).toHaveBeenLastCalledWith(\n+ router.getState(),\n+ previousState\n+ )\n+ router.removeListener(listener)\n+ done()\n+ })\n+ })\n+ })\n+\n+ it('should not invoke listeners if trying to navigate to the current route', function(done) {\n+ router.navigate('orders.view', { id: 123 }, {}, () => {\n+ const listener = jest.fn()\n+ router.addListener(listener)\n+\n+ router.navigate('orders.view', { id: 123 }, {}, () => {\n+ expect(listener).not.toHaveBeenCalled()\n+ done()\n+ })\n+ })\n+ })\n+\n+ it('should invoke node listeners', function(done) {\n+ router.navigate('users.list', {}, {}, () => {\n+ const nodeListener = jest.fn()\n+ router.addNodeListener('users', nodeListener)\n+ router.navigate('users.view', { id: 1 }, {}, () => {\n+ expect(nodeListener).toHaveBeenCalled()\n+ router.navigate('users.view', { id: 1 }, {}, () => {\n+ router.navigate('users.view', { id: 2 }, {}, function(\n+ err,\n+ state\n+ ) {\n+ expect(nodeListener).toHaveBeenCalledTimes(2)\n+ router.removeNodeListener('users', nodeListener)\n+ done()\n+ })\n+ })\n+ })\n+ })\n+ })\n+\n+ it('should invoke node listeners on root', function(done) {\n+ router.navigate('orders', {}, {}, () => {\n+ const nodeListener = jest.fn()\n+ router.addNodeListener('', nodeListener)\n+ router.navigate('users', {}, {}, () => {\n+ expect(nodeListener).toHaveBeenCalled()\n+ router.removeNodeListener('', nodeListener)\n+ done()\n+ })\n+ })\n+ })\n+\n+ it('should invoke route listeners', function(done) {\n+ router.navigate('users.list', {}, {}, () => {\n+ const nodeListener = jest.fn()\n+ router.addRouteListener('users', nodeListener)\n+ router.navigate('users', {}, {}, () => {\n+ expect(nodeListener).toHaveBeenCalled()\n+ router.removeRouteListener('users', nodeListener)\n+ done()\n+ })\n+ })\n+ })\n+\n+ it('should automatically remove node listeners if autoCleanUp', function(done) {\n+ router.navigate('orders.completed', {}, {}, function(err, state) {\n+ router.addNodeListener('orders', () => {})\n+ router.navigate('users', {}, {}, function(err, state) {\n+ setTimeout(() => {\n+ expect(router.getListeners()['^orders']).toEqual([])\n+ done()\n+ })\n+ })\n+ })\n+ })\n+\n+ it('should warn if trying to register a listener on an unknown route', () => {\n+ jest.spyOn(console, 'warn').mockImplementation(() => {})\n+ router.addRouteListener('fake.route', () => {})\n+ expect(console.warn).toHaveBeenCalled()\n+ jest.resetAllMocks()\n+ })\n+\n+ it('should not invoke listeners removed by previously called listeners', function(done) {\n+ router.navigate('home', {}, {}, () => {\n+ const listener2 = jest.fn()\n+ const listener1 = jest.fn(() => router.removeListener(listener2))\n+ router.addListener(listener1)\n+ router.addListener(listener2)\n+\n+ router.navigate('orders.pending', {}, {}, () => {\n+ expect(listener2).not.toHaveBeenCalled()\n+ router.removeListener(listener1)\n+ done()\n+ })\n+ })\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-listeners/modules/index.ts",
"diff": "+import { PluginFactory, Router } from 'router5'\n+import transitionPath from 'router5-transition-path'\n+\n+export interface ListenersPluginOptions {\n+ autoCleanUp?: boolean\n+}\n+\n+const defaultOptions: ListenersPluginOptions = {\n+ autoCleanUp: true\n+}\n+\n+const listenersPluginFactory: PluginFactory = (\n+ options: ListenersPluginOptions = defaultOptions\n+) => {\n+ function listenersPlugin(router: Router) {\n+ let listeners = {}\n+\n+ function removeListener(name, cb?) {\n+ if (cb) {\n+ if (listeners[name])\n+ listeners[name] = listeners[name].filter(\n+ callback => callback !== cb\n+ )\n+ } else {\n+ listeners[name] = []\n+ }\n+ return router\n+ }\n+\n+ function addListener(name, cb, replace?) {\n+ const normalizedName = name.replace(/^(\\*|\\^|=)/, '')\n+\n+ if (normalizedName && !/^\\$/.test(name)) {\n+ const segments = router.rootNode.getSegmentsByName(\n+ normalizedName\n+ )\n+ if (!segments)\n+ console.warn(\n+ `No route found for ${normalizedName}, listener might never be called!`\n+ )\n+ }\n+\n+ if (!listeners[name]) listeners[name] = []\n+ listeners[name] = (replace ? [] : listeners[name]).concat(cb)\n+\n+ return router\n+ }\n+\n+ router.getListeners = () => listeners\n+\n+ router.addListener = cb => addListener('*', cb)\n+ router.removeListener = cb => removeListener('*', cb)\n+\n+ router.addNodeListener = (name, cb) => addListener('^' + name, cb, true)\n+ router.removeNodeListener = (name, cb) => removeListener('^' + name, cb)\n+\n+ router.addRouteListener = (name, cb) => addListener('=' + name, cb)\n+ router.removeRouteListener = (name, cb) =>\n+ removeListener('=' + name, cb)\n+\n+ function invokeListeners(name, toState, fromState) {\n+ ;(listeners[name] || []).forEach(cb => {\n+ if (listeners[name].indexOf(cb) !== -1) {\n+ cb(toState, fromState)\n+ }\n+ })\n+ }\n+\n+ function onTransitionSuccess(toState, fromState, opts) {\n+ const { intersection, toDeactivate } = transitionPath(\n+ toState,\n+ fromState\n+ )\n+ const intersectionNode = opts.reload ? '' : intersection\n+ const { name } = toState\n+\n+ if (options.autoCleanUp) {\n+ toDeactivate.forEach(name => removeListener('^' + name))\n+ }\n+\n+ invokeListeners('^' + intersectionNode, toState, fromState)\n+ invokeListeners('=' + name, toState, fromState)\n+ invokeListeners('*', toState, fromState)\n+ }\n+\n+ return { onTransitionSuccess }\n+ }\n+\n+ listenersPlugin.pluginName = 'LISTENERS_PLUGIN'\n+\n+ return listenersPlugin\n+}\n+\n+export default listenersPluginFactory\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-listeners/package.json",
"diff": "+{\n+ \"name\": \"router5-plugin-listeners\",\n+ \"version\": \"0.0.0\",\n+ \"description\": \"Router5 browser plugin\",\n+ \"main\": \"dist/index.js\",\n+ \"jsnext:main\": \"dist/index.es.js\",\n+ \"module\": \"dist/index.es.js\",\n+ \"sideEffects\": false,\n+ \"repository\": {\n+ \"type\": \"git\",\n+ \"url\": \"git+https://github.com/router5/router5.git\"\n+ },\n+ \"keywords\": [\"router5\", \"helpers\"],\n+ \"author\": \"Thomas Roch <[email protected]>\",\n+ \"license\": \"MIT\",\n+ \"bugs\": {\n+ \"url\": \"https://github.com/router5/router5/issues\"\n+ },\n+ \"devDependencies\": {\n+ \"router5\": \"^6.6.2\"\n+ },\n+ \"dependencies\": {\n+ \"router5-transition-path\": \"^5.4.0\"\n+ },\n+ \"peerDependencies\": {\n+ \"router5\": \"^5.0.0 || ^6.0.0\"\n+ },\n+ \"homepage\":\n+ \"https://github.com/router5/router5/tree/master/packages/router5-plugin-listeners\",\n+ \"typings\": \"./types/index.d.ts\",\n+ \"scripts\": {\n+ \"test\": \"jest\"\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-listeners/tsconfig.build.json",
"diff": "+{\n+ \"extends\": \"./tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"declaration\": true,\n+ \"declarationDir\": \"./types\",\n+ \"outDir\": \"./dist\"\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-listeners/tsconfig.json",
"diff": "+{\n+ \"extends\": \"../../tsconfig.base.json\",\n+ \"exclude\": [\"node_modules\", \"modules/__tests__\"],\n+ \"include\": [\"modules\"]\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-listeners/tsconfig.test.json",
"diff": "+{\n+ \"extends\": \"./tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"allowJs\": true\n+ },\n+ \"include\": [\"./modules/__tests__/**/*.ts\"]\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-listeners/types/index.d.ts",
"diff": "+import { PluginFactory } from 'router5'\n+export interface ListenersPluginOptions {\n+ autoCleanUp?: boolean\n+}\n+declare const listenersPluginFactory: PluginFactory\n+export default listenersPluginFactory\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-logger/package.json",
"new_path": "packages/router5-plugin-logger/package.json",
"diff": "\"peerDependencies\": {\n\"router5\": \"^5.0.0 || ^6.0.0\"\n},\n- \"homepage\": \"https://github.com/router5/router5/tree/master/packages/router5-plugin-logger\"\n+ \"homepage\": \"https://github.com/router5/router5/tree/master/packages/router5-plugin-logger\",\n+ \"typings\": \"./types/index.d.ts\"\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "rollup.config.js",
"new_path": "rollup.config.js",
"diff": "@@ -8,8 +8,16 @@ const formatSuffix = {\ncjs: ''\n}\n-const makeConfig = ({ packageName, declaration = false, format, external, compress = false, file }) => {\n- const outputFile = file || `packages/${packageName}/dist/index${formatSuffix[format]}.js`\n+const makeConfig = ({\n+ packageName,\n+ declaration = false,\n+ format,\n+ external,\n+ compress = false,\n+ file\n+}) => {\n+ const outputFile =\n+ file || `packages/${packageName}/dist/index${formatSuffix[format]}.js`\nconst plugins = [\nnodeResolve({ jsnext: true, module: true }),\ncommon({ include: `packages/${packageName}/node_modules/**` }),\n@@ -29,13 +37,17 @@ const makeConfig = ({ packageName, declaration = false, format, external, compre\nname: packageName,\nformat\n},\n- external,\n+ external:\n+ format === 'es' || format === 'cjs'\n+ ? Object.keys(\n+ require(`./packages/${packageName}/package.json`)\n+ .dependencies || {}\n+ )\n+ : [],\nplugins\n}\n}\n-const router5Dependencies = Object.keys(require('./packages/router5/package.json').dependencies)\n-\nconst config = [\nmakeConfig({\npackageName: 'router5',\n@@ -51,13 +63,11 @@ const config = [\nmakeConfig({\npackageName: 'router5',\ndeclaration: true,\n- format: 'cjs',\n- external: router5Dependencies\n+ format: 'cjs'\n}),\nmakeConfig({\npackageName: 'router5',\n- format: 'es',\n- external: router5Dependencies\n+ format: 'es'\n}),\nmakeConfig({\npackageName: 'router5-helpers',\n@@ -94,6 +104,15 @@ const config = [\nmakeConfig({\npackageName: 'router5-plugin-logger',\nformat: 'es'\n+ }),\n+ makeConfig({\n+ packageName: 'router5-plugin-listeners',\n+ declaration: true,\n+ format: 'cjs'\n+ }),\n+ makeConfig({\n+ packageName: 'router5-plugin-listeners',\n+ format: 'es'\n})\n]\n"
}
] | TypeScript | MIT License | router5/router5 | chore: add listeners plugin package |
580,249 | 29.11.2018 17:40:48 | 0 | f00aa3ce587d97347a08dbb35f0ca7b1c734d7eb | chore: add persistent params plugin package | [
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-listeners/modules/index.ts",
"new_path": "packages/router5-plugin-listeners/modules/index.ts",
"diff": "@@ -9,10 +9,10 @@ const defaultOptions: ListenersPluginOptions = {\nautoCleanUp: true\n}\n-const listenersPluginFactory: PluginFactory = (\n+const listenersPluginFactory = (\noptions: ListenersPluginOptions = defaultOptions\n) => {\n- function listenersPlugin(router: Router) {\n+ function listenersPlugin(router: Router): PluginFactory {\nlet listeners = {}\nfunction removeListener(name, cb?) {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-listeners/types/index.d.ts",
"new_path": "packages/router5-plugin-listeners/types/index.d.ts",
"diff": "-import { PluginFactory } from 'router5'\nexport interface ListenersPluginOptions {\nautoCleanUp?: boolean\n}\n-declare const listenersPluginFactory: PluginFactory\n+declare const listenersPluginFactory: (\n+ options?: ListenersPluginOptions\n+) => {\n+ (router: any): any\n+ pluginName: string\n+}\nexport default listenersPluginFactory\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-persistent-params/README.md",
"diff": "+# Router5 browser plugin\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+```js\n+import browserPlugin from 'router5-plugin-persistent-params';\n+\n+const router = createRouter()\n+ .usePlugin(browserPlugin({\n+ useHash: true\n+ }))\n+ .start();\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"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-persistent-params/jest.config.js",
"diff": "+module.exports = {\n+ transform: {\n+ '^.+\\\\.tsx?$': 'ts-jest'\n+ },\n+ moduleFileExtensions: ['ts', 'js'],\n+ preset: 'ts-jest',\n+ testEnvironment: 'node',\n+ globals: {\n+ 'ts-jest': {\n+ tsConfig: '<rootDir>/tsconfig.test.json'\n+ }\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-persistent-params/modules/__tests__/index.ts",
"diff": "+import { createRouter } from 'router5'\n+import persistentParamsPlugin from '../'\n+\n+const createTestRouter = () =>\n+ createRouter([\n+ { name: 'route1', path: '/route1/:id' },\n+ { name: 'route2', path: '/route2/:id' }\n+ ])\n+\n+describe('Persistent params plugin', () => {\n+ let router\n+\n+ describe('with an array', () => {\n+ beforeAll(() => {\n+ router = createTestRouter()\n+ })\n+\n+ it('should be registered with params', () => {\n+ router.usePlugin(persistentParamsPlugin(['mode']))\n+ })\n+\n+ it('should persist specified parameters', done => {\n+ router.start('route1')\n+ router.navigate('route2', { id: '2' }, {}, (err, state) => {\n+ expect(state.path).toBe('/route2/2')\n+ router.navigate(\n+ 'route1',\n+ { id: '1', mode: 'dev' },\n+ {},\n+ (err, state) => {\n+ expect(state.path).toBe('/route1/1?mode=dev')\n+\n+ router.navigate(\n+ 'route2',\n+ { id: '2' },\n+ {},\n+ (err, state) => {\n+ expect(state.path).toBe('/route2/2?mode=dev')\n+ done()\n+ }\n+ )\n+ }\n+ )\n+ })\n+ })\n+\n+ it('should save value on start', done => {\n+ router.stop()\n+ router.start('/route2/1?mode=dev', (err, state) => {\n+ expect(state.params).toEqual({ mode: 'dev', id: '1' })\n+\n+ router.navigate('route2', { id: '2' }, {}, (err, state) => {\n+ expect(state.path).toBe('/route2/2?mode=dev')\n+ done()\n+ })\n+ })\n+ })\n+ })\n+\n+ describe('with an object', () => {\n+ beforeAll(() => {\n+ router.stop()\n+ router = createTestRouter()\n+ })\n+\n+ it('should be registered with params', () => {\n+ router.usePlugin(persistentParamsPlugin({ mode: 'dev' }))\n+ })\n+\n+ it('should persist specified parameters', done => {\n+ router.start()\n+ router.navigate('route1', { id: '1' }, {}, (err, state) => {\n+ expect(state.path).toBe('/route1/1?mode=dev')\n+ done()\n+ })\n+ })\n+ })\n+})\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-persistent-params/modules/index.ts",
"diff": "+import { PluginFactory } from 'router5'\n+\n+const getDefinedParams = params =>\n+ Object.keys(params)\n+ .filter(param => params[param] !== undefined)\n+ .reduce((acc, param) => ({ ...acc, [param]: params[param] }), {})\n+\n+function persistentParamsPluginFactory(params = {}): PluginFactory {\n+ function persistentParamsPlugin(router) {\n+ // Persistent parameters\n+ const persistentParams = Array.isArray(params)\n+ ? params.reduce(\n+ (acc, param) => ({ ...acc, [param]: undefined }),\n+ {}\n+ )\n+ : params\n+\n+ const paramNames = Object.keys(persistentParams)\n+ const hasQueryParams = router.rootNode.path.indexOf('?') !== -1\n+ const queryParams = paramNames.join('&')\n+ const search = queryParams\n+ ? `${hasQueryParams ? '&' : '?'}${queryParams}`\n+ : ''\n+\n+ // Root node path\n+ const path = router.rootNode.path.split('?')[0] + search\n+ router.setRootPath(path)\n+\n+ const { buildPath, buildState } = router\n+\n+ // Decorators\n+ router.buildPath = function(route, params) {\n+ const routeParams = {\n+ ...getDefinedParams(persistentParams),\n+ ...params\n+ }\n+ return buildPath.call(router, route, routeParams)\n+ }\n+\n+ router.buildState = function(route, params) {\n+ const routeParams = {\n+ ...getDefinedParams(persistentParams),\n+ ...params\n+ }\n+ return buildState.call(router, route, routeParams)\n+ }\n+\n+ return {\n+ onTransitionSuccess(toState) {\n+ Object.keys(toState.params)\n+ .filter(p => paramNames.indexOf(p) !== -1)\n+ .forEach(p => (persistentParams[p] = toState.params[p]))\n+ }\n+ }\n+ }\n+\n+ persistentParamsPlugin.pluginName = 'PERSISTENT_PARAMS_PLUGIN'\n+\n+ return persistentParamsPlugin\n+}\n+\n+export default persistentParamsPluginFactory\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-persistent-params/package.json",
"diff": "+{\n+ \"name\": \"router5-plugin-persistent-params\",\n+ \"version\": \"0.0.0\",\n+ \"description\": \"Router5 browser plugin\",\n+ \"main\": \"dist/index.js\",\n+ \"jsnext:main\": \"dist/index.es.js\",\n+ \"module\": \"dist/index.es.js\",\n+ \"sideEffects\": false,\n+ \"repository\": {\n+ \"type\": \"git\",\n+ \"url\": \"git+https://github.com/router5/router5.git\"\n+ },\n+ \"keywords\": [\"router5\", \"helpers\"],\n+ \"author\": \"Thomas Roch <[email protected]>\",\n+ \"license\": \"MIT\",\n+ \"bugs\": {\n+ \"url\": \"https://github.com/router5/router5/issues\"\n+ },\n+ \"devDependencies\": {\n+ \"router5\": \"^6.6.2\"\n+ },\n+ \"peerDependencies\": {\n+ \"router5\": \"^5.0.0 || ^6.0.0\"\n+ },\n+ \"homepage\":\n+ \"https://github.com/router5/router5/tree/master/packages/router5-plugin-persistent-params\",\n+ \"typings\": \"./types/index.d.ts\",\n+ \"scripts\": {\n+ \"test\": \"jest\"\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-persistent-params/tsconfig.build.json",
"diff": "+{\n+ \"extends\": \"./tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"declaration\": true,\n+ \"declarationDir\": \"./types\",\n+ \"outDir\": \"./dist\"\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-persistent-params/tsconfig.json",
"diff": "+{\n+ \"extends\": \"../../tsconfig.base.json\",\n+ \"exclude\": [\"node_modules\", \"modules/__tests__\"],\n+ \"include\": [\"modules\"]\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-persistent-params/tsconfig.test.json",
"diff": "+{\n+ \"extends\": \"./tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"allowJs\": true\n+ },\n+ \"include\": [\"./modules/__tests__/**/*.ts\"]\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-persistent-params/types/index.d.ts",
"diff": "+import { PluginFactory } from 'router5'\n+declare function persistentParamsPluginFactory(params?: {}): PluginFactory\n+export default persistentParamsPluginFactory\n"
},
{
"change_type": "MODIFY",
"old_path": "rollup.config.js",
"new_path": "rollup.config.js",
"diff": "@@ -113,6 +113,15 @@ const config = [\nmakeConfig({\npackageName: 'router5-plugin-listeners',\nformat: 'es'\n+ }),\n+ makeConfig({\n+ packageName: 'router5-plugin-persistent-params',\n+ declaration: true,\n+ format: 'cjs'\n+ }),\n+ makeConfig({\n+ packageName: 'router5-plugin-persistent-params',\n+ format: 'es'\n})\n]\n"
}
] | TypeScript | MIT License | router5/router5 | chore: add persistent params plugin package |
580,249 | 30.11.2018 01:43:14 | 0 | c633d1d5e54dc16393711d8643eada3f92c41fa3 | chore: remove TS errors before adding type merging | [
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-browser/modules/index.ts",
"new_path": "packages/router5-plugin-browser/modules/index.ts",
"diff": "import { constants, errorCodes, Router, PluginFactory } from 'router5'\nimport safeBrowser from './browser'\n-import withUtils from './utils'\nimport { BrowserPluginOptions } from './types'\nconst defaultOptions: BrowserPluginOptions = {\n@@ -29,7 +28,41 @@ function browserPluginFactory(\nconst routerOptions = router.getOptions()\nconst routerStart = router.start\n- withUtils(router, options)\n+ router.buildUrl = (route, params) => {\n+ const base = options.base || ''\n+ const prefix = options.useHash ? `#${options.hashPrefix}` : ''\n+ const path = router.buildPath(route, params)\n+\n+ if (path === null) return null\n+\n+ return base + prefix + path\n+ }\n+\n+ router.urlToPath = (url: string) => {\n+ const match = url.match(\n+ /^(?:http|https):\\/\\/(?:[0-9a-z_\\-.:]+?)(?=\\/)(.*)$/\n+ )\n+ const path = match ? match[1] : url\n+\n+ const pathParts = path.match(/^(.+?)(#.+?)?(\\?.+)?$/)\n+\n+ if (!pathParts)\n+ throw new Error(`[router5] Could not parse url ${url}`)\n+\n+ const pathname = pathParts[1]\n+ const hash = pathParts[2] || ''\n+ const search = pathParts[3] || ''\n+\n+ return (\n+ (options.useHash\n+ ? hash.replace(new RegExp('^#' + options.hashPrefix), '')\n+ : options.base\n+ ? pathname.replace(new RegExp('^' + options.base), '')\n+ : pathname) + search\n+ )\n+ }\n+\n+ router.matchUrl = url => router.matchPath(router.urlToPath(url))\nrouter.start = function(...args) {\nif (args.length === 0 || typeof args[0] === 'function') {\n"
},
{
"change_type": "DELETE",
"old_path": "packages/router5-plugin-browser/modules/utils.ts",
"new_path": null,
"diff": "-import { Router } from 'router5'\n-import { BrowserPluginOptions } from './types'\n-\n-export default function withUtils(\n- router: Router,\n- options: BrowserPluginOptions\n-) {\n- router.urlToPath = urlToPath\n- router.buildUrl = buildUrl\n- router.matchUrl = matchUrl\n-\n- function buildUrl(route, params) {\n- const base = options.base || ''\n- const prefix = options.useHash ? `#${options.hashPrefix}` : ''\n- const path = router.buildPath(route, params)\n-\n- if (path === null) return null\n-\n- return base + prefix + path\n- }\n-\n- function urlToPath(url) {\n- const match = url.match(\n- /^(?:http|https):\\/\\/(?:[0-9a-z_\\-.:]+?)(?=\\/)(.*)$/\n- )\n- const path = match ? match[1] : url\n-\n- const pathParts = path.match(/^(.+?)(#.+?)?(\\?.+)?$/)\n-\n- if (!pathParts) throw new Error(`[router5] Could not parse url ${url}`)\n-\n- const pathname = pathParts[1]\n- const hash = pathParts[2] || ''\n- const search = pathParts[3] || ''\n-\n- return (\n- (options.useHash\n- ? hash.replace(new RegExp('^#' + options.hashPrefix), '')\n- : options.base\n- ? pathname.replace(new RegExp('^' + options.base), '')\n- : pathname) + search\n- )\n- }\n-\n- function matchUrl(url) {\n- return router.matchPath(urlToPath(url))\n- }\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-listeners/modules/index.ts",
"new_path": "packages/router5-plugin-listeners/modules/index.ts",
"diff": "@@ -11,8 +11,8 @@ const defaultOptions: ListenersPluginOptions = {\nconst listenersPluginFactory = (\noptions: ListenersPluginOptions = defaultOptions\n-) => {\n- function listenersPlugin(router: Router): PluginFactory {\n+): PluginFactory => {\n+ function listenersPlugin(router: Router) {\nlet listeners = {}\nfunction removeListener(name, cb?) {\n@@ -31,6 +31,7 @@ const listenersPluginFactory = (\nconst normalizedName = name.replace(/^(\\*|\\^|=)/, '')\nif (normalizedName && !/^\\$/.test(name)) {\n+ //@ts-ignore\nconst segments = router.rootNode.getSegmentsByName(\nnormalizedName\n)\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-listeners/types/index.d.ts",
"new_path": "packages/router5-plugin-listeners/types/index.d.ts",
"diff": "+import { PluginFactory } from 'router5'\nexport interface ListenersPluginOptions {\nautoCleanUp?: boolean\n}\ndeclare const listenersPluginFactory: (\noptions?: ListenersPluginOptions\n-) => {\n- (router: any): any\n- pluginName: string\n-}\n+) => PluginFactory\nexport default listenersPluginFactory\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5/modules/types/router.ts",
"new_path": "packages/router5/modules/types/router.ts",
"diff": "@@ -67,11 +67,9 @@ export interface Config {\nforwardMap: { [key: string]: any }\n}\n-export interface BaseRouter {\n+export interface Router {\nconfig: Config\n-}\n-export interface RouterWithRoutes {\nrootNode: RouteNode\nadd(routes: Route[] | Route, finalSort?: boolean): Router\naddNode(\n@@ -88,14 +86,10 @@ export interface RouterWithRoutes {\nbuildPath(route: string, params?: Params): string\nmatchPath(path: string, source?: string): State | null\nsetRootPath(rootPath: string): void\n-}\n-export interface RouterWithOptions {\ngetOptions(): Options\nsetOption(option: string, value: any): Router\n-}\n-export interface RouterWithState {\nmakeState(\nname: string,\nparams?: Params,\n@@ -114,16 +108,12 @@ export interface RouterWithState {\nareStatesDescendants(parentState: State, childState: State): boolean\nforwardState(routeName: string, routeParams: Params): SimpleState\nbuildState(routeName: string, routeParams: Params): RouteNodeState | null\n-}\n-export interface RouterWithLifecycle {\nisStarted(): boolean\nstart(startPathOrState: string | State, done?: DoneFn): Router\nstart(done?: DoneFn): Router\nstop(): void\n-}\n-export interface RouterWithRouteLifecycle {\ncanDeactivate(\nname: string,\ncanDeactivateHandler: ActivationFnFactory | boolean\n@@ -141,23 +131,17 @@ export interface RouterWithRouteLifecycle {\n{ [key: string]: ActivationFn },\n{ [key: string]: ActivationFn }\n]\n-}\n-export interface RouterWithPlugins {\nusePlugin(...plugins: PluginFactory[]): Router\nhasPlugin(pluginName: string): boolean\naddPlugin(plugin: Plugin): Router\ngetPlugins(): PluginFactory[]\n-}\n-export interface RouterWithMiddleware {\nuseMiddleware(...middlewares: MiddlewareFactory[]): Router\nclearMiddleware(): Router\ngetMiddlewareFactories: () => MiddlewareFactory[]\ngetMiddlewareFunctions: () => Middleware[]\n-}\n-export interface RouterWithDependencies {\nsetDependency(dependencyName: string, dependency: any): Router\nsetDependencies(deps: Dependencies): Router\ngetDependencies(): Dependencies\n@@ -165,15 +149,11 @@ export interface RouterWithDependencies {\nexecuteFactory(\nfactory: (router?: Router, dependencies?: Dependencies) => any\n): any\n-}\n-export interface RouterWithEvents {\ninvokeEventListeners: (eventName, ...args) => void\nremoveEventListener: (eventName, cb) => void\naddEventListener: (eventName, cb) => Unsubscribe\n-}\n-export interface RouterWithNavigation {\ncancel(): Router\nforward(fromRoute: string, toRoute: string): Router\nnavigate(\n@@ -192,27 +172,10 @@ export interface RouterWithNavigation {\nopts: NavigationOptions,\ndone: DoneFn\n)\n-}\n-export interface RouterWithObservable {\nsubscribe(listener: SubscribeFn | Listener): UnsubscribeFn | Subscription\n-}\n-export type Router = BaseRouter &\n- RouterWithRoutes &\n- RouterWithOptions &\n- RouterWithDependencies &\n- RouterWithEvents &\n- RouterWithPlugins &\n- RouterWithMiddleware &\n- RouterWithState &\n- RouterWithLifecycle &\n- RouterWithRouteLifecycle &\n- RouterWithNavigation &\n- RouterWithObservable\n-\n-export interface InternalRouter {\n- setState(state: State): void\n+ [key: string]: any\n}\nexport interface Plugin {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5/types/types/router.d.ts",
"new_path": "packages/router5/types/types/router.d.ts",
"diff": "@@ -67,10 +67,8 @@ export interface Config {\n[key: string]: any\n}\n}\n-export interface BaseRouter {\n+export interface Router {\nconfig: Config\n-}\n-export interface RouterWithRoutes {\nrootNode: RouteNode\nadd(routes: Route[] | Route, finalSort?: boolean): Router\naddNode(\n@@ -87,12 +85,8 @@ export interface RouterWithRoutes {\nbuildPath(route: string, params?: Params): string\nmatchPath(path: string, source?: string): State | null\nsetRootPath(rootPath: string): void\n-}\n-export interface RouterWithOptions {\ngetOptions(): Options\nsetOption(option: string, value: any): Router\n-}\n-export interface RouterWithState {\nmakeState(\nname: string,\nparams?: Params,\n@@ -111,14 +105,10 @@ export interface RouterWithState {\nareStatesDescendants(parentState: State, childState: State): boolean\nforwardState(routeName: string, routeParams: Params): SimpleState\nbuildState(routeName: string, routeParams: Params): RouteNodeState | null\n-}\n-export interface RouterWithLifecycle {\nisStarted(): boolean\nstart(startPathOrState: string | State, done?: DoneFn): Router\nstart(done?: DoneFn): Router\nstop(): void\n-}\n-export interface RouterWithRouteLifecycle {\ncanDeactivate(\nname: string,\ncanDeactivateHandler: ActivationFnFactory | boolean\n@@ -144,20 +134,14 @@ export interface RouterWithRouteLifecycle {\n[key: string]: ActivationFn\n}\n]\n-}\n-export interface RouterWithPlugins {\nusePlugin(...plugins: PluginFactory[]): Router\nhasPlugin(pluginName: string): boolean\naddPlugin(plugin: Plugin): Router\ngetPlugins(): PluginFactory[]\n-}\n-export interface RouterWithMiddleware {\nuseMiddleware(...middlewares: MiddlewareFactory[]): Router\nclearMiddleware(): Router\ngetMiddlewareFactories: () => MiddlewareFactory[]\ngetMiddlewareFunctions: () => Middleware[]\n-}\n-export interface RouterWithDependencies {\nsetDependency(dependencyName: string, dependency: any): Router\nsetDependencies(deps: Dependencies): Router\ngetDependencies(): Dependencies\n@@ -165,13 +149,9 @@ export interface RouterWithDependencies {\nexecuteFactory(\nfactory: (router?: Router, dependencies?: Dependencies) => any\n): any\n-}\n-export interface RouterWithEvents {\ninvokeEventListeners: (eventName: any, ...args: any[]) => void\nremoveEventListener: (eventName: any, cb: any) => void\naddEventListener: (eventName: any, cb: any) => Unsubscribe\n-}\n-export interface RouterWithNavigation {\ncancel(): Router\nforward(fromRoute: string, toRoute: string): Router\nnavigate(\n@@ -190,24 +170,8 @@ export interface RouterWithNavigation {\nopts: NavigationOptions,\ndone: DoneFn\n): any\n-}\n-export interface RouterWithObservable {\nsubscribe(listener: SubscribeFn | Listener): UnsubscribeFn | Subscription\n-}\n-export declare type Router = BaseRouter &\n- RouterWithRoutes &\n- RouterWithOptions &\n- RouterWithDependencies &\n- RouterWithEvents &\n- RouterWithPlugins &\n- RouterWithMiddleware &\n- RouterWithState &\n- RouterWithLifecycle &\n- RouterWithRouteLifecycle &\n- RouterWithNavigation &\n- RouterWithObservable\n-export interface InternalRouter {\n- setState(state: State): void\n+ [key: string]: any\n}\nexport interface Plugin {\nonStart?(): void\n"
}
] | TypeScript | MIT License | router5/router5 | chore: remove TS errors before adding type merging |
580,249 | 30.11.2018 08:33:21 | 0 | fc00f65b8419781ed2cca9d4d45aae16e3f7df75 | chore: use TS module augmentation for plugins | [
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-browser/modules/__tests__/index.ts",
"new_path": "packages/router5-plugin-browser/modules/__tests__/index.ts",
"diff": "@@ -116,11 +116,6 @@ function test(useHash) {\n})\n})\n- it('should be able to extract the path of an URL', function() {\n- expect(router.urlToPath(makeUrl('/home'))).toBe('/home')\n- expect(() => router.urlToPath('')).toThrow()\n- })\n-\nit('should match an URL', function() {\nexpect(withoutMeta(router.matchUrl(makeUrl('/home')))).toEqual({\nname: 'home',\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-browser/modules/index.ts",
"new_path": "packages/router5-plugin-browser/modules/index.ts",
"diff": "-import { constants, errorCodes, Router, PluginFactory } from 'router5'\n+import { PluginFactory, errorCodes, constants, Router, State } from 'router5'\nimport safeBrowser from './browser'\nimport { BrowserPluginOptions } from './types'\n+declare module 'router5/types/types/router' {\n+ interface Router {\n+ buildUrl(name: string, params?: { [key: string]: any }): string\n+ matchUrl(url: string): State | null\n+ replaceHistoryState(\n+ name: string,\n+ params?: { [key: string]: any },\n+ title?: string\n+ ): void\n+ lastKnownState: State\n+ }\n+}\n+\nconst defaultOptions: BrowserPluginOptions = {\nforceDeactivate: true,\nuseHash: false,\n@@ -38,7 +51,7 @@ function browserPluginFactory(\nreturn base + prefix + path\n}\n- router.urlToPath = (url: string) => {\n+ const urlToPath = (url: string) => {\nconst match = url.match(\n/^(?:http|https):\\/\\/(?:[0-9a-z_\\-.:]+?)(?=\\/)(.*)$/\n)\n@@ -62,7 +75,7 @@ function browserPluginFactory(\n)\n}\n- router.matchUrl = url => router.matchPath(router.urlToPath(url))\n+ router.matchUrl = url => router.matchPath(urlToPath(url))\nrouter.start = function(...args) {\nif (args.length === 0 || typeof args[0] === 'function') {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-browser/types/index.d.ts",
"new_path": "packages/router5-plugin-browser/types/index.d.ts",
"diff": "-import { PluginFactory } from 'router5'\n+import { PluginFactory, State } from 'router5'\nimport { BrowserPluginOptions } from './types'\n+declare module 'router5/types/types/router' {\n+ interface Router {\n+ buildUrl(\n+ name: string,\n+ params?: {\n+ [key: string]: any\n+ }\n+ ): string\n+ matchUrl(url: string): State | null\n+ replaceHistoryState(\n+ name: string,\n+ params?: {\n+ [key: string]: any\n+ },\n+ title?: string\n+ ): void\n+ lastKnownState: State\n+ }\n+}\ndeclare function browserPluginFactory(\nopts?: BrowserPluginOptions,\nbrowser?: import('./types').Browser\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-listeners/modules/index.ts",
"new_path": "packages/router5-plugin-listeners/modules/index.ts",
"diff": "-import { PluginFactory, Router } from 'router5'\n+import { PluginFactory, Router, State } from 'router5'\nimport transitionPath from 'router5-transition-path'\n-\n+import { removeListener } from 'cluster'\n+\n+export type Listener = (toState: State, fromState: State | null) => void\n+\n+declare module 'router5/types/types/router' {\n+ interface Router {\n+ getListeners(): { [key: string]: Listener[] }\n+ addListener(name: string, callback: Listener): void\n+ removeListener(name: string, callback: Listener): void\n+ addNodeListener(name: string, callback: Listener): void\n+ removeNodeListener(name: string, callback: Listener): void\n+ addRouteListener(name: string, callback: Listener): void\n+ removeRouteListener(name: string, callback: Listener): void\n+ }\n+}\nexport interface ListenersPluginOptions {\nautoCleanUp?: boolean\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-listeners/types/index.d.ts",
"new_path": "packages/router5-plugin-listeners/types/index.d.ts",
"diff": "-import { PluginFactory } from 'router5'\n+import { PluginFactory, State } from 'router5'\n+export declare type Listener = (toState: State, fromState: State | null) => void\n+declare module 'router5/types/types/router' {\n+ interface Router {\n+ getListeners(): {\n+ [key: string]: Listener[]\n+ }\n+ addListener(name: string, callback: Listener): void\n+ removeListener(name: string, callback: Listener): void\n+ addNodeListener(name: string, callback: Listener): void\n+ removeNodeListener(name: string, callback: Listener): void\n+ addRouteListener(name: string, callback: Listener): void\n+ removeRouteListener(name: string, callback: Listener): void\n+ }\n+}\nexport interface ListenersPluginOptions {\nautoCleanUp?: boolean\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5/modules/types/router.ts",
"new_path": "packages/router5/modules/types/router.ts",
"diff": "@@ -174,8 +174,6 @@ export interface Router {\n)\nsubscribe(listener: SubscribeFn | Listener): UnsubscribeFn | Subscription\n-\n- [key: string]: any\n}\nexport interface Plugin {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5/types/types/router.d.ts",
"new_path": "packages/router5/types/types/router.d.ts",
"diff": "@@ -171,7 +171,6 @@ export interface Router {\ndone: DoneFn\n): any\nsubscribe(listener: SubscribeFn | Listener): UnsubscribeFn | Subscription\n- [key: string]: any\n}\nexport interface Plugin {\nonStart?(): void\n"
}
] | TypeScript | MIT License | router5/router5 | chore: use TS module augmentation for plugins |
580,249 | 30.11.2018 10:30:25 | 0 | c733d15cd30039e1dbaa14536e11a0e11a1d21fd | chore: move xstream-router5 to TS and jest | [
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-listeners/modules/__tests__/index.ts",
"new_path": "packages/router5-plugin-listeners/modules/__tests__/index.ts",
"diff": "@@ -73,7 +73,7 @@ describe('listenersPlugin', () => {\nrouter.addListener(listener)\nrouter.navigate('orders.pending', {}, {}, () => {\n- expect(listener).toHaveBeenLastCalledWith(\n+ expect(listener).toHaveBeenCalledWith(\nrouter.getState(),\npreviousState\n)\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/rxjs-router5/modules/index.ts",
"new_path": "packages/rxjs-router5/modules/index.ts",
"diff": "@@ -4,18 +4,11 @@ import transitionPath from 'router5-transition-path'\nimport { map, startWith, filter, distinctUntilChanged } from 'rxjs/operators'\nimport { PluginFactory } from 'router5'\n-const PLUGIN_NAME = 'RXJS_PLUGIN'\n-const TRANSITION_SUCCESS = 'success'\n-const TRANSITION_ERROR = 'error'\n-const TRANSITION_START = 'start'\n-const TRANSITION_CANCEL = 'cancel'\n-\n-export {\n- TRANSITION_SUCCESS,\n- TRANSITION_ERROR,\n- TRANSITION_START,\n- TRANSITION_CANCEL\n-}\n+export const PLUGIN_NAME = 'RXJS_PLUGIN'\n+export const TRANSITION_SUCCESS = 'success'\n+export const TRANSITION_ERROR = 'error'\n+export const TRANSITION_START = 'start'\n+export const TRANSITION_CANCEL = 'cancel'\nexport interface RouterAction {\ntype: string\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/xstream-router5/.npmignore",
"new_path": "packages/xstream-router5/.npmignore",
"diff": "**/.*\n+modules\nnode_modules\nnpm-debug.log\n-test\n*.md\n*.config.js\n+*.json\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/xstream-router5/jest.config.js",
"diff": "+module.exports = {\n+ transform: {\n+ '^.+\\\\.tsx?$': 'ts-jest'\n+ },\n+ moduleFileExtensions: ['ts', 'js'],\n+ preset: 'ts-jest',\n+ testEnvironment: 'node',\n+ globals: {\n+ 'ts-jest': {\n+ tsConfig: '<rootDir>/tsconfig.test.json'\n+ }\n+ }\n+}\n"
},
{
"change_type": "RENAME",
"old_path": "packages/xstream-router5/test/main.js",
"new_path": "packages/xstream-router5/modules/__tests__/main.ts",
"diff": "-import { expect } from 'chai'\nimport { Stream } from 'xstream'\n-import createRouter from '../../router5'\n-import createObservables from '../modules'\n+import createRouter from 'router5'\n+import createObservables from '../'\ndescribe('xsPlugin', () => {\nlet observables\n- before(() => {\n+ beforeAll(() => {\nobservables = createObservables(createRouter())\n})\nit('should initialise observables', () => {\n- expect(observables).to.exist\n+ expect(observables).toBeDefined()\n})\nit('should expose a route$ observable', () => {\n- expect(observables.route$).to.be.instanceof(Stream)\n+ expect(observables.route$).toBeInstanceOf(Stream)\n})\nit('should expose a routeNode observable factory', () => {\n- expect(observables.routeNode('')).to.be.instanceof(Stream)\n+ expect(observables.routeNode('')).toBeInstanceOf(Stream)\n})\nit('should expose a transitionError$ observable', () => {\n- expect(observables.transitionError$).to.be.instanceof(Stream)\n+ expect(observables.transitionError$).toBeInstanceOf(Stream)\n})\nit('should expose a transitionRoute$ observable', () => {\n- expect(observables.transitionRoute$).to.be.instanceof(Stream)\n+ expect(observables.transitionRoute$).toBeInstanceOf(Stream)\n})\n})\n"
},
{
"change_type": "RENAME",
"old_path": "packages/xstream-router5/test/route$.js",
"new_path": "packages/xstream-router5/modules/__tests__/route$.ts",
"diff": "-import { expect } from 'chai'\n-import { spy } from 'sinon'\n-import { state1, state2, state3 } from './_helpers'\n-import createObservables from '../modules'\n-import createRouter, { constants } from '../../router5'\n+import createObservables from '../'\n+import createRouter, { constants } from 'router5'\n+\n+const state1 = { name: 'route1', path: '/route1', meta: { params: {} } }\n+const state2 = { name: 'route2', path: '/route2', meta: { params: {} } }\n+const state3 = { name: 'route3', path: '/route3', meta: { params: {} } }\ndescribe('route$', () => {\nit('should push new values to route$ on transitionSuccess events', () => {\nconst router = createRouter()\nconst observables = createObservables(router)\n- const listener = { next: spy(), error() {}, complete: spy() }\n+ const listener = { next: jest.fn(), error() {}, complete: jest.fn() }\nobservables.route$.addListener(listener)\n- expect(listener.next).to.have.been.calledWith(null)\n+ expect(listener.next).toHaveBeenCalledWith(null)\nrouter.invokeEventListeners(constants.TRANSITION_START, state1, null)\nrouter.invokeEventListeners(constants.TRANSITION_SUCCESS, state1, null)\n- expect(listener.next).to.have.been.calledWith(state1)\n+ expect(listener.next).toHaveBeenCalledWith(state1)\nrouter.invokeEventListeners(constants.TRANSITION_START, state2, state1)\nrouter.invokeEventListeners(\n@@ -25,7 +26,7 @@ describe('route$', () => {\nstate1\n)\n- expect(listener.next).to.have.been.calledWith(state2)\n+ expect(listener.next).toHaveBeenCalledWith(state2)\nrouter.invokeEventListeners(constants.TRANSITION_START, state3, state2)\nrouter.invokeEventListeners(\n@@ -34,24 +35,24 @@ describe('route$', () => {\nstate2\n)\n- expect(listener.next).to.have.been.calledWith(state3)\n+ expect(listener.next).toHaveBeenCalledWith(state3)\nrouter.invokeEventListeners(constants.ROUTER_STOP)\n- expect(listener.complete).to.have.been.called\n+ expect(listener.complete).toHaveBeenCalled\n})\nit('should not push new values to route$ on transitionError events', () => {\nconst router = createRouter()\nconst observables = createObservables(router)\n- const listener = { next: spy(), error() {}, complete() {} }\n+ const listener = { next: jest.fn(), error() {}, complete() {} }\nobservables.route$.addListener(listener)\nrouter.invokeEventListeners(constants.TRANSITION_START, state1, null)\nrouter.invokeEventListeners(constants.TRANSITION_ERROR, state1, null)\n- expect(listener.next).to.have.been.calledOnce\n- expect(listener.next).to.have.been.calledWith(null)\n+ expect(listener.next).toHaveBeenCalledTimes(1)\n+ expect(listener.next).toHaveBeenCalledWith(null)\nrouter.invokeEventListeners(constants.ROUTER_STOP)\n})\n"
},
{
"change_type": "RENAME",
"old_path": "packages/xstream-router5/test/routeNode.js",
"new_path": "packages/xstream-router5/modules/__tests__/routeNode.ts",
"diff": "-import { expect } from 'chai'\n-import { spy } from 'sinon'\n-import { state1, state2, state3 } from './_helpers'\n-import createObservables from '../modules'\n-import createRouter, { constants } from '../../router5'\n+import createObservables from '..'\n+import createRouter, { constants } from 'router5'\n+\n+const state1 = { name: 'route1', path: '/route1', meta: { params: {} } }\n+const state2 = { name: 'route2', path: '/route2', meta: { params: {} } }\n+const state3 = { name: 'route3', path: '/route3', meta: { params: {} } }\nconst nestedA = { name: 'a', path: '/a', meta: { params: {} } }\nconst nestedAB = { name: 'a.b', path: '/a/b', meta: { params: {} } }\n@@ -12,14 +13,14 @@ describe('routeNode', () => {\nit('should see route updates for the root node', () => {\nconst router = createRouter()\nconst observables = createObservables(router)\n- const listener = { next: spy(), error() {}, complete: spy() }\n+ const listener = { next: jest.fn(), error() {}, complete: jest.fn() }\nobservables.routeNode('').addListener(listener)\nrouter.invokeEventListeners(constants.TRANSITION_START, state1, null)\nrouter.invokeEventListeners(constants.TRANSITION_SUCCESS, state1, null)\n- expect(listener.next).to.have.been.calledWith(state1)\n+ expect(listener.next).toHaveBeenCalledWith(state1)\nrouter.invokeEventListeners(constants.TRANSITION_START, state2, state1)\nrouter.invokeEventListeners(\n@@ -28,7 +29,7 @@ describe('routeNode', () => {\nstate1\n)\n- expect(listener.next).to.have.been.calledWith(state2)\n+ expect(listener.next).toHaveBeenCalledWith(state2)\nrouter.invokeEventListeners(constants.TRANSITION_START, state3, state2)\nrouter.invokeEventListeners(\n@@ -37,17 +38,17 @@ describe('routeNode', () => {\nstate2\n)\n- expect(listener.next).to.have.been.calledWith(state3)\n+ expect(listener.next).toHaveBeenCalledWith(state3)\nrouter.invokeEventListeners(constants.ROUTER_STOP)\n- expect(listener.complete).to.have.been.called\n+ expect(listener.complete).toHaveBeenCalled()\n})\nit('should work with nested routes', () => {\nconst router = createRouter()\nconst observables = createObservables(router)\n- const listener = { next: spy(), error() {}, complete() {} }\n+ const listener = { next: jest.fn(), error() {}, complete() {} }\nobservables.routeNode('a').addListener(listener)\n@@ -65,7 +66,7 @@ describe('routeNode', () => {\nnestedA\n)\n- expect(listener.next).to.have.been.calledWith(nestedAB)\n+ expect(listener.next).toHaveBeenCalledWith(nestedAB)\nrouter.invokeEventListeners(\nconstants.TRANSITION_START,\n@@ -78,7 +79,7 @@ describe('routeNode', () => {\nnestedAB\n)\n- expect(listener.next).to.have.been.calledWith(nestedAC)\n+ expect(listener.next).toHaveBeenCalledWith(nestedAC)\nrouter.invokeEventListeners(constants.ROUTER_STOP)\n})\n"
},
{
"change_type": "RENAME",
"old_path": "packages/xstream-router5/test/transitionError$.js",
"new_path": "packages/xstream-router5/modules/__tests__/transitionError$.ts",
"diff": "-import { expect } from 'chai'\n-import { spy } from 'sinon'\n-import { state1, state2 } from './_helpers'\n-import createObservables from '../modules'\n-import createRouter, { constants } from '../../router5'\n+import createObservables from '..'\n+import createRouter, { constants } from 'router5'\n+const state1 = { name: 'route1', path: '/route1', meta: { params: {} } }\n+const state2 = { name: 'route2', path: '/route2', meta: { params: {} } }\nconst error = 'error'\ndescribe('transitionError$', () => {\nit('should push new values to transitionError$ on transitionError events', () => {\nconst router = createRouter()\nconst observables = createObservables(router)\n- const listener = { next: spy(), error() {}, complete: spy() }\n+ const listener = { next: jest.fn(), error() {}, complete: jest.fn() }\nobservables.transitionError$.addListener(listener)\n@@ -22,19 +21,19 @@ describe('transitionError$', () => {\nerror\n)\n- expect(listener.next).to.have.been.calledTwice\n- expect(listener.next).to.have.been.calledWith(null)\n- expect(listener.next).to.have.been.calledWith(error)\n+ expect(listener.next).toHaveBeenCalledTimes(2)\n+ expect(listener.next).toHaveBeenCalledWith(null)\n+ expect(listener.next).toHaveBeenCalledWith(error)\nrouter.invokeEventListeners(constants.ROUTER_STOP)\n- expect(listener.complete).to.have.been.called\n+ expect(listener.complete).toHaveBeenCalled()\n})\nit('should become null on a new transition start event', () => {\nconst router = createRouter()\nconst observables = createObservables(router)\n- const listener = { next: spy(), error() {}, complete: spy() }\n+ const listener = { next: jest.fn(), error() {}, complete: jest.fn() }\nobservables.transitionError$.addListener(listener)\n@@ -47,13 +46,13 @@ describe('transitionError$', () => {\n)\nrouter.invokeEventListeners(constants.TRANSITION_START, state2, null)\n- expect(listener.next).to.have.been.calledThrice\n- expect(listener.next).to.have.been.calledWith(null)\n- expect(listener.next).to.have.been.calledWith(error)\n- expect(listener.next).to.have.been.calledWith(null)\n+ expect(listener.next).toHaveBeenCalledTimes(3)\n+ expect(listener.next).toHaveBeenCalledWith(null)\n+ expect(listener.next).toHaveBeenCalledWith(error)\n+ expect(listener.next).toHaveBeenCalledWith(null)\nrouter.invokeEventListeners(constants.ROUTER_STOP)\n- expect(listener.complete).to.have.been.called\n+ expect(listener.complete).toHaveBeenCalled()\n})\n})\n"
},
{
"change_type": "RENAME",
"old_path": "packages/xstream-router5/test/transitionRoute$.js",
"new_path": "packages/xstream-router5/modules/__tests__/transitionRoute$.ts",
"diff": "-import { expect } from 'chai'\n-import { spy } from 'sinon'\n-import { state1 } from './_helpers'\n-import createObservables from '../modules'\n-import createRouter, { constants } from '../../router5'\n+import createObservables from '..'\n+import createRouter, { constants } from 'router5'\n+\n+const state1 = { name: 'route1', path: '/route1', meta: { params: {} } }\ndescribe('transitionRoute$', () => {\nit('should push new values to transitionRoute$ on transitionStart events', () => {\nconst router = createRouter()\nconst observables = createObservables(router)\n- const listener = { next: spy(), error() {}, complete: spy() }\n+ const listener = { next: jest.fn(), error() {}, complete: jest.fn() }\nobservables.transitionRoute$.addListener(listener)\nrouter.invokeEventListeners(constants.TRANSITION_START, state1, null)\n- expect(listener.next).to.have.been.calledTwice\n- expect(listener.next).to.have.been.calledWith(null)\n- expect(listener.next).to.have.been.calledWith(state1)\n+ expect(listener.next).toHaveBeenCalledTimes(2)\n+ expect(listener.next).toHaveBeenCalledWith(null)\n+ expect(listener.next).toHaveBeenCalledWith(state1)\nrouter.invokeEventListeners(constants.ROUTER_STOP)\n- expect(listener.complete).to.have.been.called\n+ expect(listener.complete).toHaveBeenCalled()\n})\nit('should become null on a transition success', () => {\nconst router = createRouter()\nconst observables = createObservables(router)\n- const listener = { next: spy(), error() {}, complete() {} }\n+ const listener = { next: jest.fn(), error() {}, complete() {} }\nobservables.transitionRoute$.addListener(listener)\nrouter.invokeEventListeners(constants.TRANSITION_START, state1, null)\nrouter.invokeEventListeners(constants.TRANSITION_SUCCESS, state1, null)\n- expect(listener.next).to.have.been.calledThrice\n- expect(listener.next).to.have.been.calledWith(null)\n- expect(listener.next).to.have.been.calledWith(state1)\n- expect(listener.next).to.have.been.calledWith(null)\n+ expect(listener.next).toHaveBeenCalledTimes(3)\n+ expect(listener.next).toHaveBeenCalledWith(null)\n+ expect(listener.next).toHaveBeenCalledWith(state1)\n+ expect(listener.next).toHaveBeenCalledWith(null)\nrouter.invokeEventListeners(constants.ROUTER_STOP)\n})\n@@ -42,16 +41,16 @@ describe('transitionRoute$', () => {\nit('should become null on a transition error', () => {\nconst router = createRouter()\nconst observables = createObservables(router)\n- const listener = { next: spy(), error() {}, complete() {} }\n+ const listener = { next: jest.fn(), error() {}, complete() {} }\nobservables.transitionRoute$.addListener(listener)\nrouter.invokeEventListeners(constants.TRANSITION_START, state1, null)\nrouter.invokeEventListeners(constants.TRANSITION_ERROR, state1, null)\n- expect(listener.next).to.have.been.calledThrice\n- expect(listener.next).to.have.been.calledWith(null)\n- expect(listener.next).to.have.been.calledWith(state1)\n- expect(listener.next).to.have.been.calledWith(null)\n+ expect(listener.next).toHaveBeenCalledTimes(3)\n+ expect(listener.next).toHaveBeenCalledWith(null)\n+ expect(listener.next).toHaveBeenCalledWith(state1)\n+ expect(listener.next).toHaveBeenCalledWith(null)\nrouter.invokeEventListeners(constants.ROUTER_STOP)\n})\n"
},
{
"change_type": "RENAME",
"old_path": "packages/xstream-router5/modules/index.js",
"new_path": "packages/xstream-router5/modules/index.ts",
"diff": "-import xs from 'xstream'\n+import xs, { Listener } from 'xstream'\n+import { State, PluginFactory } from 'router5'\nimport dropRepeats from 'xstream/extra/dropRepeats'\nimport transitionPath from 'router5-transition-path'\n-const TRANSITION_SUCCESS = '@@router5/TRANSITION_SUCCESS'\n-const TRANSITION_ERROR = '@@router5/TRANSITION_ERROR'\n-const TRANSITION_START = '@@router5/TRANSITION_START'\n-const TRANSITION_CANCEL = '@@router5/TRANSITION_CANCEL'\n+export const TRANSITION_SUCCESS = 'success'\n+export const TRANSITION_ERROR = 'error'\n+export const TRANSITION_START = 'start'\n+export const TRANSITION_CANCEL = 'cancel'\n-export {\n- TRANSITION_SUCCESS,\n- TRANSITION_ERROR,\n- TRANSITION_START,\n- TRANSITION_CANCEL\n+export interface RouterAction {\n+ type: string\n+ toState: State\n+ fromState: State | null\n+ error?: any\n}\n-function xsPluginFactory(listener) {\n- return function xsPlugin() {\n- const dispatch = (type, isError) => (toState, fromState, error) => {\n+export interface RouterState {\n+ intersection: ''\n+ state: State\n+}\n+\n+function xsPluginFactory(listener: Listener<RouterAction>): PluginFactory {\n+ function xsPlugin() {\n+ const dispatch = (type: string, isError?: boolean) => (\n+ toState: State,\n+ fromState: State | null,\n+ error: any\n+ ) => {\nif (listener) {\nconst routerEvt = { type, toState, fromState }\n@@ -32,11 +42,15 @@ function xsPluginFactory(listener) {\nonTransitionCancel: dispatch(TRANSITION_CANCEL)\n}\n}\n+\n+ xsPlugin.pluginName = 'xstream'\n+\n+ return xsPlugin as PluginFactory\n}\nfunction createObservables(router) {\n// Events observable\n- const transitionEvents$ = xs.create({\n+ const transitionEvents$ = xs.create<RouterAction>({\nstart(listener) {\nrouter.usePlugin(xsPluginFactory(listener))\n},\n@@ -45,33 +59,35 @@ function createObservables(router) {\n// Transition Route\nconst transitionRoute$ = transitionEvents$\n- .map(_ => (_.type === TRANSITION_START ? _.toState : null))\n+ .map<State | null>(_ =>\n+ _.type === TRANSITION_START ? _.toState : null\n+ )\n.startWith(null)\n// Error\nconst transitionError$ = transitionEvents$\n- .filter(_ => _.type)\n- .map(_ => (_.type === TRANSITION_ERROR ? _.error : null))\n+ .filter(_ => Boolean(_.type))\n+ .map<any>(_ => (_.type === TRANSITION_ERROR ? _.error : null))\n.startWith(null)\n.compose(dropRepeats())\n// Route with intersection\nconst routeState$ = transitionEvents$\n.filter(_ => _.type === TRANSITION_SUCCESS && _.toState !== null)\n- .map(({ toState, fromState }) => {\n+ .map<RouterState>(({ toState, fromState }) => {\nconst { intersection } = transitionPath(toState, fromState)\n- return { intersection, route: toState }\n+ return { intersection, state: toState } as RouterState\n})\n- .startWith({ intersection: '', route: router.getState() })\n+ .startWith({ intersection: '', state: router.getState() })\n// Create a route observable\n- const route$ = routeState$.map(({ route }) => route)\n+ const route$ = routeState$.map<State>(({ state }) => state)\n// Create a route node observable\n- const routeNode = node =>\n+ const routeNode = (node: string) =>\nrouteState$\n.filter(({ intersection }) => intersection === node)\n- .map(({ route }) => route)\n+ .map(({ state }) => state)\n.startWith(router.getState())\n// Return observables\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/xstream-router5/package.json",
"new_path": "packages/xstream-router5/package.json",
"diff": "\"url\": \"https://github.com/router5/router5/issues\"\n},\n\"homepage\": \"https://github.com/router5/router5/tree/master/packages/xstream-router5\",\n+ \"devDependencies\": {\n+ \"router5\": \"^6.0.0\",\n+ \"xstream\": \"^10.0.0 || ^11.0.0\"\n+ },\n\"dependencies\": {\n- \"router5-transition-path\": \"5.4.0\",\n- \"xstream\": \"^10.0.0\"\n+ \"router5-transition-path\": \"5.4.0\"\n},\n\"peerDependencies\": {\n\"router5\": \"^5.0.0 || ^6.0.0\",\n\"xstream\": \"^10.0.0\"\n+ },\n+ \"typings\": \"./types/index.d.ts\",\n+ \"scripts\": {\n+ \"test\": \"jest\"\n}\n}\n"
},
{
"change_type": "DELETE",
"old_path": "packages/xstream-router5/test/_helpers.js",
"new_path": null,
"diff": "-export const state1 = { name: 'route1', path: '/route1', meta: { params: {} } }\n-export const state2 = { name: 'route2', path: '/route2', meta: { params: {} } }\n-export const state3 = { name: 'route3', path: '/route3', meta: { params: {} } }\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/xstream-router5/tsconfig.build.json",
"diff": "+{\n+ \"extends\": \"./tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"declaration\": true,\n+ \"declarationDir\": \"./types\",\n+ \"outDir\": \"./dist\"\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/xstream-router5/tsconfig.json",
"diff": "+{\n+ \"extends\": \"../../tsconfig.base.json\",\n+ \"exclude\": [\"node_modules\", \"modules/__tests__\"],\n+ \"include\": [\"modules\"]\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/xstream-router5/tsconfig.test.json",
"diff": "+{\n+ \"extends\": \"./tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"allowJs\": true\n+ },\n+ \"include\": [\"./modules/__tests__/**/*.ts\"]\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "rollup.config.js",
"new_path": "rollup.config.js",
"diff": "@@ -12,7 +12,6 @@ const makeConfig = ({\npackageName,\ndeclaration = false,\nformat,\n- external,\ncompress = false,\nfile\n}) => {\n@@ -122,6 +121,24 @@ const config = [\nmakeConfig({\npackageName: 'router5-plugin-persistent-params',\nformat: 'es'\n+ }),\n+ makeConfig({\n+ packageName: 'rxjs-router5',\n+ declaration: true,\n+ format: 'cjs'\n+ }),\n+ makeConfig({\n+ packageName: 'rxjs-router5',\n+ format: 'es'\n+ }),\n+ makeConfig({\n+ packageName: 'xstream-router5',\n+ declaration: true,\n+ format: 'cjs'\n+ }),\n+ makeConfig({\n+ packageName: 'xstream-router5',\n+ format: 'es'\n})\n]\n"
}
] | TypeScript | MIT License | router5/router5 | chore: move xstream-router5 to TS and jest |
580,249 | 30.11.2018 10:31:20 | 0 | 3b30203d738e9f9f7ffa5ba715fbce9dbb179879 | chore: add rxjs and xstream types | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/rxjs-router5/types/index.d.ts",
"diff": "+import { Observable } from 'rxjs'\n+import { Router, State } from 'router5'\n+export declare const PLUGIN_NAME = 'RXJS_PLUGIN'\n+export declare const TRANSITION_SUCCESS = 'success'\n+export declare const TRANSITION_ERROR = 'error'\n+export declare const TRANSITION_START = 'start'\n+export declare const TRANSITION_CANCEL = 'cancel'\n+export interface RouterAction {\n+ type: string\n+ toState: State\n+ fromState: State | null\n+ error?: any\n+}\n+export interface RouterState {\n+ intersection: ''\n+ state: State\n+}\n+declare function createObservables(\n+ router: Router\n+): {\n+ route$: Observable<State>\n+ routeNode: (node: string) => Observable<State>\n+ transitionError$: Observable<any>\n+ transitionRoute$: Observable<State>\n+}\n+export default createObservables\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/xstream-router5/types/index.d.ts",
"diff": "+import xs from 'xstream'\n+import { State } from 'router5'\n+export declare const TRANSITION_SUCCESS = 'success'\n+export declare const TRANSITION_ERROR = 'error'\n+export declare const TRANSITION_START = 'start'\n+export declare const TRANSITION_CANCEL = 'cancel'\n+export interface RouterAction {\n+ type: string\n+ toState: State\n+ fromState: State | null\n+ error?: any\n+}\n+export interface RouterState {\n+ intersection: ''\n+ state: State\n+}\n+declare function createObservables(\n+ router: any\n+): {\n+ route$: import('xstream').MemoryStream<State>\n+ routeNode: (node: string) => import('xstream').MemoryStream<State>\n+ transitionError$: xs<any>\n+ transitionRoute$: import('xstream').MemoryStream<State>\n+}\n+export default createObservables\n"
}
] | TypeScript | MIT License | router5/router5 | chore: add rxjs and xstream types |
580,249 | 30.11.2018 17:32:10 | 0 | 4648bf81e751d93f374b55ef12dbaf514dc69966 | chore: build react-router5 with rollup | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/BaseLink.ts",
"new_path": "packages/react-router5/modules/BaseLink.ts",
"diff": "@@ -45,7 +45,9 @@ class BaseLink extends Component<BaseLinkProps, BaseLinkState> {\n}\nbuildUrl(routeName, routeParams) {\n+ //@ts-ignore\nif (this.router.buildUrl) {\n+ //@ts-ignore\nreturn this.router.buildUrl(routeName, routeParams)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/RouteProvider.tsx",
"new_path": "packages/react-router5/modules/RouteProvider.tsx",
"diff": "@@ -2,7 +2,7 @@ import React, { ReactNode } from 'react'\nimport PropTypes from 'prop-types'\nimport { shouldUpdateNode } from 'router5-transition-path'\nimport { State, Router } from 'router5'\n-import { RouterContext, RouterState } from './types';\n+import { RouterContext, RouterState, UnsubscribeFn } from './types';\nconst emptyCreateContext = () => ({\nProvider: ({ children }) => children,\n@@ -23,7 +23,7 @@ class RouteProvider extends React.PureComponent<RouteProviderProps> {\nprivate mounted: boolean\nprivate router: Router\nprivate routeState: RouterState\n- private unsubscribe: () => void\n+ private unsubscribe: UnsubscribeFn\nconstructor(props) {\nsuper(props)\n@@ -45,7 +45,7 @@ class RouteProvider extends React.PureComponent<RouteProviderProps> {\nthis.forceUpdate()\n}\n}\n- this.unsubscribe = this.router.subscribe(listener)\n+ this.unsubscribe = this.router.subscribe(listener) as UnsubscribeFn\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/routeNode.ts",
"new_path": "packages/react-router5/modules/routeNode.ts",
"diff": "import { Component, createElement, ComponentClass } from 'react'\nimport PropTypes from 'prop-types'\nimport { shouldUpdateNode } from 'router5-transition-path'\n-import { RouterState, RouterContext } from './types'\n+import { RouterState, RouterContext, UnsubscribeFn } from './types'\nimport { Router } from 'router5'\nfunction routeNode<P>(nodeName: string) {\n@@ -12,7 +12,7 @@ function routeNode<P>(nodeName: string) {\nprivate router: Router\nprivate routeState: RouterState\nprivate mounted: boolean\n- private unsubscribe: () => void\n+ private unsubscribe: UnsubscribeFn\nconstructor(props, context) {\nsuper(props, context)\n@@ -35,7 +35,9 @@ function routeNode<P>(nodeName: string) {\n}\n}\n}\n- this.unsubscribe = this.router.subscribe(listener)\n+ this.unsubscribe = this.router.subscribe(\n+ listener\n+ ) as UnsubscribeFn\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/types.ts",
"new_path": "packages/react-router5/modules/types.ts",
"diff": "@@ -10,3 +10,5 @@ export interface RouterState {\nroute: State\npreviousRoute: State | null\n}\n+\n+export type UnsubscribeFn = () => void\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/withRoute.ts",
"new_path": "packages/react-router5/modules/withRoute.ts",
"diff": "import { Component, createElement, ComponentClass } from 'react'\nimport PropTypes from 'prop-types'\nimport { Router } from 'router5'\n-import { RouterState } from './types'\n+import { RouterState, UnsubscribeFn } from './types'\nfunction withRoute<P>(\nBaseComponent: React.ComponentType<P & RouterState>\n@@ -10,7 +10,7 @@ function withRoute<P>(\nprivate router: Router\nprivate routeState: RouterState\nprivate mounted: boolean\n- private unsubscribe: () => void\n+ private unsubscribe: UnsubscribeFn\nconstructor(props, context) {\nsuper(props, context)\n@@ -31,7 +31,9 @@ function withRoute<P>(\nthis.forceUpdate()\n}\n}\n- this.unsubscribe = this.router.subscribe(listener)\n+ this.unsubscribe = this.router.subscribe(\n+ listener\n+ ) as UnsubscribeFn\n}\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/types/BaseLink.d.ts",
"diff": "+import { NavigationOptions, State, Router } from 'router5'\n+import React, { Component, HTMLAttributes, MouseEventHandler } from 'react'\n+export interface BaseLinkProps extends HTMLAttributes<HTMLAnchorElement> {\n+ routeName: string\n+ routeParams?: {\n+ [key: string]: any\n+ }\n+ routeOptions?: NavigationOptions\n+ className?: string\n+ activeClassName?: string\n+ activeStrict?: boolean\n+ ignoreQueryParams?: boolean\n+ onClick?: MouseEventHandler<HTMLAnchorElement>\n+ onMouseOver?: MouseEventHandler<HTMLAnchorElement>\n+ successCallback?(state?: State): void\n+ errorCallback?(error?: any): void\n+ target?: string\n+ route?: State\n+ previousRoute?: State\n+ router?: Router\n+}\n+export interface BaseLinkState {\n+ active: boolean\n+}\n+declare class BaseLink extends Component<BaseLinkProps, BaseLinkState> {\n+ router: Router\n+ constructor(props: any, context: any)\n+ buildUrl(routeName: any, routeParams: any): any\n+ isActive(): boolean\n+ callback(err: any, state: any): void\n+ clickHandler(evt: any): void\n+ render(): React.DetailedReactHTMLElement<\n+ {\n+ href: any\n+ className: string\n+ onClick: (evt: any) => void\n+ onMouseOver?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n+ target?: string\n+ defaultChecked?: boolean\n+ defaultValue?: string | string[]\n+ suppressContentEditableWarning?: boolean\n+ suppressHydrationWarning?: boolean\n+ accessKey?: string\n+ contentEditable?: boolean\n+ contextMenu?: string\n+ dir?: string\n+ draggable?: boolean\n+ hidden?: boolean\n+ id?: string\n+ lang?: string\n+ placeholder?: string\n+ slot?: string\n+ spellCheck?: boolean\n+ style?: React.CSSProperties\n+ tabIndex?: number\n+ title?: string\n+ inputMode?: string\n+ is?: string\n+ radioGroup?: string\n+ role?: string\n+ about?: string\n+ datatype?: string\n+ inlist?: any\n+ prefix?: string\n+ property?: string\n+ resource?: string\n+ typeof?: string\n+ vocab?: string\n+ autoCapitalize?: string\n+ autoCorrect?: string\n+ autoSave?: string\n+ color?: string\n+ itemProp?: string\n+ itemScope?: boolean\n+ itemType?: string\n+ itemID?: string\n+ itemRef?: string\n+ results?: number\n+ security?: string\n+ unselectable?: 'on' | 'off'\n+ 'aria-activedescendant'?: string\n+ 'aria-atomic'?: boolean | 'false' | 'true'\n+ 'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both'\n+ 'aria-busy'?: boolean | 'false' | 'true'\n+ 'aria-checked'?: boolean | 'false' | 'true' | 'mixed'\n+ 'aria-colcount'?: number\n+ 'aria-colindex'?: number\n+ 'aria-colspan'?: number\n+ 'aria-controls'?: string\n+ 'aria-current'?:\n+ | boolean\n+ | 'time'\n+ | 'false'\n+ | 'true'\n+ | 'page'\n+ | 'step'\n+ | 'location'\n+ | 'date'\n+ 'aria-describedby'?: string\n+ 'aria-details'?: string\n+ 'aria-disabled'?: boolean | 'false' | 'true'\n+ 'aria-dropeffect'?:\n+ | 'link'\n+ | 'none'\n+ | 'copy'\n+ | 'execute'\n+ | 'move'\n+ | 'popup'\n+ 'aria-errormessage'?: string\n+ 'aria-expanded'?: boolean | 'false' | 'true'\n+ 'aria-flowto'?: string\n+ 'aria-grabbed'?: boolean | 'false' | 'true'\n+ 'aria-haspopup'?:\n+ | boolean\n+ | 'dialog'\n+ | 'menu'\n+ | 'false'\n+ | 'true'\n+ | 'listbox'\n+ | 'tree'\n+ | 'grid'\n+ 'aria-hidden'?: boolean | 'false' | 'true'\n+ 'aria-invalid'?: boolean | 'false' | 'true' | 'grammar' | 'spelling'\n+ 'aria-keyshortcuts'?: string\n+ 'aria-label'?: string\n+ 'aria-labelledby'?: string\n+ 'aria-level'?: number\n+ 'aria-live'?: 'off' | 'assertive' | 'polite'\n+ 'aria-modal'?: boolean | 'false' | 'true'\n+ 'aria-multiline'?: boolean | 'false' | 'true'\n+ 'aria-multiselectable'?: boolean | 'false' | 'true'\n+ 'aria-orientation'?: 'horizontal' | 'vertical'\n+ 'aria-owns'?: string\n+ 'aria-placeholder'?: string\n+ 'aria-posinset'?: number\n+ 'aria-pressed'?: boolean | 'false' | 'true' | 'mixed'\n+ 'aria-readonly'?: boolean | 'false' | 'true'\n+ 'aria-relevant'?:\n+ | 'additions'\n+ | 'additions text'\n+ | 'all'\n+ | 'removals'\n+ | 'text'\n+ 'aria-required'?: boolean | 'false' | 'true'\n+ 'aria-roledescription'?: string\n+ 'aria-rowcount'?: number\n+ 'aria-rowindex'?: number\n+ 'aria-rowspan'?: number\n+ 'aria-selected'?: boolean | 'false' | 'true'\n+ 'aria-setsize'?: number\n+ 'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other'\n+ 'aria-valuemax'?: number\n+ 'aria-valuemin'?: number\n+ 'aria-valuenow'?: number\n+ 'aria-valuetext'?: string\n+ dangerouslySetInnerHTML?: {\n+ __html: string\n+ }\n+ onCopy?: (event: React.ClipboardEvent<HTMLAnchorElement>) => void\n+ onCopyCapture?: (\n+ event: React.ClipboardEvent<HTMLAnchorElement>\n+ ) => void\n+ onCut?: (event: React.ClipboardEvent<HTMLAnchorElement>) => void\n+ onCutCapture?: (\n+ event: React.ClipboardEvent<HTMLAnchorElement>\n+ ) => void\n+ onPaste?: (event: React.ClipboardEvent<HTMLAnchorElement>) => void\n+ onPasteCapture?: (\n+ event: React.ClipboardEvent<HTMLAnchorElement>\n+ ) => void\n+ onCompositionEnd?: (\n+ event: React.CompositionEvent<HTMLAnchorElement>\n+ ) => void\n+ onCompositionEndCapture?: (\n+ event: React.CompositionEvent<HTMLAnchorElement>\n+ ) => void\n+ onCompositionStart?: (\n+ event: React.CompositionEvent<HTMLAnchorElement>\n+ ) => void\n+ onCompositionStartCapture?: (\n+ event: React.CompositionEvent<HTMLAnchorElement>\n+ ) => void\n+ onCompositionUpdate?: (\n+ event: React.CompositionEvent<HTMLAnchorElement>\n+ ) => void\n+ onCompositionUpdateCapture?: (\n+ event: React.CompositionEvent<HTMLAnchorElement>\n+ ) => void\n+ onFocus?: (event: React.FocusEvent<HTMLAnchorElement>) => void\n+ onFocusCapture?: (\n+ event: React.FocusEvent<HTMLAnchorElement>\n+ ) => void\n+ onBlur?: (event: React.FocusEvent<HTMLAnchorElement>) => void\n+ onBlurCapture?: (event: React.FocusEvent<HTMLAnchorElement>) => void\n+ onChange?: (event: React.FormEvent<HTMLAnchorElement>) => void\n+ onChangeCapture?: (\n+ event: React.FormEvent<HTMLAnchorElement>\n+ ) => void\n+ onInput?: (event: React.FormEvent<HTMLAnchorElement>) => void\n+ onInputCapture?: (event: React.FormEvent<HTMLAnchorElement>) => void\n+ onReset?: (event: React.FormEvent<HTMLAnchorElement>) => void\n+ onResetCapture?: (event: React.FormEvent<HTMLAnchorElement>) => void\n+ onSubmit?: (event: React.FormEvent<HTMLAnchorElement>) => void\n+ onSubmitCapture?: (\n+ event: React.FormEvent<HTMLAnchorElement>\n+ ) => void\n+ onInvalid?: (event: React.FormEvent<HTMLAnchorElement>) => void\n+ onInvalidCapture?: (\n+ event: React.FormEvent<HTMLAnchorElement>\n+ ) => void\n+ onLoad?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onLoadCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onError?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onErrorCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onKeyDown?: (event: React.KeyboardEvent<HTMLAnchorElement>) => void\n+ onKeyDownCapture?: (\n+ event: React.KeyboardEvent<HTMLAnchorElement>\n+ ) => void\n+ onKeyPress?: (event: React.KeyboardEvent<HTMLAnchorElement>) => void\n+ onKeyPressCapture?: (\n+ event: React.KeyboardEvent<HTMLAnchorElement>\n+ ) => void\n+ onKeyUp?: (event: React.KeyboardEvent<HTMLAnchorElement>) => void\n+ onKeyUpCapture?: (\n+ event: React.KeyboardEvent<HTMLAnchorElement>\n+ ) => void\n+ onAbort?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onAbortCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onCanPlay?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onCanPlayCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onCanPlayThrough?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onCanPlayThroughCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onDurationChange?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onDurationChangeCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onEmptied?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onEmptiedCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onEncrypted?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onEncryptedCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onEnded?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onEndedCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onLoadedData?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onLoadedDataCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onLoadedMetadata?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onLoadedMetadataCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onLoadStart?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onLoadStartCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onPause?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onPauseCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onPlay?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onPlayCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onPlaying?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onPlayingCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onProgress?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onProgressCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onRateChange?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onRateChangeCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onSeeked?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onSeekedCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onSeeking?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onSeekingCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onStalled?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onStalledCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onSuspend?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onSuspendCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onTimeUpdate?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onTimeUpdateCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onVolumeChange?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onVolumeChangeCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onWaiting?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onWaitingCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onClickCapture?: (\n+ event: React.MouseEvent<HTMLAnchorElement>\n+ ) => void\n+ onContextMenu?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n+ onContextMenuCapture?: (\n+ event: React.MouseEvent<HTMLAnchorElement>\n+ ) => void\n+ onDoubleClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n+ onDoubleClickCapture?: (\n+ event: React.MouseEvent<HTMLAnchorElement>\n+ ) => void\n+ onDrag?: (event: React.DragEvent<HTMLAnchorElement>) => void\n+ onDragCapture?: (event: React.DragEvent<HTMLAnchorElement>) => void\n+ onDragEnd?: (event: React.DragEvent<HTMLAnchorElement>) => void\n+ onDragEndCapture?: (\n+ event: React.DragEvent<HTMLAnchorElement>\n+ ) => void\n+ onDragEnter?: (event: React.DragEvent<HTMLAnchorElement>) => void\n+ onDragEnterCapture?: (\n+ event: React.DragEvent<HTMLAnchorElement>\n+ ) => void\n+ onDragExit?: (event: React.DragEvent<HTMLAnchorElement>) => void\n+ onDragExitCapture?: (\n+ event: React.DragEvent<HTMLAnchorElement>\n+ ) => void\n+ onDragLeave?: (event: React.DragEvent<HTMLAnchorElement>) => void\n+ onDragLeaveCapture?: (\n+ event: React.DragEvent<HTMLAnchorElement>\n+ ) => void\n+ onDragOver?: (event: React.DragEvent<HTMLAnchorElement>) => void\n+ onDragOverCapture?: (\n+ event: React.DragEvent<HTMLAnchorElement>\n+ ) => void\n+ onDragStart?: (event: React.DragEvent<HTMLAnchorElement>) => void\n+ onDragStartCapture?: (\n+ event: React.DragEvent<HTMLAnchorElement>\n+ ) => void\n+ onDrop?: (event: React.DragEvent<HTMLAnchorElement>) => void\n+ onDropCapture?: (event: React.DragEvent<HTMLAnchorElement>) => void\n+ onMouseDown?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n+ onMouseDownCapture?: (\n+ event: React.MouseEvent<HTMLAnchorElement>\n+ ) => void\n+ onMouseEnter?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n+ onMouseLeave?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n+ onMouseMove?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n+ onMouseMoveCapture?: (\n+ event: React.MouseEvent<HTMLAnchorElement>\n+ ) => void\n+ onMouseOut?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n+ onMouseOutCapture?: (\n+ event: React.MouseEvent<HTMLAnchorElement>\n+ ) => void\n+ onMouseOverCapture?: (\n+ event: React.MouseEvent<HTMLAnchorElement>\n+ ) => void\n+ onMouseUp?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n+ onMouseUpCapture?: (\n+ event: React.MouseEvent<HTMLAnchorElement>\n+ ) => void\n+ onSelect?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n+ onSelectCapture?: (\n+ event: React.SyntheticEvent<HTMLAnchorElement>\n+ ) => void\n+ onTouchCancel?: (event: React.TouchEvent<HTMLAnchorElement>) => void\n+ onTouchCancelCapture?: (\n+ event: React.TouchEvent<HTMLAnchorElement>\n+ ) => void\n+ onTouchEnd?: (event: React.TouchEvent<HTMLAnchorElement>) => void\n+ onTouchEndCapture?: (\n+ event: React.TouchEvent<HTMLAnchorElement>\n+ ) => void\n+ onTouchMove?: (event: React.TouchEvent<HTMLAnchorElement>) => void\n+ onTouchMoveCapture?: (\n+ event: React.TouchEvent<HTMLAnchorElement>\n+ ) => void\n+ onTouchStart?: (event: React.TouchEvent<HTMLAnchorElement>) => void\n+ onTouchStartCapture?: (\n+ event: React.TouchEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerDown?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerDownCapture?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerMove?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerMoveCapture?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerUp?: (event: React.PointerEvent<HTMLAnchorElement>) => void\n+ onPointerUpCapture?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerCancel?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerCancelCapture?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerEnter?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerEnterCapture?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerLeave?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerLeaveCapture?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerOver?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerOverCapture?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerOut?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onPointerOutCapture?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onGotPointerCapture?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onGotPointerCaptureCapture?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onLostPointerCapture?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onLostPointerCaptureCapture?: (\n+ event: React.PointerEvent<HTMLAnchorElement>\n+ ) => void\n+ onScroll?: (event: React.UIEvent<HTMLAnchorElement>) => void\n+ onScrollCapture?: (event: React.UIEvent<HTMLAnchorElement>) => void\n+ onWheel?: (event: React.WheelEvent<HTMLAnchorElement>) => void\n+ onWheelCapture?: (\n+ event: React.WheelEvent<HTMLAnchorElement>\n+ ) => void\n+ onAnimationStart?: (\n+ event: React.AnimationEvent<HTMLAnchorElement>\n+ ) => void\n+ onAnimationStartCapture?: (\n+ event: React.AnimationEvent<HTMLAnchorElement>\n+ ) => void\n+ onAnimationEnd?: (\n+ event: React.AnimationEvent<HTMLAnchorElement>\n+ ) => void\n+ onAnimationEndCapture?: (\n+ event: React.AnimationEvent<HTMLAnchorElement>\n+ ) => void\n+ onAnimationIteration?: (\n+ event: React.AnimationEvent<HTMLAnchorElement>\n+ ) => void\n+ onAnimationIterationCapture?: (\n+ event: React.AnimationEvent<HTMLAnchorElement>\n+ ) => void\n+ onTransitionEnd?: (\n+ event: React.TransitionEvent<HTMLAnchorElement>\n+ ) => void\n+ onTransitionEndCapture?: (\n+ event: React.TransitionEvent<HTMLAnchorElement>\n+ ) => void\n+ },\n+ HTMLElement\n+ >\n+}\n+export default BaseLink\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/types/RouteProvider.d.ts",
"diff": "+import React, { ReactNode } from 'react'\n+import { Router } from 'router5'\n+import { RouterContext } from './types'\n+declare const Route: any\n+export interface RouteProviderProps {\n+ router: Router\n+ children: ReactNode\n+}\n+declare class RouteProvider extends React.PureComponent<RouteProviderProps> {\n+ private mounted\n+ private router\n+ private routeState\n+ private unsubscribe\n+ constructor(props: any)\n+ componentDidMount(): void\n+ componentWillUnmount(): void\n+ getChildContext(): {\n+ router: Router\n+ }\n+ render(): JSX.Element\n+}\n+export interface RouteNodeProps {\n+ nodeName: string\n+ children: (routeContext: RouterContext) => ReactNode\n+}\n+declare class RouteNode extends React.Component<RouteNodeProps> {\n+ private memoizedResult\n+ constructor(props: any, context: any)\n+ renderOnRouteNodeChange(routeContext: any): React.ReactNode\n+ render(): JSX.Element\n+}\n+export { RouteProvider, Route, RouteNode }\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/types/RouterProvider.d.ts",
"diff": "+import { Component, ReactNode } from 'react'\n+import { Router } from 'router5'\n+interface RouterProviderProps {\n+ router?: Router\n+ children: ReactNode\n+}\n+declare class RouterProvider extends Component<RouterProviderProps> {\n+ private router\n+ constructor(props: any, context: any)\n+ getChildContext(): {\n+ router: Router\n+ }\n+ render(): import('react').ReactElement<any>\n+}\n+export default RouterProvider\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/types/index.d.ts",
"diff": "+/// <reference types=\"react\" />\n+import BaseLink from './BaseLink'\n+import routeNode from './routeNode'\n+import RouterProvider from './RouterProvider'\n+import withRoute from './withRoute'\n+import withRouter from './withRouter'\n+import { RouteProvider, Route, RouteNode } from './RouteProvider'\n+declare const Link: import('react').ComponentClass<any, any>\n+export {\n+ BaseLink,\n+ routeNode,\n+ RouterProvider,\n+ withRoute,\n+ withRouter,\n+ Link,\n+ RouteProvider,\n+ Route,\n+ RouteNode\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/types/routeNode.d.ts",
"diff": "+import { ComponentClass } from 'react'\n+import { RouterContext } from './types'\n+declare function routeNode<P>(\n+ nodeName: string\n+): (\n+ RouteSegment: import('react').ComponentType<P & RouterContext>\n+) => ComponentClass<P, any>\n+export default routeNode\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/types/types.d.ts",
"diff": "+import { Router, State } from 'router5'\n+export interface RouterContext {\n+ router: Router\n+ route: State\n+ previousRoute: State | null\n+}\n+export interface RouterState {\n+ route: State\n+ previousRoute: State | null\n+}\n+export declare type UnsubscribeFn = () => void\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/types/withRoute.d.ts",
"diff": "+import { ComponentClass } from 'react'\n+import { RouterState } from './types'\n+declare function withRoute<P>(\n+ BaseComponent: React.ComponentType<P & RouterState>\n+): ComponentClass<P>\n+export default withRoute\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/types/withRouter.d.ts",
"diff": "+import { ComponentClass } from 'react'\n+import { Router } from 'router5'\n+declare function withRouter<P>(\n+ BaseComponent: ComponentClass<\n+ P,\n+ {\n+ router: Router\n+ }\n+ >\n+): ComponentClass<P>\n+export default withRouter\n"
},
{
"change_type": "MODIFY",
"old_path": "rollup.config.js",
"new_path": "rollup.config.js",
"diff": "@@ -49,7 +49,10 @@ const makeConfig = ({\n? Object.keys(\nrequire(`./packages/${packageName}/package.json`)\n.dependencies || {}\n- )\n+ ).concat(Object.keys(\n+ require(`./packages/${packageName}/package.json`)\n+ .peerDependencies || {}\n+ ))\n: [],\nplugins\n}\n@@ -88,6 +91,7 @@ module.exports = [\n...makePackageConfig('router5-plugin-persistent-params'),\n...makePackageConfig('rxjs-router5'),\n...makePackageConfig('xstream-router5'),\n+ ...makePackageConfig('react-router5'),\n...makePackageConfig('redux-router5'),\n...makePackageConfig('redux-router5-immutable'),\n]\n"
}
] | TypeScript | MIT License | router5/router5 | chore: build react-router5 with rollup |
580,249 | 30.11.2018 20:47:06 | 0 | ef4eebb434e27106b35e9c849b2a316eb82b08b5 | refactor: use new context API for all components, keep legacy ones | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/BaseLink.ts",
"new_path": "packages/react-router5/modules/BaseLink.ts",
"diff": "import { NavigationOptions, State, Router } from 'router5'\nimport React, { Component, HTMLAttributes, MouseEventHandler } from 'react'\nimport PropTypes from 'prop-types'\n+import { routerContext } from './context'\nexport interface BaseLinkProps extends HTMLAttributes<HTMLAnchorElement> {\nrouteName: string\n@@ -25,11 +26,13 @@ export interface BaseLinkState {\n}\nclass BaseLink extends Component<BaseLinkProps, BaseLinkState> {\n+ static contextType = routerContext\npublic router: Router\n+\nconstructor(props, context) {\nsuper(props, context)\n- this.router = context.router\n+ this.router = context\nif (!this.router.hasPlugin('BROWSER_PLUGIN')) {\nconsole.error(\n@@ -145,8 +148,4 @@ class BaseLink extends Component<BaseLinkProps, BaseLinkState> {\n}\n}\n-BaseLink.contextTypes = {\n- router: PropTypes.object.isRequired\n-}\n-\nexport default BaseLink\n"
},
{
"change_type": "DELETE",
"old_path": "packages/react-router5/modules/RouteProvider.tsx",
"new_path": null,
"diff": "-import React, { ReactNode } from 'react'\n-import PropTypes from 'prop-types'\n-import { shouldUpdateNode } from 'router5-transition-path'\n-import { State, Router } from 'router5'\n-import { RouterContext, RouterState, UnsubscribeFn } from './types';\n-\n-const emptyCreateContext = () => ({\n- Provider: ({ children }) => children,\n- Consumer: () => null\n-})\n-\n-\n-const createContext = React.createContext || emptyCreateContext\n-//@ts-ignore\n-const { Provider, Consumer: Route } = createContext<RouterContext>({})\n-\n-export interface RouteProviderProps {\n- router: Router\n- children: ReactNode\n-}\n-\n-class RouteProvider extends React.PureComponent<RouteProviderProps> {\n- private mounted: boolean\n- private router: Router\n- private routeState: RouterState\n- private unsubscribe: UnsubscribeFn\n-\n- constructor(props) {\n- super(props)\n- const { router } = props\n- this.mounted = false\n- this.router = router\n- this.routeState = {\n- route: router.getState(),\n- previousRoute: null\n- }\n-\n- if (typeof window !== 'undefined') {\n- const listener = ({ route, previousRoute }) => {\n- this.routeState = {\n- route,\n- previousRoute\n- }\n- if (this.mounted) {\n- this.forceUpdate()\n- }\n- }\n- this.unsubscribe = this.router.subscribe(listener) as UnsubscribeFn\n- }\n- }\n-\n- componentDidMount() {\n- this.mounted = true\n- }\n-\n- componentWillUnmount() {\n- if (this.unsubscribe) {\n- this.unsubscribe()\n- }\n- }\n-\n- getChildContext() {\n- return { router: this.props.router }\n- }\n-\n- render() {\n- const value = {\n- router: this.props.router,\n- ...this.routeState\n- }\n- return <Provider value={value}>{this.props.children}</Provider>\n- }\n-}\n-\n-RouteProvider.childContextTypes = {\n- router: PropTypes.object.isRequired\n-}\n-\n-export interface RouteNodeProps {\n- nodeName: string\n- children: (routeContext: RouterContext) => ReactNode\n-}\n-\n-class RouteNode extends React.Component<RouteNodeProps> {\n- private memoizedResult: ReactNode\n-\n- constructor(props, context) {\n- super(props, context)\n-\n- this.renderOnRouteNodeChange = this.renderOnRouteNodeChange.bind(this)\n- }\n-\n- renderOnRouteNodeChange(routeContext) {\n- const shouldUpdate = shouldUpdateNode(this.props.nodeName)(\n- routeContext.route,\n- routeContext.previousRoute\n- )\n-\n- if (!this.memoizedResult || shouldUpdate) {\n- this.memoizedResult = this.props.children(routeContext)\n- }\n-\n- return this.memoizedResult\n- }\n-\n- render() {\n- return <Route>{this.renderOnRouteNodeChange}</Route>\n- }\n-}\n-\n-export { RouteProvider, Route, RouteNode }\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/RouterProvider.tsx",
"diff": "+import React, { ReactNode } from 'react'\n+import { UnsubscribeFn, RouterState } from './types'\n+import { Router } from 'router5'\n+import { routerContext, routeContext } from './context'\n+\n+export interface RouteProviderProps {\n+ router: Router\n+ children: ReactNode\n+}\n+\n+class RouterProvider extends React.PureComponent<RouteProviderProps> {\n+ private mounted: boolean\n+ private routeState: RouterState\n+ private unsubscribe: UnsubscribeFn\n+\n+ constructor(props) {\n+ super(props)\n+ this.mounted = false\n+ this.routeState = {\n+ route: props.router.getState(),\n+ previousRoute: null\n+ }\n+\n+ if (typeof window !== 'undefined') {\n+ const listener = ({ route, previousRoute }) => {\n+ this.routeState = {\n+ route,\n+ previousRoute\n+ }\n+ if (this.mounted) {\n+ this.forceUpdate()\n+ }\n+ }\n+ this.unsubscribe = this.props.router.subscribe(\n+ listener\n+ ) as UnsubscribeFn\n+ }\n+ }\n+\n+ componentDidMount() {\n+ this.mounted = true\n+ }\n+\n+ componentWillUnmount() {\n+ if (this.unsubscribe) {\n+ this.unsubscribe()\n+ }\n+ }\n+\n+ render() {\n+ return (\n+ <routerContext.Provider value={this.props.router}>\n+ <routeContext.Provider\n+ value={{ router: this.props.router, ...this.routeState }}\n+ >\n+ {this.props.children}\n+ </routeContext.Provider>\n+ </routerContext.Provider>\n+ )\n+ }\n+}\n+\n+export default RouterProvider\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/context.ts",
"diff": "+import React from 'react'\n+import { RouteContext } from './types'\n+import { Router } from 'router5'\n+\n+const createContext = React.createContext\n+export const routeContext = createContext<RouteContext>(null)\n+export const routerContext = createContext<Router>(null)\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/hocs/routeNode.tsx",
"diff": "+import React, { SFC, ComponentType } from 'react'\n+import { RouteContext } from '../types'\n+import RouteNode from '../render/RouteNode'\n+\n+function routeNode<P>(nodeName: string) {\n+ return function(BaseComponent: ComponentType<P & RouteContext>): SFC<P> {\n+ function RouteNode(props) {\n+ return (\n+ <RouteNode nodeName={nodeName}>\n+ {routeContext => (\n+ <BaseComponent {...props} {...routeContext} />\n+ )}\n+ </RouteNode>\n+ )\n+ }\n+\n+ return RouteNode\n+ }\n+}\n+\n+export default routeNode\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/hocs/withRoute.tsx",
"diff": "+import React, { SFC, ComponentType } from 'react'\n+import { routeContext } from '../context'\n+import { RouteContext } from '../types'\n+\n+function withRoute<P>(BaseComponent: ComponentType<P & RouteContext>): SFC<P> {\n+ return function withRoute(props) {\n+ return (\n+ <routeContext.Consumer>\n+ {routeContext => <BaseComponent {...props} {...routeContext} />}\n+ </routeContext.Consumer>\n+ )\n+ }\n+}\n+\n+export default withRoute\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/hocs/withRouter.tsx",
"diff": "+import React, { SFC, ComponentType } from 'react'\n+import { Router } from 'router5'\n+import { routerContext } from '../context'\n+\n+function withRouter<P>(\n+ BaseComponent: ComponentType<P & { router: Router }>\n+): SFC<P> {\n+ return function WithRouter(props) {\n+ return (\n+ <routerContext.Consumer>\n+ {router => <BaseComponent {...props} router={router} />}\n+ </routerContext.Consumer>\n+ )\n+ }\n+}\n+\n+export default withRouter\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/index.ts",
"new_path": "packages/react-router5/modules/index.ts",
"diff": "import BaseLink from './BaseLink'\n-import routeNode from './routeNode'\n+import routeNode from './hocs/routeNode'\n+import withRoute from './hocs/withRoute'\n+import withRouter from './hocs/withRouter'\n+import RouteNode from './render/RouteNode'\nimport RouterProvider from './RouterProvider'\n-import withRoute from './withRoute'\n-import withRouter from './withRouter'\n-import { RouteProvider, Route, RouteNode } from './RouteProvider'\n+\n+export { routerContext, routeContext } from './context'\nconst Link = withRoute(BaseLink)\nexport {\nBaseLink,\nrouteNode,\n- RouterProvider,\nwithRoute,\nwithRouter,\nLink,\n- RouteProvider,\n- Route,\n- RouteNode\n+ RouteNode,\n+ RouterProvider\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/legacy/BaseLink.ts",
"diff": "+import { NavigationOptions, State, Router } from 'router5'\n+import React, { Component, HTMLAttributes, MouseEventHandler } from 'react'\n+import PropTypes from 'prop-types'\n+\n+export interface BaseLinkProps extends HTMLAttributes<HTMLAnchorElement> {\n+ routeName: string\n+ routeParams?: { [key: string]: any }\n+ routeOptions?: NavigationOptions\n+ className?: string\n+ activeClassName?: string\n+ activeStrict?: boolean\n+ ignoreQueryParams?: boolean\n+ onClick?: MouseEventHandler<HTMLAnchorElement>\n+ onMouseOver?: MouseEventHandler<HTMLAnchorElement>\n+ successCallback?(state?: State): void\n+ errorCallback?(error?: any): void\n+ target?: string\n+ route?: State\n+ previousRoute?: State\n+ router?: Router\n+}\n+\n+export interface BaseLinkState {\n+ active: boolean\n+}\n+\n+class BaseLink extends Component<BaseLinkProps, BaseLinkState> {\n+ public router: Router\n+ constructor(props, context) {\n+ super(props, context)\n+\n+ this.router = context.router\n+\n+ if (!this.router.hasPlugin('BROWSER_PLUGIN')) {\n+ console.error(\n+ '[react-router5][BaseLink] missing browser plugin, href might be built incorrectly'\n+ )\n+ }\n+\n+ this.isActive = this.isActive.bind(this)\n+ this.clickHandler = this.clickHandler.bind(this)\n+ this.callback = this.callback.bind(this)\n+\n+ this.state = { active: this.isActive() }\n+ }\n+\n+ buildUrl(routeName, routeParams) {\n+ //@ts-ignore\n+ if (this.router.buildUrl) {\n+ //@ts-ignore\n+ return this.router.buildUrl(routeName, routeParams)\n+ }\n+\n+ return this.router.buildPath(routeName, routeParams)\n+ }\n+\n+ isActive() {\n+ const {\n+ routeName,\n+ routeParams = {},\n+ activeStrict = false,\n+ ignoreQueryParams = true\n+ } = this.props\n+\n+ return this.router.isActive(\n+ routeName,\n+ routeParams,\n+ activeStrict,\n+ ignoreQueryParams\n+ )\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+\n+ clickHandler(evt) {\n+ const { onClick, target } = this.props\n+\n+ if (onClick) {\n+ onClick(evt)\n+\n+ if (evt.defaultPrevented) {\n+ return\n+ }\n+ }\n+\n+ const comboKey =\n+ evt.metaKey || evt.altKey || evt.ctrlKey || evt.shiftKey\n+\n+ if (evt.button === 0 && !comboKey && target !== '_blank') {\n+ evt.preventDefault()\n+ this.router.navigate(\n+ this.props.routeName,\n+ this.props.routeParams || {},\n+ this.props.routeOptions || {},\n+ this.callback\n+ )\n+ }\n+ }\n+\n+ render() {\n+ /* eslint-disable */\n+ const {\n+ routeName,\n+ routeParams,\n+ routeOptions,\n+ className,\n+ activeClassName = 'active',\n+ activeStrict,\n+ ignoreQueryParams,\n+ route,\n+ previousRoute,\n+ router,\n+ children,\n+ onClick,\n+ successCallback,\n+ errorCallback,\n+ ...linkProps\n+ } = this.props\n+ /* eslint-enable */\n+\n+ const active = this.isActive()\n+ const href = this.buildUrl(routeName, routeParams)\n+ const linkclassName = (active ? [activeClassName] : [])\n+ .concat(className ? className.split(' ') : [])\n+ .join(' ')\n+\n+ return React.createElement(\n+ 'a',\n+ {\n+ ...linkProps,\n+ href,\n+ className: linkclassName,\n+ onClick: this.clickHandler\n+ },\n+ children\n+ )\n+ }\n+}\n+\n+BaseLink.contextTypes = {\n+ router: PropTypes.object.isRequired\n+}\n+\n+export default BaseLink\n"
},
{
"change_type": "RENAME",
"old_path": "packages/react-router5/modules/RouterProvider.ts",
"new_path": "packages/react-router5/modules/legacy/RouterProvider.ts",
"diff": ""
},
{
"change_type": "RENAME",
"old_path": "packages/react-router5/modules/routeNode.ts",
"new_path": "packages/react-router5/modules/legacy/routeNode.ts",
"diff": "import { Component, createElement, ComponentClass } from 'react'\nimport PropTypes from 'prop-types'\nimport { shouldUpdateNode } from 'router5-transition-path'\n-import { RouterState, RouterContext, UnsubscribeFn } from './types'\n+import { RouterState, RouteContext, UnsubscribeFn } from '../types'\nimport { Router } from 'router5'\nfunction routeNode<P>(nodeName: string) {\nreturn function routeNodeWrapper(\n- RouteSegment: React.ComponentType<P & RouterContext>\n+ RouteSegment: React.ComponentType<P & RouteContext>\n): ComponentClass<P> {\nclass RouteNode extends Component<P> {\nprivate router: Router\n"
},
{
"change_type": "RENAME",
"old_path": "packages/react-router5/modules/withRoute.ts",
"new_path": "packages/react-router5/modules/legacy/withRoute.ts",
"diff": "import { Component, createElement, ComponentClass } from 'react'\nimport PropTypes from 'prop-types'\nimport { Router } from 'router5'\n-import { RouterState, UnsubscribeFn } from './types'\n+import { RouterState, UnsubscribeFn } from '../types'\nfunction withRoute<P>(\nBaseComponent: React.ComponentType<P & RouterState>\n"
},
{
"change_type": "RENAME",
"old_path": "packages/react-router5/modules/withRouter.ts",
"new_path": "packages/react-router5/modules/legacy/withRouter.ts",
"diff": "-import { Component, createElement, ComponentClass } from 'react'\n+import { Component, createElement, ComponentClass, ComponentType } from 'react'\nimport PropTypes from 'prop-types'\nimport { Router } from 'router5'\nfunction withRouter<P>(\n- BaseComponent: ComponentClass<P, { router: Router }>\n+ BaseComponent: ComponentType<P & { router: Router }>\n): ComponentClass<P> {\nclass WithRouter extends Component<P> {\nprivate router: Router\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/render/RouteNode.tsx",
"diff": "+import React, { ReactNode, ReactElement } from 'react'\n+import { shouldUpdateNode } from 'router5-transition-path'\n+import { RouteContext } from '../types'\n+import { routeContext } from '../context'\n+\n+export interface RouteNodeProps {\n+ nodeName: string\n+ children: (routeContext: RouteContext) => ReactNode\n+}\n+\n+class RouteNode extends React.Component<RouteNodeProps> {\n+ private memoizedResult: ReactNode\n+\n+ constructor(props, context) {\n+ super(props, context)\n+\n+ this.renderOnRouteNodeChange = this.renderOnRouteNodeChange.bind(this)\n+ }\n+\n+ renderOnRouteNodeChange(routeContext) {\n+ const shouldUpdate = shouldUpdateNode(this.props.nodeName)(\n+ routeContext.route,\n+ routeContext.previousRoute\n+ )\n+\n+ if (!this.memoizedResult || shouldUpdate) {\n+ this.memoizedResult = this.props.children(routeContext)\n+ }\n+\n+ return this.memoizedResult\n+ }\n+\n+ render() {\n+ return (\n+ <routeContext.Consumer>\n+ {this.renderOnRouteNodeChange}\n+ </routeContext.Consumer>\n+ )\n+ }\n+}\n+\n+export default RouteNode\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/types.ts",
"new_path": "packages/react-router5/modules/types.ts",
"diff": "import { Router, State } from 'router5'\n-export interface RouterContext {\n+export type RouteContext = {\nrouter: Router\n- route: State\n- previousRoute: State | null\n-}\n+} & RouterState\nexport interface RouterState {\nroute: State\n"
}
] | TypeScript | MIT License | router5/router5 | refactor: use new context API for all components, keep legacy ones |
580,249 | 30.11.2018 21:10:29 | 0 | 0a639e6f9773f907d0ee59f3b486097ac0e7043f | feat: introduce React hooks | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"homepage\": \"https://router5.js.org\",\n\"devDependencies\": {\n\"@types/jest\": \"~23.3.10\",\n+ \"@types/react\": \"~16.7.10\",\n\"conventional-changelog\": \"~1.1.3\",\n\"enzyme\": \"~3.7.0\",\n\"express\": \"~4.16.4\",\n\"lint-staged\": \"~8.1.0\",\n\"most\": \"~1.7.3\",\n\"prettier\": \"~1.15.2\",\n- \"react\": \"~16.6.3\",\n+ \"react\": \"~16.7.0-alpha.2\",\n\"react-addons-test-utils\": \"~15.6.2\",\n- \"react-dom\": \"~16.6.3\",\n+ \"react-dom\": \"~16.7.0-alpha.2\",\n\"rimraf\": \"~2.6.1\",\n\"rollup\": \"~0.67.3\",\n\"rollup-plugin-commonjs\": \"~9.2.0\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/hooks/useRoute.ts",
"diff": "+import { useContext } from 'react'\n+import { routeContext } from '../context'\n+import { RouteContext } from '../types'\n+\n+export default function useRoute(): RouteContext {\n+ return useContext(routeContext)\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/hooks/useRouteNode.ts",
"diff": "+import { shouldUpdateNode } from 'router5-transition-path'\n+import { useContext, useEffect, useState } from 'react'\n+import { routerContext } from '../context'\n+import { RouteContext } from '../types'\n+\n+export type UnsubscribeFn = () => void\n+\n+export default function useRouter(nodeName: string): RouteContext {\n+ const router = useContext(routerContext)\n+ const [state, setState] = useState({\n+ previousRoute: null,\n+ route: null\n+ })\n+\n+ useEffect(\n+ () =>\n+ router.subscribe(({ route, previousRoute }) => {\n+ const shouldUpdate = shouldUpdateNode(nodeName)(\n+ route,\n+ previousRoute\n+ )\n+\n+ if (shouldUpdate) {\n+ setState({\n+ route,\n+ previousRoute\n+ })\n+ }\n+ }) as UnsubscribeFn,\n+ []\n+ )\n+\n+ return { router, ...state }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/hooks/useRouter.ts",
"diff": "+import { useContext } from 'react'\n+import { routerContext } from '../context'\n+import { Router } from 'router5'\n+\n+export default function useRouter(): Router {\n+ return useContext(routerContext)\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/index.ts",
"new_path": "packages/react-router5/modules/index.ts",
"diff": "+import RouterProvider from './RouterProvider'\n+export { routerContext, routeContext } from './context'\nimport BaseLink from './BaseLink'\n-import routeNode from './hocs/routeNode'\n-import withRoute from './hocs/withRoute'\nimport withRouter from './hocs/withRouter'\n+import withRoute from './hocs/withRoute'\n+import routeNode from './hocs/routeNode'\nimport RouteNode from './render/RouteNode'\n-import RouterProvider from './RouterProvider'\n-\n-export { routerContext, routeContext } from './context'\n+import useRouter from './hooks/useRouter'\n+import useRoute from './hooks/useRoute'\n+import useRouteNode from './hooks/useRouteNode'\nconst Link = withRoute(BaseLink)\nexport {\n+ RouterProvider,\nBaseLink,\n- routeNode,\n- withRoute,\n- withRouter,\nLink,\n+ withRouter,\n+ withRoute,\n+ routeNode,\nRouteNode,\n- RouterProvider\n+ useRouter,\n+ useRoute,\n+ useRouteNode\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/package.json",
"new_path": "packages/react-router5/package.json",
"diff": "},\n\"homepage\": \"https://router5.js.org\",\n\"devDependencies\": {\n- \"@types/react\": \"~16.7.10\",\n\"enzyme-adapter-react-16\": \"~1.7.0\",\n\"router5\": \"^6.6.2\"\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "yarn.lock",
"new_path": "yarn.lock",
"diff": "resolved \"https://registry.yarnpkg.com/@types/node/-/node-10.12.10.tgz#4fa76e6598b7de3f0cb6ec3abacc4f59e5b3a2ce\"\nintegrity sha512-8xZEYckCbUVgK8Eg7lf5Iy4COKJ5uXlnIOnePN0WUwSQggy9tolM+tDJf7wMOnT/JT/W9xDYIaYggt3mRV2O5w==\n+\"@types/prop-types@*\":\n+ version \"15.5.6\"\n+ resolved \"https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.5.6.tgz#9c03d3fed70a8d517c191b7734da2879b50ca26c\"\n+ integrity sha512-ZBFR7TROLVzCkswA3Fmqq+IIJt62/T7aY/Dmz+QkU7CaW2QFqAitCE8Ups7IzmGhcN1YWMBT4Qcoc07jU9hOJQ==\n+\n+\"@types/react@~16.7.10\":\n+ version \"16.7.10\"\n+ resolved \"https://registry.yarnpkg.com/@types/react/-/react-16.7.10.tgz#a0ebd3af6632d6997506f6d1aac67fed8d0851b0\"\n+ integrity sha512-8EFSjCFLUA7JJQ6lJ9+9/99urIrdHACwH8GqPlYAPyIjxOkz2snkttOzItwUwXgqc2xg+r/IYW8M1J8WXax7xg==\n+ dependencies:\n+ \"@types/prop-types\" \"*\"\n+ csstype \"^2.2.0\"\n+\n\"@webassemblyjs/[email protected]\":\nversion \"1.7.11\"\nresolved \"https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.7.11.tgz#b988582cafbb2b095e8b556526f30c90d057cace\"\n@@ -2370,6 +2383,11 @@ cssstyle@^1.0.0:\ndependencies:\ncssom \"0.3.x\"\n+csstype@^2.2.0:\n+ version \"2.5.7\"\n+ resolved \"https://registry.yarnpkg.com/csstype/-/csstype-2.5.7.tgz#bf9235d5872141eccfb2d16d82993c6b149179ff\"\n+ integrity sha512-Nt5VDyOTIIV4/nRFswoCKps1R5CD1hkiyjBE9/thNaNZILLEviVw9yWQw15+O+CpNjQKB/uvdcxFFOrSflY3Yw==\n+\ncurrently-unhandled@^0.4.1:\nversion \"0.4.1\"\nresolved \"https://registry.yarnpkg.com/currently-unhandled/-/currently-unhandled-0.4.1.tgz#988df33feab191ef799a61369dd76c17adf957ea\"\n@@ -5099,7 +5117,7 @@ lerna-changelog@~0.8.2:\nstring.prototype.padend \"^3.0.0\"\nyargs \"^11.0.0\"\n-lerna@~3.5.0:\n+lerna@^3.5.1:\nversion \"3.5.1\"\nresolved \"https://registry.yarnpkg.com/lerna/-/lerna-3.5.1.tgz#350b24b58fc2d7bc2c1e1f4ef3058afe827cfa68\"\nintegrity sha512-0AyxMr2UpR3RAJsyrfNtYvfcI01YVSSnbRdzum7frZAtb7S+8NSY2ip7aDbN6/YsQK2K/zOCQ4shu/nwgub8aw==\n@@ -6917,25 +6935,25 @@ react-addons-test-utils@~15.6.2:\nresolved \"https://registry.yarnpkg.com/react-addons-test-utils/-/react-addons-test-utils-15.6.2.tgz#c12b6efdc2247c10da7b8770d185080a7b047156\"\nintegrity sha1-wStu/cIkfBDae4dw0YUICnsEcVY=\n-react-dom@~16.6.3:\n- version \"16.6.3\"\n- resolved \"https://registry.yarnpkg.com/react-dom/-/react-dom-16.6.3.tgz#8fa7ba6883c85211b8da2d0efeffc9d3825cccc0\"\n- integrity sha512-8ugJWRCWLGXy+7PmNh8WJz3g1TaTUt1XyoIcFN+x0Zbkoz+KKdUyx1AQLYJdbFXjuF41Nmjn5+j//rxvhFjgSQ==\n+react-dom@~16.7.0-alpha.2:\n+ version \"16.7.0-alpha.2\"\n+ resolved \"https://registry.yarnpkg.com/react-dom/-/react-dom-16.7.0-alpha.2.tgz#16632880ed43676315991d8b412cce6975a30282\"\n+ integrity sha512-o0mMw8jBlwHjGZEy/vvKd/6giAX0+skREMOTs3/QHmgi+yAhUClp4My4Z9lsKy3SXV+03uPdm1l/QM7NTcGuMw==\ndependencies:\nloose-envify \"^1.1.0\"\nobject-assign \"^4.1.1\"\nprop-types \"^15.6.2\"\n- scheduler \"^0.11.2\"\n+ scheduler \"^0.12.0-alpha.2\"\n-react@~16.6.3:\n- version \"16.6.3\"\n- resolved \"https://registry.yarnpkg.com/react/-/react-16.6.3.tgz#25d77c91911d6bbdd23db41e70fb094cc1e0871c\"\n- integrity sha512-zCvmH2vbEolgKxtqXL2wmGCUxUyNheYn/C+PD1YAjfxHC54+MhdruyhO7QieQrYsYeTxrn93PM2y0jRH1zEExw==\n+react@~16.7.0-alpha.2:\n+ version \"16.7.0-alpha.2\"\n+ resolved \"https://registry.yarnpkg.com/react/-/react-16.7.0-alpha.2.tgz#924f2ae843a46ea82d104a8def7a599fbf2c78ce\"\n+ integrity sha512-Xh1CC8KkqIojhC+LFXd21jxlVtzoVYdGnQAi/I2+dxbmos9ghbx5TQf9/nDxc4WxaFfUQJkya0w1k6rMeyIaxQ==\ndependencies:\nloose-envify \"^1.1.0\"\nobject-assign \"^4.1.1\"\nprop-types \"^15.6.2\"\n- scheduler \"^0.11.2\"\n+ scheduler \"^0.12.0-alpha.2\"\nread-cmd-shim@^1.0.1:\nversion \"1.0.1\"\n@@ -7379,10 +7397,10 @@ sax@^1.2.4:\nresolved \"https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9\"\nintegrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==\n-scheduler@^0.11.2:\n- version \"0.11.2\"\n- resolved \"https://registry.yarnpkg.com/scheduler/-/scheduler-0.11.2.tgz#a8db5399d06eba5abac51b705b7151d2319d33d3\"\n- integrity sha512-+WCP3s3wOaW4S7C1tl3TEXp4l9lJn0ZK8G3W3WKRWmw77Z2cIFUW2MiNTMHn5sCjxN+t7N43HAOOgMjyAg5hlg==\n+scheduler@^0.12.0-alpha.2:\n+ version \"0.12.0-alpha.2\"\n+ resolved \"https://registry.yarnpkg.com/scheduler/-/scheduler-0.12.0-alpha.2.tgz#2a8bc8dc6ecdb75fa6480ceeedc1f187c9539970\"\n+ integrity sha512-bfqFzGH18MjjhePIzYQNR0uGQ1wMCX6Q83c2s+3fzyuqKT6zBI2wNQTpq01q72C7QItAp8if5w2LfMiXnI2SYw==\ndependencies:\nloose-envify \"^1.1.0\"\nobject-assign \"^4.1.1\"\n"
}
] | TypeScript | MIT License | router5/router5 | feat: introduce React hooks |
580,249 | 30.11.2018 21:36:03 | 0 | 758a097ca5401b4f7cba842eb8ad8afb2c40ed89 | chore: add react-router5-hocs package | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/jest.config.js",
"diff": "+module.exports = {\n+ transform: {\n+ '^.+\\\\.tsx?$': 'ts-jest'\n+ },\n+ moduleFileExtensions: ['ts', 'tsx', 'js'],\n+ preset: 'ts-jest',\n+ testPathIgnorePatterns: ['<rootDir>/modules/__tests__/helpers/.*\\\\.tsx?$'],\n+ globals: {\n+ 'ts-jest': {\n+ tsConfig: '<rootDir>/tsconfig.test.json'\n+ }\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/modules/BaseLink.ts",
"diff": "+import { NavigationOptions, State, Router } from 'router5'\n+import React, { Component, HTMLAttributes, MouseEventHandler } from 'react'\n+import PropTypes from 'prop-types'\n+\n+export interface BaseLinkProps extends HTMLAttributes<HTMLAnchorElement> {\n+ routeName: string\n+ routeParams?: { [key: string]: any }\n+ routeOptions?: NavigationOptions\n+ className?: string\n+ activeClassName?: string\n+ activeStrict?: boolean\n+ ignoreQueryParams?: boolean\n+ onClick?: MouseEventHandler<HTMLAnchorElement>\n+ onMouseOver?: MouseEventHandler<HTMLAnchorElement>\n+ successCallback?(state?: State): void\n+ errorCallback?(error?: any): void\n+ target?: string\n+ route?: State\n+ previousRoute?: State\n+ router?: Router\n+}\n+\n+export interface BaseLinkState {\n+ active: boolean\n+}\n+\n+class BaseLink extends Component<BaseLinkProps, BaseLinkState> {\n+ public router: Router\n+ constructor(props, context) {\n+ super(props, context)\n+\n+ this.router = context.router\n+\n+ if (!this.router.hasPlugin('BROWSER_PLUGIN')) {\n+ console.error(\n+ '[react-router5-hocs][BaseLink] missing browser plugin, href might be built incorrectly'\n+ )\n+ }\n+\n+ this.isActive = this.isActive.bind(this)\n+ this.clickHandler = this.clickHandler.bind(this)\n+ this.callback = this.callback.bind(this)\n+\n+ this.state = { active: this.isActive() }\n+ }\n+\n+ buildUrl(routeName, routeParams) {\n+ //@ts-ignore\n+ if (this.router.buildUrl) {\n+ //@ts-ignore\n+ return this.router.buildUrl(routeName, routeParams)\n+ }\n+\n+ return this.router.buildPath(routeName, routeParams)\n+ }\n+\n+ isActive() {\n+ const {\n+ routeName,\n+ routeParams = {},\n+ activeStrict = false,\n+ ignoreQueryParams = true\n+ } = this.props\n+\n+ return this.router.isActive(\n+ routeName,\n+ routeParams,\n+ activeStrict,\n+ ignoreQueryParams\n+ )\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+\n+ clickHandler(evt) {\n+ const { onClick, target } = this.props\n+\n+ if (onClick) {\n+ onClick(evt)\n+\n+ if (evt.defaultPrevented) {\n+ return\n+ }\n+ }\n+\n+ const comboKey =\n+ evt.metaKey || evt.altKey || evt.ctrlKey || evt.shiftKey\n+\n+ if (evt.button === 0 && !comboKey && target !== '_blank') {\n+ evt.preventDefault()\n+ this.router.navigate(\n+ this.props.routeName,\n+ this.props.routeParams || {},\n+ this.props.routeOptions || {},\n+ this.callback\n+ )\n+ }\n+ }\n+\n+ render() {\n+ /* eslint-disable */\n+ const {\n+ routeName,\n+ routeParams,\n+ routeOptions,\n+ className,\n+ activeClassName = 'active',\n+ activeStrict,\n+ ignoreQueryParams,\n+ route,\n+ previousRoute,\n+ router,\n+ children,\n+ onClick,\n+ successCallback,\n+ errorCallback,\n+ ...linkProps\n+ } = this.props\n+ /* eslint-enable */\n+\n+ const active = this.isActive()\n+ const href = this.buildUrl(routeName, routeParams)\n+ const linkclassName = (active ? [activeClassName] : [])\n+ .concat(className ? className.split(' ') : [])\n+ .join(' ')\n+\n+ return React.createElement(\n+ 'a',\n+ {\n+ ...linkProps,\n+ href,\n+ className: linkclassName,\n+ onClick: this.clickHandler\n+ },\n+ children\n+ )\n+ }\n+}\n+\n+BaseLink.contextTypes = {\n+ router: PropTypes.object.isRequired\n+}\n+\n+export default BaseLink\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/modules/RouterProvider.ts",
"diff": "+import { Component, Children, ReactNode } from 'react'\n+import PropTypes from 'prop-types'\n+import { Router } from 'router5'\n+\n+interface RouterProviderProps {\n+ router?: Router\n+ children: ReactNode\n+}\n+\n+class RouterProvider extends Component<RouterProviderProps> {\n+ private router: Router\n+\n+ constructor(props, context) {\n+ super(props, context)\n+ this.router = props.router\n+ }\n+\n+ getChildContext() {\n+ return { router: this.router }\n+ }\n+\n+ render() {\n+ const { children } = this.props\n+ return Children.only(children)\n+ }\n+}\n+\n+RouterProvider.childContextTypes = {\n+ router: PropTypes.object.isRequired\n+}\n+\n+export default RouterProvider\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/modules/__tests__/helpers/index.tsx",
"diff": "+import createRouter from 'router5'\n+import React, { Component } from 'react'\n+import PropTypes from 'prop-types'\n+import { RouterProvider } from '../../'\n+import { mount } from 'enzyme'\n+import browserPlugin from '../../../../router5-plugin-browser'\n+\n+export class Child extends Component {\n+ render() {\n+ return <div />\n+ }\n+}\n+\n+Child.contextTypes = {\n+ router: PropTypes.object.isRequired\n+}\n+\n+export const FnChild = props => <div />\n+\n+export const createTestRouter = () => createRouter([]).usePlugin(browserPlugin())\n+\n+export const renderWithRouter = router => BaseComponent =>\n+ mount(\n+ <RouterProvider router={router}>\n+ <BaseComponent />\n+ </RouterProvider>\n+ )\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/modules/index.ts",
"diff": "+import RouterProvider from './RouterProvider'\n+import BaseLink from './BaseLink'\n+import withRouter from './withRouter'\n+import withRoute from './withRoute'\n+import routeNode from './routeNode'\n+\n+const Link = withRoute(BaseLink)\n+\n+export { RouterProvider, BaseLink, Link, withRouter, withRoute, routeNode }\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/modules/routeNode.ts",
"diff": "+import { Component, createElement, ComponentClass } from 'react'\n+import PropTypes from 'prop-types'\n+import { shouldUpdateNode } from 'router5-transition-path'\n+import { RouterState, RouteState, UnsubscribeFn } from './types'\n+import { Router } from 'router5'\n+\n+function routeNode<P>(nodeName: string) {\n+ return function routeNodeWrapper(\n+ RouteSegment: React.ComponentType<P & RouterState>\n+ ): ComponentClass<P> {\n+ class RouteNode extends Component<P> {\n+ private router: Router\n+ private routeState: RouteState\n+ private mounted: boolean\n+ private unsubscribe: UnsubscribeFn\n+\n+ constructor(props, context) {\n+ super(props, context)\n+ this.router = context.router\n+ this.routeState = {\n+ previousRoute: null,\n+ route: this.router.getState()\n+ }\n+ this.mounted = false\n+\n+ if (typeof window !== 'undefined') {\n+ const listener = ({ route, previousRoute }) => {\n+ if (shouldUpdateNode(nodeName)(route, previousRoute)) {\n+ this.routeState = {\n+ previousRoute,\n+ route\n+ }\n+ if (this.mounted) {\n+ this.forceUpdate()\n+ }\n+ }\n+ }\n+ this.unsubscribe = this.router.subscribe(\n+ listener\n+ ) as UnsubscribeFn\n+ }\n+ }\n+\n+ componentDidMount() {\n+ this.mounted = true\n+ }\n+\n+ componentWillUnmount() {\n+ if (this.unsubscribe) {\n+ this.unsubscribe()\n+ }\n+ }\n+\n+ render() {\n+ const { props, router } = this\n+ const { previousRoute, route } = this.routeState\n+ const component = createElement(RouteSegment, {\n+ //@ts-ignore\n+ ...props,\n+ router,\n+ previousRoute,\n+ route\n+ })\n+\n+ return component\n+ }\n+ }\n+\n+ RouteNode.contextTypes = {\n+ router: PropTypes.object.isRequired\n+ }\n+\n+ return RouteNode\n+ }\n+}\n+\n+export default routeNode\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/modules/types.ts",
"diff": "+import { Router, State } from 'router5'\n+\n+export type RouterState = {\n+ router: Router\n+} & RouteState\n+\n+export interface RouteState {\n+ route: State\n+ previousRoute: State | null\n+}\n+\n+export type UnsubscribeFn = () => void\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/modules/withRoute.ts",
"diff": "+import { Component, createElement, ComponentClass } from 'react'\n+import PropTypes from 'prop-types'\n+import { Router } from 'router5'\n+import { RouterState, RouteState, UnsubscribeFn } from './types'\n+\n+function withRoute<P>(\n+ BaseComponent: React.ComponentType<P & RouterState>\n+): ComponentClass<P> {\n+ class WithRoute extends Component<P> {\n+ private router: Router\n+ private routeState: RouteState\n+ private mounted: boolean\n+ private unsubscribe: UnsubscribeFn\n+\n+ constructor(props, context) {\n+ super(props, context)\n+ this.router = context.router\n+ this.routeState = {\n+ previousRoute: null,\n+ route: this.router.getState()\n+ }\n+ this.mounted = false\n+\n+ if (typeof window !== 'undefined') {\n+ const listener = ({ route, previousRoute }) => {\n+ this.routeState = {\n+ route,\n+ previousRoute\n+ }\n+ if (this.mounted) {\n+ this.forceUpdate()\n+ }\n+ }\n+ this.unsubscribe = this.router.subscribe(\n+ listener\n+ ) as UnsubscribeFn\n+ }\n+ }\n+\n+ componentDidMount() {\n+ this.mounted = true\n+ }\n+\n+ componentWillUnmount() {\n+ if (this.unsubscribe) {\n+ this.unsubscribe()\n+ }\n+ }\n+\n+ render() {\n+ return createElement(BaseComponent, {\n+ //@ts-ignore\n+ ...this.props,\n+ ...this.routeState,\n+ router: this.router\n+ })\n+ }\n+ }\n+\n+ WithRoute.contextTypes = {\n+ router: PropTypes.object.isRequired\n+ }\n+\n+ return WithRoute\n+}\n+\n+export default withRoute\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/modules/withRouter.ts",
"diff": "+import { Component, createElement, ComponentClass, ComponentType } from 'react'\n+import PropTypes from 'prop-types'\n+import { Router } from 'router5'\n+\n+function withRouter<P>(\n+ BaseComponent: ComponentType<P & { router: Router }>\n+): ComponentClass<P> {\n+ class WithRouter extends Component<P> {\n+ private router: Router\n+\n+ constructor(props, context) {\n+ super(props, context)\n+ this.router = context.router\n+ }\n+\n+ render() {\n+ return createElement(BaseComponent, {\n+ //@ts-ignore\n+ ...this.props,\n+ router: this.router\n+ })\n+ }\n+ }\n+\n+ WithRouter.contextTypes = {\n+ router: PropTypes.object.isRequired\n+ }\n+\n+ return WithRouter\n+}\n+\n+export default withRouter\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/package.json",
"diff": "+{\n+ \"name\": \"react-router5-hocs\",\n+ \"version\": \"6.5.3\",\n+ \"description\": \"router5 helpers for React\",\n+ \"main\": \"dist/commonjs/index.js\",\n+ \"jsnext:main\": \"dist/es/index.js\",\n+ \"module\": \"dist/es/index.js\",\n+ \"repository\": {\n+ \"type\": \"git\",\n+ \"url\": \"https://github.com/router5/router5.git\"\n+ },\n+ \"keywords\": [\n+ \"router\",\n+ \"html5\",\n+ \"history\",\n+ \"tree\",\n+ \"react\",\n+ \"functional\"\n+ ],\n+ \"author\": \"Thomas Roch\",\n+ \"license\": \"MIT\",\n+ \"bugs\": {\n+ \"url\": \"https://github.com/router5/router5/issues\"\n+ },\n+ \"homepage\": \"https://router5.js.org\",\n+ \"devDependencies\": {\n+ \"enzyme-adapter-react-16\": \"~1.7.0\",\n+ \"router5\": \"^6.6.2\"\n+ },\n+ \"peerDependencies\": {\n+ \"react\": \"^15.0.0 || ^16.0.0\",\n+ \"router5\": \">= 6.1.0 < 7.0.0\"\n+ },\n+ \"dependencies\": {\n+ \"prop-types\": \"~15.6.2\",\n+ \"router5-transition-path\": \"5.4.0\"\n+ },\n+ \"typings\": \"./index.d.ts\",\n+ \"scripts\": {\n+ \"test\": \"jest\"\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/tsconfig.build.json",
"diff": "+{\n+ \"extends\": \"./tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"declaration\": true,\n+ \"declarationDir\": \"./types\",\n+ \"outDir\": \"./dist\"\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/tsconfig.json",
"diff": "+{\n+ \"extends\": \"../../tsconfig.base.json\",\n+ \"compilerOptions\": {\n+ \"jsx\": \"react\"\n+ },\n+ \"exclude\": [\"node_modules\", \"modules/__tests__\"],\n+ \"include\": [\"modules\"]\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/tsconfig.test.json",
"diff": "+{\n+ \"extends\": \"./tsconfig.json\",\n+ \"compilerOptions\": {\n+ \"allowJs\": true\n+ },\n+ \"include\": [\"./modules/__tests__/**/*.ts\"]\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/yarn.lock",
"diff": "+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n+# yarn lockfile v1\n+\n+\n+define-properties@^1.1.2:\n+ version \"1.1.3\"\n+ resolved \"https://registry.yarnpkg.com/define-properties/-/define-properties-1.1.3.tgz#cf88da6cbee26fe6db7094f61d870cbd84cee9f1\"\n+ integrity sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==\n+ dependencies:\n+ object-keys \"^1.0.12\"\n+\n+enzyme-adapter-react-16@~1.7.0:\n+ version \"1.7.0\"\n+ resolved \"https://registry.yarnpkg.com/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.7.0.tgz#90344395a89624edbe7f0e443bc19fef62bf1f9f\"\n+ integrity sha512-rDr0xlnnFPffAPYrvG97QYJaRl9unVDslKee33wTStsBEwZTkESX1H7VHGT5eUc6ifNzPgOJGvSh2zpHT4gXjA==\n+ dependencies:\n+ enzyme-adapter-utils \"^1.9.0\"\n+ function.prototype.name \"^1.1.0\"\n+ object.assign \"^4.1.0\"\n+ object.values \"^1.0.4\"\n+ prop-types \"^15.6.2\"\n+ react-is \"^16.6.1\"\n+ react-test-renderer \"^16.0.0-0\"\n+\n+enzyme-adapter-utils@^1.9.0:\n+ version \"1.9.0\"\n+ resolved \"https://registry.yarnpkg.com/enzyme-adapter-utils/-/enzyme-adapter-utils-1.9.0.tgz#3997c20f3387fdcd932b155b3740829ea10aa86c\"\n+ integrity sha512-uMe4xw4l/Iloh2Fz+EO23XUYMEQXj5k/5ioLUXCNOUCI8Dml5XQMO9+QwUq962hBsY5qftfHHns+d990byWHvg==\n+ dependencies:\n+ function.prototype.name \"^1.1.0\"\n+ object.assign \"^4.1.0\"\n+ prop-types \"^15.6.2\"\n+ semver \"^5.6.0\"\n+\n+es-abstract@^1.6.1:\n+ version \"1.12.0\"\n+ resolved \"https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.12.0.tgz#9dbbdd27c6856f0001421ca18782d786bf8a6165\"\n+ integrity sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==\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+\n+es-to-primitive@^1.1.1:\n+ version \"1.2.0\"\n+ resolved \"https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.0.tgz#edf72478033456e8dda8ef09e00ad9650707f377\"\n+ integrity sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==\n+ dependencies:\n+ is-callable \"^1.1.4\"\n+ is-date-object \"^1.0.1\"\n+ is-symbol \"^1.0.2\"\n+\n+function-bind@^1.1.0, 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+ integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==\n+\n+function.prototype.name@^1.1.0:\n+ version \"1.1.0\"\n+ resolved \"https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.0.tgz#8bd763cc0af860a859cc5d49384d74b932cd2327\"\n+ integrity sha512-Bs0VRrTz4ghD8pTmbJQD1mZ8A/mN0ur/jGz+A6FBxPDUPkm1tNfF6bhTYPA7i7aF4lZJVr+OXTNNrnnIl58Wfg==\n+ dependencies:\n+ define-properties \"^1.1.2\"\n+ function-bind \"^1.1.1\"\n+ is-callable \"^1.1.3\"\n+\n+has-symbols@^1.0.0:\n+ version \"1.0.0\"\n+ resolved \"https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44\"\n+ integrity sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=\n+\n+has@^1.0.1:\n+ version \"1.0.3\"\n+ resolved \"https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796\"\n+ integrity sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==\n+ dependencies:\n+ function-bind \"^1.1.1\"\n+\n+is-callable@^1.1.3, is-callable@^1.1.4:\n+ version \"1.1.4\"\n+ resolved \"https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75\"\n+ integrity sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==\n+\n+is-date-object@^1.0.1:\n+ version \"1.0.1\"\n+ resolved \"https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16\"\n+ integrity sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=\n+\n+is-regex@^1.0.4:\n+ version \"1.0.4\"\n+ resolved \"https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491\"\n+ integrity sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=\n+ dependencies:\n+ has \"^1.0.1\"\n+\n+is-symbol@^1.0.2:\n+ version \"1.0.2\"\n+ resolved \"https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.2.tgz#a055f6ae57192caee329e7a860118b497a950f38\"\n+ integrity sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==\n+ dependencies:\n+ has-symbols \"^1.0.0\"\n+\n+\"js-tokens@^3.0.0 || ^4.0.0\":\n+ version \"4.0.0\"\n+ resolved \"https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499\"\n+ integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==\n+\n+loose-envify@^1.1.0, loose-envify@^1.3.1:\n+ version \"1.4.0\"\n+ resolved \"https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf\"\n+ integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==\n+ dependencies:\n+ js-tokens \"^3.0.0 || ^4.0.0\"\n+\n+object-assign@^4.1.1:\n+ version \"4.1.1\"\n+ resolved \"https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863\"\n+ integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=\n+\n+object-keys@^1.0.11, object-keys@^1.0.12:\n+ version \"1.0.12\"\n+ resolved \"https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.12.tgz#09c53855377575310cca62f55bb334abff7b3ed2\"\n+ integrity sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==\n+\n+object.assign@^4.1.0:\n+ version \"4.1.0\"\n+ resolved \"https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da\"\n+ integrity sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==\n+ dependencies:\n+ define-properties \"^1.1.2\"\n+ function-bind \"^1.1.1\"\n+ has-symbols \"^1.0.0\"\n+ object-keys \"^1.0.11\"\n+\n+object.values@^1.0.4:\n+ version \"1.0.4\"\n+ resolved \"https://registry.yarnpkg.com/object.values/-/object.values-1.0.4.tgz#e524da09b4f66ff05df457546ec72ac99f13069a\"\n+ integrity sha1-5STaCbT2b/Bd9FdUbscqyZ8TBpo=\n+ dependencies:\n+ define-properties \"^1.1.2\"\n+ es-abstract \"^1.6.1\"\n+ function-bind \"^1.1.0\"\n+ has \"^1.0.1\"\n+\n+prop-types@^15.6.2, prop-types@~15.6.2:\n+ version \"15.6.2\"\n+ resolved \"https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.2.tgz#05d5ca77b4453e985d60fc7ff8c859094a497102\"\n+ integrity sha512-3pboPvLiWD7dkI3qf3KbUe6hKFKa52w+AE0VCqECtf+QHAKgOL37tTaNCnuX1nAAQ4ZhyP+kYVKf8rLmJ/feDQ==\n+ dependencies:\n+ loose-envify \"^1.3.1\"\n+ object-assign \"^4.1.1\"\n+\n+react-is@^16.6.1, react-is@^16.6.3:\n+ version \"16.6.3\"\n+ resolved \"https://registry.yarnpkg.com/react-is/-/react-is-16.6.3.tgz#d2d7462fcfcbe6ec0da56ad69047e47e56e7eac0\"\n+ integrity sha512-u7FDWtthB4rWibG/+mFbVd5FvdI20yde86qKGx4lVUTWmPlSWQ4QxbBIrrs+HnXGbxOUlUzTAP/VDmvCwaP2yA==\n+\n+react-test-renderer@^16.0.0-0:\n+ version \"16.6.3\"\n+ resolved \"https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.6.3.tgz#5f3a1a7d5c3379d46f7052b848b4b72e47c89f38\"\n+ integrity sha512-B5bCer+qymrQz/wN03lT0LppbZUDRq6AMfzMKrovzkGzfO81a9T+PWQW6MzkWknbwODQH/qpJno/yFQLX5IWrQ==\n+ dependencies:\n+ object-assign \"^4.1.1\"\n+ prop-types \"^15.6.2\"\n+ react-is \"^16.6.3\"\n+ scheduler \"^0.11.2\"\n+\n+scheduler@^0.11.2:\n+ version \"0.11.2\"\n+ resolved \"https://registry.yarnpkg.com/scheduler/-/scheduler-0.11.2.tgz#a8db5399d06eba5abac51b705b7151d2319d33d3\"\n+ integrity sha512-+WCP3s3wOaW4S7C1tl3TEXp4l9lJn0ZK8G3W3WKRWmw77Z2cIFUW2MiNTMHn5sCjxN+t7N43HAOOgMjyAg5hlg==\n+ dependencies:\n+ loose-envify \"^1.1.0\"\n+ object-assign \"^4.1.1\"\n+\n+semver@^5.6.0:\n+ version \"5.6.0\"\n+ resolved \"https://registry.yarnpkg.com/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004\"\n+ integrity sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==\n"
}
] | TypeScript | MIT License | router5/router5 | chore: add react-router5-hocs package |
580,249 | 30.11.2018 22:35:17 | 0 | dbc91a9a169013a3aa6426081bb2ebbefa482bb6 | chore: add hook tests | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5-hocs/modules/__tests__/main.tsx",
"new_path": "packages/react-router5-hocs/modules/__tests__/main.tsx",
"diff": "-import React, { SFC } from 'react'\n-import { Child, createTestRouter, FnChild, renderWithRouter } from './helpers'\n+import React from 'react'\n+import { createTestRouter, FnChild, renderWithRouter } from './helpers'\nimport {\nRouterProvider,\nwithRoute,\n@@ -62,7 +62,7 @@ describe('routeNode hoc', () => {\nit('should inject the router in the wrapped component props', () => {\nconst ChildSpy = jest.fn(FnChild)\n- renderWithRouter(router)(withRoute(ChildSpy))\n+ renderWithRouter(router)(routeNode('')(ChildSpy))\nexpect(ChildSpy).toHaveBeenCalledWith({\nrouter,\nroute: null,\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/__tests__/hocs.ts",
"diff": "+import { createTestRouter, FnChild, renderWithRouter } from './helpers'\n+import { withRoute, withRouter, routeNode } from '..'\n+import { configure } from 'enzyme'\n+import Adapter from 'enzyme-adapter-react-16'\n+\n+//@ts-ignore\n+configure({ adapter: new Adapter() })\n+\n+describe('withRoute hoc', () => {\n+ let router\n+\n+ beforeAll(() => {\n+ router = createTestRouter()\n+ })\n+\n+ it('should inject the router in the wrapped component props', () => {\n+ const ChildSpy = jest.fn(FnChild)\n+\n+ renderWithRouter(router)(withRoute(ChildSpy))\n+ expect(ChildSpy).toHaveBeenCalledWith(\n+ {\n+ router,\n+ route: null,\n+ previousRoute: null\n+ },\n+ {}\n+ )\n+ })\n+})\n+\n+describe('withRouter hoc', () => {\n+ let router\n+\n+ beforeAll(() => {\n+ router = createTestRouter()\n+ })\n+\n+ it('should inject the router on the wrapped component props', () => {\n+ const ChildSpy = jest.fn(FnChild)\n+\n+ //@ts-ignore\n+ renderWithRouter(router)(withRouter(ChildSpy))\n+\n+ expect(ChildSpy).toHaveBeenCalledWith(\n+ {\n+ router\n+ },\n+ {}\n+ )\n+ })\n+})\n+\n+// describe('routeNode hoc', () => {\n+// let router\n+\n+// beforeAll(() => {\n+// router = createTestRouter()\n+// })\n+\n+// it('should inject the router in the wrapped component props', () => {\n+// const ChildSpy = jest.fn(FnChild)\n+\n+// renderWithRouter(router)(routeNode('')(ChildSpy))\n+// expect(ChildSpy).toHaveBeenCalledWith({\n+// router,\n+// route: null,\n+// previousRoute: null\n+// }, {})\n+// })\n+// })\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5/modules/__tests__/hooks.ts",
"diff": "+import { createTestRouter, FnChild, renderWithRouter } from './helpers'\n+import { useRoute, useRouter, useRouteNode } from '..'\n+import { configure } from 'enzyme'\n+import Adapter from 'enzyme-adapter-react-16'\n+\n+//@ts-ignore\n+configure({ adapter: new Adapter() })\n+\n+describe('useRoute hook', () => {\n+ let router\n+\n+ beforeAll(() => {\n+ router = createTestRouter()\n+ })\n+\n+ it('should inject the router in the wrapped component props', () => {\n+ const ChildSpy = jest.fn(FnChild)\n+\n+ renderWithRouter(router)(() => {\n+ return ChildSpy(useRoute())\n+ })\n+ expect(ChildSpy).toHaveBeenCalledWith({\n+ router,\n+ route: null,\n+ previousRoute: null\n+ })\n+ })\n+})\n+\n+describe('useRouter hook', () => {\n+ let router\n+\n+ beforeAll(() => {\n+ router = createTestRouter()\n+ })\n+\n+ it('should inject the router on the wrapped component props', () => {\n+ const ChildSpy = jest.fn(FnChild)\n+\n+ //@ts-ignore\n+ renderWithRouter(router)(() => {\n+ return ChildSpy({ router: useRouter() })\n+ })\n+\n+ expect(ChildSpy).toHaveBeenCalledWith({\n+ router\n+ })\n+ })\n+})\n+\n+describe('useRouteNode hook', () => {\n+ let router\n+\n+ beforeAll(() => {\n+ router = createTestRouter()\n+ })\n+\n+ it('should inject the router in the wrapped component props', () => {\n+ const ChildSpy = jest.fn(FnChild)\n+\n+ renderWithRouter(router)(() => ChildSpy(useRouteNode('')))\n+ expect(ChildSpy).toHaveBeenCalledWith({\n+ router,\n+ route: null,\n+ previousRoute: null\n+ })\n+ })\n+})\n"
},
{
"change_type": "DELETE",
"old_path": "packages/react-router5/modules/__tests__/hooks.tsx",
"new_path": "packages/react-router5/modules/__tests__/hooks.tsx",
"diff": ""
},
{
"change_type": "RENAME",
"old_path": "packages/react-router5/modules/__tests__/main.tsx",
"new_path": "packages/react-router5/modules/__tests__/link.tsx",
"diff": "-import React, { SFC } from 'react'\n-import { Child, createTestRouter, FnChild, renderWithRouter } from './helpers'\n-import {\n- RouterProvider,\n- withRoute,\n- withRouter,\n- routeNode,\n- BaseLink,\n- Link\n-} from '..'\n+import React from 'react'\n+import { createTestRouter } from './helpers'\n+import { RouterProvider, BaseLink, Link } from '..'\nimport { mount, configure } from 'enzyme'\nimport Adapter from 'enzyme-adapter-react-16'\n//@ts-ignore\nconfigure({ adapter: new Adapter() })\n-describe('withRoute hoc', () => {\n- let router\n-\n- beforeAll(() => {\n- router = createTestRouter()\n- })\n-\n- it('should inject the router in the wrapped component props', () => {\n- const ChildSpy = jest.fn(FnChild)\n-\n- renderWithRouter(router)(withRoute(ChildSpy))\n- expect(ChildSpy).toHaveBeenCalledWith({\n- router,\n- route: null,\n- previousRoute: null\n- }, {})\n- })\n-})\n-\n-describe('withRouter hoc', () => {\n- let router\n-\n- beforeAll(() => {\n- router = createTestRouter()\n- })\n-\n- it('should inject the router on the wrapped component props', () => {\n- const ChildSpy = jest.fn(FnChild)\n-\n- //@ts-ignore\n- renderWithRouter(router)(withRouter(ChildSpy))\n-\n- expect(ChildSpy).toHaveBeenCalledWith({\n- router\n- }, {})\n- })\n-})\n-\n-describe('routeNode hoc', () => {\n- let router\n-\n- beforeAll(() => {\n- router = createTestRouter()\n- })\n-\n- it('should inject the router in the wrapped component props', () => {\n- const ChildSpy = jest.fn(FnChild)\n-\n- renderWithRouter(router)(withRoute(ChildSpy))\n- expect(ChildSpy).toHaveBeenCalledWith({\n- router,\n- route: null,\n- previousRoute: null\n- }, {})\n- })\n-})\n-\ndescribe('BaseLink component', () => {\nlet router\n"
}
] | TypeScript | MIT License | router5/router5 | chore: add hook tests |
580,249 | 30.11.2018 22:36:21 | 0 | 8a36eba52f566d8d0acb2bd561a6a6bf5eb5c921 | chore: update husky hook | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"lint:check-conflicts\": \"eslint --print-config .eslintrc | eslint-config-prettier-check\",\n\"format\": \"prettier 'packages/**/*.{js,ts}'\",\n\"check\": \"yarn run lint:check-conflicts && yarn run lint && yarn run test && yarn run format --list-different\",\n- \"precommit\": \"lint-staged\",\n\"changelog\": \"lerna-changelog\",\n\"docs:start\": \"node packages/docs/scripts/start\",\n\"copy\": \"cp -f README.md ./packages/router5/README.md\",\n\"webpack-dev-middleware\": \"~3.1.2\",\n\"webpack-dev-server\": \"~3.1.3\",\n\"xstream\": \"~11.7.0\"\n+ },\n+ \"husky\": {\n+ \"hooks\": {\n+ \"pre-commit\": \"lint-staged\"\n+ }\n}\n}\n"
}
] | TypeScript | MIT License | router5/router5 | chore: update husky hook |
580,249 | 01.12.2018 11:25:13 | 0 | f62fb0c837a7661f6c5951e70300de5ca6ed02e5 | chore: rework RouteNode render prop | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/__tests__/hocs.ts",
"new_path": "packages/react-router5/modules/__tests__/hocs.ts",
"diff": "@@ -50,21 +50,24 @@ describe('withRouter hoc', () => {\n})\n})\n-// describe('routeNode hoc', () => {\n-// let router\n+describe('routeNode hoc', () => {\n+ let router\n-// beforeAll(() => {\n-// router = createTestRouter()\n-// })\n+ beforeAll(() => {\n+ router = createTestRouter()\n+ })\n-// it('should inject the router in the wrapped component props', () => {\n-// const ChildSpy = jest.fn(FnChild)\n+ it('should inject the router in the wrapped component props', () => {\n+ const ChildSpy = jest.fn(FnChild)\n-// renderWithRouter(router)(routeNode('')(ChildSpy))\n-// expect(ChildSpy).toHaveBeenCalledWith({\n-// router,\n-// route: null,\n-// previousRoute: null\n-// }, {})\n-// })\n-// })\n+ renderWithRouter(router)(routeNode('')(ChildSpy))\n+ expect(ChildSpy).toHaveBeenCalledWith(\n+ {\n+ router,\n+ route: null,\n+ previousRoute: null\n+ },\n+ {}\n+ )\n+ })\n+})\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/hocs/routeNode.tsx",
"new_path": "packages/react-router5/modules/hocs/routeNode.tsx",
"diff": "@@ -4,7 +4,7 @@ import RouteNode from '../render/RouteNode'\nfunction routeNode<P>(nodeName: string) {\nreturn function(BaseComponent: ComponentType<P & RouteContext>): SFC<P> {\n- function RouteNode(props) {\n+ function RouteNodeWrapper(props) {\nreturn (\n<RouteNode nodeName={nodeName}>\n{routeContext => (\n@@ -14,7 +14,7 @@ function routeNode<P>(nodeName: string) {\n)\n}\n- return RouteNode\n+ return RouteNodeWrapper\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/render/RouteNode.tsx",
"new_path": "packages/react-router5/modules/render/RouteNode.tsx",
"diff": "-import React, { ReactNode, ReactElement } from 'react'\n+import React, { ReactNode, ReactElement, SFC } from 'react'\nimport { shouldUpdateNode } from 'router5-transition-path'\nimport { RouteContext } from '../types'\nimport { routeContext } from '../context'\n@@ -8,35 +8,31 @@ export interface RouteNodeProps {\nchildren: (routeContext: RouteContext) => ReactNode\n}\n-class RouteNode extends React.Component<RouteNodeProps> {\n- private memoizedResult: ReactNode\n-\n- constructor(props, context) {\n- super(props, context)\n-\n- this.renderOnRouteNodeChange = this.renderOnRouteNodeChange.bind(this)\n+class RouteNodeRenderer extends React.Component<RouteNodeProps & RouteContext> {\n+ constructor(props) {\n+ super(props)\n}\n- renderOnRouteNodeChange(routeContext) {\n- const shouldUpdate = shouldUpdateNode(this.props.nodeName)(\n- routeContext.route,\n- routeContext.previousRoute\n+ shouldComponentUpdate(nextProps) {\n+ return shouldUpdateNode(this.props.nodeName)(\n+ nextProps.route,\n+ nextProps.previousRoute\n)\n-\n- if (!this.memoizedResult || shouldUpdate) {\n- this.memoizedResult = this.props.children(routeContext)\n}\n- return this.memoizedResult\n+ render() {\n+ const { router, route, previousRoute } = this.props\n+\n+ return this.props.children({ router, route, previousRoute })\n+ }\n}\n- render() {\n+const RouteNode: SFC<RouteNodeProps> = props => {\nreturn (\n<routeContext.Consumer>\n- {this.renderOnRouteNodeChange}\n+ {routeContext => <RouteNodeRenderer {...props} {...routeContext} />}\n</routeContext.Consumer>\n)\n}\n-}\nexport default RouteNode\n"
}
] | TypeScript | MIT License | router5/router5 | chore: rework RouteNode render prop |
580,249 | 01.12.2018 18:50:53 | 0 | 9c6c671d47afa302bc945e4232d0139c9bce1099 | refactor: lazily add rxjs plugin on subscription, and multicast | [
{
"change_type": "MODIFY",
"old_path": "packages/rxjs-router5/modules/index.ts",
"new_path": "packages/rxjs-router5/modules/index.ts",
"diff": "-import { Subject, Observable } from 'rxjs'\n+import { Observable, Subscriber } from 'rxjs'\nimport { Router, State } from 'router5'\nimport transitionPath from 'router5-transition-path'\n-import { map, startWith, filter, distinctUntilChanged } from 'rxjs/operators'\n+import {\n+ map,\n+ startWith,\n+ filter,\n+ distinctUntilChanged,\n+ share\n+} from 'rxjs/operators'\nimport { PluginFactory } from 'router5'\nexport const PLUGIN_NAME = 'RXJS_PLUGIN'\n@@ -22,7 +28,7 @@ export interface RouterState {\nstate: State\n}\n-function rxjsPluginFactory(observer: Subject<RouterAction>): PluginFactory {\n+function rxjsPluginFactory(observer: Subscriber<RouterAction>): PluginFactory {\nfunction rxjsPlugin() {\nconst dispatch = (type: string, isError = false) => (\ntoState: State,\n@@ -50,9 +56,12 @@ function rxjsPluginFactory(observer: Subject<RouterAction>): PluginFactory {\nfunction createObservables(router: Router) {\n// Events observable\n- const transitionEvents$ = new Subject<RouterAction>()\n+ const transitionEvents$ = new Observable<RouterAction>(observer => {\n+ const unsubscribe = router.usePlugin(rxjsPluginFactory(observer))\n+\n+ return unsubscribe\n+ }).pipe(share<RouterAction>())\n- router.usePlugin(rxjsPluginFactory(transitionEvents$))\n// Transition Route\nconst transitionRoute$ = transitionEvents$.pipe(\nmap(_ => (_.type === TRANSITION_START ? _.toState : null)),\n"
}
] | TypeScript | MIT License | router5/router5 | refactor: lazily add rxjs plugin on subscription, and multicast |
580,249 | 01.12.2018 19:57:36 | 0 | 3ab2e468f12627f91e93e1b4b1ab129ce2a00f66 | test: add plugin deregistration and teardown tests | [
{
"change_type": "MODIFY",
"old_path": "packages/router5/modules/__tests__/plugins.ts",
"new_path": "packages/router5/modules/__tests__/plugins.ts",
"diff": "import { createTestRouter } from './helpers'\n+import createRouter from '..'\ndescribe('core/plugins', () => {\nlet router\n@@ -32,4 +33,19 @@ describe('core/plugins', () => {\n})\n})\n})\n+\n+ it('should return an deregister function and call teardown', () => {\n+ const router = createRouter()\n+ const teardown = jest.fn()\n+ const unsubscribe = router.usePlugin(() => ({\n+ teardown\n+ }))\n+\n+ expect(router.getPlugins().length).toBe(1)\n+\n+ unsubscribe()\n+\n+ expect(router.getPlugins().length).toBe(0)\n+ expect(teardown).toHaveBeenCalled()\n+ })\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5/modules/core/plugins.ts",
"new_path": "packages/router5/modules/core/plugins.ts",
"diff": "@@ -22,7 +22,9 @@ export default function withPlugins(router: Router): Router {\n})\nreturn () => {\n- routerPlugins.filter(plugin => routerPlugins.indexOf(plugin) >= 0)\n+ routerPlugins = routerPlugins.filter(\n+ plugin => plugins.indexOf(plugin) === -1\n+ )\nremovePluginFns.forEach(removePlugin => removePlugin())\n}\n}\n@@ -43,8 +45,8 @@ export default function withPlugins(router: Router): Router {\nreturn () => {\nremoveEventListeners.forEach(removeListener => removeListener())\n- if (plugin.teardown) {\n- plugin.teardown()\n+ if (appliedPlugin.teardown) {\n+ appliedPlugin.teardown()\n}\n}\n}\n"
}
] | TypeScript | MIT License | router5/router5 | test: add plugin deregistration and teardown tests |
580,235 | 07.12.2018 11:42:08 | -7,200 | 935f3185e9dd9997e3b8ed419bf1e2b9555b64fe | Fix issue with browsers that don't URL encode characters (Edge) | [
{
"change_type": "MODIFY",
"old_path": "packages/router5/modules/plugins/browser/browser.js",
"new_path": "packages/router5/modules/plugins/browser/browser.js",
"diff": "@@ -49,8 +49,8 @@ const getLocation = opts => {\n? window.location.hash.replace(new RegExp('^#' + opts.hashPrefix), '')\n: window.location.pathname.replace(new RegExp('^' + opts.base), '')\n- // Fix Frefox issue with non encoded pipe characters\n- const correctedPath = path.replace(/\\|/g, '%7C')\n+ // Fix issue with browsers that don't URL encode characters (Edge)\n+ const correctedPath = encodeURI(decodeURI(path))\nreturn (correctedPath || '/') + window.location.search\n}\n"
}
] | TypeScript | MIT License | router5/router5 | Fix issue with browsers that don't URL encode characters (Edge) |
580,249 | 15.12.2018 20:42:09 | 0 | b30f6bf4c4c408d46f55515fe3001a29b542667d | chore: remove usage of contextType and rename link components | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/BaseLink.ts",
"new_path": "packages/react-router5/modules/BaseLink.ts",
"diff": "@@ -26,13 +26,12 @@ export interface BaseLinkState {\n}\nclass BaseLink extends Component<BaseLinkProps, BaseLinkState> {\n- static contextType = routerContext\npublic router: Router\nconstructor(props, context) {\nsuper(props, context)\n- this.router = context\n+ this.router = this.props.router\nthis.isActive = this.isActive.bind(this)\nthis.clickHandler = this.clickHandler.bind(this)\nthis.callback = this.callback.bind(this)\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/__tests__/helpers/index.tsx",
"new_path": "packages/react-router5/modules/__tests__/helpers/index.tsx",
"diff": "import createRouter from 'router5'\nimport React, { Component } from 'react'\n-import PropTypes from 'prop-types'\nimport { RouterProvider } from '../../'\nimport { mount } from 'enzyme'\nimport browserPlugin from '../../../../router5-plugin-browser'\n@@ -11,10 +10,6 @@ export class Child extends Component {\n}\n}\n-Child.contextTypes = {\n- router: PropTypes.object.isRequired\n-}\n-\nexport const FnChild = props => <div />\nexport const createTestRouter = () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/__tests__/link.tsx",
"new_path": "packages/react-router5/modules/__tests__/link.tsx",
"diff": "import React from 'react'\nimport { createTestRouter } from './helpers'\n-import { RouterProvider, BaseLink, Link } from '..'\n+import { RouterProvider, Link, ConnectedLink } from '..'\nimport { mount, configure } from 'enzyme'\nimport Adapter from 'enzyme-adapter-react-16'\n//@ts-ignore\nconfigure({ adapter: new Adapter() })\n-describe('BaseLink component', () => {\n+describe('Link component', () => {\nlet router\nbeforeAll(() => {\n@@ -18,7 +18,7 @@ describe('BaseLink component', () => {\nrouter.addNode('home', '/home')\nconst output = mount(\n<RouterProvider router={router}>\n- <BaseLink routeName={'home'} />\n+ <Link routeName={'home'} />\n</RouterProvider>\n)\nexpect(output.find('a').prop('href')).toBe('/home')\n@@ -30,7 +30,7 @@ describe('BaseLink component', () => {\nrouter.start()\nconst output = mount(\n<RouterProvider router={router}>\n- <BaseLink routeName={'home'} />\n+ <Link routeName={'home'} />\n</RouterProvider>\n)\nexpect(output.find('a').prop('className')).toContain('active')\n@@ -40,7 +40,7 @@ describe('BaseLink component', () => {\nrouter.start()\nconst output = mount(\n<RouterProvider router={router}>\n- <Link routeName=\"home\" title=\"Hello\" target=\"_blank\" />\n+ <ConnectedLink routeName=\"home\" title=\"Hello\" target=\"_blank\" />\n</RouterProvider>\n)\nconst a = output.find('a')\n@@ -57,7 +57,7 @@ describe('BaseLink component', () => {\nconst onMouseLeave = () => {}\nconst output = mount(\n<RouterProvider router={router}>\n- <Link\n+ <ConnectedLink\nrouteName={'home'}\ntitle=\"Hello\"\ndata-test-id=\"Link\"\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/index.ts",
"new_path": "packages/react-router5/modules/index.ts",
"diff": "@@ -9,11 +9,12 @@ import useRouter from './hooks/useRouter'\nimport useRoute from './hooks/useRoute'\nimport useRouteNode from './hooks/useRouteNode'\n-const Link = withRoute(BaseLink)\n+const ConnectedLink = withRoute(BaseLink)\n+const Link = withRouter(BaseLink)\nexport {\nRouterProvider,\n- BaseLink,\n+ ConnectedLink,\nLink,\nwithRouter,\nwithRoute,\n"
}
] | TypeScript | MIT License | router5/router5 | chore: remove usage of contextType and rename link components |
580,249 | 15.12.2018 20:43:03 | 0 | 7a1afa3d2be31532791ed9e3f553374075af09a2 | chore: update React peer dependency | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/package.json",
"new_path": "packages/react-router5/package.json",
"diff": "\"router5\": \"^6.6.2\"\n},\n\"peerDependencies\": {\n- \"react\": \"^0.14.0 || ^15.0.0 || ^16.0.0\",\n+ \"react\": \">=16.3.0\",\n\"router5\": \">= 6.1.0 < 7.0.0\"\n},\n\"dependencies\": {\n"
}
] | TypeScript | MIT License | router5/router5 | chore: update React peer dependency |
580,249 | 15.12.2018 20:49:19 | 0 | d2fa481652a2f5ef8a004fe1865c8658e81bcbfc | chore: rename link components | [
{
"change_type": "RENAME",
"old_path": "packages/react-router5-hocs/modules/BaseLink.ts",
"new_path": "packages/react-router5-hocs/modules/Link.ts",
"diff": "@@ -2,7 +2,7 @@ import { NavigationOptions, State, Router } from 'router5'\nimport React, { Component, HTMLAttributes, MouseEventHandler } from 'react'\nimport PropTypes from 'prop-types'\n-export interface BaseLinkProps extends HTMLAttributes<HTMLAnchorElement> {\n+export interface LinkProps extends HTMLAttributes<HTMLAnchorElement> {\nrouteName: string\nrouteParams?: { [key: string]: any }\nrouteOptions?: NavigationOptions\n@@ -20,11 +20,11 @@ export interface BaseLinkProps extends HTMLAttributes<HTMLAnchorElement> {\nrouter?: Router\n}\n-export interface BaseLinkState {\n+export interface LinkState {\nactive: boolean\n}\n-class BaseLink extends Component<BaseLinkProps, BaseLinkState> {\n+class Link extends Component<LinkProps, LinkState> {\npublic router: Router\nconstructor(props, context) {\nsuper(props, context)\n@@ -139,8 +139,8 @@ class BaseLink extends Component<BaseLinkProps, BaseLinkState> {\n}\n}\n-BaseLink.contextTypes = {\n+Link.contextTypes = {\nrouter: PropTypes.object.isRequired\n}\n-export default BaseLink\n+export default Link\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5-hocs/modules/__tests__/main.tsx",
"new_path": "packages/react-router5-hocs/modules/__tests__/main.tsx",
"diff": "@@ -5,8 +5,8 @@ import {\nwithRoute,\nwithRouter,\nrouteNode,\n- BaseLink,\n- Link\n+ Link,\n+ ConnectedLink\n} from '..'\nimport { mount, configure } from 'enzyme'\nimport Adapter from 'enzyme-adapter-react-16'\n@@ -71,7 +71,7 @@ describe('routeNode hoc', () => {\n})\n})\n-describe('BaseLink component', () => {\n+describe('Link component', () => {\nlet router\nbeforeAll(() => {\n@@ -82,7 +82,7 @@ describe('BaseLink component', () => {\nrouter.addNode('home', '/home')\nconst output = mount(\n<RouterProvider router={router}>\n- <BaseLink routeName={'home'} />\n+ <Link routeName={'home'} />\n</RouterProvider>\n)\nexpect(output.find('a').prop('href')).toBe('/home')\n@@ -94,7 +94,7 @@ describe('BaseLink component', () => {\nrouter.start()\nconst output = mount(\n<RouterProvider router={router}>\n- <BaseLink routeName={'home'} />\n+ <Link routeName={'home'} />\n</RouterProvider>\n)\nexpect(output.find('a').prop('className')).toContain('active')\n@@ -104,7 +104,7 @@ describe('BaseLink component', () => {\nrouter.start()\nconst output = mount(\n<RouterProvider router={router}>\n- <Link routeName=\"home\" title=\"Hello\" target=\"_blank\" />\n+ <ConnectedLink routeName=\"home\" title=\"Hello\" target=\"_blank\" />\n</RouterProvider>\n)\nconst a = output.find('a')\n@@ -121,7 +121,7 @@ describe('BaseLink component', () => {\nconst onMouseLeave = () => {}\nconst output = mount(\n<RouterProvider router={router}>\n- <Link\n+ <ConnectedLink\nrouteName={'home'}\ntitle=\"Hello\"\ndata-test-id=\"Link\"\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5-hocs/modules/index.ts",
"new_path": "packages/react-router5-hocs/modules/index.ts",
"diff": "import RouterProvider from './RouterProvider'\n-import BaseLink from './BaseLink'\n+import Link from './Link'\nimport withRouter from './withRouter'\nimport withRoute from './withRoute'\nimport routeNode from './routeNode'\n-const Link = withRoute(BaseLink)\n+const ConnectedLink = withRoute(Link)\n-export { RouterProvider, BaseLink, Link, withRouter, withRoute, routeNode }\n+export { RouterProvider, ConnectedLink, Link, withRouter, withRoute, routeNode }\n"
}
] | TypeScript | MIT License | router5/router5 | chore: rename link components |
580,249 | 15.12.2018 22:16:54 | 0 | 77829e561f94db65aaad44ff27fc710c2705b5ee | chore: add links to migration guide | [
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "+# [email protected] (2018-12-??)\n+\n+See migration guide: https://router5.js.org/migration/migrating-from-6.x-to-7.x\n+\n## [email protected] (2018-12-15)\n#### Bug fix\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/README.md",
"new_path": "docs/README.md",
"diff": "* [Listeners plugin](advanced/listeners-plugin.md)\n* [API Reference](api-reference.md)\n* Migration\n+ * [Migrating from 6.x to 7.x](migration/migrating-from-6.x-to-7.x.md)\n* [Migrating from 5.x to 6.x](migration/migrating-from-5.x-to-6.x.md)\n* [Migrating from 4.x to 5.x](migration/migrating-from-4.x-to-5.x.md)\n* [Migrating from 3.x to 4.x](migration/migrating-from-3.x-to-4.x.md)\n"
}
] | TypeScript | MIT License | router5/router5 | chore: add links to migration guide |
580,249 | 16.12.2018 10:33:58 | 0 | 7219598ecd73f7990b23bea8520ff11c9bb91415 | docs: add removal of hasPlugin in migration guide | [
{
"change_type": "MODIFY",
"old_path": "docs/migration/migrating-from-6.x-to-7.x.md",
"new_path": "docs/migration/migrating-from-6.x-to-7.x.md",
"diff": "@@ -25,6 +25,7 @@ An `unmaintained` directory has been created to move packages which are no longe\n- `router5-plugin-persistent-params`\n- `useMiddleware` no longer returns your router instance, but a function to remove the added middleware. You can still pass multiple middleware, in which case calling the teardown function will remove all of them.\n- `usePlugin` no longer returns your router instance, but a function to remove the added plugin. You can still pass multiple plugins, in which case calling the teardown function will remove all of them.\n+- `hasPlugin` method has been removed, and `pluginName` is no longer needed\n- Cloning is now done using a `cloneRouter` function, and it no longer re-uses existing dependencies\n```js\nimport { cloneRouter } from 'router5'\n"
}
] | TypeScript | MIT License | router5/router5 | docs: add removal of hasPlugin in migration guide |
580,249 | 16.12.2018 16:56:28 | 0 | a46f6d9dde0433df0c58528998537ec21691fdc7 | docs: update docs for v7 | [
{
"change_type": "MODIFY",
"old_path": ".prettierignore",
"new_path": ".prettierignore",
"diff": "packages/*/dist\n-packages/redux-router5/immutable\n-packages/redux-router5/index.js\n-packages/redux-router5/lib\n-packages/router5/constants.js\n-packages/router5/core\n-packages/router5/create-router.js\n-packages/router5/index.js\n-packages/router5/plugins\n-packages/router5/transition\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "-# Read Me\n+# Router5\n[](http://badge.fury.io/js/router5)\n[](https://opensource.org/licenses/MIT)\n> Official website: [router5.js.org](https://router5.js.org)\n-## Router5\n-\nrouter5 is a **framework and view library agnostic router**.\n* **view / state separation**: router5 processes routing **instructions** and outputs **state** updates.\n@@ -17,14 +15,16 @@ router5 is a **framework and view library agnostic router**.\n```javascript\nimport createRouter from 'router5'\n-import browserPlugin from 'router5/plugins/browser'\n+import browserPlugin from 'router5-plugin-browser'\nconst routes = [\n{ name: 'home', path: '/' },\n{ name: 'profile', path: '/profile' }\n]\n-const router = createRouter(routes).usePlugin(browserPlugin())\n+const router = createRouter(routes)\n+\n+router.usePlugin(browserPlugin())\nrouter.start()\n```\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/advanced/listeners-plugin.md",
"new_path": "docs/advanced/listeners-plugin.md",
"diff": "## Usage\n```javascript\n-import listenersPlugin from 'router5/plugins/listeners';\n+import listenersPlugin from 'router5-plugin-listeners'\nconst router = createRouter()\n- .usePlugin(listenersPlugin());\n+\n+router.usePlugin(listenersPlugin())\n```\n## Types of listeners\n@@ -28,4 +29,3 @@ Listeners registered with `addListener(fn)` will be triggered on any route chang\n## Listen to a specific route\n`addRouteListener(name, fn)` will register a listener which will be triggered when the router is navigating to the supplied route name.\n-\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/advanced/plugins.md",
"new_path": "docs/advanced/plugins.md",
"diff": "@@ -6,12 +6,13 @@ router5 is extensible with the use of plugins. Plugins can decorate a route inst\nA plugin is a function taking a router instance and returning an object with a name and at least one of the following methods:\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+- `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+- `teardown()`: a function called when removing the plugin\n## Registering a plugin\n@@ -19,30 +20,30 @@ A plugin is a function taking a router instance and returning an object with a n\nfunction myPlugin(router, dependencies) {\nreturn {\nonTransitionSuccess: (toState, fromState) => {\n- console.log('Yippee, navigation to ' + toState.name + ' was successful!');\n+ console.log(\n+ 'Yippee, navigation to ' + toState.name + ' was successful!'\n+ )\n+ }\n+ }\n}\n- };\n-\n-myPlugin.pluginName = 'MY_PLUGIN';\nconst router = createRouter()\n- .usePlugin(myPlugin);\n-router.hasPlugin('MY_PLUGIN'); // => true\n+router.usePlugin(myPlugin)\n```\n## Plugin examples\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+- [Browser plugin](https://github.com/router5/router5/blob/master/packages/router5-plugin-browser/modules/index.ts)\n+- [Persistent params plugin](https://github.com/router5/router5/blob/master/packages/router5-plugin-persistent-params/modules/index.ts)\n+- [Logger](https://github.com/router5/router5/blob/master/packages/router5-plugin-logger/modules/index.ts)\nRouter5 includes a logging plugin that you can use to help development\n```javascript\n-import createRouter, { loggerPlugin } from 'router5';\n+import createRouter, { loggerPlugin } from 'router5'\nconst router = createRouter()\n- .usePlugin(loggerPlugin);\n-```\n+const teardownPlgin = router.usePlugin(loggerPlugin)\n+```\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/advanced/universal-routing.md",
"new_path": "docs/advanced/universal-routing.md",
"diff": "@@ -11,10 +11,10 @@ You can use the same code for configuring your router on both client and server\n```javascript\nconst createRouter = require( 'router5' ).default;\n-const browserPlugin = require( 'router5/plugins/browser' );\n+const browserPlugin = require( 'router5-plugin-browser' );\nfunction createRouter() {\n- return createRouter([\n+ const router = createRouter([\n{ name: 'home', path: '/home' },\n{ name: 'about', path: '/about' },\n{ name: 'contact', path: '/contact' },\n@@ -23,9 +23,12 @@ function createRouter() {\ntrailingSlash: true,\ndefaultRoute: '404'\n})\n- .usePlugin(browserPlugin({\n+\n+ router.usePlugin(browserPlugin({\nuseHash: false\n}))\n+\n+ return router\n}\nexport default createRouter\n@@ -121,8 +124,10 @@ A user reported a gain from 300ms to 10ms per request for creating a new router,\n{% endhint %}\n```javascript\n+import { createRouter, cloneRouter } from 'router5'\n+\nconst baseRouter = createRouter(/* ... */);\n-const router = baseRouter.clone(dependencies);\n+const router = cloneRouter(baseRouter);\n```\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/api-reference.md",
"new_path": "docs/api-reference.md",
"diff": "@@ -14,15 +14,16 @@ const router = createRouter([routes], [options], [dependencies])\n* `options`: your router options, see [router options](https://github.com/router5/router5/tree/1cc1c6969a96918deb28e45b8c5b2d6aa19d0a19/docs/guides/router5-options.md)\n* `dependencies`: the dependencies you want to make available in middleware and plugins, see [dependency injection](https://github.com/router5/router5/tree/1cc1c6969a96918deb28e45b8c5b2d6aa19d0a19/docs/adavanced/dependency-injection.md)\n-### clone\n+### cloneRouter\nClone an existing router.\n```javascript\n-const clonedRouter = router.clone(dependencies)\n+const clonedRouter = cloneRouter(router, dependencies)\n```\n-* `dependencies`: the new dependencies, for the cloned router\n+* `router`: the router instance to clone\n+* `dependencies`: the new dependencies, for the cloned router (optional)\n### add\n@@ -147,7 +148,7 @@ const dependencies = router.getDependencies()\nRegister one or multiple middlewares, see [middleware](advanced/middleware.md)\n```javascript\n-router.useMiddleware(...middlewares)\n+const remove = router.useMiddleware(...middlewares)\n```\n### clearMiddleware\n@@ -163,16 +164,9 @@ router.clearMiddleware()\nRegister one or multiple plugins, see [plugins](advanced/plugins.md)\n```javascript\n-router.usePlugin(...plugins)\n+const teardown = router.usePlugin(...plugins)\n```\n-### hasPlugin\n-\n-Check if a plugin is in use\n-\n-```javascript\n-router.hasPlugin(pluginName)\n-```\n### canActivate\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/guides/in-the-browser.md",
"new_path": "docs/guides/in-the-browser.md",
"diff": "@@ -9,21 +9,24 @@ This plugin uses HTML5 history API and therefore is not compatible with browsers\nIt 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```javascript\n-import browserPlugin from 'router5/plugins/browser';\n+import browserPlugin from 'router5-plugin-browser'\nconst router = createRouter()\n- .usePlugin(browserPlugin({\n+\n+router.usePlugin(\n+ browserPlugin({\nuseHash: true\n- }))\n- .start();\n+ })\n+)\n+\n+router.start()\n```\n## Plugin options\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-\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"
},
{
"change_type": "MODIFY",
"old_path": "docs/introduction/getting-started.md",
"new_path": "docs/introduction/getting-started.md",
"diff": "@@ -19,16 +19,16 @@ npm install router5\n// ES2015+\nimport createRouter from 'router5';\n-import browserPlugin from 'router5/plugins/browser';\n-import persistentParamsPlugin from 'router5/plugins/persistentParams';\n+import browserPlugin from 'router5-plugin-browser';\n+import persistentParamsPlugin from 'router5-plugin-persistent-params';\n```\n### CommonJS syntax\n```javascript\nvar createRouter = require('router5').default;\n-var browserPlugin = require('router5/plugins/browser');\n-var persistentParamsPlugin = require('router5/plugins/persistentParams');\n+var browserPlugin = require('router5-plugin-browser');\n+var persistentParamsPlugin = require('router5-plugin-persistent-params');\n```\n### UMD\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/migration/migrating-from-0.x-to-1.x.md",
"new_path": "docs/migration/migrating-from-0.x-to-1.x.md",
"diff": "@@ -21,9 +21,9 @@ npm install router5\n// ES2015+\nimport createRouter, { RouteNode, errorCodes, transitionPath, loggerPlugin, constants } from 'router5';\n-import browserPlugin from 'router5/plugins/browser';\n-import listenersPlugin from 'router5/plugins/listeners';\n-import persistentParamsPlugin from 'router5/plugins/persistentParams';\n+import browserPlugin from 'router5-plugin-browser';\n+import listenersPlugin from 'router5-plugin-listeners';\n+import persistentParamsPlugin from 'router5-plugin-persistent-params';\n// ES5\nvar router5 = require('router5');\n@@ -36,9 +36,9 @@ var transitionPath = router5.transitionPath;\nvar loggerPlugin = router5.loggerPlugin;\nvar constants = router5.constants;\n-var browserPlugin = require('router5/plugins/browser');\n-var listenersPlugin = require('router5/plugins/listeners');\n-var persistentParamsPlugin = require('router5/plugins/persistentParams');\n+var browserPlugin = require('router5-plugin-browser');\n+var listenersPlugin = require('router5-plugin-listeners');\n+var persistentParamsPlugin = require('router5-plugin-persistent-params');\n```\n**UMD**\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/migration/migrating-from-3.x-to-4.x.md",
"new_path": "docs/migration/migrating-from-3.x-to-4.x.md",
"diff": "@@ -17,9 +17,9 @@ const router = createRouter(routes, options);\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```javascript\n-import browserPlugin from 'router5/plugins/browser';\n-import listenersPlugin from 'router5/plugins/listeners';\n-import persistentParamsPlugin from 'router5/plugins/persistentParams';\n+import browserPlugin from 'router5-plugin-browser';\n+import listenersPlugin from 'router5-plugin-listeners';\n+import persistentParamsPlugin from 'router5-plugin-persistent-params';\n```\nThe 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@@ -28,7 +28,7 @@ The history plugin has been renamed 'browser plugin', to better describe its res\n* `buildUrl`, `matchUrl` and `urlToPath` methods are no longer present by default and are added to your router instance by `browserPlugin`.\n```javascript\n-import browserPlugin from 'router5/plugins/browser';\n+import browserPlugin from 'router5-plugin-browser';\nrouter.usePlugin(browserPlugin({\nuseHash: true\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-browser/README.md",
"new_path": "packages/router5-plugin-browser/README.md",
"diff": "@@ -9,20 +9,24 @@ This plugin uses HTML5 history API and therefore is not compatible with browsers\nIt 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```js\n-import browserPlugin from 'router5-plugin-browser';\n+import browserPlugin from 'router5-plugin-browser'\nconst router = createRouter()\n- .usePlugin(browserPlugin({\n+\n+router.usePlugin(\n+ browserPlugin({\nuseHash: true\n- }))\n- .start();\n+ })\n+)\n+\n+router.start()\n```\n## Plugin options\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+- `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"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-listeners/README.md",
"new_path": "packages/router5-plugin-listeners/README.md",
"diff": "-# Router5 browser plugin\n+# Router5 listeners plugin\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+## No longer needed!\n-## Using the browser plugin\n+`router.subscribe` is now available and as a result listeners plugin is no longer needed.\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+## Usage\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-```js\n-import browserPlugin from 'router5-plugin-listeners';\n+```javascript\n+import listenersPlugin from 'router5-plugin-listeners'\nconst router = createRouter()\n- .usePlugin(browserPlugin({\n- useHash: true\n- }))\n- .start();\n+\n+router.usePlugin(listenersPlugin())\n```\n-## Plugin options\n+## Types of listeners\n+\n+Listeners are called with `toState` and `fromState` arguments.\n+\n+### Listen to a node change\n+\n+`addNodeListener(name, fn)` will register a listener which will be invoked when the specified route node is the **transition node** of a route change, i.e. the intersection between deactivated and activated segments.\n+\n+## Listen to any route change\n+\n+Listeners registered with `addListener(fn)` will be triggered on any route change, including route reloads \\(_toState_ will be equal to _fromState_\\). You can remove a previously added listener by using `removeListener(fn)`.\n+\n+## Listen to a specific route\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+`addRouteListener(name, fn)` will register a listener which will be triggered when the router is navigating to the supplied route name.\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-logger/README.md",
"new_path": "packages/router5-plugin-logger/README.md",
"diff": "-# Router5 browser plugin\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+# Router5 logger plugin\n```js\n-import browserPlugin from 'router5-plugin-logger';\n+import loggerPlugin from 'router5-plugin-logger';\nconst router = createRouter()\n- .usePlugin(browserPlugin({\n- useHash: true\n- }))\n- .start();\n-```\n-\n-## Plugin options\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+router.usePlugin(loggerPlugin);\n+```\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-persistent-params/README.md",
"new_path": "packages/router5-plugin-persistent-params/README.md",
"diff": "-# Router5 browser plugin\n+# Router5 persistent params plugin\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+Persist params on navigation. You just have to pass to the plugin an array of persistent parameters, and those parameters will be added to any route as query parameters (using their last known value). Note: if you use # in your routes, they are not \"true\" query parameters.\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+For now, only query parameters are supported. It works by modifying the path of the root node of your tree of routes (by default the root node path is ''). If you need support for other types of parameters, please raise an issue to discuss it.\n```js\n-import browserPlugin from 'router5-plugin-persistent-params';\n+import persistentParamsPlugin from 'router5-plugin-persistent-params'\n-const router = createRouter()\n- .usePlugin(browserPlugin({\n- useHash: true\n- }))\n- .start();\n-```\n+const router = new Router5()\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+router.usePlugin(persistentParamsPlugin(['mode']));\n+```\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5/README.md",
"new_path": "packages/router5/README.md",
"diff": "@@ -18,7 +18,7 @@ router5 is a **framework and view library agnostic router**.\n```javascript\nimport createRouter from 'router5'\n-import browserPlugin from 'router5/plugins/browser'\n+import browserPlugin from 'router5-plugin-browser'\nconst routes = [\n{ name: 'home', path: '/' },\n@@ -26,12 +26,13 @@ const routes = [\n]\nconst router = createRouter(routes)\n- .usePlugin(browserPlugin())\n+\n+router.usePlugin(browserPlugin())\nrouter.start()\n```\n-**With React \\(new context API\\)**\n+**With React\n```javascript\nimport React from 'react'\n"
}
] | TypeScript | MIT License | router5/router5 | docs: update docs for v7 |
580,249 | 16.12.2018 17:11:05 | 0 | a20d8f23414e4428c60a0cb69e227788a5740df5 | docs: update React docs and add missing render prop components | [
{
"change_type": "MODIFY",
"old_path": "docs/integration/with-react.md",
"new_path": "docs/integration/with-react.md",
"diff": "@@ -54,7 +54,7 @@ export default routeNode('users')(Users)\n## Link components\n* **Link**: a component to render hyperlinks. For a full list of supported props, check the source! `Link` is `withRoute` and `Link` composed together\n-* **BaseLink**: same as `Link`, except it won't re-render on a route change.\n+* **ConnectedLink**: same as `Link`, except it re-renders on a route changes.\n```javascript\nimport React from 'react'\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5-hocs/README.md",
"new_path": "packages/react-router5-hocs/README.md",
"diff": "@@ -56,7 +56,7 @@ export default routeNode('users')(Users)\n## Link components\n- **Link**: a component to render hyperlinks. For a full list of supported props, check the source! `Link` is `withRoute` and `Link` composed together\n-- **BaseLink**: same as `Link`, except it won't re-render on a route change.\n+- **ConnectedLink**: same as `Link`, except it re-render on route changes\n```javascript\nimport React from 'react'\n"
},
{
"change_type": "DELETE",
"old_path": "packages/react-router5-hocs/types/BaseLink.d.ts",
"new_path": null,
"diff": "-import { NavigationOptions, State, Router } from 'router5'\n-import React, { Component, HTMLAttributes, MouseEventHandler } from 'react'\n-export interface BaseLinkProps extends HTMLAttributes<HTMLAnchorElement> {\n- routeName: string\n- routeParams?: {\n- [key: string]: any\n- }\n- routeOptions?: NavigationOptions\n- className?: string\n- activeClassName?: string\n- activeStrict?: boolean\n- ignoreQueryParams?: boolean\n- onClick?: MouseEventHandler<HTMLAnchorElement>\n- onMouseOver?: MouseEventHandler<HTMLAnchorElement>\n- successCallback?(state?: State): void\n- errorCallback?(error?: any): void\n- target?: string\n- route?: State\n- previousRoute?: State\n- router?: Router\n-}\n-export interface BaseLinkState {\n- active: boolean\n-}\n-declare class BaseLink extends Component<BaseLinkProps, BaseLinkState> {\n- router: Router\n- constructor(props: any, context: any)\n- buildUrl(routeName: any, routeParams: any): any\n- isActive(): boolean\n- callback(err: any, state: any): void\n- clickHandler(evt: any): void\n- render(): React.DetailedReactHTMLElement<\n- {\n- href: any\n- className: string\n- onClick: (evt: any) => void\n- onMouseOver?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n- target?: string\n- defaultChecked?: boolean\n- defaultValue?: string | string[]\n- suppressContentEditableWarning?: boolean\n- suppressHydrationWarning?: boolean\n- accessKey?: string\n- contentEditable?: boolean\n- contextMenu?: string\n- dir?: string\n- draggable?: boolean\n- hidden?: boolean\n- id?: string\n- lang?: string\n- placeholder?: string\n- slot?: string\n- spellCheck?: boolean\n- style?: React.CSSProperties\n- tabIndex?: number\n- title?: string\n- inputMode?: string\n- is?: string\n- radioGroup?: string\n- role?: string\n- about?: string\n- datatype?: string\n- inlist?: any\n- prefix?: string\n- property?: string\n- resource?: string\n- typeof?: string\n- vocab?: string\n- autoCapitalize?: string\n- autoCorrect?: string\n- autoSave?: string\n- color?: string\n- itemProp?: string\n- itemScope?: boolean\n- itemType?: string\n- itemID?: string\n- itemRef?: string\n- results?: number\n- security?: string\n- unselectable?: 'on' | 'off'\n- 'aria-activedescendant'?: string\n- 'aria-atomic'?: boolean | 'false' | 'true'\n- 'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both'\n- 'aria-busy'?: boolean | 'false' | 'true'\n- 'aria-checked'?: boolean | 'false' | 'true' | 'mixed'\n- 'aria-colcount'?: number\n- 'aria-colindex'?: number\n- 'aria-colspan'?: number\n- 'aria-controls'?: string\n- 'aria-current'?:\n- | boolean\n- | 'time'\n- | 'false'\n- | 'true'\n- | 'page'\n- | 'step'\n- | 'location'\n- | 'date'\n- 'aria-describedby'?: string\n- 'aria-details'?: string\n- 'aria-disabled'?: boolean | 'false' | 'true'\n- 'aria-dropeffect'?:\n- | 'link'\n- | 'none'\n- | 'copy'\n- | 'execute'\n- | 'move'\n- | 'popup'\n- 'aria-errormessage'?: string\n- 'aria-expanded'?: boolean | 'false' | 'true'\n- 'aria-flowto'?: string\n- 'aria-grabbed'?: boolean | 'false' | 'true'\n- 'aria-haspopup'?:\n- | boolean\n- | 'dialog'\n- | 'menu'\n- | 'false'\n- | 'true'\n- | 'listbox'\n- | 'tree'\n- | 'grid'\n- 'aria-hidden'?: boolean | 'false' | 'true'\n- 'aria-invalid'?: boolean | 'false' | 'true' | 'grammar' | 'spelling'\n- 'aria-keyshortcuts'?: string\n- 'aria-label'?: string\n- 'aria-labelledby'?: string\n- 'aria-level'?: number\n- 'aria-live'?: 'off' | 'assertive' | 'polite'\n- 'aria-modal'?: boolean | 'false' | 'true'\n- 'aria-multiline'?: boolean | 'false' | 'true'\n- 'aria-multiselectable'?: boolean | 'false' | 'true'\n- 'aria-orientation'?: 'horizontal' | 'vertical'\n- 'aria-owns'?: string\n- 'aria-placeholder'?: string\n- 'aria-posinset'?: number\n- 'aria-pressed'?: boolean | 'false' | 'true' | 'mixed'\n- 'aria-readonly'?: boolean | 'false' | 'true'\n- 'aria-relevant'?:\n- | 'additions'\n- | 'additions text'\n- | 'all'\n- | 'removals'\n- | 'text'\n- 'aria-required'?: boolean | 'false' | 'true'\n- 'aria-roledescription'?: string\n- 'aria-rowcount'?: number\n- 'aria-rowindex'?: number\n- 'aria-rowspan'?: number\n- 'aria-selected'?: boolean | 'false' | 'true'\n- 'aria-setsize'?: number\n- 'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other'\n- 'aria-valuemax'?: number\n- 'aria-valuemin'?: number\n- 'aria-valuenow'?: number\n- 'aria-valuetext'?: string\n- dangerouslySetInnerHTML?: {\n- __html: string\n- }\n- onCopy?: (event: React.ClipboardEvent<HTMLAnchorElement>) => void\n- onCopyCapture?: (\n- event: React.ClipboardEvent<HTMLAnchorElement>\n- ) => void\n- onCut?: (event: React.ClipboardEvent<HTMLAnchorElement>) => void\n- onCutCapture?: (\n- event: React.ClipboardEvent<HTMLAnchorElement>\n- ) => void\n- onPaste?: (event: React.ClipboardEvent<HTMLAnchorElement>) => void\n- onPasteCapture?: (\n- event: React.ClipboardEvent<HTMLAnchorElement>\n- ) => void\n- onCompositionEnd?: (\n- event: React.CompositionEvent<HTMLAnchorElement>\n- ) => void\n- onCompositionEndCapture?: (\n- event: React.CompositionEvent<HTMLAnchorElement>\n- ) => void\n- onCompositionStart?: (\n- event: React.CompositionEvent<HTMLAnchorElement>\n- ) => void\n- onCompositionStartCapture?: (\n- event: React.CompositionEvent<HTMLAnchorElement>\n- ) => void\n- onCompositionUpdate?: (\n- event: React.CompositionEvent<HTMLAnchorElement>\n- ) => void\n- onCompositionUpdateCapture?: (\n- event: React.CompositionEvent<HTMLAnchorElement>\n- ) => void\n- onFocus?: (event: React.FocusEvent<HTMLAnchorElement>) => void\n- onFocusCapture?: (\n- event: React.FocusEvent<HTMLAnchorElement>\n- ) => void\n- onBlur?: (event: React.FocusEvent<HTMLAnchorElement>) => void\n- onBlurCapture?: (event: React.FocusEvent<HTMLAnchorElement>) => void\n- onChange?: (event: React.FormEvent<HTMLAnchorElement>) => void\n- onChangeCapture?: (\n- event: React.FormEvent<HTMLAnchorElement>\n- ) => void\n- onInput?: (event: React.FormEvent<HTMLAnchorElement>) => void\n- onInputCapture?: (event: React.FormEvent<HTMLAnchorElement>) => void\n- onReset?: (event: React.FormEvent<HTMLAnchorElement>) => void\n- onResetCapture?: (event: React.FormEvent<HTMLAnchorElement>) => void\n- onSubmit?: (event: React.FormEvent<HTMLAnchorElement>) => void\n- onSubmitCapture?: (\n- event: React.FormEvent<HTMLAnchorElement>\n- ) => void\n- onInvalid?: (event: React.FormEvent<HTMLAnchorElement>) => void\n- onInvalidCapture?: (\n- event: React.FormEvent<HTMLAnchorElement>\n- ) => void\n- onLoad?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onLoadCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onError?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onErrorCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onKeyDown?: (event: React.KeyboardEvent<HTMLAnchorElement>) => void\n- onKeyDownCapture?: (\n- event: React.KeyboardEvent<HTMLAnchorElement>\n- ) => void\n- onKeyPress?: (event: React.KeyboardEvent<HTMLAnchorElement>) => void\n- onKeyPressCapture?: (\n- event: React.KeyboardEvent<HTMLAnchorElement>\n- ) => void\n- onKeyUp?: (event: React.KeyboardEvent<HTMLAnchorElement>) => void\n- onKeyUpCapture?: (\n- event: React.KeyboardEvent<HTMLAnchorElement>\n- ) => void\n- onAbort?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onAbortCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onCanPlay?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onCanPlayCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onCanPlayThrough?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onCanPlayThroughCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onDurationChange?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onDurationChangeCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onEmptied?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onEmptiedCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onEncrypted?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onEncryptedCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onEnded?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onEndedCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onLoadedData?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onLoadedDataCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onLoadedMetadata?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onLoadedMetadataCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onLoadStart?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onLoadStartCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onPause?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onPauseCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onPlay?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onPlayCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onPlaying?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onPlayingCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onProgress?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onProgressCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onRateChange?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onRateChangeCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onSeeked?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onSeekedCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onSeeking?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onSeekingCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onStalled?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onStalledCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onSuspend?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onSuspendCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onTimeUpdate?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onTimeUpdateCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onVolumeChange?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onVolumeChangeCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onWaiting?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onWaitingCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onClickCapture?: (\n- event: React.MouseEvent<HTMLAnchorElement>\n- ) => void\n- onContextMenu?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n- onContextMenuCapture?: (\n- event: React.MouseEvent<HTMLAnchorElement>\n- ) => void\n- onDoubleClick?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n- onDoubleClickCapture?: (\n- event: React.MouseEvent<HTMLAnchorElement>\n- ) => void\n- onDrag?: (event: React.DragEvent<HTMLAnchorElement>) => void\n- onDragCapture?: (event: React.DragEvent<HTMLAnchorElement>) => void\n- onDragEnd?: (event: React.DragEvent<HTMLAnchorElement>) => void\n- onDragEndCapture?: (\n- event: React.DragEvent<HTMLAnchorElement>\n- ) => void\n- onDragEnter?: (event: React.DragEvent<HTMLAnchorElement>) => void\n- onDragEnterCapture?: (\n- event: React.DragEvent<HTMLAnchorElement>\n- ) => void\n- onDragExit?: (event: React.DragEvent<HTMLAnchorElement>) => void\n- onDragExitCapture?: (\n- event: React.DragEvent<HTMLAnchorElement>\n- ) => void\n- onDragLeave?: (event: React.DragEvent<HTMLAnchorElement>) => void\n- onDragLeaveCapture?: (\n- event: React.DragEvent<HTMLAnchorElement>\n- ) => void\n- onDragOver?: (event: React.DragEvent<HTMLAnchorElement>) => void\n- onDragOverCapture?: (\n- event: React.DragEvent<HTMLAnchorElement>\n- ) => void\n- onDragStart?: (event: React.DragEvent<HTMLAnchorElement>) => void\n- onDragStartCapture?: (\n- event: React.DragEvent<HTMLAnchorElement>\n- ) => void\n- onDrop?: (event: React.DragEvent<HTMLAnchorElement>) => void\n- onDropCapture?: (event: React.DragEvent<HTMLAnchorElement>) => void\n- onMouseDown?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n- onMouseDownCapture?: (\n- event: React.MouseEvent<HTMLAnchorElement>\n- ) => void\n- onMouseEnter?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n- onMouseLeave?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n- onMouseMove?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n- onMouseMoveCapture?: (\n- event: React.MouseEvent<HTMLAnchorElement>\n- ) => void\n- onMouseOut?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n- onMouseOutCapture?: (\n- event: React.MouseEvent<HTMLAnchorElement>\n- ) => void\n- onMouseOverCapture?: (\n- event: React.MouseEvent<HTMLAnchorElement>\n- ) => void\n- onMouseUp?: (event: React.MouseEvent<HTMLAnchorElement>) => void\n- onMouseUpCapture?: (\n- event: React.MouseEvent<HTMLAnchorElement>\n- ) => void\n- onSelect?: (event: React.SyntheticEvent<HTMLAnchorElement>) => void\n- onSelectCapture?: (\n- event: React.SyntheticEvent<HTMLAnchorElement>\n- ) => void\n- onTouchCancel?: (event: React.TouchEvent<HTMLAnchorElement>) => void\n- onTouchCancelCapture?: (\n- event: React.TouchEvent<HTMLAnchorElement>\n- ) => void\n- onTouchEnd?: (event: React.TouchEvent<HTMLAnchorElement>) => void\n- onTouchEndCapture?: (\n- event: React.TouchEvent<HTMLAnchorElement>\n- ) => void\n- onTouchMove?: (event: React.TouchEvent<HTMLAnchorElement>) => void\n- onTouchMoveCapture?: (\n- event: React.TouchEvent<HTMLAnchorElement>\n- ) => void\n- onTouchStart?: (event: React.TouchEvent<HTMLAnchorElement>) => void\n- onTouchStartCapture?: (\n- event: React.TouchEvent<HTMLAnchorElement>\n- ) => void\n- onPointerDown?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerDownCapture?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerMove?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerMoveCapture?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerUp?: (event: React.PointerEvent<HTMLAnchorElement>) => void\n- onPointerUpCapture?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerCancel?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerCancelCapture?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerEnter?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerEnterCapture?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerLeave?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerLeaveCapture?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerOver?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerOverCapture?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerOut?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onPointerOutCapture?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onGotPointerCapture?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onGotPointerCaptureCapture?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onLostPointerCapture?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onLostPointerCaptureCapture?: (\n- event: React.PointerEvent<HTMLAnchorElement>\n- ) => void\n- onScroll?: (event: React.UIEvent<HTMLAnchorElement>) => void\n- onScrollCapture?: (event: React.UIEvent<HTMLAnchorElement>) => void\n- onWheel?: (event: React.WheelEvent<HTMLAnchorElement>) => void\n- onWheelCapture?: (\n- event: React.WheelEvent<HTMLAnchorElement>\n- ) => void\n- onAnimationStart?: (\n- event: React.AnimationEvent<HTMLAnchorElement>\n- ) => void\n- onAnimationStartCapture?: (\n- event: React.AnimationEvent<HTMLAnchorElement>\n- ) => void\n- onAnimationEnd?: (\n- event: React.AnimationEvent<HTMLAnchorElement>\n- ) => void\n- onAnimationEndCapture?: (\n- event: React.AnimationEvent<HTMLAnchorElement>\n- ) => void\n- onAnimationIteration?: (\n- event: React.AnimationEvent<HTMLAnchorElement>\n- ) => void\n- onAnimationIterationCapture?: (\n- event: React.AnimationEvent<HTMLAnchorElement>\n- ) => void\n- onTransitionEnd?: (\n- event: React.TransitionEvent<HTMLAnchorElement>\n- ) => void\n- onTransitionEndCapture?: (\n- event: React.TransitionEvent<HTMLAnchorElement>\n- ) => void\n- },\n- HTMLElement\n- >\n-}\n-export default BaseLink\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/README.md",
"new_path": "packages/react-router5/README.md",
"diff": "# react-router5\n-\n-## Demos and examples\n-\n-* Higher-order components: [https://stackblitz.com/edit/react-router5-new-context-api](https://stackblitz.com/edit/react-router5)\n-* New context API: [https://stackblitz.com/edit/react-router5-new-context-api](https://stackblitz.com/edit/react-router5-new-context-api)\n-\n-\n## Installation\nInstall module `react-router5:\n@@ -19,9 +12,14 @@ yarn add react-router5\nnpm install --save react-router5\n```\n-## Higher-order components\n+## Demos and examples\n-* **RouterProvider**: adds your router instance in context.\n+- Higher-order components: [https://stackblitz.com/edit/react-router5-new-context-api](https://stackblitz.com/edit/react-router5)\n+- Render props: [https://stackblitz.com/edit/react-router5-new-context-api](https://stackblitz.com/edit/react-router5-new-context-api)\n+\n+## Provider\n+\n+- **RouterProvider**: adds your router instance and router state in context.\n```javascript\nconst AppWithRouter = (\n@@ -31,35 +29,24 @@ const AppWithRouter = (\n)\n```\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\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-* **withRouter**: HoC injecting your router instance only (from context) to the wrapped component.\n+## Connecting components\n-```javascript\n-import React from 'react'\n-import { routeNode } from 'react-router5'\n-import { UserView, UserList, NotFound } from './components'\n-\n-function Users(props) {\n- const { previousRoute, route } = props\n-\n- switch (route.name) {\n- case 'users.list':\n- return <UserList />\n- case 'users.view':\n- return <UserView />\n- default:\n- return <NotFound />\n- }\n-}\n+You can connect your components using three different methods:\n-export default routeNode('users')(Users)\n-```\n+- Higher-order components: `withRouter`, `withRoute` and `routeNode`\n+- Render props: `Router`, `Route` and `RouteNode`\n+- Hooks: `useRouter`, `useRoute` and `useRouteNode`\n+\n+| | HoC | Render prop | Hook |\n+| ------------------------ | ------------ | ----------- | -------------- |\n+| Use your router instance | `withRouter` | `Router` | `useRouter` |\n+| Connect to routing state | `withRoute` | `Route` | `useRoute` |\n+| Connect to a route node | `routeNode` | `RouteNode` | `useRouteNode` |\n## Link components\n-* **Link**: a component to render hyperlinks. For a full list of supported props, check the source! `Link` is `withRoute` and `Link` composed together\n-* **BaseLink**: same as `Link`, except it won't re-render on a route change.\n+- **Link**: a component to render hyperlinks. For a full list of supported props, check the source! `Link` is `withRoute` and `Link` composed together\n+- **ConnectedLink**: same as `Link`, except it re-renders on a route changes.\n```javascript\nimport React from 'react'\n@@ -77,25 +64,3 @@ function Menu(props) {\nexport default Menu\n```\n-\n-## New React context API\n-\n-For using the new React context API, you need React version 16.3 or above.\n-\n-> Three new components have been published to leverage React's new context API. Those components won't replace existing ones: instead `react-router5` will keep offering higher-order components and components accepting render functions.\n-\n-* `RouteProvider`\n-* `Route`\n-* `RouteNode`\n-\n-Both `Route` and `RouteNode` pass to their chilren an object containing `route`, `previousRoute` and `router`.\n-\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"
},
{
"change_type": "MODIFY",
"old_path": "packages/redux-router5/README.md",
"new_path": "packages/redux-router5/README.md",
"diff": "@@ -19,7 +19,7 @@ In both cases, __use the provided reducer (`router5Reducer`).__\n## Using the router plugin\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+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 `Link` from `react-router5`.\n```js\nimport { reduxPlugin } from 'redux-router5';\n"
}
] | TypeScript | MIT License | router5/router5 | docs: update React docs and add missing render prop components |
580,249 | 18.12.2018 14:02:55 | 0 | 8eb48fa1bbfacab5e8a7c87367ba9a2de608b5a1 | fix: fix path for types | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5-hocs/package.json",
"new_path": "packages/react-router5-hocs/package.json",
"diff": "\"prop-types\": \"~15.6.2\",\n\"router5-transition-path\": \"^7.0.0\"\n},\n- \"typings\": \"./index.d.ts\",\n+ \"typings\": \"./types/index.d.ts\",\n\"scripts\": {\n\"test\": \"jest\"\n}\n"
}
] | TypeScript | MIT License | router5/router5 | fix: fix path for types |
580,235 | 08.01.2019 23:26:55 | -7,200 | 5425b92913b075846a6b2638a36341a736b5c9d6 | Safely encode path to avoid URIError URI malformed | [
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-browser/modules/browser.ts",
"new_path": "packages/router5-plugin-browser/modules/browser.ts",
"diff": "@@ -41,11 +41,19 @@ const getLocation = opts => {\n: window.location.pathname.replace(new RegExp('^' + opts.base), '')\n// Fix issue with browsers that don't URL encode characters (Edge)\n- const correctedPath = encodeURI(decodeURI(path))\n+ const correctedPath = safelyEncodePath(path)\nreturn (correctedPath || '/') + window.location.search\n}\n+const safelyEncodePath = path => {\n+ try {\n+ return encodeURI(decodeURI(path))\n+ } catch (_) {\n+ return path\n+ }\n+}\n+\nconst getState = () => window.history.state\nconst getHash = () => window.location.hash\n"
}
] | TypeScript | MIT License | router5/router5 | Safely encode path to avoid URIError URI malformed |
580,258 | 16.01.2019 14:03:46 | -3,600 | db01cb59f561675806cea533a7c5854ab3adac90 | export BaseLink | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/README.md",
"new_path": "packages/react-router5/README.md",
"diff": "@@ -45,7 +45,8 @@ You can connect your components using three different methods:\n## Link components\n-- **Link**: a component to render hyperlinks. For a full list of supported props, check the source! `Link` is `withRoute` and `Link` composed together\n+- **BaseLink**: a component to render hyperlinks. For a full list of supported props, check the source!\n+- **Link**: `Link` is `withRoute` and `BaseLink` composed together\n- **ConnectedLink**: same as `Link`, except it re-renders on a route changes.\n```javascript\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/BaseLink.ts",
"new_path": "packages/react-router5/modules/BaseLink.ts",
"diff": "@@ -16,7 +16,7 @@ export interface BaseLinkProps extends HTMLAttributes<HTMLAnchorElement> {\ntarget?: string\nroute?: State\npreviousRoute?: State\n- router?: Router\n+ router: Router\n}\nexport interface BaseLinkState {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/hocs/withRouter.tsx",
"new_path": "packages/react-router5/modules/hocs/withRouter.tsx",
"diff": "@@ -4,7 +4,7 @@ import { routerContext } from '../context'\nfunction withRouter<P>(\nBaseComponent: ComponentType<P & { router: Router }>\n-): SFC<P> {\n+): SFC<Exclude<P, 'router'>> {\nreturn function WithRouter(props) {\nreturn (\n<routerContext.Consumer>\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/index.ts",
"new_path": "packages/react-router5/modules/index.ts",
"diff": "@@ -18,6 +18,7 @@ const Route = routeContext.Consumer\nexport {\nRouterProvider,\n+ BaseLink,\nConnectedLink,\nLink,\n// HoC\n"
}
] | TypeScript | MIT License | router5/router5 | export BaseLink |
580,271 | 07.02.2019 17:28:11 | -3,600 | cfc9800793c4aaea1182eff6acd46156b088b6e3 | Add failings tests | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/__tests__/helpers/index.tsx",
"new_path": "packages/react-router5/modules/__tests__/helpers/index.tsx",
"diff": "@@ -18,6 +18,24 @@ export const createTestRouter = () => {\nreturn router\n}\n+export const createTestRouterWithADefaultRoute = () => {\n+ const router = createRouter(\n+ [\n+ {\n+ name: 'test',\n+ path: '/'\n+ }\n+ ],\n+ { defaultRoute: 'test' }\n+ )\n+ router.usePlugin(\n+ browserPlugin({\n+ useHash: true\n+ })\n+ )\n+ return router\n+}\n+\nexport const renderWithRouter = router => BaseComponent =>\nmount(\n<RouterProvider router={router}>\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/__tests__/hocs.ts",
"new_path": "packages/react-router5/modules/__tests__/hocs.ts",
"diff": "-import { createTestRouter, FnChild, renderWithRouter } from './helpers'\n+import {\n+ createTestRouter,\n+ FnChild,\n+ renderWithRouter,\n+ createTestRouterWithADefaultRoute\n+} from './helpers'\nimport { withRoute, withRouter, routeNode } from '..'\nimport { configure } from 'enzyme'\nimport Adapter from 'enzyme-adapter-react-16'\n@@ -52,9 +57,11 @@ describe('withRouter hoc', () => {\ndescribe('routeNode hoc', () => {\nlet router\n+ let routerWithADefaultRoute\nbeforeAll(() => {\nrouter = createTestRouter()\n+ routerWithADefaultRoute = createTestRouterWithADefaultRoute()\n})\nit('should inject the router in the wrapped component props', () => {\n@@ -70,4 +77,16 @@ describe('routeNode hoc', () => {\n{}\n)\n})\n+\n+ it('Route should not be null with a default route and the router started', () => {\n+ const ChildSpy = jest.fn(FnChild)\n+\n+ const BaseComponent = routeNode('')(ChildSpy)\n+\n+ routerWithADefaultRoute.start(() => {\n+ renderWithRouter(routerWithADefaultRoute)(BaseComponent)\n+ /* first call, first argument */\n+ expect(ChildSpy.mock.calls[0][0].route.name).toBe('test')\n+ })\n+ })\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/__tests__/hooks.ts",
"new_path": "packages/react-router5/modules/__tests__/hooks.ts",
"diff": "-import { createTestRouter, FnChild, renderWithRouter } from './helpers'\n+import {\n+ createTestRouter,\n+ createTestRouterWithADefaultRoute,\n+ FnChild,\n+ renderWithRouter\n+} from './helpers'\nimport { useRoute, useRouter, useRouteNode } from '..'\nimport { configure } from 'enzyme'\nimport Adapter from 'enzyme-adapter-react-16'\n@@ -50,12 +55,14 @@ describe('useRouter hook', () => {\ndescribe('useRouteNode hook', () => {\nlet router\n+ let routerWithADefaultRoute\nbeforeAll(() => {\nrouter = createTestRouter()\n+ routerWithADefaultRoute = createTestRouterWithADefaultRoute()\n})\n- it('should inject the router in the wrapped component props', () => {\n+ it('should return the router', () => {\nconst ChildSpy = jest.fn(FnChild)\nrenderWithRouter(router)(() => ChildSpy(useRouteNode('')))\n@@ -65,4 +72,16 @@ describe('useRouteNode hook', () => {\npreviousRoute: null\n})\n})\n+\n+ it('should not return a null route with a default route and the router started', () => {\n+ const ChildSpy = jest.fn(FnChild)\n+\n+ const BaseComponent = () => ChildSpy(useRouteNode(''))\n+\n+ routerWithADefaultRoute.start(() => {\n+ renderWithRouter(routerWithADefaultRoute)(BaseComponent)\n+ /* first call, first argument */\n+ expect(ChildSpy.mock.calls[0][0].route.name).toBe('test')\n+ })\n+ })\n})\n"
}
] | TypeScript | MIT License | router5/router5 | Add failings tests |
580,271 | 07.02.2019 17:29:45 | -3,600 | fe9ee90845b131236d62eeb0517a858345888ced | Initialize route in useRouteNode the same way we do in the hoc/render props version | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/hooks/useRouteNode.ts",
"new_path": "packages/react-router5/modules/hooks/useRouteNode.ts",
"diff": "@@ -7,10 +7,11 @@ export type UnsubscribeFn = () => void\nexport default function useRouter(nodeName: string): RouteContext {\nconst router = useContext(routerContext)\n- const [state, setState] = useState({\n+\n+ const [state, setState] = useState(() => ({\npreviousRoute: null,\n- route: null\n- })\n+ route: router.getState()\n+ }))\nuseEffect(\n() =>\n"
}
] | TypeScript | MIT License | router5/router5 | Initialize route in useRouteNode the same way we do in the hoc/render props version |
580,249 | 21.02.2019 22:24:12 | -3,600 | e5815636163949fc36f0e8982f9ed5ac17c3ec89 | chore: update files ignored by npm | [
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/react-router5-hocs/.npmignore",
"diff": "+**/.*\n+node_modules\n+modules\n+*.log\n+*.md\n+*.config.js\n+*.json\n+*.lock\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/.npmignore",
"new_path": "packages/react-router5/.npmignore",
"diff": "**/.*\nnode_modules\n-npm-debug.log\n-test\n-scripts\n+modules\n+*.log\n*.md\n*.config.js\n+*.json\n+*.lock\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/redux-router5-immutable/.npmignore",
"diff": "+**/.*\n+node_modules\n+modules\n+*.log\n+*.md\n+*.config.js\n+*.json\n+*.lock\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/redux-router5/.npmignore",
"new_path": "packages/redux-router5/.npmignore",
"diff": "**/.*\n-modules\nnode_modules\n-npm-debug.log\n+modules\n+*.log\n*.md\n*.config.js\n*.json\n+*.lock\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-helpers/.npmignore",
"new_path": "packages/router5-helpers/.npmignore",
"diff": "**/.*\n-modules\nnode_modules\n-npm-debug.log\n+modules\n+*.log\n*.md\n+*.config.js\n+*.json\n+*.lock\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-browser/.npmignore",
"diff": "+**/.*\n+node_modules\n+modules\n+*.log\n+*.md\n+*.config.js\n+*.json\n+*.lock\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-listeners/.npmignore",
"diff": "+**/.*\n+node_modules\n+modules\n+*.log\n+*.md\n+*.config.js\n+*.json\n+*.lock\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-logger/.npmignore",
"diff": "+**/.*\n+node_modules\n+modules\n+*.log\n+*.md\n+*.config.js\n+*.json\n+*.lock\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "packages/router5-plugin-persistent-params/.npmignore",
"diff": "+**/.*\n+node_modules\n+modules\n+*.log\n+*.md\n+*.config.js\n+*.json\n+*.lock\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-transition-path/.npmignore",
"new_path": "packages/router5-transition-path/.npmignore",
"diff": "**/.*\nnode_modules\n-npm-debug.log\n-test\n+modules\n+*.log\n*.md\n+*.config.js\n+*.json\n+*.lock\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5/.npmignore",
"new_path": "packages/router5/.npmignore",
"diff": "**/.*\n-modules\n-coverage\n-test\nnode_modules\n+modules\n+*.log\n*.md\n*.config.js\n*.json\n+*.lock\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/rxjs-router5/.npmignore",
"new_path": "packages/rxjs-router5/.npmignore",
"diff": "**/.*\nnode_modules\n-npm-debug.log\n-test\n+modules\n+*.log\n*.md\n*.config.js\n+*.json\n+*.lock\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/xstream-router5/.npmignore",
"new_path": "packages/xstream-router5/.npmignore",
"diff": "**/.*\n-modules\nnode_modules\n-npm-debug.log\n+modules\n+*.log\n*.md\n*.config.js\n*.json\n+*.lock\n"
}
] | TypeScript | MIT License | router5/router5 | chore: update files ignored by npm |
580,254 | 12.03.2019 20:06:13 | 25,200 | 569104c7d0ce65ad8c0ac478eca5c6f03d97cdf0 | Update ecosystem.md
add Mr. Router5 to community packages | [
{
"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+* [Mr. Router5](https://github.com/pzmosquito/mr-router5): integration with MobX and React (support router5 7.x and mobx-react-lite)\n## Examples\n"
}
] | TypeScript | MIT License | router5/router5 | Update ecosystem.md
add Mr. Router5 to community packages |
580,247 | 01.03.2020 09:52:52 | 18,000 | e95c54075b3fd313ab320f569d12bbfd44fd86d6 | chore: fix function name | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/hooks/useRouteNode.ts",
"new_path": "packages/react-router5/modules/hooks/useRouteNode.ts",
"diff": "@@ -5,7 +5,7 @@ import { RouteContext } from '../types'\nexport type UnsubscribeFn = () => void\n-export default function useRouter(nodeName: string): RouteContext {\n+export default function useRouteNode(nodeName: string): RouteContext {\nconst router = useContext(routerContext)\nconst [state, setState] = useState(() => ({\n"
}
] | TypeScript | MIT License | router5/router5 | chore: fix function name (#421) |
580,254 | 01.03.2020 06:55:21 | 28,800 | ef2b14c2e470be668c70a9688ecec995398b3880 | docs: change mr-router5 package name | [
{
"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-* [Mr. Router5](https://github.com/pzmosquito/mr-router5): integration with MobX and React (support router5 7.x and mobx-react-lite)\n+* [mr-router5](https://github.com/pzmosquito/mr-router5): lightweight integration with MobX and React\n## Examples\n"
}
] | TypeScript | MIT License | router5/router5 | docs: change mr-router5 package name (#425) |
580,249 | 01.03.2020 21:25:26 | -3,600 | 1a5ca9c8327d27ac48a1c213346a9aee9deff40a | docs: link migration to v8 | [
{
"change_type": "MODIFY",
"old_path": ".prettierrc",
"new_path": ".prettierrc",
"diff": "\"singleQuote\": true,\n\"overrides\": [\n{\n- \"files\": [\"*.json\", \"*.yml\", \".eslintrc\", \".prettierrc\"],\n+ \"files\": [\"*.json\", \"*.md\", \"*.yml\", \".eslintrc\", \".prettierrc\"],\n\"options\": {\n\"tabWidth\": 2\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "docs/README.md",
"new_path": "docs/README.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- * [Core concepts](introduction/core-concepts.md)\n- * [Transition phase](introduction/transition-phase.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- * [Navigating](guides/navigating.md)\n- * [In the browser](guides/in-the-browser.md)\n- * [Observing state](guides/observing-state.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- * [Preventing navigation](advanced/preventing-navigation.md)\n- * [Errors and redirections](advanced/errors-and-redirections.md)\n- * [Dependency injection](advanced/dependency-injection.md)\n- * [Loading async data](advanced/loading-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 6.x to 7.x](migration/migrating-from-6.x-to-7.x.md)\n- * [Migrating from 5.x to 6.x](migration/migrating-from-5.x-to-6.x.md)\n- * [Migrating from 4.x to 5.x](migration/migrating-from-4.x-to-5.x.md)\n- * [Migrating from 3.x to 4.x](migration/migrating-from-3.x-to-4.x.md)\n- * [Migrating from 2.x to 3.x](migration/migrating-from-2.x-to-3.x.md)\n- * [Migrating from 1.x to 2.x](migration/migrating-from-1.x-to-2.x.md)\n- * [Migrating from 0.x to 1.x](migration/migrating-from-0.x-to-1.x.md)\n-\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+ - [Core concepts](introduction/core-concepts.md)\n+ - [Transition phase](introduction/transition-phase.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+ - [Navigating](guides/navigating.md)\n+ - [In the browser](guides/in-the-browser.md)\n+ - [Observing state](guides/observing-state.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+ - [Preventing navigation](advanced/preventing-navigation.md)\n+ - [Errors and redirections](advanced/errors-and-redirections.md)\n+ - [Dependency injection](advanced/dependency-injection.md)\n+ - [Loading async data](advanced/loading-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 7.x to 8.x](migration/migrating-from-6.x-to-7.x.md)\n+ - [Migrating from 6.x to 7.x](migration/migrating-from-6.x-to-7.x.md)\n+ - [Migrating from 5.x to 6.x](migration/migrating-from-5.x-to-6.x.md)\n+ - [Migrating from 4.x to 5.x](migration/migrating-from-4.x-to-5.x.md)\n+ - [Migrating from 3.x to 4.x](migration/migrating-from-3.x-to-4.x.md)\n+ - [Migrating from 2.x to 3.x](migration/migrating-from-2.x-to-3.x.md)\n+ - [Migrating from 1.x to 2.x](migration/migrating-from-1.x-to-2.x.md)\n+ - [Migrating from 0.x to 1.x](migration/migrating-from-0.x-to-1.x.md)\n"
}
] | TypeScript | MIT License | router5/router5 | docs: link migration to v8 |
580,249 | 01.03.2020 21:44:41 | -3,600 | 35f98f3ff7701e6d23d1079a048d0af96962fe75 | docs: correct example | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -52,7 +52,12 @@ function App() {\n}\n}\n-ReactDOM.render(<App />, document.getElementById('root'))\n+ReactDOM.render(\n+ <RouterProvider router={router}>\n+ <App />\n+ </RouterProvider>,\n+ document.getElementById('root')\n+)\n```\n**With observables**\n"
}
] | TypeScript | MIT License | router5/router5 | docs: correct example |
580,249 | 02.03.2020 10:52:24 | -3,600 | 1b0e54f50cbda4950d76429845ff9f6940dd4b10 | chore: no longer build react-router5-hocs | [
{
"change_type": "MODIFY",
"old_path": "packages/router5/README.md",
"new_path": "packages/router5/README.md",
"diff": "@@ -29,14 +29,16 @@ router.usePlugin(browserPlugin())\nrouter.start()\n```\n-**With React \\(new context API\\)**\n+**With React \\(hooks\\)**\n```javascript\nimport React from 'react'\nimport ReactDOM from 'react-dom'\n-import { RouteProvider, Route } from 'react-router5'\n+import { RouterProvider, useRoute } from 'react-router5'\n+\n+function App() {\n+ const { route } = useRoute()\n-function App({ route }) {\nif (!route) {\nreturn null\n}\n@@ -51,9 +53,9 @@ function App({ route }) {\n}\nReactDOM.render(\n- <RouteProvider router={router}>\n- <Route>{({ route }) => <App route={route} />}</Route>\n- </RouteProvider>,\n+ <RouterProvider router={router}>\n+ <App />\n+ </RouterProvider>,\ndocument.getElementById('root')\n)\n```\n"
},
{
"change_type": "MODIFY",
"old_path": "rollup.config.js",
"new_path": "rollup.config.js",
"diff": "@@ -85,7 +85,6 @@ module.exports = [\nmakePackageConfig('rxjs-router5'),\nmakePackageConfig('xstream-router5'),\nmakePackageConfig('react-router5'),\n- makePackageConfig('react-router5-hocs'),\nmakePackageConfig('redux-router5'),\nmakePackageConfig('redux-router5-immutable')\n].filter(Boolean)\n"
}
] | TypeScript | MIT License | router5/router5 | chore: no longer build react-router5-hocs |
580,269 | 19.03.2020 04:49:17 | 18,000 | 6e82a38373cc5fed02ed19606a63ab54afebab07 | fix: update Peer Dependencies to 8.x | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/package.json",
"new_path": "packages/react-router5/package.json",
"diff": "},\n\"peerDependencies\": {\n\"react\": \">=16.3.0\",\n- \"router5\": \"^7.0.0\"\n+ \"router5\": \"^8.0.0\"\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/redux-router5-immutable/package.json",
"new_path": "packages/redux-router5-immutable/package.json",
"diff": "\"peerDependencies\": {\n\"immutable\": \"^3.0.0\",\n\"redux\": \"^3.0.0 || ^4.0.0\",\n- \"router5\": \"^7.0.0\"\n+ \"router5\": \"^8.0.0\"\n},\n\"dependencies\": {\n\"redux-router5\": \"^8.0.0\"\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/redux-router5/package.json",
"new_path": "packages/redux-router5/package.json",
"diff": "},\n\"peerDependencies\": {\n\"redux\": \"^3.0.0 || ^4.0.0\",\n- \"router5\": \"^7.0.0\"\n+ \"router5\": \"^8.0.0\"\n},\n\"dependencies\": {\n\"router5-transition-path\": \"^8.0.0\"\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-browser/package.json",
"new_path": "packages/router5-plugin-browser/package.json",
"diff": "\"router5\": \"^8.0.0\"\n},\n\"peerDependencies\": {\n- \"router5\": \"^7.0.0\"\n+ \"router5\": \"^8.0.0\"\n},\n\"homepage\": \"https://github.com/router5/router5/tree/master/packages/router5-plugin-browser\",\n\"scripts\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-listeners/package.json",
"new_path": "packages/router5-plugin-listeners/package.json",
"diff": "\"router5-transition-path\": \"^8.0.0\"\n},\n\"peerDependencies\": {\n- \"router5\": \"^7.0.0\"\n+ \"router5\": \"^8.0.0\"\n},\n\"homepage\": \"https://github.com/router5/router5/tree/master/packages/router5-plugin-listeners\",\n\"scripts\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-logger/package.json",
"new_path": "packages/router5-plugin-logger/package.json",
"diff": "\"router5\": \"^8.0.0\"\n},\n\"peerDependencies\": {\n- \"router5\": \"^7.0.0\"\n+ \"router5\": \"^8.0.0\"\n},\n\"homepage\": \"https://github.com/router5/router5/tree/master/packages/router5-plugin-logger\"\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-plugin-persistent-params/package.json",
"new_path": "packages/router5-plugin-persistent-params/package.json",
"diff": "\"router5\": \"^8.0.0\"\n},\n\"peerDependencies\": {\n- \"router5\": \"^7.0.0\"\n+ \"router5\": \"^8.0.0\"\n},\n\"homepage\": \"https://github.com/router5/router5/tree/master/packages/router5-plugin-persistent-params\",\n\"scripts\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/router5-transition-path/package.json",
"new_path": "packages/router5-transition-path/package.json",
"diff": "},\n\"homepage\": \"https://github.com/router5/router5/tree/master/packages/router5-transition-path\",\n\"peerDependencies\": {\n- \"router5\": \"^7.0.0\"\n+ \"router5\": \"^8.0.0\"\n},\n\"scripts\": {\n\"test\": \"jest\"\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/rxjs-router5/package.json",
"new_path": "packages/rxjs-router5/package.json",
"diff": "\"router5-transition-path\": \"^8.0.0\"\n},\n\"peerDependencies\": {\n- \"router5\": \"^7.0.0\",\n+ \"router5\": \"^8.0.0\",\n\"rxjs\": \"^6.0.0\"\n},\n\"scripts\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "packages/xstream-router5/package.json",
"new_path": "packages/xstream-router5/package.json",
"diff": "\"router5-transition-path\": \"^8.0.0\"\n},\n\"peerDependencies\": {\n- \"router5\": \"^7.0.0\",\n+ \"router5\": \"^8.0.0\",\n\"xstream\": \"^10.0.0\"\n},\n\"scripts\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "unmaintained/react-router5-hocs/package.json",
"new_path": "unmaintained/react-router5-hocs/package.json",
"diff": "},\n\"peerDependencies\": {\n\"react\": \"^15.0.0 || ^16.0.0\",\n- \"router5\": \"^7.0.0\"\n+ \"router5\": \"^8.0.0\"\n}\n}\n"
}
] | TypeScript | MIT License | router5/router5 | fix: update Peer Dependencies to 8.x (#458) |
580,252 | 21.04.2020 23:05:06 | -3,600 | b79f999d55cedeac4e446166f60ccbf70e0f19ca | docs: improve withRouter hoc types | [
{
"change_type": "MODIFY",
"old_path": "packages/react-router5/modules/hocs/withRouter.tsx",
"new_path": "packages/react-router5/modules/hocs/withRouter.tsx",
"diff": "-import React, { SFC, ComponentType } from 'react'\n+import React, { ComponentType } from 'react'\nimport { Router } from 'router5'\nimport { routerContext } from '../context'\nfunction withRouter<P>(\nBaseComponent: ComponentType<P & { router: Router }>\n-): SFC<Exclude<P, 'router'>> {\n- return function WithRouter(props) {\n+): ComponentType<Omit<P, 'router'>> {\n+ return function WithRouter(props: P) {\nreturn (\n<routerContext.Consumer>\n{router => <BaseComponent {...props} router={router} />}\n"
}
] | TypeScript | MIT License | router5/router5 | docs: improve withRouter hoc types (#463) |
699 | 27.11.2017 21:46:36 | 21,600 | 3ad744e450993526c94567146f59d4a91a06c775 | subfolder template support, adds --help, --dir, --version cmd line options | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"ava\": \"^0.23.0\"\n},\n\"dependencies\": {\n+ \"chalk\": \"^2.3.0\",\n\"consolidate\": \"^0.15.0\",\n\"ejs\": \"^2.5.7\",\n\"fs-extra\": \"^4.0.2\",\n- \"globby\": \"^7.1.1\",\n\"glob-watcher\": \"^4.0.0\",\n+ \"globby\": \"^7.1.1\",\n\"gray-matter\": \"^3.1.1\",\n\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.0.11\",\n\"markdown-it\": \"^8.4.0\",\n\"minimist\": \"^1.2.0\",\n\"mustache\": \"^2.3.0\",\n+ \"normalize-path\": \"^2.1.1\",\n\"nunjucks\": \"^3.0.1\",\n\"parse-filepath\": \"^1.0.1\",\n\"promise\": \"^8.0.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -2,6 +2,7 @@ const ejs = require(\"ejs\");\nconst fs = require(\"fs-extra\");\nconst parsePath = require('parse-filepath');\nconst matter = require('gray-matter');\n+const normalize = require('normalize-path');\nconst TemplateRender = require( \"./TemplateRender\" );\nconst Layout = require( \"./Layout\" );\n@@ -11,13 +12,16 @@ function Template( path, globalData ) {\nthis.path = path;\nthis.inputContent = this.getInput();\nthis.parsed = parsePath( path );\n- this.dir = this.parsed.dir.replace( new RegExp( \"^\" + cfg.dir.templates ), \"\" );\n+ this.dir = this.cleanDir();\nthis.frontMatter = this.getMatter();\nthis.data = this.mergeData( globalData, this.frontMatter.data );\nthis.outputPath = this.getOutputPath();\n}\n+Template.prototype.cleanDir = function() {\n+ return normalize( this.parsed.dir.replace( /^\\.\\//, \"\" ).replace( new RegExp( \"^\" + cfg.dir.templates ), \"\" ) );\n+};\nTemplate.prototype.getOutputPath = function() {\n- return cfg.dir.output + \"/\" + ( this.dir ? this.dir + \"/\" : \"\" ) + this.parsed.name + \".html\";\n+ return normalize( cfg.dir.output + \"/\" + ( this.dir ? this.dir + \"/\" : \"\" ) + this.parsed.name + \".html\" );\n};\nTemplate.prototype.getInput = function() {\nreturn fs.readFileSync(this.path, \"utf-8\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -30,6 +30,8 @@ TemplateWriter.prototype.write = function() {\nlet tmpl = new Template( path, self.globalData );\ntmpl.write();\n});\n+\n+ console.log( \"Finished\", (new Date()).toLocaleTimeString() );\n});\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "templates/testing/test4.ejs",
"diff": "+sdlkjfkl<%= _package.version %>sldkjfskl\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "test/LayoutTest.js",
"new_path": "test/LayoutTest.js",
"diff": "@@ -2,10 +2,10 @@ import test from \"ava\";\nimport Layout from \"../src/Layout\";\ntest(t => {\n- t.is( (new Layout( \"default\", \"./test/LayoutStubs\" )).findFileName(), \"default.ejs\" );\n+ t.is( (new Layout( \"default\", \"./test/stubs\" )).findFileName(), \"default.ejs\" );\n});\ntest(t => {\n// pick the first one if multiple exist.\n- t.is( (new Layout( \"multiple\", \"./test/LayoutStubs\" )).findFileName(), \"multiple.ejs\" );\n+ t.is( (new Layout( \"multiple\", \"./test/stubs\" )).findFileName(), \"multiple.ejs\" );\n});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/TemplateTest.js",
"diff": "+import test from \"ava\";\n+import Template from \"../src/Template\";\n+\n+test(t => {\n+ let tmpl = new Template(\"./test/stubs/template.ejs\", {});\n+ t.is(tmpl.cleanDir(), \"test/stubs\");\n+});\n+\n+test(t => {\n+ let tmpl = new Template(\"./test/stubs/template.ejs\", {});\n+ t.is(tmpl.getOutputPath(), \"dist/test/stubs/template.html\");\n+});\n+\n+test(t => {\n+ let tmpl = new Template(\"./test/stubs/subfolder/subfolder.ejs\", {});\n+ t.is(tmpl.getOutputPath(), \"dist/test/stubs/subfolder/subfolder.html\");\n+});\n"
},
{
"change_type": "RENAME",
"old_path": "test/LayoutStubs/default.ejs",
"new_path": "test/stubs/default.ejs",
"diff": ""
},
{
"change_type": "RENAME",
"old_path": "test/LayoutStubs/multiple.ejs",
"new_path": "test/stubs/multiple.ejs",
"diff": ""
},
{
"change_type": "RENAME",
"old_path": "test/LayoutStubs/multiple.md",
"new_path": "test/stubs/multiple.md",
"diff": ""
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/subfolder/subfolder.ejs",
"diff": "+subfolder\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": "test/stubs/template.ejs",
"new_path": "test/stubs/template.ejs",
"diff": ""
}
] | JavaScript | MIT License | 11ty/eleventy | subfolder template support, adds --help, --dir, --version cmd line options |
699 | 27.11.2017 21:55:05 | 21,600 | 3bce7b5b3c45f78cf82f6a772b45d6729a988290 | Ignoring _ prefixed files. | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -29,6 +29,10 @@ Template.prototype.getInput = function() {\nTemplate.prototype.getMatter = function() {\nreturn matter( this.inputContent );\n};\n+Template.prototype.isIgnored = function() {\n+ return this.parsed.name.match(/^\\_/) !== null;\n+};\n+\nTemplate.prototype.mergeData = function( globalData, pageData ) {\nlet data = {};\nfor( let j in globalData ) {\n@@ -67,11 +71,15 @@ Template.prototype.render = function() {\n}\n};\nTemplate.prototype.write = function() {\n+ if( this.isIgnored() ) {\n+ console.log( \"Ignoring\", this.outputPath );\n+ } else {\nlet err = fs.outputFileSync(this.outputPath, this.render());\nif(err) {\nthrow err;\n}\nconsole.log( \"Writing\", this.outputPath );\n+ }\n};\nmodule.exports = Template;\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "templates/_ignored.ejs",
"diff": "+Ignored.\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -15,3 +15,8 @@ test(t => {\nlet tmpl = new Template(\"./test/stubs/subfolder/subfolder.ejs\", {});\nt.is(tmpl.getOutputPath(), \"dist/test/stubs/subfolder/subfolder.html\");\n});\n+\n+test(t => {\n+ let tmpl = new Template(\"./test/stubs/_ignored.ejs\", {});\n+ t.is(tmpl.isIgnored(), true);\n+});\n"
},
{
"change_type": "ADD",
"old_path": "test/stubs/_ignored.ejs",
"new_path": "test/stubs/_ignored.ejs",
"diff": ""
}
] | JavaScript | MIT License | 11ty/eleventy | Ignoring _ prefixed files. |
699 | 27.11.2017 22:02:53 | 21,600 | 27122851028a062b609b7e76d64032515788a684 | Adds --output and --dir options | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -8,20 +8,21 @@ const Layout = require( \"./Layout\" );\nconst cfg = require(\"../config.json\");\n-function Template( path, globalData ) {\n+function Template( path, globalData, outputDir ) {\nthis.path = path;\nthis.inputContent = this.getInput();\nthis.parsed = parsePath( path );\nthis.dir = this.cleanDir();\nthis.frontMatter = this.getMatter();\nthis.data = this.mergeData( globalData, this.frontMatter.data );\n+ this.outputDir = outputDir;\nthis.outputPath = this.getOutputPath();\n}\nTemplate.prototype.cleanDir = function() {\nreturn normalize( this.parsed.dir.replace( /^\\.\\//, \"\" ).replace( new RegExp( \"^\" + cfg.dir.templates ), \"\" ) );\n};\nTemplate.prototype.getOutputPath = function() {\n- return normalize( cfg.dir.output + \"/\" + ( this.dir ? this.dir + \"/\" : \"\" ) + this.parsed.name + \".html\" );\n+ return normalize( this.outputDir + \"/\" + ( this.dir ? this.dir + \"/\" : \"\" ) + this.parsed.name + \".html\" );\n};\nTemplate.prototype.getInput = function() {\nreturn fs.readFileSync(this.path, \"utf-8\");\n@@ -50,7 +51,7 @@ Template.prototype.renderLayout = function(tmpl, data) {\nlet layoutPath = (new Layout( tmpl.data.layout, cfg.dir.templates + \"/_layouts\" )).getFullPath();\nconsole.log( \"Reading layout \" + tmpl.data.layout + \":\", layoutPath );\n- let layout = new Template( layoutPath, {} );\n+ let layout = new Template( layoutPath, {}, this.outputDir );\nlet layoutData = this.mergeData( layout.data, data );\nlayoutData._layoutContent = this.renderContent( tmpl.getPreRender(), data );\nlet rendered = layout.renderContent( layout.getPreRender(), layoutData );\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -5,12 +5,14 @@ const Template = require( \"./Template\" );\nconst TemplateRender = require( \"./TemplateRender\" );\nconst PKG = require(\"../package.json\");\n-function TemplateWriter(files, globalDataPath) {\n+function TemplateWriter(files, globalDataPath, outputDir) {\nthis.files = files;\nthis.globalRenderFunction = (new TemplateRender()).getRenderFunction();\nthis.globalDataPath = globalDataPath;\nthis.globalData = this.mergeDataImports(this.readJsonAsTemplate(globalDataPath));\n+\n+ this.outputDir = outputDir;\n}\nTemplateWriter.prototype.mergeDataImports = function(data) {\n@@ -27,7 +29,7 @@ TemplateWriter.prototype.write = function() {\nglobby(this.files).then(function(templates) {\ntemplates.forEach(function(path) {\nconsole.log( \"Reading\", path );\n- let tmpl = new Template( path, self.globalData );\n+ let tmpl = new Template( path, self.globalData, self.outputDir );\ntmpl.write();\n});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds --output and --dir options |
699 | 27.11.2017 22:34:51 | 21,600 | 03c3ac603e45d71e06a4343aa2e0d1234d3d75f7 | Switch to --input instead of --dir | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -8,13 +8,14 @@ const TemplateWriter = require(\"./src/TemplateWriter\");\nconst pkg = require(\"./package.json\");\nconst cfg = require(\"./config.json\");\n// argv._ ? argv._ :\n-const dir = argv.dir ? argv.dir : cfg.dir.templates;\n+const dir = argv.input ? argv.input : cfg.dir.templates;\nlet files = cfg.templateFormats.map(function(extension) {\nreturn normalize( dir + \"/**/*.\" + extension );\n-}).concat( \"!\" + normalize( dir + \"/_layouts/*\" ) );\n+});\nlet writer = new TemplateWriter(\n+ dir,\nfiles,\ncfg.dataFileName,\nargv.output || cfg.dir.output\n@@ -26,13 +27,13 @@ if( argv.version ) {\nlet out = [];\nout.push( \"usage: elevenisland\" );\nout.push( \" elevenisland --watch\" );\n- out.push( \" elevenisland --dir=./templates --output=./dist\" );\n+ out.push( \" elevenisland --input=./templates --output=./dist\" );\nout.push( \"\" );\nout.push( \"arguments: \" );\nout.push( \" --version\" );\nout.push( \" --watch\" );\nout.push( \" Wait for files to change and automatically rewrite.\" );\n- out.push( \" --dir\" );\n+ out.push( \" --input\" );\nout.push( \" Input template files (default: `templates`)\" );\nout.push( \" --output\" );\nout.push( \" Write HTML output to this folder (default: `dist`)\" );\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "const fs = require(\"fs-extra\");\nconst globby = require('globby');\n+const normalize = require('normalize-path');\nconst Template = require( \"./Template\" );\nconst TemplateRender = require( \"./TemplateRender\" );\nconst PKG = require(\"../package.json\");\n-function TemplateWriter(files, globalDataPath, outputDir) {\n- this.files = files;\n+function TemplateWriter(baseDir, files, globalDataPath, outputDir) {\n+ this.baseDir = baseDir;\n+ this.files = this.addFiles(baseDir, files);\nthis.globalRenderFunction = (new TemplateRender()).getRenderFunction();\nthis.globalDataPath = globalDataPath;\n@@ -15,6 +17,10 @@ function TemplateWriter(files, globalDataPath, outputDir) {\nthis.outputDir = outputDir;\n}\n+TemplateWriter.prototype.addFiles = function(baseDir, files) {\n+ return files.concat( \"!\" + normalize( baseDir + \"/_layouts/*\" ) );\n+};\n+\nTemplateWriter.prototype.mergeDataImports = function(data) {\ndata._package = PKG;\nreturn data;\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Switch to --input instead of --dir |
699 | 27.11.2017 22:36:21 | 21,600 | 6bf4d55e74521b7549c4aa0234b52df1ccceccba | README commands | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -19,6 +19,13 @@ elevenisland\n# Watch\nelevenisland --watch\n+\n+# Modify directories\n+elevenisland --input=./templates --output=./dist\n+\n+# Version and Help\n+elevenisland --version\n+elevenisland --help\n```\n### Advanced\n@@ -30,7 +37,6 @@ elevenisland --watch\n## TODO\n* Partials/helpers\n-* Think about default transforming the current directory instead of `templates/`\n## Tests\n"
}
] | JavaScript | MIT License | 11ty/eleventy | README commands |
699 | 27.11.2017 23:57:02 | 21,600 | 7602ea2e3efccd6be05ccabfd394da237d9ae110 | Start of a helpers/components dir | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -10,6 +10,7 @@ const cfg = require(\"./config.json\");\n// argv._ ? argv._ :\nconst dir = argv.input ? argv.input : cfg.dir.templates;\n+let start = new Date();\nlet files = cfg.templateFormats.map(function(extension) {\nreturn normalize( dir + \"/**/*.\" + extension );\n});\n@@ -55,5 +56,6 @@ if( argv.version ) {\n});\n} else {\nwriter.write();\n+ console.log( \"Finished in\", (((new Date()) - start)/1000).toFixed(2),\"seconds\" );\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Layout.js",
"new_path": "src/Layout.js",
"diff": "@@ -15,7 +15,7 @@ Layout.prototype.getFullPath = function() {\nLayout.prototype.findFileName = function() {\nlet file;\nif( !fs.existsSync(this.dir) ) {\n- throw Error( \"Layout directory does not exist: \" + this.dir );\n+ throw Error( \"Layout directory does not exist for \" + this.name + \": \" + this.dir );\n}\nCFG.templateFormats.forEach(function( extension ) {\nlet filename = this.name + \".\" + extension;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -12,17 +12,17 @@ function Template( path, globalData, outputDir ) {\nthis.path = path;\nthis.inputContent = this.getInput();\nthis.parsed = parsePath( path );\n- this.dir = this.cleanDir();\nthis.frontMatter = this.getMatter();\nthis.data = this.mergeData( globalData, this.frontMatter.data );\nthis.outputDir = outputDir;\nthis.outputPath = this.getOutputPath();\n}\n-Template.prototype.cleanDir = function() {\n+Template.prototype.cleanOutputDir = function() {\nreturn normalize( this.parsed.dir.replace( /^\\.\\//, \"\" ).replace( new RegExp( \"^\" + cfg.dir.templates ), \"\" ) );\n};\nTemplate.prototype.getOutputPath = function() {\n- return normalize( this.outputDir + \"/\" + ( this.dir ? this.dir + \"/\" : \"\" ) + this.parsed.name + \".html\" );\n+ let dir = this.cleanOutputDir();\n+ return normalize( this.outputDir + \"/\" + ( dir ? dir + \"/\" : \"\" ) + this.parsed.name + \".html\" );\n};\nTemplate.prototype.getInput = function() {\nreturn fs.readFileSync(this.path, \"utf-8\");\n@@ -31,10 +31,10 @@ Template.prototype.getMatter = function() {\nreturn matter( this.inputContent );\n};\nTemplate.prototype.isIgnored = function() {\n- return this.parsed.name.match(/^\\_/) !== null;\n+ return this.parsed.name.match(/^\\_/) !== null || this.outputDir === false;\n};\n-Template.prototype.mergeData = function( globalData, pageData ) {\n+Template.prototype.mergeData = function( globalData, pageData, localData ) {\nlet data = {};\nfor( let j in globalData ) {\ndata[ j ] = globalData[ j ];\n@@ -42,15 +42,20 @@ Template.prototype.mergeData = function( globalData, pageData ) {\nfor( let j in pageData ) {\ndata[ j ] = pageData[ j ];\n}\n+ if( localData ) {\n+ for( let j in localData ) {\n+ data[ j ] = localData[ j ];\n+ }\n+ }\nreturn data;\n};\nTemplate.prototype.getPreRender = function() {\nreturn this.frontMatter.content;\n};\nTemplate.prototype.renderLayout = function(tmpl, data) {\n- let layoutPath = (new Layout( tmpl.data.layout, cfg.dir.templates + \"/_layouts\" )).getFullPath();\n+ let layoutPath = (new Layout( tmpl.data.layout, this.parsed.dir + \"/_layouts\" )).getFullPath();\n- console.log( \"Reading layout \" + tmpl.data.layout + \":\", layoutPath );\n+ console.log( \"Found layout `\" + tmpl.data.layout + \"`:\", layoutPath );\nlet layout = new Template( layoutPath, {}, this.outputDir );\nlet layoutData = this.mergeData( layout.data, data );\nlayoutData._layoutContent = this.renderContent( tmpl.getPreRender(), data );\n@@ -61,8 +66,14 @@ Template.prototype.renderLayout = function(tmpl, data) {\nreturn rendered;\n};\n+Template.prototype.getTemplateRender = function() {\n+ return ( new TemplateRender( this.path ));\n+};\n+Template.prototype.getCompiledTemplate = function() {\n+ return this.getTemplateRender().getCompiledTemplate(this.getPreRender());\n+};\nTemplate.prototype.renderContent = function( str, data ) {\n- return ( new TemplateRender( this.path )).getRenderFunction()( str, data );\n+ return this.getTemplateRender().getRenderFunction()( str, data );\n};\nTemplate.prototype.render = function() {\nif( this.data.layout ) {\n@@ -79,7 +90,7 @@ Template.prototype.write = function() {\nif(err) {\nthrow err;\n}\n- console.log( \"Writing\", this.outputPath );\n+ console.log( \"Writing\", this.outputPath, \"from\", this.path );\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -11,9 +11,31 @@ function TemplateRender( path ) {\nthis.parsed = path ? parsePath( path ) : undefined;\n}\n+TemplateRender.prototype.getCompiledTemplate = function(str) {\n+ if( !this.parsed || this.parsed.ext === \".ejs\" ) {\n+ return ejs.compile(str);\n+ } else if( this.parsed.ext === \".md\" ) {\n+ throw new Error( \"Markdown is not a supported compiled template in TemplateRender.getCompiledTemplate\");\n+ } else if( this.parsed.ext === \".hbs\" ) {\n+ return Handlebars.compile(str);\n+ } else if( this.parsed.ext === \".mustache\" ) {\n+ return function(data) {\n+ return Mustache.render(str, data).trim();\n+ };\n+ } else if( this.parsed.ext === \".haml\" ) {\n+ return haml.compile(str);\n+ } else if( this.parsed.ext === \".pug\" ) {\n+ return pug.compile(str);\n+ } else if( this.parsed.ext === \".njk\" ) {\n+ return (new nunjucks.Template(str)).render;\n+ }\n+};\n+\nTemplateRender.prototype.getRenderFunction = function() {\nif( !this.parsed || this.parsed.ext === \".ejs\" ) {\n- return ejs.render;\n+ return function(str, data) {\n+ return ejs.compile(str)(data);\n+ };\n} else if( this.parsed.ext === \".md\" ) {\nreturn function(str, data) {\nvar render = (new TemplateRender()).getRenderFunction();\n@@ -22,11 +44,11 @@ TemplateRender.prototype.getRenderFunction = function() {\n} else if( this.parsed.ext === \".hbs\" ) {\nreturn function(str, data) {\nreturn Handlebars.compile(str)(data).trim();\n- }\n+ };\n} else if( this.parsed.ext === \".mustache\" ) {\nreturn function(str, data) {\nreturn Mustache.render(str, data).trim();\n- }\n+ };\n} else if( this.parsed.ext === \".haml\" ) {\nreturn function(str, data) {\nreturn haml.compile(str)(data).trim();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "const fs = require(\"fs-extra\");\nconst globby = require('globby');\nconst normalize = require('normalize-path');\n+const parsePath = require('parse-filepath');\nconst Template = require( \"./Template\" );\nconst TemplateRender = require( \"./TemplateRender\" );\n@@ -18,11 +19,23 @@ function TemplateWriter(baseDir, files, globalDataPath, outputDir) {\n}\nTemplateWriter.prototype.addFiles = function(baseDir, files) {\n- return files.concat( \"!\" + normalize( baseDir + \"/_layouts/*\" ) );\n+ return files.concat( \"!\" + normalize( baseDir + \"/_layouts/*\" ), \"!\" + normalize( baseDir + \"/_components/*\" ) );\n};\nTemplateWriter.prototype.mergeDataImports = function(data) {\ndata._package = PKG;\n+ data._components = {};\n+\n+ let self = this;\n+ globby.sync(this.baseDir + \"/_components/*\" ).forEach(function(component) {\n+ let parsed = parsePath( component );\n+ data._components[ parsed.name ] = function(data) {\n+ let tmpl = new Template( component, self.globalData, false );\n+ let merged = tmpl.mergeData(self.globalData, tmpl.getMatter().data, data);\n+ return tmpl.getCompiledTemplate()(merged);\n+ };\n+ });\n+\nreturn data;\n};\n@@ -32,15 +45,10 @@ TemplateWriter.prototype.readJsonAsTemplate = function( path ) {\nTemplateWriter.prototype.write = function() {\nlet self = this;\n- globby(this.files).then(function(templates) {\n- templates.forEach(function(path) {\n- console.log( \"Reading\", path );\n+ globby.sync(this.files).forEach(function(path) {\nlet tmpl = new Template( path, self.globalData, self.outputDir );\ntmpl.write();\n});\n-\n- console.log( \"Finished\", (new Date()).toLocaleTimeString() );\n- });\n};\nmodule.exports = TemplateWriter;\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "templates/_components/list.ejs",
"diff": "+---\n+defaultString: \"DEFAULT STRING!\"\n+---\n+\n+<p><%= defaultString %></p>\n+<ul>\n+<% for(var j=0, k=items.length; j<k; j++) { %>\n+ <li><%= items[ j ]; %></li>\n+<% } %>\n+</ul>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/test.ejs",
"new_path": "templates/test.ejs",
"diff": "@@ -14,6 +14,8 @@ This is a teslkjdfklsjfkl kjsldjfkla\n<h1><%= version %></h1>\n<h1><%= title %></h1>\n+<%- _components.list({items: [\"first item\", \"second item\"]}) %>\n+\n<%= globaltitle %>\n<%= daysPosted %>\n<%= permalink %>\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderTest.js",
"new_path": "test/TemplateRenderTest.js",
"diff": "@@ -5,11 +5,7 @@ import TemplateRender from \"../src/TemplateRender\";\n// EJS\ntest(t => {\nt.is( (new TemplateRender( \"default.ejs\" )).parsed.ext, \".ejs\" );\n-\n- t.is( (new TemplateRender()).getRenderFunction(), ejs.render );\nt.is( (new TemplateRender()).getRenderFunction()(\"<p><%= name %></p>\", {name: \"Zach\"}), \"<p>Zach</p>\" );\n-\n- t.is( (new TemplateRender( \"default.ejs\" )).getRenderFunction(), ejs.render );\nt.is( (new TemplateRender( \"default.ejs\" )).getRenderFunction()(\"<p><%= name %></p>\", {name: \"Zach\"}), \"<p>Zach</p>\" );\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -2,21 +2,21 @@ import test from \"ava\";\nimport Template from \"../src/Template\";\ntest(t => {\n- let tmpl = new Template(\"./test/stubs/template.ejs\", {});\n- t.is(tmpl.cleanDir(), \"test/stubs\");\n+ let tmpl = new Template(\"./test/stubs/template.ejs\", {}, \"dist\");\n+ t.is(tmpl.cleanOutputDir(), \"test/stubs\");\n});\ntest(t => {\n- let tmpl = new Template(\"./test/stubs/template.ejs\", {});\n+ let tmpl = new Template(\"./test/stubs/template.ejs\", {}, \"dist\");\nt.is(tmpl.getOutputPath(), \"dist/test/stubs/template.html\");\n});\ntest(t => {\n- let tmpl = new Template(\"./test/stubs/subfolder/subfolder.ejs\", {});\n+ let tmpl = new Template(\"./test/stubs/subfolder/subfolder.ejs\", {}, \"dist\");\nt.is(tmpl.getOutputPath(), \"dist/test/stubs/subfolder/subfolder.html\");\n});\ntest(t => {\n- let tmpl = new Template(\"./test/stubs/_ignored.ejs\", {});\n+ let tmpl = new Template(\"./test/stubs/_ignored.ejs\", {}, \"dist\");\nt.is(tmpl.isIgnored(), true);\n});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Start of a helpers/components dir |
699 | 01.12.2017 08:32:11 | 21,600 | 3dd2f56a025653471824588fb060a52cbeac6fdf | Cleanup TemplateRender, adds a bunch more tests. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -9,47 +9,65 @@ const pug = require('pug');\nconst nunjucks = require('nunjucks');\nconst liquidEngine = require('liquidjs')();\n+// TODO make path and str for template content independent, why do we even need a path here?\nfunction TemplateRender( path ) {\nthis.parsed = path ? parsePath( path ) : undefined;\n+ this.engine = this.parsed && this.parsed.ext ? this.parsed.ext.substr(1) : path;\n+ this.defaultMarkdownEngine = \"ejs\";\n}\n+TemplateRender.prototype.setDefaultMarkdownEngine = function(markdownEngine) {\n+ this.defaultMarkdownEngine = markdownEngine;\n+};\n+\nTemplateRender.prototype.render = async function(str, data) {\nlet fn = await this.getCompiledTemplatePromise(str);\nreturn fn(data);\n};\n-TemplateRender.prototype.getCompiledTemplatePromise = function(str) {\n- return new Promise(function (resolve, reject) {\n- if( !this.parsed || this.parsed.ext === \".ejs\" ) {\n- resolve( ejs.compile(str) );\n- } else if( this.parsed.ext === \".md\" ) {\n- (new TemplateRender()).getCompiledTemplatePromise(str).then(function(fn) {\n- resolve(function(data) {\n- return md.render(fn(data));\n- });\n- });\n- } else if( this.parsed.ext === \".hbs\" ) {\n- resolve(Handlebars.compile(str));\n- } else if( this.parsed.ext === \".mustache\" ) {\n- resolve(function(data) {\n+TemplateRender.prototype.getCompiledTemplatePromise = async function(str, options) {\n+ options = Object.assign({\n+ parseMarkdownWith: this.defaultMarkdownEngine\n+ }, options);\n+\n+ if( !this.engine || this.engine === \"ejs\" ) {\n+ return ejs.compile(str);\n+ } else if( this.engine === \"md\" ) {\n+ if( options.parseMarkdownWith ) {\n+ let fn = await ((new TemplateRender(options.parseMarkdownWith)).getCompiledTemplatePromise(str));\n+\n+ return async function(data) {\n+ return md.render(await fn(data));\n+ };\n+ } else {\n+ return function(data) {\n+ // do nothing with data if parseMarkdownWith is falsy\n+ return md.render(str);\n+ };\n+ }\n+ } else if( this.engine === \"hbs\" ) {\n+ return Handlebars.compile(str);\n+ } else if( this.engine === \"mustache\" ) {\n+ return function(data) {\nreturn Mustache.render(str, data).trim();\n- });\n- } else if( this.parsed.ext === \".haml\" ) {\n- resolve(haml.compile(str));\n- } else if( this.parsed.ext === \".pug\" ) {\n- resolve(pug.compile(str));\n- } else if( this.parsed.ext === \".njk\" ) {\n+ };\n+ } else if( this.engine === \"haml\" ) {\n+ return haml.compile(str);\n+ } else if( this.engine === \"pug\" ) {\n+ return pug.compile(str);\n+ } else if( this.engine === \"njk\" ) {\nlet tmpl = new nunjucks.Template(str);\n- resolve(function(data) {\n+ return function(data) {\nreturn tmpl.render(data);\n- });\n- } else if( this.parsed.ext === \".liquid\" ) {\n- let tmpl = liquidEngine.parse(str);\n- resolve(function(data) {\n- return liquidEngine.render(tmpl, data); // is a promise too fuuuuck\n- });\n+ };\n+ } else if( this.engine === \"liquid\" ) {\n+ let tmpl = await liquidEngine.parse(str);\n+ return async function(data) {\n+ return await liquidEngine.render(tmpl, data);\n+ };\n+ } else {\n+ throw new Error(engine + \" is not a supported template engine.\");\n}\n- }.bind(this));\n};\nmodule.exports = TemplateRender;\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderTest.js",
"new_path": "test/TemplateRenderTest.js",
"diff": "import test from \"ava\";\nimport ejs from \"ejs\";\nimport TemplateRender from \"../src/TemplateRender\";\n+import parsePath from \"parse-filepath\";\n-// EJS\ntest(t => {\n- t.is( (new TemplateRender( \"default.ejs\" )).parsed.ext, \".ejs\" );\n+ // Path is unnecessary but supported\n+ t.truthy((new TemplateRender(\"default.ejs\")).parsed);\n+ t.is((new TemplateRender(\"default.ejs\")).engine, \"ejs\");\n+\n+ // Better\n+ t.truthy((new TemplateRender(\"ejs\")).parsed);\n+ t.is((new TemplateRender(\"ejs\")).engine, \"ejs\");\n+});\n+\n+test(\"Unsupported engine\", async t => {\n+ t.is( (new TemplateRender( \"doesnotexist\" )).engine, \"doesnotexist\" );\n+\n+ await t.throws( (new TemplateRender( \"doesnotexist\" )).getCompiledTemplatePromise(\"<p></p>\") );\n});\n-test(async t => {\n- let fn = await (new TemplateRender( \"default.ejs\" )).getCompiledTemplatePromise(\"<p><%= name %></p>\");\n+\n+// EJS\n+test(\"EJS\", async t => {\n+ t.is( (new TemplateRender( \"ejs\" )).engine, \"ejs\" );\n+\n+ let fn = await (new TemplateRender( \"ejs\" )).getCompiledTemplatePromise(\"<p><%= name %></p>\");\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n});\n// Markdown\n-test(t => {\n- t.is( (new TemplateRender( \"markdown.md\" )).parsed.ext, \".md\" );\n+test(\"Markdown\", t => {\n+ t.is( (new TemplateRender( \"md\" )).engine, \"md\" );\n});\n-test(async t => {\n- let fn = await (new TemplateRender( \"markdown.md\" )).getCompiledTemplatePromise(\"# Header\");\n+\n+test(\"Markdown: Parses base markdown\", async t => {\n+ let fn = await (new TemplateRender( \"md\" )).getCompiledTemplatePromise(\"# Header\");\nt.is( (await fn()).trim(), \"<h1>Header</h1>\" );\n});\n-// Handlebars\n-test(t => {\n- t.is( (new TemplateRender( \"handlebars.hbs\" )).parsed.ext, \".hbs\" );\n+test(\"Markdown: Parses templates using default engine\", async t => {\n+ let fn = await (new TemplateRender( \"md\" )).getCompiledTemplatePromise(\"# <%=title %>\");\n+ t.is( (await fn({title: \"My Title\"})).trim(), \"<h1>My Title</h1>\" );\n+});\n+\n+test(\"Markdown: Override markdown engine no data\", async t => {\n+ let fn = await (new TemplateRender( \"md\" )).getCompiledTemplatePromise(\"# My Title\", {\n+ parseMarkdownWith: \"liquid\"\n+ });\n+\n+ t.is( (await fn()).trim(), \"<h1>My Title</h1>\" );\n+});\n+\n+test(\"Markdown: Override markdown engine\", async t => {\n+ let fn = await ((new TemplateRender( \"md\" )).getCompiledTemplatePromise(\"# {{title}}\", {\n+ parseMarkdownWith: \"liquid\"\n+ }));\n+ t.is( (await fn({title: \"My Title\"})).trim(), \"<h1>My Title</h1>\" );\n+});\n+\n+test(\"Markdown: Set markdown engine to false\", async t => {\n+ let fn = await ((new TemplateRender( \"md\" )).getCompiledTemplatePromise(\"# {{title}}\", {\n+ parseMarkdownWith: false\n+ }));\n+ t.is( (await fn()).trim(), \"<h1>{{title}}</h1>\" );\n+});\n+\n+test(\"Markdown: Change the default engine\", async t => {\n+ let tr = new TemplateRender( \"md\" );\n+ tr.setDefaultMarkdownEngine(\"liquid\");\n+\n+ let fn = await (tr.getCompiledTemplatePromise(\"# {{title}}\"));\n+ t.is( (await fn({title: \"My Title\"})).trim(), \"<h1>My Title</h1>\" );\n});\n-test(async t => {\n- let fn = await (new TemplateRender( \"handlebars.hbs\" )).getCompiledTemplatePromise(\"<p>{{name}}</p>\");\n+\n+test(\"Markdown: Change the default engine and pass in an override\", async t => {\n+ let tr = new TemplateRender( \"md\" );\n+ tr.setDefaultMarkdownEngine(\"njk\");\n+\n+ let fn = await (tr.getCompiledTemplatePromise(\"# {{title}}\", {\n+ parseMarkdownWith: \"liquid\"\n+ }));\n+\n+ t.is( (await fn({title: \"My Title\"})).trim(), \"<h1>My Title</h1>\" );\n+});\n+\n+// Handlebars\n+test(\"Handlebars\", async t => {\n+ t.is( (new TemplateRender( \"hbs\" )).engine, \"hbs\" );\n+\n+ let fn = await (new TemplateRender( \"hbs\" )).getCompiledTemplatePromise(\"<p>{{name}}</p>\");\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n});\n// Mustache\n-test(t => {\n- t.is( (new TemplateRender( \"mustache.mustache\" )).parsed.ext, \".mustache\" );\n-});\n-test(async t => {\n- let fn = await (new TemplateRender( \"mustache.mustache\" )).getCompiledTemplatePromise(\"<p>{{name}}</p>\");\n+test(\"Mustache\", async t => {\n+ t.is( (new TemplateRender( \"mustache\" )).engine, \"mustache\" );\n+\n+ let fn = await (new TemplateRender( \"mustache\" )).getCompiledTemplatePromise(\"<p>{{name}}</p>\");\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n});\n// Haml\n-test(t => {\n- t.is( (new TemplateRender( \"haml.haml\" )).parsed.ext, \".haml\" );\n-});\n-test(async t => {\n- let fn = await (new TemplateRender( \"haml.haml\" )).getCompiledTemplatePromise(\"%p= name\");\n+test(\"Haml\", async t => {\n+ t.is( (new TemplateRender( \"haml\" )).engine, \"haml\" );\n+\n+ let fn = await (new TemplateRender( \"haml\" )).getCompiledTemplatePromise(\"%p= name\");\nt.is( (await fn({name: \"Zach\"})).trim(), \"<p>Zach</p>\" );\n});\n// Pug\n-test(t => {\n- t.is( (new TemplateRender( \"pug.pug\" )).parsed.ext, \".pug\" );\n-});\n-test(async t => {\n- let fn = await (new TemplateRender( \"pug.pug\" )).getCompiledTemplatePromise(\"p= name\");\n+test(\"Pug\", async t => {\n+ t.is( (new TemplateRender( \"pug\" )).engine, \"pug\" );\n+\n+ let fn = await (new TemplateRender( \"pug\" )).getCompiledTemplatePromise(\"p= name\");\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n});\n// Nunjucks\n-test(t => {\n- t.is( (new TemplateRender( \"nunjucks.njk\" )).parsed.ext, \".njk\" );\n-});\n-test(async t => {\n- let fn = await (new TemplateRender( \"nunjucks.njk\" )).getCompiledTemplatePromise(\"<p>{{ name }}</p>\");\n+test(\"Nunjucks\", async t => {\n+ t.is( (new TemplateRender( \"njk\" )).engine, \"njk\" );\n+\n+ let fn = await (new TemplateRender( \"njk\" )).getCompiledTemplatePromise(\"<p>{{ name }}</p>\");\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n});\n// Liquid\n-test(t => {\n- t.is( (new TemplateRender( \"liquid.liquid\" )).parsed.ext, \".liquid\" );\n-});\n-test(async t => {\n- let fn = await (new TemplateRender( \"liquid.liquid\" )).getCompiledTemplatePromise(\"<p>{{name | capitalize}}</p>\");\n+test(\"Liquid\", async t => {\n+ t.is( (new TemplateRender( \"liquid\" )).engine, \"liquid\" );\n+\n+ let fn = await (new TemplateRender( \"liquid\" )).getCompiledTemplatePromise(\"<p>{{name | capitalize}}</p>\");\nt.is(await fn({name: \"tim\"}), \"<p>Tim</p>\" );\n});\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Cleanup TemplateRender, adds a bunch more tests. |
699 | 01.12.2017 22:48:34 | 21,600 | 56e396ecc20a229907d738010efff481f0be20e0 | Fixed a bunch of bugs with inputDirs that are not a direct child of cmd. Adds --formats | [
{
"change_type": "MODIFY",
"old_path": ".gitignore",
"new_path": ".gitignore",
"diff": "dist/\n+_site/\nnode_modules/\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -28,6 +28,16 @@ elevenisland --input=./templates --output=./dist\nelevenisland --help\n```\n+### Examples\n+\n+```\n+# Watch a directory for any changes to markdown files, then\n+# automatically parse and output as HTML files, respecting\n+# directory structure.\n+\n+elevenisland --input=. --output=. --watch --formats=md\n+```\n+\n### Advanced\n* Modify `data.json` to set global static data available to templates.\n"
},
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "{\n\"globalDataFile\": \"./data.json\",\n- \"templateFormats\": [\"ejs\", \"md\", \"hbs\", \"mustache\", \"haml\", \"pug\", \"njk\", \"liquid\"],\n+ \"templateFormats\": [\"liquid\", \"ejs\", \"md\", \"hbs\", \"mustache\", \"haml\", \"pug\", \"njk\"],\n+ \"markdownTemplateEngine\": \"liquid\",\n\"dir\": {\n\"templates\": \"templates\",\n\"layouts\": \"_layouts\",\n\"components\": \"_components\",\n- \"output\": \"dist\"\n+ \"output\": \"_site\"\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -8,17 +8,25 @@ const Layout = require(\"./Layout\");\nconst cfg = require(\"../config.json\");\n-function Template(path, outputDir, templateData) {\n+function Template(path, inputDir, outputDir, templateData) {\nthis.inputPath = path;\n- this.inputContent = fs.readFileSync(this.inputPath, \"utf-8\");\n-\n+ this.inputContent = fs.readFileSync(path, \"utf-8\");\nthis.parsed = parsePath(path);\n- this.frontMatter = this.getMatter();\n-\n- this.layoutsDir = this.cleanLayoutDir(this.parsed.dir + \"/\" + cfg.dir.layouts);\n- this.outputDir = outputDir;\n+ if( inputDir ) {\n+ this.inputDir = normalize( inputDir );\n+ this.layoutsDir = this.inputDir + \"/\" + cfg.dir.layouts;\n+ } else {\n+ this.inputDir = false;\n+ }\n+ if( outputDir ) {\n+ this.outputDir = normalize( outputDir );\nthis.outputPath = this.getOutputPath();\n+ } else {\n+ this.outputDir = false;\n+ }\n+\n+ this.frontMatter = this.getMatter();\nthis.postProcessFilters = [];\nthis.templateData = templateData;\n@@ -26,24 +34,20 @@ function Template(path, outputDir, templateData) {\nthis.templateRender = new TemplateRender(this.inputPath);\n}\n-Template.prototype.cleanLayoutDir = function(dir) {\n- return (\n- dir\n- .replace(new RegExp(\"/?\" + cfg.dir.layouts, \"g\"), \"\")\n- .replace(new RegExp(\"/?\" + cfg.dir.components, \"g\"), \"\") +\n- \"/\" +\n- cfg.dir.layouts\n- );\n+Template.prototype.stripLeadingDotSlash = function(dir) {\n+ return dir.replace(/^\\.\\//, \"\");\n};\n-Template.prototype.cleanOutputDir = function() {\n- return normalize(\n- this.parsed.dir.replace(/^\\.\\//, \"\").replace(new RegExp(\"^\" + cfg.dir.templates), \"\")\n- );\n+Template.prototype.getTemplateSubfolder = function() {\n+ var pathDir = this.parsed.dir;\n+ var index = pathDir.indexOf( this.inputDir );\n+\n+ return this.stripLeadingDotSlash( index > -1 ? pathDir.substr( this.inputDir.length + 1 ) : this.inputDir );\n};\nTemplate.prototype.getOutputPath = function() {\n- let dir = this.cleanOutputDir();\n+ let dir = this.getTemplateSubfolder();\n+// console.log( this.inputPath,\"|\", this.inputDir, \"|\", dir );\nreturn normalize(this.outputDir + \"/\" + (dir ? dir + \"/\" : \"\") + this.parsed.name + \".html\");\n};\n@@ -61,7 +65,7 @@ Template.prototype.getPreRender = function() {\nTemplate.prototype.getLayoutTemplate = function(name) {\nlet path = new Layout(name, this.layoutsDir).getFullPath();\n- return new Template(path, this.outputDir);\n+ return new Template(path, this.inputDir, this.outputDir);\n};\nTemplate.prototype.getFrontMatterData = function() {\n@@ -149,9 +153,9 @@ Template.prototype.write = async function() {\nif (this.isIgnored()) {\nconsole.log(\"Ignoring\", this.outputPath);\n} else {\n- // let renderStr = this.runFilters(await this.render());\n- let renderStr = await this.render();\n- let err = fs.outputFileSync(this.outputPath, renderStr);\n+ let str = await this.render();\n+ let filtered = this.runFilters(str);\n+ let err = fs.outputFileSync(this.outputPath, filtered);\nif (err) {\nthrow err;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateComponents.js",
"new_path": "src/TemplateComponents.js",
"diff": "const Template = require( \"./Template\" );\nconst globby = require('globby');\nconst parsePath = require('parse-filepath');\n+const cfg = require('../config.json');\n-function TemplateComponents(componentsPath) {\n- this.componentsPath = componentsPath;\n+function TemplateComponents(inputDir) {\n+ this.inputDir = inputDir;\n+ this.componentsPath = inputDir + \"/\" + cfg.dir.components;\n}\nTemplateComponents.prototype.getComponents = async function(templateData) {\n@@ -19,7 +21,7 @@ TemplateComponents.prototype.getComponents = async function(templateData) {\n};\nTemplateComponents.prototype.getComponentFn = async function(componentFile, templateData) {\n- let tmpl = new Template( componentFile, false, templateData );\n+ let tmpl = new Template( componentFile, this.inputDir, false, templateData );\nlet templateFunction = await tmpl.getCompiledPromise();\nreturn function(data) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -14,8 +14,10 @@ function TemplateData(globalDataPath, templateComponents) {\n}\nTemplateData.prototype.getData = async function() {\n+ let json = await this.getJson(this.globalDataPath, this.rawImports);\n+\n// without components\n- this.rawData = Object.assign({}, await this.getJson(this.globalDataPath, this.rawImports), this.rawImports );\n+ this.rawData = Object.assign({}, json, this.rawImports );\n// with components\nthis.globalData = Object.assign({}, this.rawData, {\n@@ -30,8 +32,16 @@ TemplateData.prototype.getData = async function() {\n};\nTemplateData.prototype.getJson = async function(path, rawImports) {\n- let rawInput = fs.readFileSync(path, \"utf-8\");\n- let fn = await new TemplateRender().getCompiledTemplatePromise(rawInput);\n+ // todo convert to readFile with await (and promisify?)\n+ let rawInput;\n+ try {\n+ rawInput = fs.readFileSync(path, \"utf-8\");\n+ } catch(e) {\n+ // if file does not exist, return empty obj\n+ return {};\n+ }\n+\n+ let fn = await (new TemplateRender()).getCompiledTemplatePromise(rawInput);\n// no components allowed here\n// <%= _components.component({componentStr: 'test'}) %>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -9,11 +9,13 @@ const pug = require('pug');\nconst nunjucks = require('nunjucks');\nconst liquidEngine = require('liquidjs')();\n+const cfg = require(\"../config.json\");\n+\n// TODO make path and str for template content independent, why do we even need a path here?\nfunction TemplateRender( path ) {\nthis.parsed = path ? parsePath( path ) : undefined;\nthis.engine = this.parsed && this.parsed.ext ? this.parsed.ext.substr(1) : path;\n- this.defaultMarkdownEngine = \"ejs\";\n+ this.defaultMarkdownEngine = cfg.markdownTemplateEngine || \"liquid\";\n}\nTemplateRender.prototype.setDefaultMarkdownEngine = function(markdownEngine) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -7,29 +7,50 @@ const TemplateRender = require(\"./TemplateRender\");\nconst pkg = require(\"../package.json\");\nconst cfg = require(\"../config.json\");\n-function TemplateWriter(baseDir, files, outputDir, templateData) {\n+function TemplateWriter(baseDir, outputDir, extensions, templateData) {\nthis.baseDir = baseDir;\n- this.files = this.addFiles(baseDir, files);\n+ this.templateExtensions = extensions;\nthis.outputDir = outputDir;\nthis.templateData = templateData;\n+\n+ this.rawFiles = this.templateExtensions.map(function(extension) {\n+ return normalize( this.baseDir + \"/**/*.\" + extension );\n+ }.bind(this));\n+\n+ this.files = this.addIgnores(baseDir, this.rawFiles);\n}\n-TemplateWriter.prototype.addFiles = function(baseDir, files) {\n+TemplateWriter.prototype.getFiles = function() {\n+ return this.files;\n+};\n+\n+TemplateWriter.prototype.addIgnores = function(baseDir, files) {\nreturn files.concat(\n+ \"!\" + normalize(baseDir + \"/\" + cfg.dir.output + \"/*\"),\n\"!\" + normalize(baseDir + \"/\" + cfg.dir.layouts + \"/*\"),\n\"!\" + normalize(baseDir + \"/\" + cfg.dir.components + \"/*\")\n);\n};\n-TemplateWriter.prototype.write = function() {\n- let self = this;\n- globby.sync(this.files).forEach(function(path) {\n- let tmpl = new Template(path, self.outputDir, self.templateData);\n+TemplateWriter.prototype._getTemplate = function(path) {\n+ let tmpl = new Template(path, this.baseDir, this.outputDir, this.templateData);\ntmpl.addPostProcessFilter(function(str) {\nreturn pretty(str, { ocd: true });\n});\n- tmpl.write();\n- });\n+ return tmpl;\n+};\n+\n+TemplateWriter.prototype._writeTemplate = async function(path) {\n+ let tmpl = this._getTemplate( path );\n+ await tmpl.write();\n+ return tmpl;\n+};\n+\n+TemplateWriter.prototype.write = async function() {\n+ var paths = globby.sync(this.files);\n+ for( var j = 0, k = paths.length; j < k; j++ ) {\n+ await this._writeTemplate( paths[j] );\n+ }\n};\nmodule.exports = TemplateWriter;\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_components/list.ejs",
"new_path": "templates/_components/list.ejs",
"diff": "---\ndefaultString: \"DEFAULT STRING!\"\n+items:\n+ - firstitem\n+ - seconditem\n---\n<p><%= defaultString %></p>\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateComponentsTest.js",
"new_path": "test/TemplateComponentsTest.js",
"diff": "@@ -4,7 +4,7 @@ import TemplateComponents from \"../src/TemplateComponents\";\nimport pkg from \"../package.json\";\ntest(async t => {\n- let componentsObj = new TemplateComponents( \"./test/stubs/_components\" );\n+ let componentsObj = new TemplateComponents( \"./test/stubs\" );\nlet components = await componentsObj.getComponents({_package: pkg});\nt.is( \"testComponent\" in components, true );\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateDataTest.js",
"new_path": "test/TemplateDataTest.js",
"diff": "@@ -11,7 +11,7 @@ test(\"create without components\", async t => {\n});\ntest(\"getData()\", async t => {\n- let componentsObj = new TemplateComponents( \"./test/stubs/_components\" );\n+ let componentsObj = new TemplateComponents( \"./test/stubs\" );\nlet dataObj = new TemplateData( \"./test/stubs/globalData.json\", componentsObj );\nt.is( dataObj.getData().toString(), \"[object Promise]\" );\n@@ -29,7 +29,7 @@ test(\"getData()\", async t => {\n});\ntest(\"getJson()\", async t => {\n- let componentsObj = new TemplateComponents( \"./test/stubs/_components\" );\n+ let componentsObj = new TemplateComponents( \"./test/stubs\" );\nlet dataObj = new TemplateData( \"./test/stubs/globalData.json\", componentsObj );\nlet data = await dataObj.getJson(dataObj.globalDataPath, dataObj.rawImports)\n@@ -37,3 +37,12 @@ test(\"getJson()\", async t => {\nt.is( data.datakey1, \"datavalue1\" );\nt.is( data.datakey2, \"elevenisland\" );\n});\n+\n+test(\"getJson() file does not exist\", async t => {\n+ let dataObj = new TemplateData( \"./test/stubs/thisfiledoesnotexist.json\" );\n+\n+ let data = await dataObj.getJson(dataObj.globalDataPath, dataObj.rawImports)\n+\n+ t.is( typeof data, \"object\" );\n+ t.is( Object.keys( data ).length, 0 );\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -3,48 +3,59 @@ import TemplateComponents from \"../src/TemplateComponents\";\nimport TemplateData from \"../src/TemplateData\";\nimport Template from \"../src/Template\";\nimport pretty from \"pretty\";\n+import normalize from \"normalize-path\";\nfunction cleanHtml(str) {\nreturn pretty(str, {ocd: true});\n}\n-test(t => {\n- let tmpl = new Template(\"./test/stubs/template.ejs\", \"dist\");\n- t.is(tmpl.cleanOutputDir(), \"test/stubs\");\n+test(\"stripLeadingDotSlash\", t => {\n+ let tmpl = new Template(\"./test/stubs/template.ejs\", \"./test/stubs/\", \"./dist\");\n+ t.is( tmpl.stripLeadingDotSlash(\"./test/stubs\"), \"test/stubs\" );\n+ t.is( tmpl.stripLeadingDotSlash(\"./dist\"), \"dist\" );\n+ t.is( tmpl.stripLeadingDotSlash(\"../dist\"), \"../dist\" );\n+ t.is( tmpl.stripLeadingDotSlash(\"dist\"), \"dist\" );\n+});\n+\n+test(\"getTemplateSubFolder\", t => {\n+ let tmpl = new Template(\"./test/stubs/template.ejs\", \"./test/stubs/\", \"./dist\");\n+ t.is(tmpl.getTemplateSubfolder(), \"\");\n+});\n+\n+test(\"getTemplateSubFolder, output is a subdir of input\", t => {\n+ let tmpl = new Template(\"./test/stubs/template.ejs\", \"./test/stubs/\", \"./test/stubs/_site\");\n+ t.is(tmpl.getTemplateSubfolder(), \"\");\n});\ntest(\"output path maps to an html file\", t => {\n- let tmpl = new Template(\"./test/stubs/template.ejs\", \"dist\");\n- t.is(tmpl.getOutputPath(), \"dist/test/stubs/template.html\");\n+ let tmpl = new Template(\"./test/stubs/template.ejs\", \"./test/stubs/\", \"./dist\");\n+ t.is(tmpl.parsed.dir, \"./test/stubs\");\n+ t.is(tmpl.inputDir, \"./test/stubs\");\n+ t.is(tmpl.outputDir, \"./dist\");\n+ t.is(tmpl.getTemplateSubfolder(), \"\");\n+ t.is(tmpl.getOutputPath(), \"./dist/template.html\");\n});\ntest(\"subfolder outputs to a subfolder\", t => {\n- let tmpl = new Template(\"./test/stubs/subfolder/subfolder.ejs\", \"dist\");\n- t.is(tmpl.getOutputPath(), \"dist/test/stubs/subfolder/subfolder.html\");\n+ let tmpl = new Template(\"./test/stubs/subfolder/subfolder.ejs\", \"./test/stubs/\", \"./dist\");\n+ t.is(tmpl.parsed.dir, \"./test/stubs/subfolder\");\n+ t.is(tmpl.getTemplateSubfolder(), \"subfolder\");\n+ t.is(tmpl.getOutputPath(), \"./dist/subfolder/subfolder.html\");\n});\ntest(\"ignored files start with an underscore\", t => {\n- let tmpl = new Template(\"./test/stubs/_ignored.ejs\", \"dist\");\n+ let tmpl = new Template(\"./test/stubs/_ignored.ejs\", \"./test/stubs/\", \"./dist\");\nt.is(tmpl.isIgnored(), true);\n});\n-test(\"cleanLayoutDir\", t => {\n- let tmpl = new Template(\"./test/stubs/_ignored.ejs\", \"dist\");\n- t.is(tmpl.cleanLayoutDir(\"./test/stubs\"), \"./test/stubs/_layouts\");\n- t.is(tmpl.cleanLayoutDir(\"./test/stubs/_components\"), \"./test/stubs/_layouts\");\n- t.is(tmpl.cleanLayoutDir(\"./test/stubs/_components/_layouts\"), \"./test/stubs/_layouts\");\n- t.is(tmpl.cleanLayoutDir(\"./test/stubs/_layouts\"), \"./test/stubs/_layouts\");\n- t.is(tmpl.cleanLayoutDir(\"./test/stubs/_layouts/_layouts\"), \"./test/stubs/_layouts\");\n-});\n-\ntest(\"Test raw front matter from template\", t => {\n- let tmpl = new Template(\"./test/stubs/templateFrontMatter.ejs\", \"dist\");\n+ let tmpl = new Template(\"./test/stubs/templateFrontMatter.ejs\", \"./test/stubs/\", \"./dist\");\nt.truthy( tmpl.inputContent, \"template exists and can be opened.\" );\nt.is( tmpl.frontMatter.data.key1, \"value1\" );\n});\ntest(\"Test that getData() works\", async t => {\n- let tmpl = new Template(\"./test/stubs/templateFrontMatter.ejs\", \"dist\");\n+ let tmpl = new Template(\"./test/stubs/templateFrontMatter.ejs\", \"./test/stubs/\", \"./dist\");\nlet data = await tmpl.getData();\nt.is( data.key1, \"value1\" );\n@@ -57,9 +68,9 @@ test(\"Test that getData() works\", async t => {\n});\ntest(\"More advanced getData()\", async t => {\n- let componentsObj = new TemplateComponents( \"./test/stubs/_components\" );\n+ let componentsObj = new TemplateComponents( \"./test/stubs\" );\nlet dataObj = new TemplateData( \"./test/stubs/globalData.json\", componentsObj );\n- let tmpl = new Template(\"./test/stubs/templateFrontMatter.ejs\", \"dist\", dataObj);\n+ let tmpl = new Template(\"./test/stubs/templateFrontMatter.ejs\", \"./test/stubs/\", \"dist\", dataObj);\nlet data = await tmpl.getData({\nkey1: \"value1override\",\nkey2: \"value2\"\n@@ -73,7 +84,7 @@ test(\"More advanced getData()\", async t => {\ntest( \"One Layout\", async t => {\nlet dataObj = new TemplateData( \"./test/stubs/globalData.json\" );\n- let tmpl = new Template(\"./test/stubs/templateWithLayout.ejs\", \"dist\", dataObj);\n+ let tmpl = new Template(\"./test/stubs/templateWithLayout.ejs\", \"./test/stubs/\", \"dist\", dataObj);\nt.is(tmpl.frontMatter.data.layout, \"defaultLayout\");\n@@ -92,7 +103,7 @@ test( \"One Layout\", async t => {\ntest( \"Two Layouts\", async t => {\nlet dataObj = new TemplateData( \"./test/stubs/globalData.json\" );\n- let tmpl = new Template(\"./test/stubs/templateTwoLayouts.ejs\", \"dist\", dataObj);\n+ let tmpl = new Template(\"./test/stubs/templateTwoLayouts.ejs\", \"./test/stubs/\", \"dist\", dataObj);\nt.is(tmpl.frontMatter.data.layout, \"layout-a\");\n@@ -113,7 +124,7 @@ test( \"Two Layouts\", async t => {\ntest( \"Liquid template\", async t => {\nlet dataObj = new TemplateData( \"./test/stubs/globalData.json\" );\n- let tmpl = new Template(\"./test/stubs/formatTest.liquid\", \"dist\", dataObj);\n+ let tmpl = new Template(\"./test/stubs/formatTest.liquid\", \"./test/stubs/\", \"dist\", dataObj);\nt.is( await tmpl.render(), `<p>Zach</p>` );\n});\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/writeTest/test.md",
"diff": "+# Header\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Fixed a bunch of bugs with inputDirs that are not a direct child of cmd. Adds --formats |
699 | 01.12.2017 23:32:08 | 21,600 | a035d8195c4791b70a9e8fff106b2f89d123763c | Adds raw HTML template option. Adds config options for template engines for HTML files and data.json. | [
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "{\n\"globalDataFile\": \"./data.json\",\n- \"templateFormats\": [\"liquid\", \"ejs\", \"md\", \"hbs\", \"mustache\", \"haml\", \"pug\", \"njk\"],\n+ \"templateFormats\": [\"liquid\", \"ejs\", \"md\", \"hbs\", \"mustache\", \"haml\", \"pug\", \"njk\", \"html\"],\n\"markdownTemplateEngine\": \"liquid\",\n+ \"htmlTemplateEngine\": \"liquid\",\n+ \"jsonDataTemplateEngine\": \"ejs\",\n\"dir\": {\n\"templates\": \"templates\",\n\"layouts\": \"_layouts\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -4,6 +4,7 @@ const TemplateComponents = require(\"./TemplateComponents\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst pkg = require(\"../package.json\");\n+const cfg = require(\"../config.json\");\nfunction TemplateData(globalDataPath, templateComponents) {\nthis.globalDataPath = globalDataPath;\n@@ -41,7 +42,7 @@ TemplateData.prototype.getJson = async function(path, rawImports) {\nreturn {};\n}\n- let fn = await (new TemplateRender()).getCompiledTemplatePromise(rawInput);\n+ let fn = await (new TemplateRender(cfg.jsonDataTemplateEngine)).getCompiledTemplatePromise(rawInput);\n// no components allowed here\n// <%= _components.component({componentStr: 'test'}) %>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -11,17 +11,26 @@ const liquidEngine = require('liquidjs')();\nconst cfg = require(\"../config.json\");\n-// TODO make path and str for template content independent, why do we even need a path here?\n+// works with full path names or short engine name\nfunction TemplateRender( path ) {\nthis.parsed = path ? parsePath( path ) : undefined;\nthis.engine = this.parsed && this.parsed.ext ? this.parsed.ext.substr(1) : path;\nthis.defaultMarkdownEngine = cfg.markdownTemplateEngine || \"liquid\";\n+ this.defaultHtmlEngine = cfg.htmlTemplateEngine || \"liquid\";\n}\nTemplateRender.prototype.setDefaultMarkdownEngine = function(markdownEngine) {\nthis.defaultMarkdownEngine = markdownEngine;\n};\n+TemplateRender.prototype.setDefaultHtmlEngine = function(htmlEngine) {\n+ this.defaultHtmlEngine = htmlEngine;\n+};\n+\n+TemplateRender.prototype.isEngine = function(engine) {\n+ return this.engine === engine;\n+};\n+\nTemplateRender.prototype.render = async function(str, data) {\nlet fn = await this.getCompiledTemplatePromise(str);\nreturn fn(data);\n@@ -29,7 +38,8 @@ TemplateRender.prototype.render = async function(str, data) {\nTemplateRender.prototype.getCompiledTemplatePromise = async function(str, options) {\noptions = Object.assign({\n- parseMarkdownWith: this.defaultMarkdownEngine\n+ parseMarkdownWith: this.defaultMarkdownEngine,\n+ parseHtmlWith: this.defaultHtmlEngine\n}, options);\nif( !this.engine || this.engine === \"ejs\" ) {\n@@ -47,6 +57,19 @@ TemplateRender.prototype.getCompiledTemplatePromise = async function(str, option\nreturn md.render(str);\n};\n}\n+ } else if( this.engine === \"html\" ) {\n+ if( options.parseHtmlWith ) {\n+ let fn = await ((new TemplateRender(options.parseHtmlWith)).getCompiledTemplatePromise(str));\n+\n+ return async function(data) {\n+ return await fn(data);\n+ };\n+ } else {\n+ return function(data) {\n+ // do nothing with data if parseHtmlWith is falsy\n+ return str;\n+ };\n+ }\n} else if( this.engine === \"hbs\" ) {\nreturn Handlebars.compile(str);\n} else if( this.engine === \"mustache\" ) {\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_components/list.ejs",
"new_path": "templates/_components/list.ejs",
"diff": "---\ndefaultString: \"DEFAULT STRING!\"\n-items:\n- - firstitem\n- - seconditem\n---\n<p><%= defaultString %></p>\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -48,6 +48,11 @@ test(\"ignored files start with an underscore\", t => {\nt.is(tmpl.isIgnored(), true);\n});\n+test(\"HTML files cannot output to the same as the input directory, throws error.\", async t => {\n+ let tmpl = new Template(\"./test/stubs/testing.html\", \"./test/stubs\", \"./test/stubs\");\n+ t.is(tmpl.getOutputPath(), \"./test/stubs/testing-output.html\");\n+});\n+\ntest(\"Test raw front matter from template\", t => {\nlet tmpl = new Template(\"./test/stubs/templateFrontMatter.ejs\", \"./test/stubs/\", \"./dist\");\nt.truthy( tmpl.inputContent, \"template exists and can be opened.\" );\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/testing.html",
"diff": "+<html>\n+<body>\n+ This is an html template.\n+</body>\n+</html>\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds raw HTML template option. Adds config options for template engines for HTML files and data.json. |
699 | 04.12.2017 22:39:51 | 21,600 | 1aa5147b0f3fad092a72e3d0909298fafc92796c | Includes on liquid and ejs templates | [
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "\"templates\": \"templates\",\n\"layouts\": \"_layouts\",\n\"components\": \"_components\",\n+ \"includes\": \"_includes\",\n\"output\": \"_site\"\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"elevenisland\",\n\"version\": \"1.0.0\",\n\"description\": \"Transform a directory of templates into HTML.\",\n+ \"license\": \"MIT\",\n\"main\": \"cmd.js\",\n\"scripts\": {\n\"default\": \"node cmd.js\",\n\"bin\": {\n\"elevenisland\": \"./cmd.js\"\n},\n+ \"repository\": {\n+ \"type\": \"git\",\n+ \"url\": \"git://github.com/zachleat/elevenisland.git\"\n+ },\n\"devDependencies\": {\n\"ava\": \"^0.24.0\"\n},\n\"dependencies\": {\n\"chalk\": \"^2.3.0\",\n\"consolidate\": \"^0.15.0\",\n- \"ejs\": \"^2.5.7\",\n+ \"ejs\": \"git+ssh://[email protected]:zachleat/ejs.git#v2.5.7-h1\",\n\"fs-extra\": \"^4.0.2\",\n\"glob-watcher\": \"^4.0.0\",\n\"globby\": \"^7.1.1\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/TemplatePath.js",
"diff": "+const path = require(\"path\");\n+const cfg = require(\"../config.json\");\n+const normalize = require(\"normalize-path\");\n+\n+function TemplatePath() {\n+\n+}\n+\n+TemplatePath.getModuleDir = function() {\n+ return path.resolve(__dirname, \"..\");\n+};\n+\n+TemplatePath.getWorkingDir = function() {\n+ return path.resolve(\"./\");\n+};\n+\n+/* Outputs ./SAFE/LOCAL/PATHS/WITHOUT/TRAILING/SLASHES */\n+TemplatePath.normalize = function() {\n+ return normalize( path.join.apply(null, [...arguments]) );\n+};\n+\n+module.exports = TemplatePath;\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "const parsePath = require('parse-filepath');\n-\n+const path = require(\"path\");\nconst ejs = require( \"ejs\" );\nconst md = require('markdown-it')();\nconst Handlebars = require('handlebars');\n@@ -7,16 +7,19 @@ const Mustache = require('mustache');\nconst haml = require('hamljs');\nconst pug = require('pug');\nconst nunjucks = require('nunjucks');\n-const liquidEngine = require('liquidjs')();\n+const Liquid = require('liquidjs');\nconst cfg = require(\"../config.json\");\n+const TemplatePath = require(\"./TemplatePath\");\n// works with full path names or short engine name\n-function TemplateRender( path ) {\n- this.parsed = path ? parsePath( path ) : undefined;\n- this.engine = this.parsed && this.parsed.ext ? this.parsed.ext.substr(1) : path;\n+function TemplateRender( tmplPath, inputDir ) {\n+ this.path = tmplPath;\n+ this.parsed = tmplPath ? parsePath( tmplPath ) : undefined;\n+ this.engineName = this.parsed && this.parsed.ext ? this.parsed.ext.substr(1) : tmplPath;\nthis.defaultMarkdownEngine = cfg.markdownTemplateEngine || \"liquid\";\nthis.defaultHtmlEngine = cfg.htmlTemplateEngine || \"liquid\";\n+ this.inputDir = inputDir;\n}\nTemplateRender.prototype.setDefaultMarkdownEngine = function(markdownEngine) {\n@@ -27,8 +30,18 @@ TemplateRender.prototype.setDefaultHtmlEngine = function(htmlEngine) {\nthis.defaultHtmlEngine = htmlEngine;\n};\n+TemplateRender.prototype.getEngineName = function() {\n+ return this.engineName;\n+};\n+\n+TemplateRender.prototype.getInputDir = function() {\n+ return this.inputDir ?\n+ TemplatePath.normalize( this.inputDir, cfg.dir.includes ) :\n+ TemplatePath.normalize( cfg.dir.templates );\n+};\n+\nTemplateRender.prototype.isEngine = function(engine) {\n- return this.engine === engine;\n+ return this.engineName === engine;\n};\nTemplateRender.prototype.render = async function(str, data) {\n@@ -42,11 +55,18 @@ TemplateRender.prototype.getCompiledTemplatePromise = async function(str, option\nparseHtmlWith: this.defaultHtmlEngine\n}, options);\n- if( !this.engine || this.engine === \"ejs\" ) {\n- return ejs.compile(str);\n- } else if( this.engine === \"md\" ) {\n+ if( this.engineName === \"ejs\" ) {\n+ let fn = ejs.compile(str, {\n+ root: \"./\" + this.getInputDir(),\n+ compileDebug: true\n+ });\n+\n+ return function(data) {\n+ return fn(data);\n+ };\n+ } else if( this.engineName === \"md\" ) {\nif( options.parseMarkdownWith ) {\n- let fn = await ((new TemplateRender(options.parseMarkdownWith)).getCompiledTemplatePromise(str));\n+ let fn = await ((new TemplateRender(options.parseMarkdownWith, this.inputDir)).getCompiledTemplatePromise(str));\nreturn async function(data) {\nreturn md.render(await fn(data));\n@@ -57,9 +77,9 @@ TemplateRender.prototype.getCompiledTemplatePromise = async function(str, option\nreturn md.render(str);\n};\n}\n- } else if( this.engine === \"html\" ) {\n+ } else if( this.engineName === \"html\" ) {\nif( options.parseHtmlWith ) {\n- let fn = await ((new TemplateRender(options.parseHtmlWith)).getCompiledTemplatePromise(str));\n+ let fn = await ((new TemplateRender(options.parseHtmlWith, this.inputDir)).getCompiledTemplatePromise(str));\nreturn async function(data) {\nreturn await fn(data);\n@@ -70,25 +90,30 @@ TemplateRender.prototype.getCompiledTemplatePromise = async function(str, option\nreturn str;\n};\n}\n- } else if( this.engine === \"hbs\" ) {\n+ } else if( this.engineName === \"hbs\" ) {\nreturn Handlebars.compile(str);\n- } else if( this.engine === \"mustache\" ) {\n+ } else if( this.engineName === \"mustache\" ) {\nreturn function(data) {\nreturn Mustache.render(str, data).trim();\n};\n- } else if( this.engine === \"haml\" ) {\n+ } else if( this.engineName === \"haml\" ) {\nreturn haml.compile(str);\n- } else if( this.engine === \"pug\" ) {\n+ } else if( this.engineName === \"pug\" ) {\nreturn pug.compile(str);\n- } else if( this.engine === \"njk\" ) {\n+ } else if( this.engineName === \"njk\" ) {\nlet tmpl = new nunjucks.Template(str);\nreturn function(data) {\nreturn tmpl.render(data);\n};\n- } else if( this.engine === \"liquid\" ) {\n- let tmpl = await liquidEngine.parse(str);\n+ } else if( this.engineName === \"liquid\" ) {\n+ // warning, the include syntax supported here does not match what jekyll uses.\n+ let engine = Liquid({\n+ root: [this.getInputDir()],\n+ extname: '.liquid'\n+ });\n+ let tmpl = await engine.parse(str);\nreturn async function(data) {\n- return await liquidEngine.render(tmpl, data);\n+ return await engine.render(tmpl, data);\n};\n} else {\nthrow new Error(engine + \" is not a supported template engine.\");\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/TemplatePathTest.js",
"diff": "+import test from \"ava\";\n+import path from \"path\";\n+import TemplatePath from \"../src/TemplatePath\";\n+\n+test(\"Working dir\", t => {\n+ t.is(TemplatePath.getWorkingDir(), path.resolve(\"./\"));\n+ t.is(TemplatePath.getModuleDir(), path.resolve( __dirname, \"..\" ));\n+});\n+\n+test(\"Normalizer\", async t => {\n+ t.is( TemplatePath.normalize(\"testing\", \"hello\"), \"testing/hello\" );\n+ t.is( TemplatePath.normalize(\"testing\", \"hello/\"), \"testing/hello\" );\n+ t.is( TemplatePath.normalize(\"./testing\", \"hello\"), \"testing/hello\" );\n+ t.is( TemplatePath.normalize(\"./testing\", \"hello/\"), \"testing/hello\" );\n+ t.is( TemplatePath.normalize(\"./testing/hello\"), \"testing/hello\" );\n+ t.is( TemplatePath.normalize(\"./testing/hello/\"), \"testing/hello\" );\n+});\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderTest.js",
"new_path": "test/TemplateRenderTest.js",
"diff": "import test from \"ava\";\nimport ejs from \"ejs\";\nimport TemplateRender from \"../src/TemplateRender\";\n+import normalize from \"normalize-path\";\nimport parsePath from \"parse-filepath\";\n+import path from \"path\";\ntest(t => {\n// Path is unnecessary but supported\nt.truthy((new TemplateRender(\"default.ejs\")).parsed);\n- t.is((new TemplateRender(\"default.ejs\")).engine, \"ejs\");\n+ t.is((new TemplateRender(\"default.ejs\")).getEngineName(), \"ejs\");\n// Better\nt.truthy((new TemplateRender(\"ejs\")).parsed);\n- t.is((new TemplateRender(\"ejs\")).engine, \"ejs\");\n+ t.is((new TemplateRender(\"ejs\")).getEngineName(), \"ejs\");\n+});\n+\n+test(\"Input Dir\", async t => {\n+ t.is( (new TemplateRender( \"ejs\", \"./test/stubs\" )).getInputDir(), \"test/stubs/_includes\" );\n});\ntest(\"Unsupported engine\", async t => {\n- t.is( (new TemplateRender( \"doesnotexist\" )).engine, \"doesnotexist\" );\n+ t.is( (new TemplateRender( \"doesnotexist\" )).getEngineName(), \"doesnotexist\" );\nawait t.throws( (new TemplateRender( \"doesnotexist\" )).getCompiledTemplatePromise(\"<p></p>\") );\n});\n// HTML\ntest(\"HTML\", async t => {\n- t.is( (new TemplateRender( \"html\" )).engine, \"html\" );\n+ t.is( (new TemplateRender( \"html\" )).getEngineName(), \"html\" );\nlet fn = await (new TemplateRender( \"html\" )).getCompiledTemplatePromise(\"<p>Paragraph</p>\");\nt.is( await fn(), \"<p>Paragraph</p>\" );\n@@ -68,15 +74,22 @@ test(\"HTML: Change the default engine and pass in an override\", async t => {\n// EJS\ntest(\"EJS\", async t => {\n- t.is( (new TemplateRender( \"ejs\" )).engine, \"ejs\" );\n+ t.is( (new TemplateRender( \"ejs\" )).getEngineName(), \"ejs\" );\nlet fn = await (new TemplateRender( \"ejs\" )).getCompiledTemplatePromise(\"<p><%= name %></p>\");\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n});\n+test(\"EJS Include\", async t => {\n+ t.is( path.resolve(undefined, \"/included\" ), \"/included\" );\n+\n+ let fn = await (new TemplateRender( \"ejs\", \"./test/stubs/\" )).getCompiledTemplatePromise(\"<p><% include /included %></p>\");\n+ t.is(await fn(), \"<p>This is an include.</p>\" );\n+});\n+\n// Markdown\ntest(\"Markdown\", t => {\n- t.is( (new TemplateRender( \"md\" )).engine, \"md\" );\n+ t.is( (new TemplateRender( \"md\" )).getEngineName(), \"md\" );\n});\ntest(\"Markdown: Parses base markdown, no data\", async t => {\n@@ -121,7 +134,7 @@ test(\"Markdown: Change the default engine and pass in an override\", async t => {\n// Handlebars\ntest(\"Handlebars\", async t => {\n- t.is( (new TemplateRender( \"hbs\" )).engine, \"hbs\" );\n+ t.is( (new TemplateRender( \"hbs\" )).getEngineName(), \"hbs\" );\nlet fn = await (new TemplateRender( \"hbs\" )).getCompiledTemplatePromise(\"<p>{{name}}</p>\");\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n@@ -129,7 +142,7 @@ test(\"Handlebars\", async t => {\n// Mustache\ntest(\"Mustache\", async t => {\n- t.is( (new TemplateRender( \"mustache\" )).engine, \"mustache\" );\n+ t.is( (new TemplateRender( \"mustache\" )).getEngineName(), \"mustache\" );\nlet fn = await (new TemplateRender( \"mustache\" )).getCompiledTemplatePromise(\"<p>{{name}}</p>\");\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n@@ -137,7 +150,7 @@ test(\"Mustache\", async t => {\n// Haml\ntest(\"Haml\", async t => {\n- t.is( (new TemplateRender( \"haml\" )).engine, \"haml\" );\n+ t.is( (new TemplateRender( \"haml\" )).getEngineName(), \"haml\" );\nlet fn = await (new TemplateRender( \"haml\" )).getCompiledTemplatePromise(\"%p= name\");\nt.is( (await fn({name: \"Zach\"})).trim(), \"<p>Zach</p>\" );\n@@ -145,7 +158,7 @@ test(\"Haml\", async t => {\n// Pug\ntest(\"Pug\", async t => {\n- t.is( (new TemplateRender( \"pug\" )).engine, \"pug\" );\n+ t.is( (new TemplateRender( \"pug\" )).getEngineName(), \"pug\" );\nlet fn = await (new TemplateRender( \"pug\" )).getCompiledTemplatePromise(\"p= name\");\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n@@ -153,7 +166,7 @@ test(\"Pug\", async t => {\n// Nunjucks\ntest(\"Nunjucks\", async t => {\n- t.is( (new TemplateRender( \"njk\" )).engine, \"njk\" );\n+ t.is( (new TemplateRender( \"njk\" )).getEngineName(), \"njk\" );\nlet fn = await (new TemplateRender( \"njk\" )).getCompiledTemplatePromise(\"<p>{{ name }}</p>\");\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n@@ -161,8 +174,15 @@ test(\"Nunjucks\", async t => {\n// Liquid\ntest(\"Liquid\", async t => {\n- t.is( (new TemplateRender( \"liquid\" )).engine, \"liquid\" );\n+ t.is( (new TemplateRender( \"liquid\" )).getEngineName(), \"liquid\" );\nlet fn = await (new TemplateRender( \"liquid\" )).getCompiledTemplatePromise(\"<p>{{name | capitalize}}</p>\");\nt.is(await fn({name: \"tim\"}), \"<p>Tim</p>\" );\n});\n+\n+test(\"Liquid Include\", async t => {\n+ t.is( (new TemplateRender( \"liquid\", \"./test/stubs/\" )).getEngineName(), \"liquid\" );\n+\n+ let fn = await (new TemplateRender( \"liquid_include_test.liquid\", \"./test/stubs/\" )).getCompiledTemplatePromise(\"<p>{% include 'included' %}</p>\");\n+ t.is(await fn(), \"<p>This is an include.</p>\" );\n+});\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -133,3 +133,9 @@ test( \"Liquid template\", async t => {\nt.is( await tmpl.render(), `<p>Zach</p>` );\n});\n+\n+test( \"Liquid template with include\", async t => {\n+ let tmpl = new Template(\"./test/stubs/includer.liquid\", \"./test/stubs/\", \"dist\");\n+\n+ t.is( await tmpl.render(), `<p>This is an include.</p>` );\n+});\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/included.ejs",
"diff": "+This is an include.\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/included.liquid",
"diff": "+This is an include.\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/includer.liquid",
"diff": "+<p>{% include 'included' %}</p>\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Includes on liquid and ejs templates |
699 | 04.12.2017 23:11:15 | 21,600 | af80f085c42120ab9fb36d18c07fbc0d3691eabc | New include style for EJS | [
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderTest.js",
"new_path": "test/TemplateRenderTest.js",
"diff": "@@ -87,6 +87,17 @@ test(\"EJS Include\", async t => {\nt.is(await fn(), \"<p>This is an include.</p>\" );\n});\n+test(\"EJS Include, New Style\", async t => {\n+ let fn = await (new TemplateRender( \"ejs\", \"./test/stubs/\" )).getCompiledTemplatePromise(\"<p><%- include('/included', {}) %></p>\");\n+ t.is(await fn(), \"<p>This is an include.</p>\" );\n+});\n+\n+test(\"EJS Include, New Style with Data\", async t => {\n+ let fn = await (new TemplateRender( \"ejs\", \"./test/stubs/\" )).getCompiledTemplatePromise(\"<p><%- include('/includedvar', { name: 'Bill' }) %></p>\");\n+ t.is(await fn(), \"<p>This is an Bill.</p>\" );\n+});\n+\n+\n// Markdown\ntest(\"Markdown\", t => {\nt.is( (new TemplateRender( \"md\" )).getEngineName(), \"md\" );\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/includedvar.ejs",
"diff": "+This is an <%= name %>.\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | New include style for EJS |
699 | 05.12.2017 08:31:29 | 21,600 | 096671713625ddc2035bc06bdf546189ab27de75 | Adds mustache partials tests | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -8,6 +8,8 @@ const haml = require('hamljs');\nconst pug = require('pug');\nconst nunjucks = require('nunjucks');\nconst Liquid = require('liquidjs');\n+const fs = require(\"fs-extra\");\n+const globby = require(\"globby\");\nconst cfg = require(\"../config.json\");\nconst TemplatePath = require(\"./TemplatePath\");\n@@ -20,6 +22,11 @@ function TemplateRender( tmplPath, inputDir ) {\nthis.defaultMarkdownEngine = cfg.markdownTemplateEngine || \"liquid\";\nthis.defaultHtmlEngine = cfg.htmlTemplateEngine || \"liquid\";\nthis.inputDir = inputDir;\n+ this.mustachePartials = {};\n+\n+ if( this.engineName === \"mustache\" ) {\n+ this.mustachePartials = this.cacheMustachePartials();\n+ }\n}\nTemplateRender.prototype.setDefaultMarkdownEngine = function(markdownEngine) {\n@@ -37,13 +44,23 @@ TemplateRender.prototype.getEngineName = function() {\nTemplateRender.prototype.getInputDir = function() {\nreturn this.inputDir ?\nTemplatePath.normalize( this.inputDir, cfg.dir.includes ) :\n- TemplatePath.normalize( cfg.dir.templates );\n+ TemplatePath.normalize( cfg.dir.templates, cfg.dir.includes );\n};\nTemplateRender.prototype.isEngine = function(engine) {\nreturn this.engineName === engine;\n};\n+TemplateRender.prototype.cacheMustachePartials = function() {\n+ let partials = {};\n+ let partialFiles = globby.sync( this.getInputDir() + \"/*.mustache\" );\n+ for( var j = 0, k = partialFiles.length; j < k; j++ ) {\n+ let key = parsePath( partialFiles[ j ] ).name;\n+ partials[ key ] = fs.readFileSync(partialFiles[ j ], \"utf-8\");\n+ }\n+ return partials;\n+};\n+\nTemplateRender.prototype.render = async function(str, data) {\nlet fn = await this.getCompiledTemplatePromise(str);\nreturn fn(data);\n@@ -94,8 +111,8 @@ TemplateRender.prototype.getCompiledTemplatePromise = async function(str, option\nreturn Handlebars.compile(str);\n} else if( this.engineName === \"mustache\" ) {\nreturn function(data) {\n- return Mustache.render(str, data).trim();\n- };\n+ return Mustache.render(str, data, this.mustachePartials).trim();\n+ }.bind( this );\n} else if( this.engineName === \"haml\" ) {\nreturn haml.compile(str);\n} else if( this.engineName === \"pug\" ) {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/included.mustache",
"diff": "+This is an include.\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/includedvar.mustache",
"diff": "+This is a {{name}}.\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds mustache partials tests |
699 | 05.12.2017 09:00:16 | 21,600 | 7452b8cc5f5ef868e87eaf62f9a3d66c1c2a60fd | Handlebars partials | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -22,10 +22,10 @@ function TemplateRender( tmplPath, inputDir ) {\nthis.defaultMarkdownEngine = cfg.markdownTemplateEngine || \"liquid\";\nthis.defaultHtmlEngine = cfg.htmlTemplateEngine || \"liquid\";\nthis.inputDir = inputDir;\n- this.mustachePartials = {};\n+ this.partials = this.cachePartialFiles( this.engineName );\n- if( this.engineName === \"mustache\" ) {\n- this.mustachePartials = this.cacheMustachePartials();\n+ if( this.engineName === \"hbs\" ) {\n+ this.registerHandlebarsPartials();\n}\n}\n@@ -51,9 +51,10 @@ TemplateRender.prototype.isEngine = function(engine) {\nreturn this.engineName === engine;\n};\n-TemplateRender.prototype.cacheMustachePartials = function() {\n+TemplateRender.prototype.cachePartialFiles = function(engineName) {\nlet partials = {};\n- let partialFiles = globby.sync( this.getInputDir() + \"/*.mustache\" );\n+ // TODO: reuse mustache partials in handlebars?\n+ let partialFiles = globby.sync( this.getInputDir() + \"/*.\" + engineName );\nfor( var j = 0, k = partialFiles.length; j < k; j++ ) {\nlet key = parsePath( partialFiles[ j ] ).name;\npartials[ key ] = fs.readFileSync(partialFiles[ j ], \"utf-8\");\n@@ -61,6 +62,12 @@ TemplateRender.prototype.cacheMustachePartials = function() {\nreturn partials;\n};\n+TemplateRender.prototype.registerHandlebarsPartials = function() {\n+ for( var name in this.partials ) {\n+ Handlebars.registerPartial( name, this.partials[ name ] );\n+ }\n+};\n+\nTemplateRender.prototype.render = async function(str, data) {\nlet fn = await this.getCompiledTemplatePromise(str);\nreturn fn(data);\n@@ -108,10 +115,13 @@ TemplateRender.prototype.getCompiledTemplatePromise = async function(str, option\n};\n}\n} else if( this.engineName === \"hbs\" ) {\n- return Handlebars.compile(str);\n+ let fn = Handlebars.compile(str);\n+ return function(data) {\n+ return fn(data);\n+ };\n} else if( this.engineName === \"mustache\" ) {\nreturn function(data) {\n- return Mustache.render(str, data, this.mustachePartials).trim();\n+ return Mustache.render(str, data, this.partials).trim();\n}.bind( this );\n} else if( this.engineName === \"haml\" ) {\nreturn haml.compile(str);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderTest.js",
"new_path": "test/TemplateRenderTest.js",
"diff": "@@ -160,6 +160,16 @@ test(\"Handlebars Render\", async t => {\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n});\n+test(\"Handlebars Render Partial\", async t => {\n+ let fn = await (new TemplateRender( \"hbs\", \"./test/stubs/\" )).getCompiledTemplatePromise(\"<p>{{> included}}</p>\");\n+ t.is( await fn(), \"<p>This is an include.</p>\" );\n+});\n+\n+test(\"Handlebars Render Partial\", async t => {\n+ let fn = await (new TemplateRender( \"hbs\", \"./test/stubs/\" )).getCompiledTemplatePromise(\"<p>{{> includedvar}}</p>\");\n+ t.is( await fn({name: \"Zach\"}), \"<p>This is a Zach.</p>\" );\n+});\n+\n// Mustache\ntest(\"Mustache\", async t => {\nt.is( (new TemplateRender( \"mustache\" )).getEngineName(), \"mustache\" );\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/included.hbs",
"diff": "+This is an include.\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/includedvar.hbs",
"diff": "+This is a {{name}}.\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Handlebars partials |
699 | 06.12.2017 07:43:42 | 21,600 | f904b40448c9cc867f255f0dbba2ecb130307f1b | Pug features | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -126,7 +126,9 @@ TemplateRender.prototype.getCompiledTemplatePromise = async function(str, option\n} else if( this.engineName === \"haml\" ) {\nreturn haml.compile(str);\n} else if( this.engineName === \"pug\" ) {\n- return pug.compile(str);\n+ return pug.compile(str, {\n+ basedir: this.getInputDir()\n+ });\n} else if( this.engineName === \"njk\" ) {\nlet tmpl = new nunjucks.Template(str);\nreturn function(data) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderTest.js",
"new_path": "test/TemplateRenderTest.js",
"diff": "@@ -210,6 +210,33 @@ test(\"Pug Render\", async t => {\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n});\n+test(\"Pug Render Include\", async t => {\n+ let fn = await (new TemplateRender( \"pug\", \"./test/stubs/\" )).getCompiledTemplatePromise(`p\n+ include /included.pug`);\n+ t.is( await fn({name: \"Zach\"}), \"<p><span>This is an include.</span></p>\" );\n+});\n+\n+test(\"Pug Render Include with Data\", async t => {\n+ let fn = await (new TemplateRender( \"pug\", \"./test/stubs/\" )).getCompiledTemplatePromise(`p\n+ include /includedvar.pug`);\n+ t.is( await fn({name: \"Zach\"}), \"<p><span>This is Zach.</span></p>\" );\n+});\n+\n+test(\"Pug Render Include with Data, inline var overrides data\", async t => {\n+ let fn = await (new TemplateRender( \"pug\", \"./test/stubs/\" )).getCompiledTemplatePromise(`\n+- var name = \"Bill\";\n+p\n+ include /includedvar.pug`);\n+ t.is( await fn({name: \"Zach\"}), \"<p><span>This is Bill.</span></p>\" );\n+});\n+\n+test(\"Pug Render Extends (Layouts)\", async t => {\n+ let fn = await (new TemplateRender( \"pug\", \"./test/stubs/\" )).getCompiledTemplatePromise(`extends /layout.pug\n+block content\n+ h1= name`);\n+ t.is( await fn({name: \"Zach\"}), \"<html><body><h1>Zach</h1></body></html>\" );\n+});\n+\n// Nunjucks\ntest(\"Nunjucks\", t => {\nt.is( (new TemplateRender( \"njk\" )).getEngineName(), \"njk\" );\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/included.pug",
"diff": "+span This is an include.\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/includedvar.pug",
"diff": "+span This is #{name}.\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/layout.pug",
"diff": "+html\n+ body\n+ block content\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Pug features |
699 | 06.12.2017 07:43:54 | 21,600 | b95e333f6fececac1d3450c79a0c688f98d67876 | Nunjucks features | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -27,6 +27,10 @@ function TemplateRender( tmplPath, inputDir ) {\nif( this.engineName === \"hbs\" ) {\nthis.registerHandlebarsPartials();\n}\n+\n+ if( this.engineName === \"njk\" ) {\n+ this.njkEnv = new nunjucks.Environment(new nunjucks.FileSystemLoader(this.getInputDir()));\n+ }\n}\nTemplateRender.prototype.setDefaultMarkdownEngine = function(markdownEngine) {\n@@ -130,7 +134,7 @@ TemplateRender.prototype.getCompiledTemplatePromise = async function(str, option\nbasedir: this.getInputDir()\n});\n} else if( this.engineName === \"njk\" ) {\n- let tmpl = new nunjucks.Template(str);\n+ let tmpl = nunjucks.compile(str, this.njkEnv);\nreturn function(data) {\nreturn tmpl.render(data);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderTest.js",
"new_path": "test/TemplateRenderTest.js",
"diff": "@@ -247,6 +247,26 @@ test(\"Nunjucks Render\", async t => {\nt.is( await fn({name: \"Zach\"}), \"<p>Zach</p>\" );\n});\n+test(\"Nunjucks Render Extends\", async t => {\n+ let fn = await (new TemplateRender( \"njk\", \"test/stubs\" )).getCompiledTemplatePromise(\"{% extends 'base.njk' %}{% block content %}This is a child.{% endblock %}\");\n+ t.is( await fn(), \"<p>This is a child.</p>\" );\n+});\n+\n+test(\"Nunjucks Render Include\", async t => {\n+ let fn = await (new TemplateRender( \"njk\", \"test/stubs\" )).getCompiledTemplatePromise(\"<p>{% include 'included.njk' %}</p>\");\n+ t.is( await fn(), \"<p>This is an include.</p>\" );\n+});\n+\n+test(\"Nunjucks Render Imports\", async t => {\n+ let fn = await (new TemplateRender( \"njk\", \"test/stubs\" )).getCompiledTemplatePromise(\"{% import 'imports.njk' as forms %}<div>{{ forms.label('Name') }}</div>\");\n+ t.is( await fn(), \"<div><label>Name</label></div>\" );\n+});\n+\n+test(\"Nunjucks Render Imports From\", async t => {\n+ let fn = await (new TemplateRender( \"njk\", \"test/stubs\" )).getCompiledTemplatePromise(\"{% from 'imports.njk' import label %}<div>{{ label('Name') }}</div>\");\n+ t.is( await fn(), \"<div><label>Name</label></div>\" );\n+});\n+\n// Liquid\ntest(\"Liquid\", t => {\nt.is( (new TemplateRender( \"liquid\" )).getEngineName(), \"liquid\" );\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/base.njk",
"diff": "+<p>{% block content %}This is a parent.{% endblock %}</p>\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/imports.njk",
"diff": "+{% macro label(text) %}<label>{{ text }}</label>{% endmacro %}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/included.njk",
"diff": "+This is an include.\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Nunjucks features |
699 | 06.12.2017 08:27:15 | 21,600 | c437bab1f9edc4d525fb1dcc12a1b38ce6c6c79a | Extra packages hiding in there | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "#!/usr/bin/env node\nconst watch = require(\"glob-watcher\");\n-const chalk = require(\"chalk\");\nconst argv = require( \"minimist\" )( process.argv.slice(2) );\nconst normalize = require('normalize-path');\nconst TemplateData = require(\"./src/TemplateData\");\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"elevenisland\",\n- \"version\": \"1.0.0\",\n+ \"version\": \"0.1.0\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"license\": \"MIT\",\n\"main\": \"cmd.js\",\n\"ava\": \"^0.24.0\"\n},\n\"dependencies\": {\n- \"chalk\": \"^2.3.0\",\n- \"consolidate\": \"^0.15.0\",\n\"ejs\": \"git+ssh://[email protected]:zachleat/ejs.git#v2.5.7-h1\",\n\"fs-extra\": \"^4.0.2\",\n\"glob-watcher\": \"^4.0.0\",\n\"nunjucks\": \"^3.0.1\",\n\"parse-filepath\": \"^1.0.1\",\n\"pretty\": \"^2.0.0\",\n- \"promise\": \"^8.0.1\",\n\"pug\": \"^2.0.0-rc.4\"\n}\n}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Extra packages hiding in there |
699 | 07.12.2017 00:00:19 | 21,600 | fba3b0d2802c97a93cd8b8288fb49be36008b10f | Use TemplateConfig to deal with both module config.json and local elevenisland.config.js files with overrides | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -4,11 +4,16 @@ const argv = require( \"minimist\" )( process.argv.slice(2) );\nconst normalize = require('normalize-path');\nconst TemplateData = require(\"./src/TemplateData\");\nconst TemplateWriter = require(\"./src/TemplateWriter\");\n+const cfg = require(\"./src/TemplateConfig\");\nconst pkg = require(\"./package.json\");\n-const cfg = require(\"./config.json\");\n+\n+// No command line override for the local filename\n+let templateCfg = new TemplateConfig(require(\"./config.json\"));\n+let cfg = templateCfg.getConfig();\n+\n// argv._ ? argv._ :\n-const inputDir = argv.input ? argv.input : cfg.dir.templates;\n+let inputDir = argv.input ? argv.input : cfg.dir.input;\nlet formats = cfg.templateFormats;\nif( argv.formats && argv.formats !== \"*\" ) {\n@@ -45,6 +50,8 @@ if( argv.version ) {\nout.push( \" Whitelist only certain template types (default: `*`)\" );\nout.push( \" --data\" );\nout.push( \" Set your own global data file (default: `data.json`)\" );\n+ // out.push( \" --config\" );\n+ // out.push( \" Set your own local configuration file (default: `elevenisland.config.js`)\" );\nout.push( \" --help\" );\nout.push( \" Show this message.\" );\nconsole.log( out.join( \"\\n\" ) );\n"
},
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "{\n\"globalDataFile\": \"./data.json\",\n- \"templateFormats\": [\"liquid\", \"ejs\", \"md\", \"hbs\", \"mustache\", \"haml\", \"pug\", \"njk\", \"html\"],\n+ \"templateFormats\": [\n+ \"liquid\",\n+ \"ejs\",\n+ \"md\",\n+ \"hbs\",\n+ \"mustache\",\n+ \"haml\",\n+ \"pug\",\n+ \"njk\",\n+ \"html\"\n+ ],\n\"markdownTemplateEngine\": \"liquid\",\n\"htmlTemplateEngine\": \"liquid\",\n\"jsonDataTemplateEngine\": \"ejs\",\n\"dir\": {\n- \"templates\": \"templates\",\n+ \"input\": \".\",\n\"layouts\": \"_layouts\",\n\"includes\": \"_includes\",\n\"output\": \"_site\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Layout.js",
"new_path": "src/Layout.js",
"diff": "-const CFG = require( \"../config.json\" );\n+const TemplateConfig = require( \"./TemplateConfig\" );\nconst fs = require(\"fs-extra\");\n+let templateCfg = new TemplateConfig(require(\"../config.json\"));\n+let cfg = templateCfg.getConfig();\n+\nfunction Layout( name, dir ) {\nthis.dir = dir;\nthis.name = name;\n@@ -17,7 +20,7 @@ Layout.prototype.findFileName = function() {\nif( !fs.existsSync(this.dir) ) {\nthrow Error( \"Layout directory does not exist for \" + this.name + \": \" + this.dir );\n}\n- CFG.templateFormats.forEach(function( extension ) {\n+ cfg.templateFormats.forEach(function( extension ) {\nlet filename = this.name + \".\" + extension;\nif(!file && fs.existsSync( this.dir + \"/\" + filename)) {\nfile = filename;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -5,8 +5,10 @@ const matter = require(\"gray-matter\");\nconst normalize = require(\"normalize-path\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst Layout = require(\"./Layout\");\n+const TemplateConfig = require(\"./TemplateConfig\");\n-const cfg = require(\"../config.json\");\n+let templateCfg = new TemplateConfig(require(\"../config.json\"));\n+let cfg = templateCfg.getConfig();\nfunction Template(path, inputDir, outputDir, templateData) {\nthis.inputPath = path;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/TemplateConfig.js",
"diff": "+const fs = require(\"fs-extra\");\n+const TemplatePath = require(\"./TemplatePath\");\n+\n+function TemplateConfig(globalConfig, localConfigPath) {\n+ this.localConfigPath = localConfigPath || \"elevenisland.config.js\";\n+ this.config = this.mergeConfig(globalConfig);\n+}\n+\n+TemplateConfig.prototype.getConfig = function() {\n+ return this.config;\n+};\n+\n+TemplateConfig.prototype.mergeConfig = function( globalConfig ) {\n+ let localConfig;\n+ let path = TemplatePath.normalize( TemplatePath.getWorkingDir() + \"/\" + this.localConfigPath );\n+ try {\n+ localConfig = require( path );\n+ } catch(e) {\n+ // if file does not exist, return empty obj\n+ localConfig = {};\n+ }\n+\n+ return Object.assign( {}, globalConfig, localConfig );\n+};\n+\n+module.exports = TemplateConfig;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "const fs = require(\"fs-extra\");\n-\nconst TemplateRender = require(\"./TemplateRender\");\n+const TemplateConfig = require(\"./TemplateConfig\");\nconst pkg = require(\"../package.json\");\n-const cfg = require(\"../config.json\");\n+\n+let templateCfg = new TemplateConfig(require(\"../config.json\"));\n+let cfg = templateCfg.getConfig();\nfunction TemplateData(globalDataPath) {\nthis.globalDataPath = globalDataPath;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePath.js",
"new_path": "src/TemplatePath.js",
"diff": "const path = require(\"path\");\n-const cfg = require(\"../config.json\");\nconst normalize = require(\"normalize-path\");\nfunction TemplatePath() {}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -11,9 +11,12 @@ const Liquid = require('liquidjs');\nconst fs = require(\"fs-extra\");\nconst globby = require(\"globby\");\n-const cfg = require(\"../config.json\");\n+const TemplateConfig = require(\"./TemplateConfig\");\nconst TemplatePath = require(\"./TemplatePath\");\n+let templateCfg = new TemplateConfig(require(\"../config.json\"));\n+let cfg = templateCfg.getConfig();\n+\n// works with full path names or short engine name\nfunction TemplateRender( tmplPath, inputDir ) {\nthis.path = tmplPath;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "const globby = require(\"globby\");\nconst normalize = require(\"normalize-path\");\nconst pretty = require(\"pretty\");\n-\nconst Template = require(\"./Template\");\nconst TemplateRender = require(\"./TemplateRender\");\n+const TemplateConfig = require(\"./TemplateConfig\");\n+\nconst pkg = require(\"../package.json\");\n-const cfg = require(\"../config.json\");\n+\n+let templateCfg = new TemplateConfig(require(\"../config.json\"));\n+let cfg = templateCfg.getConfig();\n+\nfunction TemplateWriter(baseDir, outputDir, extensions, templateData) {\nthis.baseDir = baseDir;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/TemplateConfigTest.js",
"diff": "+import test from \"ava\";\n+import TemplateConfig from \"../src/TemplateConfig\";\n+\n+test(\"Template Config local config overrides base config\", async t => {\n+ let templateCfg = new TemplateConfig(require(\"../config.json\"), \"./test/stubs/config.js\" );\n+ let cfg = templateCfg.getConfig();\n+\n+ t.is( cfg.markdownTemplateEngine, \"ejs\" );\n+});\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateWriterTest.js",
"new_path": "test/TemplateWriterTest.js",
"diff": "import fs from \"fs-extra\";\nimport test from \"ava\";\nimport globby from \"globby\";\n-\nimport TemplateWriter from \"../src/TemplateWriter\";\n-import cfg from \"../config.json\";\n-\ntest(\"Mutually exclusive Input and Output dirs\", t => {\nlet tw = new TemplateWriter(\"./test/stubs/writeTest\", \"./test/stubs/_writeTestSite\", [\"ejs\", \"md\"]);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/config.js",
"diff": "+module.exports = {\n+ \"markdownTemplateEngine\": \"ejs\"\n+};\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Use TemplateConfig to deal with both module config.json and local elevenisland.config.js files with overrides |
699 | 07.12.2017 00:11:19 | 21,600 | 69306b7a4ef0df1f16196fbd6e8ac3ed98a589e8 | Customize the html suffix | [
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "\"markdownTemplateEngine\": \"liquid\",\n\"htmlTemplateEngine\": \"liquid\",\n\"jsonDataTemplateEngine\": \"ejs\",\n+ \"htmlOutputSuffix\": \"-output\",\n\"dir\": {\n\"input\": \".\",\n\"layouts\": \"_layouts\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -56,7 +56,7 @@ Template.prototype.getTemplateSubfolder = function() {\nTemplate.prototype.getOutputPath = function() {\nlet dir = this.getTemplateSubfolder();\n// console.log( this.inputPath,\"|\", this.inputDir, \"|\", dir );\n- return normalize(this.outputDir + \"/\" + (dir ? dir + \"/\" : \"\") + this.parsed.name + (this.isHtmlIOException ? \"-output\" : \"\") + \".html\");\n+ return normalize(this.outputDir + \"/\" + (dir ? dir + \"/\" : \"\") + this.parsed.name + (this.isHtmlIOException ? cfg.htmlOutputSuffix : \"\") + \".html\");\n};\nTemplate.prototype.isIgnored = function() {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -47,7 +47,7 @@ test(\"ignored files start with an underscore\", t => {\nt.is(tmpl.isIgnored(), true);\n});\n-test(\"HTML files cannot output to the same as the input directory, throws error.\", async t => {\n+test(\"HTML files output to the same as the input directory have a file suffix added.\", async t => {\nlet tmpl = new Template(\"./test/stubs/testing.html\", \"./test/stubs\", \"./test/stubs\");\nt.is(tmpl.getOutputPath(), \"./test/stubs/testing-output.html\");\n});\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Customize the html suffix |
699 | 07.12.2017 00:11:38 | 21,600 | 4c26ddccc4057991ee61b0145e4f09c9c17038ac | Change default config filename to .elevenisland.js | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "@@ -2,7 +2,7 @@ const fs = require(\"fs-extra\");\nconst TemplatePath = require(\"./TemplatePath\");\nfunction TemplateConfig(globalConfig, localConfigPath) {\n- this.localConfigPath = localConfigPath || \"elevenisland.config.js\";\n+ this.localConfigPath = localConfigPath || \".elevenisland.js\";\nthis.config = this.mergeConfig(globalConfig);\n}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Change default config filename to .elevenisland.js |
699 | 07.12.2017 00:18:43 | 21,600 | c009616e239df982c318870a8e279196f60910ed | Table was broken | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -77,8 +77,8 @@ For example:\nAdd a `.elevenisland.js` file to your directory to override these configuration options with your own preferences.\n-|Configuration Option Key|Command Line Override|Default Option|Valid Options|Description|\n-|---|---|---|---|\n+|Configuration Option Key|Default Option|Valid Options|Command Line Override|Description|\n+|---|---|---|---|---|\n|`globalDataFile`|`data.json`|A valid JSON filename|`--data`|Control the file name used for global data available to all templates.|\n|`jsonDataTemplateEngine`|N/A|`ejs`|_A valid template engine_ or `false`|N/A|Run the `globalDataFile` through this template engine before transforming it to JSON.|\n|`markdownTemplateEngine`|`liquid`|_A valid template engine_ or `false`|N/A|Run markdown through this template engine before transforming it to HTML.|\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Table was broken |
699 | 07.12.2017 00:19:55 | 21,600 | af41299bfee2af73fae1441ed0f8b0d6cc04ed77 | Missing cell | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -82,7 +82,7 @@ Add a `.elevenisland.js` file to your directory to override these configuration\n|`globalDataFile`|`data.json`|A valid JSON filename|`--data`|Control the file name used for global data available to all templates.|\n|`jsonDataTemplateEngine`|N/A|`ejs`|_A valid template engine_ or `false`|N/A|Run the `globalDataFile` through this template engine before transforming it to JSON.|\n|`markdownTemplateEngine`|`liquid`|_A valid template engine_ or `false`|N/A|Run markdown through this template engine before transforming it to HTML.|\n-|`htmlTemplateEngine`|`liquid`|_A valid template engine_ or `false`|Run HTML templates through this template engine before transforming it to (better) HTML.|\n+|`htmlTemplateEngine`|`liquid`|_A valid template engine_ or `false`|N/A|Run HTML templates through this template engine before transforming it to (better) HTML.|\n|`templateFormats`|`[\"liquid\", \"ejs\", \"md\", \"hbs\", \"mustache\", \"haml\", \"pug\", \"njk\", \"html\"]`|_Any combination of these_|`--formats`|Specify which type of templates should be transformed.|\n|`htmlOutputSuffix`|`-output`|`String`|N/A|If the input and output directory match, HTML files will have this suffix added to their output filename (to prevent overwriting the template).|\n|`dir.input`|`.`|_Any valid directory._|`--input`|Controls the top level directory inside which the templates should be found.|\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Missing cell |
699 | 07.12.2017 00:26:49 | 21,600 | d041111c4184b157ff29643d21db6ee2e98d1816 | Change project name to eleventy | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -34,9 +34,9 @@ if( argv.version ) {\nconsole.log( pkg.version );\n} else if( argv.help ) {\nlet out = [];\n- out.push( \"usage: elevenisland\" );\n- out.push( \" elevenisland --watch\" );\n- out.push( \" elevenisland --input=./templates --output=./dist\" );\n+ out.push( \"usage: eleventy\" );\n+ out.push( \" eleventy --watch\" );\n+ out.push( \" eleventy --input=./templates --output=./dist\" );\nout.push( \"\" );\nout.push( \"arguments: \" );\nout.push( \" --version\" );\n@@ -51,7 +51,7 @@ if( argv.version ) {\nout.push( \" --data\" );\nout.push( \" Set your own global data file (default: `data.json`)\" );\n// out.push( \" --config\" );\n- // out.push( \" Set your own local configuration file (default: `elevenisland.config.js`)\" );\n+ // out.push( \" Set your own local configuration file (default: `eleventy.config.js`)\" );\nout.push( \" --help\" );\nout.push( \" Show this message.\" );\nconsole.log( out.join( \"\\n\" ) );\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n- \"name\": \"elevenisland\",\n+ \"name\": \"eleventy\",\n\"version\": \"0.1.0\",\n\"description\": \"Transform a directory of templates into HTML.\",\n\"license\": \"MIT\",\n\"url\": \"https://zachleat.com/\"\n},\n\"bin\": {\n- \"elevenisland\": \"./cmd.js\"\n+ \"eleventy\": \"./cmd.js\"\n},\n\"repository\": {\n\"type\": \"git\",\n- \"url\": \"git://github.com/zachleat/elevenisland.git\"\n+ \"url\": \"git://github.com/zachleat/eleventy.git\"\n},\n\"ava\": {\n\"files\": [\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "@@ -2,7 +2,7 @@ const fs = require(\"fs-extra\");\nconst TemplatePath = require(\"./TemplatePath\");\nfunction TemplateConfig(globalConfig, localConfigPath) {\n- this.localConfigPath = localConfigPath || \".elevenisland.js\";\n+ this.localConfigPath = localConfigPath || \".eleventy.js\";\nthis.config = this.mergeConfig(globalConfig);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateDataTest.js",
"new_path": "test/TemplateDataTest.js",
"diff": "@@ -15,7 +15,7 @@ test(\"getData()\", async t => {\nlet globalData = await dataObj.getData();\nt.is( globalData.datakey1, \"datavalue1\", \"simple data value\" );\n- t.is( globalData.datakey2, \"elevenisland\", \"variables, resolve _package to its value.\" );\n+ t.is( globalData.datakey2, \"eleventy\", \"variables, resolve _package to its value.\" );\nt.true( Object.keys( globalData._package ).length > 0, \"package.json imported to data in _package\" );\n});\n@@ -26,7 +26,7 @@ test(\"getJson()\", async t => {\nlet data = await dataObj.getJson(dataObj.globalDataPath, dataObj.rawImports)\nt.is( data.datakey1, \"datavalue1\" );\n- t.is( data.datakey2, \"elevenisland\" );\n+ t.is( data.datakey2, \"eleventy\" );\n});\ntest(\"getJson() file does not exist\", async t => {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -79,7 +79,7 @@ test(\"More advanced getData()\", async t => {\nkey2: \"value2\"\n});\n- t.is( data._package.name, \"elevenisland\" );\n+ t.is( data._package.name, \"eleventy\" );\nt.is( data.key1, \"value1override\", \"local data argument overrides front matter\" );\nt.is( data.key2, \"value2\", \"local data argument, no front matter\" );\nt.is( data.key3, \"value3\", \"front matter only\" );\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Change project name to eleventy |
699 | 07.12.2017 23:23:59 | 21,600 | 81d9f19d7b76bd2287839124cd474764f6f83dcd | Adds support for handlebars helpers | [
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "\"layouts\": \"_layouts\",\n\"includes\": \"_includes\",\n\"output\": \"_site\"\n- }\n+ },\n+ \"handlebarsHelpers\": {}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Handlebars.js",
"new_path": "src/Engines/Handlebars.js",
"diff": "const HandlebarsLib = require('handlebars');\nconst TemplateEngine = require(\"./TemplateEngine\");\n+const TemplateConfig = require(\"../TemplateConfig\");\n+\n+let templateCfg = new TemplateConfig(require(\"../../config.json\"));\n+let cfg = templateCfg.getConfig();\nclass Handlebars extends TemplateEngine {\nconstructor(name, inputDir) {\nsuper(name, inputDir);\nlet partials = super.getPartials();\n- for( var name in partials) {\n+ for( let name in partials) {\nHandlebarsLib.registerPartial( name, partials[ name ] );\n}\n+\n+ this.addHelpers(cfg.handlebarsHelpers);\n+ }\n+\n+ addHelpers(helpers) {\n+ for( let name in helpers) {\n+ HandlebarsLib.registerHelper( name, helpers[ name ] );\n+ }\n}\nasync compile(str) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateEngineTest.js",
"new_path": "test/TemplateEngineTest.js",
"diff": "@@ -8,3 +8,16 @@ test(\"Unsupported engine\", async t => {\nTemplateEngine.getEngine( \"doesnotexist\" );\n});\n});\n+\n+test(\"Handlebars Helpers\", async t => {\n+ let engine = TemplateEngine.getEngine( \"hbs\" );\n+ engine.addHelpers({\n+ 'uppercase': function(name) {\n+ return name.toUpperCase();\n+ }\n+ });\n+\n+ let fn = await engine.compile(\"<p>{{uppercase author}}</p>\")\n+ t.is(await fn({author: \"zach\"}), \"<p>ZACH</p>\");\n+});\n+\n"
},
{
"change_type": "DELETE",
"old_path": "test/main.test.js",
"new_path": null,
"diff": "-import test from 'ava';\n-\n-test(t => {\n- t.deepEqual([1, 2], [1, 2]);\n-});\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds support for handlebars helpers |
699 | 08.12.2017 22:24:59 | 21,600 | 9ea85db2b054dc885dca10fa07f777ae988d683f | Import the local package.json for data vars | [
{
"change_type": "MODIFY",
"old_path": "src/TemplatePath.js",
"new_path": "src/TemplatePath.js",
"diff": "@@ -16,4 +16,8 @@ TemplatePath.normalize = function(...paths) {\nreturn normalize( path.join(...paths) );\n};\n+TemplatePath.localPath = function(...paths) {\n+ return normalize( path.join(TemplatePath.getWorkingDir(), ...paths));\n+};\n+\nmodule.exports = TemplatePath;\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Import the local package.json for data vars |
699 | 09.12.2017 22:05:18 | 21,600 | de23a3638311b9645f3de1ea6f05cab857087789 | Adds .eleventyignore for ignoring files. | [
{
"change_type": "ADD",
"old_path": null,
"new_path": ".eleventy.js",
"diff": "+module.exports = {\n+ dir: {\n+ input: \"playground\"\n+ }\n+};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateConfig.js",
"new_path": "src/TemplateConfig.js",
"diff": "const fs = require(\"fs-extra\");\n+const merge = require(\"lodash.merge\");\nconst TemplatePath = require(\"./TemplatePath\");\nfunction TemplateConfig(globalConfig, localConfigPath) {\n@@ -12,15 +13,16 @@ TemplateConfig.prototype.getConfig = function() {\nTemplateConfig.prototype.mergeConfig = function(globalConfig) {\nlet localConfig;\n- let path = TemplatePath.normalize( TemplatePath.getWorkingDir() + \"/\" + this.localConfigPath );\n+ let path = TemplatePath.normalize(\n+ TemplatePath.getWorkingDir() + \"/\" + this.localConfigPath\n+ );\ntry {\nlocalConfig = require(path);\n} catch (e) {\n// if file does not exist, return empty obj\nlocalConfig = {};\n}\n-\n- return Object.assign( {}, globalConfig, localConfig );\n+ return merge({}, globalConfig, localConfig);\n};\nmodule.exports = TemplateConfig;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "const globby = require(\"globby\");\nconst normalize = require(\"normalize-path\");\nconst pretty = require(\"pretty\");\n+const fs = require(\"fs-extra\");\nconst Template = require(\"./Template\");\n+const TemplatePath = require(\"./TemplatePath\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplateConfig = require(\"./TemplateConfig\");\n@@ -10,16 +12,17 @@ const pkg = require(\"../package.json\");\nlet templateCfg = new TemplateConfig(require(\"../config.json\"));\nlet cfg = templateCfg.getConfig();\n-\nfunction TemplateWriter(baseDir, outputDir, extensions, templateData) {\nthis.baseDir = baseDir;\nthis.templateExtensions = extensions;\nthis.outputDir = outputDir;\nthis.templateData = templateData;\n- this.rawFiles = this.templateExtensions.map(function(extension) {\n+ this.rawFiles = this.templateExtensions.map(\n+ function(extension) {\nreturn normalize(this.baseDir + \"/**/*.\" + extension);\n- }.bind(this));\n+ }.bind(this)\n+ );\nthis.files = this.addIgnores(baseDir, this.rawFiles);\n}\n@@ -28,15 +31,59 @@ TemplateWriter.prototype.getFiles = function() {\nreturn this.files;\n};\n+TemplateWriter.getFileIgnores = function(baseDir) {\n+ let ignorePath = TemplatePath.normalize(baseDir + \"/.eleventyignore\");\n+ let ignoreContent;\n+ try {\n+ ignoreContent = fs.readFileSync(ignorePath, \"utf-8\");\n+ } catch (e) {\n+ ignoreContent = \"\";\n+ }\n+ let ignores = [];\n+\n+ if (ignoreContent) {\n+ ignores = ignoreContent.split(\"\\n\").map(line => {\n+ line = line.trim();\n+ path = TemplatePath.normalize(baseDir, \"/\", line);\n+ if (fs.statSync(path).isDirectory()) {\n+ return \"!\" + path + \"/**\";\n+ }\n+ return \"!\" + path;\n+ });\n+ }\n+\n+ return ignores;\n+};\n+\nTemplateWriter.prototype.addIgnores = function(baseDir, files) {\n- return files.concat(\n- \"!\" + normalize(baseDir + \"/\" + cfg.dir.output + \"/*\"),\n- \"!\" + normalize(baseDir + \"/\" + cfg.dir.layouts + \"/*\")\n+ files = files.concat(TemplateWriter.getFileIgnores(baseDir));\n+\n+ if (cfg.dir.output) {\n+ files = files.concat(\n+ \"!\" + normalize(baseDir + \"/\" + cfg.dir.output + \"/**\")\n);\n+ }\n+ if (cfg.dir.layouts) {\n+ files = files.concat(\n+ \"!\" + normalize(baseDir + \"/\" + cfg.dir.layouts + \"/**\")\n+ );\n+ }\n+ if (cfg.dir.includes) {\n+ files = files.concat(\n+ \"!\" + normalize(baseDir + \"/\" + cfg.dir.includes + \"/**\")\n+ );\n+ }\n+\n+ return files;\n};\nTemplateWriter.prototype._getTemplate = function(path) {\n- let tmpl = new Template(path, this.baseDir, this.outputDir, this.templateData);\n+ let tmpl = new Template(\n+ path,\n+ this.baseDir,\n+ this.outputDir,\n+ this.templateData\n+ );\ntmpl.addPostProcessFilter(function(str) {\nreturn pretty(str, { ocd: true });\n});\n@@ -50,7 +97,7 @@ TemplateWriter.prototype._writeTemplate = async function(path) {\n};\nTemplateWriter.prototype.write = async function() {\n- var paths = globby.sync(this.files);\n+ var paths = globby.sync(this.files, { gitignore: true });\nfor (var j = 0, k = paths.length; j < k; j++) {\nawait this._writeTemplate(paths[j]);\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/.eleventyignore",
"diff": "+ignoredFolder\n+ignoredFolder/ignored.md\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/ignoredFolder/ignored.md",
"diff": "+# This should be ignored\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds .eleventyignore for ignoring files. |
699 | 10.12.2017 12:34:39 | 21,600 | 5d8480e5b88ea8f835bbd229e29b0405b5f88027 | Switches to use .jstl for template literal templates instead of .js | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -4,15 +4,16 @@ Transform a directory of templates into HTML.\nWorks with:\n-* HTML (`html`)\n-* Markdown (`md`) (using [`markdown-it`](https://github.com/markdown-it/markdown-it))\n-* [Liquid](https://www.npmjs.com/package/liquidjs) (`liquid`) (used by Jekyll)\n-* [EJS](https://www.npmjs.com/package/ejs) (`ejs`)\n-* [Handlebars](https://github.com/wycats/handlebars.js) (`hbs`)\n-* [Mustache](https://github.com/janl/mustache.js/) (`mustache`)\n-* [Haml](https://github.com/tj/haml.js) (`haml`)\n-* [Pug](https://github.com/pugjs/pug) (formerly Jade, `pug`)\n-* [Nunjucks](https://mozilla.github.io/nunjucks/) (`njk`)\n+* HTML (`.html`)\n+* Markdown (`.md`) (using [`markdown-it`](https://github.com/markdown-it/markdown-it))\n+* [Liquid](https://www.npmjs.com/package/liquidjs) (`.liquid`) (used by Jekyll)\n+* [EJS](https://www.npmjs.com/package/ejs) (`.ejs`)\n+* [Handlebars](https://github.com/wycats/handlebars.js) (`.hbs`)\n+* [Mustache](https://github.com/janl/mustache.js/) (`.mustache`)\n+* [Haml](https://github.com/tj/haml.js) (`.haml`)\n+* [Pug](https://github.com/pugjs/pug) (formerly Jade, `.pug`)\n+* [Nunjucks](https://mozilla.github.io/nunjucks/) (`.njk`)\n+* JavaScript Template Literals (`.jstl`)\n## Usage\n"
},
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "\"pug\",\n\"njk\",\n\"html\",\n- \"js\"\n+ \"jstl\"\n],\n\"markdownTemplateEngine\": \"liquid\",\n\"htmlTemplateEngine\": \"liquid\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/TemplateEngine.js",
"new_path": "src/Engines/TemplateEngine.js",
"diff": "const globby = require(\"globby\");\nconst fs = require(\"fs-extra\");\n-const parsePath = require('parse-filepath');\n+const parsePath = require(\"parse-filepath\");\nclass TemplateEngine {\nconstructor(name, inputDir) {\n@@ -10,14 +10,22 @@ class TemplateEngine {\nthis.partials = this.cachePartialFiles(this.extension);\n}\n- getName() { return this.name; }\n- getInputDir() { return this.inputDir; }\n- getPartials() { return this.partials; }\n+ getName() {\n+ return this.name;\n+ }\n+ getInputDir() {\n+ return this.inputDir;\n+ }\n+ getPartials() {\n+ return this.partials;\n+ }\ncachePartialFiles() {\nlet partials = {};\n// TODO: reuse mustache partials in handlebars?\n- let partialFiles = this.inputDir ? globby.sync( this.inputDir + \"/*\" + this.extension ) : [];\n+ let partialFiles = this.inputDir\n+ ? globby.sync(this.inputDir + \"/*\" + this.extension)\n+ : [];\nfor (var j = 0, k = partialFiles.length; j < k; j++) {\nlet key = parsePath(partialFiles[j]).name;\npartials[key] = fs.readFileSync(partialFiles[j], \"utf-8\");\n@@ -32,20 +40,22 @@ class TemplateEngine {\nstatic getEngine(name, inputDir) {\nlet classMap = {\n- \"ejs\": \"Ejs\",\n- \"md\": \"Markdown\",\n- \"js\": \"JavaScript\",\n- \"html\": \"Html\",\n- \"hbs\": \"Handlebars\",\n- \"mustache\": \"Mustache\",\n- \"haml\": \"Haml\",\n- \"pug\": \"Pug\",\n- \"njk\": \"Nunjucks\",\n- \"liquid\": \"Liquid\",\n+ ejs: \"Ejs\",\n+ md: \"Markdown\",\n+ jstl: \"JavaScript\",\n+ html: \"Html\",\n+ hbs: \"Handlebars\",\n+ mustache: \"Mustache\",\n+ haml: \"Haml\",\n+ pug: \"Pug\",\n+ njk: \"Nunjucks\",\n+ liquid: \"Liquid\"\n};\nif (!(name in classMap)) {\n- throw new Error( \"Template Engine \" + name + \" does not exist in getEngine\" );\n+ throw new Error(\n+ \"Template Engine \" + name + \" does not exist in getEngine\"\n+ );\n}\nconst cls = require(\"./\" + classMap[name]);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -9,7 +9,11 @@ function cleanHtml(str) {\n}\ntest(\"stripLeadingDotSlash\", t => {\n- let tmpl = new Template(\"./test/stubs/template.ejs\", \"./test/stubs/\", \"./dist\");\n+ let tmpl = new Template(\n+ \"./test/stubs/template.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\nt.is(tmpl.stripLeadingDotSlash(\"./test/stubs\"), \"test/stubs\");\nt.is(tmpl.stripLeadingDotSlash(\"./dist\"), \"dist\");\nt.is(tmpl.stripLeadingDotSlash(\"../dist\"), \"../dist\");\n@@ -17,17 +21,29 @@ test(\"stripLeadingDotSlash\", t => {\n});\ntest(\"getTemplateSubFolder\", t => {\n- let tmpl = new Template(\"./test/stubs/template.ejs\", \"./test/stubs/\", \"./dist\");\n+ let tmpl = new Template(\n+ \"./test/stubs/template.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\nt.is(tmpl.getTemplateSubfolder(), \"\");\n});\ntest(\"getTemplateSubFolder, output is a subdir of input\", t => {\n- let tmpl = new Template(\"./test/stubs/template.ejs\", \"./test/stubs/\", \"./test/stubs/_site\");\n+ let tmpl = new Template(\n+ \"./test/stubs/template.ejs\",\n+ \"./test/stubs/\",\n+ \"./test/stubs/_site\"\n+ );\nt.is(tmpl.getTemplateSubfolder(), \"\");\n});\ntest(\"output path maps to an html file\", t => {\n- let tmpl = new Template(\"./test/stubs/template.ejs\", \"./test/stubs/\", \"./dist\");\n+ let tmpl = new Template(\n+ \"./test/stubs/template.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\nt.is(tmpl.parsed.dir, \"./test/stubs\");\nt.is(tmpl.inputDir, \"./test/stubs\");\nt.is(tmpl.outputDir, \"./dist\");\n@@ -36,36 +52,59 @@ test(\"output path maps to an html file\", t => {\n});\ntest(\"subfolder outputs to a subfolder\", t => {\n- let tmpl = new Template(\"./test/stubs/subfolder/subfolder.ejs\", \"./test/stubs/\", \"./dist\");\n+ let tmpl = new Template(\n+ \"./test/stubs/subfolder/subfolder.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\nt.is(tmpl.parsed.dir, \"./test/stubs/subfolder\");\nt.is(tmpl.getTemplateSubfolder(), \"subfolder\");\nt.is(tmpl.getOutputPath(), \"./dist/subfolder/subfolder.html\");\n});\ntest(\"ignored files start with an underscore\", t => {\n- let tmpl = new Template(\"./test/stubs/_ignored.ejs\", \"./test/stubs/\", \"./dist\");\n+ let tmpl = new Template(\n+ \"./test/stubs/_ignored.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\nt.is(tmpl.isIgnored(), true);\n});\ntest(\"HTML files output to the same as the input directory have a file suffix added.\", async t => {\n- let tmpl = new Template(\"./test/stubs/testing.html\", \"./test/stubs\", \"./test/stubs\");\n+ let tmpl = new Template(\n+ \"./test/stubs/testing.html\",\n+ \"./test/stubs\",\n+ \"./test/stubs\"\n+ );\nt.is(tmpl.getOutputPath(), \"./test/stubs/testing-output.html\");\n});\ntest(\"Test raw front matter from template\", t => {\n- let tmpl = new Template(\"./test/stubs/templateFrontMatter.ejs\", \"./test/stubs/\", \"./dist\");\n+ let tmpl = new Template(\n+ \"./test/stubs/templateFrontMatter.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\nt.truthy(tmpl.inputContent, \"template exists and can be opened.\");\nt.is(tmpl.frontMatter.data.key1, \"value1\");\n});\ntest(\"Test that getData() works\", async t => {\n- let tmpl = new Template(\"./test/stubs/templateFrontMatter.ejs\", \"./test/stubs/\", \"./dist\");\n+ let tmpl = new Template(\n+ \"./test/stubs/templateFrontMatter.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\nlet data = await tmpl.getData();\nt.is(data.key1, \"value1\");\nt.is(data.key3, \"value3\");\n- let mergedFrontMatter = tmpl.getAllLayoutFrontMatterData(tmpl, tmpl.getFrontMatterData());\n+ let mergedFrontMatter = tmpl.getAllLayoutFrontMatterData(\n+ tmpl,\n+ tmpl.getFrontMatterData()\n+ );\nt.is(mergedFrontMatter.key1, \"value1\");\nt.is(mergedFrontMatter.key3, \"value3\");\n@@ -73,32 +112,52 @@ test(\"Test that getData() works\", async t => {\ntest(\"More advanced getData()\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/globalData.json\");\n- let tmpl = new Template(\"./test/stubs/templateFrontMatter.ejs\", \"./test/stubs/\", \"dist\", dataObj);\n+ let tmpl = new Template(\n+ \"./test/stubs/templateFrontMatter.ejs\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj\n+ );\nlet data = await tmpl.getData({\nkey1: \"value1override\",\nkey2: \"value2\"\n});\nt.is(data._package.name, \"eleventy\");\n- t.is( data.key1, \"value1override\", \"local data argument overrides front matter\" );\n+ t.is(\n+ data.key1,\n+ \"value1override\",\n+ \"local data argument overrides front matter\"\n+ );\nt.is(data.key2, \"value2\", \"local data argument, no front matter\");\nt.is(data.key3, \"value3\", \"front matter only\");\n});\ntest(\"One Layout\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/globalData.json\");\n- let tmpl = new Template(\"./test/stubs/templateWithLayout.ejs\", \"./test/stubs/\", \"dist\", dataObj);\n+ let tmpl = new Template(\n+ \"./test/stubs/templateWithLayout.ejs\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj\n+ );\nt.is(tmpl.frontMatter.data.layout, \"defaultLayout\");\nlet data = await tmpl.getData();\nt.is(data.layout, \"defaultLayout\");\n- t.is( cleanHtml( await tmpl.renderLayout(tmpl, data) ), `<div id=\"layout\">\n+ t.is(\n+ cleanHtml(await tmpl.renderLayout(tmpl, data)),\n+ `<div id=\"layout\">\n<p>Hello.</p>\n-</div>` );\n+</div>`\n+ );\n- let mergedFrontMatter = tmpl.getAllLayoutFrontMatterData(tmpl, tmpl.getFrontMatterData());\n+ let mergedFrontMatter = tmpl.getAllLayoutFrontMatterData(\n+ tmpl,\n+ tmpl.getFrontMatterData()\n+ );\nt.is(mergedFrontMatter.keymain, \"valuemain\");\nt.is(mergedFrontMatter.keylayout, \"valuelayout\");\n@@ -106,7 +165,12 @@ test( \"One Layout\", async t => {\ntest(\"Two Layouts\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/globalData.json\");\n- let tmpl = new Template(\"./test/stubs/templateTwoLayouts.ejs\", \"./test/stubs/\", \"dist\", dataObj);\n+ let tmpl = new Template(\n+ \"./test/stubs/templateTwoLayouts.ejs\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj\n+ );\nt.is(tmpl.frontMatter.data.layout, \"layout-a\");\n@@ -114,33 +178,53 @@ test( \"Two Layouts\", async t => {\nt.is(data.layout, \"layout-a\");\nt.is(data.key1, \"value1\");\n- t.is( cleanHtml( await tmpl.renderLayout(tmpl, data) ), `<div id=\"layout-b\">\n+ t.is(\n+ cleanHtml(await tmpl.renderLayout(tmpl, data)),\n+ `<div id=\"layout-b\">\n<div id=\"layout-a\">\n<p>value2-a</p>\n</div>\n-</div>` );\n+</div>`\n+ );\n- let mergedFrontMatter = tmpl.getAllLayoutFrontMatterData(tmpl, tmpl.getFrontMatterData());\n+ let mergedFrontMatter = tmpl.getAllLayoutFrontMatterData(\n+ tmpl,\n+ tmpl.getFrontMatterData()\n+ );\nt.is(mergedFrontMatter.daysPosted, 152);\n});\ntest(\"Liquid template\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/globalData.json\");\n- let tmpl = new Template(\"./test/stubs/formatTest.liquid\", \"./test/stubs/\", \"dist\", dataObj);\n+ let tmpl = new Template(\n+ \"./test/stubs/formatTest.liquid\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj\n+ );\nt.is(await tmpl.render(), `<p>Zach</p>`);\n});\ntest(\"Liquid template with include\", async t => {\n- let tmpl = new Template(\"./test/stubs/includer.liquid\", \"./test/stubs/\", \"dist\");\n+ let tmpl = new Template(\n+ \"./test/stubs/includer.liquid\",\n+ \"./test/stubs/\",\n+ \"dist\"\n+ );\nt.is(await tmpl.render(), `<p>This is an include.</p>`);\n});\ntest(\"ES6 Template Literal\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/globalData.json\");\n- let tmpl = new Template(\"./test/stubs/formatTest.js\", \"./test/stubs/\", \"dist\", dataObj);\n+ let tmpl = new Template(\n+ \"./test/stubs/formatTest.jstl\",\n+ \"./test/stubs/\",\n+ \"dist\",\n+ dataObj\n+ );\nt.is(await tmpl.render(), `<p>ZACH</p>`);\n});\n"
},
{
"change_type": "RENAME",
"old_path": "test/stubs/formatTest.js",
"new_path": "test/stubs/formatTest.jstl",
"diff": ""
}
] | JavaScript | MIT License | 11ty/eleventy | Switches to use .jstl for template literal templates instead of .js |
699 | 10.12.2017 12:41:51 | 21,600 | df6ad29fa288a58cc2990d937a86bed2632805cd | Adds an config sample | [
{
"change_type": "MODIFY",
"old_path": "test/stubs/.eleventyignore",
"new_path": "test/stubs/.eleventyignore",
"diff": "ignoredFolder\n-ignoredFolder/ignored.md\n\\ No newline at end of file\n+./ignoredFolder/ignored.md\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds an config sample |
699 | 10.12.2017 13:11:17 | 21,600 | ddcd8f26cc55977fa53fef0b7f85d7c10db43567 | Change default data template engine to liquid | [
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "],\n\"markdownTemplateEngine\": \"liquid\",\n\"htmlTemplateEngine\": \"liquid\",\n- \"jsonDataTemplateEngine\": \"ejs\",\n+ \"jsonDataTemplateEngine\": \"liquid\",\n\"htmlOutputSuffix\": \"-output\",\n\"dir\": {\n\"input\": \".\",\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/globalData.json",
"new_path": "test/stubs/globalData.json",
"diff": "{\n\"datakey1\": \"datavalue1\",\n- \"datakey2\": \"<%= _package.name %>\"\n+ \"datakey2\": \"{{_package.name}}\"\n}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Change default data template engine to liquid |
699 | 10.12.2017 14:36:05 | 21,600 | 11b9f73f841ef22f369e3a8f2bbfa92730721704 | Combine _layouts dir into _includes. | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -92,7 +92,6 @@ module.exports = {\n| ------------------------ | -------------------------------------------------------------------------- | -------------------------------------------- | --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |\n| `globalDataFile` | `data.json` | A valid JSON filename | `--data` | Control the file name used for global data available to all templates. |\n| `dir.input` | `.` | _Any valid directory._ | `--input` | Controls the top level directory inside which the templates should be found. |\n-| `dir.layouts` | `_layouts` | _Any valid directory inside of `dir.input`._ | N/A | Controls the directory inside which the eleventy layouts can be found. |\n| `dir.includes` | `_includes` | _Any valid directory inside of `dir.input`._ | N/A | Controls the directory inside which the template includes/extends/partials/etc can be found. |\n| `dir.output` | `_site` | _Any valid directory._ | `--output` | Controls the directory inside which the transformed finished templates can be found. |\n| `jsonDataTemplateEngine` | `ejs` | _A valid template engine_ or `false` | N/A | Run the `globalDataFile` through this template engine before transforming it to JSON. |\n"
},
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "\"htmlOutputSuffix\": \"-output\",\n\"dir\": {\n\"input\": \".\",\n- \"layouts\": \"_layouts\",\n\"includes\": \"_includes\",\n\"output\": \"_site\"\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/JavaScript.js",
"new_path": "src/Engines/JavaScript.js",
"diff": "@@ -4,7 +4,7 @@ class JavaScript extends TemplateEngine {\nasync compile(str) {\nreturn function(data) {\n// avoid `with`\n- let dataStr = '';\n+ let dataStr = \"\";\nfor (var j in data) {\ndataStr += `let ${j} = ${JSON.stringify(data[j])};\\n`;\n}\n@@ -14,7 +14,6 @@ class JavaScript extends TemplateEngine {\nstr = \"`\" + str + \"`\";\n}\n// TODO switch to https://www.npmjs.com/package/es6-template-strings\n- // sorry not sorry, buncha template engines do eval (ejs, for one)\nreturn eval(dataStr + \"\\n\" + str + \";\");\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -63,11 +63,6 @@ TemplateWriter.prototype.addIgnores = function(baseDir, files) {\n\"!\" + normalize(baseDir + \"/\" + cfg.dir.output + \"/**\")\n);\n}\n- if (cfg.dir.layouts) {\n- files = files.concat(\n- \"!\" + normalize(baseDir + \"/\" + cfg.dir.layouts + \"/**\")\n- );\n- }\nif (cfg.dir.includes) {\nfiles = files.concat(\n\"!\" + normalize(baseDir + \"/\" + cfg.dir.includes + \"/**\")\n"
},
{
"change_type": "RENAME",
"old_path": "test/stubs/_layouts/defaultLayout.ejs",
"new_path": "test/stubs/_includes/defaultLayout.ejs",
"diff": ""
},
{
"change_type": "RENAME",
"old_path": "test/stubs/_layouts/layout-a.ejs",
"new_path": "test/stubs/_includes/layout-a.ejs",
"diff": ""
},
{
"change_type": "RENAME",
"old_path": "test/stubs/_layouts/layout-b.ejs",
"new_path": "test/stubs/_includes/layout-b.ejs",
"diff": ""
}
] | JavaScript | MIT License | 11ty/eleventy | Combine _layouts dir into _includes. |
699 | 10.12.2017 15:05:32 | 21,600 | 4b8150e62b6ee303d4aa045b1a8405ba49564298 | Permalinks map to a new output subfolder | [
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "\"htmlTemplateEngine\": \"liquid\",\n\"jsonDataTemplateEngine\": \"liquid\",\n\"htmlOutputSuffix\": \"-output\",\n+ \"keys\": {\n+ \"permalink\": \"_permalink\",\n+ \"package\": \"_package\"\n+ },\n\"dir\": {\n\"input\": \".\",\n\"includes\": \"_includes\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -4,6 +4,7 @@ const parsePath = require(\"parse-filepath\");\nconst matter = require(\"gray-matter\");\nconst normalize = require(\"normalize-path\");\nconst TemplateRender = require(\"./TemplateRender\");\n+const TemplatePath = require(\"./TemplatePath\");\nconst Layout = require(\"./Layout\");\nconst TemplateConfig = require(\"./TemplateConfig\");\n@@ -57,16 +58,20 @@ Template.prototype.getTemplateSubfolder = function() {\n};\nTemplate.prototype.getOutputPath = function() {\n+ let permalink = this.getFrontMatterData()[cfg.keys.permalink];\n+ if (permalink) {\n+ return TemplatePath.normalize(this.outputDir, permalink);\n+ }\n+\nlet dir = this.getTemplateSubfolder();\n- // console.log( this.inputPath,\"|\", this.inputDir, \"|\", dir );\n- return normalize(\n- this.outputDir +\n+ let path =\n\"/\" +\n(dir ? dir + \"/\" : \"\") +\nthis.parsed.name +\n(this.isHtmlIOException ? cfg.htmlOutputSuffix : \"\") +\n- \".html\"\n- );\n+ \".html\";\n+ // console.log( this.inputPath,\"|\", this.inputDir, \"|\", dir );\n+ return normalize(this.outputDir + path);\n};\nTemplate.prototype.isIgnored = function() {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -8,9 +8,11 @@ let cfg = templateCfg.getConfig();\nfunction TemplateData(globalDataPath) {\nthis.globalDataPath = globalDataPath;\n- this.rawImports = {\n- _package: this.getJsonRaw(TemplatePath.localPath(\"package.json\"))\n- };\n+\n+ this.rawImports = {};\n+ this.rawImports[cfg.keys.package] = this.getJsonRaw(\n+ TemplatePath.localPath(\"package.json\")\n+ );\n}\nTemplateData.prototype.getData = async function() {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateDataTest.js",
"new_path": "test/TemplateDataTest.js",
"diff": "import test from \"ava\";\nimport TemplateData from \"../src/TemplateData\";\n+import TemplateConfig from \"../src/TemplateConfig\";\n+\n+let templateCfg = new TemplateConfig(require(\"../config.json\"));\n+let cfg = templateCfg.getConfig();\ntest(\"Create\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/globalData.json\");\nlet data = await dataObj.getData();\n- t.true( Object.keys( data._package ).length > 0 );\n+ t.true(Object.keys(data[cfg.keys.package]).length > 0);\n});\ntest(\"getData()\", async t => {\n@@ -15,15 +19,22 @@ test(\"getData()\", async t => {\nlet globalData = await dataObj.getData();\nt.is(globalData.datakey1, \"datavalue1\", \"simple data value\");\n- t.is( globalData.datakey2, \"eleventy\", \"variables, resolve _package to its value.\" );\n-\n- t.true( Object.keys( globalData._package ).length > 0, \"package.json imported to data in _package\" );\n+ t.is(\n+ globalData.datakey2,\n+ \"eleventy\",\n+ `variables, resolve ${cfg.keys.package} to its value.`\n+ );\n+\n+ t.true(\n+ Object.keys(globalData[cfg.keys.package]).length > 0,\n+ `package.json imported to data in ${cfg.keys.package}`\n+ );\n});\ntest(\"getJson()\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/globalData.json\");\n- let data = await dataObj.getJson(dataObj.globalDataPath, dataObj.rawImports)\n+ let data = await dataObj.getJson(dataObj.globalDataPath, dataObj.rawImports);\nt.is(data.datakey1, \"datavalue1\");\nt.is(data.datakey2, \"eleventy\");\n@@ -32,7 +43,7 @@ test(\"getJson()\", async t => {\ntest(\"getJson() file does not exist\", async t => {\nlet dataObj = new TemplateData(\"./test/stubs/thisfiledoesnotexist.json\");\n- let data = await dataObj.getJson(dataObj.globalDataPath, dataObj.rawImports)\n+ let data = await dataObj.getJson(dataObj.globalDataPath, dataObj.rawImports);\nt.is(typeof data, \"object\");\nt.is(Object.keys(data).length, 0);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "import test from \"ava\";\nimport TemplateData from \"../src/TemplateData\";\n+import TemplateConfig from \"../src/TemplateConfig\";\nimport Template from \"../src/Template\";\nimport pretty from \"pretty\";\nimport normalize from \"normalize-path\";\n+let templateCfg = new TemplateConfig(require(\"../config.json\"));\n+let cfg = templateCfg.getConfig();\n+\nfunction cleanHtml(str) {\nreturn pretty(str, { ocd: true });\n}\n@@ -123,7 +127,7 @@ test(\"More advanced getData()\", async t => {\nkey2: \"value2\"\n});\n- t.is(data._package.name, \"eleventy\");\n+ t.is(data[cfg.keys.package].name, \"eleventy\");\nt.is(\ndata.key1,\n\"value1override\",\n@@ -228,3 +232,12 @@ test(\"ES6 Template Literal\", async t => {\nt.is(await tmpl.render(), `<p>ZACH</p>`);\n});\n+\n+test(\"Permalink output directory\", t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/permalinked.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+ t.is(tmpl.getOutputPath(), \"dist/permalinksubfolder/index.html\");\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/permalinked.ejs",
"diff": "+---\n+_permalink: permalinksubfolder/index.html\n+---\n+Current url: <%= permalink %>\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Permalinks map to a new output subfolder |
699 | 10.12.2017 21:09:14 | 21,600 | 2df1fd680517dd0f62dd3b64344a4bc8b3d6dca2 | Use dynamic key for `layout`, switch back to `permalink` (no underscore) | [
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "\"jsonDataTemplateEngine\": \"liquid\",\n\"htmlOutputSuffix\": \"-output\",\n\"keys\": {\n- \"permalink\": \"_permalink\",\n- \"package\": \"_package\"\n+ \"package\": \"_package\",\n+ \"layout\": \"layout\",\n+ \"permalink\": \"permalink\"\n},\n\"dir\": {\n\"input\": \".\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -100,8 +100,8 @@ Template.prototype.getAllLayoutFrontMatterData = function(tmpl, data, merged) {\nmerged = data;\n}\n- if (data.layout) {\n- let layout = tmpl.getLayoutTemplate(data.layout);\n+ if (data[cfg.keys.layout]) {\n+ let layout = tmpl.getLayoutTemplate(data[cfg.keys.layout]);\nlet layoutData = layout.getFrontMatterData();\nreturn this.getAllLayoutFrontMatterData(\n@@ -129,9 +129,9 @@ Template.prototype.getData = async function(localData) {\n};\nTemplate.prototype.renderLayout = async function(tmpl, tmplData) {\n- let layoutName = tmplData.layout;\n+ let layoutName = tmplData[cfg.keys.layout];\n// TODO make layout key to be available to templates (without it causing issues with merge below)\n- delete tmplData.layout;\n+ delete tmplData[cfg.keys.layout];\nlet layout = this.getLayoutTemplate(layoutName);\nlet layoutData = await layout.getData(tmplData);\n@@ -143,7 +143,7 @@ Template.prototype.renderLayout = async function(tmpl, tmplData) {\ntmplData\n);\n- if (layoutData.layout) {\n+ if (layoutData[cfg.keys.layout]) {\nreturn await this.renderLayout(layout, layoutData);\n}\n@@ -162,7 +162,7 @@ Template.prototype.renderContent = async function(str, data) {\nTemplate.prototype.render = async function() {\nlet data = await this.getData();\n- if (data.layout) {\n+ if (data[cfg.keys.layout]) {\nreturn await this.renderLayout(this, data);\n} else {\nreturn await this.renderContent(this.getPreRender(), data);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -146,10 +146,10 @@ test(\"One Layout\", async t => {\ndataObj\n);\n- t.is(tmpl.frontMatter.data.layout, \"defaultLayout\");\n+ t.is(tmpl.frontMatter.data[cfg.keys.layout], \"defaultLayout\");\nlet data = await tmpl.getData();\n- t.is(data.layout, \"defaultLayout\");\n+ t.is(data[cfg.keys.layout], \"defaultLayout\");\nt.is(\ncleanHtml(await tmpl.renderLayout(tmpl, data)),\n@@ -176,10 +176,10 @@ test(\"Two Layouts\", async t => {\ndataObj\n);\n- t.is(tmpl.frontMatter.data.layout, \"layout-a\");\n+ t.is(tmpl.frontMatter.data[cfg.keys.layout], \"layout-a\");\nlet data = await tmpl.getData();\n- t.is(data.layout, \"layout-a\");\n+ t.is(data[cfg.keys.layout], \"layout-a\");\nt.is(data.key1, \"value1\");\nt.is(\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/permalinked.ejs",
"new_path": "test/stubs/permalinked.ejs",
"diff": "---\n-_permalink: permalinksubfolder/index.html\n+permalink: permalinksubfolder/index.html\n---\nCurrent url: <%= permalink %>\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Use dynamic key for `layout`, switch back to `permalink` (no underscore) |
699 | 11.12.2017 08:57:07 | 21,600 | b988bf2689099c9a892b0ebb6e0ac719940af356 | Adds pify, removes some syncs | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"ava\": \"^0.24.0\",\n\"husky\": \"^0.14.3\",\n\"lint-staged\": \"^6.0.0\",\n+ \"pify\": \"^3.0.0\",\n\"prettier\": \"1.9.1\"\n},\n\"dependencies\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "const ejs = require(\"ejs\");\n-const fs = require(\"fs-extra\");\n+const pify = require(\"pify\");\n+const fs = pify(require(\"fs-extra\"));\nconst parsePath = require(\"parse-filepath\");\nconst matter = require(\"gray-matter\");\nconst normalize = require(\"normalize-path\");\n@@ -186,10 +187,7 @@ Template.prototype.write = async function() {\n} else {\nlet str = await this.render();\nlet filtered = this.runFilters(str);\n- let err = fs.outputFileSync(this.outputPath, filtered);\n- if (err) {\n- throw err;\n- }\n+ await pify(fs.outputFile)(this.outputPath, filtered);\nconsole.log(\"Writing\", this.outputPath, \"from\", this.inputPath);\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -92,7 +92,7 @@ TemplateWriter.prototype._writeTemplate = async function(path) {\n};\nTemplateWriter.prototype.write = async function() {\n- var paths = globby.sync(this.files, { gitignore: true });\n+ var paths = await globby(this.files, { gitignore: true });\nfor (var j = 0, k = paths.length; j < k; j++) {\nawait this._writeTemplate(paths[j]);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateWriterTest.js",
"new_path": "test/TemplateWriterTest.js",
"diff": "@@ -3,13 +3,14 @@ import test from \"ava\";\nimport globby from \"globby\";\nimport TemplateWriter from \"../src/TemplateWriter\";\n-test(\"Mutually exclusive Input and Output dirs\", t => {\n+test(\"Mutually exclusive Input and Output dirs\", async t => {\nlet tw = new TemplateWriter(\n\"./test/stubs/writeTest\",\n\"./test/stubs/_writeTestSite\",\n[\"ejs\", \"md\"]\n);\n- let files = globby.sync(tw.files);\n+\n+ let files = await globby(tw.files);\nt.is(tw.rawFiles.length, 2);\nt.true(files.length > 0);\nt.is(files[0], \"./test/stubs/writeTest/test.md\");\n@@ -22,7 +23,7 @@ test(\"Output is a subdir of input\", async t => {\n\"./test/stubs/writeTest/_writeTestSite\",\n[\"ejs\", \"md\"]\n);\n- let files = globby.sync(tw.files);\n+ let files = await globby(tw.files);\nt.is(tw.rawFiles.length, 2);\nt.true(files.length > 0);\n@@ -42,12 +43,12 @@ test(\".eleventyignore ignores parsing\", t => {\nt.is(ignores[1], \"!test/stubs/ignoredFolder/ignored.md\");\n});\n-test(\".eleventyignore files\", t => {\n+test(\".eleventyignore files\", async t => {\nlet tw = new TemplateWriter(\"test/stubs\", \"test/stubs/_site\", [\"ejs\", \"md\"]);\n- let ignoredFiles = globby.sync(\"test/stubs/ignoredFolder/*.md\");\n+ let ignoredFiles = await globby(\"test/stubs/ignoredFolder/*.md\");\nt.is(ignoredFiles.length, 1);\n- let files = globby.sync(tw.files);\n+ let files = await globby(tw.files);\nt.true(files.length > 0);\nt.is(\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds pify, removes some syncs |
699 | 14.12.2017 20:58:11 | 21,600 | b7dbcd03189febe73811035a045c821bd097de85 | A few more async things | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "const ejs = require(\"ejs\");\nconst pify = require(\"pify\");\n-const fs = pify(require(\"fs-extra\"));\n+const fs = require(\"fs-extra\");\nconst parsePath = require(\"parse-filepath\");\nconst matter = require(\"gray-matter\");\nconst normalize = require(\"normalize-path\");\n@@ -96,7 +96,11 @@ Template.prototype.getFrontMatterData = function() {\nreturn this.frontMatter.data || {};\n};\n-Template.prototype.getAllLayoutFrontMatterData = function(tmpl, data, merged) {\n+Template.prototype.getAllLayoutFrontMatterData = async function(\n+ tmpl,\n+ data,\n+ merged\n+) {\nif (!merged) {\nmerged = data;\n}\n@@ -105,7 +109,7 @@ Template.prototype.getAllLayoutFrontMatterData = function(tmpl, data, merged) {\nlet layout = tmpl.getLayoutTemplate(data[cfg.keys.layout]);\nlet layoutData = layout.getFrontMatterData();\n- return this.getAllLayoutFrontMatterData(\n+ return await this.getAllLayoutFrontMatterData(\ntmpl,\nlayoutData,\nObject.assign({}, layoutData, merged)\n@@ -122,7 +126,7 @@ Template.prototype.getData = async function(localData) {\ndata = await this.templateData.getData();\n}\n- let mergedLayoutData = this.getAllLayoutFrontMatterData(\n+ let mergedLayoutData = await this.getAllLayoutFrontMatterData(\nthis,\nthis.getFrontMatterData()\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -105,7 +105,7 @@ test(\"Test that getData() works\", async t => {\nt.is(data.key1, \"value1\");\nt.is(data.key3, \"value3\");\n- let mergedFrontMatter = tmpl.getAllLayoutFrontMatterData(\n+ let mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\ntmpl,\ntmpl.getFrontMatterData()\n);\n@@ -158,7 +158,7 @@ test(\"One Layout\", async t => {\n</div>`\n);\n- let mergedFrontMatter = tmpl.getAllLayoutFrontMatterData(\n+ let mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\ntmpl,\ntmpl.getFrontMatterData()\n);\n@@ -191,7 +191,7 @@ test(\"Two Layouts\", async t => {\n</div>`\n);\n- let mergedFrontMatter = tmpl.getAllLayoutFrontMatterData(\n+ let mergedFrontMatter = await tmpl.getAllLayoutFrontMatterData(\ntmpl,\ntmpl.getFrontMatterData()\n);\n"
}
] | JavaScript | MIT License | 11ty/eleventy | A few more async things |
699 | 14.12.2017 22:10:05 | 21,600 | eb4af5decfa06bfb9cad6d1b25845e40bdb540d3 | Imports a local component json data file (and caches the global data if possible) | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -22,6 +22,10 @@ if (argv.formats && argv.formats !== \"*\") {\nlet start = new Date();\nlet data = new TemplateData(argv.data || cfg.globalDataFile);\n+(async function() {\n+ await data.cacheData();\n+})();\n+\nlet writer = new TemplateWriter(\ninputDir,\nargv.output || cfg.dir.output,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -119,17 +119,22 @@ Template.prototype.getAllLayoutFrontMatterData = async function(\nreturn merged;\n};\n+Template.prototype.getLocalDataPath = function() {\n+ return this.parsed.dir + \"/\" + this.parsed.name + \".json\";\n+};\n+\nTemplate.prototype.getData = async function(localData) {\nlet data = {};\nif (this.templateData) {\n- data = await this.templateData.getData();\n+ data = await this.templateData.getLocalData(this.getLocalDataPath());\n}\nlet mergedLayoutData = await this.getAllLayoutFrontMatterData(\nthis,\nthis.getFrontMatterData()\n);\n+\nreturn Object.assign({}, data, mergedLayoutData, localData);\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "const fs = require(\"fs-extra\");\n+const parsePath = require(\"parse-filepath\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplateConfig = require(\"./TemplateConfig\");\nconst TemplatePath = require(\"./TemplatePath\");\n@@ -13,16 +14,47 @@ function TemplateData(globalDataPath) {\nthis.rawImports[cfg.keys.package] = this.getJsonRaw(\nTemplatePath.localPath(\"package.json\")\n);\n+\n+ this.globalData = null;\n}\n+TemplateData.prototype.clearData = function() {\n+ this.globalData = null;\n+};\n+\n+TemplateData.prototype.cacheData = async function() {\n+ this.clearData();\n+\n+ return await this.getData();\n+};\n+\nTemplateData.prototype.getData = async function() {\n- let json = await this.getJson(this.globalDataPath, this.rawImports);\n+ if (!this.globalData) {\n+ let json = {};\n+\n+ if (this.globalDataPath) {\n+ json = await this.getJson(this.globalDataPath, this.rawImports);\n+ }\nthis.globalData = Object.assign({}, json, this.rawImports);\n+ }\nreturn this.globalData;\n};\n+TemplateData.prototype.getLocalData = async function(localDataPath) {\n+ let localFilename = parsePath(localDataPath).name;\n+ let importedData = {};\n+ importedData[localFilename] = await this.getJson(\n+ localDataPath,\n+ this.rawImports\n+ );\n+\n+ let globalData = await this.getData();\n+\n+ return Object.assign({}, globalData, importedData);\n+};\n+\nTemplateData.prototype._getLocalJson = function(path) {\n// todo convert to readFile with await (and promisify?)\nlet rawInput;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -241,3 +241,20 @@ test(\"Permalink output directory\", t => {\n);\nt.is(tmpl.getOutputPath(), \"dist/permalinksubfolder/index.html\");\n});\n+\n+test(\"Local template data file import (without a global data json)\", async t => {\n+ let dataObj = new TemplateData();\n+ await dataObj.cacheData();\n+\n+ let tmpl = new Template(\n+ \"./test/stubs/component/component.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+\n+ let data = await tmpl.getData();\n+ t.is(tmpl.getLocalDataPath(), \"./test/stubs/component/component.json\");\n+ t.is(data.component.localdatakey1, \"localdatavalue1\");\n+ t.is(await tmpl.render(), \"localdatavalue1\");\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/component/component.json",
"diff": "+{\n+ \"localdatakey1\": \"localdatavalue1\"\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/component/component.njk",
"diff": "+{{component.localdatakey1}}\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Imports a local component json data file (and caches the global data if possible) |
699 | 14.12.2017 22:38:59 | 21,600 | 79891860561dd5bb5dad2e4f512fde2b6eca349b | Asyncing all of it | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -19,12 +19,11 @@ if (argv.formats && argv.formats !== \"*\") {\nformats = argv.formats.split(\",\");\n}\n+(async function() {\nlet start = new Date();\nlet data = new TemplateData(argv.data || cfg.globalDataFile);\n-(async function() {\nawait data.cacheData();\n-})();\nlet writer = new TemplateWriter(\ninputDir,\n@@ -54,7 +53,7 @@ if (argv.version) {\nout.push(\" --data\");\nout.push(\" Set your own global data file (default: `data.json`)\");\n// out.push( \" --config\" );\n- // out.push( \" Set your own local configuration file (default: `eleventy.config.js`)\" );\n+ // out.push( \" Set your own local configuration file (default: `.eleventy.js`)\" );\nout.push(\" --help\");\nout.push(\" Show this message.\");\nconsole.log(out.join(\"\\n\"));\n@@ -72,10 +71,11 @@ if (argv.version) {\nwriter.write();\n});\n} else {\n- writer.write();\n+ await writer.write();\nconsole.log(\n\"Finished in\",\n((new Date() - start) / 1000).toFixed(2),\n\"seconds\"\n);\n}\n+})();\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Asyncing all of it |
699 | 15.12.2017 07:13:41 | 21,600 | 3b206f72fbbeb121fb8a8ea461d5eba201fe160b | Rename method name, not happy with Promise in the name | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -161,9 +161,7 @@ Template.prototype.renderLayout = async function(tmpl, tmplData) {\n};\nTemplate.prototype.getCompiledPromise = async function() {\n- return await this.templateRender.getCompiledTemplatePromise(\n- this.getPreRender()\n- );\n+ return await this.templateRender.getCompiledTemplate(this.getPreRender());\n};\nTemplate.prototype.renderContent = async function(str, data) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "-const parsePath = require('parse-filepath');\n+const parsePath = require(\"parse-filepath\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateEngine = require(\"./Engines/TemplateEngine\");\nconst TemplateConfig = require(\"./TemplateConfig\");\n@@ -10,7 +10,8 @@ let cfg = templateCfg.getConfig();\nfunction TemplateRender(tmplPath, inputDir) {\nthis.path = tmplPath;\nthis.parsed = tmplPath ? parsePath(tmplPath) : undefined;\n- this.engineName = this.parsed && this.parsed.ext ? this.parsed.ext.substr(1) : tmplPath;\n+ this.engineName =\n+ this.parsed && this.parsed.ext ? this.parsed.ext.substr(1) : tmplPath;\nthis.inputDir = this._normalizeInputDir(inputDir);\nthis.engine = TemplateEngine.getEngine(this.engineName, this.inputDir);\n@@ -31,9 +32,9 @@ TemplateRender.prototype.getEngineName = function() {\n};\nTemplateRender.prototype._normalizeInputDir = function(dir) {\n- return dir ?\n- TemplatePath.normalize( dir, cfg.dir.includes ) :\n- TemplatePath.normalize( cfg.dir.input, cfg.dir.includes );\n+ return dir\n+ ? TemplatePath.normalize(dir, cfg.dir.includes)\n+ : TemplatePath.normalize(cfg.dir.input, cfg.dir.includes);\n};\nTemplateRender.prototype.getInputDir = function() {\n@@ -48,11 +49,14 @@ TemplateRender.prototype.render = async function(str, data) {\nreturn this.engine.render(str, data);\n};\n-TemplateRender.prototype.getCompiledTemplatePromise = async function(str, options) {\n- options = Object.assign({\n+TemplateRender.prototype.getCompiledTemplate = async function(str, options) {\n+ options = Object.assign(\n+ {\nparseMarkdownWith: this.defaultMarkdownEngine,\nparseHtmlWith: this.defaultHtmlEngine\n- }, options);\n+ },\n+ options\n+ );\n// TODO refactor better\nif (this.engineName === \"md\") {\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Rename method name, not happy with Promise in the name |
699 | 15.12.2017 07:52:31 | 21,600 | c1dc0509f89fd5b31c4fdee91f335469c2e418a3 | `return await` is unnecessary. | [
{
"change_type": "MODIFY",
"old_path": "src/Engines/Html.js",
"new_path": "src/Engines/Html.js",
"diff": "@@ -3,11 +3,14 @@ const TemplateEngine = require(\"./TemplateEngine\");\nclass Html extends TemplateEngine {\nasync compile(str, preTemplateEngine) {\nif (preTemplateEngine) {\n- let engine = TemplateEngine.getEngine(preTemplateEngine, super.getInputDir());\n+ let engine = TemplateEngine.getEngine(\n+ preTemplateEngine,\n+ super.getInputDir()\n+ );\nlet fn = await engine.compile(str);\nreturn async function(data) {\n- return await fn(data);\n+ return fn(data);\n};\n} else {\nreturn function(data) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Liquid.js",
"new_path": "src/Engines/Liquid.js",
"diff": "-const LiquidLib = require('liquidjs');\n+const LiquidLib = require(\"liquidjs\");\nconst TemplateEngine = require(\"./TemplateEngine\");\nclass Liquid extends TemplateEngine {\n@@ -6,12 +6,12 @@ class Liquid extends TemplateEngine {\n// warning, the include syntax supported here does not match what jekyll uses.\nlet engine = LiquidLib({\nroot: [super.getInputDir()],\n- extname: '.liquid'\n+ extname: \".liquid\"\n});\nlet tmpl = await engine.parse(str);\nreturn async function(data) {\n- return await engine.render(tmpl, data);\n+ return engine.render(tmpl, data);\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -109,7 +109,7 @@ Template.prototype.getAllLayoutFrontMatterData = async function(\nlet layout = tmpl.getLayoutTemplate(data[cfg.keys.layout]);\nlet layoutData = layout.getFrontMatterData();\n- return await this.getAllLayoutFrontMatterData(\n+ return this.getAllLayoutFrontMatterData(\ntmpl,\nlayoutData,\nObject.assign({}, layoutData, merged)\n@@ -154,26 +154,26 @@ Template.prototype.renderLayout = async function(tmpl, tmplData) {\n);\nif (layoutData[cfg.keys.layout]) {\n- return await this.renderLayout(layout, layoutData);\n+ return this.renderLayout(layout, layoutData);\n}\n- return await layout.renderContent(layout.getPreRender(), layoutData);\n+ return layout.renderContent(layout.getPreRender(), layoutData);\n};\nTemplate.prototype.getCompiledPromise = async function() {\n- return await this.templateRender.getCompiledTemplate(this.getPreRender());\n+ return this.templateRender.getCompiledTemplate(this.getPreRender());\n};\nTemplate.prototype.renderContent = async function(str, data) {\n- return await this.templateRender.render(str, data);\n+ return this.templateRender.render(str, data);\n};\nTemplate.prototype.render = async function() {\nlet data = await this.getData();\nif (data[cfg.keys.layout]) {\n- return await this.renderLayout(this, data);\n+ return this.renderLayout(this, data);\n} else {\n- return await this.renderContent(this.getPreRender(), data);\n+ return this.renderContent(this.getPreRender(), data);\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "const fs = require(\"fs-extra\");\n+const globby = require(\"globby\");\nconst parsePath = require(\"parse-filepath\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplateConfig = require(\"./TemplateConfig\");\n@@ -25,18 +26,22 @@ TemplateData.prototype.clearData = function() {\nTemplateData.prototype.cacheData = async function() {\nthis.clearData();\n- return await this.getData();\n+ return this.getData();\n+};\n+\n+TemplateData.prototype.getAllGlobalData = async function() {\n+ return this.getJson(this.globalDataPath, this.rawImports);\n};\nTemplateData.prototype.getData = async function() {\nif (!this.globalData) {\n- let json = {};\n+ let globalJson = {};\nif (this.globalDataPath) {\n- json = await this.getJson(this.globalDataPath, this.rawImports);\n+ globalJson = await this.getAllGlobalData();\n}\n- this.globalData = Object.assign({}, json, this.rawImports);\n+ this.globalData = Object.assign({}, globalJson, this.rawImports);\n}\nreturn this.globalData;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateRender.js",
"new_path": "src/TemplateRender.js",
"diff": "@@ -60,11 +60,11 @@ TemplateRender.prototype.getCompiledTemplate = async function(str, options) {\n// TODO refactor better\nif (this.engineName === \"md\") {\n- return await this.engine.compile(str, options.parseMarkdownWith);\n+ return this.engine.compile(str, options.parseMarkdownWith);\n} else if (this.engineName === \"html\") {\n- return await this.engine.compile(str, options.parseHtmlWith);\n+ return this.engine.compile(str, options.parseHtmlWith);\n} else {\n- return await this.engine.compile(str);\n+ return this.engine.compile(str);\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateRenderTest.js",
"new_path": "test/TemplateRenderTest.js",
"diff": "@@ -321,12 +321,43 @@ test(\"Liquid Render Include\", async t => {\nt.is(new TemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(), \"liquid\");\nlet fn = await new TemplateRender(\n- \"liquid_include_test.liquid\",\n+ \"liquid\",\n\"./test/stubs/\"\n).getCompiledTemplate(\"<p>{% include 'included' %}</p>\");\nt.is(await fn(), \"<p>This is an include.</p>\");\n});\n+test(\"Liquid Render Include with Liquid Suffix\", async t => {\n+ t.is(new TemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(), \"liquid\");\n+\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p>{% include 'included.liquid' %}</p>\");\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+test(\"Liquid Render Include with HTML Suffix\", async t => {\n+ t.is(new TemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(), \"liquid\");\n+\n+ let fn = await new TemplateRender(\n+ \"liquid\",\n+ \"./test/stubs/\"\n+ ).getCompiledTemplate(\"<p>{% include 'included.html' %}</p>\");\n+ t.is(await fn(), \"<p>This is an include.</p>\");\n+});\n+\n+// This is an upstream limitation of the Liquid implementation\n+// test(\"Liquid Render Include No Quotes\", async t => {\n+// t.is(new TemplateRender(\"liquid\", \"./test/stubs/\").getEngineName(), \"liquid\");\n+\n+// let fn = await new TemplateRender(\n+// \"liquid\",\n+// \"./test/stubs/\"\n+// ).getCompiledTemplate(\"<p>{% include included.liquid %}</p>\");\n+// t.is(await fn(), \"<p>This is an include.</p>\");\n+// });\n+\n// ES6\ntest(\"ES6 Template Literal\", t => {\nt.is(new TemplateRender(\"jstl\").getEngineName(), \"jstl\");\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_includes/included.html",
"diff": "+This is an include.\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | `return await` is unnecessary. |
699 | 15.12.2017 08:43:31 | 21,600 | 673b75475ecf85f72a5d6b9f4cfb057b13d63a75 | Use _data dir instead of one big global data file. | [
{
"change_type": "MODIFY",
"old_path": "cmd.js",
"new_path": "cmd.js",
"diff": "@@ -22,7 +22,7 @@ if (argv.formats && argv.formats !== \"*\") {\n(async function() {\nlet start = new Date();\n- let data = new TemplateData(argv.data || cfg.globalDataFile);\n+ let data = new TemplateData(argv.input);\nawait data.cacheData();\nlet writer = new TemplateWriter(\n"
},
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "\"dir\": {\n\"input\": \".\",\n\"includes\": \"_includes\",\n+ \"data\": \"_data\",\n\"output\": \"_site\"\n},\n\"handlebarsHelpers\": {}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "const fs = require(\"fs-extra\");\n+const pify = require(\"pify\");\nconst globby = require(\"globby\");\nconst parsePath = require(\"parse-filepath\");\nconst TemplateRender = require(\"./TemplateRender\");\n@@ -29,8 +30,40 @@ TemplateData.prototype.cacheData = async function() {\nreturn this.getData();\n};\n+TemplateData.prototype.getGlobalDataGlob = async function(inputDir) {\n+ let dir = \".\";\n+\n+ if (this.globalDataPath) {\n+ let globalPathStat = await pify(fs.stat)(this.globalDataPath);\n+\n+ if (globalPathStat.isDirectory()) {\n+ dir = this.globalDataPath;\n+ } else {\n+ dir = parsePath(this.globalDataPath).dir;\n+ }\n+ }\n+\n+ return TemplatePath.normalize(dir, \"/\", cfg.dir.data) + \"/**/*.json\";\n+};\n+\n+TemplateData.prototype.getGlobalDataFiles = async function() {\n+ return globby(await this.getGlobalDataGlob(), { gitignore: true });\n+};\n+\nTemplateData.prototype.getAllGlobalData = async function() {\n- return this.getJson(this.globalDataPath, this.rawImports);\n+ let globalData = {};\n+ let files = await this.getGlobalDataFiles();\n+\n+ for (var j = 0, k = files.length; j < k; j++) {\n+ let key = parsePath(files[j]).name;\n+ globalData[key] = await this.getJson(files[j], this.rawImports);\n+ }\n+\n+ return Object.assign(\n+ {},\n+ globalData,\n+ await this.getJson(this.globalDataPath, this.rawImports)\n+ );\n};\nTemplateData.prototype.getData = async function() {\n@@ -61,7 +94,7 @@ TemplateData.prototype.getLocalData = async function(localDataPath) {\n};\nTemplateData.prototype._getLocalJson = function(path) {\n- // todo convert to readFile with await (and promisify?)\n+ // TODO convert to pify and async\nlet rawInput;\ntry {\nrawInput = fs.readFileSync(path, \"utf-8\");\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_data/testData.json",
"diff": "+{\n+ \"testdatakey1\": \"testdatavalue1\"\n+}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Use _data dir instead of one big global data file. |
699 | 15.12.2017 21:00:21 | 21,600 | 6198624fb492819ba8eb4241b83b1f0e6508dabf | Removes global data file at root (moving to _data) | [
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "{\n- \"globalDataFile\": \"./data.json\",\n\"templateFormats\": [\n\"liquid\",\n\"ejs\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -30,17 +30,19 @@ TemplateData.prototype.cacheData = async function() {\nreturn this.getData();\n};\n-TemplateData.prototype.getGlobalDataGlob = async function(inputDir) {\n+TemplateData.prototype.getGlobalDataGlob = async function() {\nlet dir = \".\";\nif (this.globalDataPath) {\nlet globalPathStat = await pify(fs.stat)(this.globalDataPath);\n- if (globalPathStat.isDirectory()) {\n- dir = this.globalDataPath;\n- } else {\n- dir = parsePath(this.globalDataPath).dir;\n+ if (!globalPathStat.isDirectory()) {\n+ throw new Error(\n+ \"Could not find data path directory: \" + this.globalDataPath\n+ );\n}\n+\n+ dir = this.globalDataPath;\n}\nreturn TemplatePath.normalize(dir, \"/\", cfg.dir.data) + \"/**/*.json\";\n@@ -59,20 +61,12 @@ TemplateData.prototype.getAllGlobalData = async function() {\nglobalData[key] = await this.getJson(files[j], this.rawImports);\n}\n- return Object.assign(\n- {},\n- globalData,\n- await this.getJson(this.globalDataPath, this.rawImports)\n- );\n+ return globalData;\n};\nTemplateData.prototype.getData = async function() {\nif (!this.globalData) {\n- let globalJson = {};\n-\n- if (this.globalDataPath) {\n- globalJson = await this.getAllGlobalData();\n- }\n+ let globalJson = await this.getAllGlobalData();\nthis.globalData = Object.assign({}, globalJson, this.rawImports);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -12,18 +12,6 @@ function cleanHtml(str) {\nreturn pretty(str, { ocd: true });\n}\n-test(\"stripLeadingDotSlash\", t => {\n- let tmpl = new Template(\n- \"./test/stubs/template.ejs\",\n- \"./test/stubs/\",\n- \"./dist\"\n- );\n- t.is(tmpl.stripLeadingDotSlash(\"./test/stubs\"), \"test/stubs\");\n- t.is(tmpl.stripLeadingDotSlash(\"./dist\"), \"dist\");\n- t.is(tmpl.stripLeadingDotSlash(\"../dist\"), \"../dist\");\n- t.is(tmpl.stripLeadingDotSlash(\"dist\"), \"dist\");\n-});\n-\ntest(\"getTemplateSubFolder\", t => {\nlet tmpl = new Template(\n\"./test/stubs/template.ejs\",\n@@ -115,7 +103,7 @@ test(\"Test that getData() works\", async t => {\n});\ntest(\"More advanced getData()\", async t => {\n- let dataObj = new TemplateData(\"./test/stubs/globalData.json\");\n+ let dataObj = new TemplateData(\"./test/stubs/\");\nlet tmpl = new Template(\n\"./test/stubs/templateFrontMatter.ejs\",\n\"./test/stubs/\",\n@@ -138,7 +126,7 @@ test(\"More advanced getData()\", async t => {\n});\ntest(\"One Layout\", async t => {\n- let dataObj = new TemplateData(\"./test/stubs/globalData.json\");\n+ let dataObj = new TemplateData(\"./test/stubs/\");\nlet tmpl = new Template(\n\"./test/stubs/templateWithLayout.ejs\",\n\"./test/stubs/\",\n@@ -168,7 +156,7 @@ test(\"One Layout\", async t => {\n});\ntest(\"Two Layouts\", async t => {\n- let dataObj = new TemplateData(\"./test/stubs/globalData.json\");\n+ let dataObj = new TemplateData(\"./test/stubs/\");\nlet tmpl = new Template(\n\"./test/stubs/templateTwoLayouts.ejs\",\n\"./test/stubs/\",\n@@ -200,7 +188,7 @@ test(\"Two Layouts\", async t => {\n});\ntest(\"Liquid template\", async t => {\n- let dataObj = new TemplateData(\"./test/stubs/globalData.json\");\n+ let dataObj = new TemplateData(\"./test/stubs/\");\nlet tmpl = new Template(\n\"./test/stubs/formatTest.liquid\",\n\"./test/stubs/\",\n@@ -222,7 +210,7 @@ test(\"Liquid template with include\", async t => {\n});\ntest(\"ES6 Template Literal\", async t => {\n- let dataObj = new TemplateData(\"./test/stubs/globalData.json\");\n+ let dataObj = new TemplateData(\"./test/stubs/\");\nlet tmpl = new Template(\n\"./test/stubs/formatTest.jstl\",\n\"./test/stubs/\",\n"
},
{
"change_type": "RENAME",
"old_path": "test/stubs/globalData.json",
"new_path": "test/stubs/_data/globalData.json",
"diff": ""
}
] | JavaScript | MIT License | 11ty/eleventy | Removes global data file at root (moving to _data) |
699 | 15.12.2017 21:05:30 | 21,600 | c041d71df975f3df9d13f2e3c155f912b4e2ab1e | Renames data template engine to be format independent | [
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -68,7 +68,7 @@ eleventy --input=. --output=. --formats=html\nOptionally add data files to add global static data available to all templates. See the `dir.data` configuration below.\n-The global data files will be pre-processed by a template engine specified under the `jsonDataTemplateEngine` configuration option. Note that `package.json` data is available to these options under the `_package` variable.\n+The global data files will be pre-processed by a template engine specified under the `dataTemplateEngine` configuration option. Note that `package.json` data is available to these options under the `_package` variable.\nFor example:\n@@ -100,7 +100,7 @@ module.exports = {\n| `dir.includes` | `_includes` | _Any valid directory inside of `dir.input`._ | N/A | Controls the directory inside which the template includes/extends/partials/etc can be found. |\n| `dir.data` | `_data` | _Any valid directory inside of `dir.input`._ | N/A | Controls the directory inside which the global data template files, available to all templates, can be found. |\n| `dir.output` | `_site` | _Any valid directory._ | `--output` | Controls the directory inside which the transformed finished templates can be found. |\n-| `jsonDataTemplateEngine` | `ejs` | _A valid template engine_ or `false` | N/A | Run the `data.dir` global data files through this template engine before transforming it to JSON. |\n+| `dataTemplateEngine` | `ejs` | _A valid template engine_ or `false` | N/A | Run the `data.dir` global data files through this template engine before transforming it to JSON. |\n| `markdownTemplateEngine` | `liquid` | _A valid template engine_ or `false` | N/A | Run markdown through this template engine before transforming it to HTML. |\n| `htmlTemplateEngine` | `liquid` | _A valid template engine_ or `false` | N/A | Run HTML templates through this template engine before transforming it to (better) HTML. |\n| `templateFormats` | `[\"liquid\", \"ejs\", \"md\", \"hbs\", \"mustache\", \"haml\", \"pug\", \"njk\", \"html\"]` | _Any combination of these_ | `--formats` | Specify which type of templates should be transformed. |\n"
},
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "],\n\"markdownTemplateEngine\": \"liquid\",\n\"htmlTemplateEngine\": \"liquid\",\n- \"jsonDataTemplateEngine\": \"liquid\",\n+ \"dataTemplateEngine\": \"liquid\",\n\"htmlOutputSuffix\": \"-output\",\n\"keys\": {\n\"package\": \"_package\",\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Renames data template engine to be format independent |
699 | 15.12.2017 21:27:19 | 21,600 | c82d59cec73f9393d487e7e8586042bd85366220 | Rename _package to pkg | [
{
"change_type": "MODIFY",
"old_path": "config.json",
"new_path": "config.json",
"diff": "\"dataTemplateEngine\": \"liquid\",\n\"htmlOutputSuffix\": \"-output\",\n\"keys\": {\n- \"package\": \"_package\",\n+ \"package\": \"pkg\",\n\"layout\": \"layout\",\n\"permalink\": \"permalink\"\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/_data/globalData.json",
"new_path": "test/stubs/_data/globalData.json",
"diff": "{\n\"datakey1\": \"datavalue1\",\n- \"datakey2\": \"{{_package.name}}\"\n+ \"datakey2\": \"{{pkg.name}}\"\n}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Rename _package to pkg |
699 | 15.12.2017 21:37:24 | 21,600 | 030f0f36a48370c4d36596a9ac4762f595693f44 | Local component data should not be namespaced. | [
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -76,12 +76,7 @@ TemplateData.prototype.getData = async function() {\nTemplateData.prototype.getLocalData = async function(localDataPath) {\nlet localFilename = parsePath(localDataPath).name;\n- let importedData = {};\n- importedData[localFilename] = await this.getJson(\n- localDataPath,\n- this.rawImports\n- );\n-\n+ let importedData = await this.getJson(localDataPath, this.rawImports);\nlet globalData = await this.getData();\nreturn Object.assign({}, globalData, importedData);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -243,6 +243,6 @@ test(\"Local template data file import (without a global data json)\", async t =>\nlet data = await tmpl.getData();\nt.is(tmpl.getLocalDataPath(), \"./test/stubs/component/component.json\");\n- t.is(data.component.localdatakey1, \"localdatavalue1\");\n+ t.is(data.localdatakey1, \"localdatavalue1\");\nt.is(await tmpl.render(), \"localdatavalue1\");\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/stubs/component/component.njk",
"new_path": "test/stubs/component/component.njk",
"diff": "-{{component.localdatakey1}}\n\\ No newline at end of file\n+{{localdatakey1}}\n\\ No newline at end of file\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Local component data should not be namespaced. |
699 | 17.12.2017 23:14:14 | 21,600 | b52530fce1e7e7850fdb84150ecae5aee03713e3 | Adds pagination plugin | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"hamljs\": \"^0.6.2\",\n\"handlebars\": \"^4.0.11\",\n\"liquidjs\": \"^2.0.3\",\n+ \"lodash.chunk\": \"^4.2.0\",\n+ \"lodash.clone\": \"^4.5.0\",\n\"lodash.merge\": \"^4.6.0\",\n\"markdown-it\": \"^8.4.0\",\n\"minimist\": \"^1.2.0\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Plugins/Pagination.js",
"diff": "+const chunk = require(\"lodash.chunk\");\n+\n+function Pagination(data) {\n+ this.data = data;\n+ this.defaultSize = 10;\n+}\n+\n+Pagination.prototype.setTemplate = function(tmpl) {\n+ this.template = tmpl;\n+};\n+\n+Pagination.prototype._getItems = function() {\n+ // todo targets that are children of arrays: [] not just .\n+ let keys = this.data.pagination.data.split(\".\");\n+ let target = this.data;\n+\n+ keys.forEach(function(key) {\n+ target = target[key];\n+ });\n+\n+ return target;\n+};\n+\n+Pagination.prototype._getSize = function() {\n+ return this.data.pagination.size || this.defaultSize;\n+};\n+\n+Pagination.prototype.cancel = function() {\n+ return \"pagination\" in this.data;\n+};\n+\n+Pagination.prototype.getPageTemplates = async function() {\n+ let pages = [];\n+\n+ if (this.data.pagination) {\n+ let items = chunk(this._getItems(), this._getSize());\n+ let tmpl = this.template;\n+\n+ items.forEach(\n+ function(chunk, pageNumber) {\n+ let cloned = tmpl.clone();\n+ cloned.setExtraOutputSubdirectory(pageNumber);\n+ cloned.removePlugin(\"pagination\");\n+\n+ cloned.setDataOverrides({\n+ pagination: {\n+ data: this.data.pagination.data,\n+ size: this.data.pagination.size,\n+ items: chunk,\n+ pageNumber: pageNumber\n+ }\n+ });\n+\n+ pages.push(cloned);\n+ }.bind(this)\n+ );\n+ }\n+\n+ return pages;\n+};\n+\n+Pagination.prototype.write = async function() {\n+ let pages = await this.getPageTemplates();\n+ pages.forEach(async function(pageTmpl) {\n+ await pageTmpl.write();\n+ });\n+};\n+\n+module.exports = Pagination;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateData.js",
"new_path": "src/TemplateData.js",
"diff": "@@ -75,7 +75,6 @@ TemplateData.prototype.getData = async function() {\n};\nTemplateData.prototype.getLocalData = async function(localDataPath) {\n- let localFilename = parsePath(localDataPath).name;\nlet importedData = await this.getJson(localDataPath, this.rawImports);\nlet globalData = await this.getData();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplateWriter.js",
"new_path": "src/TemplateWriter.js",
"diff": "@@ -6,6 +6,7 @@ const Template = require(\"./Template\");\nconst TemplatePath = require(\"./TemplatePath\");\nconst TemplateRender = require(\"./TemplateRender\");\nconst TemplateConfig = require(\"./TemplateConfig\");\n+const Pagination = require(\"./Plugins/Pagination\");\nconst pkg = require(\"../package.json\");\n@@ -98,9 +99,20 @@ TemplateWriter.prototype._getTemplate = function(path) {\nthis.outputDir,\nthis.templateData\n);\n- tmpl.addPostProcessFilter(function(str) {\n+\n+ tmpl.addFilter(function(str) {\nreturn pretty(str, { ocd: true });\n});\n+\n+ tmpl.addPlugin(\"pagination\", async function(data) {\n+ var paging = new Pagination(data);\n+ paging.setTemplate(this);\n+ await paging.write();\n+ if (paging.cancel()) {\n+ return false;\n+ }\n+ });\n+\nreturn tmpl;\n};\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/PaginationTest.js",
"diff": "+import test from \"ava\";\n+import Template from \"../src/Template\";\n+import TemplateData from \"../src/TemplateData\";\n+import Pagination from \"../src/Plugins/Pagination\";\n+\n+test(\"Test that getData() works\", async t => {\n+ let dataObj = new TemplateData();\n+ await dataObj.cacheData();\n+\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/paged.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\",\n+ dataObj\n+ );\n+\n+ let data = await tmpl.getData();\n+\n+ t.truthy(data.pagination);\n+ t.is(data.pagination.data, \"items.sub\");\n+ t.is(data.pagination.size, 5);\n+\n+ // local data\n+ t.truthy(data.items.sub.length);\n+\n+ var paging = new Pagination(data);\n+ paging.setTemplate(tmpl);\n+ let pages = await paging.getPageTemplates();\n+ t.is(pages.length, 2);\n+\n+ t.is(pages[0].getOutputPath(), \"./dist/paged/paged/0/index.html\");\n+ t.is(\n+ (await pages[0].render()).trim(),\n+ \"<ol><li>item1</li><li>item2</li><li>item3</li><li>item4</li><li>item5</li></ol>\"\n+ );\n+\n+ t.is(pages[1].getOutputPath(), \"./dist/paged/paged/1/index.html\");\n+ t.is(\n+ (await pages[1].render()).trim(),\n+ \"<ol><li>item6</li><li>item7</li><li>item8</li></ol>\"\n+ );\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -40,7 +40,7 @@ test(\"output path maps to an html file\", t => {\nt.is(tmpl.inputDir, \"./test/stubs\");\nt.is(tmpl.outputDir, \"./dist\");\nt.is(tmpl.getTemplateSubfolder(), \"\");\n- t.is(tmpl.getOutputPath(), \"./dist/template.html\");\n+ t.is(tmpl.getOutputPath(), \"./dist/template/index.html\");\n});\ntest(\"subfolder outputs to a subfolder\", t => {\n@@ -51,7 +51,7 @@ test(\"subfolder outputs to a subfolder\", t => {\n);\nt.is(tmpl.parsed.dir, \"./test/stubs/subfolder\");\nt.is(tmpl.getTemplateSubfolder(), \"subfolder\");\n- t.is(tmpl.getOutputPath(), \"./dist/subfolder/subfolder.html\");\n+ t.is(tmpl.getOutputPath(), \"./dist/subfolder/subfolder/index.html\");\n});\ntest(\"ignored files start with an underscore\", t => {\n@@ -63,13 +63,22 @@ test(\"ignored files start with an underscore\", t => {\nt.is(tmpl.isIgnored(), true);\n});\n-test(\"HTML files output to the same as the input directory have a file suffix added.\", async t => {\n+test(\"HTML files output to the same as the input directory have a file suffix added (only if index, this is not index).\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/testing.html\",\n\"./test/stubs\",\n\"./test/stubs\"\n);\n- t.is(tmpl.getOutputPath(), \"./test/stubs/testing-output.html\");\n+ t.is(tmpl.getOutputPath(), \"./test/stubs/testing/index.html\");\n+});\n+\n+test(\"HTML files output to the same as the input directory have a file suffix added (only if index, this _is_ index).\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/index.html\",\n+ \"./test/stubs\",\n+ \"./test/stubs\"\n+ );\n+ t.is(tmpl.getOutputPath(), \"./test/stubs/index-output.html\");\n});\ntest(\"Test raw front matter from template\", t => {\n@@ -246,3 +255,16 @@ test(\"Local template data file import (without a global data json)\", async t =>\nt.is(data.localdatakey1, \"localdatavalue1\");\nt.is(await tmpl.render(), \"localdatavalue1\");\n});\n+\n+test(\"Clone the template\", t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/default.ejs\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ let cloned = tmpl.clone();\n+\n+ t.is(tmpl.getOutputPath(), \"./dist/default/index.html\");\n+ t.is(cloned.getOutputPath(), \"./dist/default/index.html\");\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/index.html",
"diff": "+<html>\n+<body>\n+ This is an html template.\n+</body>\n+</html>\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/paged/paged.json",
"diff": "+{\n+ \"items\": {\n+ \"sub\": [\n+ \"item1\",\n+ \"item2\",\n+ \"item3\",\n+ \"item4\",\n+ \"item5\",\n+ \"item6\",\n+ \"item7\",\n+ \"item8\"\n+ ]\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/paged/paged.njk",
"diff": "+---\n+pagination:\n+ data: items.sub\n+ size: 5\n+---\n+<ol>{% for item in pagination.items %}<li>{{ item }}</li>{% endfor %}</ol>\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Adds pagination plugin |
699 | 17.12.2017 23:55:30 | 21,600 | d0790850cca7b580feb6b9d29db1fd1bb2f37e6e | Add pagination links to pagination object | [
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -62,14 +62,11 @@ Template.prototype.setExtraOutputSubdirectory = function(dir) {\nthis.extraOutputSubdirectory = dir + \"/\";\n};\n-// TODO check for conflicts, see if file already exists?\n-Template.prototype.getOutputPath = function() {\n+Template.prototype.getOutputLink = function() {\nlet permalink = this.getFrontMatterData()[cfg.keys.permalink];\nif (permalink) {\nlet permalinkParsed = parsePath(permalink);\nreturn TemplatePath.normalize(\n- this.outputDir +\n- \"/\" +\npermalinkParsed.dir +\n\"/\" +\nthis.extraOutputSubdirectory +\n@@ -79,7 +76,6 @@ Template.prototype.getOutputPath = function() {\nlet dir = this.getTemplateSubfolder();\nlet path =\n- \"/\" +\n(dir ? dir + \"/\" : \"\") +\n(this.parsed.name !== \"index\" ? this.parsed.name + \"/\" : \"\") +\nthis.extraOutputSubdirectory +\n@@ -87,7 +83,12 @@ Template.prototype.getOutputPath = function() {\n(this.isHtmlIOException ? cfg.htmlOutputSuffix : \"\") +\n\".html\";\n// console.log( this.inputPath,\"|\", this.inputDir, \"|\", dir );\n- return normalize(this.outputDir + path);\n+ return normalize(path);\n+};\n+\n+// TODO check for conflicts, see if file already exists?\n+Template.prototype.getOutputPath = function() {\n+ return normalize(this.outputDir + \"/\" + this.getOutputLink());\n};\nTemplate.prototype.setDataOverrides = function(overrides) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/PaginationTest.js",
"new_path": "test/PaginationTest.js",
"diff": "@@ -28,7 +28,7 @@ test(\"Test that getData() works\", async t => {\nlet pages = await paging.getPageTemplates();\nt.is(pages.length, 2);\n- t.is(pages[0].getOutputPath(), \"./dist/paged/paged/0/index.html\");\n+ t.is(pages[0].getOutputPath(), \"./dist/paged/paged/index.html\");\nt.is(\n(await pages[0].render()).trim(),\n\"<ol><li>item1</li><li>item2</li><li>item3</li><li>item4</li><li>item5</li></ol>\"\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -236,7 +236,7 @@ test(\"Permalink output directory\", t => {\n\"./test/stubs/\",\n\"./dist\"\n);\n- t.is(tmpl.getOutputPath(), \"dist/permalinksubfolder/index.html\");\n+ t.is(tmpl.getOutputPath(), \"./dist/permalinksubfolder/index.html\");\n});\ntest(\"Local template data file import (without a global data json)\", async t => {\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Add pagination links to pagination object |
699 | 18.12.2017 07:26:15 | 21,600 | 49a2529cee4f7e738c57879832c08c5a078c9630 | Ugh, more tabs | [
{
"change_type": "MODIFY",
"old_path": "test/LayoutTest.js",
"new_path": "test/LayoutTest.js",
"diff": "@@ -2,10 +2,10 @@ import test from \"ava\";\nimport Layout from \"../src/Layout\";\ntest(t => {\n- t.is( (new Layout( \"default\", \"./test/stubs\" )).findFileName(), \"default.ejs\" );\n+ t.is(new Layout(\"default\", \"./test/stubs\").findFileName(), \"default.ejs\");\n});\ntest(t => {\n// pick the first one if multiple exist.\n- t.is( (new Layout( \"multiple\", \"./test/stubs\" )).findFileName(), \"multiple.ejs\" );\n+ t.is(new Layout(\"multiple\", \"./test/stubs\").findFileName(), \"multiple.ejs\");\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateConfigTest.js",
"new_path": "test/TemplateConfigTest.js",
"diff": "@@ -2,7 +2,10 @@ import test from \"ava\";\nimport TemplateConfig from \"../src/TemplateConfig\";\ntest(\"Template Config local config overrides base config\", async t => {\n- let templateCfg = new TemplateConfig(require(\"../config.json\"), \"./test/stubs/config.js\" );\n+ let templateCfg = new TemplateConfig(\n+ require(\"../config.json\"),\n+ \"./test/stubs/config.js\"\n+ );\nlet cfg = templateCfg.getConfig();\nt.is(cfg.markdownTemplateEngine, \"ejs\");\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateEngineTest.js",
"new_path": "test/TemplateEngineTest.js",
"diff": "@@ -2,7 +2,7 @@ import test from \"ava\";\nimport TemplateEngine from \"../src/Engines/TemplateEngine\";\ntest(\"Unsupported engine\", async t => {\n- t.is( (new TemplateEngine( \"doesnotexist\" )).getName(), \"doesnotexist\" );\n+ t.is(new TemplateEngine(\"doesnotexist\").getName(), \"doesnotexist\");\nt.throws(() => {\nTemplateEngine.getEngine(\"doesnotexist\");\n@@ -12,12 +12,11 @@ test(\"Unsupported engine\", async t => {\ntest(\"Handlebars Helpers\", async t => {\nlet engine = TemplateEngine.getEngine(\"hbs\");\nengine.addHelpers({\n- 'uppercase': function(name) {\n+ uppercase: function(name) {\nreturn name.toUpperCase();\n}\n});\n- let fn = await engine.compile(\"<p>{{uppercase author}}</p>\")\n+ let fn = await engine.compile(\"<p>{{uppercase author}}</p>\");\nt.is(await fn({ author: \"zach\" }), \"<p>ZACH</p>\");\n});\n-\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Ugh, more tabs |
699 | 18.12.2017 21:20:54 | 21,600 | 43538f74c34051d1ec9a17993425dd0d9b5fd817 | Subdirectory global data | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"lodash.chunk\": \"^4.2.0\",\n\"lodash.clone\": \"^4.5.0\",\n\"lodash.merge\": \"^4.6.0\",\n+ \"lodash.set\": \"^4.3.2\",\n\"markdown-it\": \"^8.4.0\",\n\"minimist\": \"^1.2.0\",\n\"mustache\": \"^2.3.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/TemplatePath.js",
"new_path": "src/TemplatePath.js",
"diff": "@@ -24,4 +24,15 @@ TemplatePath.stripLeadingDotSlash = function(dir) {\nreturn dir.replace(/^\\.\\//, \"\");\n};\n+TemplatePath.stripPathFromDir = function(targetDir, prunedPath) {\n+ targetDir = TemplatePath.stripLeadingDotSlash(normalize(targetDir));\n+ prunedPath = TemplatePath.stripLeadingDotSlash(normalize(prunedPath));\n+\n+ if (targetDir.indexOf(prunedPath) === 0) {\n+ return targetDir.substr(prunedPath.length + 1);\n+ }\n+\n+ return targetDir;\n+};\n+\nmodule.exports = TemplatePath;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateDataTest.js",
"new_path": "test/TemplateDataTest.js",
"diff": "@@ -90,7 +90,12 @@ test(\"getAllGlobalData() with other data files\", async t => {\nt.true((await dataObj.getGlobalDataFiles()).length > 0);\nt.not(typeof data.testData, \"undefined\");\n+\nt.deepEqual(data.testData, {\ntestdatakey1: \"testdatavalue1\"\n});\n+\n+ t.deepEqual(data.subdir.testDataSubdir, {\n+ subdirkey: \"subdirvalue\"\n+ });\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplatePathTest.js",
"new_path": "test/TemplatePathTest.js",
"diff": "@@ -22,3 +22,18 @@ test(\"stripLeadingDotSlash\", t => {\nt.is(TemplatePath.stripLeadingDotSlash(\"../dist\"), \"../dist\");\nt.is(TemplatePath.stripLeadingDotSlash(\"dist\"), \"dist\");\n});\n+\n+test(\"stripPathFromDir\", t => {\n+ t.is(\n+ TemplatePath.stripPathFromDir(\"./testing/hello\", \"./lskdjklfjz\"),\n+ \"testing/hello\"\n+ );\n+ t.is(TemplatePath.stripPathFromDir(\"./test/stubs\", \"./test\"), \"stubs\");\n+ t.is(TemplatePath.stripPathFromDir(\"./testing/hello\", \"testing\"), \"hello\");\n+ t.is(TemplatePath.stripPathFromDir(\"testing/hello\", \"testing\"), \"hello\");\n+ t.is(TemplatePath.stripPathFromDir(\"testing/hello\", \"./testing\"), \"hello\");\n+ t.is(\n+ TemplatePath.stripPathFromDir(\"testing/hello/subdir/test\", \"testing\"),\n+ \"hello/subdir/test\"\n+ );\n+});\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/_data/subdir/testDataSubdir.json",
"diff": "+{\n+ \"subdirkey\": \"subdirvalue\"\n+}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Subdirectory global data |
699 | 18.12.2017 21:27:15 | 21,600 | 944a05b5f7374d872d94485529c087b2cfc1d830 | Allows insides arrays for pagination targets | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"liquidjs\": \"^2.0.3\",\n\"lodash.chunk\": \"^4.2.0\",\n\"lodash.clone\": \"^4.5.0\",\n+ \"lodash.get\": \"^4.4.2\",\n\"lodash.merge\": \"^4.6.0\",\n\"lodash.set\": \"^4.3.2\",\n\"markdown-it\": \"^8.4.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Plugins/Pagination.js",
"new_path": "src/Plugins/Pagination.js",
"diff": "-const chunk = require(\"lodash.chunk\");\n+const lodashchunk = require(\"lodash.chunk\");\n+const lodashget = require(\"lodash.get\");\nfunction Pagination(data) {\nthis.data = data || {};\n@@ -30,25 +31,20 @@ Pagination.prototype._getDataKey = function() {\n};\nPagination.prototype._resolveItems = function() {\n- // todo targets that are children of arrays: [] not just .\n- let keys = this._getDataKey().split(\".\");\n- let target = this.data;\n+ let notFoundValue = \"__NOT_FOUND_ERROR__\";\n+ let ret = lodashget(this.data, this._getDataKey(), notFoundValue);\n- keys.forEach(function(key) {\n- if (!(key in target)) {\n+ if (ret === notFoundValue) {\nthrow new Error(\n- `Could not resolve pagination key in front matter: ${this._getDataKey()}`\n+ `Could not resolve pagination key in template data: ${this._getDataKey()}`\n);\n}\n- target = target[key];\n- });\n-\n- return target;\n+ return ret;\n};\nPagination.prototype.getPagedItems = function() {\n- return chunk(this.target, this.size);\n+ return lodashchunk(this.target, this.size);\n};\n// TODO this name is not good\n@@ -70,6 +66,10 @@ Pagination.prototype.getTemplates = async function() {\nitems.forEach(function(chunk, pageNumber) {\nlet cloned = tmpl.clone();\n+ // TODO make permalinks work better? We want to be able to iterate over a data set and generate\n+ // templates for all things without having numeric keys in urls\n+ // Read: fonts/noto-sans instead of fonts/2\n+ // maybe also move this permalink additions up into the pagination class\nif (pageNumber > 0) {\ncloned.setExtraOutputSubdirectory(pageNumber);\n}\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Allows insides arrays for pagination targets |
699 | 18.12.2017 23:34:50 | 21,600 | 48d4e76d0b26cf7e0a5a45fdd22743b1c30e8d13 | Sweet, sweet pagination permalinks | [
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"parse-filepath\": \"^1.0.1\",\n\"pify\": \"^3.0.0\",\n\"pretty\": \"^2.0.0\",\n- \"pug\": \"^2.0.0-rc.4\"\n+ \"pug\": \"^2.0.0-rc.4\",\n+ \"slug-rfc\": \"^0.1.0\"\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Engines/Nunjucks.js",
"new_path": "src/Engines/Nunjucks.js",
"diff": "const NunjucksLib = require(\"nunjucks\");\nconst TemplateEngine = require(\"./TemplateEngine\");\n+const slug = require(\"slug-rfc\");\nclass Nunjucks extends TemplateEngine {\nconstructor(name, inputDir) {\n@@ -8,6 +9,12 @@ class Nunjucks extends TemplateEngine {\nthis.njkEnv = new NunjucksLib.Environment(\nnew NunjucksLib.FileSystemLoader(super.getInputDir())\n);\n+\n+ this.njkEnv.addFilter(\"slug\", function(str) {\n+ return slug(str, {\n+ lower: true\n+ });\n+ });\n}\nasync compile(str) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Template.js",
"new_path": "src/Template.js",
"diff": "@@ -50,27 +50,23 @@ function Template(path, inputDir, outputDir, templateData) {\n}\nTemplate.prototype.getTemplateSubfolder = function() {\n- var pathDir = this.parsed.dir;\n- var index = pathDir.indexOf(this.inputDir);\n-\n- return TemplatePath.stripLeadingDotSlash(\n- index > -1 ? pathDir.substr(this.inputDir.length + 1) : this.inputDir\n- );\n+ return TemplatePath.stripPathFromDir(this.parsed.dir, this.inputDir);\n};\nTemplate.prototype.setExtraOutputSubdirectory = function(dir) {\nthis.extraOutputSubdirectory = dir + \"/\";\n};\n-Template.prototype.getOutputLink = function() {\n+Template.prototype.getOutputLink = async function() {\nlet permalink = this.getFrontMatterData()[cfg.keys.permalink];\nif (permalink) {\n- let permalinkParsed = parsePath(permalink);\n+ let data = await this.getData();\n+ let permalinkParsed = parsePath(await this.renderContent(permalink, data));\nreturn TemplatePath.normalize(\npermalinkParsed.dir +\n\"/\" +\nthis.extraOutputSubdirectory +\n- permalinkParsed.base\n+ permalinkParsed.base // name with extension\n);\n}\n@@ -87,8 +83,9 @@ Template.prototype.getOutputLink = function() {\n};\n// TODO check for conflicts, see if file already exists?\n-Template.prototype.getOutputPath = function() {\n- return normalize(this.outputDir + \"/\" + this.getOutputLink());\n+Template.prototype.getOutputPath = async function() {\n+ let uri = await this.getOutputLink();\n+ return normalize(this.outputDir + \"/\" + uri);\n};\nTemplate.prototype.setDataOverrides = function(overrides) {\n@@ -238,14 +235,13 @@ Template.prototype.runPlugins = async function(data) {\n};\nTemplate.prototype.write = async function() {\n- let outputPath = this.getOutputPath();\n+ let outputPath = await this.getOutputPath();\nif (this.isIgnored()) {\nconsole.log(\"Ignoring\", outputPath);\n} else {\nlet data = await this.getData();\nlet str = await this.render(data);\nlet pluginRet = await this.runPlugins(data);\n-\nif (pluginRet) {\nlet filtered = this.runFilters(str);\nawait pify(fs.outputFile)(outputPath, filtered);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/PaginationTest.js",
"new_path": "test/PaginationTest.js",
"diff": "@@ -78,13 +78,19 @@ test(\"Paginate data in frontmatter\", async t => {\nlet pages = await paging.getTemplates();\nt.is(pages.length, 2);\n- t.is(pages[0].getOutputPath(), \"./dist/paged/pagedinlinedata/index.html\");\n+ t.is(\n+ await pages[0].getOutputPath(),\n+ \"./dist/paged/pagedinlinedata/index.html\"\n+ );\nt.is(\n(await pages[0].render()).trim(),\n\"<ol><li>item1</li><li>item2</li><li>item3</li><li>item4</li></ol>\"\n);\n- t.is(pages[1].getOutputPath(), \"./dist/paged/pagedinlinedata/1/index.html\");\n+ t.is(\n+ await pages[1].getOutputPath(),\n+ \"./dist/paged/pagedinlinedata/1/index.html\"\n+ );\nt.is(\n(await pages[1].render()).trim(),\n\"<ol><li>item5</li><li>item6</li><li>item7</li><li>item8</li></ol>\"\n@@ -112,15 +118,62 @@ test(\"Paginate external data file\", async t => {\nlet pages = await paging.getTemplates();\nt.is(pages.length, 2);\n- t.is(pages[0].getOutputPath(), \"./dist/paged/paged/index.html\");\n+ t.is(await pages[0].getOutputPath(), \"./dist/paged/paged/index.html\");\nt.is(\n(await pages[0].render()).trim(),\n\"<ol><li>item1</li><li>item2</li><li>item3</li><li>item4</li><li>item5</li></ol>\"\n);\n- t.is(pages[1].getOutputPath(), \"./dist/paged/paged/1/index.html\");\n+ t.is(await pages[1].getOutputPath(), \"./dist/paged/paged/1/index.html\");\nt.is(\n(await pages[1].render()).trim(),\n\"<ol><li>item6</li><li>item7</li><li>item8</li></ol>\"\n);\n});\n+\n+test(\"Permalink with pagination variables\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/pagedpermalink.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let paging = new Pagination(data);\n+ paging.setTemplate(tmpl);\n+ let pages = await paging.getTemplates();\n+\n+ t.is(\n+ await pages[0].getOutputPath(),\n+ \"./dist/paged/slug-candidate/index.html\"\n+ );\n+ t.is(\n+ await pages[1].getOutputPath(),\n+ \"./dist/paged/another-slug-candidate/index.html\"\n+ );\n+});\n+\n+test(\"Permalink with pagination variables (numeric)\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/paged/pagedpermalinknumeric.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ let data = await tmpl.getData();\n+ let paging = new Pagination(data);\n+ paging.setTemplate(tmpl);\n+ let pages = await paging.getTemplates();\n+\n+ let page0Data = await pages[0].getData();\n+ t.is(await pages[0].getOutputPath(), \"./dist/paged/page-0/index.html\");\n+ t.falsy(page0Data.pagination.previousPageLink);\n+ t.is(page0Data.pagination.nextPageLink, \"/paged/page-1/index.html\");\n+ t.is(page0Data.pagination.pageLinks.length, 2);\n+\n+ let page1Data = await pages[1].getData();\n+ t.is(await pages[1].getOutputPath(), \"./dist/paged/page-1/index.html\");\n+ t.is(page1Data.pagination.previousPageLink, \"/paged/page-0/index.html\");\n+ t.falsy(page1Data.pagination.nextPageLink);\n+ t.is(page1Data.pagination.pageLinks.length, 2);\n+});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateTest.js",
"new_path": "test/TemplateTest.js",
"diff": "@@ -30,7 +30,7 @@ test(\"getTemplateSubFolder, output is a subdir of input\", t => {\nt.is(tmpl.getTemplateSubfolder(), \"\");\n});\n-test(\"output path maps to an html file\", t => {\n+test(\"output path maps to an html file\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/template.ejs\",\n\"./test/stubs/\",\n@@ -40,10 +40,10 @@ test(\"output path maps to an html file\", t => {\nt.is(tmpl.inputDir, \"./test/stubs\");\nt.is(tmpl.outputDir, \"./dist\");\nt.is(tmpl.getTemplateSubfolder(), \"\");\n- t.is(tmpl.getOutputPath(), \"./dist/template/index.html\");\n+ t.is(await tmpl.getOutputPath(), \"./dist/template/index.html\");\n});\n-test(\"subfolder outputs to a subfolder\", t => {\n+test(\"subfolder outputs to a subfolder\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/subfolder/subfolder.ejs\",\n\"./test/stubs/\",\n@@ -51,7 +51,7 @@ test(\"subfolder outputs to a subfolder\", t => {\n);\nt.is(tmpl.parsed.dir, \"./test/stubs/subfolder\");\nt.is(tmpl.getTemplateSubfolder(), \"subfolder\");\n- t.is(tmpl.getOutputPath(), \"./dist/subfolder/subfolder/index.html\");\n+ t.is(await tmpl.getOutputPath(), \"./dist/subfolder/subfolder/index.html\");\n});\ntest(\"ignored files start with an underscore\", t => {\n@@ -69,7 +69,7 @@ test(\"HTML files output to the same as the input directory have a file suffix ad\n\"./test/stubs\",\n\"./test/stubs\"\n);\n- t.is(tmpl.getOutputPath(), \"./test/stubs/testing/index.html\");\n+ t.is(await tmpl.getOutputPath(), \"./test/stubs/testing/index.html\");\n});\ntest(\"HTML files output to the same as the input directory have a file suffix added (only if index, this _is_ index).\", async t => {\n@@ -78,7 +78,7 @@ test(\"HTML files output to the same as the input directory have a file suffix ad\n\"./test/stubs\",\n\"./test/stubs\"\n);\n- t.is(tmpl.getOutputPath(), \"./test/stubs/index-output.html\");\n+ t.is(await tmpl.getOutputPath(), \"./test/stubs/index-output.html\");\n});\ntest(\"Test raw front matter from template\", t => {\n@@ -230,13 +230,13 @@ test(\"ES6 Template Literal\", async t => {\nt.is(await tmpl.render(), `<p>ZACH</p>`);\n});\n-test(\"Permalink output directory\", t => {\n+test(\"Permalink output directory\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/permalinked.ejs\",\n\"./test/stubs/\",\n\"./dist\"\n);\n- t.is(tmpl.getOutputPath(), \"./dist/permalinksubfolder/index.html\");\n+ t.is(await tmpl.getOutputPath(), \"./dist/permalinksubfolder/index.html\");\n});\ntest(\"Local template data file import (without a global data json)\", async t => {\n@@ -256,7 +256,7 @@ test(\"Local template data file import (without a global data json)\", async t =>\nt.is(await tmpl.render(), \"localdatavalue1\");\n});\n-test(\"Clone the template\", t => {\n+test(\"Clone the template\", async t => {\nlet tmpl = new Template(\n\"./test/stubs/default.ejs\",\n\"./test/stubs/\",\n@@ -265,6 +265,16 @@ test(\"Clone the template\", t => {\nlet cloned = tmpl.clone();\n- t.is(tmpl.getOutputPath(), \"./dist/default/index.html\");\n- t.is(cloned.getOutputPath(), \"./dist/default/index.html\");\n+ t.is(await tmpl.getOutputPath(), \"./dist/default/index.html\");\n+ t.is(await cloned.getOutputPath(), \"./dist/default/index.html\");\n+});\n+\n+test(\"Permalink with variables!\", async t => {\n+ let tmpl = new Template(\n+ \"./test/stubs/permalinkdata.njk\",\n+ \"./test/stubs/\",\n+ \"./dist\"\n+ );\n+\n+ t.is(await tmpl.getOutputPath(), \"./dist/subdir/slug-candidate/index.html\");\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/TemplateWriterTest.js",
"new_path": "test/TemplateWriterTest.js",
"diff": "@@ -30,7 +30,7 @@ test(\"Output is a subdir of input\", async t => {\nlet tmpl = tw._getTemplate(files[0]);\nt.is(tmpl.inputDir, \"./test/stubs/writeTest\");\nt.is(\n- tmpl.getOutputPath(),\n+ await tmpl.getOutputPath(),\n\"./test/stubs/writeTest/_writeTestSite/test/index.html\"\n);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/paged/pagedpermalink.njk",
"diff": "+---\n+pagination:\n+ data: items\n+ size: 5\n+items:\n+ - Slug CANDIDATE\n+ - item2\n+ - item3\n+ - item4\n+ - item5\n+ - another-slug CandiDate\n+ - item7\n+ - item8\n+permalink: paged/{{ pagination.items[0] | slug }}/index.html\n+---\n+<ol>{% for item in pagination.items %}<li>{{ item }}</li>{% endfor %}</ol>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/paged/pagedpermalinknumeric.njk",
"diff": "+---\n+pagination:\n+ data: items\n+ size: 5\n+items:\n+ - Slug CANDIDATE\n+ - item2\n+ - item3\n+ - item4\n+ - item5\n+ - another-slug CandiDate\n+ - item7\n+ - item8\n+permalink: paged/page-{{ pagination.pageNumber }}/index.html\n+---\n+<ol>{% for item in pagination.items %}<li>{{ item }}</li>{% endfor %}</ol>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/stubs/permalinkdata.njk",
"diff": "+---\n+title: Slug CANDIDATE\n+permalink: subdir/{{ title | slug }}/index.html\n+---\n+Slugged.\n"
}
] | JavaScript | MIT License | 11ty/eleventy | Sweet, sweet pagination permalinks |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.