@ikas/storefront-next 5.0.6 → 5.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__spreadArray as o,__assign as n}from'./../ext/tslib/tslib.es6.js';import r from"fs";import s from"next/config.js";import{IkasThemeJsonPageType as i}from"@ikas/storefront-models";import{IkasPageDataProvider as a}from"@ikas/storefront-providers";import{IkasStorefrontConfig as c}from"@ikas/storefront-config";import{getStorefrontSettings as l,listMerchantSettings as u,setAPIClientConfig as p,listCheckoutSettings as d}from"@ikas/storefront-api";import{getGoogleFontHref as g}from"../utils/google-fonts.js";import{I18NFileReader as f}from"../utils/i18n.js";import{createFile as m,deleteDirContent as h}from"../utils/fs.js";var S=function(){function S(){}return S.readLocalTheme=function(){return new Promise((function(e,t){r.readFile("./src/theme.json",{flag:"a+"},(function(o,n){if(o)return t(o);var r=n.length?JSON.parse(n.toString()):{};e(r)}))}))},S.readSettingsFile=function(){return new Promise((function(e){var t=s().serverRuntimeConfig.SETTINGS;r.readFile(t,{flag:"a+"},(function(t,o){if(t)return console.error("SETTINGS FILE READ ERROR!!!"),console.error(t),e(null);var n=o.length?JSON.parse(o.toString()):{};e(n)}))}))},S.cacheLocalSettingsFile=function(o){return e(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return[4,h(e=".ikas")];case 1:return t.sent(),n="settings-".concat(this.startTime,".json"),[4,m(e,n,JSON.stringify(o,null,2))];case 2:return t.sent(),[2]}}))}))},S.readLocalSettingsFile=function(){try{var e=r.readFileSync(".ikas/settings-".concat(this.startTime,".json"));if(e&&e.length)return JSON.parse(e.toString())}catch(e){}},S.getLocalSettings=function(o){return e(this,void 0,void 0,(function(){var e,n,r,s,i,a,c,u,p,d;return t(this,(function(t){switch(t.label){case 0:return[4,S.readLocalSettingsFile()];case 1:return(e=t.sent())?[3,4]:[4,l()];case 2:return(n=t.sent()).isSuccess&&n.data?(e=n.data,[4,this.cacheLocalSettingsFile(e)]):(console.error("Storefront settings fetch failed!"),console.error(n),[2,null]);case 3:t.sent(),t.label=4;case 4:return r=e.storefront,s=e.salesChannel,i=[],a=e.productBackInStockSettings?{customerLoginRequired:e.productBackInStockSettings.customerLoginRequired}:null,c=e.customerReviewSettings?{customerLoginRequired:e.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:e.customerReviewSettings.customerPurchaseRequired||!1}:null,[4,S.readLocalTheme()];case 5:return u=t.sent(),p=S.createColorScript(u.settings),[4,S.createFontScript(u.settings)];case 6:return d=t.sent(),p&&i.push(p),d&&i.push(d),[2,{storefront:r,themeLocalization:{id:"",locale:"en",privacyPolicy:null,returnPolicy:null,storefrontId:r.id,storefrontThemeId:"",termsOfService:null,imprint:null,shippingPolicy:null,themeJson:u},salesChannel:s,routing:r.routings.length?r.routings.find((function(e){return e.locale===o||e.id===o}))||r.routings[0]:{countryCodes:[],domain:"",dynamicCurrencySettings:{roundingFormat:null,targetCurrencyCode:""},id:"",locale:"en",path:null,priceListId:null,currencyCode:"USD",currencySymbol:"$"},favicon:u.settings.favicon,stockPreference:u.settings.stockPreference,storefrontJSScripts:i,highPriorityStoreFrontJSScripts:[],domain:"localhost:3333",productBackInStockSettings:a,customerReviewSettings:c,merchantSettings:e.merchantSettings,customerSettings:e.customerSettings}]}}))}))},S.getProdSettings=function(o){return e(this,void 0,void 0,(function(){var n=this;return t(this,(function(s){return[2,new Promise((function(s){return e(n,void 0,void 0,(function(){var n,i,a,c,l,p,d,g,f,m,h,v,C;return t(this,(function(I){switch(I.label){case 0:return[4,S.readSettingsFile()];case 1:return(n=I.sent())&&n.localizationMap?(i=n.storefront,a=n.salesChannel,c=n.localizationMap,l=n.storefrontJSScripts||[],p=n.highPriorityStoreFrontJSScripts||[],d=n.domain,g=n.productBackInStockSettings?{customerLoginRequired:n.productBackInStockSettings.customerLoginRequired}:null,f=n.customerReviewSettings?{customerLoginRequired:n.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:n.customerReviewSettings.customerPurchaseRequired||!1}:null,(m=n.merchantSettings)?[3,3]:[4,u({})]):[2,s(null)];case 2:if(!(h=I.sent()).isSuccess||!h.data)return console.error("MERCHANT SETTINGS FETCH FAILED!"),[2,s(null)];m=h.data,I.label=3;case 3:return m&&(m.address=null,delete m.merchantAddress),v=c[o],C=i.routings.find((function(e){return e.id===o||e.path===o})),v&&C?(r.readFile(v,{flag:"a+"},(function(o,r){return e(this,void 0,void 0,(function(){var e,c,u,h,v,I,y;return t(this,(function(t){switch(t.label){case 0:return o?(console.error("THEME LOCALIZATION FILE READ ERROR!!!"),console.error(o),[2,s(null)]):(e=r.length?JSON.parse(r.toString()):{},u=(c=e).themeJson.settings.favicon,h=c.themeJson.settings.stockPreference,c.themeJson.settings?(v=S.createColorScript(c.themeJson.settings),[4,S.createFontScript(c.themeJson.settings)]):[3,2]);case 1:I=t.sent(),v&&l.push(v),I&&l.push(I),t.label=2;case 2:return y=n.customerSettings,s({storefront:i,themeLocalization:c,salesChannel:a,routing:C,favicon:u,stockPreference:h,storefrontJSScripts:l,highPriorityStoreFrontJSScripts:p,domain:d,productBackInStockSettings:g,customerReviewSettings:f,merchantSettings:m,customerSettings:y,custom:n.custom}),[2]}}))}))})),[2]):(console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!"),[2,s(null)])}}))}))}))]}))}))},S.getSettings=function(o){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return"local"===process.env.NEXT_PUBLIC_ENV?[4,this.getLocalSettings(o)]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return[4,this.getProdSettings(o)]}}))}))},S.setStorefrontConfig=function(o){var n;return e(this,void 0,void 0,(function(){var e,r,s,i,a,l,u,d,g,f,m,h;return t(this,(function(t){return e=o.storefront,r=o.salesChannel,s=o.routing,i=o.favicon,a=o.stockPreference,l=o.storefrontJSScripts,u=o.domain,d=o.productBackInStockSettings,g=o.customerReviewSettings,f=o.merchantSettings,m=o.customerSettings,h=o.custom,c.init({apiUrl:process.env.NEXT_PUBLIC_GQL_URL,cdnUrl:process.env.NEXT_PUBLIC_CDN_URL,storefrontId:e.id,storefrontRoutingId:s.id,storefrontThemeId:e.mainStorefrontThemeId,storefrontB2BSettings:e.b2bSettings||void 0,storefrontType:e.type,salesChannelId:e.salesChannelId,priceListId:s.priceListId||void 0,stockLocationIds:null===(n=r.stockLocations)||void 0===n?void 0:n.map((function(e){return e.id})),routings:e.routings,paymentGateways:r.paymentGateways||[],gtmId:e.gtmId||void 0,fbpId:e.fbpId||void 0,analytics4Id:e.analytics4Id||void 0,universalAnalyticsId:e.universalAnalyticsId||void 0,tiktokPixelId:e.tiktokPixelId||void 0,favicon:i||null,pickUpStockLocationIds:e.pickUpStockLocationIds&&e.pickUpStockLocationIds.length?e.pickUpStockLocationIds:null,stockPreference:a||null,storefrontJSScripts:l||[],domain:u,productBackInStockSettings:d,customerReviewSettings:g,merchantSettings:f,customerSettings:m,metaTemplates:e.metaTemplates||null,custom:h||null,indexPageSeoSettings:e.indexPageSeoSettings}),p(),[2]}))}))},S.setTranslations=function(n,r,a,l,u){return e(this,void 0,void 0,(function(){var e,p,d,g,m,h,S,v;return t(this,(function(t){switch(t.label){case 0:return e=s().serverRuntimeConfig,p=n.routing,d="local"===process.env.NEXT_PUBLIC_ENV,g=n.themeLocalization.themeJson.components.filter((function(e){return l||r.includes(e.id)})),m=o(["common"],g.map((function(e){return e.dir})),!0),(a===i.CHECKOUT||l)&&m.push("checkout-page"),h=e.nextI18nConf,S=d&&u?u:p.locale,[4,new f(S,m,d?void 0:h.localePath).read()];case 1:return v=t.sent(),c.init({translations:v}),[2]}}))}))},S.getExtraProps=function(o,n,r){var s,a,c,l,u,p,g,f,m,h,S,v,C,I,y,L,P,T,w,k,O,B;return e(this,void 0,void 0,(function(){var e,b,R,E,V;return t(this,(function(t){switch(t.label){case 0:return e={},b=o.themeLocalization,r!==i.CHECKOUT?[3,2]:(R=null===(s=n.page)||void 0===s?void 0:s.components[0])?[4,d({})]:[3,2];case 1:(E=t.sent()).isSuccess||(console.error("CHECKOUT SETTINGS FETCH FAILED!"),console.error(E.graphQLErrors),console.error(E.errorCodes)),V={logo:null!==(a=R.propValues.logo)&&void 0!==a?a:null,showTax:null===(c=R.propValues.showTax)||void 0===c||c,showCampaignOffersDesign:null!==(l=R.propValues.showCampaignOffersDesign)&&void 0!==l&&l,showCampaignIsBiggerImage:null!==(u=R.propValues.showCampaignIsBiggerImage)&&void 0!==u&&u,campaignOfferIsSmallDesign:null!==(p=R.propValues.campaignOfferIsSmallDesign)&&void 0!==p&&p,showCampaignHideDiscountBadge:null!==(g=R.propValues.showCampaignHideDiscountBadge)&&void 0!==g&&g,campaignOfferCountdownStyleIsLine:null!==(f=R.propValues.campaignOfferCountdownStyleIsLine)&&void 0!==f&&f,campaignOfferCountdownStyleIsLineSuccessPage:null!==(m=R.propValues.campaignOfferCountdownStyleIsLineSuccessPage)&&void 0!==m&&m,campaignOffersEnableMiddlePhase:null!==(h=R.propValues.campaignOffersEnableMiddlePhase)&&void 0!==h&&h,campaignOffersTitleColor:null!==(S=R.propValues.campaignOffersTitleColor)&&void 0!==S?S:null,campaignOffersDescriptionColor:null!==(v=R.propValues.campaignOffersDescriptionColor)&&void 0!==v?v:null,campaignOffersDiscountPercentageColor:null!==(C=R.propValues.campaignOffersDiscountPercentageColor)&&void 0!==C?C:null,campaignOffersDiscountPercentageBgColor:null!==(I=R.propValues.campaignOffersDiscountPercentageBgColor)&&void 0!==I?I:null,campaignOffersCountdownTextColor:null!==(y=R.propValues.campaignOffersCountdownTextColor)&&void 0!==y?y:null,campaignOffersCountdownTimeColor:null!==(L=R.propValues.campaignOffersCountdownTimeColor)&&void 0!==L?L:null,campaignOffersCountdownBgColor:null!==(P=R.propValues.campaignOffersCountdownBgColor)&&void 0!==P?P:null,campaignOffersMiddlePhaseOverlayColor:null!==(T=R.propValues.campaignOffersMiddlePhaseOverlayColor)&&void 0!==T?T:null,buttonBgColor:R.propValues.buttonBgColor,buttonTextColor:R.propValues.buttonTextColor,buttonDisabledBgColor:R.propValues.buttonDisabledBgColor,buttonDisabledTextColor:R.propValues.buttonDisabledTextColor,primaryTextColor:R.propValues.primaryTextColor,secondaryTextColor:R.propValues.secondaryTextColor,primaryBgColor:R.propValues.primaryBgColor,secondaryBgColor:R.propValues.secondaryBgColor,borderColor:R.propValues.borderColor,cardBgColor:R.propValues.cardBgColor,errorColor:R.propValues.errorColor,errorLightColor:R.propValues.errorLightColor,warningColor:R.propValues.warningColor,warningLightColor:R.propValues.warningLightColor,successColor:R.propValues.successColor,successLightColor:R.propValues.successLightColor,secondaryButtonBgColor:null!==(w=R.propValues.secondaryButtonBgColor)&&void 0!==w?w:null,secondaryButtonTextColor:null!==(k=R.propValues.secondaryButtonTextColor)&&void 0!==k?k:null,secondaryButtonBorderColor:null!==(O=R.propValues.secondaryButtonBorderColor)&&void 0!==O?O:null},e.customizationProps=V,e.returnPolicy=b.returnPolicy,e.privacyPolicy=b.privacyPolicy,e.termsOfService=b.termsOfService,e.imprint=b.imprint,e.shippingPolicy=b.shippingPolicy,e.checkoutSettings=(null===(B=null==E?void 0:E.data)||void 0===B?void 0:B.length)?E.data[0]:null,t.label=2;case 2:return[2,e]}}))}))},S.getPageData=function(o,r,s,i,l){var u;return e(this,void 0,void 0,(function(){var e,d,g,f,m,h,v,C;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,d=!e&&l,c.init({apiUrl:process.env.NEXT_PUBLIC_GQL_URL,cdnUrl:process.env.NEXT_PUBLIC_CDN_URL}),p(),d?[3,7]:(g=o.locale)?[4,S.getSettings(g)]:[2,{props:{},notFound:!0}];case 1:return(f=t.sent())&&f.storefront.mainStorefrontThemeId&&f.storefront.salesChannelId?[4,this.setStorefrontConfig(f)]:[2,{props:{},notFound:!0}];case 2:return t.sent(),m=f.themeLocalization,(h=new a(m.themeJson,o.params,s,f.merchantSettings)).possiblePageTypes=i||(s?[s]:[]),l?[3,4]:[4,h.getPageData()];case 3:if(t.sent(),!h.page)return[2,{props:{},notFound:!0}];t.label=4;case 4:return v=l?h.theme.components.map((function(e){return e.id})):(null===(u=h.page)||void 0===u?void 0:u.components.map((function(e){return e.componentId})))||[],[4,this.setTranslations(f,v,s,l,g)];case 5:return t.sent(),[4,this.getExtraProps(f,h,s)];case 6:return C=t.sent(),r?[2,{props:n(n({},h.nextPageData.props),C)}]:[2,{props:n(n({},h.nextPageData.props),C),revalidate:60}];case 7:return[2,{props:{}}];case 8:return[2]}}))}))},S.getStaticProps=function(o,n,r,s){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,S.getPageData(o,!1,n,r,s)];case 1:return[2,e.sent()]}}))}))},S.getServerSideProps=function(o,n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,S.getPageData(o,!0,n)];case 1:return[2,e.sent()]}}))}))},S.createColorScript=function(e){if(e.colors)return"<script>".concat(e.colors.map((function(e){return'document.documentElement.style.setProperty("'.concat(e.key,'","').concat(e.color,'");')})).join("\r\n"),"<\/script> \n ")},S.createFontScript=function(o){return e(this,void 0,void 0,(function(){var e,n,r;return t(this,(function(t){switch(t.label){case 0:return(e=g(o.fontFamily))?[4,fetch(e,{headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36"}})]:[3,3];case 1:return[4,t.sent().text()];case 2:return n=t.sent(),r=n.replace(new RegExp("fonts.gstatic.com","g"),"fonts.myikas.com"),[2,"<style>\n ".concat(r,"\n\n body { \n font-family: '").concat(o.fontFamily.name,'\', -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;\n } \n\n </style>')];case 3:return[2]}}))}))},S.startTime=Date.now(),S}();export{S as IkasNextPageDataProvider};
1
+ import{__awaiter as e,__generator as t,__spreadArray as o,__assign as n}from'./../ext/tslib/tslib.es6.js';import r from"fs";import i from"next/config.js";import{IkasThemeJsonPageType as s}from"@ikas/storefront-models";import{IkasPageDataProvider as a}from"@ikas/storefront-providers";import{IkasStorefrontConfig as c}from"@ikas/storefront-config";import{getStorefrontSettings as l,listMerchantSettings as u,setAPIClientConfig as p,listCheckoutSettings as g}from"@ikas/storefront-api";import{getGoogleFontHref as d}from"../utils/google-fonts.js";import{I18NFileReader as f}from"../utils/i18n.js";import{createFile as m,deleteDirContent as h}from"../utils/fs.js";var S=function(){function S(){}return S.readLocalTheme=function(){return new Promise((function(e,t){r.readFile("./src/theme.json",{flag:"a+"},(function(o,n){if(o)return t(o);var r=n.length?JSON.parse(n.toString()):{};e(r)}))}))},S.readSettingsFile=function(){return new Promise((function(e){var t=i().serverRuntimeConfig.SETTINGS;r.readFile(t,{flag:"a+"},(function(t,o){if(t)return console.error("SETTINGS FILE READ ERROR!!!"),console.error(t),e(null);var n=o.length?JSON.parse(o.toString()):{};e(n)}))}))},S.cacheLocalSettingsFile=function(o){return e(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:return[4,h(e=".ikas")];case 1:return t.sent(),n="settings-".concat(this.startTime,".json"),[4,m(e,n,JSON.stringify(o,null,2))];case 2:return t.sent(),[2]}}))}))},S.readLocalSettingsFile=function(){try{var e=r.readFileSync(".ikas/settings-".concat(this.startTime,".json"));if(e&&e.length)return JSON.parse(e.toString())}catch(e){}},S.getLocalSettings=function(o){return e(this,void 0,void 0,(function(){var e,n,r,i,s,a,c,u,p,g;return t(this,(function(t){switch(t.label){case 0:return[4,S.readLocalSettingsFile()];case 1:return(e=t.sent())?[3,4]:[4,l()];case 2:return(n=t.sent()).isSuccess&&n.data?(e=n.data,[4,this.cacheLocalSettingsFile(e)]):(console.error("Storefront settings fetch failed!"),console.error(n),[2,null]);case 3:t.sent(),t.label=4;case 4:return r=e.storefront,i=e.salesChannel,s=[],a=e.productBackInStockSettings?{customerLoginRequired:e.productBackInStockSettings.customerLoginRequired}:null,c=e.customerReviewSettings?{customerLoginRequired:e.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:e.customerReviewSettings.customerPurchaseRequired||!1}:null,[4,S.readLocalTheme()];case 5:return u=t.sent(),p=S.createColorScript(u.settings),[4,S.createFontScript(u.settings)];case 6:return g=t.sent(),p&&s.push(p),g&&s.push(g),[2,{storefront:r,themeLocalization:{id:"",locale:"en",privacyPolicy:null,returnPolicy:null,storefrontId:r.id,storefrontThemeId:"",termsOfService:null,imprint:null,shippingPolicy:null,themeJson:u},salesChannel:i,routing:r.routings.length?r.routings.find((function(e){return e.locale===o||e.id===o}))||r.routings[0]:{countryCodes:[],domain:"",dynamicCurrencySettings:{roundingFormat:null,targetCurrencyCode:""},id:"",locale:"en",path:null,priceListId:null,currencyCode:"USD",currencySymbol:"$"},favicon:u.settings.favicon,stockPreference:u.settings.stockPreference,storefrontJSScripts:s,highPriorityStoreFrontJSScripts:[],domain:"localhost:3333",productBackInStockSettings:a,customerReviewSettings:c,merchantSettings:e.merchantSettings,customerSettings:e.customerSettings}]}}))}))},S.getProdSettings=function(o){return e(this,void 0,void 0,(function(){var n=this;return t(this,(function(i){return[2,new Promise((function(i){return e(n,void 0,void 0,(function(){var n,s,a,c,l,p,g,d,f,m,h,v,C;return t(this,(function(I){switch(I.label){case 0:return[4,S.readSettingsFile()];case 1:return(n=I.sent())&&n.localizationMap?(s=n.storefront,a=n.salesChannel,c=n.localizationMap,l=n.storefrontJSScripts||[],p=n.highPriorityStoreFrontJSScripts||[],g=n.domain,d=n.productBackInStockSettings?{customerLoginRequired:n.productBackInStockSettings.customerLoginRequired}:null,f=n.customerReviewSettings?{customerLoginRequired:n.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:n.customerReviewSettings.customerPurchaseRequired||!1}:null,(m=n.merchantSettings)?[3,3]:[4,u({})]):[2,i(null)];case 2:if(!(h=I.sent()).isSuccess||!h.data)return console.error("MERCHANT SETTINGS FETCH FAILED!"),[2,i(null)];m=h.data,I.label=3;case 3:return m&&(m.address=null,delete m.merchantAddress),v=c[o],C=s.routings.find((function(e){return e.id===o||e.path===o})),v&&C?(r.readFile(v,{flag:"a+"},(function(o,r){return e(this,void 0,void 0,(function(){var e,c,u,h,v,I,y;return t(this,(function(t){switch(t.label){case 0:return o?(console.error("THEME LOCALIZATION FILE READ ERROR!!!"),console.error(o),[2,i(null)]):(e=r.length?JSON.parse(r.toString()):{},u=(c=e).themeJson.settings.favicon,h=c.themeJson.settings.stockPreference,c.themeJson.settings?(v=S.createColorScript(c.themeJson.settings),[4,S.createFontScript(c.themeJson.settings)]):[3,2]);case 1:I=t.sent(),v&&l.push(v),I&&l.push(I),t.label=2;case 2:return y=n.customerSettings,i({storefront:s,themeLocalization:c,salesChannel:a,routing:C,favicon:u,stockPreference:h,storefrontJSScripts:l,highPriorityStoreFrontJSScripts:p,domain:g,productBackInStockSettings:d,customerReviewSettings:f,merchantSettings:m,customerSettings:y,custom:n.custom}),[2]}}))}))})),[2]):(console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!"),[2,i(null)])}}))}))}))]}))}))},S.getSettings=function(o){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return"local"===process.env.NEXT_PUBLIC_ENV?[4,this.getLocalSettings(o)]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return[4,this.getProdSettings(o)]}}))}))},S.setStorefrontConfig=function(o){var n;return e(this,void 0,void 0,(function(){var e,r,i,s,a,l,u,g,d,f,m,h,S;return t(this,(function(t){return e=o.storefront,r=o.salesChannel,i=o.routing,s=o.favicon,a=o.stockPreference,l=o.storefrontJSScripts,u=o.highPriorityStoreFrontJSScripts,g=o.domain,d=o.productBackInStockSettings,f=o.customerReviewSettings,m=o.merchantSettings,h=o.customerSettings,S=o.custom,c.init({apiUrl:process.env.NEXT_PUBLIC_GQL_URL,cdnUrl:process.env.NEXT_PUBLIC_CDN_URL,storefrontId:e.id,storefrontRoutingId:i.id,storefrontThemeId:e.mainStorefrontThemeId,storefrontB2BSettings:e.b2bSettings||void 0,storefrontType:e.type,salesChannelId:e.salesChannelId,priceListId:i.priceListId||void 0,stockLocationIds:null===(n=r.stockLocations)||void 0===n?void 0:n.map((function(e){return e.id})),routings:e.routings,paymentGateways:r.paymentGateways||[],gtmId:e.gtmId||void 0,fbpId:e.fbpId||void 0,analytics4Id:e.analytics4Id||void 0,universalAnalyticsId:e.universalAnalyticsId||void 0,tiktokPixelId:e.tiktokPixelId||void 0,favicon:s||null,pickUpStockLocationIds:e.pickUpStockLocationIds&&e.pickUpStockLocationIds.length?e.pickUpStockLocationIds:null,stockPreference:a||null,storefrontJSScripts:l||[],highPriorityStoreFrontJSScripts:u||[],domain:g,productBackInStockSettings:d,customerReviewSettings:f,merchantSettings:m,customerSettings:h,metaTemplates:e.metaTemplates||null,custom:S||null,indexPageSeoSettings:e.indexPageSeoSettings}),p(),[2]}))}))},S.setTranslations=function(n,r,a,l,u){return e(this,void 0,void 0,(function(){var e,p,g,d,m,h,S,v;return t(this,(function(t){switch(t.label){case 0:return e=i().serverRuntimeConfig,p=n.routing,g="local"===process.env.NEXT_PUBLIC_ENV,d=n.themeLocalization.themeJson.components.filter((function(e){return l||r.includes(e.id)})),m=o(["common"],d.map((function(e){return e.dir})),!0),(a===s.CHECKOUT||l)&&m.push("checkout-page"),h=e.nextI18nConf,S=g&&u?u:p.locale,[4,new f(S,m,g?void 0:h.localePath).read()];case 1:return v=t.sent(),c.init({translations:v}),[2]}}))}))},S.getExtraProps=function(o,n,r){var i,a,c,l,u,p,d,f,m,h,S,v,C,I,y,P,L,T,w,k,O,B;return e(this,void 0,void 0,(function(){var e,b,R,E,V;return t(this,(function(t){switch(t.label){case 0:return e={},b=o.themeLocalization,r!==s.CHECKOUT?[3,2]:(R=null===(i=n.page)||void 0===i?void 0:i.components[0])?[4,g({})]:[3,2];case 1:(E=t.sent()).isSuccess||(console.error("CHECKOUT SETTINGS FETCH FAILED!"),console.error(E.graphQLErrors),console.error(E.errorCodes)),V={logo:null!==(a=R.propValues.logo)&&void 0!==a?a:null,showTax:null===(c=R.propValues.showTax)||void 0===c||c,showCampaignOffersDesign:null!==(l=R.propValues.showCampaignOffersDesign)&&void 0!==l&&l,showCampaignIsBiggerImage:null!==(u=R.propValues.showCampaignIsBiggerImage)&&void 0!==u&&u,campaignOfferIsSmallDesign:null!==(p=R.propValues.campaignOfferIsSmallDesign)&&void 0!==p&&p,showCampaignHideDiscountBadge:null!==(d=R.propValues.showCampaignHideDiscountBadge)&&void 0!==d&&d,campaignOfferCountdownStyleIsLine:null!==(f=R.propValues.campaignOfferCountdownStyleIsLine)&&void 0!==f&&f,campaignOfferCountdownStyleIsLineSuccessPage:null!==(m=R.propValues.campaignOfferCountdownStyleIsLineSuccessPage)&&void 0!==m&&m,campaignOffersEnableMiddlePhase:null!==(h=R.propValues.campaignOffersEnableMiddlePhase)&&void 0!==h&&h,campaignOffersTitleColor:null!==(S=R.propValues.campaignOffersTitleColor)&&void 0!==S?S:null,campaignOffersDescriptionColor:null!==(v=R.propValues.campaignOffersDescriptionColor)&&void 0!==v?v:null,campaignOffersDiscountPercentageColor:null!==(C=R.propValues.campaignOffersDiscountPercentageColor)&&void 0!==C?C:null,campaignOffersDiscountPercentageBgColor:null!==(I=R.propValues.campaignOffersDiscountPercentageBgColor)&&void 0!==I?I:null,campaignOffersCountdownTextColor:null!==(y=R.propValues.campaignOffersCountdownTextColor)&&void 0!==y?y:null,campaignOffersCountdownTimeColor:null!==(P=R.propValues.campaignOffersCountdownTimeColor)&&void 0!==P?P:null,campaignOffersCountdownBgColor:null!==(L=R.propValues.campaignOffersCountdownBgColor)&&void 0!==L?L:null,campaignOffersMiddlePhaseOverlayColor:null!==(T=R.propValues.campaignOffersMiddlePhaseOverlayColor)&&void 0!==T?T:null,buttonBgColor:R.propValues.buttonBgColor,buttonTextColor:R.propValues.buttonTextColor,buttonDisabledBgColor:R.propValues.buttonDisabledBgColor,buttonDisabledTextColor:R.propValues.buttonDisabledTextColor,primaryTextColor:R.propValues.primaryTextColor,secondaryTextColor:R.propValues.secondaryTextColor,primaryBgColor:R.propValues.primaryBgColor,secondaryBgColor:R.propValues.secondaryBgColor,borderColor:R.propValues.borderColor,cardBgColor:R.propValues.cardBgColor,errorColor:R.propValues.errorColor,errorLightColor:R.propValues.errorLightColor,warningColor:R.propValues.warningColor,warningLightColor:R.propValues.warningLightColor,successColor:R.propValues.successColor,successLightColor:R.propValues.successLightColor,secondaryButtonBgColor:null!==(w=R.propValues.secondaryButtonBgColor)&&void 0!==w?w:null,secondaryButtonTextColor:null!==(k=R.propValues.secondaryButtonTextColor)&&void 0!==k?k:null,secondaryButtonBorderColor:null!==(O=R.propValues.secondaryButtonBorderColor)&&void 0!==O?O:null},e.customizationProps=V,e.returnPolicy=b.returnPolicy,e.privacyPolicy=b.privacyPolicy,e.termsOfService=b.termsOfService,e.imprint=b.imprint,e.shippingPolicy=b.shippingPolicy,e.checkoutSettings=(null===(B=null==E?void 0:E.data)||void 0===B?void 0:B.length)?E.data[0]:null,t.label=2;case 2:return[2,e]}}))}))},S.getPageData=function(o,r,i,s,l){var u;return e(this,void 0,void 0,(function(){var e,g,d,f,m,h,v,C;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,g=!e&&l,c.init({apiUrl:process.env.NEXT_PUBLIC_GQL_URL,cdnUrl:process.env.NEXT_PUBLIC_CDN_URL}),p(),g?[3,7]:(d=o.locale)?[4,S.getSettings(d)]:[2,{props:{},notFound:!0}];case 1:return(f=t.sent())&&f.storefront.mainStorefrontThemeId&&f.storefront.salesChannelId?[4,this.setStorefrontConfig(f)]:[2,{props:{},notFound:!0}];case 2:return t.sent(),m=f.themeLocalization,(h=new a(m.themeJson,o.params,i,f.merchantSettings)).possiblePageTypes=s||(i?[i]:[]),l?[3,4]:[4,h.getPageData()];case 3:if(t.sent(),!h.page)return[2,{props:{},notFound:!0}];t.label=4;case 4:return v=l?h.theme.components.map((function(e){return e.id})):(null===(u=h.page)||void 0===u?void 0:u.components.map((function(e){return e.componentId})))||[],[4,this.setTranslations(f,v,i,l,d)];case 5:return t.sent(),[4,this.getExtraProps(f,h,i)];case 6:return C=t.sent(),r?[2,{props:n(n({},h.nextPageData.props),C)}]:[2,{props:n(n({},h.nextPageData.props),C),revalidate:60}];case 7:return[2,{props:{}}];case 8:return[2]}}))}))},S.getStaticProps=function(o,n,r,i){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,S.getPageData(o,!1,n,r,i)];case 1:return[2,e.sent()]}}))}))},S.getServerSideProps=function(o,n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,S.getPageData(o,!0,n)];case 1:return[2,e.sent()]}}))}))},S.createColorScript=function(e){if(e.colors)return"<script>".concat(e.colors.map((function(e){return'document.documentElement.style.setProperty("'.concat(e.key,'","').concat(e.color,'");')})).join("\r\n"),"<\/script> \n ")},S.createFontScript=function(o){return e(this,void 0,void 0,(function(){var e,n,r;return t(this,(function(t){switch(t.label){case 0:return(e=d(o.fontFamily))?[4,fetch(e,{headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36"}})]:[3,3];case 1:return[4,t.sent().text()];case 2:return n=t.sent(),r=n.replace(new RegExp("fonts.gstatic.com","g"),"fonts.myikas.com"),[2,"<style>\n ".concat(r,"\n\n body { \n font-family: '").concat(o.fontFamily.name,'\', -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;\n } \n\n </style>')];case 3:return[2]}}))}))},S.startTime=Date.now(),S}();export{S as IkasNextPageDataProvider};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront-next",
3
- "version": "5.0.6",
3
+ "version": "5.0.8",
4
4
  "description": "Next.js specific functions for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -17,23 +17,23 @@
17
17
  },
18
18
  "peerDependencies": {
19
19
  "next": "12.2.0",
20
- "@ikas/storefront-config": "^5.0.6",
21
- "@ikas/storefront-providers": "^5.0.6",
22
- "@ikas/storefront-models": "^5.0.6",
23
- "@ikas/storefront-api": "^5.0.6",
24
- "@ikas/storefront-assets": "^5.0.6",
20
+ "@ikas/storefront-config": "^5.0.8",
21
+ "@ikas/storefront-providers": "^5.0.8",
22
+ "@ikas/storefront-models": "^5.0.8",
23
+ "@ikas/storefront-api": "^5.0.8",
24
+ "@ikas/storefront-assets": "^5.0.8",
25
25
  "axios": "^0.26.0",
26
26
  "lodash": "^4.17.21",
27
27
  "cors": "^2.8.5",
28
28
  "adm-zip": "^0.5.9"
29
29
  },
30
30
  "devDependencies": {
31
- "@ikas/storefront-cmd": "^5.0.6",
32
- "@ikas/storefront-config": "^5.0.6",
33
- "@ikas/storefront-providers": "^5.0.6",
34
- "@ikas/storefront-models": "^5.0.6",
35
- "@ikas/storefront-api": "^5.0.6",
36
- "@ikas/storefront-assets": "^5.0.6",
31
+ "@ikas/storefront-cmd": "^5.0.8",
32
+ "@ikas/storefront-config": "^5.0.8",
33
+ "@ikas/storefront-providers": "^5.0.8",
34
+ "@ikas/storefront-models": "^5.0.8",
35
+ "@ikas/storefront-api": "^5.0.8",
36
+ "@ikas/storefront-assets": "^5.0.8",
37
37
  "@rollup/plugin-node-resolve": "^13.3.0",
38
38
  "@rollup/plugin-commonjs": "^22.0.0",
39
39
  "@rollup/plugin-json": "^4.1.0",