@ikas/storefront-next 4.10.0-beta.6 → 4.10.0-beta.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,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { GetServerSidePropsContext, GetStaticPropsContext } from "next";
3
3
  import { ParsedUrlQuery } from "querystring";
4
- import { IkasCustomerReviewSettings, IkasCustomerSettings, IkasMerchantSettings, IkasProductBackInStockSettings, IkasSalesChannel, IkasStorefront, IkasStorefrontRouting, IkasStorefrontThemeLocalization, IkasThemeJson, IkasThemeJsonFavicon, IkasThemeJsonPageType, IkasThemeJsonSettings, IkasThemeJsonStockPreference } from "@ikas/storefront-models";
4
+ import { IkasCustomerReviewSettings, IkasCustomerSettings, IkasImage, IkasMerchantSettings, IkasProductBackInStockSettings, IkasSalesChannel, IkasStorefront, IkasStorefrontRouting, IkasStorefrontThemeLocalization, IkasThemeJson, IkasThemeJsonFavicon, IkasThemeJsonPageType, IkasThemeJsonSettings, IkasThemeJsonStockPreference } from "@ikas/storefront-models";
5
5
  import { IkasPageDataProvider } from "@ikas/storefront-providers";
6
6
  import { IkasStorefrontSettings } from "@ikas/storefront-api";
7
7
  export declare class IkasNextPageDataProvider {
@@ -75,6 +75,7 @@ export declare type SettingsData = {
75
75
  custom?: Record<string, any> | null;
76
76
  };
77
77
  export declare type IkasCheckoutCustomizationProps = {
78
+ logo?: IkasImage;
78
79
  showTax?: boolean;
79
80
  buttonBgColor?: string;
80
81
  buttonTextColor?: string;
@@ -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,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;return e(this,(function(C){switch(C.label){case 0:return[4,S.readSettingsFile()];case 1:return(n=C.sent())&&n.localizationMap?(i=n.storefront,c=n.salesChannel,a=n.localizationMap,u=n.storefrontJSScripts||[],p=n.domain,d=n.productBackInStockSettings?{customerLoginRequired:n.productBackInStockSettings.customerLoginRequired}:null,g=n.customerReviewSettings?{customerLoginRequired:n.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:n.customerReviewSettings.customerPurchaseRequired||!1}:null,(m=n.merchantSettings)?[3,3]:[4,l({})]):[2,s(null)];case 2:if(!(f=C.sent()).isSuccess||!f.data)return console.error("MERCHANT SETTINGS FETCH FAILED!"),[2,s(null)];m=f.data,C.label=3;case 3:return h=a[r],v=i.routings.find((function(t){return t.id===r||t.path===r})),h&&v?(o.readFile(h,{flag:"a+"},(function(r,o){return t(this,void 0,void 0,(function(){var t,a,l,f,h,C,I;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,f=a.themeJson.settings.stockPreference,a.themeJson.settings?(h=S.createColorScript(a.themeJson.settings),[4,S.createFontScript(a.themeJson.settings)]):[3,2]);case 1:C=e.sent(),h&&u.push(h),C&&u.push(C),e.label=2;case 2:return I=n.customerSettings,s({storefront:i,themeLocalization:a,salesChannel:c,routing:v,favicon:l,stockPreference:f,storefrontJSScripts:u,domain:p,productBackInStockSettings:d,customerReviewSettings:g,merchantSettings:m,customerSettings:I,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,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}),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;return t(this,void 0,void 0,(function(){var t,u,l,p,g;return e(this,(function(e){switch(e.label){case 0:return t={},u=r.themeLocalization,o!==i.CHECKOUT?[3,2]:(l=null===(s=n.page)||void 0===s?void 0:s.components[0])?[4,d({})]:[3,2];case 1:(p=e.sent()).isSuccess||(console.error("CHECKOUT SETTINGS FETCH FAILED!"),console.error(p.graphQLErrors),console.error(p.errorCodes)),g={showTax:null===(c=l.propValues.showTax)||void 0===c||c,buttonBgColor:l.propValues.buttonBgColor,buttonTextColor:l.propValues.buttonTextColor,buttonDisabledBgColor:l.propValues.buttonDisabledBgColor,buttonDisabledTextColor:l.propValues.buttonDisabledTextColor,primaryTextColor:l.propValues.primaryTextColor,secondaryTextColor:l.propValues.secondaryTextColor,primaryBgColor:l.propValues.primaryBgColor,secondaryBgColor:l.propValues.secondaryBgColor,borderColor:l.propValues.borderColor,cardBgColor:l.propValues.cardBgColor,errorColor:l.propValues.errorColor,errorLightColor:l.propValues.errorLightColor,warningColor:l.propValues.warningColor,warningLightColor:l.propValues.warningLightColor,successColor:l.propValues.successColor,successLightColor:l.propValues.successLightColor},t.customizationProps=g,t.returnPolicy=u.returnPolicy,t.privacyPolicy=u.privacyPolicy,t.termsOfService=u.termsOfService,t.imprint=u.imprint,t.shippingPolicy=u.shippingPolicy,t.checkoutSettings=(null===(a=null==p?void 0:p.data)||void 0===a?void 0:a.length)?p.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)).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 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,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;return e(this,(function(C){switch(C.label){case 0:return[4,S.readSettingsFile()];case 1:return(n=C.sent())&&n.localizationMap?(i=n.storefront,c=n.salesChannel,a=n.localizationMap,u=n.storefrontJSScripts||[],p=n.domain,d=n.productBackInStockSettings?{customerLoginRequired:n.productBackInStockSettings.customerLoginRequired}:null,g=n.customerReviewSettings?{customerLoginRequired:n.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:n.customerReviewSettings.customerPurchaseRequired||!1}:null,(m=n.merchantSettings)?[3,3]:[4,l({})]):[2,s(null)];case 2:if(!(f=C.sent()).isSuccess||!f.data)return console.error("MERCHANT SETTINGS FETCH FAILED!"),[2,s(null)];m=f.data,C.label=3;case 3:return h=a[r],v=i.routings.find((function(t){return t.id===r||t.path===r})),h&&v?(o.readFile(h,{flag:"a+"},(function(r,o){return t(this,void 0,void 0,(function(){var t,a,l,f,h,C,I;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,f=a.themeJson.settings.stockPreference,a.themeJson.settings?(h=S.createColorScript(a.themeJson.settings),[4,S.createFontScript(a.themeJson.settings)]):[3,2]);case 1:C=e.sent(),h&&u.push(h),C&&u.push(C),e.label=2;case 2:return I=n.customerSettings,s({storefront:i,themeLocalization:a,salesChannel:c,routing:v,favicon:l,stockPreference:f,storefrontJSScripts:u,domain:p,productBackInStockSettings:d,customerReviewSettings:g,merchantSettings:m,customerSettings:I,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,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}),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)).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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront-next",
3
- "version": "4.10.0-beta.6",
3
+ "version": "4.10.0-beta.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": "^4.10.0-beta.6",
21
- "@ikas/storefront-providers": "^4.10.0-beta.6",
22
- "@ikas/storefront-models": "^4.10.0-beta.6",
23
- "@ikas/storefront-api": "^4.10.0-beta.6",
24
- "@ikas/storefront-assets": "^4.10.0-beta.6",
20
+ "@ikas/storefront-config": "^4.10.0-beta.8",
21
+ "@ikas/storefront-providers": "^4.10.0-beta.8",
22
+ "@ikas/storefront-models": "^4.10.0-beta.8",
23
+ "@ikas/storefront-api": "^4.10.0-beta.8",
24
+ "@ikas/storefront-assets": "^4.10.0-beta.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": "^4.10.0-beta.6",
32
- "@ikas/storefront-config": "^4.10.0-beta.6",
33
- "@ikas/storefront-providers": "^4.10.0-beta.6",
34
- "@ikas/storefront-models": "^4.10.0-beta.6",
35
- "@ikas/storefront-api": "^4.10.0-beta.6",
36
- "@ikas/storefront-assets": "^4.10.0-beta.6",
31
+ "@ikas/storefront-cmd": "^4.10.0-beta.8",
32
+ "@ikas/storefront-config": "^4.10.0-beta.8",
33
+ "@ikas/storefront-providers": "^4.10.0-beta.8",
34
+ "@ikas/storefront-models": "^4.10.0-beta.8",
35
+ "@ikas/storefront-api": "^4.10.0-beta.8",
36
+ "@ikas/storefront-assets": "^4.10.0-beta.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",