@ikas/storefront-next 5.0.4 → 5.0.6

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.
@@ -78,6 +78,21 @@ export declare type SettingsData = {
78
78
  export declare type IkasCheckoutCustomizationProps = {
79
79
  logo?: IkasImage;
80
80
  showTax?: boolean;
81
+ showCampaignOffersDesign?: boolean;
82
+ showCampaignIsBiggerImage?: boolean;
83
+ campaignOfferIsSmallDesign?: boolean;
84
+ showCampaignHideDiscountBadge?: boolean;
85
+ campaignOfferCountdownStyleIsLine?: boolean;
86
+ campaignOfferCountdownStyleIsLineSuccessPage?: boolean;
87
+ campaignOffersEnableMiddlePhase?: boolean;
88
+ campaignOffersTitleColor?: string;
89
+ campaignOffersDescriptionColor?: string;
90
+ campaignOffersDiscountPercentageColor?: string;
91
+ campaignOffersDiscountPercentageBgColor?: string;
92
+ campaignOffersCountdownTextColor?: string;
93
+ campaignOffersCountdownTimeColor?: string;
94
+ campaignOffersCountdownBgColor?: string;
95
+ campaignOffersMiddlePhaseOverlayColor?: string;
81
96
  buttonBgColor?: string;
82
97
  buttonTextColor?: string;
83
98
  buttonDisabledBgColor?: string;
@@ -94,4 +109,7 @@ export declare type IkasCheckoutCustomizationProps = {
94
109
  warningLightColor?: string;
95
110
  successColor?: string;
96
111
  successLightColor?: string;
112
+ secondaryButtonBgColor?: string;
113
+ secondaryButtonTextColor?: string;
114
+ secondaryButtonBorderColor?: string;
97
115
  };
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as e,__spreadArray as r,__assign as n}from'./../ext/tslib/tslib.es6.js';import o from"fs";import s from"next/config.js";import{IkasThemeJsonPageType as i}from"@ikas/storefront-models";import{IkasPageDataProvider as c}from"@ikas/storefront-providers";import{IkasStorefrontConfig as a}from"@ikas/storefront-config";import{getStorefrontSettings as u,listMerchantSettings as l,setAPIClientConfig as p,listCheckoutSettings as d}from"@ikas/storefront-api";import{getGoogleFontHref as g}from"../utils/google-fonts.js";import{I18NFileReader as m}from"../utils/i18n.js";import{createFile as f,deleteDirContent as h}from"../utils/fs.js";var S=function(){function S(){}return S.readLocalTheme=function(){return new Promise((function(t,e){o.readFile("./src/theme.json",{flag:"a+"},(function(r,n){if(r)return e(r);var o=n.length?JSON.parse(n.toString()):{};t(o)}))}))},S.readSettingsFile=function(){return new Promise((function(t){var e=s().serverRuntimeConfig.SETTINGS;o.readFile(e,{flag:"a+"},(function(e,r){if(e)return console.error("SETTINGS FILE READ ERROR!!!"),console.error(e),t(null);var n=r.length?JSON.parse(r.toString()):{};t(n)}))}))},S.cacheLocalSettingsFile=function(r){return t(this,void 0,void 0,(function(){var t,n;return e(this,(function(e){switch(e.label){case 0:return[4,h(t=".ikas")];case 1:return e.sent(),n="settings-".concat(this.startTime,".json"),[4,f(t,n,JSON.stringify(r,null,2))];case 2:return e.sent(),[2]}}))}))},S.readLocalSettingsFile=function(){try{var t=o.readFileSync(".ikas/settings-".concat(this.startTime,".json"));if(t&&t.length)return JSON.parse(t.toString())}catch(t){}},S.getLocalSettings=function(r){return t(this,void 0,void 0,(function(){var t,n,o,s,i,c,a,l,p,d;return e(this,(function(e){switch(e.label){case 0:return[4,S.readLocalSettingsFile()];case 1:return(t=e.sent())?[3,4]:[4,u()];case 2:return(n=e.sent()).isSuccess&&n.data?(t=n.data,[4,this.cacheLocalSettingsFile(t)]):(console.error("Storefront settings fetch failed!"),console.error(n),[2,null]);case 3:e.sent(),e.label=4;case 4:return o=t.storefront,s=t.salesChannel,i=[],c=t.productBackInStockSettings?{customerLoginRequired:t.productBackInStockSettings.customerLoginRequired}:null,a=t.customerReviewSettings?{customerLoginRequired:t.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:t.customerReviewSettings.customerPurchaseRequired||!1}:null,[4,S.readLocalTheme()];case 5:return l=e.sent(),p=S.createColorScript(l.settings),[4,S.createFontScript(l.settings)];case 6:return d=e.sent(),p&&i.push(p),d&&i.push(d),[2,{storefront:o,themeLocalization:{id:"",locale:"en",privacyPolicy:null,returnPolicy:null,storefrontId:o.id,storefrontThemeId:"",termsOfService:null,imprint:null,shippingPolicy:null,themeJson:l},salesChannel:s,routing:o.routings.length?o.routings.find((function(t){return t.locale===r||t.id===r}))||o.routings[0]:{countryCodes:[],domain:"",dynamicCurrencySettings:{roundingFormat:null,targetCurrencyCode:""},id:"",locale:"en",path:null,priceListId:null,currencyCode:"USD",currencySymbol:"$"},favicon:l.settings.favicon,stockPreference:l.settings.stockPreference,storefrontJSScripts:i,highPriorityStoreFrontJSScripts:[],domain:"localhost:3333",productBackInStockSettings:c,customerReviewSettings:a,merchantSettings:t.merchantSettings,customerSettings:t.customerSettings}]}}))}))},S.getProdSettings=function(r){return t(this,void 0,void 0,(function(){var n=this;return e(this,(function(s){return[2,new Promise((function(s){return t(n,void 0,void 0,(function(){var n,i,c,a,u,p,d,g,m,f,h,v,C;return e(this,(function(I){switch(I.label){case 0:return[4,S.readSettingsFile()];case 1:return(n=I.sent())&&n.localizationMap?(i=n.storefront,c=n.salesChannel,a=n.localizationMap,u=n.storefrontJSScripts||[],p=n.highPriorityStoreFrontJSScripts||[],d=n.domain,g=n.productBackInStockSettings?{customerLoginRequired:n.productBackInStockSettings.customerLoginRequired}:null,m=n.customerReviewSettings?{customerLoginRequired:n.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:n.customerReviewSettings.customerPurchaseRequired||!1}:null,(f=n.merchantSettings)?[3,3]:[4,l({})]):[2,s(null)];case 2:if(!(h=I.sent()).isSuccess||!h.data)return console.error("MERCHANT SETTINGS FETCH FAILED!"),[2,s(null)];f=h.data,I.label=3;case 3:return f&&(f.address=null,delete f.merchantAddress),v=a[r],C=i.routings.find((function(t){return t.id===r||t.path===r})),v&&C?(o.readFile(v,{flag:"a+"},(function(r,o){return t(this,void 0,void 0,(function(){var t,a,l,h,v,I,L;return e(this,(function(e){switch(e.label){case 0:return r?(console.error("THEME LOCALIZATION FILE READ ERROR!!!"),console.error(r),[2,s(null)]):(t=o.length?JSON.parse(o.toString()):{},l=(a=t).themeJson.settings.favicon,h=a.themeJson.settings.stockPreference,a.themeJson.settings?(v=S.createColorScript(a.themeJson.settings),[4,S.createFontScript(a.themeJson.settings)]):[3,2]);case 1:I=e.sent(),v&&u.push(v),I&&u.push(I),e.label=2;case 2:return L=n.customerSettings,s({storefront:i,themeLocalization:a,salesChannel:c,routing:C,favicon:l,stockPreference:h,storefrontJSScripts:u,highPriorityStoreFrontJSScripts:p,domain:d,productBackInStockSettings:g,customerReviewSettings:m,merchantSettings:f,customerSettings:L,custom:n.custom}),[2]}}))}))})),[2]):(console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!"),[2,s(null)])}}))}))}))]}))}))},S.getSettings=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return"local"===process.env.NEXT_PUBLIC_ENV?[4,this.getLocalSettings(r)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return[4,this.getProdSettings(r)]}}))}))},S.setStorefrontConfig=function(r){var n;return t(this,void 0,void 0,(function(){var t,o,s,i,c,u,l,d,g,m,f,h;return e(this,(function(e){return t=r.storefront,o=r.salesChannel,s=r.routing,i=r.favicon,c=r.stockPreference,u=r.storefrontJSScripts,l=r.domain,d=r.productBackInStockSettings,g=r.customerReviewSettings,m=r.merchantSettings,f=r.customerSettings,h=r.custom,a.init({apiUrl:process.env.NEXT_PUBLIC_GQL_URL,cdnUrl:process.env.NEXT_PUBLIC_CDN_URL,storefrontId:t.id,storefrontRoutingId:s.id,storefrontThemeId:t.mainStorefrontThemeId,storefrontB2BSettings:t.b2bSettings||void 0,storefrontType:t.type,salesChannelId:t.salesChannelId,priceListId:s.priceListId||void 0,stockLocationIds:null===(n=o.stockLocations)||void 0===n?void 0:n.map((function(t){return t.id})),routings:t.routings,paymentGateways:o.paymentGateways||[],gtmId:t.gtmId||void 0,fbpId:t.fbpId||void 0,analytics4Id:t.analytics4Id||void 0,universalAnalyticsId:t.universalAnalyticsId||void 0,tiktokPixelId:t.tiktokPixelId||void 0,favicon:i||null,pickUpStockLocationIds:t.pickUpStockLocationIds&&t.pickUpStockLocationIds.length?t.pickUpStockLocationIds:null,stockPreference:c||null,storefrontJSScripts:u||[],domain:l,productBackInStockSettings:d,customerReviewSettings:g,merchantSettings:m,customerSettings:f,metaTemplates:t.metaTemplates||null,custom:h||null,indexPageSeoSettings:t.indexPageSeoSettings}),p(),[2]}))}))},S.setTranslations=function(n,o,c,u,l){return t(this,void 0,void 0,(function(){var t,p,d,g,f,h,S,v;return e(this,(function(e){switch(e.label){case 0:return t=s().serverRuntimeConfig,p=n.routing,d="local"===process.env.NEXT_PUBLIC_ENV,g=n.themeLocalization.themeJson.components.filter((function(t){return u||o.includes(t.id)})),f=r(["common"],g.map((function(t){return t.dir})),!0),(c===i.CHECKOUT||u)&&f.push("checkout-page"),h=t.nextI18nConf,S=d&&l?l:p.locale,[4,new m(S,f,d?void 0:h.localePath).read()];case 1:return v=e.sent(),a.init({translations:v}),[2]}}))}))},S.getExtraProps=function(r,n,o){var s,c,a,u;return t(this,void 0,void 0,(function(){var t,l,p,g,m;return e(this,(function(e){switch(e.label){case 0:return t={},l=r.themeLocalization,o!==i.CHECKOUT?[3,2]:(p=null===(s=n.page)||void 0===s?void 0:s.components[0])?[4,d({})]:[3,2];case 1:(g=e.sent()).isSuccess||(console.error("CHECKOUT SETTINGS FETCH FAILED!"),console.error(g.graphQLErrors),console.error(g.errorCodes)),m={logo:null!==(c=p.propValues.logo)&&void 0!==c?c:null,showTax:null===(a=p.propValues.showTax)||void 0===a||a,buttonBgColor:p.propValues.buttonBgColor,buttonTextColor:p.propValues.buttonTextColor,buttonDisabledBgColor:p.propValues.buttonDisabledBgColor,buttonDisabledTextColor:p.propValues.buttonDisabledTextColor,primaryTextColor:p.propValues.primaryTextColor,secondaryTextColor:p.propValues.secondaryTextColor,primaryBgColor:p.propValues.primaryBgColor,secondaryBgColor:p.propValues.secondaryBgColor,borderColor:p.propValues.borderColor,cardBgColor:p.propValues.cardBgColor,errorColor:p.propValues.errorColor,errorLightColor:p.propValues.errorLightColor,warningColor:p.propValues.warningColor,warningLightColor:p.propValues.warningLightColor,successColor:p.propValues.successColor,successLightColor:p.propValues.successLightColor},t.customizationProps=m,t.returnPolicy=l.returnPolicy,t.privacyPolicy=l.privacyPolicy,t.termsOfService=l.termsOfService,t.imprint=l.imprint,t.shippingPolicy=l.shippingPolicy,t.checkoutSettings=(null===(u=null==g?void 0:g.data)||void 0===u?void 0:u.length)?g.data[0]:null,e.label=2;case 2:return[2,t]}}))}))},S.getPageData=function(r,o,s,i,u){var l;return t(this,void 0,void 0,(function(){var t,d,g,m,f,h,v,C;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,d=!t&&u,a.init({apiUrl:process.env.NEXT_PUBLIC_GQL_URL,cdnUrl:process.env.NEXT_PUBLIC_CDN_URL}),p(),d?[3,7]:(g=r.locale)?[4,S.getSettings(g)]:[2,{props:{},notFound:!0}];case 1:return(m=e.sent())&&m.storefront.mainStorefrontThemeId&&m.storefront.salesChannelId?[4,this.setStorefrontConfig(m)]:[2,{props:{},notFound:!0}];case 2:return e.sent(),f=m.themeLocalization,(h=new c(f.themeJson,r.params,s,m.merchantSettings)).possiblePageTypes=i||(s?[s]:[]),u?[3,4]:[4,h.getPageData()];case 3:if(e.sent(),!h.page)return[2,{props:{},notFound:!0}];e.label=4;case 4:return v=u?h.theme.components.map((function(t){return t.id})):(null===(l=h.page)||void 0===l?void 0:l.components.map((function(t){return t.componentId})))||[],[4,this.setTranslations(m,v,s,u,g)];case 5:return e.sent(),[4,this.getExtraProps(m,h,s)];case 6:return C=e.sent(),o?[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(r,n,o,s){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,S.getPageData(r,!1,n,o,s)];case 1:return[2,t.sent()]}}))}))},S.getServerSideProps=function(r,n){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,S.getPageData(r,!0,n)];case 1:return[2,t.sent()]}}))}))},S.createColorScript=function(t){if(t.colors)return"<script>".concat(t.colors.map((function(t){return'document.documentElement.style.setProperty("'.concat(t.key,'","').concat(t.color,'");')})).join("\r\n"),"<\/script> \n ")},S.createFontScript=function(r){return t(this,void 0,void 0,(function(){var t,n,o;return e(this,(function(e){switch(e.label){case 0:return(t=g(r.fontFamily))?[4,fetch(t,{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,e.sent().text()];case 2:return n=e.sent(),o=n.replace(new RegExp("fonts.gstatic.com","g"),"fonts.myikas.com"),[2,"<style>\n ".concat(o,"\n\n body { \n font-family: '").concat(r.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 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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront-next",
3
- "version": "5.0.4",
3
+ "version": "5.0.6",
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.4",
21
- "@ikas/storefront-providers": "^5.0.4",
22
- "@ikas/storefront-models": "^5.0.4",
23
- "@ikas/storefront-api": "^5.0.4",
24
- "@ikas/storefront-assets": "^5.0.4",
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",
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.4",
32
- "@ikas/storefront-config": "^5.0.4",
33
- "@ikas/storefront-providers": "^5.0.4",
34
- "@ikas/storefront-models": "^5.0.4",
35
- "@ikas/storefront-api": "^5.0.4",
36
- "@ikas/storefront-assets": "^5.0.4",
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",
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",