@vue-storefront/core
Advanced tools
Comparing version
@@ -15,3 +15,3 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@vue/composition-api"),t=function(){return(t=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var u in t=arguments[r])Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e}).apply(this,arguments)}; | ||
and limitations under the License. | ||
***************************************************************************** */function r(e,t,r,n){return new(r||(r=Promise))((function(u,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){e.done?u(e.value):new r((function(t){t(e.value)})).then(i,o)}s((n=n.apply(e,t||[])).next())}))}function n(e,t){var r,n,u,a,i={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(u=2&a[0]?n.return:a[0]?n.throw||((u=n.return)&&u.call(n),0):n.next)&&!(u=u.call(n,a[1])).done)return u;switch(n=0,u&&(a=[2&a[0],u.value]),a[0]){case 0:case 1:u=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(u=i.trys,(u=u.length>0&&u[u.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!u||a[1]>u[0]&&a[1]<u[3])){i.label=a[1];break}if(6===a[0]&&i.label<u[1]){i.label=u[1],u=a;break}if(u&&i.label<u[2]){i.label=u[2],i.ops.push(a);break}u[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=u=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}var u=[],a=[],i=function(e){return e.$isServer?e.$ssrContext.nuxt.vsfState:window.__VSF_STATE__||{}},o=0,s=function(t){var i,s=e.getCurrentInstance(),l=s.$isServer;l&&!s.$ssrContext.nuxt.vsfState&&(s.$ssrContext.nuxt.vsfState={}),e.onServerPrefetch((function(){return r(void 0,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,t()];case 1:return e.sent(),r="set-ssr-cache",n=function(e){var t=e.key,r=e.value;s.$ssrContext.nuxt.vsfState[t]=r},u.push({eventName:r,handler:n}),a.filter((function(e){return e.eventName===r})).forEach((function(e){n(e.value)})),a=a.filter((function(e){return e.eventName!==r})),[2]}var r,n}))}))})),!l&&(i=window.__VSF_STATE__?JSON.stringify(window.__VSF_STATE__).length:0,o===i||(o=i,0))&&t()};exports.useSSR=function(t){var r=e.getCurrentInstance();r.$isServer&&!r.$ssrContext.nuxt.vsfState&&(r.$ssrContext.nuxt.vsfState={});return{saveToInitialState:function(e){!function(e,t){var r=u.filter((function(t){return t.eventName===e}));r.forEach((function(e){e.handler(t)})),0===r.length&&a.push({eventName:e,value:t})}("set-ssr-cache",{key:t,value:e})},initialState:i(r)[t]}};var l;(l=exports.AgnosticOrderStatus||(exports.AgnosticOrderStatus={})).Open="Open",l.Pending="Pending",l.Confirmed="Confirmed",l.Shipped="Shipped",l.Complete="Complete",l.Cancelled="Cancelled",l.Refunded="Refunded",exports.apiClientFactory=function(e){var r=t(t({},e.defaultSettings),{overrides:{}});return{override:function(e){r.overrides=t(t({},r.overrides),e)},setup:function(n){r=t(t(t({},e.defaultSettings),{overrides:r.overrides}),n),e.onSetup(r)},update:function(n){r=t(t({},r),n),e.onSetup(r)},getSettings:function(){return Object.freeze(r)}}},exports.configureSSR=function(e){exports.useSSR=e.useSSR},exports.onSSR=s,exports.useCartFactory=function(t){var u=e.ref(null),a=e.ref(!1),i=e.ref(null),o=!1;return{useCart:function(){var s=exports.useSSR("vsf-cart"),l=s.initialState,c=s.saveToInitialState;i.value=o?i.value:l||null,o=!0;return{cart:e.computed((function(){return i.value})),isOnCart:function(e){return t.isOnCart({currentCart:i.value,product:e})},addToCart:function(e,u){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return a.value=!0,[4,t.addToCart({currentCart:i.value,product:e,quantity:u})];case 1:return r=n.sent(),i.value=r,a.value=!1,[2]}}))}))},loadCart:function(){return r(void 0,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return i.value?[2]:(a.value=!0,e=i,[4,t.loadCart()]);case 1:return e.value=r.sent(),c(i.value),a.value=!1,[2]}}))}))},removeFromCart:function(e){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return a.value=!0,[4,t.removeFromCart({currentCart:i.value,product:e})];case 1:return r=n.sent(),i.value=r,a.value=!1,[2]}}))}))},clearCart:function(){return r(void 0,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return a.value=!0,[4,t.clearCart({currentCart:i.value})];case 1:return e=r.sent(),i.value=e,a.value=!1,[2]}}))}))},updateQuantity:function(e,u){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return u&&u>0?(a.value=!0,[4,t.updateQuantity({currentCart:i.value,product:e,quantity:u})]):[3,2];case 1:r=n.sent(),i.value=r,a.value=!1,n.label=2;case 2:return[2]}}))}))},coupon:e.computed((function(){return u.value})),applyCoupon:function(e){return r(void 0,void 0,void 0,(function(){var r,o,s;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,,2,3]),a.value=!0,[4,t.applyCoupon({currentCart:i.value,coupon:e})];case 1:return r=n.sent(),o=r.updatedCart,s=r.updatedCoupon,i.value=o,u.value=s,[3,3];case 2:return a.value=!1,[7];case 3:return[2]}}))}))},removeCoupon:function(){return r(void 0,void 0,void 0,(function(){var e,r,o;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,,2,3]),a.value=!0,[4,t.removeCoupon({currentCart:i.value})];case 1:return e=n.sent(),r=e.updatedCart,o=e.updatedCoupon,i.value=r,u.value=o,a.value=!1,[3,3];case 2:return a.value=!1,[7];case 3:return[2]}}))}))},loading:e.computed((function(){return a.value}))}},setCart:function(e){i.value=e}}},exports.useCategoryFactory=function(t){return function(u){var a=this,i=exports.useSSR(u),o=i.initialState,s=i.saveToInitialState,l=e.ref(o||[]),c=e.ref(!1);return{search:function(e){return r(a,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return o||(c.value=!0),r=l,[4,t.categorySearch(e)];case 1:return r.value=n.sent(),s(l.value),c.value=!1,[2]}}))}))},loading:e.computed((function(){return c.value})),categories:e.computed((function(){return l.value}))}}},exports.useLocaleFactory=function(t){var u=this,a=e.ref(!1),i=e.ref(null),o=e.ref(null),s=e.ref(null),l=e.ref([]),c=e.ref([]),v=e.ref([]),f=function(e){return r(u,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return a.value=!0,r=i,[4,t.setLocale(e)];case 1:return r.value=n.sent(),a.value=!1,[2]}}))}))},d=function(e){return r(u,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return a.value=!0,r=o,[4,t.setCountry(e)];case 1:return r.value=n.sent(),a.value=!1,[2]}}))}))},h=function(e){return r(u,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return a.value=!0,r=s,[4,t.setCurrency(e)];case 1:return r.value=n.sent(),a.value=!1,[2]}}))}))},p=function(){return r(u,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return e=l,[4,t.loadAvailableLocales()];case 1:return e.value=r.sent(),[2]}}))}))},b=function(){return r(u,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return e=c,[4,t.loadAvailableCountries()];case 1:return e.value=r.sent(),[2]}}))}))},S=function(){return r(u,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return e=v,[4,t.loadAvailableCurrencies()];case 1:return e.value=r.sent(),[2]}}))}))};return function(){return{loadAvailableLocales:p,loadAvailableCountries:b,loadAvailableCurrencies:S,setCountry:d,setCurrency:h,setLocale:f,loading:e.computed((function(){return a.value})),locale:e.computed((function(){return i.value})),country:e.computed((function(){return o.value})),currency:e.computed((function(){return s.value})),availableLocales:e.computed((function(){return l.value})),availableCountries:e.computed((function(){return c.value})),availableCurrencies:e.computed((function(){return v.value}))}}},exports.useProductFactory=function(t){return function(u){var a=this,i=exports.useSSR(u),o=i.initialState,s=i.saveToInitialState,l=e.ref((null==o?void 0:o.data)||[]),c=e.ref((null==o?void 0:o.total)||0),v=e.ref((null==o?void 0:o.availableFilters)||null),f=e.ref((null==o?void 0:o.availableSortingOptions)||null),d=e.ref(!1);return{products:e.computed((function(){return l.value})),availableFilters:e.computed((function(){return v.value})),totalProducts:e.computed((function(){return c.value})),search:function(e){return r(a,void 0,void 0,(function(){var r,u,a,i,h;return n(this,(function(n){switch(n.label){case 0:o||(d.value=!0),v.value=null,n.label=1;case 1:return n.trys.push([1,,3,4]),[4,t.productsSearch(e)];case 2:return r=n.sent(),u=r.data,a=r.total,i=r.availableFilters,h=r.availableSortingOptions,l.value=u,c.value=a,v.value=i||null,f.value=h||null,s({data:u,total:a,availableFilters:i,availableSortingOptions:h}),[3,4];case 3:return d.value=!1,[7];case 4:return[2]}}))}))},availableSortingOptions:e.computed((function(){return f.value})),loading:e.computed((function(){return d.value}))}}},exports.useUserFactory=function(t){var u=!1,a=e.ref(null),i=e.ref(!1),o=e.computed((function(){return Boolean(a.value)}));return{useUser:function(){var l=exports.useSSR("vsf-user"),c=l.initialState,v=l.saveToInitialState;a.value=u?a.value:c||null,u=!0;var f=function(){return r(void 0,void 0,void 0,(function(){var e,r;return n(this,(function(n){switch(n.label){case 0:i.value=!0,n.label=1;case 1:return n.trys.push([1,3,4,5]),e=a,[4,t.loadUser()];case 2:return e.value=n.sent(),v(a.value),[3,5];case 3:throw r=n.sent(),new Error(r);case 4:return i.value=!1,[7];case 5:return[2]}}))}))};return s((function(){return r(void 0,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return a.value?[3,2]:[4,f()];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))})),{user:e.computed((function(){return a.value})),updateUser:function(e){return r(void 0,void 0,void 0,(function(){var r,u;return n(this,(function(n){switch(n.label){case 0:i.value=!0,n.label=1;case 1:return n.trys.push([1,3,4,5]),r=a,[4,t.updateUser({currentUser:a.value,updatedUserData:e})];case 2:return r.value=n.sent(),[3,5];case 3:throw u=n.sent(),new Error(u);case 4:return i.value=!1,[7];case 5:return[2]}}))}))},register:function(e){return r(void 0,void 0,void 0,(function(){var r,u;return n(this,(function(n){switch(n.label){case 0:i.value=!0,n.label=1;case 1:return n.trys.push([1,3,4,5]),r=a,[4,t.register(e)];case 2:return r.value=n.sent(),[3,5];case 3:throw u=n.sent(),new Error(u);case 4:return i.value=!1,[7];case 5:return[2]}}))}))},login:function(e){return r(void 0,void 0,void 0,(function(){var r,u;return n(this,(function(n){switch(n.label){case 0:i.value=!0,n.label=1;case 1:return n.trys.push([1,3,4,5]),r=a,[4,t.logIn(e)];case 2:return r.value=n.sent(),[3,5];case 3:throw u=n.sent(),new Error(u);case 4:return i.value=!1,[7];case 5:return[2]}}))}))},logout:function(){return r(void 0,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t.logOut()];case 1:return r.sent(),a.value=null,[3,3];case 2:throw e=r.sent(),new Error(e);case 3:return[2]}}))}))},isAuthenticated:o,changePassword:function(e,u){return r(void 0,void 0,void 0,(function(){var r,o;return n(this,(function(n){switch(n.label){case 0:i.value=!0,n.label=1;case 1:return n.trys.push([1,3,4,5]),r=a,[4,t.changePassword({currentUser:a.value,currentPassword:e,newPassword:u})];case 2:return r.value=n.sent(),[3,5];case 3:throw o=n.sent(),new Error(o);case 4:return i.value=!1,[7];case 5:return[2]}}))}))},refreshUser:f,loading:e.computed((function(){return i.value}))}},setUser:function(e){a.value=e}}},exports.useUserOrdersFactory=function(t){return function(){var u=this,a=exports.useSSR("vsf-user-orders"),i=a.initialState,o=a.saveToInitialState,s=e.ref((null==i?void 0:i.data)||[]),l=e.ref((null==i?void 0:i.total)||0),c=e.ref(!1);return{orders:e.computed((function(){return s.value})),totalOrders:e.computed((function(){return l.value})),searchOrders:function(e){return r(u,void 0,void 0,(function(){var r,u,a;return n(this,(function(n){switch(n.label){case 0:c.value=!0,n.label=1;case 1:return n.trys.push([1,,3,4]),[4,t.searchOrders(e)];case 2:return r=n.sent(),u=r.data,a=r.total,s.value=u,l.value=a,o({data:u,total:a}),[3,4];case 3:return c.value=!1,[7];case 4:return[2]}}))}))},loading:e.computed((function(){return c.value}))}}},exports.useWishlistFactory=function(t){var u=e.ref(!1),a=e.ref(null),i=!1;return{useWishlist:function(){var o=exports.useSSR("vsf-wishlist"),s=o.initialState,l=o.saveToInitialState;a.value=i?a.value:s||null,i=!0;return{wishlist:e.computed((function(){return a.value})),isOnWishlist:function(e){return t.isOnWishlist({currentWishlist:a.value,product:e})},addToWishlist:function(e){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return u.value=!0,[4,t.addToWishlist({currentWishlist:a.value,product:e})];case 1:return r=n.sent(),a.value=r,u.value=!1,[2]}}))}))},loadWishlist:function(){return r(void 0,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return a.value?[2]:(u.value=!0,e=a,[4,t.loadWishlist()]);case 1:return e.value=r.sent(),l(a.value),u.value=!1,[2]}}))}))},removeFromWishlist:function(e){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return u.value=!0,[4,t.removeFromWishlist({currentWishlist:a.value,product:e})];case 1:return r=n.sent(),a.value=r,u.value=!1,[2]}}))}))},clearWishlist:function(){return r(void 0,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return u.value=!0,[4,t.clearWishlist({currentWishlist:a.value})];case 1:return e=r.sent(),a.value=e,u.value=!1,[2]}}))}))},loading:e.computed((function(){return u.value}))}},setWishlist:function(e){a.value=e}}},exports.wrap=function(t){return e.isRef(t)?t:e.ref(t)}; | ||
***************************************************************************** */function r(e,t,r,n){return new(r||(r=Promise))((function(u,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function o(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){e.done?u(e.value):new r((function(t){t(e.value)})).then(i,o)}s((n=n.apply(e,t||[])).next())}))}function n(e,t){var r,n,u,a,i={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(u=2&a[0]?n.return:a[0]?n.throw||((u=n.return)&&u.call(n),0):n.next)&&!(u=u.call(n,a[1])).done)return u;switch(n=0,u&&(a=[2&a[0],u.value]),a[0]){case 0:case 1:u=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,n=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(u=i.trys,(u=u.length>0&&u[u.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!u||a[1]>u[0]&&a[1]<u[3])){i.label=a[1];break}if(6===a[0]&&i.label<u[1]){i.label=u[1],u=a;break}if(u&&i.label<u[2]){i.label=u[2],i.ops.push(a);break}u[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],n=0}finally{r=u=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}var u=[],a=[],i=function(e){return e.$isServer?e.$ssrContext.nuxt.vsfState:window.__VSF_STATE__||{}},o=0,s=function(t){var i,s=e.getCurrentInstance(),l=s.$isServer;l&&!s.$ssrContext.nuxt.vsfState&&(s.$ssrContext.nuxt.vsfState={}),e.onServerPrefetch((function(){return r(void 0,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return[4,t()];case 1:return e.sent(),r="set-ssr-cache",n=function(e){var t=e.key,r=e.value;s.$ssrContext.nuxt.vsfState[t]=r},u.push({eventName:r,handler:n}),a.filter((function(e){return e.eventName===r})).forEach((function(e){n(e.value)})),a=a.filter((function(e){return e.eventName!==r})),[2]}var r,n}))}))})),!l&&(i=window.__VSF_STATE__?JSON.stringify(window.__VSF_STATE__).length:0,o===i||(o=i,0))&&t()};exports.useSSR=function(t){var r=e.getCurrentInstance();r.$isServer&&!r.$ssrContext.nuxt.vsfState&&(r.$ssrContext.nuxt.vsfState={});return{saveToInitialState:function(e){!function(e,t){var r=u.filter((function(t){return t.eventName===e}));r.forEach((function(e){e.handler(t)})),0===r.length&&a.push({eventName:e,value:t})}("set-ssr-cache",{key:t,value:e})},initialState:i(r)[t]}};var l;(l=exports.AgnosticOrderStatus||(exports.AgnosticOrderStatus={})).Open="Open",l.Pending="Pending",l.Confirmed="Confirmed",l.Shipped="Shipped",l.Complete="Complete",l.Cancelled="Cancelled",l.Refunded="Refunded",exports.apiClientFactory=function(e){var r=t(t({},e.defaultSettings),{overrides:{}});return{override:function(e){r.overrides=t(t({},r.overrides),e)},setup:function(n){r=t(t(t({},e.defaultSettings),{overrides:r.overrides}),n),e.onSetup(r)},update:function(n){r=t(t({},r),n),e.onSetup(r)},getSettings:function(){return Object.freeze(r)}}},exports.configureSSR=function(e){exports.useSSR=e.useSSR},exports.onSSR=s,exports.useCartFactory=function(t){var u=e.ref(null),a=e.ref(!1),i=e.ref(null),o=!1;return{useCart:function(){var s=exports.useSSR("vsf-cart"),l=s.initialState,c=s.saveToInitialState;i.value=o?i.value:l||null,o=!0;return{cart:e.computed((function(){return i.value})),isOnCart:function(e){return t.isOnCart({currentCart:i.value,product:e})},addToCart:function(e,u){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return a.value=!0,[4,t.addToCart({currentCart:i.value,product:e,quantity:u})];case 1:return r=n.sent(),i.value=r,a.value=!1,[2]}}))}))},loadCart:function(){return r(void 0,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return i.value?[2]:(a.value=!0,e=i,[4,t.loadCart()]);case 1:return e.value=r.sent(),c(i.value),a.value=!1,[2]}}))}))},removeFromCart:function(e){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return a.value=!0,[4,t.removeFromCart({currentCart:i.value,product:e})];case 1:return r=n.sent(),i.value=r,a.value=!1,[2]}}))}))},clearCart:function(){return r(void 0,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return a.value=!0,[4,t.clearCart({currentCart:i.value})];case 1:return e=r.sent(),i.value=e,a.value=!1,[2]}}))}))},updateQuantity:function(e,u){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return u&&u>0?(a.value=!0,[4,t.updateQuantity({currentCart:i.value,product:e,quantity:u})]):[3,2];case 1:r=n.sent(),i.value=r,a.value=!1,n.label=2;case 2:return[2]}}))}))},coupon:e.computed((function(){return u.value})),applyCoupon:function(e){return r(void 0,void 0,void 0,(function(){var r,o,s;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,,2,3]),a.value=!0,[4,t.applyCoupon({currentCart:i.value,coupon:e})];case 1:return r=n.sent(),o=r.updatedCart,s=r.updatedCoupon,i.value=o,u.value=s,[3,3];case 2:return a.value=!1,[7];case 3:return[2]}}))}))},removeCoupon:function(){return r(void 0,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return r.trys.push([0,,2,3]),a.value=!0,[4,t.removeCoupon({currentCart:i.value,coupon:u.value})];case 1:return e=r.sent().updatedCart,i.value=e,u.value=null,a.value=!1,[3,3];case 2:return a.value=!1,[7];case 3:return[2]}}))}))},loading:e.computed((function(){return a.value}))}},setCart:function(e){i.value=e}}},exports.useCategoryFactory=function(t){return function(u){var a=this,i=exports.useSSR(u),o=i.initialState,s=i.saveToInitialState,l=e.ref(o||[]),c=e.ref(!1);return{search:function(e){return r(a,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return o||(c.value=!0),r=l,[4,t.categorySearch(e)];case 1:return r.value=n.sent(),s(l.value),c.value=!1,[2]}}))}))},loading:e.computed((function(){return c.value})),categories:e.computed((function(){return l.value}))}}},exports.useLocaleFactory=function(t){var u=this,a=e.ref(!1),i=e.ref(null),o=e.ref(null),s=e.ref(null),l=e.ref([]),c=e.ref([]),v=e.ref([]),f=function(e){return r(u,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return a.value=!0,r=i,[4,t.setLocale(e)];case 1:return r.value=n.sent(),a.value=!1,[2]}}))}))},d=function(e){return r(u,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return a.value=!0,r=o,[4,t.setCountry(e)];case 1:return r.value=n.sent(),a.value=!1,[2]}}))}))},h=function(e){return r(u,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return a.value=!0,r=s,[4,t.setCurrency(e)];case 1:return r.value=n.sent(),a.value=!1,[2]}}))}))},p=function(){return r(u,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return e=l,[4,t.loadAvailableLocales()];case 1:return e.value=r.sent(),[2]}}))}))},b=function(){return r(u,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return e=c,[4,t.loadAvailableCountries()];case 1:return e.value=r.sent(),[2]}}))}))},S=function(){return r(u,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return e=v,[4,t.loadAvailableCurrencies()];case 1:return e.value=r.sent(),[2]}}))}))};return function(){return{loadAvailableLocales:p,loadAvailableCountries:b,loadAvailableCurrencies:S,setCountry:d,setCurrency:h,setLocale:f,loading:e.computed((function(){return a.value})),locale:e.computed((function(){return i.value})),country:e.computed((function(){return o.value})),currency:e.computed((function(){return s.value})),availableLocales:e.computed((function(){return l.value})),availableCountries:e.computed((function(){return c.value})),availableCurrencies:e.computed((function(){return v.value}))}}},exports.useProductFactory=function(t){return function(u){var a=this,i=exports.useSSR(u),o=i.initialState,s=i.saveToInitialState,l=e.ref((null==o?void 0:o.data)||[]),c=e.ref((null==o?void 0:o.total)||0),v=e.ref((null==o?void 0:o.availableFilters)||null),f=e.ref((null==o?void 0:o.availableSortingOptions)||null),d=e.ref(!1);return{products:e.computed((function(){return l.value})),availableFilters:e.computed((function(){return v.value})),totalProducts:e.computed((function(){return c.value})),search:function(e){return r(a,void 0,void 0,(function(){var r,u,a,i,h;return n(this,(function(n){switch(n.label){case 0:o||(d.value=!0),v.value=null,n.label=1;case 1:return n.trys.push([1,,3,4]),[4,t.productsSearch(e)];case 2:return r=n.sent(),u=r.data,a=r.total,i=r.availableFilters,h=r.availableSortingOptions,l.value=u,c.value=a,v.value=i||null,f.value=h||null,s({data:u,total:a,availableFilters:i,availableSortingOptions:h}),[3,4];case 3:return d.value=!1,[7];case 4:return[2]}}))}))},availableSortingOptions:e.computed((function(){return f.value})),loading:e.computed((function(){return d.value}))}}},exports.useUserFactory=function(t){var u=!1,a=e.ref(null),i=e.ref(!1),o=e.computed((function(){return Boolean(a.value)}));return{useUser:function(){var l=exports.useSSR("vsf-user"),c=l.initialState,v=l.saveToInitialState;a.value=u?a.value:c||null,u=!0;var f=function(){return r(void 0,void 0,void 0,(function(){var e,r;return n(this,(function(n){switch(n.label){case 0:i.value=!0,n.label=1;case 1:return n.trys.push([1,3,4,5]),e=a,[4,t.loadUser()];case 2:return e.value=n.sent(),v(a.value),[3,5];case 3:throw r=n.sent(),new Error(r);case 4:return i.value=!1,[7];case 5:return[2]}}))}))};return s((function(){return r(void 0,void 0,void 0,(function(){return n(this,(function(e){switch(e.label){case 0:return a.value?[3,2]:[4,f()];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))})),{user:e.computed((function(){return a.value})),updateUser:function(e){return r(void 0,void 0,void 0,(function(){var r,u;return n(this,(function(n){switch(n.label){case 0:i.value=!0,n.label=1;case 1:return n.trys.push([1,3,4,5]),r=a,[4,t.updateUser({currentUser:a.value,updatedUserData:e})];case 2:return r.value=n.sent(),[3,5];case 3:throw u=n.sent(),new Error(u);case 4:return i.value=!1,[7];case 5:return[2]}}))}))},register:function(e){return r(void 0,void 0,void 0,(function(){var r,u;return n(this,(function(n){switch(n.label){case 0:i.value=!0,n.label=1;case 1:return n.trys.push([1,3,4,5]),r=a,[4,t.register(e)];case 2:return r.value=n.sent(),[3,5];case 3:throw u=n.sent(),new Error(u);case 4:return i.value=!1,[7];case 5:return[2]}}))}))},login:function(e){return r(void 0,void 0,void 0,(function(){var r,u;return n(this,(function(n){switch(n.label){case 0:i.value=!0,n.label=1;case 1:return n.trys.push([1,3,4,5]),r=a,[4,t.logIn(e)];case 2:return r.value=n.sent(),[3,5];case 3:throw u=n.sent(),new Error(u);case 4:return i.value=!1,[7];case 5:return[2]}}))}))},logout:function(){return r(void 0,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t.logOut()];case 1:return r.sent(),a.value=null,[3,3];case 2:throw e=r.sent(),new Error(e);case 3:return[2]}}))}))},isAuthenticated:o,changePassword:function(e,u){return r(void 0,void 0,void 0,(function(){var r,o;return n(this,(function(n){switch(n.label){case 0:i.value=!0,n.label=1;case 1:return n.trys.push([1,3,4,5]),r=a,[4,t.changePassword({currentUser:a.value,currentPassword:e,newPassword:u})];case 2:return r.value=n.sent(),[3,5];case 3:throw o=n.sent(),new Error(o);case 4:return i.value=!1,[7];case 5:return[2]}}))}))},refreshUser:f,loading:e.computed((function(){return i.value}))}},setUser:function(e){a.value=e}}},exports.useUserOrdersFactory=function(t){return function(){var u=this,a=exports.useSSR("vsf-user-orders"),i=a.initialState,o=a.saveToInitialState,s=e.ref((null==i?void 0:i.data)||[]),l=e.ref((null==i?void 0:i.total)||0),c=e.ref(!1);return{orders:e.computed((function(){return s.value})),totalOrders:e.computed((function(){return l.value})),searchOrders:function(e){return r(u,void 0,void 0,(function(){var r,u,a;return n(this,(function(n){switch(n.label){case 0:c.value=!0,n.label=1;case 1:return n.trys.push([1,,3,4]),[4,t.searchOrders(e)];case 2:return r=n.sent(),u=r.data,a=r.total,s.value=u,l.value=a,o({data:u,total:a}),[3,4];case 3:return c.value=!1,[7];case 4:return[2]}}))}))},loading:e.computed((function(){return c.value}))}}},exports.useWishlistFactory=function(t){var u=e.ref(!1),a=e.ref(null),i=!1;return{useWishlist:function(){var o=exports.useSSR("vsf-wishlist"),s=o.initialState,l=o.saveToInitialState;a.value=i?a.value:s||null,i=!0;return{wishlist:e.computed((function(){return a.value})),isOnWishlist:function(e){return t.isOnWishlist({currentWishlist:a.value,product:e})},addToWishlist:function(e){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return u.value=!0,[4,t.addToWishlist({currentWishlist:a.value,product:e})];case 1:return r=n.sent(),a.value=r,u.value=!1,[2]}}))}))},loadWishlist:function(){return r(void 0,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return a.value?[2]:(u.value=!0,e=a,[4,t.loadWishlist()]);case 1:return e.value=r.sent(),l(a.value),u.value=!1,[2]}}))}))},removeFromWishlist:function(e){return r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return u.value=!0,[4,t.removeFromWishlist({currentWishlist:a.value,product:e})];case 1:return r=n.sent(),a.value=r,u.value=!1,[2]}}))}))},clearWishlist:function(){return r(void 0,void 0,void 0,(function(){var e;return n(this,(function(r){switch(r.label){case 0:return u.value=!0,[4,t.clearWishlist({currentWishlist:a.value})];case 1:return e=r.sent(),a.value=e,u.value=!1,[2]}}))}))},loading:e.computed((function(){return u.value}))}},setWishlist:function(e){a.value=e}}},exports.wrap=function(t){return e.isRef(t)?t:e.ref(t)}; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -15,3 +15,3 @@ import{getCurrentInstance as e,onServerPrefetch as t,isRef as n,ref as r,computed as u}from"@vue/composition-api"; | ||
and limitations under the License. | ||
***************************************************************************** */var a=function(){return(a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var u in t=arguments[n])Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e}).apply(this,arguments)};function i(e,t,n,r){return new(n||(n=Promise))((function(u,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function o(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){e.done?u(e.value):new n((function(t){t(e.value)})).then(i,o)}l((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,u,a,i={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(u=2&a[0]?r.return:a[0]?r.throw||((u=r.return)&&u.call(r),0):r.next)&&!(u=u.call(r,a[1])).done)return u;switch(r=0,u&&(a=[2&a[0],u.value]),a[0]){case 0:case 1:u=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(u=i.trys,(u=u.length>0&&u[u.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!u||a[1]>u[0]&&a[1]<u[3])){i.label=a[1];break}if(6===a[0]&&i.label<u[1]){i.label=u[1],u=a;break}if(u&&i.label<u[2]){i.label=u[2],i.ops.push(a);break}u[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=u=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}var l=[],s=[],c=function(e){return e.$isServer?e.$ssrContext.nuxt.vsfState:window.__VSF_STATE__||{}},v=0,f=function(n){var r,u=e(),a=u.$isServer;a&&!u.$ssrContext.nuxt.vsfState&&(u.$ssrContext.nuxt.vsfState={}),t((function(){return i(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,n()];case 1:return e.sent(),t="set-ssr-cache",r=function(e){var t=e.key,n=e.value;u.$ssrContext.nuxt.vsfState[t]=n},l.push({eventName:t,handler:r}),s.filter((function(e){return e.eventName===t})).forEach((function(e){r(e.value)})),s=s.filter((function(e){return e.eventName!==t})),[2]}var t,r}))}))})),!a&&(r=window.__VSF_STATE__?JSON.stringify(window.__VSF_STATE__).length:0,v===r||(v=r,0))&&n()},d=function(t){var n=e();n.$isServer&&!n.$ssrContext.nuxt.vsfState&&(n.$ssrContext.nuxt.vsfState={});return{saveToInitialState:function(e){!function(e,t){var n=l.filter((function(t){return t.eventName===e}));n.forEach((function(e){e.handler(t)})),0===n.length&&s.push({eventName:e,value:t})}("set-ssr-cache",{key:t,value:e})},initialState:c(n)[t]}},h=function(e){d=e.useSSR};function p(e){return n(e)?e:r(e)}var b=function(e){var t=r(null),n=r(!1),a=r(null),l=!1;return{useCart:function(){var r=d("vsf-cart"),s=r.initialState,c=r.saveToInitialState;a.value=l?a.value:s||null,l=!0;return{cart:u((function(){return a.value})),isOnCart:function(t){return e.isOnCart({currentCart:a.value,product:t})},addToCart:function(t,r){return i(void 0,void 0,void 0,(function(){var u;return o(this,(function(i){switch(i.label){case 0:return n.value=!0,[4,e.addToCart({currentCart:a.value,product:t,quantity:r})];case 1:return u=i.sent(),a.value=u,n.value=!1,[2]}}))}))},loadCart:function(){return i(void 0,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return a.value?[2]:(n.value=!0,t=a,[4,e.loadCart()]);case 1:return t.value=r.sent(),c(a.value),n.value=!1,[2]}}))}))},removeFromCart:function(t){return i(void 0,void 0,void 0,(function(){var r;return o(this,(function(u){switch(u.label){case 0:return n.value=!0,[4,e.removeFromCart({currentCart:a.value,product:t})];case 1:return r=u.sent(),a.value=r,n.value=!1,[2]}}))}))},clearCart:function(){return i(void 0,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return n.value=!0,[4,e.clearCart({currentCart:a.value})];case 1:return t=r.sent(),a.value=t,n.value=!1,[2]}}))}))},updateQuantity:function(t,r){return i(void 0,void 0,void 0,(function(){var u;return o(this,(function(i){switch(i.label){case 0:return r&&r>0?(n.value=!0,[4,e.updateQuantity({currentCart:a.value,product:t,quantity:r})]):[3,2];case 1:u=i.sent(),a.value=u,n.value=!1,i.label=2;case 2:return[2]}}))}))},coupon:u((function(){return t.value})),applyCoupon:function(r){return i(void 0,void 0,void 0,(function(){var u,i,l;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,,2,3]),n.value=!0,[4,e.applyCoupon({currentCart:a.value,coupon:r})];case 1:return u=o.sent(),i=u.updatedCart,l=u.updatedCoupon,a.value=i,t.value=l,[3,3];case 2:return n.value=!1,[7];case 3:return[2]}}))}))},removeCoupon:function(){return i(void 0,void 0,void 0,(function(){var r,u,i;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,,2,3]),n.value=!0,[4,e.removeCoupon({currentCart:a.value})];case 1:return r=o.sent(),u=r.updatedCart,i=r.updatedCoupon,a.value=u,t.value=i,n.value=!1,[3,3];case 2:return n.value=!1,[7];case 3:return[2]}}))}))},loading:u((function(){return n.value}))}},setCart:function(e){a.value=e}}},w=function(e){var t=r(!1),n=r(null),a=!1;return{useWishlist:function(){var r=d("vsf-wishlist"),l=r.initialState,s=r.saveToInitialState;n.value=a?n.value:l||null,a=!0;return{wishlist:u((function(){return n.value})),isOnWishlist:function(t){return e.isOnWishlist({currentWishlist:n.value,product:t})},addToWishlist:function(r){return i(void 0,void 0,void 0,(function(){var u;return o(this,(function(a){switch(a.label){case 0:return t.value=!0,[4,e.addToWishlist({currentWishlist:n.value,product:r})];case 1:return u=a.sent(),n.value=u,t.value=!1,[2]}}))}))},loadWishlist:function(){return i(void 0,void 0,void 0,(function(){var r;return o(this,(function(u){switch(u.label){case 0:return n.value?[2]:(t.value=!0,r=n,[4,e.loadWishlist()]);case 1:return r.value=u.sent(),s(n.value),t.value=!1,[2]}}))}))},removeFromWishlist:function(r){return i(void 0,void 0,void 0,(function(){var u;return o(this,(function(a){switch(a.label){case 0:return t.value=!0,[4,e.removeFromWishlist({currentWishlist:n.value,product:r})];case 1:return u=a.sent(),n.value=u,t.value=!1,[2]}}))}))},clearWishlist:function(){return i(void 0,void 0,void 0,(function(){var r;return o(this,(function(u){switch(u.label){case 0:return t.value=!0,[4,e.clearWishlist({currentWishlist:n.value})];case 1:return r=u.sent(),n.value=r,t.value=!1,[2]}}))}))},loading:u((function(){return t.value}))}},setWishlist:function(e){n.value=e}}};function C(e){return function(t){var n=this,a=d(t),l=a.initialState,s=a.saveToInitialState,c=r(l||[]),v=r(!1);return{search:function(t){return i(n,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return l||(v.value=!0),n=c,[4,e.categorySearch(t)];case 1:return n.value=r.sent(),s(c.value),v.value=!1,[2]}}))}))},loading:u((function(){return v.value})),categories:u((function(){return c.value}))}}}function S(e){var t=this,n=r(!1),a=r(null),l=r(null),s=r(null),c=r([]),v=r([]),f=r([]),d=function(r){return i(t,void 0,void 0,(function(){var t;return o(this,(function(u){switch(u.label){case 0:return n.value=!0,t=a,[4,e.setLocale(r)];case 1:return t.value=u.sent(),n.value=!1,[2]}}))}))},h=function(r){return i(t,void 0,void 0,(function(){var t;return o(this,(function(u){switch(u.label){case 0:return n.value=!0,t=l,[4,e.setCountry(r)];case 1:return t.value=u.sent(),n.value=!1,[2]}}))}))},p=function(r){return i(t,void 0,void 0,(function(){var t;return o(this,(function(u){switch(u.label){case 0:return n.value=!0,t=s,[4,e.setCurrency(r)];case 1:return t.value=u.sent(),n.value=!1,[2]}}))}))},b=function(){return i(t,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=c,[4,e.loadAvailableLocales()];case 1:return t.value=n.sent(),[2]}}))}))},w=function(){return i(t,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=v,[4,e.loadAvailableCountries()];case 1:return t.value=n.sent(),[2]}}))}))},C=function(){return i(t,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=f,[4,e.loadAvailableCurrencies()];case 1:return t.value=n.sent(),[2]}}))}))};return function(){return{loadAvailableLocales:b,loadAvailableCountries:w,loadAvailableCurrencies:C,setCountry:h,setCurrency:p,setLocale:d,loading:u((function(){return n.value})),locale:u((function(){return a.value})),country:u((function(){return l.value})),currency:u((function(){return s.value})),availableLocales:u((function(){return c.value})),availableCountries:u((function(){return v.value})),availableCurrencies:u((function(){return f.value}))}}}function y(e){return function(t){var n=this,a=d(t),l=a.initialState,s=a.saveToInitialState,c=r((null==l?void 0:l.data)||[]),v=r((null==l?void 0:l.total)||0),f=r((null==l?void 0:l.availableFilters)||null),h=r((null==l?void 0:l.availableSortingOptions)||null),p=r(!1);return{products:u((function(){return c.value})),availableFilters:u((function(){return f.value})),totalProducts:u((function(){return v.value})),search:function(t){return i(n,void 0,void 0,(function(){var n,r,u,a,i;return o(this,(function(o){switch(o.label){case 0:l||(p.value=!0),f.value=null,o.label=1;case 1:return o.trys.push([1,,3,4]),[4,e.productsSearch(t)];case 2:return n=o.sent(),r=n.data,u=n.total,a=n.availableFilters,i=n.availableSortingOptions,c.value=r,v.value=u,f.value=a||null,h.value=i||null,s({data:r,total:u,availableFilters:a,availableSortingOptions:i}),[3,4];case 3:return p.value=!1,[7];case 4:return[2]}}))}))},availableSortingOptions:u((function(){return h.value})),loading:u((function(){return p.value}))}}}var g,m=function(e){var t=!1,n=r(null),a=r(!1),l=u((function(){return Boolean(n.value)}));return{useUser:function(){var r=d("vsf-user"),s=r.initialState,c=r.saveToInitialState;n.value=t?n.value:s||null,t=!0;var v=function(){return i(void 0,void 0,void 0,(function(){var t,r;return o(this,(function(u){switch(u.label){case 0:a.value=!0,u.label=1;case 1:return u.trys.push([1,3,4,5]),t=n,[4,e.loadUser()];case 2:return t.value=u.sent(),c(n.value),[3,5];case 3:throw r=u.sent(),new Error(r);case 4:return a.value=!1,[7];case 5:return[2]}}))}))};return f((function(){return i(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return n.value?[3,2]:[4,v()];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))})),{user:u((function(){return n.value})),updateUser:function(t){return i(void 0,void 0,void 0,(function(){var r,u;return o(this,(function(i){switch(i.label){case 0:a.value=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),r=n,[4,e.updateUser({currentUser:n.value,updatedUserData:t})];case 2:return r.value=i.sent(),[3,5];case 3:throw u=i.sent(),new Error(u);case 4:return a.value=!1,[7];case 5:return[2]}}))}))},register:function(t){return i(void 0,void 0,void 0,(function(){var r,u;return o(this,(function(i){switch(i.label){case 0:a.value=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),r=n,[4,e.register(t)];case 2:return r.value=i.sent(),[3,5];case 3:throw u=i.sent(),new Error(u);case 4:return a.value=!1,[7];case 5:return[2]}}))}))},login:function(t){return i(void 0,void 0,void 0,(function(){var r,u;return o(this,(function(i){switch(i.label){case 0:a.value=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),r=n,[4,e.logIn(t)];case 2:return r.value=i.sent(),[3,5];case 3:throw u=i.sent(),new Error(u);case 4:return a.value=!1,[7];case 5:return[2]}}))}))},logout:function(){return i(void 0,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e.logOut()];case 1:return r.sent(),n.value=null,[3,3];case 2:throw t=r.sent(),new Error(t);case 3:return[2]}}))}))},isAuthenticated:l,changePassword:function(t,r){return i(void 0,void 0,void 0,(function(){var u,i;return o(this,(function(o){switch(o.label){case 0:a.value=!0,o.label=1;case 1:return o.trys.push([1,3,4,5]),u=n,[4,e.changePassword({currentUser:n.value,currentPassword:t,newPassword:r})];case 2:return u.value=o.sent(),[3,5];case 3:throw i=o.sent(),new Error(i);case 4:return a.value=!1,[7];case 5:return[2]}}))}))},refreshUser:v,loading:u((function(){return a.value}))}},setUser:function(e){n.value=e}}};function O(e){return function(){var t=this,n=d("vsf-user-orders"),a=n.initialState,l=n.saveToInitialState,s=r((null==a?void 0:a.data)||[]),c=r((null==a?void 0:a.total)||0),v=r(!1);return{orders:u((function(){return s.value})),totalOrders:u((function(){return c.value})),searchOrders:function(n){return i(t,void 0,void 0,(function(){var t,r,u;return o(this,(function(a){switch(a.label){case 0:v.value=!0,a.label=1;case 1:return a.trys.push([1,,3,4]),[4,e.searchOrders(n)];case 2:return t=a.sent(),r=t.data,u=t.total,s.value=r,c.value=u,l({data:r,total:u}),[3,4];case 3:return v.value=!1,[7];case 4:return[2]}}))}))},loading:u((function(){return v.value}))}}}function x(e){var t=a(a({},e.defaultSettings),{overrides:{}});return{override:function(e){t.overrides=a(a({},t.overrides),e)},setup:function(n){t=a(a(a({},e.defaultSettings),{overrides:t.overrides}),n),e.onSetup(t)},update:function(n){t=a(a({},t),n),e.onSetup(t)},getSettings:function(){return Object.freeze(t)}}}!function(e){e.Open="Open",e.Pending="Pending",e.Confirmed="Confirmed",e.Shipped="Shipped",e.Complete="Complete",e.Cancelled="Cancelled",e.Refunded="Refunded"}(g||(g={}));export{g as AgnosticOrderStatus,x as apiClientFactory,h as configureSSR,f as onSSR,b as useCartFactory,C as useCategoryFactory,S as useLocaleFactory,y as useProductFactory,d as useSSR,m as useUserFactory,O as useUserOrdersFactory,w as useWishlistFactory,p as wrap}; | ||
***************************************************************************** */var a=function(){return(a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var u in t=arguments[n])Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e}).apply(this,arguments)};function i(e,t,n,r){return new(n||(n=Promise))((function(u,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function o(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){e.done?u(e.value):new n((function(t){t(e.value)})).then(i,o)}l((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,u,a,i={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(u=2&a[0]?r.return:a[0]?r.throw||((u=r.return)&&u.call(r),0):r.next)&&!(u=u.call(r,a[1])).done)return u;switch(r=0,u&&(a=[2&a[0],u.value]),a[0]){case 0:case 1:u=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(u=i.trys,(u=u.length>0&&u[u.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!u||a[1]>u[0]&&a[1]<u[3])){i.label=a[1];break}if(6===a[0]&&i.label<u[1]){i.label=u[1],u=a;break}if(u&&i.label<u[2]){i.label=u[2],i.ops.push(a);break}u[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=u=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}var l=[],s=[],c=function(e){return e.$isServer?e.$ssrContext.nuxt.vsfState:window.__VSF_STATE__||{}},v=0,f=function(n){var r,u=e(),a=u.$isServer;a&&!u.$ssrContext.nuxt.vsfState&&(u.$ssrContext.nuxt.vsfState={}),t((function(){return i(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,n()];case 1:return e.sent(),t="set-ssr-cache",r=function(e){var t=e.key,n=e.value;u.$ssrContext.nuxt.vsfState[t]=n},l.push({eventName:t,handler:r}),s.filter((function(e){return e.eventName===t})).forEach((function(e){r(e.value)})),s=s.filter((function(e){return e.eventName!==t})),[2]}var t,r}))}))})),!a&&(r=window.__VSF_STATE__?JSON.stringify(window.__VSF_STATE__).length:0,v===r||(v=r,0))&&n()},d=function(t){var n=e();n.$isServer&&!n.$ssrContext.nuxt.vsfState&&(n.$ssrContext.nuxt.vsfState={});return{saveToInitialState:function(e){!function(e,t){var n=l.filter((function(t){return t.eventName===e}));n.forEach((function(e){e.handler(t)})),0===n.length&&s.push({eventName:e,value:t})}("set-ssr-cache",{key:t,value:e})},initialState:c(n)[t]}},h=function(e){d=e.useSSR};function p(e){return n(e)?e:r(e)}var b=function(e){var t=r(null),n=r(!1),a=r(null),l=!1;return{useCart:function(){var r=d("vsf-cart"),s=r.initialState,c=r.saveToInitialState;a.value=l?a.value:s||null,l=!0;return{cart:u((function(){return a.value})),isOnCart:function(t){return e.isOnCart({currentCart:a.value,product:t})},addToCart:function(t,r){return i(void 0,void 0,void 0,(function(){var u;return o(this,(function(i){switch(i.label){case 0:return n.value=!0,[4,e.addToCart({currentCart:a.value,product:t,quantity:r})];case 1:return u=i.sent(),a.value=u,n.value=!1,[2]}}))}))},loadCart:function(){return i(void 0,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return a.value?[2]:(n.value=!0,t=a,[4,e.loadCart()]);case 1:return t.value=r.sent(),c(a.value),n.value=!1,[2]}}))}))},removeFromCart:function(t){return i(void 0,void 0,void 0,(function(){var r;return o(this,(function(u){switch(u.label){case 0:return n.value=!0,[4,e.removeFromCart({currentCart:a.value,product:t})];case 1:return r=u.sent(),a.value=r,n.value=!1,[2]}}))}))},clearCart:function(){return i(void 0,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return n.value=!0,[4,e.clearCart({currentCart:a.value})];case 1:return t=r.sent(),a.value=t,n.value=!1,[2]}}))}))},updateQuantity:function(t,r){return i(void 0,void 0,void 0,(function(){var u;return o(this,(function(i){switch(i.label){case 0:return r&&r>0?(n.value=!0,[4,e.updateQuantity({currentCart:a.value,product:t,quantity:r})]):[3,2];case 1:u=i.sent(),a.value=u,n.value=!1,i.label=2;case 2:return[2]}}))}))},coupon:u((function(){return t.value})),applyCoupon:function(r){return i(void 0,void 0,void 0,(function(){var u,i,l;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,,2,3]),n.value=!0,[4,e.applyCoupon({currentCart:a.value,coupon:r})];case 1:return u=o.sent(),i=u.updatedCart,l=u.updatedCoupon,a.value=i,t.value=l,[3,3];case 2:return n.value=!1,[7];case 3:return[2]}}))}))},removeCoupon:function(){return i(void 0,void 0,void 0,(function(){var r;return o(this,(function(u){switch(u.label){case 0:return u.trys.push([0,,2,3]),n.value=!0,[4,e.removeCoupon({currentCart:a.value,coupon:t.value})];case 1:return r=u.sent().updatedCart,a.value=r,t.value=null,n.value=!1,[3,3];case 2:return n.value=!1,[7];case 3:return[2]}}))}))},loading:u((function(){return n.value}))}},setCart:function(e){a.value=e}}},w=function(e){var t=r(!1),n=r(null),a=!1;return{useWishlist:function(){var r=d("vsf-wishlist"),l=r.initialState,s=r.saveToInitialState;n.value=a?n.value:l||null,a=!0;return{wishlist:u((function(){return n.value})),isOnWishlist:function(t){return e.isOnWishlist({currentWishlist:n.value,product:t})},addToWishlist:function(r){return i(void 0,void 0,void 0,(function(){var u;return o(this,(function(a){switch(a.label){case 0:return t.value=!0,[4,e.addToWishlist({currentWishlist:n.value,product:r})];case 1:return u=a.sent(),n.value=u,t.value=!1,[2]}}))}))},loadWishlist:function(){return i(void 0,void 0,void 0,(function(){var r;return o(this,(function(u){switch(u.label){case 0:return n.value?[2]:(t.value=!0,r=n,[4,e.loadWishlist()]);case 1:return r.value=u.sent(),s(n.value),t.value=!1,[2]}}))}))},removeFromWishlist:function(r){return i(void 0,void 0,void 0,(function(){var u;return o(this,(function(a){switch(a.label){case 0:return t.value=!0,[4,e.removeFromWishlist({currentWishlist:n.value,product:r})];case 1:return u=a.sent(),n.value=u,t.value=!1,[2]}}))}))},clearWishlist:function(){return i(void 0,void 0,void 0,(function(){var r;return o(this,(function(u){switch(u.label){case 0:return t.value=!0,[4,e.clearWishlist({currentWishlist:n.value})];case 1:return r=u.sent(),n.value=r,t.value=!1,[2]}}))}))},loading:u((function(){return t.value}))}},setWishlist:function(e){n.value=e}}};function S(e){return function(t){var n=this,a=d(t),l=a.initialState,s=a.saveToInitialState,c=r(l||[]),v=r(!1);return{search:function(t){return i(n,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return l||(v.value=!0),n=c,[4,e.categorySearch(t)];case 1:return n.value=r.sent(),s(c.value),v.value=!1,[2]}}))}))},loading:u((function(){return v.value})),categories:u((function(){return c.value}))}}}function C(e){var t=this,n=r(!1),a=r(null),l=r(null),s=r(null),c=r([]),v=r([]),f=r([]),d=function(r){return i(t,void 0,void 0,(function(){var t;return o(this,(function(u){switch(u.label){case 0:return n.value=!0,t=a,[4,e.setLocale(r)];case 1:return t.value=u.sent(),n.value=!1,[2]}}))}))},h=function(r){return i(t,void 0,void 0,(function(){var t;return o(this,(function(u){switch(u.label){case 0:return n.value=!0,t=l,[4,e.setCountry(r)];case 1:return t.value=u.sent(),n.value=!1,[2]}}))}))},p=function(r){return i(t,void 0,void 0,(function(){var t;return o(this,(function(u){switch(u.label){case 0:return n.value=!0,t=s,[4,e.setCurrency(r)];case 1:return t.value=u.sent(),n.value=!1,[2]}}))}))},b=function(){return i(t,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=c,[4,e.loadAvailableLocales()];case 1:return t.value=n.sent(),[2]}}))}))},w=function(){return i(t,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=v,[4,e.loadAvailableCountries()];case 1:return t.value=n.sent(),[2]}}))}))},S=function(){return i(t,void 0,void 0,(function(){var t;return o(this,(function(n){switch(n.label){case 0:return t=f,[4,e.loadAvailableCurrencies()];case 1:return t.value=n.sent(),[2]}}))}))};return function(){return{loadAvailableLocales:b,loadAvailableCountries:w,loadAvailableCurrencies:S,setCountry:h,setCurrency:p,setLocale:d,loading:u((function(){return n.value})),locale:u((function(){return a.value})),country:u((function(){return l.value})),currency:u((function(){return s.value})),availableLocales:u((function(){return c.value})),availableCountries:u((function(){return v.value})),availableCurrencies:u((function(){return f.value}))}}}function y(e){return function(t){var n=this,a=d(t),l=a.initialState,s=a.saveToInitialState,c=r((null==l?void 0:l.data)||[]),v=r((null==l?void 0:l.total)||0),f=r((null==l?void 0:l.availableFilters)||null),h=r((null==l?void 0:l.availableSortingOptions)||null),p=r(!1);return{products:u((function(){return c.value})),availableFilters:u((function(){return f.value})),totalProducts:u((function(){return v.value})),search:function(t){return i(n,void 0,void 0,(function(){var n,r,u,a,i;return o(this,(function(o){switch(o.label){case 0:l||(p.value=!0),f.value=null,o.label=1;case 1:return o.trys.push([1,,3,4]),[4,e.productsSearch(t)];case 2:return n=o.sent(),r=n.data,u=n.total,a=n.availableFilters,i=n.availableSortingOptions,c.value=r,v.value=u,f.value=a||null,h.value=i||null,s({data:r,total:u,availableFilters:a,availableSortingOptions:i}),[3,4];case 3:return p.value=!1,[7];case 4:return[2]}}))}))},availableSortingOptions:u((function(){return h.value})),loading:u((function(){return p.value}))}}}var g,m=function(e){var t=!1,n=r(null),a=r(!1),l=u((function(){return Boolean(n.value)}));return{useUser:function(){var r=d("vsf-user"),s=r.initialState,c=r.saveToInitialState;n.value=t?n.value:s||null,t=!0;var v=function(){return i(void 0,void 0,void 0,(function(){var t,r;return o(this,(function(u){switch(u.label){case 0:a.value=!0,u.label=1;case 1:return u.trys.push([1,3,4,5]),t=n,[4,e.loadUser()];case 2:return t.value=u.sent(),c(n.value),[3,5];case 3:throw r=u.sent(),new Error(r);case 4:return a.value=!1,[7];case 5:return[2]}}))}))};return f((function(){return i(void 0,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return n.value?[3,2]:[4,v()];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))})),{user:u((function(){return n.value})),updateUser:function(t){return i(void 0,void 0,void 0,(function(){var r,u;return o(this,(function(i){switch(i.label){case 0:a.value=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),r=n,[4,e.updateUser({currentUser:n.value,updatedUserData:t})];case 2:return r.value=i.sent(),[3,5];case 3:throw u=i.sent(),new Error(u);case 4:return a.value=!1,[7];case 5:return[2]}}))}))},register:function(t){return i(void 0,void 0,void 0,(function(){var r,u;return o(this,(function(i){switch(i.label){case 0:a.value=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),r=n,[4,e.register(t)];case 2:return r.value=i.sent(),[3,5];case 3:throw u=i.sent(),new Error(u);case 4:return a.value=!1,[7];case 5:return[2]}}))}))},login:function(t){return i(void 0,void 0,void 0,(function(){var r,u;return o(this,(function(i){switch(i.label){case 0:a.value=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),r=n,[4,e.logIn(t)];case 2:return r.value=i.sent(),[3,5];case 3:throw u=i.sent(),new Error(u);case 4:return a.value=!1,[7];case 5:return[2]}}))}))},logout:function(){return i(void 0,void 0,void 0,(function(){var t;return o(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e.logOut()];case 1:return r.sent(),n.value=null,[3,3];case 2:throw t=r.sent(),new Error(t);case 3:return[2]}}))}))},isAuthenticated:l,changePassword:function(t,r){return i(void 0,void 0,void 0,(function(){var u,i;return o(this,(function(o){switch(o.label){case 0:a.value=!0,o.label=1;case 1:return o.trys.push([1,3,4,5]),u=n,[4,e.changePassword({currentUser:n.value,currentPassword:t,newPassword:r})];case 2:return u.value=o.sent(),[3,5];case 3:throw i=o.sent(),new Error(i);case 4:return a.value=!1,[7];case 5:return[2]}}))}))},refreshUser:v,loading:u((function(){return a.value}))}},setUser:function(e){n.value=e}}};function O(e){return function(){var t=this,n=d("vsf-user-orders"),a=n.initialState,l=n.saveToInitialState,s=r((null==a?void 0:a.data)||[]),c=r((null==a?void 0:a.total)||0),v=r(!1);return{orders:u((function(){return s.value})),totalOrders:u((function(){return c.value})),searchOrders:function(n){return i(t,void 0,void 0,(function(){var t,r,u;return o(this,(function(a){switch(a.label){case 0:v.value=!0,a.label=1;case 1:return a.trys.push([1,,3,4]),[4,e.searchOrders(n)];case 2:return t=a.sent(),r=t.data,u=t.total,s.value=r,c.value=u,l({data:r,total:u}),[3,4];case 3:return v.value=!1,[7];case 4:return[2]}}))}))},loading:u((function(){return v.value}))}}}function x(e){var t=a(a({},e.defaultSettings),{overrides:{}});return{override:function(e){t.overrides=a(a({},t.overrides),e)},setup:function(n){t=a(a(a({},e.defaultSettings),{overrides:t.overrides}),n),e.onSetup(t)},update:function(n){t=a(a({},t),n),e.onSetup(t)},getSettings:function(){return Object.freeze(t)}}}!function(e){e.Open="Open",e.Pending="Pending",e.Confirmed="Confirmed",e.Shipped="Shipped",e.Complete="Complete",e.Cancelled="Cancelled",e.Refunded="Refunded"}(g||(g={}));export{g as AgnosticOrderStatus,x as apiClientFactory,h as configureSSR,f as onSSR,b as useCartFactory,S as useCategoryFactory,C as useLocaleFactory,y as useProductFactory,d as useSSR,m as useUserFactory,O as useUserOrdersFactory,w as useWishlistFactory,p as wrap}; | ||
//# sourceMappingURL=index.es.js.map |
@@ -30,5 +30,5 @@ import { UseCart } from '../types'; | ||
currentCart: CART; | ||
coupon: COUPON; | ||
}) => Promise<{ | ||
updatedCart: CART; | ||
updatedCoupon: COUPON; | ||
}>; | ||
@@ -35,0 +35,0 @@ isOnCart: (params: { |
{ | ||
"name": "@vue-storefront/core", | ||
"version": "2.0.1-prealpha.620+fa062e66a", | ||
"version": "2.0.1-prealpha.660+1f1e30ca5", | ||
"sideEffects": false, | ||
@@ -26,3 +26,3 @@ "main": "lib/index.cjs.js", | ||
}, | ||
"gitHead": "fa062e66a4753b03a0ffcce8b280ffd555c89872" | ||
"gitHead": "1f1e30ca5306e1ed61b060de093ba31ff9536816" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
136437
0.12%