@ikas/storefront 0.0.161-alpha.9 → 0.0.161

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.
package/build/index.es.js CHANGED
@@ -37682,6 +37682,30 @@ var index = /*#__PURE__*/Object.freeze({
37682
37682
  Image: Image
37683
37683
  });
37684
37684
 
37685
+ /**
37686
+ * Creates a duplicate-free version of an array, using
37687
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
37688
+ * for equality comparisons, in which only the first occurrence of each element
37689
+ * is kept. The order of result values is determined by the order they occur
37690
+ * in the array.
37691
+ *
37692
+ * @static
37693
+ * @memberOf _
37694
+ * @since 0.1.0
37695
+ * @category Array
37696
+ * @param {Array} array The array to inspect.
37697
+ * @returns {Array} Returns the new duplicate free array.
37698
+ * @example
37699
+ *
37700
+ * _.uniq([2, 1, 2]);
37701
+ * // => [2, 1]
37702
+ */
37703
+ function uniq(array) {
37704
+ return (array && array.length) ? _baseUniq(array) : [];
37705
+ }
37706
+
37707
+ var uniq_1 = uniq;
37708
+
37685
37709
  var IkasStorefrontLocalization = /** @class */ (function () {
37686
37710
  function IkasStorefrontLocalization(data) {
37687
37711
  this.id = data.id || "";
@@ -37968,10 +37992,10 @@ var SettingsHelper = /** @class */ (function () {
37968
37992
  });
37969
37993
  }); });
37970
37994
  };
37971
- SettingsHelper.getPageData = function (context, isServer, pageType, possiblePageTypes) {
37995
+ SettingsHelper.getPageData = function (context, isServer, pageType, possiblePageTypes, isEditor) {
37972
37996
  var _a;
37973
37997
  return __awaiter(this, void 0, void 0, function () {
37974
- var isLocal, locale, serverRuntimeConfig, settings, storefront, themeLocalization, salesChannel, routing, favicon, stockPreference, provider, componentIds, components, componentDirs, _b, _c;
37998
+ var isLocal, locale, serverRuntimeConfig, settings, storefront, themeLocalization, salesChannel, routing, favicon, stockPreference, provider, componentIds, components, componentDirs, nextI18nConf, routingLocales, defaultRoutingLocale, _b, _c;
37975
37999
  var _d, _e;
37976
38000
  return __generator(this, function (_f) {
37977
38001
  switch (_f.label) {
@@ -38011,56 +38035,67 @@ var SettingsHelper = /** @class */ (function () {
38011
38035
  IkasStorefrontConfig.stockPreference = stockPreference || null;
38012
38036
  provider = new IkasPageDataProvider(themeLocalization.themeJson, context.params, pageType);
38013
38037
  provider.possiblePageTypes = possiblePageTypes;
38038
+ if (!!isEditor) return [3 /*break*/, 3];
38014
38039
  return [4 /*yield*/, provider.getPageData()];
38015
38040
  case 2:
38016
38041
  _f.sent();
38042
+ _f.label = 3;
38043
+ case 3:
38017
38044
  if (!provider.page) {
38018
- return [2 /*return*/, {
38019
- props: {},
38020
- notFound: true,
38021
- }];
38045
+ if (!isEditor)
38046
+ return [2 /*return*/, {
38047
+ props: {},
38048
+ notFound: true,
38049
+ }];
38022
38050
  }
38023
- componentIds = provider.page.components.map(function (pc) { return pc.componentId; });
38024
- components = themeLocalization.themeJson.components.filter(function (c) {
38025
- return componentIds.includes(c.id);
38026
- });
38051
+ componentIds = isEditor
38052
+ ? provider.theme.components.map(function (c) { return c.id; })
38053
+ : provider.page.components.map(function (pc) { return pc.componentId; });
38054
+ components = themeLocalization.themeJson.components.filter(function (c) { return isEditor || componentIds.includes(c.id); });
38027
38055
  componentDirs = __spreadArrays(["common"], components.map(function (c) { return c.dir; }));
38028
- if (!isServer) return [3 /*break*/, 4];
38056
+ nextI18nConf = serverRuntimeConfig.nextI18nConf;
38057
+ routingLocales = uniq_1(storefront.routings.map(function (sr) { return sr.locale; }));
38058
+ defaultRoutingLocale = routing.locale;
38059
+ if (!isServer) return [3 /*break*/, 5];
38029
38060
  _d = {};
38030
38061
  _b = [{}];
38031
- return [4 /*yield*/, serverSideTranslations(locale, componentDirs, {
38032
- i18n: {
38033
- locales: serverRuntimeConfig.i18n.locales,
38034
- defaultLocale: serverRuntimeConfig.i18n.defaultLocale,
38035
- },
38036
- serializeConfig: false,
38037
- localePath: serverRuntimeConfig.localePath,
38038
- })];
38039
- case 3: return [2 /*return*/, (_d.props = __assign.apply(void 0, [__assign.apply(void 0, _b.concat([(_f.sent())])), provider.nextPageData.props]),
38062
+ return [4 /*yield*/, serverSideTranslations(routing.locale, componentDirs, isLocal
38063
+ ? undefined
38064
+ : {
38065
+ i18n: {
38066
+ locales: routingLocales,
38067
+ defaultLocale: defaultRoutingLocale,
38068
+ },
38069
+ serializeConfig: false,
38070
+ localePath: nextI18nConf.localePath,
38071
+ })];
38072
+ case 4: return [2 /*return*/, (_d.props = __assign.apply(void 0, [__assign.apply(void 0, _b.concat([(_f.sent())])), provider.nextPageData.props]),
38040
38073
  _d)];
38041
- case 4:
38074
+ case 5:
38042
38075
  _e = {};
38043
38076
  _c = [{}];
38044
- return [4 /*yield*/, serverSideTranslations(locale, componentDirs, {
38045
- i18n: {
38046
- locales: serverRuntimeConfig.i18n.locales,
38047
- defaultLocale: serverRuntimeConfig.i18n.defaultLocale,
38048
- },
38049
- serializeConfig: false,
38050
- localePath: serverRuntimeConfig.localePath,
38051
- })];
38052
- case 5: return [2 /*return*/, (_e.props = __assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_f.sent())])), provider.nextPageData.props]),
38077
+ return [4 /*yield*/, serverSideTranslations(routing.locale, componentDirs, isLocal
38078
+ ? undefined
38079
+ : {
38080
+ i18n: {
38081
+ locales: routingLocales,
38082
+ defaultLocale: defaultRoutingLocale,
38083
+ },
38084
+ serializeConfig: false,
38085
+ localePath: nextI18nConf.localePath,
38086
+ })];
38087
+ case 6: return [2 /*return*/, (_e.props = __assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_f.sent())])), provider.nextPageData.props]),
38053
38088
  _e.revalidate = 60,
38054
38089
  _e)];
38055
38090
  }
38056
38091
  });
38057
38092
  });
38058
38093
  };
38059
- SettingsHelper.getStaticProps = function (context, pageType, possiblePageTypes) {
38094
+ SettingsHelper.getStaticProps = function (context, pageType, possiblePageTypes, isEditor) {
38060
38095
  return __awaiter(this, void 0, void 0, function () {
38061
38096
  return __generator(this, function (_a) {
38062
38097
  switch (_a.label) {
38063
- case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType, possiblePageTypes)];
38098
+ case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType, possiblePageTypes, isEditor)];
38064
38099
  case 1: return [2 /*return*/, _a.sent()];
38065
38100
  }
38066
38101
  });
@@ -38290,16 +38325,17 @@ var CheckoutPage = function (_a) {
38290
38325
  };
38291
38326
  var _id_ = observer(CheckoutPage);
38292
38327
  var getServerSideProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38293
- var id, locale, settings, storefront, themeLocalization, salesChannel, routing, redirect, checkout, checkoutSettings;
38294
- var _a;
38295
- return __generator(this, function (_b) {
38296
- switch (_b.label) {
38328
+ var id, locale, settings, storefront, themeLocalization, salesChannel, routing, redirect, checkout, checkoutSettings, componentDirs, isLocal, serverRuntimeConfig, routingLocales, defaultRoutingLocale, nextI18nConf, _a;
38329
+ var _b;
38330
+ var _c;
38331
+ return __generator(this, function (_d) {
38332
+ switch (_d.label) {
38297
38333
  case 0:
38298
38334
  id = context.query.id;
38299
38335
  locale = context.locale || context.defaultLocale || "en";
38300
38336
  return [4 /*yield*/, SettingsHelper.getSettings(locale)];
38301
38337
  case 1:
38302
- settings = _b.sent();
38338
+ settings = _d.sent();
38303
38339
  // TODO maybe remove this and convert this page to static
38304
38340
  if (!settings ||
38305
38341
  !settings.storefront.mainStorefrontThemeId ||
@@ -38315,7 +38351,7 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
38315
38351
  IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
38316
38352
  IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
38317
38353
  IkasStorefrontConfig.priceListId = routing.priceListId || undefined;
38318
- IkasStorefrontConfig.stockLocationIds = (_a = salesChannel.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return sl.id; });
38354
+ IkasStorefrontConfig.stockLocationIds = (_c = salesChannel.stockLocations) === null || _c === void 0 ? void 0 : _c.map(function (sl) { return sl.id; });
38319
38355
  IkasStorefrontConfig.routings = storefront.routings;
38320
38356
  IkasStorefrontConfig.paymentGateways = salesChannel.paymentGateways || [];
38321
38357
  IkasStorefrontConfig.gtmId = storefront.gtmId || undefined;
@@ -38331,24 +38367,33 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
38331
38367
  }
38332
38368
  return [4 /*yield*/, IkasCheckoutAPI.getCheckoutById(id)];
38333
38369
  case 2:
38334
- checkout = _b.sent();
38335
- if (!checkout) return [3 /*break*/, 4];
38370
+ checkout = _d.sent();
38371
+ if (!checkout) return [3 /*break*/, 5];
38336
38372
  return [4 /*yield*/, IkasCheckoutAPI.listCheckoutSettings()];
38337
38373
  case 3:
38338
- checkoutSettings = _b.sent();
38339
- return [2 /*return*/, {
38340
- props: {
38341
- checkoutStr: JSON.stringify(checkout),
38342
- checkoutSettingsStr: (checkoutSettings === null || checkoutSettings === void 0 ? void 0 : checkoutSettings.length) ? JSON.stringify(checkoutSettings[0])
38343
- : null,
38344
- configJson: IkasStorefrontConfig.getJson(),
38345
- returnPolicy: themeLocalization.returnPolicy || "",
38346
- privacyPolicy: themeLocalization.privacyPolicy || "",
38347
- termsOfService: themeLocalization.termsOfService || "",
38348
- queryParams: context.query,
38349
- },
38350
- }];
38351
- case 4: return [2 /*return*/, redirect()];
38374
+ checkoutSettings = _d.sent();
38375
+ componentDirs = ["common", "checkout-page"];
38376
+ isLocal = process.env.NEXT_PUBLIC_ENV === "local";
38377
+ serverRuntimeConfig = getConfig().serverRuntimeConfig;
38378
+ routingLocales = uniq_1(storefront.routings.map(function (sr) { return sr.locale; }));
38379
+ defaultRoutingLocale = routing.locale;
38380
+ nextI18nConf = serverRuntimeConfig.nextI18nConf;
38381
+ _b = {};
38382
+ _a = [{}];
38383
+ return [4 /*yield*/, serverSideTranslations(routing.locale, componentDirs, isLocal
38384
+ ? undefined
38385
+ : {
38386
+ i18n: {
38387
+ locales: routingLocales,
38388
+ defaultLocale: defaultRoutingLocale,
38389
+ },
38390
+ serializeConfig: false,
38391
+ localePath: nextI18nConf.localePath,
38392
+ })];
38393
+ case 4: return [2 /*return*/, (_b.props = __assign.apply(void 0, [__assign.apply(void 0, _a.concat([(_d.sent())])), { checkoutStr: JSON.stringify(checkout), checkoutSettingsStr: (checkoutSettings === null || checkoutSettings === void 0 ? void 0 : checkoutSettings.length) ? JSON.stringify(checkoutSettings[0])
38394
+ : null, configJson: IkasStorefrontConfig.getJson(), returnPolicy: themeLocalization.returnPolicy || "", privacyPolicy: themeLocalization.privacyPolicy || "", termsOfService: themeLocalization.termsOfService || "", queryParams: context.query }]),
38395
+ _b)];
38396
+ case 5: return [2 /*return*/, redirect()];
38352
38397
  }
38353
38398
  });
38354
38399
  }); };
@@ -38583,10 +38628,19 @@ var IkasPageEditor$1 = dynamic(function () { return Promise.resolve().then(funct
38583
38628
  var Page$c = function () {
38584
38629
  return createElement(IkasPageEditor$1, null);
38585
38630
  };
38631
+ var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38632
+ return __generator(this, function (_a) {
38633
+ switch (_a.label) {
38634
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, undefined, undefined, true)];
38635
+ case 1: return [2 /*return*/, _a.sent()];
38636
+ }
38637
+ });
38638
+ }); };
38586
38639
  var editor = observer(Page$c);
38587
38640
 
38588
38641
  var editor$1 = /*#__PURE__*/Object.freeze({
38589
38642
  __proto__: null,
38643
+ getStaticProps: getStaticProps$b,
38590
38644
  'default': editor
38591
38645
  });
38592
38646
 
@@ -38599,7 +38653,7 @@ var Page$d = function (_a) {
38599
38653
  }, [propValuesStr]);
38600
38654
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
38601
38655
  };
38602
- var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38656
+ var getStaticProps$c = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38603
38657
  return __generator(this, function (_a) {
38604
38658
  switch (_a.label) {
38605
38659
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.FAVORITE_PRODUCTS)];
@@ -38611,7 +38665,7 @@ var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, voi
38611
38665
  var favoriteProducts = /*#__PURE__*/Object.freeze({
38612
38666
  __proto__: null,
38613
38667
  'default': Page$d,
38614
- getStaticProps: getStaticProps$b
38668
+ getStaticProps: getStaticProps$c
38615
38669
  });
38616
38670
 
38617
38671
  var Page$e = function (_a) {
@@ -38631,7 +38685,7 @@ var Page$e = function (_a) {
38631
38685
  }, [isBrowser, propValuesStr]);
38632
38686
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
38633
38687
  };
38634
- var getStaticProps$c = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38688
+ var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38635
38689
  return __generator(this, function (_a) {
38636
38690
  switch (_a.label) {
38637
38691
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.SEARCH)];
@@ -38643,7 +38697,7 @@ var getStaticProps$c = function (context) { return __awaiter(void 0, void 0, voi
38643
38697
  var search = /*#__PURE__*/Object.freeze({
38644
38698
  __proto__: null,
38645
38699
  'default': Page$e,
38646
- getStaticProps: getStaticProps$c
38700
+ getStaticProps: getStaticProps$d
38647
38701
  });
38648
38702
 
38649
38703
  var Page$f = function (_a) {
@@ -38657,7 +38711,7 @@ var Page$f = function (_a) {
38657
38711
  }, [propValuesStr]);
38658
38712
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
38659
38713
  };
38660
- var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38714
+ var getStaticProps$e = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38661
38715
  var props;
38662
38716
  return __generator(this, function (_a) {
38663
38717
  switch (_a.label) {
@@ -38679,7 +38733,7 @@ var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, voi
38679
38733
  var _404 = /*#__PURE__*/Object.freeze({
38680
38734
  __proto__: null,
38681
38735
  'default': Page$f,
38682
- getStaticProps: getStaticProps$d
38736
+ getStaticProps: getStaticProps$e
38683
38737
  });
38684
38738
 
38685
38739
  var Page$g = function (_a) {
@@ -38691,7 +38745,7 @@ var Page$g = function (_a) {
38691
38745
  }, [propValuesStr]);
38692
38746
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
38693
38747
  };
38694
- var getStaticProps$e = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38748
+ var getStaticProps$f = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38695
38749
  return __generator(this, function (_a) {
38696
38750
  switch (_a.label) {
38697
38751
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.BLOG_INDEX)];
@@ -38703,7 +38757,7 @@ var getStaticProps$e = function (context) { return __awaiter(void 0, void 0, voi
38703
38757
  var index$5 = /*#__PURE__*/Object.freeze({
38704
38758
  __proto__: null,
38705
38759
  'default': Page$g,
38706
- getStaticProps: getStaticProps$e
38760
+ getStaticProps: getStaticProps$f
38707
38761
  });
38708
38762
 
38709
38763
  var Page$h = function (_a) {
@@ -38732,7 +38786,7 @@ var getStaticPaths$2 = function (context) { return __awaiter(void 0, void 0, voi
38732
38786
  }];
38733
38787
  });
38734
38788
  }); };
38735
- var getStaticProps$f = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38789
+ var getStaticProps$g = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38736
38790
  return __generator(this, function (_a) {
38737
38791
  switch (_a.label) {
38738
38792
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, undefined, [
@@ -38748,7 +38802,7 @@ var _slug_$2 = /*#__PURE__*/Object.freeze({
38748
38802
  __proto__: null,
38749
38803
  'default': _slug_$1,
38750
38804
  getStaticPaths: getStaticPaths$2,
38751
- getStaticProps: getStaticProps$f
38805
+ getStaticProps: getStaticProps$g
38752
38806
  });
38753
38807
 
38754
38808
  /**
package/build/index.js CHANGED
@@ -37659,6 +37659,30 @@ var index = /*#__PURE__*/Object.freeze({
37659
37659
  Image: Image
37660
37660
  });
37661
37661
 
37662
+ /**
37663
+ * Creates a duplicate-free version of an array, using
37664
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
37665
+ * for equality comparisons, in which only the first occurrence of each element
37666
+ * is kept. The order of result values is determined by the order they occur
37667
+ * in the array.
37668
+ *
37669
+ * @static
37670
+ * @memberOf _
37671
+ * @since 0.1.0
37672
+ * @category Array
37673
+ * @param {Array} array The array to inspect.
37674
+ * @returns {Array} Returns the new duplicate free array.
37675
+ * @example
37676
+ *
37677
+ * _.uniq([2, 1, 2]);
37678
+ * // => [2, 1]
37679
+ */
37680
+ function uniq(array) {
37681
+ return (array && array.length) ? _baseUniq(array) : [];
37682
+ }
37683
+
37684
+ var uniq_1 = uniq;
37685
+
37662
37686
  var IkasStorefrontLocalization = /** @class */ (function () {
37663
37687
  function IkasStorefrontLocalization(data) {
37664
37688
  this.id = data.id || "";
@@ -37945,10 +37969,10 @@ var SettingsHelper = /** @class */ (function () {
37945
37969
  });
37946
37970
  }); });
37947
37971
  };
37948
- SettingsHelper.getPageData = function (context, isServer, pageType, possiblePageTypes) {
37972
+ SettingsHelper.getPageData = function (context, isServer, pageType, possiblePageTypes, isEditor) {
37949
37973
  var _a;
37950
37974
  return __awaiter(this, void 0, void 0, function () {
37951
- var isLocal, locale, serverRuntimeConfig, settings, storefront, themeLocalization, salesChannel, routing, favicon, stockPreference, provider, componentIds, components, componentDirs, _b, _c;
37975
+ var isLocal, locale, serverRuntimeConfig, settings, storefront, themeLocalization, salesChannel, routing, favicon, stockPreference, provider, componentIds, components, componentDirs, nextI18nConf, routingLocales, defaultRoutingLocale, _b, _c;
37952
37976
  var _d, _e;
37953
37977
  return __generator(this, function (_f) {
37954
37978
  switch (_f.label) {
@@ -37988,56 +38012,67 @@ var SettingsHelper = /** @class */ (function () {
37988
38012
  IkasStorefrontConfig.stockPreference = stockPreference || null;
37989
38013
  provider = new IkasPageDataProvider(themeLocalization.themeJson, context.params, pageType);
37990
38014
  provider.possiblePageTypes = possiblePageTypes;
38015
+ if (!!isEditor) return [3 /*break*/, 3];
37991
38016
  return [4 /*yield*/, provider.getPageData()];
37992
38017
  case 2:
37993
38018
  _f.sent();
38019
+ _f.label = 3;
38020
+ case 3:
37994
38021
  if (!provider.page) {
37995
- return [2 /*return*/, {
37996
- props: {},
37997
- notFound: true,
37998
- }];
38022
+ if (!isEditor)
38023
+ return [2 /*return*/, {
38024
+ props: {},
38025
+ notFound: true,
38026
+ }];
37999
38027
  }
38000
- componentIds = provider.page.components.map(function (pc) { return pc.componentId; });
38001
- components = themeLocalization.themeJson.components.filter(function (c) {
38002
- return componentIds.includes(c.id);
38003
- });
38028
+ componentIds = isEditor
38029
+ ? provider.theme.components.map(function (c) { return c.id; })
38030
+ : provider.page.components.map(function (pc) { return pc.componentId; });
38031
+ components = themeLocalization.themeJson.components.filter(function (c) { return isEditor || componentIds.includes(c.id); });
38004
38032
  componentDirs = __spreadArrays(["common"], components.map(function (c) { return c.dir; }));
38005
- if (!isServer) return [3 /*break*/, 4];
38033
+ nextI18nConf = serverRuntimeConfig.nextI18nConf;
38034
+ routingLocales = uniq_1(storefront.routings.map(function (sr) { return sr.locale; }));
38035
+ defaultRoutingLocale = routing.locale;
38036
+ if (!isServer) return [3 /*break*/, 5];
38006
38037
  _d = {};
38007
38038
  _b = [{}];
38008
- return [4 /*yield*/, serverSideTranslations.serverSideTranslations(locale, componentDirs, {
38009
- i18n: {
38010
- locales: serverRuntimeConfig.i18n.locales,
38011
- defaultLocale: serverRuntimeConfig.i18n.defaultLocale,
38012
- },
38013
- serializeConfig: false,
38014
- localePath: serverRuntimeConfig.localePath,
38015
- })];
38016
- case 3: return [2 /*return*/, (_d.props = __assign.apply(void 0, [__assign.apply(void 0, _b.concat([(_f.sent())])), provider.nextPageData.props]),
38039
+ return [4 /*yield*/, serverSideTranslations.serverSideTranslations(routing.locale, componentDirs, isLocal
38040
+ ? undefined
38041
+ : {
38042
+ i18n: {
38043
+ locales: routingLocales,
38044
+ defaultLocale: defaultRoutingLocale,
38045
+ },
38046
+ serializeConfig: false,
38047
+ localePath: nextI18nConf.localePath,
38048
+ })];
38049
+ case 4: return [2 /*return*/, (_d.props = __assign.apply(void 0, [__assign.apply(void 0, _b.concat([(_f.sent())])), provider.nextPageData.props]),
38017
38050
  _d)];
38018
- case 4:
38051
+ case 5:
38019
38052
  _e = {};
38020
38053
  _c = [{}];
38021
- return [4 /*yield*/, serverSideTranslations.serverSideTranslations(locale, componentDirs, {
38022
- i18n: {
38023
- locales: serverRuntimeConfig.i18n.locales,
38024
- defaultLocale: serverRuntimeConfig.i18n.defaultLocale,
38025
- },
38026
- serializeConfig: false,
38027
- localePath: serverRuntimeConfig.localePath,
38028
- })];
38029
- case 5: return [2 /*return*/, (_e.props = __assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_f.sent())])), provider.nextPageData.props]),
38054
+ return [4 /*yield*/, serverSideTranslations.serverSideTranslations(routing.locale, componentDirs, isLocal
38055
+ ? undefined
38056
+ : {
38057
+ i18n: {
38058
+ locales: routingLocales,
38059
+ defaultLocale: defaultRoutingLocale,
38060
+ },
38061
+ serializeConfig: false,
38062
+ localePath: nextI18nConf.localePath,
38063
+ })];
38064
+ case 6: return [2 /*return*/, (_e.props = __assign.apply(void 0, [__assign.apply(void 0, _c.concat([(_f.sent())])), provider.nextPageData.props]),
38030
38065
  _e.revalidate = 60,
38031
38066
  _e)];
38032
38067
  }
38033
38068
  });
38034
38069
  });
38035
38070
  };
38036
- SettingsHelper.getStaticProps = function (context, pageType, possiblePageTypes) {
38071
+ SettingsHelper.getStaticProps = function (context, pageType, possiblePageTypes, isEditor) {
38037
38072
  return __awaiter(this, void 0, void 0, function () {
38038
38073
  return __generator(this, function (_a) {
38039
38074
  switch (_a.label) {
38040
- case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType, possiblePageTypes)];
38075
+ case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType, possiblePageTypes, isEditor)];
38041
38076
  case 1: return [2 /*return*/, _a.sent()];
38042
38077
  }
38043
38078
  });
@@ -38267,16 +38302,17 @@ var CheckoutPage = function (_a) {
38267
38302
  };
38268
38303
  var _id_ = mobxReactLite.observer(CheckoutPage);
38269
38304
  var getServerSideProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38270
- var id, locale, settings, storefront, themeLocalization, salesChannel, routing, redirect, checkout, checkoutSettings;
38271
- var _a;
38272
- return __generator(this, function (_b) {
38273
- switch (_b.label) {
38305
+ var id, locale, settings, storefront, themeLocalization, salesChannel, routing, redirect, checkout, checkoutSettings, componentDirs, isLocal, serverRuntimeConfig, routingLocales, defaultRoutingLocale, nextI18nConf, _a;
38306
+ var _b;
38307
+ var _c;
38308
+ return __generator(this, function (_d) {
38309
+ switch (_d.label) {
38274
38310
  case 0:
38275
38311
  id = context.query.id;
38276
38312
  locale = context.locale || context.defaultLocale || "en";
38277
38313
  return [4 /*yield*/, SettingsHelper.getSettings(locale)];
38278
38314
  case 1:
38279
- settings = _b.sent();
38315
+ settings = _d.sent();
38280
38316
  // TODO maybe remove this and convert this page to static
38281
38317
  if (!settings ||
38282
38318
  !settings.storefront.mainStorefrontThemeId ||
@@ -38292,7 +38328,7 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
38292
38328
  IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
38293
38329
  IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
38294
38330
  IkasStorefrontConfig.priceListId = routing.priceListId || undefined;
38295
- IkasStorefrontConfig.stockLocationIds = (_a = salesChannel.stockLocations) === null || _a === void 0 ? void 0 : _a.map(function (sl) { return sl.id; });
38331
+ IkasStorefrontConfig.stockLocationIds = (_c = salesChannel.stockLocations) === null || _c === void 0 ? void 0 : _c.map(function (sl) { return sl.id; });
38296
38332
  IkasStorefrontConfig.routings = storefront.routings;
38297
38333
  IkasStorefrontConfig.paymentGateways = salesChannel.paymentGateways || [];
38298
38334
  IkasStorefrontConfig.gtmId = storefront.gtmId || undefined;
@@ -38308,24 +38344,33 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
38308
38344
  }
38309
38345
  return [4 /*yield*/, IkasCheckoutAPI.getCheckoutById(id)];
38310
38346
  case 2:
38311
- checkout = _b.sent();
38312
- if (!checkout) return [3 /*break*/, 4];
38347
+ checkout = _d.sent();
38348
+ if (!checkout) return [3 /*break*/, 5];
38313
38349
  return [4 /*yield*/, IkasCheckoutAPI.listCheckoutSettings()];
38314
38350
  case 3:
38315
- checkoutSettings = _b.sent();
38316
- return [2 /*return*/, {
38317
- props: {
38318
- checkoutStr: JSON.stringify(checkout),
38319
- checkoutSettingsStr: (checkoutSettings === null || checkoutSettings === void 0 ? void 0 : checkoutSettings.length) ? JSON.stringify(checkoutSettings[0])
38320
- : null,
38321
- configJson: IkasStorefrontConfig.getJson(),
38322
- returnPolicy: themeLocalization.returnPolicy || "",
38323
- privacyPolicy: themeLocalization.privacyPolicy || "",
38324
- termsOfService: themeLocalization.termsOfService || "",
38325
- queryParams: context.query,
38326
- },
38327
- }];
38328
- case 4: return [2 /*return*/, redirect()];
38351
+ checkoutSettings = _d.sent();
38352
+ componentDirs = ["common", "checkout-page"];
38353
+ isLocal = process.env.NEXT_PUBLIC_ENV === "local";
38354
+ serverRuntimeConfig = getConfig__default['default']().serverRuntimeConfig;
38355
+ routingLocales = uniq_1(storefront.routings.map(function (sr) { return sr.locale; }));
38356
+ defaultRoutingLocale = routing.locale;
38357
+ nextI18nConf = serverRuntimeConfig.nextI18nConf;
38358
+ _b = {};
38359
+ _a = [{}];
38360
+ return [4 /*yield*/, serverSideTranslations.serverSideTranslations(routing.locale, componentDirs, isLocal
38361
+ ? undefined
38362
+ : {
38363
+ i18n: {
38364
+ locales: routingLocales,
38365
+ defaultLocale: defaultRoutingLocale,
38366
+ },
38367
+ serializeConfig: false,
38368
+ localePath: nextI18nConf.localePath,
38369
+ })];
38370
+ case 4: return [2 /*return*/, (_b.props = __assign.apply(void 0, [__assign.apply(void 0, _a.concat([(_d.sent())])), { checkoutStr: JSON.stringify(checkout), checkoutSettingsStr: (checkoutSettings === null || checkoutSettings === void 0 ? void 0 : checkoutSettings.length) ? JSON.stringify(checkoutSettings[0])
38371
+ : null, configJson: IkasStorefrontConfig.getJson(), returnPolicy: themeLocalization.returnPolicy || "", privacyPolicy: themeLocalization.privacyPolicy || "", termsOfService: themeLocalization.termsOfService || "", queryParams: context.query }]),
38372
+ _b)];
38373
+ case 5: return [2 /*return*/, redirect()];
38329
38374
  }
38330
38375
  });
38331
38376
  }); };
@@ -38560,10 +38605,19 @@ var IkasPageEditor$1 = dynamic__default['default'](function () { return Promise.
38560
38605
  var Page$c = function () {
38561
38606
  return React.createElement(IkasPageEditor$1, null);
38562
38607
  };
38608
+ var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38609
+ return __generator(this, function (_a) {
38610
+ switch (_a.label) {
38611
+ case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, undefined, undefined, true)];
38612
+ case 1: return [2 /*return*/, _a.sent()];
38613
+ }
38614
+ });
38615
+ }); };
38563
38616
  var editor = mobxReactLite.observer(Page$c);
38564
38617
 
38565
38618
  var editor$1 = /*#__PURE__*/Object.freeze({
38566
38619
  __proto__: null,
38620
+ getStaticProps: getStaticProps$b,
38567
38621
  'default': editor
38568
38622
  });
38569
38623
 
@@ -38576,7 +38630,7 @@ var Page$d = function (_a) {
38576
38630
  }, [propValuesStr]);
38577
38631
  return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
38578
38632
  };
38579
- var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38633
+ var getStaticProps$c = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38580
38634
  return __generator(this, function (_a) {
38581
38635
  switch (_a.label) {
38582
38636
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.FAVORITE_PRODUCTS)];
@@ -38588,7 +38642,7 @@ var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, voi
38588
38642
  var favoriteProducts = /*#__PURE__*/Object.freeze({
38589
38643
  __proto__: null,
38590
38644
  'default': Page$d,
38591
- getStaticProps: getStaticProps$b
38645
+ getStaticProps: getStaticProps$c
38592
38646
  });
38593
38647
 
38594
38648
  var Page$e = function (_a) {
@@ -38608,7 +38662,7 @@ var Page$e = function (_a) {
38608
38662
  }, [isBrowser, propValuesStr]);
38609
38663
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
38610
38664
  };
38611
- var getStaticProps$c = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38665
+ var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38612
38666
  return __generator(this, function (_a) {
38613
38667
  switch (_a.label) {
38614
38668
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.SEARCH)];
@@ -38620,7 +38674,7 @@ var getStaticProps$c = function (context) { return __awaiter(void 0, void 0, voi
38620
38674
  var search = /*#__PURE__*/Object.freeze({
38621
38675
  __proto__: null,
38622
38676
  'default': Page$e,
38623
- getStaticProps: getStaticProps$c
38677
+ getStaticProps: getStaticProps$d
38624
38678
  });
38625
38679
 
38626
38680
  var Page$f = function (_a) {
@@ -38634,7 +38688,7 @@ var Page$f = function (_a) {
38634
38688
  }, [propValuesStr]);
38635
38689
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
38636
38690
  };
38637
- var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38691
+ var getStaticProps$e = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38638
38692
  var props;
38639
38693
  return __generator(this, function (_a) {
38640
38694
  switch (_a.label) {
@@ -38656,7 +38710,7 @@ var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, voi
38656
38710
  var _404 = /*#__PURE__*/Object.freeze({
38657
38711
  __proto__: null,
38658
38712
  'default': Page$f,
38659
- getStaticProps: getStaticProps$d
38713
+ getStaticProps: getStaticProps$e
38660
38714
  });
38661
38715
 
38662
38716
  var Page$g = function (_a) {
@@ -38668,7 +38722,7 @@ var Page$g = function (_a) {
38668
38722
  }, [propValuesStr]);
38669
38723
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
38670
38724
  };
38671
- var getStaticProps$e = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38725
+ var getStaticProps$f = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38672
38726
  return __generator(this, function (_a) {
38673
38727
  switch (_a.label) {
38674
38728
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.BLOG_INDEX)];
@@ -38680,7 +38734,7 @@ var getStaticProps$e = function (context) { return __awaiter(void 0, void 0, voi
38680
38734
  var index$5 = /*#__PURE__*/Object.freeze({
38681
38735
  __proto__: null,
38682
38736
  'default': Page$g,
38683
- getStaticProps: getStaticProps$e
38737
+ getStaticProps: getStaticProps$f
38684
38738
  });
38685
38739
 
38686
38740
  var Page$h = function (_a) {
@@ -38709,7 +38763,7 @@ var getStaticPaths$2 = function (context) { return __awaiter(void 0, void 0, voi
38709
38763
  }];
38710
38764
  });
38711
38765
  }); };
38712
- var getStaticProps$f = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38766
+ var getStaticProps$g = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38713
38767
  return __generator(this, function (_a) {
38714
38768
  switch (_a.label) {
38715
38769
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, undefined, [
@@ -38725,7 +38779,7 @@ var _slug_$2 = /*#__PURE__*/Object.freeze({
38725
38779
  __proto__: null,
38726
38780
  'default': _slug_$1,
38727
38781
  getStaticPaths: getStaticPaths$2,
38728
- getStaticProps: getStaticProps$f
38782
+ getStaticProps: getStaticProps$g
38729
38783
  });
38730
38784
 
38731
38785
  /**
@@ -1,4 +1,6 @@
1
1
  /// <reference types="react" />
2
+ import { GetStaticProps } from "next";
3
+ export declare const getStaticProps: GetStaticProps;
2
4
  declare const _default: (() => JSX.Element) & {
3
5
  displayName: string;
4
6
  };
@@ -12,7 +12,7 @@ export declare class SettingsHelper {
12
12
  static readLocalTheme(): Promise<IkasTheme>;
13
13
  static readSettingsFile(): Promise<any>;
14
14
  static getSettings(locale: string): Promise<SettingsData | null>;
15
- static getPageData(context: GetStaticPropsContext<ParsedUrlQuery> | GetServerSidePropsContext<ParsedUrlQuery>, isServer: boolean, pageType?: IkasThemePageType, possiblePageTypes?: IkasThemePageType[]): Promise<{
15
+ static getPageData(context: GetStaticPropsContext<ParsedUrlQuery> | GetServerSidePropsContext<ParsedUrlQuery>, isServer: boolean, pageType?: IkasThemePageType, possiblePageTypes?: IkasThemePageType[], isEditor?: boolean): Promise<{
16
16
  props: {};
17
17
  notFound: boolean;
18
18
  revalidate?: undefined;
@@ -75,7 +75,7 @@ export declare class SettingsHelper {
75
75
  revalidate: number;
76
76
  notFound?: undefined;
77
77
  }>;
78
- static getStaticProps(context: GetStaticPropsContext<ParsedUrlQuery>, pageType?: IkasThemePageType, possiblePageTypes?: IkasThemePageType[]): Promise<{
78
+ static getStaticProps(context: GetStaticPropsContext<ParsedUrlQuery>, pageType?: IkasThemePageType, possiblePageTypes?: IkasThemePageType[], isEditor?: boolean): Promise<{
79
79
  props: {};
80
80
  notFound: boolean;
81
81
  revalidate?: undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.161-alpha.9",
3
+ "version": "0.0.161",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",