New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@nx/next-router

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nx/next-router - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

2

dist/index.d.ts

@@ -19,2 +19,2 @@ import NextLink from 'next/link';

export { default as RouteClass } from './Route';
export { Routes, RouteMatch, RouteAssemble, LinkProps } from './types';
export { Routes, RouteMatch, RouteAssemble, LinkProps, CurrentRoute, } from './types';

@@ -199,3 +199,3 @@ 'use strict';

this.currentRoute = null;
this.addRoutes(routes);
this.setRoutes(routes);
this.events = events(this);

@@ -206,7 +206,8 @@ }

_proto.addRoutes = function addRoutes(routes, overwrite) {
if (overwrite) {
this.routes = {};
}
_proto.setRoutes = function setRoutes(routes) {
this.routes = {};
this.addRoutes(routes);
};
_proto.addRoutes = function addRoutes(routes) {
for (var route in routes) {

@@ -221,2 +222,6 @@ if (!routes.hasOwnProperty(route)) {

_proto.getRoutes = function getRoutes() {
return this.routes;
};
_proto.match = function match(asPath) {

@@ -223,0 +228,0 @@ for (var route in this.routes) {

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

"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=t(require("next/router")),r=require("react"),n=t(require("next/link"));function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function u(t,e){if(null==t)return{};var r,n,o={},u=Object.keys(t);for(n=0;n<u.length;n++)e.indexOf(r=u[n])>=0||(o[r]=t[r]);return o}var a=require("path-to-regexp"),i=function(){function t(t,e){this.page=e,this.compiled=a.compile(t),this.keys=[],this.regex=a(t,this.keys)}var e=t.prototype;return e.valuesToParams=function(t,e){return t.reduce(function(t,r,n){var o;return void 0===r?t:Object.assign(t,((o={})[e[n].name]=decodeURIComponent(r),o))},{})},e.match=function(t){var e=t.split("#"),r=e[0].split("?"),n=r[0],o={};r.length>1&&(o=function(t){if(!t)return{};var e=t.split("&"),r={};return e.map(function(t){var e=t.split("="),n=e[0],o=e[1];n&&(r[n]=o?decodeURIComponent(o):null)}),r}(r[1]));var u=e.length>1?e[1]:"",a=this.regex.exec(n);return null!==a?{params:this.valuesToParams(a.slice(1),this.keys),query:o,hash:u,path:t,page:this.page,matched:!0}:{params:{},query:o,hash:u,path:t,page:"",matched:!1}},e.assemble=function(t){var e=this.compiled(t);return""===e?"/":e.replace(/%23/g,"#")},e.getPage=function(){return this.page},t}(),s=function(t,e){return function(){var r=arguments.length<=0?void 0:arguments[0];arguments.length>1&&(r=arguments.length<=1?void 0:arguments[1]);var n=t.match(r),o=t.currentRouteFromMatch(n);1===arguments.length?e(o):e(arguments.length<=0?void 0:arguments[0],o)}},h=function(t,e){return t.findIndex(function(t){return t.handler===e})},c=function(){function t(t){var r,n;this.routes={},this.currentRoute=null,this.addRoutes(t),this.events=(r=this,n=Object.create(null),{on:function(t,o){var u=s(r,o);e.events.on(t,u),(n[t]||(n[t]=[])).push({handler:o,handlerRouter:u})},off:function(t,r){if(n[t]){var o=h(n[t],r);o>=0&&(e.events.off(t,n[t][o].handlerRouter),n[t].splice(o,1))}}})}var r=t.prototype;return r.addRoutes=function(t,e){for(var r in e&&(this.routes={}),t)t.hasOwnProperty(r)&&(this.routes[r]=new i(t[r].pattern,t[r].page))},r.match=function(t){for(var e in this.routes)if(this.routes.hasOwnProperty(e)){var r=this.routes[e].match(t);if(r.matched)return o({},r,{route:e})}return{route:"",params:{},query:{},path:t,page:"",hash:"",matched:!1}},r.assemble=function(t,e){if(this.routes[t])return{path:this.routes[t].assemble(e),page:this.routes[t].getPage()};throw new Error("next-router: No route matched")},r.getLinkProps=function(t,e,r){void 0===e&&(e={}),void 0===r&&(r="");var n=this.assemble(t,e);return{href:{pathname:n.page,query:e},as:n.path+(""!==r?"#"+r:"")}},r.getLinkPropsFromHref=function(t,e){void 0===e&&(e=function(t){return t});var r="/"!==t.substr(0,1)?"/"+t:t,n=this.match(e(r));return n.matched?this.getLinkProps(n.route,n.params,n.hash):{href:t,as:t}},r.push=function(t,r,n,o){void 0===r&&(r={}),void 0===n&&(n=""),void 0===o&&(o={});var u=this.getLinkProps(t,r,n);return e.push(u.href,u.as,o)},r.pushHref=function(t,r){void 0===r&&(r={});var n=this.getLinkPropsFromHref(t);return e.push(n.href,n.as,r)},r.replace=function(t,r,n,o){void 0===r&&(r={}),void 0===n&&(n=""),void 0===o&&(o={});var u=this.getLinkProps(t,r,n);return e.replace(u.href,u.as,o)},r.replaceHref=function(t,r){void 0===r&&(r={});var n=this.getLinkPropsFromHref(t);return e.replace(n.href,n.as,r)},r.getRequestHandler=function(t){var e=this;return function(r,n,o){if(r.url.match(/^\/_next|^\/static/))return o();var u=e.match(r.url),a=u.route,i=u.page,s=u.params,h=u.query;if(u.matched&&(e.setCurrentRoute({route:a,page:i,params:s,query:h,hash:u.hash}),t))return t(r,n,i,s,h,a);o()}},r.currentRouteFromMatch=function(t){return{route:t.route,page:t.page,params:t.params,query:t.query,hash:t.hash}},r.setCurrentRoute=function(t){this.currentRoute=t},r.getCurrentRoute=function(){return this.currentRoute},t}(),p=function(t){return function(e){var a,i=e.route,s=e.params,h=void 0===s?{}:s,c=e.hash,p=void 0===c?"":c,f=e.href,l=e.children,v=u(e,["route","params","hash","href","children"]);if(!i&&!f)throw new Error("next-router: You have to provide a route or a href to the Link");return a=o({},i?t.getLinkProps(i,h,p):t.getLinkPropsFromHref(f||""),{},v),r.createElement(n,Object.assign({},a),l)}},f=function(t,e){return e.match(t.ctx.asPath||"")},l=function(t,e){return e||(e=f),function(n){var a;return(a=function(e){var o,a;function i(){return e.apply(this,arguments)||this}return a=e,(o=i).prototype=Object.create(a.prototype),o.prototype.constructor=o,o.__proto__=a,i.prototype.render=function(){var e=this.props,o=e.initialProps,a=e.nextRouter_currentRoute,i=u(e,["initialProps","nextRouter_currentRoute"]);return t.getCurrentRoute()||t.setCurrentRoute(a),r.createElement(n,Object.assign({},i,o))},i}(r.Component)).getInitialProps=function(r){try{var u=function(){return{nextRouter_currentRoute:c,initialProps:a}},a={},i={route:"",params:{},query:{},path:"",page:"",hash:"",matched:!1};e&&(i=e(r,t)),i.matched||r.ctx.res&&(r.ctx.res.statusCode=404);var s=i.params,h=i.query,c={route:i.route,page:i.page,params:s,query:h,hash:i.hash};t.setCurrentRoute(c),r.ctx.query=o({},h,{},s);var p=function(){if("getInitialProps"in n)return Promise.resolve(n.getInitialProps.call(n,r)).then(function(t){a=t})}();return Promise.resolve(p&&p.then?p.then(u):u())}catch(t){return Promise.reject(t)}},a}};exports.LinkFactory=p,exports.RouteClass=i,exports.RouterClass=c,exports.init=function(t,e,r,n){exports.Router=e?new e(t):new c(t),exports.Link=r?r(exports.Router):p(exports.Router),exports.withNextRouter=l(exports.Router,n)},exports.useRouter=function(){if(!exports.Router)throw new Error("next-router: Router is not set. You have to initialize next-router first.");return exports.Router.getCurrentRoute()},exports.withNextRouterFactory=l;
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=t(require("next/router")),r=require("react"),n=t(require("next/link"));function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function u(t,e){if(null==t)return{};var r,n,o={},u=Object.keys(t);for(n=0;n<u.length;n++)e.indexOf(r=u[n])>=0||(o[r]=t[r]);return o}var a=require("path-to-regexp"),i=function(){function t(t,e){this.page=e,this.compiled=a.compile(t),this.keys=[],this.regex=a(t,this.keys)}var e=t.prototype;return e.valuesToParams=function(t,e){return t.reduce(function(t,r,n){var o;return void 0===r?t:Object.assign(t,((o={})[e[n].name]=decodeURIComponent(r),o))},{})},e.match=function(t){var e=t.split("#"),r=e[0].split("?"),n=r[0],o={};r.length>1&&(o=function(t){if(!t)return{};var e=t.split("&"),r={};return e.map(function(t){var e=t.split("="),n=e[0],o=e[1];n&&(r[n]=o?decodeURIComponent(o):null)}),r}(r[1]));var u=e.length>1?e[1]:"",a=this.regex.exec(n);return null!==a?{params:this.valuesToParams(a.slice(1),this.keys),query:o,hash:u,path:t,page:this.page,matched:!0}:{params:{},query:o,hash:u,path:t,page:"",matched:!1}},e.assemble=function(t){var e=this.compiled(t);return""===e?"/":e.replace(/%23/g,"#")},e.getPage=function(){return this.page},t}(),s=function(t,e){return function(){var r=arguments.length<=0?void 0:arguments[0];arguments.length>1&&(r=arguments.length<=1?void 0:arguments[1]);var n=t.match(r),o=t.currentRouteFromMatch(n);1===arguments.length?e(o):e(arguments.length<=0?void 0:arguments[0],o)}},h=function(t,e){return t.findIndex(function(t){return t.handler===e})},c=function(){function t(t){var r,n;this.routes={},this.currentRoute=null,this.setRoutes(t),this.events=(r=this,n=Object.create(null),{on:function(t,o){var u=s(r,o);e.events.on(t,u),(n[t]||(n[t]=[])).push({handler:o,handlerRouter:u})},off:function(t,r){if(n[t]){var o=h(n[t],r);o>=0&&(e.events.off(t,n[t][o].handlerRouter),n[t].splice(o,1))}}})}var r=t.prototype;return r.setRoutes=function(t){this.routes={},this.addRoutes(t)},r.addRoutes=function(t){for(var e in t)t.hasOwnProperty(e)&&(this.routes[e]=new i(t[e].pattern,t[e].page))},r.getRoutes=function(){return this.routes},r.match=function(t){for(var e in this.routes)if(this.routes.hasOwnProperty(e)){var r=this.routes[e].match(t);if(r.matched)return o({},r,{route:e})}return{route:"",params:{},query:{},path:t,page:"",hash:"",matched:!1}},r.assemble=function(t,e){if(this.routes[t])return{path:this.routes[t].assemble(e),page:this.routes[t].getPage()};throw new Error("next-router: No route matched")},r.getLinkProps=function(t,e,r){void 0===e&&(e={}),void 0===r&&(r="");var n=this.assemble(t,e);return{href:{pathname:n.page,query:e},as:n.path+(""!==r?"#"+r:"")}},r.getLinkPropsFromHref=function(t,e){void 0===e&&(e=function(t){return t});var r="/"!==t.substr(0,1)?"/"+t:t,n=this.match(e(r));return n.matched?this.getLinkProps(n.route,n.params,n.hash):{href:t,as:t}},r.push=function(t,r,n,o){void 0===r&&(r={}),void 0===n&&(n=""),void 0===o&&(o={});var u=this.getLinkProps(t,r,n);return e.push(u.href,u.as,o)},r.pushHref=function(t,r){void 0===r&&(r={});var n=this.getLinkPropsFromHref(t);return e.push(n.href,n.as,r)},r.replace=function(t,r,n,o){void 0===r&&(r={}),void 0===n&&(n=""),void 0===o&&(o={});var u=this.getLinkProps(t,r,n);return e.replace(u.href,u.as,o)},r.replaceHref=function(t,r){void 0===r&&(r={});var n=this.getLinkPropsFromHref(t);return e.replace(n.href,n.as,r)},r.getRequestHandler=function(t){var e=this;return function(r,n,o){if(r.url.match(/^\/_next|^\/static/))return o();var u=e.match(r.url),a=u.route,i=u.page,s=u.params,h=u.query;if(u.matched&&(e.setCurrentRoute({route:a,page:i,params:s,query:h,hash:u.hash}),t))return t(r,n,i,s,h,a);o()}},r.currentRouteFromMatch=function(t){return{route:t.route,page:t.page,params:t.params,query:t.query,hash:t.hash}},r.setCurrentRoute=function(t){this.currentRoute=t},r.getCurrentRoute=function(){return this.currentRoute},t}(),p=function(t){return function(e){var a,i=e.route,s=e.params,h=void 0===s?{}:s,c=e.hash,p=void 0===c?"":c,f=e.href,l=e.children,v=u(e,["route","params","hash","href","children"]);if(!i&&!f)throw new Error("next-router: You have to provide a route or a href to the Link");return a=o({},i?t.getLinkProps(i,h,p):t.getLinkPropsFromHref(f||""),{},v),r.createElement(n,Object.assign({},a),l)}},f=function(t,e){return e.match(t.ctx.asPath||"")},l=function(t,e){return e||(e=f),function(n){var a;return(a=function(e){var o,a;function i(){return e.apply(this,arguments)||this}return a=e,(o=i).prototype=Object.create(a.prototype),o.prototype.constructor=o,o.__proto__=a,i.prototype.render=function(){var e=this.props,o=e.initialProps,a=e.nextRouter_currentRoute,i=u(e,["initialProps","nextRouter_currentRoute"]);return t.getCurrentRoute()||t.setCurrentRoute(a),r.createElement(n,Object.assign({},i,o))},i}(r.Component)).getInitialProps=function(r){try{var u=function(){return{nextRouter_currentRoute:c,initialProps:a}},a={},i={route:"",params:{},query:{},path:"",page:"",hash:"",matched:!1};e&&(i=e(r,t)),i.matched||r.ctx.res&&(r.ctx.res.statusCode=404);var s=i.params,h=i.query,c={route:i.route,page:i.page,params:s,query:h,hash:i.hash};t.setCurrentRoute(c),r.ctx.query=o({},h,{},s);var p=function(){if("getInitialProps"in n)return Promise.resolve(n.getInitialProps.call(n,r)).then(function(t){a=t})}();return Promise.resolve(p&&p.then?p.then(u):u())}catch(t){return Promise.reject(t)}},a}};exports.LinkFactory=p,exports.RouteClass=i,exports.RouterClass=c,exports.init=function(t,e,r,n){exports.Router=e?new e(t):new c(t),exports.Link=r?r(exports.Router):p(exports.Router),exports.withNextRouter=l(exports.Router,n)},exports.useRouter=function(){if(!exports.Router)throw new Error("next-router: Router is not set. You have to initialize next-router first.");return exports.Router.getCurrentRoute()},exports.withNextRouterFactory=l;
//# sourceMappingURL=next-router.cjs.production.min.js.map

@@ -195,3 +195,3 @@ import NextRouter from 'next/router';

this.currentRoute = null;
this.addRoutes(routes);
this.setRoutes(routes);
this.events = events(this);

@@ -202,7 +202,8 @@ }

_proto.addRoutes = function addRoutes(routes, overwrite) {
if (overwrite) {
this.routes = {};
}
_proto.setRoutes = function setRoutes(routes) {
this.routes = {};
this.addRoutes(routes);
};
_proto.addRoutes = function addRoutes(routes) {
for (var route in routes) {

@@ -217,2 +218,6 @@ if (!routes.hasOwnProperty(route)) {

_proto.getRoutes = function getRoutes() {
return this.routes;
};
_proto.match = function match(asPath) {

@@ -219,0 +224,0 @@ for (var route in this.routes) {

import { RouterMatch, CurrentRoute, Routes, RouteAssemble, LinkProps } from '../types';
import Route from '../Route';
import { Events } from '../utils/events';

@@ -8,3 +9,7 @@ declare class Router {

constructor(routes: Routes);
addRoutes(routes: Routes, overwrite?: boolean): void;
setRoutes(routes: Routes): void;
addRoutes(routes: Routes): void;
getRoutes(): {
[key: string]: Route;
};
match(asPath: string): RouterMatch;

@@ -11,0 +16,0 @@ assemble(route: string, params: any): RouteAssemble;

{
"name": "@nx/next-router",
"version": "1.3.0",
"version": "1.4.0",
"description": "A routing library for Next.js",

@@ -5,0 +5,0 @@ "repository": "nexumAG/next-router",

Sorry, the diff of this file is not supported yet

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