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

@curi/core

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@curi/core - npm Package Compare versions

Comparing version 1.0.0-beta.26 to 1.0.0-beta.27

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## 1.0.0-beta.27
* Update `set.redirect` to take an options object.
## 1.0.0-beta.26

@@ -2,0 +6,0 @@

26

dist/curi.common.js

@@ -57,11 +57,11 @@ 'use strict';

return {
name: 'pathname',
name: "pathname",
register: function (route, parent) {
var name = route.name, path = route.path;
if (knownPaths[name] !== undefined) {
console.warn('A pathname with the name "' +
console.warn('A route with the name "' +
name +
'" already exists. Each route should' +
'have a unique name. By registering a pathname with a name that already exists, ' +
'you are overwriting the existing pathname. This may break your application.');
"have a unique name. By registering a route with a name that already exists, " +
"you are overwriting the existing one. This may break your application.");
}

@@ -220,8 +220,14 @@ var base;

function responseSetters(props) {
function responseSetters(props, addons) {
return {
redirect: function (to, code) {
if (code === void 0) { code = 301; }
props.status = code;
props.redirectTo = to;
redirect: function (redProps) {
var name = redProps.name, params = redProps.params, query = redProps.query, hash = redProps.hash, state = redProps.state, _a = redProps.status, status = _a === void 0 ? 301 : _a;
props.status = status;
var pathname = addons.pathname(name, params);
props.redirectTo = {
pathname: pathname,
query: query,
hash: hash,
state: state
};
},

@@ -259,3 +265,3 @@ error: function (err) {

route: routeProperties(route, props),
set: responseSetters(props),
set: responseSetters(props, addons),
addons: addons

@@ -262,0 +268,0 @@ });

@@ -53,11 +53,11 @@ import PathToRegexp from 'path-to-regexp';

return {
name: 'pathname',
name: "pathname",
register: function (route, parent) {
var name = route.name, path = route.path;
if (knownPaths[name] !== undefined) {
console.warn('A pathname with the name "' +
console.warn('A route with the name "' +
name +
'" already exists. Each route should' +
'have a unique name. By registering a pathname with a name that already exists, ' +
'you are overwriting the existing pathname. This may break your application.');
"have a unique name. By registering a route with a name that already exists, " +
"you are overwriting the existing one. This may break your application.");
}

@@ -216,8 +216,14 @@ var base;

function responseSetters(props) {
function responseSetters(props, addons) {
return {
redirect: function (to, code) {
if (code === void 0) { code = 301; }
props.status = code;
props.redirectTo = to;
redirect: function (redProps) {
var name = redProps.name, params = redProps.params, query = redProps.query, hash = redProps.hash, state = redProps.state, _a = redProps.status, status = _a === void 0 ? 301 : _a;
props.status = status;
var pathname = addons.pathname(name, params);
props.redirectTo = {
pathname: pathname,
query: query,
hash: hash,
state: state
};
},

@@ -255,3 +261,3 @@ error: function (err) {

route: routeProperties(route, props),
set: responseSetters(props),
set: responseSetters(props, addons),
addons: addons

@@ -258,0 +264,0 @@ });

@@ -200,3 +200,3 @@ var Curi = (function () {

for (var j = 0; j < value.length; j++) {
segment = encode(value[j]);
segment = encode(value[j], token);

@@ -214,3 +214,3 @@ if (!matches[i].test(segment)) {

if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
segment = encode(String(value));
segment = encode(String(value), token);

@@ -433,11 +433,11 @@ if (!matches[i].test(segment)) {

return {
name: 'pathname',
name: "pathname",
register: function (route, parent) {
var name = route.name, path = route.path;
if (knownPaths[name] !== undefined) {
console.warn('A pathname with the name "' +
console.warn('A route with the name "' +
name +
'" already exists. Each route should' +
'have a unique name. By registering a pathname with a name that already exists, ' +
'you are overwriting the existing pathname. This may break your application.');
"have a unique name. By registering a route with a name that already exists, " +
"you are overwriting the existing one. This may break your application.");
}

@@ -596,8 +596,14 @@ var base;

function responseSetters(props) {
function responseSetters(props, addons) {
return {
redirect: function (to, code) {
if (code === void 0) { code = 301; }
props.status = code;
props.redirectTo = to;
redirect: function (redProps) {
var name = redProps.name, params = redProps.params, query = redProps.query, hash = redProps.hash, state = redProps.state, _a = redProps.status, status = _a === void 0 ? 301 : _a;
props.status = status;
var pathname = addons.pathname(name, params);
props.redirectTo = {
pathname: pathname,
query: query,
hash: hash,
state: state
};
},

@@ -635,3 +641,3 @@ error: function (err) {

route: routeProperties(route, props),
set: responseSetters(props),
set: responseSetters(props, addons),
addons: addons

@@ -638,0 +644,0 @@ });

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

var Curi=function(){"use strict";function e(r,n,t){r.forEach(function(r){var o=n.register(r.public,t);e(r.children,n,o)})}function r(e,r){for(var n,a=[],i=0,u=0,c="",s=r&&r.delimiter||A,l=r&&r.delimiters||k,p=!1;null!==(n=R.exec(e));){var f=n[0],h=n[1],v=n.index;if(c+=e.slice(u,v),u=v+f.length,h)c+=h[1],p=!0;else{var d="",m=e[u],g=n[2],y=n[3],x=n[4],E=n[5];if(!p&&c.length){var b=c.length-1;l.indexOf(c[b])>-1&&(d=c[b],c=c.slice(0,b))}c&&(a.push(c),c="",p=!1);var w=""!==d&&void 0!==m&&m!==d,T="+"===E||"*"===E,O="?"===E||"*"===E,j=d||s,$=y||x;a.push({name:g||i++,prefix:d,delimiter:j,optional:O,repeat:T,partial:w,pattern:$?o($):"[^"+t(j)+"]+?"})}}return(c||u<e.length)&&a.push(c+e.substr(u)),a}function n(e){for(var r=new Array(e.length),n=0;n<e.length;n++)"object"==typeof e[n]&&(r[n]=new RegExp("^(?:"+e[n].pattern+")$"));return function(n,t){for(var o="",a=t&&t.encode||encodeURIComponent,i=0;i<e.length;i++){var u=e[i];if("string"!=typeof u){var c,s=n?n[u.name]:void 0;if(Array.isArray(s)){if(!u.repeat)throw new TypeError('Expected "'+u.name+'" to not repeat, but got array');if(0===s.length){if(u.optional)continue;throw new TypeError('Expected "'+u.name+'" to not be empty')}for(var l=0;l<s.length;l++){if(c=a(s[l]),!r[i].test(c))throw new TypeError('Expected all "'+u.name+'" to match "'+u.pattern+'"');o+=(0===l?u.prefix:u.delimiter)+c}}else if("string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s){if(!u.optional)throw new TypeError('Expected "'+u.name+'" to be '+(u.repeat?"an array":"a string"));u.partial&&(o+=u.prefix)}else{if(c=a(String(s)),!r[i].test(c))throw new TypeError('Expected "'+u.name+'" to match "'+u.pattern+'", but got "'+c+'"');o+=u.prefix+c}}else o+=u}return o}}function t(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function o(e){return e.replace(/([=!:$/()])/g,"\\$1")}function a(e){return e&&e.sensitive?"":"i"}function i(e,r){if(!r)return e;var n=e.source.match(/\((?!\?)/g);if(n)for(var t=0;t<n.length;t++)r.push({name:t,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e}function u(e,r,n){for(var t=[],o=0;o<e.length;o++)t.push(l(e[o],r,n).source);return new RegExp("(?:"+t.join("|")+")",a(n))}function c(e,n,t){return s(r(e,t),n,t)}function s(e,r,n){for(var o=(n=n||{}).strict,i=!1!==n.end,u=t(n.delimiter||A),c=n.delimiters||k,s=[].concat(n.endsWith||[]).map(t).concat("$").join("|"),l="",p=!1,f=0;f<e.length;f++){var h=e[f];if("string"==typeof h)l+=t(h),p=f===e.length-1&&c.indexOf(h[h.length-1])>-1;else{var v=t(h.prefix),d=h.repeat?"(?:"+h.pattern+")(?:"+v+"(?:"+h.pattern+"))*":h.pattern;r&&r.push(h),h.optional?h.partial?l+=v+"("+d+")?":l+="(?:"+v+"("+d+"))?":l+=v+"("+d+")"}}return i?(o||(l+="(?:"+u+")?"),l+="$"===s?"$":"(?="+s+")"):(o||(l+="(?:"+u+"(?="+s+"))?"),p||(l+="(?="+u+"|"+s+")")),new RegExp("^"+l,a(n))}function l(e,r,n){return e instanceof RegExp?i(e,r):Array.isArray(e)?u(e,r,n):c(e,r,n)}function p(e){var r={},n={};return{name:"pathname",register:function(e,n){var t=e.name,o=e.path;void 0!==r[t]&&console.warn('A pathname with the name "'+t+'" already exists. Each route shouldhave a unique name. By registering a pathname with a name that already exists, you are overwriting the existing pathname. This may break your application.');var a;return n&&r[n]&&(a=r[n]),r[t]=a?C(a,o):o,t},get:function(t,o){if(null!=r[t]){var a=n[t]?n[t]:n[t]=w.compile(r[t]);return $(a(o,e))}console.error("Could not generate pathname for "+t+" because it is not registered.")},reset:function(){r={},n={}}}}function f(e,r,n,t){var o=P(r),a=e.match,i=a.re,u=a.keys,c=a.mustBeExact,s=e.children,l=i.exec(o);if(!l)return!1;var p=l[0],h=l.slice(1),v={};u.forEach(function(e,r){v[e.name]=h[r]});var d=null!=t?C(t,p):$(p);if(n.push({route:e,params:v}),!s||!s.length)return!0;var m=o.slice(p.length),g=!!m.length,y=s.some(function(e){return f(e,m,n,d)});return!(c&&g&&!y)||(n.pop(),!1)}function h(e,r){if(!r)return e;var n={};for(var t in e){var o=e[t],a=r[t];if(a)try{o=a(o)}catch(r){console.error(r),o=e[t]}n[t]=o}return n}function v(e,r){return{params:r.params,location:r.location,name:e.public.name}}function d(e,r){var n,t=[],o=[],a={};if(r.some(function(r){return f(r,e.pathname,t)}),t.length){var i=t.pop();t.forEach(function(e){o.push(e.route.public.name),Object.assign(a,h(e.params,e.route.paramParsers))}),n=i.route,Object.assign(a,h(i.params,n.paramParsers))}return m(n,{location:e,params:a,partials:o,status:null!=n?200:404,body:void 0,data:void 0,title:""})}function m(e,r){if(!e)return Promise.resolve({route:e,props:r});var n=e.public.match;return Promise.all([n.initial?n.initial():void 0,n.every?n.every(v(e,r)):void 0]).then(function(n){var t=n[0],o=n[1];return{route:e,props:r,error:null,resolved:{initial:t,every:o}}},function(n){return{route:e,props:r,error:n,resolved:null}})}function g(e){return{redirect:function(r,n){void 0===n&&(n=301),e.status=n,e.redirectTo=r},error:function(r){e.error=r},status:function(r){e.status=r},data:function(r){e.data=r},body:function(r){e.body=r},title:function(r){e.title=r}}}function y(e,r){return Object.assign({key:r.location.key,name:e?e.public.name:void 0},r)}function x(e,r){var n=e.error,t=e.resolved,o=e.route,a=e.props;return o&&o.public.match.response&&o.public.match.response({error:n,resolved:t,route:v(o,a),set:g(a),addons:r}),y(o,a)}function E(e){var r=null,n=!1;return function(){return n?r:(r=e(),n=!0,r)}}var b=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++){r=arguments[n];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e},w=l,T=r,O=n,j=s,A="/",k="./",R=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");w.parse=T,w.compile=function(e,t){return n(r(e,t))},w.tokensToFunction=O,w.tokensToRegExp=j;var $=function(e){return"/"===e.charAt(0)?e:"/"+e},P=function(e){return"/"===e.charAt(0)?e.slice(1):e},B=function(e){return"/"===e.charAt(e.length-1)?e:e+"/"},C=function(e,r){return B(e)+r},W=function(e){var r=e.name,n=e.path,t=e.pathOptions,o=void 0===t?{}:t,a=e.children,i=void 0===a?[]:a,u=e.match,c=void 0===u?{}:u,s=e.extra,l=e.params,p=null==o.end||o.end,f=[];i.length&&(o.end=!1,f=i.map(W));var h=[],v=w(n,h,o);return{public:{name:r,path:n,keys:h.map(function(e){return e.name}),match:{initial:c.initial&&E(c.initial),every:c.every,response:c.response},extra:s},match:{re:v,keys:h,mustBeExact:p},children:f,paramParsers:l}};return function(r,n,t){function o(r){T=r.map(W);for(var n in O)delete O[n];j.forEach(function(r){r.reset(),O[r.name]=r.get,e(T,r)})}function a(e,r){var n={response:e,navigation:r,router:$};for(y.forEach(function(e){e(n)}),A.forEach(function(e){null!=e&&e(n)});k.length;)k.pop()(n);E.forEach(function(e){e(n)})}function i(e,n){w=void 0,h&&h.set(e),e.redirectTo&&!g||(R.response=e,R.navigation=n,a(e,n)),e.redirectTo&&r.replace(e.redirectTo)}void 0===t&&(t={});var u=t,c=u.addons,s=void 0===c?[]:c,l=u.sideEffects,f=void 0===l?[]:l,h=u.cache,v=u.pathnameOptions,m=u.emitRedirects,g=void 0===m||m,y=[],E=[];f.forEach(function(e){e.after?E.push(e.fn):y.push(e.fn)});var w,T=[],O={},j=s.concat(p(v)),A=[],k=[],R={response:null,navigation:null};o(n),r.respondWith(function(e){w&&(w.cancel(e.action),w.cancelled=!0),w=e;var r={action:e.action,previous:R.response};if(h){var n=h.get(e.location);null!=n&&i(n,r)}d(e.location,T).then(function(n){e.cancelled||(e.finish(),i(x(n,O),r))})});var $={addons:O,history:r,respond:function(e,r){if("function"!=typeof e)throw new Error('The first argument passed to "respond" must be a function');var n=r||{},t=n.observe,o=void 0!==t&&t,a=n.initial,i=void 0===a||a;if(o){R.response&&i&&e.call(null,b({},R,{router:$}));var u=A.push(e);return function(){A[u-1]=null}}R.response&&i?e.call(null,b({},R,{router:$})):k.push(e)},refresh:o,current:function(){return{response:R.response,navigation:R.navigation}}};return $}}();
var Curi=function(){"use strict";function e(r,n,t){r.forEach(function(r){var a=n.register(r.public,t);e(r.children,n,a)})}function r(e,r){for(var n,o=[],i=0,u=0,c="",s=r&&r.delimiter||A,l=r&&r.delimiters||k,p=!1;null!==(n=R.exec(e));){var f=n[0],h=n[1],v=n.index;if(c+=e.slice(u,v),u=v+f.length,h)c+=h[1],p=!0;else{var d="",m=e[u],g=n[2],y=n[3],x=n[4],E=n[5];if(!p&&c.length){var b=c.length-1;l.indexOf(c[b])>-1&&(d=c[b],c=c.slice(0,b))}c&&(o.push(c),c="",p=!1);var w=""!==d&&void 0!==m&&m!==d,T="+"===E||"*"===E,O="?"===E||"*"===E,j=d||s,$=y||x;o.push({name:g||i++,prefix:d,delimiter:j,optional:O,repeat:T,partial:w,pattern:$?a($):"[^"+t(j)+"]+?"})}}return(c||u<e.length)&&o.push(c+e.substr(u)),o}function n(e){for(var r=new Array(e.length),n=0;n<e.length;n++)"object"==typeof e[n]&&(r[n]=new RegExp("^(?:"+e[n].pattern+")$"));return function(n,t){for(var a="",o=t&&t.encode||encodeURIComponent,i=0;i<e.length;i++){var u=e[i];if("string"!=typeof u){var c,s=n?n[u.name]:void 0;if(Array.isArray(s)){if(!u.repeat)throw new TypeError('Expected "'+u.name+'" to not repeat, but got array');if(0===s.length){if(u.optional)continue;throw new TypeError('Expected "'+u.name+'" to not be empty')}for(var l=0;l<s.length;l++){if(c=o(s[l],u),!r[i].test(c))throw new TypeError('Expected all "'+u.name+'" to match "'+u.pattern+'"');a+=(0===l?u.prefix:u.delimiter)+c}}else if("string"!=typeof s&&"number"!=typeof s&&"boolean"!=typeof s){if(!u.optional)throw new TypeError('Expected "'+u.name+'" to be '+(u.repeat?"an array":"a string"));u.partial&&(a+=u.prefix)}else{if(c=o(String(s),u),!r[i].test(c))throw new TypeError('Expected "'+u.name+'" to match "'+u.pattern+'", but got "'+c+'"');a+=u.prefix+c}}else a+=u}return a}}function t(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function a(e){return e.replace(/([=!:$/()])/g,"\\$1")}function o(e){return e&&e.sensitive?"":"i"}function i(e,r){if(!r)return e;var n=e.source.match(/\((?!\?)/g);if(n)for(var t=0;t<n.length;t++)r.push({name:t,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e}function u(e,r,n){for(var t=[],a=0;a<e.length;a++)t.push(l(e[a],r,n).source);return new RegExp("(?:"+t.join("|")+")",o(n))}function c(e,n,t){return s(r(e,t),n,t)}function s(e,r,n){for(var a=(n=n||{}).strict,i=!1!==n.end,u=t(n.delimiter||A),c=n.delimiters||k,s=[].concat(n.endsWith||[]).map(t).concat("$").join("|"),l="",p=!1,f=0;f<e.length;f++){var h=e[f];if("string"==typeof h)l+=t(h),p=f===e.length-1&&c.indexOf(h[h.length-1])>-1;else{var v=t(h.prefix),d=h.repeat?"(?:"+h.pattern+")(?:"+v+"(?:"+h.pattern+"))*":h.pattern;r&&r.push(h),h.optional?h.partial?l+=v+"("+d+")?":l+="(?:"+v+"("+d+"))?":l+=v+"("+d+")"}}return i?(a||(l+="(?:"+u+")?"),l+="$"===s?"$":"(?="+s+")"):(a||(l+="(?:"+u+"(?="+s+"))?"),p||(l+="(?="+u+"|"+s+")")),new RegExp("^"+l,o(n))}function l(e,r,n){return e instanceof RegExp?i(e,r):Array.isArray(e)?u(e,r,n):c(e,r,n)}function p(e){var r={},n={};return{name:"pathname",register:function(e,n){var t=e.name,a=e.path;void 0!==r[t]&&console.warn('A route with the name "'+t+'" already exists. Each route shouldhave a unique name. By registering a route with a name that already exists, you are overwriting the existing one. This may break your application.');var o;return n&&r[n]&&(o=r[n]),r[t]=o?B(o,a):a,t},get:function(t,a){if(null!=r[t]){var o=n[t]?n[t]:n[t]=w.compile(r[t]);return $(o(a,e))}console.error("Could not generate pathname for "+t+" because it is not registered.")},reset:function(){r={},n={}}}}function f(e,r,n,t){var a=P(r),o=e.match,i=o.re,u=o.keys,c=o.mustBeExact,s=e.children,l=i.exec(a);if(!l)return!1;var p=l[0],h=l.slice(1),v={};u.forEach(function(e,r){v[e.name]=h[r]});var d=null!=t?B(t,p):$(p);if(n.push({route:e,params:v}),!s||!s.length)return!0;var m=a.slice(p.length),g=!!m.length,y=s.some(function(e){return f(e,m,n,d)});return!(c&&g&&!y)||(n.pop(),!1)}function h(e,r){if(!r)return e;var n={};for(var t in e){var a=e[t],o=r[t];if(o)try{a=o(a)}catch(r){console.error(r),a=e[t]}n[t]=a}return n}function v(e,r){return{params:r.params,location:r.location,name:e.public.name}}function d(e,r){var n,t=[],a=[],o={};if(r.some(function(r){return f(r,e.pathname,t)}),t.length){var i=t.pop();t.forEach(function(e){a.push(e.route.public.name),Object.assign(o,h(e.params,e.route.paramParsers))}),n=i.route,Object.assign(o,h(i.params,n.paramParsers))}return m(n,{location:e,params:o,partials:a,status:null!=n?200:404,body:void 0,data:void 0,title:""})}function m(e,r){if(!e)return Promise.resolve({route:e,props:r});var n=e.public.match;return Promise.all([n.initial?n.initial():void 0,n.every?n.every(v(e,r)):void 0]).then(function(n){var t=n[0],a=n[1];return{route:e,props:r,error:null,resolved:{initial:t,every:a}}},function(n){return{route:e,props:r,error:n,resolved:null}})}function g(e,r){return{redirect:function(n){var t=n.name,a=n.params,o=n.query,i=n.hash,u=n.state,c=n.status,s=void 0===c?301:c;e.status=s;var l=r.pathname(t,a);e.redirectTo={pathname:l,query:o,hash:i,state:u}},error:function(r){e.error=r},status:function(r){e.status=r},data:function(r){e.data=r},body:function(r){e.body=r},title:function(r){e.title=r}}}function y(e,r){return Object.assign({key:r.location.key,name:e?e.public.name:void 0},r)}function x(e,r){var n=e.error,t=e.resolved,a=e.route,o=e.props;return a&&a.public.match.response&&a.public.match.response({error:n,resolved:t,route:v(a,o),set:g(o,r),addons:r}),y(a,o)}function E(e){var r=null,n=!1;return function(){return n?r:(r=e(),n=!0,r)}}var b=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++){r=arguments[n];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},w=l,T=r,O=n,j=s,A="/",k="./",R=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");w.parse=T,w.compile=function(e,t){return n(r(e,t))},w.tokensToFunction=O,w.tokensToRegExp=j;var $=function(e){return"/"===e.charAt(0)?e:"/"+e},P=function(e){return"/"===e.charAt(0)?e.slice(1):e},q=function(e){return"/"===e.charAt(e.length-1)?e:e+"/"},B=function(e,r){return q(e)+r},C=function(e){var r=e.name,n=e.path,t=e.pathOptions,a=void 0===t?{}:t,o=e.children,i=void 0===o?[]:o,u=e.match,c=void 0===u?{}:u,s=e.extra,l=e.params,p=null==a.end||a.end,f=[];i.length&&(a.end=!1,f=i.map(C));var h=[],v=w(n,h,a);return{public:{name:r,path:n,keys:h.map(function(e){return e.name}),match:{initial:c.initial&&E(c.initial),every:c.every,response:c.response},extra:s},match:{re:v,keys:h,mustBeExact:p},children:f,paramParsers:l}};return function(r,n,t){function a(r){T=r.map(C);for(var n in O)delete O[n];j.forEach(function(r){r.reset(),O[r.name]=r.get,e(T,r)})}function o(e,r){var n={response:e,navigation:r,router:$};for(y.forEach(function(e){e(n)}),A.forEach(function(e){null!=e&&e(n)});k.length;)k.pop()(n);E.forEach(function(e){e(n)})}function i(e,n){w=void 0,h&&h.set(e),e.redirectTo&&!g||(R.response=e,R.navigation=n,o(e,n)),e.redirectTo&&r.replace(e.redirectTo)}void 0===t&&(t={});var u=t,c=u.addons,s=void 0===c?[]:c,l=u.sideEffects,f=void 0===l?[]:l,h=u.cache,v=u.pathnameOptions,m=u.emitRedirects,g=void 0===m||m,y=[],E=[];f.forEach(function(e){e.after?E.push(e.fn):y.push(e.fn)});var w,T=[],O={},j=s.concat(p(v)),A=[],k=[],R={response:null,navigation:null};a(n),r.respondWith(function(e){w&&(w.cancel(e.action),w.cancelled=!0),w=e;var r={action:e.action,previous:R.response};if(h){var n=h.get(e.location);null!=n&&i(n,r)}d(e.location,T).then(function(n){e.cancelled||(e.finish(),i(x(n,O),r))})});var $={addons:O,history:r,respond:function(e,r){if("function"!=typeof e)throw new Error('The first argument passed to "respond" must be a function');var n=r||{},t=n.observe,a=void 0!==t&&t,o=n.initial,i=void 0===o||o;if(a){R.response&&i&&e.call(null,b({},R,{router:$}));var u=A.push(e);return function(){A[u-1]=null}}R.response&&i?e.call(null,b({},R,{router:$})):k.push(e)},refresh:a,current:function(){return{response:R.response,navigation:R.navigation}}};return $}}();
{
"name": "@curi/core",
"version": "1.0.0-beta.26",
"version": "1.0.0-beta.27",
"description": "A JavaScript router that doesn't care how you render",

@@ -36,7 +36,7 @@ "main": "dist/curi.common.js",

"dependencies": {
"@hickory/root": "^1.0.0-beta.6",
"@hickory/root": "^1.0.0-beta.7",
"path-to-regexp": "^2.1.0"
},
"devDependencies": {
"@hickory/in-memory": "^1.0.0-beta.3",
"@hickory/in-memory": "^1.0.0-beta.4",
"@types/jest": "^22.0.1",

@@ -43,0 +43,0 @@ "@types/node": "^8.0.53",

@@ -1,4 +0,4 @@

import { PathFunctionOptions } from 'path-to-regexp';
import { Addon } from '../types/addon';
import { PathFunctionOptions } from "path-to-regexp";
import { Addon } from "../types/addon";
declare function createPathnameAddon(options?: PathFunctionOptions): Addon;
export default createPathnameAddon;

@@ -1,3 +0,3 @@

import { Addons } from './types/addon';
import { Response, PendingResponse } from './types/response';
import { Addons } from "./types/addon";
import { Response, PendingResponse } from "./types/response";
export default function finishResponse(pending: PendingResponse, addons: Addons): Response;

@@ -1,4 +0,5 @@

import { RegExpOptions, Key } from 'path-to-regexp';
import { Params } from './response';
import { Addons } from './addon';
import { RegExpOptions, Key } from "path-to-regexp";
import { Params } from "./response";
import { Addons } from "./addon";
import { LocationDetails } from "@hickory/root";
export declare type ParamParser = (input: string) => any;

@@ -13,5 +14,10 @@ export interface ParamParsers {

}
export interface RedirectProps extends LocationDetails {
name: string;
params?: Params;
status?: number;
}
export interface ResponseSetters {
error: (err: any) => void;
redirect: (to: any, status?: number) => void;
redirect: (props: RedirectProps) => void;
data: (data: any) => void;

@@ -18,0 +24,0 @@ status: (status: number) => void;

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