@badrap/preload
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -1,2 +0,2 @@ | ||
const n=function(){function n(){}return n.prototype.then=function(e,r){const o=new n,i=this.s;if(i){const n=1&i?e:r;if(n){try{t(o,1,n(this.v))}catch(n){t(o,2,n)}return o}return this}return this.o=function(n){try{const i=n.v;1&n.s?t(o,1,e?e(i):i):r?t(o,1,r(i)):t(o,2,i)}catch(n){t(o,2,n)}},o},n}();function t(e,r,o){if(!e.s){if(o instanceof n){if(!o.s)return void(o.o=t.bind(null,e,r));1&r&&(r=o.s),o=o.v}if(o&&o.then)return void o.then(t.bind(null,e,r),t.bind(null,e,2));e.s=r,e.v=o;const i=e.o;i&&i(e)}}function e(t){return t instanceof n&&1&t.s}var r=function(n,t){return n.map(function(n){return t(Object.assign({},n,{children:n.children&&r(n.children,t)}))})},o={functional:!0,props:["status","error"],render:function(n,t){return n("div",{},[t.props.status+" "+t.props.error.message])}},i=Symbol(),u=Symbol(),c=function(n,t){return void 0===n&&(n=404),void 0===t&&(t="Not found"),{$type:i,status:n,error:t instanceof Error?t:{message:t}}},f=function(n){return{$type:u,to:n}},s=function(n){return"function"!=typeof n?Promise.resolve(n):new Promise(function(t,e){Promise.resolve(n(t,e)).then(t,e)}).then(function(n){return n.__esModule?n.default:n})};module.exports=function(a,h){void 0===h&&(h={});var v=h.context;void 0===v&&(v={});var l=h.errorComponent;void 0===l&&(l=o);var d,p=h.beforePreload,m=h.afterPreload,b=function(r){try{var o=!1;function a(n){if(o)return n;d={provide:function(){var n;return(n={})[y]=h,n},render:function(n){return n("router-view",{attrs:Object.assign({},this.$attrs)})}}}var h={};p&&p();var b=function(a,p){try{var m=(b=0,function(r,o,i){for(var u;;){var c=r();if(e(c)&&(c=c.v),!c)return f;if(c.then){u=0;break}var f=i();if(f&&f.then){if(!e(f)){u=1;break}f=f.s}if(o){var s=o();if(s&&s.then&&!e(s)){u=2;break}}}var a=new n,h=t.bind(null,a,2);return(0===u?c.then(l):1===u?f.then(v):s.then(d)).then(void 0,h),a;function v(n){f=n;do{if(o&&(s=o())&&s.then&&!e(s))return void s.then(d).then(void 0,h);if(!(c=r())||e(c)&&!c.v)return void t(a,1,f);if(c.then)return void c.then(l).then(void 0,h);e(f=i())&&(f=f.v)}while(!f||!f.then);f.then(v).then(void 0,h)}function l(n){n?(f=i())&&f.then?f.then(v).then(void 0,h):v(f):t(a,1,f)}function d(){(c=r())?c.then?c.then(l).then(void 0,h):l(c):t(a,1,f)}}(function(){return!o&&b<r.matched.length},function(){return b++},function(){var a=r.matched[b],p=Object.keys(a.components);return function(m,b,P){var j,g,$=-1;return function b(k){try{for(;++$<m.length&&(!P||!P());)if((k=Promise.resolve(s(a.components[p[$]])).then(function(n){if(n&&n[y]){var t=n[y],e=t.key;return Promise.resolve(Promise.resolve((0,t.preload)(Object.assign({},{route:r,redirect:f,error:c},v)))).then(function(n){return n&&n.$type===u?(o=!0,null.to):n&&n.$type===i?(d={render:function(n){return n(l,{props:{status:null.status,error:null.error}})}},void(o=!0)):void(h[e]=n)})}}))&&k.then){if(!e(k))return void k.then(b,g||(g=t.bind(null,j=new n,2)));k=k.v}j?t(j,1,k):j=k}catch(n){t(j||(j=new Pact),2,n)}}(),j}(p,0,function(){return o})}))}catch(n){return p(!0,n)}var b;return m&&m.then?m.then(p.bind(null,!1),p.bind(null,!0)):p(!1,value)}(0,function(n,t){if(m&&m(),n)throw t;return t});return Promise.resolve(b&&b.then?b.then(a):a(b))}catch(n){return Promise.reject(n)}},y=Symbol(),P=function(n){var t=null;return function(){return t||(t=s(n).then(function(n){var t;if(!n.preload)return n;var e=Symbol();return(t={extends:n})[y]={key:e,preload:n.preload},t.inject={$preload:y},t.data=function(){return Object.assign({},this.$preload[e])},t},function(n){return t=null,Promise.reject(n)})),t}};return[{path:"",component:{beforeRouteEnter:function(n,t,e){return b(n).then(e,e)},beforeRouteUpdate:function(n,t,e){return b(n).then(e,e)},render:function(n){return n(d,{key:this.$route.fullPath,attrs:this.$attrs})}},children:r(a,function(n){var t=Object.assign({},n);if(t.component&&(t.component=P(t.component)),t.components){var e={};Object.keys(t.components).forEach(function(n){e[n]=P(t.components[n])}),t.components=e}return t})}]}; | ||
const n=function(){function n(){}return n.prototype.then=function(e,r){const o=new n,i=this.s;if(i){const n=1&i?e:r;if(n){try{t(o,1,n(this.v))}catch(n){t(o,2,n)}return o}return this}return this.o=function(n){try{const i=n.v;1&n.s?t(o,1,e?e(i):i):r?t(o,1,r(i)):t(o,2,i)}catch(n){t(o,2,n)}},o},n}();function t(e,r,o){if(!e.s){if(o instanceof n){if(!o.s)return void(o.o=t.bind(null,e,r));1&r&&(r=o.s),o=o.v}if(o&&o.then)return void o.then(t.bind(null,e,r),t.bind(null,e,2));e.s=r,e.v=o;const i=e.o;i&&i(e)}}function e(t){return t instanceof n&&1&t.s}var r=function(n,t){return n.map(function(n){return t(Object.assign({},n,{children:n.children&&r(n.children,t)}))})},o={functional:!0,props:["status","error"],render:function(n,t){return n("div",{},[t.props.status+" "+t.props.error.message])}},i=Symbol(),u=Symbol(),c=function(n,t){return void 0===n&&(n=404),void 0===t&&(t="Not found"),{$type:i,status:n,error:t instanceof Error?t:{message:t}}},f=function(n){return{$type:u,to:n}},s=function(n){return"function"!=typeof n?Promise.resolve(n):new Promise(function(t,e){Promise.resolve(n(t,e)).then(t,e)}).then(function(n){return n.__esModule?n.default:n})};module.exports=function(a,h){void 0===h&&(h={});var v=h.context;void 0===v&&(v={});var d=h.errorComponent;void 0===d&&(d=o);var l,p=h.beforePreload,m=h.afterPreload,b=function(r){try{var o=!1;function a(n){if(o)return n;l={provide:function(){var n;return(n={})[y]=h,n},render:function(n){return n("router-view",{attrs:Object.assign({},this.$attrs)})}}}var h={};p&&p();var b=function(a,p){try{var m=(b=0,function(r,o,i){for(var u;;){var c=r();if(e(c)&&(c=c.v),!c)return f;if(c.then){u=0;break}var f=i();if(f&&f.then){if(!e(f)){u=1;break}f=f.s}if(o){var s=o();if(s&&s.then&&!e(s)){u=2;break}}}var a=new n,h=t.bind(null,a,2);return(0===u?c.then(d):1===u?f.then(v):s.then(l)).then(void 0,h),a;function v(n){f=n;do{if(o&&(s=o())&&s.then&&!e(s))return void s.then(l).then(void 0,h);if(!(c=r())||e(c)&&!c.v)return void t(a,1,f);if(c.then)return void c.then(d).then(void 0,h);e(f=i())&&(f=f.v)}while(!f||!f.then);f.then(v).then(void 0,h)}function d(n){n?(f=i())&&f.then?f.then(v).then(void 0,h):v(f):t(a,1,f)}function l(){(c=r())?c.then?c.then(d).then(void 0,h):d(c):t(a,1,f)}}(function(){return!o&&b<r.matched.length},function(){return b++},function(){var a=r.matched[b],p=Object.keys(a.components);return function(m,b,P){var j,g,$=-1;return function b(k){try{for(;++$<m.length&&(!P||!P());)if((k=Promise.resolve(s(a.components[p[$]])).then(function(n){if(n&&n[y]){var t=n[y],e=t.key;return Promise.resolve(Promise.resolve((0,t.preload)(Object.assign({},{route:r,redirect:f,error:c},v)))).then(function(n){return n&&n.$type===u?(o=!0,n.to):n&&n.$type===i?(l={render:function(t){return t(d,{props:{status:n.status,error:n.error}})}},void(o=!0)):void(h[e]=n)})}}))&&k.then){if(!e(k))return void k.then(b,g||(g=t.bind(null,j=new n,2)));k=k.v}j?t(j,1,k):j=k}catch(n){t(j||(j=new Pact),2,n)}}(),j}(p,0,function(){return o})}))}catch(n){return p(!0,n)}var b;return m&&m.then?m.then(p.bind(null,!1),p.bind(null,!0)):p(!1,value)}(0,function(n,t){if(m&&m(),n)throw t;return t});return Promise.resolve(b&&b.then?b.then(a):a(b))}catch(n){return Promise.reject(n)}},y=Symbol(),P=function(n){var t=null;return function(){return t||(t=s(n).then(function(n){var t;if(!n.preload)return n;var e=Symbol();return(t={extends:n})[y]={key:e,preload:n.preload},t.inject={$preload:y},t.data=function(){return Object.assign({},this.$preload[e])},t},function(n){return t=null,Promise.reject(n)})),t}};return[{path:"",component:{beforeRouteEnter:function(n,t,e){return b(n).then(e,e)},beforeRouteUpdate:function(n,t,e){return b(n).then(e,e)},render:function(n){return n(l,{key:this.$route.fullPath,attrs:this.$attrs})}},children:r(a,function(n){var t=Object.assign({},n);if(t.component&&(t.component=P(t.component)),t.components){var e={};Object.keys(t.components).forEach(function(n){e[n]=P(t.components[n])}),t.components=e}return t})}]}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@badrap/preload", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "Data preloading for vue-router, similar to Sapper's preload or Nuxt.js's asyncData", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -109,3 +109,2 @@ const mapRoutes = (routes, func) => { | ||
async function beforeRoute(to) { | ||
let action = null; | ||
const datas = {}; | ||
@@ -132,3 +131,3 @@ | ||
if (data && data.$type === ACTION_REDIRECT) { | ||
return action.to; | ||
return data.to; | ||
} | ||
@@ -140,4 +139,4 @@ if (data && data.$type === ACTION_ERROR) { | ||
props: { | ||
status: action.status, | ||
error: action.error | ||
status: data.status, | ||
error: data.error | ||
} | ||
@@ -144,0 +143,0 @@ }); |
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
84759
204