From 8dffeb03cff1655106f512dc1eec74d275822e43 Mon Sep 17 00:00:00 2001 From: Guillaume Chau Date: Wed, 26 Jul 2017 12:00:12 +0200 Subject: [PATCH] Dist --- dist/vue-apollo.esm.js | 27 ++++++++++++++++++--------- dist/vue-apollo.min.js | 2 +- dist/vue-apollo.umd.js | 27 ++++++++++++++++++--------- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/dist/vue-apollo.esm.js b/dist/vue-apollo.esm.js index 480ca5d..e40c1ee 100644 --- a/dist/vue-apollo.esm.js +++ b/dist/vue-apollo.esm.js @@ -3292,21 +3292,30 @@ var ApolloProvider$1 = function () { }); } }, { - key: 'exportStates', - value: function exportStates(options) { + key: 'getStates', + value: function getStates(options) { var finalOptions = Object.assign({}, { - exportNamespace: '', - globalName: '__APOLLO_STATE__', - attachTo: 'window' + exportNamespace: '' }, options); - - var js = finalOptions.attachTo + '.' + finalOptions.globalName + ' = {'; + var states = {}; for (var key in this.clients) { var client = this.clients[key]; var state = defineProperty({}, client.reduxRootKey || 'apollo', client.getInitialState()); - js += '[\'' + finalOptions.exportNamespace + key + '\']:' + JSON.stringify(state) + ','; + states['' + finalOptions.exportNamespace + key] = state; } - js += '};'; + return states; + } + }, { + key: 'exportStates', + value: function exportStates(options) { + var finalOptions = Object.assign({}, { + globalName: '__APOLLO_STATE__', + attachTo: 'window' + }, options); + var states = this.getStates({ + exportNamespace: options.exportNamespace + }); + var js = finalOptions.attachTo + '.' + finalOptions.globalName + ' = ' + JSON.stringify(states) + ';'; return js; } }]); diff --git a/dist/vue-apollo.min.js b/dist/vue-apollo.min.js index ecdb920..82d7d5d 100644 --- a/dist/vue-apollo.min.js +++ b/dist/vue-apollo.min.js @@ -1 +1 @@ -!function(t){"use strict";function e(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function r(t,e){var r=t?t.length:0;return!!r&&u(t,e,0)>-1}function i(t,e,r){for(var i=-1,n=t?t.length:0;++i-1}function A(t,e){var r=this.__data__,i=V(r,t);return i<0?r.push([t,e]):r[i][1]=e,this}function P(t){var e=-1,r=t?t.length:0;for(this.clear();++e=Tt&&(a=f,l=!1,e=new M(e));t:for(;++u0&&r(a)?e>1?D(a,e-1,r,i,n):o(n,a):i||(n[n.length]=a)}return n}function N(t,e,r){var i=e(t);return he(t)?i:o(i,r(t))}function I(t){if(!lt(t)||Y(t))return!1;var e=ut(t)||p(t)?te:It;return e.test(rt(t))}function K(t){if(!lt(t))return tt(t);var e=Z(t),r=[];for(var i in t)("constructor"!=i||!e&&Yt.call(t,i))&&r.push(i);return r}function F(t,e){return t=Object(t),W(t,e,function(e,r){return r in t})}function W(t,e,r){for(var i=-1,n=e.length,o={};++i-1&&t%1==0&&t-1&&t%1==0&&t<=Lt}function lt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function ct(t){return!!t&&"object"==typeof t}function ft(t){return"symbol"==typeof t||ct(t)&&Zt.call(t)==Dt}function ht(t){return ot(t)?C(t,!0):K(t)}function pt(){return[]}function vt(t,e,r){function i(e){var r=h,i=p;return h=p=void 0,g=e,y=t.apply(i,r)}function n(t){return g=t,b=setTimeout(u,e),_?i(t):y}function o(t){var r=t-d,i=t-g,n=e-r;return m?xe(n,v-i):n}function s(t){var r=t-d,i=t-g;return void 0===d||r>=e||r<0||m&&i>=v}function u(){var t=Ee();return s(t)?a(t):void(b=setTimeout(u,o(t)))}function a(t){return b=void 0,w&&h?i(t):(h=p=void 0,y)}function l(){void 0!==b&&clearTimeout(b),g=0,h=d=p=b=void 0}function c(){return void 0===b?y:a(Ee())}function f(){var t=Ee(),r=s(t);if(h=arguments,p=this,d=t,r){if(void 0===b)return n(d);if(m)return b=setTimeout(u,e),i(d)}return void 0===b&&(b=setTimeout(u,e)),y}var h,p,v,y,b,d,g=0,_=!1,m=!1,w=!0;if("function"!=typeof t)throw new TypeError(ye);return e=_t(e)||0,bt(r)&&(_=!!r.leading,m="maxWait"in r,v=m?$e(_t(r.maxWait)||0,e):v,w="trailing"in r?!!r.trailing:w),f.cancel=l,f.flush=c,f}function yt(t,e,r){var i=!0,n=!0;if("function"!=typeof t)throw new TypeError(ye);return bt(r)&&(i="leading"in r?!!r.leading:i,n="trailing"in r?!!r.trailing:n),vt(t,e,{leading:i,maxWait:e,trailing:n})}function bt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function dt(t){return!!t&&"object"==typeof t}function gt(t){return"symbol"==typeof t||dt(t)&&Pe.call(t)==de}function _t(t){if("number"==typeof t)return t;if(gt(t))return be;if(bt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=bt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(ge,"");var r=me.test(t);return r||we.test(t)?ke(t.slice(2),r?2:8):_e.test(t)?be:+t}function mt(t,e,r){function i(e){var r=h,i=p;return h=p=void 0,g=e,y=t.apply(i,r)}function n(t){return g=t,b=setTimeout(u,e),_?i(t):y}function o(t){var r=t-d,i=t-g,n=e-r;return m?Je(n,v-i):n}function s(t){var r=t-d,i=t-g;return void 0===d||r>=e||r<0||m&&i>=v}function u(){var t=Ue();return s(t)?a(t):void(b=setTimeout(u,o(t)))}function a(t){return b=void 0,w&&h?i(t):(h=p=void 0,y)}function l(){void 0!==b&&clearTimeout(b),g=0,h=d=p=b=void 0}function c(){return void 0===b?y:a(Ue())}function f(){var t=Ue(),r=s(t);if(h=arguments,p=this,d=t,r){if(void 0===b)return n(d);if(m)return b=setTimeout(u,e),i(d)}return void 0===b&&(b=setTimeout(u,e)),y}var h,p,v,y,b,d,g=0,_=!1,m=!1,w=!0;if("function"!=typeof t)throw new TypeError(Te);return e=jt(e)||0,wt(r)&&(_=!!r.leading,m="maxWait"in r,v=m?Ge(jt(r.maxWait)||0,e):v,w="trailing"in r?!!r.trailing:w),f.cancel=l,f.flush=c,f}function wt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function kt(t){return!!t&&"object"==typeof t}function Ot(t){return"symbol"==typeof t||kt(t)&&We.call(t)==qe}function jt(t){if("number"==typeof t)return t;if(Ot(t))return Me;if(wt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=wt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Le,"");var r=Ve.test(t);return r||Re.test(t)?De(t.slice(2),r?2:8):Ce.test(t)?Me:+t}function St(t){return function(e,r){return"number"==typeof r?t(e,r):t(e,r.wait,r)}}function At(t){return Be.Vue.util.mergeOptions({},t)}function Pt(t,e){for(;"function"==typeof t;)t=t.call(e);return t}function $t(t){return pr.push(t),t}function xt(t,e,r){"undefined"!=typeof r&&("function"==typeof r?t.defineReactiveSetter(e,r):t[e]=r)}function Et(t,e){if(!Et.installed){Et.installed=!0,Be.Vue=t;var r=t.config.optionMergeStrategies.methods;t.config.optionMergeStrategies.apollo=function(t,e,i){if(!t)return e;if(!e)return t;for(var n=Object.assign({},ve(t,vr),t.data),o=Object.assign({},ve(e,vr),e.data),s={},u=0;u3&&void 0!==arguments[3])||arguments[3];if(tr(this,t),this.type=null,this.vueApolloSpecialKeys=[],this.vm=e,this.key=r,this.options=i,this._skip=!1,this._watchers=[],"function"==typeof this.options.query){var s=this.options.query.bind(this.vm);this.options.query=s(),this._watchers.push(this.vm.$watch(s,function(t){n.options.query=t,n.refresh()}))}if("function"==typeof this.options.document){var u=this.options.document.bind(this.vm);this.options.document=u(),this._watchers.push(this.vm.$watch(u,function(t){n.options.document=t,n.refresh()}))}o&&this.autostart()}return er(t,[{key:"autostart",value:function(){"function"==typeof this.options.skip?this._watchers.push(this.vm.$watch(this.options.skip.bind(this.vm),this.skipChanged.bind(this),{immediate:!0})):this.options.skip?this._skip=!0:this.start()}},{key:"skipChanged",value:function(t,e){t!==e&&(this.skip=t)}},{key:"refresh",value:function(){this._skip||(this.stop(),this.start())}},{key:"start",value:function(){var t=this;if(this.starting=!0,"function"==typeof this.options.variables){var e=this.executeApollo.bind(this);e=this.options.throttle?He(e,this.options.throttle):e,e=this.options.debounce?Xe(e,this.options.debounce):e,this.unwatchVariables=this.vm.$watch(function(){return t.options.variables.bind(t.vm)()},e,{immediate:!0})}else this.executeApollo(this.options.variables)}},{key:"stop",value:function(){this.unwatchVariables&&(this.unwatchVariables(),this.unwatchVariables=null),this.sub&&(this.sub.unsubscribe(),this.sub=null)}},{key:"generateApolloOptions",value:function(t){var e=ve(this.options,this.vueApolloSpecialKeys);return e.variables=t,e}},{key:"executeApollo",value:function(t){this.starting=!1}},{key:"nextResult",value:function(){throw new Error("Not implemented")}},{key:"catchError",value:function(t){if(t.graphQLErrors&&0!==t.graphQLErrors.length){console.error("GraphQL execution errors for "+this.type+" '"+this.key+"'");var e=!0,r=!1,i=void 0;try{for(var n,o=t.graphQLErrors[Symbol.iterator]();!(e=(n=o.next()).done);e=!0){var s=n.value;console.error(s)}}catch(t){r=!0,i=t}finally{try{!e&&o.return&&o.return()}finally{if(r)throw i}}}else if(t.networkError)console.error("Error sending the "+this.type+" '"+this.key+"'",t.networkError);else if(console.error("[vue-apollo] An error has occured for "+this.type+" '"+this.key+"'"),Array.isArray(t)){var u;(u=console).error.apply(u,ur(t))}else console.error(t);"function"==typeof this.options.error&&this.options.error.call(this.vm,t)}},{key:"destroy",value:function(){this.stop();var t=!0,e=!1,r=void 0;try{for(var i,n=this._watchers[Symbol.iterator]();!(t=(i=n.next()).done);t=!0){var o=i.value;o()}}catch(t){e=!0,r=t}finally{try{!t&&n.return&&n.return()}finally{if(e)throw r}}}},{key:"skip",get:function(){return this._skip},set:function(t){t?this.stop():this.start(),this._skip=t}}]),t}(),lr=function(t){function e(t,r,i){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(tr(this,e),!i.query){var o=i;i={query:o}}var s=sr(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r,i,n));return s.type="query",s.vueApolloSpecialKeys=Ye,s.loading=!1,s}return or(e,t),er(e,[{key:"stop",value:function(){nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"stop",this).call(this),this.observer&&(this.observer.stopPolling(),this.observer=null)}},{key:"executeApollo",value:function(t){this.observer?this.observer.setOptions(this.generateApolloOptions(t)):(this.sub&&this.sub.unsubscribe(),this.observer=this.vm.$apollo.watchQuery(this.generateApolloOptions(t)),this.sub=this.observer.subscribe({next:this.nextResult.bind(this),error:this.catchError.bind(this)})),this.maySetLoading(),nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"executeApollo",this).call(this,t)}},{key:"maySetLoading",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.observer.currentResult();(t||e.loading)&&(this.loading||this.applyLoadingModifier(1),this.loading=!0)}},{key:"nextResult",value:function(t){var e=t.data,r=t.loading;r||this.loadingDone(),"undefined"==typeof e||("function"==typeof this.options.update?this.vm[this.key]=this.options.update.call(this.vm,e):void 0===e[this.key]?console.error("Missing "+this.key+" attribute on result",e):this.vm[this.key]=e[this.key]),"function"==typeof this.options.result&&this.options.result.call(this.vm,t)}},{key:"catchError",value:function(t){nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"catchError",this).call(this,t),this.loadingDone()}},{key:"applyLoadingModifier",value:function(t){this.options.loadingKey&&(this.vm[this.options.loadingKey]+=t),this.options.watchLoading&&this.options.watchLoading.call(this.vm,1===t,t)}},{key:"loadingDone",value:function(){this.loading&&this.applyLoadingModifier(-1),this.loading=!1}},{key:"fetchMore",value:function(){if(this.observer){var t;return this.maySetLoading(!0),(t=this.observer).fetchMore.apply(t,arguments)}}},{key:"subscribeToMore",value:function(){if(this.observer){var t;return{unsubscribe:(t=this.observer).subscribeToMore.apply(t,arguments)}}}},{key:"refetch",value:function(t){var e=this;if(t&&(this.options.variables=t),this.observer){var r=this.observer.refetch(t).then(function(t){t.loading||e.loadingDone()});return this.maySetLoading(),r}}},{key:"setVariables",value:function(t,e){if(this.options.variables=t,this.observer){var r=this.observer.setVariables(t,e);return this.maySetLoading(),r}}},{key:"setOptions",value:function(t){if(Object.assign(this.options,t),this.observer){var e=this.observer.setOptions(t);return this.maySetLoading(),e}}},{key:"startPolling",value:function(){if(this.observer){var t;return(t=this.observer).startPolling.apply(t,arguments)}}},{key:"stopPolling",value:function(){if(this.observer){var t;return(t=this.observer).stopPolling.apply(t,arguments)}}}]),e}(ar),cr=function(t){function e(){var t,r,i,n;tr(this,e);for(var o=arguments.length,s=Array(o),u=0;u `subscribe` option is deprecated. Use the `$subscribe` option instead."),e.$subscribe)for(var r in e.$subscribe)this.$apollo.addSmartSubscription(r,e.$subscribe[r]);xt(this.$apollo,"skipAll",e.$skipAll),xt(this.$apollo,"skipAllQueries",e.$skipAllQueries),xt(this.$apollo,"skipAllSubscriptions",e.$skipAllSubscriptions),xt(this.$apollo,"client",e.$client)}}};hr.install=Et;var dr=hr,gr=null;"undefined"!=typeof window?gr=window.Vue:"undefined"!=typeof global&&(gr=global.Vue),gr&&gr.use(hr),t.install=Et,t.ApolloProvider=dr,t.default=hr,t.willPrefetch=$t}(this.VueApollo=this.VueApollo||{}); +!function(t){"use strict";function e(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function r(t,e){var r=t?t.length:0;return!!r&&u(t,e,0)>-1}function i(t,e,r){for(var i=-1,n=t?t.length:0;++i-1}function A(t,e){var r=this.__data__,i=V(r,t);return i<0?r.push([t,e]):r[i][1]=e,this}function P(t){var e=-1,r=t?t.length:0;for(this.clear();++e=Tt&&(a=f,l=!1,e=new M(e));t:for(;++u0&&r(a)?e>1?R(a,e-1,r,i,n):o(n,a):i||(n[n.length]=a)}return n}function D(t,e,r){var i=e(t);return he(t)?i:o(i,r(t))}function I(t){if(!lt(t)||Y(t))return!1;var e=ut(t)||p(t)?te:It;return e.test(rt(t))}function K(t){if(!lt(t))return tt(t);var e=Z(t),r=[];for(var i in t)("constructor"!=i||!e&&Yt.call(t,i))&&r.push(i);return r}function F(t,e){return t=Object(t),W(t,e,function(e,r){return r in t})}function W(t,e,r){for(var i=-1,n=e.length,o={};++i-1&&t%1==0&&t-1&&t%1==0&&t<=Lt}function lt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function ct(t){return!!t&&"object"==typeof t}function ft(t){return"symbol"==typeof t||ct(t)&&Zt.call(t)==Rt}function ht(t){return ot(t)?C(t,!0):K(t)}function pt(){return[]}function vt(t,e,r){function i(e){var r=h,i=p;return h=p=void 0,g=e,y=t.apply(i,r)}function n(t){return g=t,b=setTimeout(u,e),_?i(t):y}function o(t){var r=t-d,i=t-g,n=e-r;return m?xe(n,v-i):n}function s(t){var r=t-d,i=t-g;return void 0===d||r>=e||r<0||m&&i>=v}function u(){var t=Ee();return s(t)?a(t):void(b=setTimeout(u,o(t)))}function a(t){return b=void 0,w&&h?i(t):(h=p=void 0,y)}function l(){void 0!==b&&clearTimeout(b),g=0,h=d=p=b=void 0}function c(){return void 0===b?y:a(Ee())}function f(){var t=Ee(),r=s(t);if(h=arguments,p=this,d=t,r){if(void 0===b)return n(d);if(m)return b=setTimeout(u,e),i(d)}return void 0===b&&(b=setTimeout(u,e)),y}var h,p,v,y,b,d,g=0,_=!1,m=!1,w=!0;if("function"!=typeof t)throw new TypeError(ye);return e=_t(e)||0,bt(r)&&(_=!!r.leading,m="maxWait"in r,v=m?$e(_t(r.maxWait)||0,e):v,w="trailing"in r?!!r.trailing:w),f.cancel=l,f.flush=c,f}function yt(t,e,r){var i=!0,n=!0;if("function"!=typeof t)throw new TypeError(ye);return bt(r)&&(i="leading"in r?!!r.leading:i,n="trailing"in r?!!r.trailing:n),vt(t,e,{leading:i,maxWait:e,trailing:n})}function bt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function dt(t){return!!t&&"object"==typeof t}function gt(t){return"symbol"==typeof t||dt(t)&&Pe.call(t)==de}function _t(t){if("number"==typeof t)return t;if(gt(t))return be;if(bt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=bt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(ge,"");var r=me.test(t);return r||we.test(t)?ke(t.slice(2),r?2:8):_e.test(t)?be:+t}function mt(t,e,r){function i(e){var r=h,i=p;return h=p=void 0,g=e,y=t.apply(i,r)}function n(t){return g=t,b=setTimeout(u,e),_?i(t):y}function o(t){var r=t-d,i=t-g,n=e-r;return m?Je(n,v-i):n}function s(t){var r=t-d,i=t-g;return void 0===d||r>=e||r<0||m&&i>=v}function u(){var t=Ue();return s(t)?a(t):void(b=setTimeout(u,o(t)))}function a(t){return b=void 0,w&&h?i(t):(h=p=void 0,y)}function l(){void 0!==b&&clearTimeout(b),g=0,h=d=p=b=void 0}function c(){return void 0===b?y:a(Ue())}function f(){var t=Ue(),r=s(t);if(h=arguments,p=this,d=t,r){if(void 0===b)return n(d);if(m)return b=setTimeout(u,e),i(d)}return void 0===b&&(b=setTimeout(u,e)),y}var h,p,v,y,b,d,g=0,_=!1,m=!1,w=!0;if("function"!=typeof t)throw new TypeError(Te);return e=jt(e)||0,wt(r)&&(_=!!r.leading,m="maxWait"in r,v=m?Ge(jt(r.maxWait)||0,e):v,w="trailing"in r?!!r.trailing:w),f.cancel=l,f.flush=c,f}function wt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function kt(t){return!!t&&"object"==typeof t}function Ot(t){return"symbol"==typeof t||kt(t)&&We.call(t)==qe}function jt(t){if("number"==typeof t)return t;if(Ot(t))return Me;if(wt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=wt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Le,"");var r=Ve.test(t);return r||Ne.test(t)?Re(t.slice(2),r?2:8):Ce.test(t)?Me:+t}function St(t){return function(e,r){return"number"==typeof r?t(e,r):t(e,r.wait,r)}}function At(t){return Be.Vue.util.mergeOptions({},t)}function Pt(t,e){for(;"function"==typeof t;)t=t.call(e);return t}function $t(t){return pr.push(t),t}function xt(t,e,r){"undefined"!=typeof r&&("function"==typeof r?t.defineReactiveSetter(e,r):t[e]=r)}function Et(t,e){if(!Et.installed){Et.installed=!0,Be.Vue=t;var r=t.config.optionMergeStrategies.methods;t.config.optionMergeStrategies.apollo=function(t,e,i){if(!t)return e;if(!e)return t;for(var n=Object.assign({},ve(t,vr),t.data),o=Object.assign({},ve(e,vr),e.data),s={},u=0;u3&&void 0!==arguments[3])||arguments[3];if(tr(this,t),this.type=null,this.vueApolloSpecialKeys=[],this.vm=e,this.key=r,this.options=i,this._skip=!1,this._watchers=[],"function"==typeof this.options.query){var s=this.options.query.bind(this.vm);this.options.query=s(),this._watchers.push(this.vm.$watch(s,function(t){n.options.query=t,n.refresh()}))}if("function"==typeof this.options.document){var u=this.options.document.bind(this.vm);this.options.document=u(),this._watchers.push(this.vm.$watch(u,function(t){n.options.document=t,n.refresh()}))}o&&this.autostart()}return er(t,[{key:"autostart",value:function(){"function"==typeof this.options.skip?this._watchers.push(this.vm.$watch(this.options.skip.bind(this.vm),this.skipChanged.bind(this),{immediate:!0})):this.options.skip?this._skip=!0:this.start()}},{key:"skipChanged",value:function(t,e){t!==e&&(this.skip=t)}},{key:"refresh",value:function(){this._skip||(this.stop(),this.start())}},{key:"start",value:function(){var t=this;if(this.starting=!0,"function"==typeof this.options.variables){var e=this.executeApollo.bind(this);e=this.options.throttle?He(e,this.options.throttle):e,e=this.options.debounce?Xe(e,this.options.debounce):e,this.unwatchVariables=this.vm.$watch(function(){return t.options.variables.bind(t.vm)()},e,{immediate:!0})}else this.executeApollo(this.options.variables)}},{key:"stop",value:function(){this.unwatchVariables&&(this.unwatchVariables(),this.unwatchVariables=null),this.sub&&(this.sub.unsubscribe(),this.sub=null)}},{key:"generateApolloOptions",value:function(t){var e=ve(this.options,this.vueApolloSpecialKeys);return e.variables=t,e}},{key:"executeApollo",value:function(t){this.starting=!1}},{key:"nextResult",value:function(){throw new Error("Not implemented")}},{key:"catchError",value:function(t){if(t.graphQLErrors&&0!==t.graphQLErrors.length){console.error("GraphQL execution errors for "+this.type+" '"+this.key+"'");var e=!0,r=!1,i=void 0;try{for(var n,o=t.graphQLErrors[Symbol.iterator]();!(e=(n=o.next()).done);e=!0){var s=n.value;console.error(s)}}catch(t){r=!0,i=t}finally{try{!e&&o.return&&o.return()}finally{if(r)throw i}}}else if(t.networkError)console.error("Error sending the "+this.type+" '"+this.key+"'",t.networkError);else if(console.error("[vue-apollo] An error has occured for "+this.type+" '"+this.key+"'"),Array.isArray(t)){var u;(u=console).error.apply(u,ur(t))}else console.error(t);"function"==typeof this.options.error&&this.options.error.call(this.vm,t)}},{key:"destroy",value:function(){this.stop();var t=!0,e=!1,r=void 0;try{for(var i,n=this._watchers[Symbol.iterator]();!(t=(i=n.next()).done);t=!0){var o=i.value;o()}}catch(t){e=!0,r=t}finally{try{!t&&n.return&&n.return()}finally{if(e)throw r}}}},{key:"skip",get:function(){return this._skip},set:function(t){t?this.stop():this.start(),this._skip=t}}]),t}(),lr=function(t){function e(t,r,i){var n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if(tr(this,e),!i.query){var o=i;i={query:o}}var s=sr(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,r,i,n));return s.type="query",s.vueApolloSpecialKeys=Ye,s.loading=!1,s}return or(e,t),er(e,[{key:"stop",value:function(){nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"stop",this).call(this),this.observer&&(this.observer.stopPolling(),this.observer=null)}},{key:"executeApollo",value:function(t){this.observer?this.observer.setOptions(this.generateApolloOptions(t)):(this.sub&&this.sub.unsubscribe(),this.observer=this.vm.$apollo.watchQuery(this.generateApolloOptions(t)),this.sub=this.observer.subscribe({next:this.nextResult.bind(this),error:this.catchError.bind(this)})),this.maySetLoading(),nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"executeApollo",this).call(this,t)}},{key:"maySetLoading",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.observer.currentResult();(t||e.loading)&&(this.loading||this.applyLoadingModifier(1),this.loading=!0)}},{key:"nextResult",value:function(t){var e=t.data,r=t.loading;r||this.loadingDone(),"undefined"==typeof e||("function"==typeof this.options.update?this.vm[this.key]=this.options.update.call(this.vm,e):void 0===e[this.key]?console.error("Missing "+this.key+" attribute on result",e):this.vm[this.key]=e[this.key]),"function"==typeof this.options.result&&this.options.result.call(this.vm,t)}},{key:"catchError",value:function(t){nr(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"catchError",this).call(this,t),this.loadingDone()}},{key:"applyLoadingModifier",value:function(t){this.options.loadingKey&&(this.vm[this.options.loadingKey]+=t),this.options.watchLoading&&this.options.watchLoading.call(this.vm,1===t,t)}},{key:"loadingDone",value:function(){this.loading&&this.applyLoadingModifier(-1),this.loading=!1}},{key:"fetchMore",value:function(){if(this.observer){var t;return this.maySetLoading(!0),(t=this.observer).fetchMore.apply(t,arguments)}}},{key:"subscribeToMore",value:function(){if(this.observer){var t;return{unsubscribe:(t=this.observer).subscribeToMore.apply(t,arguments)}}}},{key:"refetch",value:function(t){var e=this;if(t&&(this.options.variables=t),this.observer){var r=this.observer.refetch(t).then(function(t){t.loading||e.loadingDone()});return this.maySetLoading(),r}}},{key:"setVariables",value:function(t,e){if(this.options.variables=t,this.observer){var r=this.observer.setVariables(t,e);return this.maySetLoading(),r}}},{key:"setOptions",value:function(t){if(Object.assign(this.options,t),this.observer){var e=this.observer.setOptions(t);return this.maySetLoading(),e}}},{key:"startPolling",value:function(){if(this.observer){var t;return(t=this.observer).startPolling.apply(t,arguments)}}},{key:"stopPolling",value:function(){if(this.observer){var t;return(t=this.observer).stopPolling.apply(t,arguments)}}}]),e}(ar),cr=function(t){function e(){var t,r,i,n;tr(this,e);for(var o=arguments.length,s=Array(o),u=0;u `subscribe` option is deprecated. Use the `$subscribe` option instead."),e.$subscribe)for(var r in e.$subscribe)this.$apollo.addSmartSubscription(r,e.$subscribe[r]);xt(this.$apollo,"skipAll",e.$skipAll),xt(this.$apollo,"skipAllQueries",e.$skipAllQueries),xt(this.$apollo,"skipAllSubscriptions",e.$skipAllSubscriptions),xt(this.$apollo,"client",e.$client)}}};hr.install=Et;var dr=hr,gr=null;"undefined"!=typeof window?gr=window.Vue:"undefined"!=typeof global&&(gr=global.Vue),gr&&gr.use(hr),t.install=Et,t.ApolloProvider=dr,t.default=hr,t.willPrefetch=$t}(this.VueApollo=this.VueApollo||{}); diff --git a/dist/vue-apollo.umd.js b/dist/vue-apollo.umd.js index 1751203..51dff38 100644 --- a/dist/vue-apollo.umd.js +++ b/dist/vue-apollo.umd.js @@ -3298,21 +3298,30 @@ var ApolloProvider$1 = function () { }); } }, { - key: 'exportStates', - value: function exportStates(options) { + key: 'getStates', + value: function getStates(options) { var finalOptions = Object.assign({}, { - exportNamespace: '', - globalName: '__APOLLO_STATE__', - attachTo: 'window' + exportNamespace: '' }, options); - - var js = finalOptions.attachTo + '.' + finalOptions.globalName + ' = {'; + var states = {}; for (var key in this.clients) { var client = this.clients[key]; var state = defineProperty({}, client.reduxRootKey || 'apollo', client.getInitialState()); - js += '[\'' + finalOptions.exportNamespace + key + '\']:' + JSON.stringify(state) + ','; + states['' + finalOptions.exportNamespace + key] = state; } - js += '};'; + return states; + } + }, { + key: 'exportStates', + value: function exportStates(options) { + var finalOptions = Object.assign({}, { + globalName: '__APOLLO_STATE__', + attachTo: 'window' + }, options); + var states = this.getStates({ + exportNamespace: options.exportNamespace + }); + var js = finalOptions.attachTo + '.' + finalOptions.globalName + ' = ' + JSON.stringify(states) + ';'; return js; } }]);