@curi/core
Advanced tools
Comparing version 1.0.0-beta.16 to 1.0.0-beta.17
@@ -0,1 +1,5 @@ | ||
## 1.0.0-beta.17 | ||
* Make the second argument to `config.subscribe` an options object. There is now a `once` option. When `once` is `true`, the "subscriber" will only be called one time. Calling `config.subscribe` when `{ once: true }` will **not** return an unsubscribe function. The `initial` argument has been removed. | ||
## 1.0.0-beta.16 | ||
@@ -5,3 +9,3 @@ | ||
* When `route.load` or `route.preload` has an uncaught error, the error will be set as the response's `error` property. Previously, Curi wouldn't emit a response. The user should still make sure to catch errors themselves, but at least now it should be more obvious what is happening. | ||
* Add `initial` argument to `subscribe`. When `false` (default), the subscriber will not be called initially; when `true`, the subscriber will be immediately called. The default allows us to remove `ready` since the subscriber will not be called until a response has been resolved. | ||
* ~~Add `initial` argument to `subscribe`. When `false` (default), the subscriber will not be called initially; when `true`, the subscriber will be immediately called. The default allows us to remove `ready` since the subscriber will not be called until a response has been resolved.~~ | ||
* Remove `ready` function. | ||
@@ -8,0 +12,0 @@ |
@@ -279,8 +279,2 @@ 'use strict'; | ||
var registeredAddons = {}; | ||
var subscribers = []; | ||
// This is the response generated for the previous navigation | ||
// and the action type of the navigation. These will be passed | ||
// to config.subscribe on their initial call. | ||
var previous = []; | ||
var currentResponse; | ||
// add the pathname addon to the provided addons | ||
@@ -313,2 +307,30 @@ var allAddons = userAddons.concat(createPathnameAddon(pathnameOptions)); | ||
} | ||
var subscribers = []; | ||
var oneTimers = []; | ||
var previous = []; | ||
function subscribe(fn, options) { | ||
if (typeof fn !== 'function') { | ||
throw new Error('The argument passed to subscribe must be a function'); | ||
} | ||
var _a = (options || {}).once, once = _a === void 0 ? false : _a; | ||
if (once) { | ||
if (previous.length) { | ||
fn.apply(null, previous); | ||
} | ||
else { | ||
oneTimers.push(fn); | ||
} | ||
} | ||
else { | ||
// Always call subscriber immediately if a previous | ||
// response/action exists. | ||
if (previous.length) { | ||
fn.apply(null, previous); | ||
} | ||
var newLength_1 = subscribers.push(fn); | ||
return function () { | ||
subscribers[newLength_1 - 1] = null; | ||
}; | ||
} | ||
} | ||
function emit(response, action) { | ||
@@ -318,2 +340,6 @@ beforeSideEffects.forEach(function (fn) { | ||
}); | ||
while (oneTimers.length) { | ||
var fn = oneTimers.pop(); | ||
fn(response, action); | ||
} | ||
subscribers.forEach(function (fn) { | ||
@@ -335,3 +361,3 @@ if (fn != null) { | ||
activeResponse = pending; | ||
currentResponse = getResponse(pending.location).then(function (response) { | ||
getResponse(pending.location).then(function (response) { | ||
if (pending.cancelled) { | ||
@@ -356,14 +382,3 @@ return; | ||
history: history, | ||
subscribe: function (fn, initial) { | ||
if (typeof fn !== 'function') { | ||
throw new Error('The argument passed to subscribe must be a function'); | ||
} | ||
if (initial) { | ||
fn.apply(null, previous); | ||
} | ||
var newLength = subscribers.push(fn); | ||
return function () { | ||
subscribers[newLength - 1] = null; | ||
}; | ||
}, | ||
subscribe: subscribe, | ||
refresh: setupRoutesAndAddons | ||
@@ -370,0 +385,0 @@ }; |
@@ -275,8 +275,2 @@ import PathToRegexp from 'path-to-regexp'; | ||
var registeredAddons = {}; | ||
var subscribers = []; | ||
// This is the response generated for the previous navigation | ||
// and the action type of the navigation. These will be passed | ||
// to config.subscribe on their initial call. | ||
var previous = []; | ||
var currentResponse; | ||
// add the pathname addon to the provided addons | ||
@@ -309,2 +303,30 @@ var allAddons = userAddons.concat(createPathnameAddon(pathnameOptions)); | ||
} | ||
var subscribers = []; | ||
var oneTimers = []; | ||
var previous = []; | ||
function subscribe(fn, options) { | ||
if (typeof fn !== 'function') { | ||
throw new Error('The argument passed to subscribe must be a function'); | ||
} | ||
var _a = (options || {}).once, once = _a === void 0 ? false : _a; | ||
if (once) { | ||
if (previous.length) { | ||
fn.apply(null, previous); | ||
} | ||
else { | ||
oneTimers.push(fn); | ||
} | ||
} | ||
else { | ||
// Always call subscriber immediately if a previous | ||
// response/action exists. | ||
if (previous.length) { | ||
fn.apply(null, previous); | ||
} | ||
var newLength_1 = subscribers.push(fn); | ||
return function () { | ||
subscribers[newLength_1 - 1] = null; | ||
}; | ||
} | ||
} | ||
function emit(response, action) { | ||
@@ -314,2 +336,6 @@ beforeSideEffects.forEach(function (fn) { | ||
}); | ||
while (oneTimers.length) { | ||
var fn = oneTimers.pop(); | ||
fn(response, action); | ||
} | ||
subscribers.forEach(function (fn) { | ||
@@ -331,3 +357,3 @@ if (fn != null) { | ||
activeResponse = pending; | ||
currentResponse = getResponse(pending.location).then(function (response) { | ||
getResponse(pending.location).then(function (response) { | ||
if (pending.cancelled) { | ||
@@ -352,14 +378,3 @@ return; | ||
history: history, | ||
subscribe: function (fn, initial) { | ||
if (typeof fn !== 'function') { | ||
throw new Error('The argument passed to subscribe must be a function'); | ||
} | ||
if (initial) { | ||
fn.apply(null, previous); | ||
} | ||
var newLength = subscribers.push(fn); | ||
return function () { | ||
subscribers[newLength - 1] = null; | ||
}; | ||
}, | ||
subscribe: subscribe, | ||
refresh: setupRoutesAndAddons | ||
@@ -366,0 +381,0 @@ }; |
@@ -653,8 +653,2 @@ var Curi = (function () { | ||
var registeredAddons = {}; | ||
var subscribers = []; | ||
// This is the response generated for the previous navigation | ||
// and the action type of the navigation. These will be passed | ||
// to config.subscribe on their initial call. | ||
var previous = []; | ||
var currentResponse; | ||
// add the pathname addon to the provided addons | ||
@@ -687,2 +681,30 @@ var allAddons = userAddons.concat(createPathnameAddon(pathnameOptions)); | ||
} | ||
var subscribers = []; | ||
var oneTimers = []; | ||
var previous = []; | ||
function subscribe(fn, options) { | ||
if (typeof fn !== 'function') { | ||
throw new Error('The argument passed to subscribe must be a function'); | ||
} | ||
var _a = (options || {}).once, once = _a === void 0 ? false : _a; | ||
if (once) { | ||
if (previous.length) { | ||
fn.apply(null, previous); | ||
} | ||
else { | ||
oneTimers.push(fn); | ||
} | ||
} | ||
else { | ||
// Always call subscriber immediately if a previous | ||
// response/action exists. | ||
if (previous.length) { | ||
fn.apply(null, previous); | ||
} | ||
var newLength_1 = subscribers.push(fn); | ||
return function () { | ||
subscribers[newLength_1 - 1] = null; | ||
}; | ||
} | ||
} | ||
function emit(response, action) { | ||
@@ -692,2 +714,6 @@ beforeSideEffects.forEach(function (fn) { | ||
}); | ||
while (oneTimers.length) { | ||
var fn = oneTimers.pop(); | ||
fn(response, action); | ||
} | ||
subscribers.forEach(function (fn) { | ||
@@ -709,3 +735,3 @@ if (fn != null) { | ||
activeResponse = pending; | ||
currentResponse = getResponse(pending.location).then(function (response) { | ||
getResponse(pending.location).then(function (response) { | ||
if (pending.cancelled) { | ||
@@ -730,14 +756,3 @@ return; | ||
history: history, | ||
subscribe: function (fn, initial) { | ||
if (typeof fn !== 'function') { | ||
throw new Error('The argument passed to subscribe must be a function'); | ||
} | ||
if (initial) { | ||
fn.apply(null, previous); | ||
} | ||
var newLength = subscribers.push(fn); | ||
return function () { | ||
subscribers[newLength - 1] = null; | ||
}; | ||
}, | ||
subscribe: subscribe, | ||
refresh: setupRoutesAndAddons | ||
@@ -744,0 +759,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
var Curi=function(){"use strict";function e(n,r,t){n.forEach(function(n){var a=r.register(n.public,t);e(n.children,r,a)})}function n(e,n){for(var r,o=[],i=0,u=0,c="",l=n&&n.delimiter||k,s=n&&n.delimiters||$,f=!1;null!==(r=j.exec(e));){var p=r[0],h=r[1],d=r.index;if(c+=e.slice(u,d),u=d+p.length,h)c+=h[1],f=!0;else{var m="",v=e[u],g=r[2],y=r[3],b=r[4],x=r[5];if(!f&&c.length){var E=c.length-1;s.indexOf(c[E])>-1&&(m=c[E],c=c.slice(0,E))}c&&(o.push(c),c="",f=!1);var w=""!==m&&void 0!==v&&v!==m,T="+"===x||"*"===x,A="?"===x||"*"===x,P=m||l,O=y||b;o.push({name:g||i++,prefix:m,delimiter:P,optional:A,repeat:T,partial:w,pattern:O?a(O):"[^"+t(P)+"]+?"})}}return(c||u<e.length)&&o.push(c+e.substr(u)),o}function r(e){for(var n=new Array(e.length),r=0;r<e.length;r++)"object"==typeof e[r]&&(n[r]=new RegExp("^(?:"+e[r].pattern+")$"));return function(r,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,l=r?r[u.name]:void 0;if(Array.isArray(l)){if(!u.repeat)throw new TypeError('Expected "'+u.name+'" to not repeat, but got array');if(0===l.length){if(u.optional)continue;throw new TypeError('Expected "'+u.name+'" to not be empty')}for(var s=0;s<l.length;s++){if(c=o(l[s]),!n[i].test(c))throw new TypeError('Expected all "'+u.name+'" to match "'+u.pattern+'"');a+=(0===s?u.prefix:u.delimiter)+c}}else if("string"!=typeof l&&"number"!=typeof l&&"boolean"!=typeof l){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(l)),!n[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,n){if(!n)return e;var r=e.source.match(/\((?!\?)/g);if(r)for(var t=0;t<r.length;t++)n.push({name:t,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e}function u(e,n,r){for(var t=[],a=0;a<e.length;a++)t.push(s(e[a],n,r).source);return new RegExp("(?:"+t.join("|")+")",o(r))}function c(e,r,t){return l(n(e,t),r,t)}function l(e,n,r){for(var a=(r=r||{}).strict,i=!1!==r.end,u=t(r.delimiter||k),c=r.delimiters||$,l=[].concat(r.endsWith||[]).map(t).concat("$").join("|"),s="",f=!1,p=0;p<e.length;p++){var h=e[p];if("string"==typeof h)s+=t(h),f=p===e.length-1&&c.indexOf(h[h.length-1])>-1;else{var d=t(h.prefix),m=h.repeat?"(?:"+h.pattern+")(?:"+d+"(?:"+h.pattern+"))*":h.pattern;n&&n.push(h),h.optional?h.partial?s+=d+"("+m+")?":s+="(?:"+d+"("+m+"))?":s+=d+"("+m+")"}}return i?(a||(s+="(?:"+u+")?"),s+="$"===l?"$":"(?="+l+")"):(a||(s+="(?:"+u+"(?="+l+"))?"),f||(s+="(?="+u+"|"+l+")")),new RegExp("^"+s,o(r))}function s(e,n,r){return e instanceof RegExp?i(e,n):Array.isArray(e)?u(e,n,r):c(e,n,r)}function f(e){var n={},r={};return{name:"pathname",register:function(e,r){var t=e.name,a=e.path;void 0!==n[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 o;return r&&n[r]&&(o=n[r]),n[t]=o?C(o,a):a,t},get:function(t,a){if(null!=n[t]){var o=r[t]?r[t]:r[t]=w.compile(n[t]);return O(o(a,e))}console.error("Could not generate pathname for "+t+" because it is not registered.")},reset:function(){n={},r={}}}}function p(e,n,r,t){var a=R(n),o=e.match,i=o.re,u=o.keys,c=o.mustBeExact,l=e.children,s=i.exec(a);if(!s)return!1;var f=s[0],h=s.slice(1),d={};u.forEach(function(e,n){d[e.name]=h[n]});var m=null!=t?C(t,f):O(f);if(r.push({route:e,params:d}),!l||!l.length)return!0;var v=a.slice(f.length),g=!!v.length,y=l.some(function(e){return p(e,v,r,m)});return!(c&&g&&!y)||(r.pop(),!1)}function h(e,n){if(!n)return e;var r={};for(var t in e){var a=e[t],o=n[t];if(o)try{a=o(a)}catch(n){console.error(n),a=e[t]}r[t]=a}return r}function d(e,n,r){var t,a=[],o=[],i={};if(n.some(function(n){return p(n,e.pathname,a)}),a.length){var u=a.pop();a.forEach(function(e){o.push(e.route.public.name),Object.assign(i,h(e.params,e.route.paramParsers))}),t=u.route,Object.assign(i,h(u.params,t.paramParsers))}return m(t,{location:e,params:i,partials:o,status:null!=t?200:404,data:void 0},r).then(function(e){return b(t,e)})}function m(e,n,r){return e?Promise.all([e.public.preload?e.public.preload():null,e.public.load?e.public.load(g(e,n),v(n),r):null]).then(function(){return n},function(e){return n.error=e,n}):Promise.resolve(n)}function v(e){return{redirect:function(n,r){void 0===r&&(r=301),e.status=r,e.redirectTo=n},fail:function(n){e.error=n},setStatus:function(n){e.status=n},setData:function(n){e.data=n}}}function g(e,n){return{params:n.params,location:n.location,name:e.public.name}}function y(){return{body:void 0,title:""}}function b(e,n){var r=Object.assign({},n,{key:n.location.key},e?e.responseProps(n):y());return Promise.resolve(r)}function x(e){var n=null,r=!1;return function(){return r?n:(n=e(),r=!0,n)}}function E(e,n){return e?"function"==typeof e?e(n.params,n.data):e:""}var w=s,T=n,A=r,P=l,k="/",$="./",j=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");w.parse=T,w.compile=function(e,t){return r(n(e,t))},w.tokensToFunction=A,w.tokensToRegExp=P;var O=function(e){return"/"===e.charAt(0)?e:"/"+e},R=function(e){return"/"===e.charAt(0)?e.slice(1):e},B=function(e){return"/"===e.charAt(e.length-1)?e:e+"/"},C=function(e,n){return B(e)+n},S=function(e){var n=e.name,r=e.path,t=e.pathOptions,a=void 0===t?{}:t,o=e.body,i=e.children,u=void 0===i?[]:i,c=e.preload,l=e.load,s=e.title,f=e.extra,p=e.params,h=null==a.end||a.end,d=[];u.length&&(a.end=!1,d=u.map(S));var m=[],v=w(r,m,a);return{public:{name:n,path:r,body:o,keys:m.map(function(e){return e.name}),preload:c&&x(c),load:l,extra:f},match:{re:v,keys:m,mustBeExact:h},children:d,paramParsers:p,responseProps:function(e){return{name:n,body:this.public.body&&this.public.body(),title:E(s,e)}}}};return function(n,r,t){function a(n){x=n.map(S);for(var r in E)delete E[r];A.forEach(function(n){n.reset(),E[n.name]=n.get,e(x,n)})}function o(e){if(h){var n=h.get(e);if(null!=n)return Promise.resolve(n)}return d(e,x,E).then(function(e){return h&&h.set(e),e})}function i(e,n){v.forEach(function(r){r(e,n)}),w.forEach(function(r){null!=r&&r(e,n)}),g.forEach(function(r){r(e,n)})}void 0===t&&(t={});var u=t,c=u.addons,l=void 0===c?[]:c,s=u.sideEffects,p=void 0===s?[]:s,h=u.cache,m=u.pathnameOptions,v=[],g=[];p.forEach(function(e){e.after?g.push(e.fn):v.push(e.fn)});var y,b,x=[],E={},w=[],T=[],A=l.concat(f(m));return a(r),n.respondWith(function(e){b&&(b.cancel(e.action),b.cancelled=!0),b=e,y=o(e.location).then(function(r){if(!e.cancelled)return e.finish(),b=void 0,i(r,e.action),T=[r,e.action],r.redirectTo&&n.replace(r.redirectTo),r})}),{addons:E,history:n,subscribe:function(e,n){if("function"!=typeof e)throw new Error("The argument passed to subscribe must be a function");n&&e.apply(null,T);var r=w.push(e);return function(){w[r-1]=null}},refresh:a}}}(); | ||
var Curi=function(){"use strict";function e(n,r,t){n.forEach(function(n){var a=r.register(n.public,t);e(n.children,r,a)})}function n(e,n){for(var r,o=[],i=0,u=0,c="",l=n&&n.delimiter||k,f=n&&n.delimiters||$,p=!1;null!==(r=j.exec(e));){var s=r[0],h=r[1],d=r.index;if(c+=e.slice(u,d),u=d+s.length,h)c+=h[1],p=!0;else{var m="",v=e[u],g=r[2],y=r[3],b=r[4],x=r[5];if(!p&&c.length){var E=c.length-1;f.indexOf(c[E])>-1&&(m=c[E],c=c.slice(0,E))}c&&(o.push(c),c="",p=!1);var w=""!==m&&void 0!==v&&v!==m,T="+"===x||"*"===x,A="?"===x||"*"===x,P=m||l,O=y||b;o.push({name:g||i++,prefix:m,delimiter:P,optional:A,repeat:T,partial:w,pattern:O?a(O):"[^"+t(P)+"]+?"})}}return(c||u<e.length)&&o.push(c+e.substr(u)),o}function r(e){for(var n=new Array(e.length),r=0;r<e.length;r++)"object"==typeof e[r]&&(n[r]=new RegExp("^(?:"+e[r].pattern+")$"));return function(r,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,l=r?r[u.name]:void 0;if(Array.isArray(l)){if(!u.repeat)throw new TypeError('Expected "'+u.name+'" to not repeat, but got array');if(0===l.length){if(u.optional)continue;throw new TypeError('Expected "'+u.name+'" to not be empty')}for(var f=0;f<l.length;f++){if(c=o(l[f]),!n[i].test(c))throw new TypeError('Expected all "'+u.name+'" to match "'+u.pattern+'"');a+=(0===f?u.prefix:u.delimiter)+c}}else if("string"!=typeof l&&"number"!=typeof l&&"boolean"!=typeof l){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(l)),!n[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,n){if(!n)return e;var r=e.source.match(/\((?!\?)/g);if(r)for(var t=0;t<r.length;t++)n.push({name:t,prefix:null,delimiter:null,optional:!1,repeat:!1,partial:!1,pattern:null});return e}function u(e,n,r){for(var t=[],a=0;a<e.length;a++)t.push(f(e[a],n,r).source);return new RegExp("(?:"+t.join("|")+")",o(r))}function c(e,r,t){return l(n(e,t),r,t)}function l(e,n,r){for(var a=(r=r||{}).strict,i=!1!==r.end,u=t(r.delimiter||k),c=r.delimiters||$,l=[].concat(r.endsWith||[]).map(t).concat("$").join("|"),f="",p=!1,s=0;s<e.length;s++){var h=e[s];if("string"==typeof h)f+=t(h),p=s===e.length-1&&c.indexOf(h[h.length-1])>-1;else{var d=t(h.prefix),m=h.repeat?"(?:"+h.pattern+")(?:"+d+"(?:"+h.pattern+"))*":h.pattern;n&&n.push(h),h.optional?h.partial?f+=d+"("+m+")?":f+="(?:"+d+"("+m+"))?":f+=d+"("+m+")"}}return i?(a||(f+="(?:"+u+")?"),f+="$"===l?"$":"(?="+l+")"):(a||(f+="(?:"+u+"(?="+l+"))?"),p||(f+="(?="+u+"|"+l+")")),new RegExp("^"+f,o(r))}function f(e,n,r){return e instanceof RegExp?i(e,n):Array.isArray(e)?u(e,n,r):c(e,n,r)}function p(e){var n={},r={};return{name:"pathname",register:function(e,r){var t=e.name,a=e.path;void 0!==n[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 o;return r&&n[r]&&(o=n[r]),n[t]=o?C(o,a):a,t},get:function(t,a){if(null!=n[t]){var o=r[t]?r[t]:r[t]=w.compile(n[t]);return O(o(a,e))}console.error("Could not generate pathname for "+t+" because it is not registered.")},reset:function(){n={},r={}}}}function s(e,n,r,t){var a=R(n),o=e.match,i=o.re,u=o.keys,c=o.mustBeExact,l=e.children,f=i.exec(a);if(!f)return!1;var p=f[0],h=f.slice(1),d={};u.forEach(function(e,n){d[e.name]=h[n]});var m=null!=t?C(t,p):O(p);if(r.push({route:e,params:d}),!l||!l.length)return!0;var v=a.slice(p.length),g=!!v.length,y=l.some(function(e){return s(e,v,r,m)});return!(c&&g&&!y)||(r.pop(),!1)}function h(e,n){if(!n)return e;var r={};for(var t in e){var a=e[t],o=n[t];if(o)try{a=o(a)}catch(n){console.error(n),a=e[t]}r[t]=a}return r}function d(e,n,r){var t,a=[],o=[],i={};if(n.some(function(n){return s(n,e.pathname,a)}),a.length){var u=a.pop();a.forEach(function(e){o.push(e.route.public.name),Object.assign(i,h(e.params,e.route.paramParsers))}),t=u.route,Object.assign(i,h(u.params,t.paramParsers))}return m(t,{location:e,params:i,partials:o,status:null!=t?200:404,data:void 0},r).then(function(e){return b(t,e)})}function m(e,n,r){return e?Promise.all([e.public.preload?e.public.preload():null,e.public.load?e.public.load(g(e,n),v(n),r):null]).then(function(){return n},function(e){return n.error=e,n}):Promise.resolve(n)}function v(e){return{redirect:function(n,r){void 0===r&&(r=301),e.status=r,e.redirectTo=n},fail:function(n){e.error=n},setStatus:function(n){e.status=n},setData:function(n){e.data=n}}}function g(e,n){return{params:n.params,location:n.location,name:e.public.name}}function y(){return{body:void 0,title:""}}function b(e,n){var r=Object.assign({},n,{key:n.location.key},e?e.responseProps(n):y());return Promise.resolve(r)}function x(e){var n=null,r=!1;return function(){return r?n:(n=e(),r=!0,n)}}function E(e,n){return e?"function"==typeof e?e(n.params,n.data):e:""}var w=f,T=n,A=r,P=l,k="/",$="./",j=new RegExp(["(\\\\.)","(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?"].join("|"),"g");w.parse=T,w.compile=function(e,t){return r(n(e,t))},w.tokensToFunction=A,w.tokensToRegExp=P;var O=function(e){return"/"===e.charAt(0)?e:"/"+e},R=function(e){return"/"===e.charAt(0)?e.slice(1):e},B=function(e){return"/"===e.charAt(e.length-1)?e:e+"/"},C=function(e,n){return B(e)+n},S=function(e){var n=e.name,r=e.path,t=e.pathOptions,a=void 0===t?{}:t,o=e.body,i=e.children,u=void 0===i?[]:i,c=e.preload,l=e.load,f=e.title,p=e.extra,s=e.params,h=null==a.end||a.end,d=[];u.length&&(a.end=!1,d=u.map(S));var m=[],v=w(r,m,a);return{public:{name:n,path:r,body:o,keys:m.map(function(e){return e.name}),preload:c&&x(c),load:l,extra:p},match:{re:v,keys:m,mustBeExact:h},children:d,paramParsers:s,responseProps:function(e){return{name:n,body:this.public.body&&this.public.body(),title:E(f,e)}}}};return function(n,r,t){function a(n){b=n.map(S);for(var r in x)delete x[r];E.forEach(function(n){n.reset(),x[n.name]=n.get,e(b,n)})}function o(e){if(h){var n=h.get(e);if(null!=n)return Promise.resolve(n)}return d(e,b,x).then(function(e){return h&&h.set(e),e})}function i(e,n){for(v.forEach(function(r){r(e,n)});T.length;)T.pop()(e,n);w.forEach(function(r){null!=r&&r(e,n)}),g.forEach(function(r){r(e,n)})}void 0===t&&(t={});var u=t,c=u.addons,l=void 0===c?[]:c,f=u.sideEffects,s=void 0===f?[]:f,h=u.cache,m=u.pathnameOptions,v=[],g=[];s.forEach(function(e){e.after?g.push(e.fn):v.push(e.fn)});var y,b=[],x={},E=l.concat(p(m)),w=[],T=[],A=[];return a(r),n.respondWith(function(e){y&&(y.cancel(e.action),y.cancelled=!0),y=e,o(e.location).then(function(r){if(!e.cancelled)return e.finish(),y=void 0,i(r,e.action),A=[r,e.action],r.redirectTo&&n.replace(r.redirectTo),r})}),{addons:x,history:n,subscribe:function(e,n){if("function"!=typeof e)throw new Error("The argument passed to subscribe must be a function");var r=(n||{}).once;if(void 0===r||!r){A.length&&e.apply(null,A);var t=w.push(e);return function(){w[t-1]=null}}A.length?e.apply(null,A):T.push(e)},refresh:a}}}(); | ||
//# sourceMappingURL=curi.min.js.map |
{ | ||
"name": "@curi/core", | ||
"version": "1.0.0-beta.16", | ||
"version": "1.0.0-beta.17", | ||
"description": "A JavaScript router you can use with anywhere", | ||
@@ -41,11 +41,11 @@ "main": "dist/curi.common.js", | ||
"@hickory/in-memory": "^1.0.0-beta.3", | ||
"@types/jest": "^20.0.8", | ||
"@types/node": "^8.0.47", | ||
"jest": "^21.1.0", | ||
"prettier": "^1.7.0", | ||
"rimraf": "^2.6.1", | ||
"@types/jest": "^21.1.8", | ||
"@types/node": "^8.0.53", | ||
"jest": "^21.2.1", | ||
"prettier": "^1.8.2", | ||
"rimraf": "^2.6.2", | ||
"rollup": "^0.50.0", | ||
"ts-jest": "^21.1.4", | ||
"typescript": "^2.5.2" | ||
"ts-jest": "^21.2.3", | ||
"typescript": "^2.6.1" | ||
} | ||
} |
@@ -11,5 +11,8 @@ import { History } from '@hickory/root'; | ||
} | ||
export interface SubscribeOptions { | ||
once?: boolean; | ||
} | ||
export interface CuriConfig { | ||
refresh: (routeArray: Array<RouteDescriptor>) => void; | ||
subscribe: (fn: Subscriber, initial?: boolean) => UnsubscribeFn; | ||
subscribe: (fn: Subscriber, options?: SubscribeOptions) => UnsubscribeFn; | ||
addons: Addons; | ||
@@ -16,0 +19,0 @@ history: History; |
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
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
105946
1634