Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

preact-router

Package Overview
Dependencies
Maintainers
8
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

preact-router - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

6

dist/preact-router.es.js

@@ -30,3 +30,3 @@ import { Component, cloneElement, createElement, toChildArray } from 'preact';

if (route[i$1] && route[i$1].charAt(0)===':') {
var param = route[i$1].replace(/(^\:|[+*?]+$)/g, ''),
var param = route[i$1].replace(/(^:|[+*?]+$)/g, ''),
flags = (route[i$1].match(/[+*?]+$/) || EMPTY$1)[0] || '',

@@ -58,4 +58,4 @@ plus = ~flags.indexOf('+'),

(a.rank < b.rank) ? 1 :
(a.rank > b.rank) ? -1 :
(a.index - b.index)
(a.rank > b.rank) ? -1 :
(a.index - b.index)
);

@@ -62,0 +62,0 @@ }

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("preact")):"function"==typeof define&&define.amd?define(["preact"],e):t.preactRouter=e(t.preact)}(this,function(t){function e(t,e){for(var n in e)t[n]=e[n];return t}function n(t,e,n){var r,o=/(?:\?([^#]*))?(#.*)?$/,u=t.match(o),a={};if(u&&u[1])for(var p=u[1].split("&"),c=0;c<p.length;c++){var f=p[c].split("=");a[decodeURIComponent(f[0])]=decodeURIComponent(f.slice(1).join("="))}t=i(t.replace(o,"")),e=i(e||"");for(var s=Math.max(t.length,e.length),l=0;l<s;l++)if(e[l]&&":"===e[l].charAt(0)){var h=e[l].replace(/(^\:|[+*?]+$)/g,""),d=(e[l].match(/[+*?]+$/)||C)[0]||"",g=~d.indexOf("+"),m=~d.indexOf("*"),y=t[l]||"";if(!y&&!m&&(d.indexOf("?")<0||g)){r=!1;break}if(a[h]=decodeURIComponent(y),g||m){a[h]=t.slice(l).map(decodeURIComponent).join("/");break}}else if(e[l]!==t[l]){r=!1;break}return(!0===n.default||!1!==r)&&a}function r(t,e){return t.rank<e.rank?1:t.rank>e.rank?-1:t.index-e.index}function o(t,e){return t.index=e,t.rank=p(t),t.props}function i(t){return t.replace(/(^\/+|\/+$)/g,"").split("/")}function u(t){return":"==t.charAt(0)?1+"*+?".indexOf(t.charAt(t.length-1))||4:5}function a(t){return i(t).map(u).join("")}function p(t){return t.props.default?0:a(t.props.path)}function c(t,e){void 0===e&&(e="push"),b&&b[e]?b[e](t):"undefined"!=typeof history&&history[e+"State"]&&history[e+"State"](null,null,t)}function f(){var t;return t=b&&b.location?b.location:b&&b.getCurrentLocation?b.getCurrentLocation():"undefined"!=typeof location?location:k,""+(t.pathname||"")+(t.search||"")}function s(t,e){return void 0===e&&(e=!1),"string"!=typeof t&&t.url&&(e=t.replace,t=t.url),l(t)&&c(t,e?"replace":"push"),h(t)}function l(t){for(var e=R.length;e--;)if(R[e].canRoute(t))return!0;return!1}function h(t){for(var e=!1,n=0;n<R.length;n++)!0===R[n].routeTo(t)&&(e=!0);for(var r=U.length;r--;)U[r](t);return e}function d(t){if(t&&t.getAttribute){var e=t.getAttribute("href"),n=t.getAttribute("target");if(e&&e.match(/^\//g)&&(!n||n.match(/^_?self$/i)))return s(e)}}function g(t){if(0==t.button)return d(t.currentTarget||t.target||this),m(t)}function m(t){return t&&(t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault()),!1}function y(t){if(!(t.ctrlKey||t.metaKey||t.altKey||t.shiftKey||0!==t.button)){var e=t.target;do{if("A"===(e.nodeName+"").toUpperCase()&&e.getAttribute("href")){if(e.hasAttribute("native"))return;if(d(e))return m(t)}}while(e=e.parentNode)}}function v(){x||("function"==typeof addEventListener&&(b||addEventListener("popstate",function(){h(f())}),addEventListener("click",y)),x=!0)}var C={},b=null,R=[],U=[],k={},x=!1,A=function(i){function u(t){i.call(this,t),t.history&&(b=t.history),this.state={url:t.url||f()},v()}return i&&(u.__proto__=i),u.prototype=Object.create(i&&i.prototype),u.prototype.constructor=u,u.prototype.shouldComponentUpdate=function(t){return!0!==t.static||(t.url!==this.props.url||t.onChange!==this.props.onChange)},u.prototype.canRoute=function(e){return this.getMatchingChildren(t.toChildArray(this.props.children),e,!1).length>0},u.prototype.routeTo=function(t){return this._didRoute=!1,this.setState({url:t}),this.updating?this.canRoute(t):(this.forceUpdate(),this._didRoute)},u.prototype.componentWillMount=function(){R.push(this),this.updating=!0},u.prototype.componentDidMount=function(){var t=this;b&&(this.unlisten=b.listen(function(e){t.routeTo(""+(e.pathname||"")+(e.search||""))})),this.updating=!1},u.prototype.componentWillUnmount=function(){"function"==typeof this.unlisten&&this.unlisten(),R.splice(R.indexOf(this),1)},u.prototype.componentWillUpdate=function(){this.updating=!0},u.prototype.componentDidUpdate=function(){this.updating=!1},u.prototype.getMatchingChildren=function(i,u,a){return i.filter(o).sort(r).map(function(r){var o=n(u,r.props.path,r.props);if(o){if(!1!==a){var i={url:u,matches:o};return e(i,o),delete i.ref,delete i.key,t.cloneElement(r,i)}return r}}).filter(Boolean)},u.prototype.render=function(e,n){var r=e.children,o=e.onChange,i=n.url,u=this.getMatchingChildren(t.toChildArray(r),i,!0),a=u[0]||null;this._didRoute=!!a;var p=this.previousUrl;return i!==p&&(this.previousUrl=i,"function"==typeof o&&o({router:this,url:i,previous:p,active:u,current:a})),a},u}(t.Component),_=function(n){return t.createElement("a",e({onClick:g},n))},E=function(e){return t.createElement(e.component,e)};return A.subscribers=U,A.getCurrentUrl=f,A.route=s,A.Router=A,A.Route=E,A.Link=_,A});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("preact")):"function"==typeof define&&define.amd?define(["preact"],e):t.preactRouter=e(t.preact)}(this,function(t){function e(t,e){for(var n in e)t[n]=e[n];return t}function n(t,e,n){var r,o=/(?:\?([^#]*))?(#.*)?$/,u=t.match(o),a={};if(u&&u[1])for(var p=u[1].split("&"),c=0;c<p.length;c++){var f=p[c].split("=");a[decodeURIComponent(f[0])]=decodeURIComponent(f.slice(1).join("="))}t=i(t.replace(o,"")),e=i(e||"");for(var s=Math.max(t.length,e.length),l=0;l<s;l++)if(e[l]&&":"===e[l].charAt(0)){var h=e[l].replace(/(^:|[+*?]+$)/g,""),d=(e[l].match(/[+*?]+$/)||C)[0]||"",g=~d.indexOf("+"),m=~d.indexOf("*"),y=t[l]||"";if(!y&&!m&&(d.indexOf("?")<0||g)){r=!1;break}if(a[h]=decodeURIComponent(y),g||m){a[h]=t.slice(l).map(decodeURIComponent).join("/");break}}else if(e[l]!==t[l]){r=!1;break}return(!0===n.default||!1!==r)&&a}function r(t,e){return t.rank<e.rank?1:t.rank>e.rank?-1:t.index-e.index}function o(t,e){return t.index=e,t.rank=p(t),t.props}function i(t){return t.replace(/(^\/+|\/+$)/g,"").split("/")}function u(t){return":"==t.charAt(0)?1+"*+?".indexOf(t.charAt(t.length-1))||4:5}function a(t){return i(t).map(u).join("")}function p(t){return t.props.default?0:a(t.props.path)}function c(t,e){void 0===e&&(e="push"),b&&b[e]?b[e](t):"undefined"!=typeof history&&history[e+"State"]&&history[e+"State"](null,null,t)}function f(){var t;return t=b&&b.location?b.location:b&&b.getCurrentLocation?b.getCurrentLocation():"undefined"!=typeof location?location:k,""+(t.pathname||"")+(t.search||"")}function s(t,e){return void 0===e&&(e=!1),"string"!=typeof t&&t.url&&(e=t.replace,t=t.url),l(t)&&c(t,e?"replace":"push"),h(t)}function l(t){for(var e=R.length;e--;)if(R[e].canRoute(t))return!0;return!1}function h(t){for(var e=!1,n=0;n<R.length;n++)!0===R[n].routeTo(t)&&(e=!0);for(var r=U.length;r--;)U[r](t);return e}function d(t){if(t&&t.getAttribute){var e=t.getAttribute("href"),n=t.getAttribute("target");if(e&&e.match(/^\//g)&&(!n||n.match(/^_?self$/i)))return s(e)}}function g(t){if(0==t.button)return d(t.currentTarget||t.target||this),m(t)}function m(t){return t&&(t.stopImmediatePropagation&&t.stopImmediatePropagation(),t.stopPropagation&&t.stopPropagation(),t.preventDefault()),!1}function y(t){if(!(t.ctrlKey||t.metaKey||t.altKey||t.shiftKey||0!==t.button)){var e=t.target;do{if("A"===(e.nodeName+"").toUpperCase()&&e.getAttribute("href")){if(e.hasAttribute("native"))return;if(d(e))return m(t)}}while(e=e.parentNode)}}function v(){x||("function"==typeof addEventListener&&(b||addEventListener("popstate",function(){h(f())}),addEventListener("click",y)),x=!0)}var C={},b=null,R=[],U=[],k={},x=!1,A=function(i){function u(t){i.call(this,t),t.history&&(b=t.history),this.state={url:t.url||f()},v()}return i&&(u.__proto__=i),u.prototype=Object.create(i&&i.prototype),u.prototype.constructor=u,u.prototype.shouldComponentUpdate=function(t){return!0!==t.static||(t.url!==this.props.url||t.onChange!==this.props.onChange)},u.prototype.canRoute=function(e){return this.getMatchingChildren(t.toChildArray(this.props.children),e,!1).length>0},u.prototype.routeTo=function(t){return this._didRoute=!1,this.setState({url:t}),this.updating?this.canRoute(t):(this.forceUpdate(),this._didRoute)},u.prototype.componentWillMount=function(){R.push(this),this.updating=!0},u.prototype.componentDidMount=function(){var t=this;b&&(this.unlisten=b.listen(function(e){t.routeTo(""+(e.pathname||"")+(e.search||""))})),this.updating=!1},u.prototype.componentWillUnmount=function(){"function"==typeof this.unlisten&&this.unlisten(),R.splice(R.indexOf(this),1)},u.prototype.componentWillUpdate=function(){this.updating=!0},u.prototype.componentDidUpdate=function(){this.updating=!1},u.prototype.getMatchingChildren=function(i,u,a){return i.filter(o).sort(r).map(function(r){var o=n(u,r.props.path,r.props);if(o){if(!1!==a){var i={url:u,matches:o};return e(i,o),delete i.ref,delete i.key,t.cloneElement(r,i)}return r}}).filter(Boolean)},u.prototype.render=function(e,n){var r=e.children,o=e.onChange,i=n.url,u=this.getMatchingChildren(t.toChildArray(r),i,!0),a=u[0]||null;this._didRoute=!!a;var p=this.previousUrl;return i!==p&&(this.previousUrl=i,"function"==typeof o&&o({router:this,url:i,previous:p,active:u,current:a})),a},u}(t.Component),_=function(n){return t.createElement("a",e({onClick:g},n))},E=function(e){return t.createElement(e.component,e)};return A.subscribers=U,A.getCurrentUrl=f,A.route=s,A.Router=A,A.Route=E,A.Link=_,A});
//# sourceMappingURL=preact-router.js.map

@@ -65,3 +65,3 @@ import * as preact from 'preact';

export function Link(props: {activeClassName?: string} & JSX.HTMLAttributes): preact.VNode;
export function Link(props: {activeClassName?: string} & preact.JSX.HTMLAttributes): preact.VNode;

@@ -68,0 +68,0 @@ declare module 'preact' {

@@ -9,4 +9,5 @@ import * as preact from 'preact';

export interface LinkProps extends JSX.HTMLAttributes {
export interface LinkProps extends preact.JSX.HTMLAttributes {
activeClassName: string;
children?: preact.ComponentChildren;
}

@@ -13,0 +14,0 @@

{
"name": "preact-router",
"amdName": "preactRouter",
"version": "3.0.0",
"version": "3.0.1",
"description": "Connect your components up to that address bar.",

@@ -17,3 +17,4 @@ "main": "dist/preact-router.js",

"test": "npm-run-all lint build test:karma test:ts",
"lint": "eslint {src,test,test_helpers}",
"lint": "eslint ./{src,test,test_helpers}/**/*.js",
"fix": "npm run lint -- --fix",
"test:karma": "karma start --single-run",

@@ -48,3 +49,3 @@ "test:watch": "karma start",

"peerDependencies": {
"preact": ">=10 || ^10.0.0-alpha.0"
"preact": ">=10 || ^10.0.0-beta.0"
},

@@ -66,18 +67,18 @@ "devDependencies": {

"diff": "^3.0.0",
"eslint": "^3.0.0",
"eslint": "^5.8.0",
"eslint-plugin-react": "^6.0.0",
"gzip-size-cli": "^1.0.0",
"karma": "^1.0.0",
"karma": "^3.1.1",
"karma-chai-sinon": "^0.1.5",
"karma-mocha": "^1.0.1",
"karma-mocha-reporter": "^2.0.3",
"karma-phantomjs-launcher": "^1.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-mocha": "^1.3.0",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.1",
"mkdirp": "^0.5.1",
"mocha": "^3.0.0",
"mocha": "^5.2.0",
"npm-run-all": "^3.0.0",
"phantomjs-prebuilt": "^2.1.7",
"preact": "^10.0.0-alpha.0",
"preact": "^10.0.0-beta.0",
"pretty-bytes-cli": "^1.0.0",
"puppeteer": "^1.9.0",
"rimraf": "^2.5.1",

@@ -90,7 +91,7 @@ "rollup": "^0.41.6",

"rollup-plugin-uglify": "^1.0.1",
"sinon": "^1.17.4",
"sinon": "^7.1.0",
"sinon-chai": "^2.8.0",
"typescript": "^2.5.3",
"typescript": "^3.4.4",
"webpack": "^1.13.1"
}
}

@@ -123,4 +123,3 @@ # preact-router

```js
import { Router } from 'preact-router';
import { Link } from 'preact-router/match';
import { Router, Link } from 'preact-router';

@@ -224,3 +223,3 @@ render(

import Router from 'preact-router';
import createHashHistory from 'history/createHashHistory';
import { createHashHistory } from 'history';

@@ -227,0 +226,0 @@ const Main = () => (

@@ -65,3 +65,3 @@ import * as preact from 'preact';

export function Link(props: {activeClassName?: string} & JSX.HTMLAttributes): preact.VNode;
export function Link(props: {activeClassName?: string} & preact.JSX.HTMLAttributes): preact.VNode;

@@ -68,0 +68,0 @@ declare module 'preact' {

@@ -9,4 +9,5 @@ import * as preact from 'preact';

export interface LinkProps extends JSX.HTMLAttributes {
export interface LinkProps extends preact.JSX.HTMLAttributes {
activeClassName: string;
children?: preact.ComponentChildren;
}

@@ -13,0 +14,0 @@

@@ -29,3 +29,3 @@

if (route[i] && route[i].charAt(0)===':') {
let param = route[i].replace(/(^\:|[+*?]+$)/g, ''),
let param = route[i].replace(/(^:|[+*?]+$)/g, ''),
flags = (route[i].match(/[+*?]+$/) || EMPTY)[0] || '',

@@ -57,4 +57,4 @@ plus = ~flags.indexOf('+'),

(a.rank < b.rank) ? 1 :
(a.rank > b.rank) ? -1 :
(a.index - b.index)
(a.rank > b.rank) ? -1 :
(a.index - b.index)
);

@@ -61,0 +61,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc