{"_id":"@altafonte/router","_rev":"4-f370071db0da909437728810db154b3f","name":"@altafonte/router","dist-tags":{"latest":"0.8.1"},"versions":{"0.7.2":{"name":"@altafonte/router","version":"0.7.2","description":"New router based in @stencil/store","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","scripts":{"build":"rm -rf dist && tsc -p . && npm run rollup","fmt":"prettier --write 'src/**/*.ts'","release":"np --any-branch","rollup":"rollup -c rollup.config.js","test":"jest --passWithNoTests","test.ci":"npm run test && npm run test.prettier","test.prettier":"prettier --check 'src/**/*.ts'","version":"npm run build"},"keywords":["stencil","router","store"],"author":{"name":"Manu Mtz.-Almeida"},"license":"MIT","peerDependencies":{"@stencil/core":">=1.10.0"},"dependencies":{"@stencil/store":"^1.1.0"},"devDependencies":{"@stencil/core":"^2.4.0","jest":"26.6.3","jest-cli":"26.6.3","np":"7.2.0","prettier":"^2.2.1","rollup":"^2.38.4","ts-jest":"^26.5.0","typescript":"^4.1.3"},"repository":{"type":"git","url":"git://github.com/sethealth/router.git"},"gitHead":"85b958915f959276605c6cfb3ac46ec08bfd4fc2","bugs":{"url":"https://github.com/sethealth/router/issues"},"homepage":"https://github.com/sethealth/router#readme","_id":"@altafonte/router@0.7.2","_nodeVersion":"15.12.0","_npmVersion":"7.6.3","dist":{"integrity":"sha512-NMgrSdM+OH9xvlJu7AzhdGfRKe3xfie6MymRGwbCFVRRKIQ4dLQ9YddkxGdqv5JjXOHCb6b+nqXt4EsHSMNX/A==","shasum":"6394fd23dfefc4f067d4bd3124f193cd022e0c4d","tarball":"https://registry.npmjs.org/@altafonte/router/-/router-0.7.2.tgz","fileCount":9,"unpackedSize":36041,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgpoKKCRA9TVsSAnZWagAAhQwQAJRxLdSJV0nbEVR+1nbs\nL3psCo/CixhKq+jfBB8ageN9Wduhu/UqyCA3LKPDEOujfIaowHG62+EP1CkM\ni4zNhuSCoLJuZMTyBBx3dgdrbn1dU+uYmofhdAYlm/npwRHWN8YMQ+JhYUu5\ngNanxbBSudKhFSiKEOslqPcKCGGYX1Ii1lMqWXH3xs40TbF3aHum4tgptzT0\nxbf8M1n7vnaMy0iSYXCgpznvB9Tr43kDNu2Eiincvh11/QKyKC7DlsyapR9V\nar+y9FqAA4bUPW2PQBlB5j7gbKL7HQ8hYvtK6W9wJmJDqtdwsppIfw0YeY6r\nf09TYSkQ5S3mIUHpwrXy3N6ID8uTt/FNGAkFHxWKfyo2d4jI3ZdxOJm4XhL6\nxvSX1l9hONzHTmcZaX84Ta43Wt0bBE2Qh13ZKsukth+M71ZPRFc7Sc9BWt73\nUjjRb7LjyCQggaHDFgD+tiUgTPMjb5YIuZJKN6Zb1gdS8e4YNtzMmk1Ff8Nr\nn8G669l1RYrQm0bYEUy7HjyhFTexeHscLME+r/XkjPnr84G7YgbwcU25KY7m\nvgSiy41SYRYoDB6k3hxvayM1xqPimR2nTyJzbOqURZpSXxowi06P/gg0K8Vj\nh0uTsK/C6E0T+pRfzaLjB5sTyx45EzvB6pRrkI9lW9WOl+sIF0GxgwN92S0W\nesVq\r\n=iHyb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCaNXcGcUIAwpuAACVV8tOoM5wboWRU2hixQwHWSPba6AIhANUb5Sd/KCnKkDNLqzUvLPkms9wbmWBlJgQJkZaThF/y"}]},"_npmUser":{"name":"agm-dev","email":"adrian.registros@gmail.com"},"directories":{},"maintainers":[{"name":"tony.martin","email":"tony.martin@altafonte.com"},{"name":"adrm","email":"adrian@adrm.es"},{"name":"agm-dev","email":"adrian.registros@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.7.2_1621525130052_0.9700593960851454"},"_hasShrinkwrap":false},"0.8.0":{"name":"@altafonte/router","version":"0.8.0","description":"This is a fork of @sethealth/router, which forks stencil-router-v2","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","scripts":{"build":"rm -rf dist && tsc -p . && npm run rollup","fmt":"prettier --write 'src/**/*.ts'","release":"np --any-branch","rollup":"rollup -c rollup.config.js","test":"jest --passWithNoTests","test.ci":"npm run test && npm run test.prettier","test.prettier":"prettier --check 'src/**/*.ts'","version":"npm run build"},"keywords":["stencil","router","store"],"author":{"name":"Altafonte"},"license":"MIT","peerDependencies":{"@stencil/core":">=1.10.0"},"dependencies":{"@stencil/store":"^1.1.0"},"devDependencies":{"@stencil/core":"^2.4.0","jest":"26.6.3","jest-cli":"26.6.3","np":"7.2.0","prettier":"^2.2.1","rollup":"^2.38.4","ts-jest":"^26.5.0","typescript":"^4.1.3"},"repository":{"type":"git","url":"git://github.com/altafonte/router.git"},"gitHead":"815b78384b4b21991b18e32eb88ea89768aad986","bugs":{"url":"https://github.com/altafonte/router/issues"},"homepage":"https://github.com/altafonte/router#readme","_id":"@altafonte/router@0.8.0","_nodeVersion":"15.12.0","_npmVersion":"7.6.3","dist":{"integrity":"sha512-Fd5XuVvUmlXjX5CfvYy/2lVZWeXkGgS9btguj8jW5tR62M8DLJgz64BW4TAgCpKOp/GPo+vPqknyMYq1FnTX5Q==","shasum":"2d3f0d6eb36338e819b1cd64a0929d4930b39d1b","tarball":"https://registry.npmjs.org/@altafonte/router/-/router-0.8.0.tgz","fileCount":2,"unpackedSize":6712,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhFO+nCRA9TVsSAnZWagAAOdAP/0Y9Mkt1YrNT/3g1LjJm\nq6CK2Zq4VtycjhOQM6dbi09TsQKNjCL72Vp8zgTfIQr5oQovBRlDnQxjBeDw\n1wJCtoegxlxsCnHChE+ru6LZ4PSsMDXD8P9zuR2oBLO2IZmEu8gobuRep2ZQ\nu0nN3fCgyH7C/GPiqjbePU/kS7hebLoyGUWLVwm6A7K7mBcXwSLYWuH8zFL8\ngWoemjj6WSF651SGfGC97l4KyAGUZ6oaTDmMOPvyVA1As9p/h999BIAMfhzM\nbACahywOXOi61uCHOF+shQR30BRWOlcweC8yiIQfXrPOcUX3NBnKL5dmKf/g\nOSIaJkwyinN/6Wdas0+2ByVnm3N1pu6qwfeOKqGbKuLp0Zs0+Owub+jcBPBb\nv3P/A98ZzQAtuOH/o0d6cVXxvzAp4OtG7lQefF2ED3nBM5lTP8DQbJ4aKrC+\n7jDJ2UY9lgIQD80IATgH7vfC4AA32qBpSBb1XmjsvoOzUhKTXFqcW+dsXltD\ngak/bBV5WHVeqFw8cb95DUzQp9eQJlE8FKh/pkSHUHf8+JTN1tDLiuALPBXn\n7WXxkC9pNN8DBFIjzE7SasImvbAyQYxwtwV9nDB0uoUs/Jr4oIcbpmR7T1P2\n2QEXEfugwwSWw5/U7qCN4KiuJIR/2AnNI/MuFNMJaSiEhCGQTS5iBBaDInVC\n4JZ2\r\n=VyXL\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBbIdeo/VGBpMFwXHFxWhG+GyQxPmL9RpbP2N1wLgLn2AiEAqUvCrEntidZCEYCjRsPHMCpOnjhgNjaVZIK90zHSriU="}]},"_npmUser":{"name":"agm-dev","email":"adrian.registros@gmail.com"},"directories":{},"maintainers":[{"name":"adrm","email":"adrian@adrm.es"},{"name":"agm-dev","email":"adrian.registros@gmail.com"},{"name":"tony.martin","email":"tony.martin@altafonte.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.8.0_1628762023448_0.3969622404206825"},"_hasShrinkwrap":false},"0.8.1":{"name":"@altafonte/router","version":"0.8.1","description":"This is a fork of @sethealth/router, which forks stencil-router-v2","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","scripts":{"build":"rm -rf dist && tsc -p . && npm run rollup","fmt":"prettier --write 'src/**/*.ts'","release":"np --any-branch","rollup":"rollup -c rollup.config.js","test":"jest --passWithNoTests","test.ci":"npm run test && npm run test.prettier","test.prettier":"prettier --check 'src/**/*.ts'","version":"npm run build"},"keywords":["stencil","router","store"],"author":{"name":"Altafonte"},"license":"MIT","peerDependencies":{"@stencil/core":">=1.10.0"},"dependencies":{"@stencil/store":"^1.1.0"},"devDependencies":{"@stencil/core":"^2.4.0","jest":"26.6.3","jest-cli":"26.6.3","np":"7.2.0","prettier":"^2.2.1","rollup":"^2.38.4","ts-jest":"^26.5.0","typescript":"^4.1.3"},"repository":{"type":"git","url":"git://github.com/altafonte/router.git"},"gitHead":"815b78384b4b21991b18e32eb88ea89768aad986","bugs":{"url":"https://github.com/altafonte/router/issues"},"homepage":"https://github.com/altafonte/router#readme","_id":"@altafonte/router@0.8.1","_nodeVersion":"15.12.0","_npmVersion":"7.6.3","dist":{"integrity":"sha512-oPj3Y+8eDA8gmjQAGoMb3LDy8XmSBDWYcqvAoDz+gdpRvQbH/XHZTFzWJM5FDKJshcr74VdrDuuLCqjU9TlMFA==","shasum":"648bcba45d30e3b4fcda925ee35d280ba9069798","tarball":"https://registry.npmjs.org/@altafonte/router/-/router-0.8.1.tgz","fileCount":9,"unpackedSize":37189,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhFPFFCRA9TVsSAnZWagAAzqUQAJsJEjc4BQS0XS1xKK2A\nuED41hs1/f+zCNDGiHtpc2buXA0usHjRnJePX7963k9IbIceU+iYO2c5P/ck\njPZ/3Mn8DdE/MYYpApYBGnofnDfIWhDIusd/9cL02f+ssAz0ouoX4TFaP48N\nKLTgf2C4YSLBy4I/Z1wMAbJj2ukSohUaNZs+mMMrWYOAH1cQ0LCPb5DNBt95\nfkzhCEkyQDnqasRGzwRU7TQCHYuG9TeDAQEjY87BRzc6htWUoyDFlZmDYYEi\njTlHVgF4pjGcSNVUU6l3TSdxIDnXTHEduJ/1PsKWREyaI/zugrG7JHXBfhD3\n9cL2VKB8H2nxA4uxF8GjIoCEoo3A2Flae3JMJdcDoBFPQAcTMKP8SPBSn/B/\nkYXGYwkNp+T/DiEtr41uIZkMF/IEmppEJPGKgv92Cb5Pe+MEfGKuIlEG+80v\ngC0UvVPbTDb0tzG4RQJ44Ky3o5cwebzWx0g8EyG+gOqNRH9h+IjVXLtL6mR9\n+xQaFZRpuOg6Ify7KXhs3ligPoAsd1o4lybiqS0vmeGFMzrP5XeL54cQcuMK\nvw82dXoj9Ey9hXKh2U9k2Fm4GD6QeXx976lzg8DXq2uEXwbGpvwWzFkhNZBp\niklg0v/1e3oZ5ddHRqgEWC0q0os0udAiwG01vAeHHsOTWa8tunP+U3zq8hfz\nZxxg\r\n=Gjk5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGrzbPPvfoAZryOzUDboGSDECJ6k9Hjvyc+k4qvAzaU0AiEA7uJm1wSavkePHi9QQejukJYgM1MiJArpf0dsbmpV/zc="}]},"_npmUser":{"name":"agm-dev","email":"adrian.registros@gmail.com"},"directories":{},"maintainers":[{"name":"adrm","email":"adrian@adrm.es"},{"name":"agm-dev","email":"adrian.registros@gmail.com"},{"name":"tony.martin","email":"tony.martin@altafonte.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/router_0.8.1_1628762437493_0.11569950570607701"},"_hasShrinkwrap":false}},"time":{"created":"2021-05-20T15:38:49.730Z","0.7.2":"2021-05-20T15:38:50.208Z","modified":"2022-05-11T11:50:17.923Z","0.8.0":"2021-08-12T09:53:43.604Z","0.8.1":"2021-08-12T10:00:37.632Z"},"maintainers":[{"email":"joseluis.garcia@altafonte.com","name":"joseluis.garcia.altafonte"},{"email":"adrian@adrm.es","name":"adrm"},{"email":"adrian.registros@gmail.com","name":"agm-dev"},{"email":"tony.martin@altafonte.com","name":"tony.martin"}],"description":"This is a fork of @sethealth/router, which forks stencil-router-v2","homepage":"https://github.com/altafonte/router#readme","keywords":["stencil","router","store"],"repository":{"type":"git","url":"git://github.com/altafonte/router.git"},"author":{"name":"Altafonte"},"bugs":{"url":"https://github.com/altafonte/router/issues"},"license":"MIT","readme":"# @altafonte/router\n\nThis package is a fork of [@sethealth/router](https://www.npmjs.com/package/@sethealth/router) which is a fork of [Stencil Router V2](https://www.npmjs.com/package/stencil-router-v2), an experimental new router for stencil that focus in:\n\n- **Lightweight** (600bytes)\n- **Treeshakable** (not used features are not included in the final build)\n- **Simple**, provide the bare mininum but it make it extendable with hooks.\n- **No DOM**: Router is not render any extra DOM element, to keep styling simple.\n- **Fast**: As fast and lightweight as writing your own router with if statements.\n\n## Features added to original @sethealth/router\n\n- The `push` function accepts a second param as options, where you can tell to `replace`, so it uses `history.replaceState` instead `history.pushState`. This is intended to be used on automatic redirections, so you don't break the back/forward feature on navigators.\n- `Router.replace(url)` is a shortcut for `Router.push(url, { replace: true })`\n\n## How does it work?\n\nThis router backs up the `document.location` in a `@stencil/store`, this way we can respond to changes in document.location is a much simpler, way, not more subscribes, no more event listeners events to connect and disconnect.\n\nFunctional Components are the used to collect the list of routes, finally the `Switch` renders only the selected route.\n\n## Install\n\n```bash\nnpm install @altafonte/router\n```\n\n## Examples\n\n```tsx\nimport { createRouter, Route } from '@altafonte/router';\n\nconst Router = createRouter();\n\n@Component({\n  tag: 'app-root',\n})\nexport class AppRoot {\n\n  render() {\n    return (\n      <Host>\n        <Router.Switch>\n\n          <Route path=\"/\">\n            <h1>Welcome<h1>\n            <p>Welcome to the new stencil-router demo</p>\n          </Route>\n\n          <Route path={/^\\/account/}>\n            <app-account></app-account>\n          </Route>\n\n        </Router.Switch>\n      </Host>\n    );\n  }\n}\n```\n\n### Redirects\n\n```tsx\n<Host>\n  <Router.Switch>\n\n    <Route path=\"/\" to=\"/main\"/>\n    <Route path={/^account/} to=\"/error\"/>\n\n  </Router.Switch>\n</Host>\n```\n\n```tsx\n<Host>\n  <Router.Switch>\n\n    <Route path={match(\"/colors/:type\")} render={({ type }) => {\n      if (![\"black\", \"white\"].includes(type)) {\n        return Router.push(\"/colors/black\", { replace: true })\n      }\n      return <valid-color-component color={type}/>\n    }}/>\n\n  </Router.Switch>\n</Host>\n```\n\n### Params\n\nRoute can take an optional `render` property that will pass down the params. This method should be used instead of JSX children.\n\nRegex or functional matches have the chance to generate an object of params when the URL matches.\n\n```tsx\nimport { createRouter, Route, match } from '@altafonte/router';\n\nconst Router = createRouter();\n\n<Host>\n  <Router.Switch>\n\n    <Route\n      path={/^acc(ou)nt/}\n      render={(params) => (\n        <p>{params[1]}</p>\n      )}\n    />\n\n    <Route\n      path={match('/blog/:page')}\n      render={({page}) => <blog-post page={page}>}\n    />\n\n    <Route\n      path={(url) => {\n        if (url.includes('hello')) {\n          return {user: 'hello'}\n        }\n        return undefined;\n      }}\n      render={({user}) => (\n        <h1>User: {user}</h1>\n      )}\n    />\n\n  </Router.Switch>\n</Host>\n```\n\n### Links\n\nThe `href()` function will inject all the handles to an native `anchor`, without extra DOM.\n\n```tsx\nimport { createRouter, Route, href } from '@altafonte/router';\n\nconst Router = createRouter();\n\n<Host>\n  <Router.Switch>\n\n    <Route path=\"/main\">\n      <a {...href('/main')} class=\"my-link\">Go to blog</a>\n    </Route>\n\n    <Route path=\"/blog\">\n      <a {...href('/main')}>Go to main</a>\n    </Route>\n\n  </Router.Switch>\n</Host>\n```\n\n### Dynamic routes (guards)\n\n```tsx\n@Component({\n  tag: 'app-root',\n})\nexport class AppRoot {\n\n  @State() logged = false;\n  render() {\n    return (\n      <Host>\n        <Router.Switch>\n\n          {this.logged && (\n            <Route path=\"/account\">\n              <app-account></app-account>\n            </Route>\n          )}\n\n          {!this.logged && (\n            <Route path=\"/account\" to=\"/error\"/>\n          )\n\n        </Router.Switch>\n      </Host>\n    );\n  }\n}\n```\n\n### Subscriptions to route changes\n\nBecause the router uses `@stencil/store` its trivial to subscribe to changes in the locations, activeRoute, or even the list of routes.\n\n```tsx\nimport { createRouter, Route } from '@altafonte/router';\n\nconst Router = createRouter();\n\n@Component({\n  tag: 'app-root',\n})\nexport class AppRoot {\n  componentWillLoad() {\n    Router.onChange('url', (newValue: InternalRouterState['url'], _oldValue: InternalRouterState['url']) => {\n      // Access fields such as pathname, search, etc. from newValue\n\n      // This would be a good place to send a Google Analytics event, for example\n    });\n  }\n\n  render() {\n    const activePath = Router.state.activeRoute?.path;\n\n    return (\n      <Host>\n        <aside>\n          <a class={{'active': activePath === '/main'}}>Main</a>\n          <a class={{'active': activePath === '/account'}}>Account</a>\n        </aside>\n\n        <Router.Switch>\n\n          <Route path=\"/main\">\n            <h1>Welcome<h1>\n            <p>Welcome to the new stencil-router demo</p>\n          </Route>\n\n          <Route path='/account'>\n            <app-account></app-account>\n          </Route>\n\n        </Router.Switch>\n      </Host>\n    );\n  }\n}\n```\n\nThe routes state includes:\n\n```tsx\n  url: URL;\n  activeRoute?: RouteEntry;\n  urlParams: { [key: string]: string };\n  routes: RouteEntry[];\n```\n","readmeFilename":"README.md"}