@curi/core
Advanced tools
Comparing version 1.0.0-beta.33 to 1.0.0-beta.34
@@ -0,1 +1,5 @@ | ||
## 1.0.0-beta.34 | ||
* Bug fix: actually pass arguments object to `on.initial()`. | ||
## 1.0.0-beta.33 | ||
@@ -2,0 +6,0 @@ |
@@ -248,3 +248,3 @@ 'use strict'; | ||
} | ||
promise = fn(); | ||
promise = fn.apply(null, arguments); | ||
hasRun = true; | ||
@@ -251,0 +251,0 @@ return promise; |
@@ -244,3 +244,3 @@ import PathToRegexp from 'path-to-regexp'; | ||
} | ||
promise = fn(); | ||
promise = fn.apply(null, arguments); | ||
hasRun = true; | ||
@@ -247,0 +247,0 @@ return promise; |
@@ -621,3 +621,3 @@ var Curi = (function () { | ||
} | ||
promise = fn(); | ||
promise = fn.apply(null, arguments); | ||
hasRun = true; | ||
@@ -624,0 +624,0 @@ return promise; |
@@ -1,1 +0,1 @@ | ||
var Curi=function(){"use strict";var b=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e};var E=c,e=o,r=function(e,r){return a(o(e,r))},t=a,n=i,T="/",P="./",j=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function o(e,r){for(var t,n,a=[],o=0,i=0,c="",u=r&&r.delimiter||T,l=r&&r.delimiters||P,s=!1;null!==(t=j.exec(e));){var p=t[0],f=t[1],h=t.index;if(c+=e.slice(i,h),i=h+p.length,f)c+=f[1],s=!0;else{var v="",m=e[i],d=t[2],g=t[3],y=t[4],b=t[5];if(!s&&c.length){var E=c.length-1;-1<l.indexOf(c[E])&&(v=c[E],c=c.slice(0,E))}c&&(a.push(c),c="",s=!1);var x=""!==v&&void 0!==m&&m!==v,w="+"===b||"*"===b,O="?"===b||"*"===b,A=v||u,R=g||y;a.push({name:d||o++,prefix:v,delimiter:A,optional:O,repeat:w,partial:x,pattern:R?(n=R,n.replace(/([=!:$/()])/g,"\\$1")):"[^"+C(A)+"]+?"})}}return(c||i<e.length)&&a.push(c+e.substr(i)),a}function a(l){for(var s=new Array(l.length),e=0;e<l.length;e++)"object"==typeof l[e]&&(s[e]=new RegExp("^(?:"+l[e].pattern+")$"));return function(e,r){for(var t="",n=r&&r.encode||encodeURIComponent,a=0;a<l.length;a++){var o=l[a];if("string"!=typeof o){var i,c=e?e[o.name]:void 0;if(Array.isArray(c)){if(!o.repeat)throw new TypeError('Expected "'+o.name+'" to not repeat, but got array');if(0===c.length){if(o.optional)continue;throw new TypeError('Expected "'+o.name+'" to not be empty')}for(var u=0;u<c.length;u++){if(i=n(c[u],o),!s[a].test(i))throw new TypeError('Expected all "'+o.name+'" to match "'+o.pattern+'"');t+=(0===u?o.prefix:o.delimiter)+i}}else if("string"!=typeof c&&"number"!=typeof c&&"boolean"!=typeof c){if(!o.optional)throw new TypeError('Expected "'+o.name+'" to be '+(o.repeat?"an array":"a string"));o.partial&&(t+=o.prefix)}else{if(i=n(String(c),o),!s[a].test(i))throw new TypeError('Expected "'+o.name+'" to match "'+o.pattern+'", but got "'+i+'"');t+=o.prefix+i}}else t+=o}return t}}function C(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function v(e){return e&&e.sensitive?"":"i"}function i(e,r,t){for(var n=(t=t||{}).strict,a=!1!==t.end,o=C(t.delimiter||T),i=t.delimiters||P,c=[].concat(t.endsWith||[]).map(C).concat("$").join("|"),u="",l=0===e.length,s=0;s<e.length;s++){var p=e[s];if("string"==typeof p)u+=C(p),l=s===e.length-1&&-1<i.indexOf(p[p.length-1]);else{var f=C(p.prefix),h=p.repeat?"(?:"+p.pattern+")(?:"+f+"(?:"+p.pattern+"))*":p.pattern;r&&r.push(p),p.optional?p.partial?u+=f+"("+h+")?":u+="(?:"+f+"("+h+"))?":u+=f+"("+h+")"}}return a?(n||(u+="(?:"+o+")?"),u+="$"===c?"$":"(?="+c+")"):(n||(u+="(?:"+o+"(?="+c+"))?"),l||(u+="(?="+o+"|"+c+")")),new RegExp("^"+u,v(t))}function c(e,r,t){return e instanceof RegExp?function(e,r){if(!r)return e;var t=e.source.match(/\((?!\?)/g);if(t)for(var n=0;n<t.length;n++)r.push({name:n,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e}(e,r):Array.isArray(e)?function(e,r,t){for(var n=[],a=0;a<e.length;a++)n.push(c(e[a],r,t).source);return new RegExp("(?:"+n.join("|")+")",v(t))}(e,r,t):(n=r,i(o(e,a=t),n,a));var n,a}E.parse=e,E.compile=r,E.tokensToFunction=t,E.tokensToRegExp=n;var x=function(e){return"/"===e.charAt(0)?e:"/"+e},f=function(e){return"/"===e.charAt(0)?e.slice(1):e},w=function(e,r){return("/"===(t=e).charAt(t.length-1)?t:t+"/")+r;var t};function u(e,r){var t=e.name,n=e.params,a=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&(t[n[a]]=e[n[a]])}return t}(e,["name","params"]),o=r.pathname(t,n);return b({pathname:o},a)}function O(e,r,t){var n=e.route,a=e.match,o=a;if(!n.response)return o;var i=n.response({resolved:t,match:a});if(!i)return o;return["status","error","body","data","title","redirectTo"].forEach(function(e){i.hasOwnProperty(e)&&(o[e]="redirectTo"===e?u(i[e],r):i[e])}),o}function l(r,e){if(!e)return r;var t={};for(var n in r){var a=r[n],o=e[n];if(o)try{a=o(a)}catch(e){console.error(e),a=r[n]}t[n]=a}return t}function A(e,r){var t=f(r),n=e.pathMatching.re.exec(t);if(!n)return[];var a=n[0],o=n.slice(1),i={};e.pathMatching.keys.forEach(function(e,r){i[e.name]=o[r]});var c=[{route:e,params:i}];if(!e.children.length)return c;for(var u=t.slice(a.length),l=e.children.length,s=0;s<l;s++){var p=A(e.children[s],u);if(p.length){c=c.concat(p);break}}return 1<c.length||e.pathMatching.mustBeExact&&0===u.length?c:[]}function R(e,r){var t=[],n={},a=e.pop();return e.forEach(function(e){t.push(e.route.public.name),Object.assign(n,l(e.params,e.route.paramParsers))}),Object.assign(n,l(a.params,a.route.paramParsers)),{route:a.route,match:{location:r,name:a.route.public.name,params:n,partials:t}}}var $=function(e){var r=e.name,t=e.path,n=e.pathOptions,a=void 0===n?{}:n,o=e.children,i=void 0===o?[]:o,c=e.response,u=e.on,l=void 0===u?{}:u,s=e.extra,p=e.params,f=null==a.end||a.end,h=[];i.length&&(a.end=!1,h=i.map($));var v,m,d,g=[],y=E(t,g,a);return{public:{name:r,path:t,keys:g.map(function(e){return e.name}),on:{initial:l.initial&&(v=l.initial,d=!1,function(){return d||(m=v(),d=!0),m}),every:l.every},extra:s},pathMatching:{re:y,keys:g,mustBeExact:f},sync:!(l.initial||l.every),response:c,children:h,paramParsers:p}};return function(l,e,t){void 0===t&&(t={});var r=t.route,i=void 0===r?[]:r,n=t.sideEffects,a=void 0===n?[]:n,o=t.emitRedirects,c=void 0===o||o,u=a.reduce(function(e,r){return r.after?e.after.push(r.effect):e.before.push(r.effect),e},{before:[],after:[]}),s=[],p={};function f(e){for(var r in s=e.map($),p)delete p[r];var n,o,a;i.concat((n=t.pathnameOptions,o={},a={},{name:"pathname",register:function(e,r){var t,n=e.name,a=e.path;return void 0!==o[n]&&console.warn('A route with the name "'+n+'" 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.'),r&&o[r]&&(t=o[r]),o[n]=t?w(t,a):a,n},get:function(e,r){if(null!=o[e]){var t=a[e]?a[e]:a[e]=E.compile(o[e]);return x(t(r,n))}console.error("Could not generate pathname for "+e+" because it is not registered.")},reset:function(){o={},a={}}})).forEach(function(e){e.reset(),p[e.name]=e.get,function t(e,n,a){e.forEach(function(e){var r=n.register(e.public,a);t(e.children,n,r)})}(s,e)})}var h,v=[],m=[],d={response:null,navigation:null};function g(e,r){h=void 0,e.redirectTo&&!c||function(e,r){var t={response:d.response=e,navigation:d.navigation=r,router:y};for(u.before.forEach(function(e){e(t)}),v.forEach(function(e){null!=e&&e(t)});m.length;){var n=m.pop();n&&n(t)}u.after.forEach(function(e){e(t)})}(e,r),void 0!==e.redirectTo&&l.navigate(e.redirectTo,"REPLACE")}var y={route:p,history:l,respond:function(e,r){var t=r||{},n=t.observe,a=void 0!==n&&n,o=t.initial,i=void 0===o||o;if(a){var c=v.push(e);return d.response&&i&&e.call(null,b({},d,{router:y})),function(){v[c-1]=null}}d.response&&i?e.call(null,b({},d,{router:y})):m.push(e)},replaceRoutes:f,current:function(){return d},navigate:function(e){var r=e.name,t=e.params,n=e.hash,a=e.query,o=e.state,i=e.method,c=void 0===i?"ANCHOR":i,u=null!=r?p.pathname(r,t):l.location.pathname;"ANCHOR"!==c&&"PUSH"!==c&&"REPLACE"!==c&&(c="ANCHOR"),l.navigate({pathname:u,hash:n,query:a,state:o},c)}};return f(e),l.respondWith(function(r){h&&(h.cancel(r.action),h.cancelled=!0);var t={action:(h=r).action,previous:d.response},n=function(e,r){for(var t=r.length,n=0;n<t;n++){var a=A(r[n],e.pathname);if(a.length)return R(a,e)}return{route:void 0,match:void 0}}(r.location,s);if(!n.route)return console.error("The current location ("+r.location.pathname+') has no matching route, so a response could not be emitted. A catch-all route ({ path: "(.*)" }) can be used to match locations with no other matching route.'),void r.finish();n.route.sync?(r.finish(),g(O(n,p,null),t)):function(e){e.match;var r=e.route.public.on;return Promise.all([r.initial&&r.initial(e.match),r.every&&r.every(e.match)]).then(function(e){return{error:null,initial:e[0],every:e[1]}},function(e){return{error:e,initial:null,every:null}})}(n).then(function(e){r.cancelled||(r.finish(),g(O(n,p,e),t))})}),y}}(); | ||
var Curi=function(){"use strict";var b=Object.assign||function(e){for(var r,t=1,n=arguments.length;t<n;t++)for(var a in r=arguments[t])Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a]);return e};var E=c,e=o,r=function(e,r){return a(o(e,r))},t=a,n=i,T="/",P="./",j=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");function o(e,r){for(var t,n,a=[],o=0,i=0,c="",u=r&&r.delimiter||T,l=r&&r.delimiters||P,s=!1;null!==(t=j.exec(e));){var p=t[0],f=t[1],h=t.index;if(c+=e.slice(i,h),i=h+p.length,f)c+=f[1],s=!0;else{var v="",m=e[i],d=t[2],g=t[3],y=t[4],b=t[5];if(!s&&c.length){var E=c.length-1;-1<l.indexOf(c[E])&&(v=c[E],c=c.slice(0,E))}c&&(a.push(c),c="",s=!1);var x=""!==v&&void 0!==m&&m!==v,w="+"===b||"*"===b,O="?"===b||"*"===b,A=v||u,R=g||y;a.push({name:d||o++,prefix:v,delimiter:A,optional:O,repeat:w,partial:x,pattern:R?(n=R,n.replace(/([=!:$/()])/g,"\\$1")):"[^"+C(A)+"]+?"})}}return(c||i<e.length)&&a.push(c+e.substr(i)),a}function a(l){for(var s=new Array(l.length),e=0;e<l.length;e++)"object"==typeof l[e]&&(s[e]=new RegExp("^(?:"+l[e].pattern+")$"));return function(e,r){for(var t="",n=r&&r.encode||encodeURIComponent,a=0;a<l.length;a++){var o=l[a];if("string"!=typeof o){var i,c=e?e[o.name]:void 0;if(Array.isArray(c)){if(!o.repeat)throw new TypeError('Expected "'+o.name+'" to not repeat, but got array');if(0===c.length){if(o.optional)continue;throw new TypeError('Expected "'+o.name+'" to not be empty')}for(var u=0;u<c.length;u++){if(i=n(c[u],o),!s[a].test(i))throw new TypeError('Expected all "'+o.name+'" to match "'+o.pattern+'"');t+=(0===u?o.prefix:o.delimiter)+i}}else if("string"!=typeof c&&"number"!=typeof c&&"boolean"!=typeof c){if(!o.optional)throw new TypeError('Expected "'+o.name+'" to be '+(o.repeat?"an array":"a string"));o.partial&&(t+=o.prefix)}else{if(i=n(String(c),o),!s[a].test(i))throw new TypeError('Expected "'+o.name+'" to match "'+o.pattern+'", but got "'+i+'"');t+=o.prefix+i}}else t+=o}return t}}function C(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function v(e){return e&&e.sensitive?"":"i"}function i(e,r,t){for(var n=(t=t||{}).strict,a=!1!==t.end,o=C(t.delimiter||T),i=t.delimiters||P,c=[].concat(t.endsWith||[]).map(C).concat("$").join("|"),u="",l=0===e.length,s=0;s<e.length;s++){var p=e[s];if("string"==typeof p)u+=C(p),l=s===e.length-1&&-1<i.indexOf(p[p.length-1]);else{var f=C(p.prefix),h=p.repeat?"(?:"+p.pattern+")(?:"+f+"(?:"+p.pattern+"))*":p.pattern;r&&r.push(p),p.optional?p.partial?u+=f+"("+h+")?":u+="(?:"+f+"("+h+"))?":u+=f+"("+h+")"}}return a?(n||(u+="(?:"+o+")?"),u+="$"===c?"$":"(?="+c+")"):(n||(u+="(?:"+o+"(?="+c+"))?"),l||(u+="(?="+o+"|"+c+")")),new RegExp("^"+u,v(t))}function c(e,r,t){return e instanceof RegExp?function(e,r){if(!r)return e;var t=e.source.match(/\((?!\?)/g);if(t)for(var n=0;n<t.length;n++)r.push({name:n,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e}(e,r):Array.isArray(e)?function(e,r,t){for(var n=[],a=0;a<e.length;a++)n.push(c(e[a],r,t).source);return new RegExp("(?:"+n.join("|")+")",v(t))}(e,r,t):(n=r,i(o(e,a=t),n,a));var n,a}E.parse=e,E.compile=r,E.tokensToFunction=t,E.tokensToRegExp=n;var x=function(e){return"/"===e.charAt(0)?e:"/"+e},f=function(e){return"/"===e.charAt(0)?e.slice(1):e},w=function(e,r){return("/"===(t=e).charAt(t.length-1)?t:t+"/")+r;var t};function u(e,r){var t=e.name,n=e.params,a=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&(t[n[a]]=e[n[a]])}return t}(e,["name","params"]),o=r.pathname(t,n);return b({pathname:o},a)}function O(e,r,t){var n=e.route,a=e.match,o=a;if(!n.response)return o;var i=n.response({resolved:t,match:a});if(!i)return o;return["status","error","body","data","title","redirectTo"].forEach(function(e){i.hasOwnProperty(e)&&(o[e]="redirectTo"===e?u(i[e],r):i[e])}),o}function l(r,e){if(!e)return r;var t={};for(var n in r){var a=r[n],o=e[n];if(o)try{a=o(a)}catch(e){console.error(e),a=r[n]}t[n]=a}return t}function A(e,r){var t=f(r),n=e.pathMatching.re.exec(t);if(!n)return[];var a=n[0],o=n.slice(1),i={};e.pathMatching.keys.forEach(function(e,r){i[e.name]=o[r]});var c=[{route:e,params:i}];if(!e.children.length)return c;for(var u=t.slice(a.length),l=e.children.length,s=0;s<l;s++){var p=A(e.children[s],u);if(p.length){c=c.concat(p);break}}return 1<c.length||e.pathMatching.mustBeExact&&0===u.length?c:[]}function R(e,r){var t=[],n={},a=e.pop();return e.forEach(function(e){t.push(e.route.public.name),Object.assign(n,l(e.params,e.route.paramParsers))}),Object.assign(n,l(a.params,a.route.paramParsers)),{route:a.route,match:{location:r,name:a.route.public.name,params:n,partials:t}}}var $=function(e){var r=e.name,t=e.path,n=e.pathOptions,a=void 0===n?{}:n,o=e.children,i=void 0===o?[]:o,c=e.response,u=e.on,l=void 0===u?{}:u,s=e.extra,p=e.params,f=null==a.end||a.end,h=[];i.length&&(a.end=!1,h=i.map($));var v,m,d,g=[],y=E(t,g,a);return{public:{name:r,path:t,keys:g.map(function(e){return e.name}),on:{initial:l.initial&&(v=l.initial,d=!1,function(){return d||(m=v.apply(null,arguments),d=!0),m}),every:l.every},extra:s},pathMatching:{re:y,keys:g,mustBeExact:f},sync:!(l.initial||l.every),response:c,children:h,paramParsers:p}};return function(l,e,t){void 0===t&&(t={});var r=t.route,i=void 0===r?[]:r,n=t.sideEffects,a=void 0===n?[]:n,o=t.emitRedirects,c=void 0===o||o,u=a.reduce(function(e,r){return r.after?e.after.push(r.effect):e.before.push(r.effect),e},{before:[],after:[]}),s=[],p={};function f(e){for(var r in s=e.map($),p)delete p[r];var n,o,a;i.concat((n=t.pathnameOptions,o={},a={},{name:"pathname",register:function(e,r){var t,n=e.name,a=e.path;return void 0!==o[n]&&console.warn('A route with the name "'+n+'" 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.'),r&&o[r]&&(t=o[r]),o[n]=t?w(t,a):a,n},get:function(e,r){if(null!=o[e]){var t=a[e]?a[e]:a[e]=E.compile(o[e]);return x(t(r,n))}console.error("Could not generate pathname for "+e+" because it is not registered.")},reset:function(){o={},a={}}})).forEach(function(e){e.reset(),p[e.name]=e.get,function t(e,n,a){e.forEach(function(e){var r=n.register(e.public,a);t(e.children,n,r)})}(s,e)})}var h,v=[],m=[],d={response:null,navigation:null};function g(e,r){h=void 0,e.redirectTo&&!c||function(e,r){var t={response:d.response=e,navigation:d.navigation=r,router:y};for(u.before.forEach(function(e){e(t)}),v.forEach(function(e){null!=e&&e(t)});m.length;){var n=m.pop();n&&n(t)}u.after.forEach(function(e){e(t)})}(e,r),void 0!==e.redirectTo&&l.navigate(e.redirectTo,"REPLACE")}var y={route:p,history:l,respond:function(e,r){var t=r||{},n=t.observe,a=void 0!==n&&n,o=t.initial,i=void 0===o||o;if(a){var c=v.push(e);return d.response&&i&&e.call(null,b({},d,{router:y})),function(){v[c-1]=null}}d.response&&i?e.call(null,b({},d,{router:y})):m.push(e)},replaceRoutes:f,current:function(){return d},navigate:function(e){var r=e.name,t=e.params,n=e.hash,a=e.query,o=e.state,i=e.method,c=void 0===i?"ANCHOR":i,u=null!=r?p.pathname(r,t):l.location.pathname;"ANCHOR"!==c&&"PUSH"!==c&&"REPLACE"!==c&&(c="ANCHOR"),l.navigate({pathname:u,hash:n,query:a,state:o},c)}};return f(e),l.respondWith(function(r){h&&(h.cancel(r.action),h.cancelled=!0);var t={action:(h=r).action,previous:d.response},n=function(e,r){for(var t=r.length,n=0;n<t;n++){var a=A(r[n],e.pathname);if(a.length)return R(a,e)}return{route:void 0,match:void 0}}(r.location,s);if(!n.route)return console.error("The current location ("+r.location.pathname+') has no matching route, so a response could not be emitted. A catch-all route ({ path: "(.*)" }) can be used to match locations with no other matching route.'),void r.finish();n.route.sync?(r.finish(),g(O(n,p,null),t)):function(e){e.match;var r=e.route.public.on;return Promise.all([r.initial&&r.initial(e.match),r.every&&r.every(e.match)]).then(function(e){return{error:null,initial:e[0],every:e[1]}},function(e){return{error:e,initial:null,every:null}})}(n).then(function(e){r.cancelled||(r.finish(),g(O(n,p,e),t))})}),y}}(); |
{ | ||
"name": "@curi/core", | ||
"version": "1.0.0-beta.33", | ||
"version": "1.0.0-beta.34", | ||
"description": "A JavaScript router that doesn't care how you render", | ||
@@ -5,0 +5,0 @@ "main": "dist/curi-core.common.js", |
@@ -1,1 +0,1 @@ | ||
export default function once(fn: () => Promise<any>): () => Promise<any>; | ||
export default function once(fn: (...args: Array<any>) => Promise<any>): () => Promise<any>; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92213