@ikas/storefront 0.0.161-alpha.8 → 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,54 +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
- })];
38038
- 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]),
38039
38073
  _d)];
38040
- case 4:
38074
+ case 5:
38041
38075
  _e = {};
38042
38076
  _c = [{}];
38043
- return [4 /*yield*/, serverSideTranslations(locale, componentDirs, {
38044
- i18n: {
38045
- locales: serverRuntimeConfig.i18n.locales,
38046
- defaultLocale: serverRuntimeConfig.i18n.defaultLocale,
38047
- },
38048
- serializeConfig: false,
38049
- })];
38050
- 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]),
38051
38088
  _e.revalidate = 60,
38052
38089
  _e)];
38053
38090
  }
38054
38091
  });
38055
38092
  });
38056
38093
  };
38057
- SettingsHelper.getStaticProps = function (context, pageType, possiblePageTypes) {
38094
+ SettingsHelper.getStaticProps = function (context, pageType, possiblePageTypes, isEditor) {
38058
38095
  return __awaiter(this, void 0, void 0, function () {
38059
38096
  return __generator(this, function (_a) {
38060
38097
  switch (_a.label) {
38061
- case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType, possiblePageTypes)];
38098
+ case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType, possiblePageTypes, isEditor)];
38062
38099
  case 1: return [2 /*return*/, _a.sent()];
38063
38100
  }
38064
38101
  });
@@ -38288,16 +38325,17 @@ var CheckoutPage = function (_a) {
38288
38325
  };
38289
38326
  var _id_ = observer(CheckoutPage);
38290
38327
  var getServerSideProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38291
- var id, locale, settings, storefront, themeLocalization, salesChannel, routing, redirect, checkout, checkoutSettings;
38292
- var _a;
38293
- return __generator(this, function (_b) {
38294
- 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) {
38295
38333
  case 0:
38296
38334
  id = context.query.id;
38297
38335
  locale = context.locale || context.defaultLocale || "en";
38298
38336
  return [4 /*yield*/, SettingsHelper.getSettings(locale)];
38299
38337
  case 1:
38300
- settings = _b.sent();
38338
+ settings = _d.sent();
38301
38339
  // TODO maybe remove this and convert this page to static
38302
38340
  if (!settings ||
38303
38341
  !settings.storefront.mainStorefrontThemeId ||
@@ -38313,7 +38351,7 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
38313
38351
  IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
38314
38352
  IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
38315
38353
  IkasStorefrontConfig.priceListId = routing.priceListId || undefined;
38316
- 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; });
38317
38355
  IkasStorefrontConfig.routings = storefront.routings;
38318
38356
  IkasStorefrontConfig.paymentGateways = salesChannel.paymentGateways || [];
38319
38357
  IkasStorefrontConfig.gtmId = storefront.gtmId || undefined;
@@ -38329,24 +38367,33 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
38329
38367
  }
38330
38368
  return [4 /*yield*/, IkasCheckoutAPI.getCheckoutById(id)];
38331
38369
  case 2:
38332
- checkout = _b.sent();
38333
- if (!checkout) return [3 /*break*/, 4];
38370
+ checkout = _d.sent();
38371
+ if (!checkout) return [3 /*break*/, 5];
38334
38372
  return [4 /*yield*/, IkasCheckoutAPI.listCheckoutSettings()];
38335
38373
  case 3:
38336
- checkoutSettings = _b.sent();
38337
- return [2 /*return*/, {
38338
- props: {
38339
- checkoutStr: JSON.stringify(checkout),
38340
- checkoutSettingsStr: (checkoutSettings === null || checkoutSettings === void 0 ? void 0 : checkoutSettings.length) ? JSON.stringify(checkoutSettings[0])
38341
- : null,
38342
- configJson: IkasStorefrontConfig.getJson(),
38343
- returnPolicy: themeLocalization.returnPolicy || "",
38344
- privacyPolicy: themeLocalization.privacyPolicy || "",
38345
- termsOfService: themeLocalization.termsOfService || "",
38346
- queryParams: context.query,
38347
- },
38348
- }];
38349
- 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()];
38350
38397
  }
38351
38398
  });
38352
38399
  }); };
@@ -38581,10 +38628,19 @@ var IkasPageEditor$1 = dynamic(function () { return Promise.resolve().then(funct
38581
38628
  var Page$c = function () {
38582
38629
  return createElement(IkasPageEditor$1, null);
38583
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
+ }); };
38584
38639
  var editor = observer(Page$c);
38585
38640
 
38586
38641
  var editor$1 = /*#__PURE__*/Object.freeze({
38587
38642
  __proto__: null,
38643
+ getStaticProps: getStaticProps$b,
38588
38644
  'default': editor
38589
38645
  });
38590
38646
 
@@ -38597,7 +38653,7 @@ var Page$d = function (_a) {
38597
38653
  }, [propValuesStr]);
38598
38654
  return (createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
38599
38655
  };
38600
- 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 () {
38601
38657
  return __generator(this, function (_a) {
38602
38658
  switch (_a.label) {
38603
38659
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.FAVORITE_PRODUCTS)];
@@ -38609,7 +38665,7 @@ var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, voi
38609
38665
  var favoriteProducts = /*#__PURE__*/Object.freeze({
38610
38666
  __proto__: null,
38611
38667
  'default': Page$d,
38612
- getStaticProps: getStaticProps$b
38668
+ getStaticProps: getStaticProps$c
38613
38669
  });
38614
38670
 
38615
38671
  var Page$e = function (_a) {
@@ -38629,7 +38685,7 @@ var Page$e = function (_a) {
38629
38685
  }, [isBrowser, propValuesStr]);
38630
38686
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
38631
38687
  };
38632
- 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 () {
38633
38689
  return __generator(this, function (_a) {
38634
38690
  switch (_a.label) {
38635
38691
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.SEARCH)];
@@ -38641,7 +38697,7 @@ var getStaticProps$c = function (context) { return __awaiter(void 0, void 0, voi
38641
38697
  var search = /*#__PURE__*/Object.freeze({
38642
38698
  __proto__: null,
38643
38699
  'default': Page$e,
38644
- getStaticProps: getStaticProps$c
38700
+ getStaticProps: getStaticProps$d
38645
38701
  });
38646
38702
 
38647
38703
  var Page$f = function (_a) {
@@ -38655,7 +38711,7 @@ var Page$f = function (_a) {
38655
38711
  }, [propValuesStr]);
38656
38712
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
38657
38713
  };
38658
- 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 () {
38659
38715
  var props;
38660
38716
  return __generator(this, function (_a) {
38661
38717
  switch (_a.label) {
@@ -38677,7 +38733,7 @@ var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, voi
38677
38733
  var _404 = /*#__PURE__*/Object.freeze({
38678
38734
  __proto__: null,
38679
38735
  'default': Page$f,
38680
- getStaticProps: getStaticProps$d
38736
+ getStaticProps: getStaticProps$e
38681
38737
  });
38682
38738
 
38683
38739
  var Page$g = function (_a) {
@@ -38689,7 +38745,7 @@ var Page$g = function (_a) {
38689
38745
  }, [propValuesStr]);
38690
38746
  return (createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
38691
38747
  };
38692
- 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 () {
38693
38749
  return __generator(this, function (_a) {
38694
38750
  switch (_a.label) {
38695
38751
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, IkasThemePageType.BLOG_INDEX)];
@@ -38701,7 +38757,7 @@ var getStaticProps$e = function (context) { return __awaiter(void 0, void 0, voi
38701
38757
  var index$5 = /*#__PURE__*/Object.freeze({
38702
38758
  __proto__: null,
38703
38759
  'default': Page$g,
38704
- getStaticProps: getStaticProps$e
38760
+ getStaticProps: getStaticProps$f
38705
38761
  });
38706
38762
 
38707
38763
  var Page$h = function (_a) {
@@ -38730,7 +38786,7 @@ var getStaticPaths$2 = function (context) { return __awaiter(void 0, void 0, voi
38730
38786
  }];
38731
38787
  });
38732
38788
  }); };
38733
- 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 () {
38734
38790
  return __generator(this, function (_a) {
38735
38791
  switch (_a.label) {
38736
38792
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, undefined, [
@@ -38746,7 +38802,7 @@ var _slug_$2 = /*#__PURE__*/Object.freeze({
38746
38802
  __proto__: null,
38747
38803
  'default': _slug_$1,
38748
38804
  getStaticPaths: getStaticPaths$2,
38749
- getStaticProps: getStaticProps$f
38805
+ getStaticProps: getStaticProps$g
38750
38806
  });
38751
38807
 
38752
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,54 +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
- })];
38015
- 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]),
38016
38050
  _d)];
38017
- case 4:
38051
+ case 5:
38018
38052
  _e = {};
38019
38053
  _c = [{}];
38020
- return [4 /*yield*/, serverSideTranslations.serverSideTranslations(locale, componentDirs, {
38021
- i18n: {
38022
- locales: serverRuntimeConfig.i18n.locales,
38023
- defaultLocale: serverRuntimeConfig.i18n.defaultLocale,
38024
- },
38025
- serializeConfig: false,
38026
- })];
38027
- 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]),
38028
38065
  _e.revalidate = 60,
38029
38066
  _e)];
38030
38067
  }
38031
38068
  });
38032
38069
  });
38033
38070
  };
38034
- SettingsHelper.getStaticProps = function (context, pageType, possiblePageTypes) {
38071
+ SettingsHelper.getStaticProps = function (context, pageType, possiblePageTypes, isEditor) {
38035
38072
  return __awaiter(this, void 0, void 0, function () {
38036
38073
  return __generator(this, function (_a) {
38037
38074
  switch (_a.label) {
38038
- case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType, possiblePageTypes)];
38075
+ case 0: return [4 /*yield*/, SettingsHelper.getPageData(context, false, pageType, possiblePageTypes, isEditor)];
38039
38076
  case 1: return [2 /*return*/, _a.sent()];
38040
38077
  }
38041
38078
  });
@@ -38265,16 +38302,17 @@ var CheckoutPage = function (_a) {
38265
38302
  };
38266
38303
  var _id_ = mobxReactLite.observer(CheckoutPage);
38267
38304
  var getServerSideProps = function (context) { return __awaiter(void 0, void 0, void 0, function () {
38268
- var id, locale, settings, storefront, themeLocalization, salesChannel, routing, redirect, checkout, checkoutSettings;
38269
- var _a;
38270
- return __generator(this, function (_b) {
38271
- 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) {
38272
38310
  case 0:
38273
38311
  id = context.query.id;
38274
38312
  locale = context.locale || context.defaultLocale || "en";
38275
38313
  return [4 /*yield*/, SettingsHelper.getSettings(locale)];
38276
38314
  case 1:
38277
- settings = _b.sent();
38315
+ settings = _d.sent();
38278
38316
  // TODO maybe remove this and convert this page to static
38279
38317
  if (!settings ||
38280
38318
  !settings.storefront.mainStorefrontThemeId ||
@@ -38290,7 +38328,7 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
38290
38328
  IkasStorefrontConfig.storefrontThemeId = storefront.mainStorefrontThemeId;
38291
38329
  IkasStorefrontConfig.salesChannelId = storefront.salesChannelId;
38292
38330
  IkasStorefrontConfig.priceListId = routing.priceListId || undefined;
38293
- 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; });
38294
38332
  IkasStorefrontConfig.routings = storefront.routings;
38295
38333
  IkasStorefrontConfig.paymentGateways = salesChannel.paymentGateways || [];
38296
38334
  IkasStorefrontConfig.gtmId = storefront.gtmId || undefined;
@@ -38306,24 +38344,33 @@ var getServerSideProps = function (context) { return __awaiter(void 0, void 0, v
38306
38344
  }
38307
38345
  return [4 /*yield*/, IkasCheckoutAPI.getCheckoutById(id)];
38308
38346
  case 2:
38309
- checkout = _b.sent();
38310
- if (!checkout) return [3 /*break*/, 4];
38347
+ checkout = _d.sent();
38348
+ if (!checkout) return [3 /*break*/, 5];
38311
38349
  return [4 /*yield*/, IkasCheckoutAPI.listCheckoutSettings()];
38312
38350
  case 3:
38313
- checkoutSettings = _b.sent();
38314
- return [2 /*return*/, {
38315
- props: {
38316
- checkoutStr: JSON.stringify(checkout),
38317
- checkoutSettingsStr: (checkoutSettings === null || checkoutSettings === void 0 ? void 0 : checkoutSettings.length) ? JSON.stringify(checkoutSettings[0])
38318
- : null,
38319
- configJson: IkasStorefrontConfig.getJson(),
38320
- returnPolicy: themeLocalization.returnPolicy || "",
38321
- privacyPolicy: themeLocalization.privacyPolicy || "",
38322
- termsOfService: themeLocalization.termsOfService || "",
38323
- queryParams: context.query,
38324
- },
38325
- }];
38326
- 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()];
38327
38374
  }
38328
38375
  });
38329
38376
  }); };
@@ -38558,10 +38605,19 @@ var IkasPageEditor$1 = dynamic__default['default'](function () { return Promise.
38558
38605
  var Page$c = function () {
38559
38606
  return React.createElement(IkasPageEditor$1, null);
38560
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
+ }); };
38561
38616
  var editor = mobxReactLite.observer(Page$c);
38562
38617
 
38563
38618
  var editor$1 = /*#__PURE__*/Object.freeze({
38564
38619
  __proto__: null,
38620
+ getStaticProps: getStaticProps$b,
38565
38621
  'default': editor
38566
38622
  });
38567
38623
 
@@ -38574,7 +38630,7 @@ var Page$d = function (_a) {
38574
38630
  }, [propValuesStr]);
38575
38631
  return (React.createElement(IkasPage, { settingsStr: settingsStr, page: page, propValues: propValues }));
38576
38632
  };
38577
- 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 () {
38578
38634
  return __generator(this, function (_a) {
38579
38635
  switch (_a.label) {
38580
38636
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.FAVORITE_PRODUCTS)];
@@ -38586,7 +38642,7 @@ var getStaticProps$b = function (context) { return __awaiter(void 0, void 0, voi
38586
38642
  var favoriteProducts = /*#__PURE__*/Object.freeze({
38587
38643
  __proto__: null,
38588
38644
  'default': Page$d,
38589
- getStaticProps: getStaticProps$b
38645
+ getStaticProps: getStaticProps$c
38590
38646
  });
38591
38647
 
38592
38648
  var Page$e = function (_a) {
@@ -38606,7 +38662,7 @@ var Page$e = function (_a) {
38606
38662
  }, [isBrowser, propValuesStr]);
38607
38663
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
38608
38664
  };
38609
- 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 () {
38610
38666
  return __generator(this, function (_a) {
38611
38667
  switch (_a.label) {
38612
38668
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.SEARCH)];
@@ -38618,7 +38674,7 @@ var getStaticProps$c = function (context) { return __awaiter(void 0, void 0, voi
38618
38674
  var search = /*#__PURE__*/Object.freeze({
38619
38675
  __proto__: null,
38620
38676
  'default': Page$e,
38621
- getStaticProps: getStaticProps$c
38677
+ getStaticProps: getStaticProps$d
38622
38678
  });
38623
38679
 
38624
38680
  var Page$f = function (_a) {
@@ -38632,7 +38688,7 @@ var Page$f = function (_a) {
38632
38688
  }, [propValuesStr]);
38633
38689
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues }));
38634
38690
  };
38635
- 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 () {
38636
38692
  var props;
38637
38693
  return __generator(this, function (_a) {
38638
38694
  switch (_a.label) {
@@ -38654,7 +38710,7 @@ var getStaticProps$d = function (context) { return __awaiter(void 0, void 0, voi
38654
38710
  var _404 = /*#__PURE__*/Object.freeze({
38655
38711
  __proto__: null,
38656
38712
  'default': Page$f,
38657
- getStaticProps: getStaticProps$d
38713
+ getStaticProps: getStaticProps$e
38658
38714
  });
38659
38715
 
38660
38716
  var Page$g = function (_a) {
@@ -38666,7 +38722,7 @@ var Page$g = function (_a) {
38666
38722
  }, [propValuesStr]);
38667
38723
  return (React.createElement(IkasPage, { merchantSettings: merchantSettings, settingsStr: settingsStr, page: page, propValues: propValues, addOgpMetas: true }));
38668
38724
  };
38669
- 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 () {
38670
38726
  return __generator(this, function (_a) {
38671
38727
  switch (_a.label) {
38672
38728
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, exports.IkasThemePageType.BLOG_INDEX)];
@@ -38678,7 +38734,7 @@ var getStaticProps$e = function (context) { return __awaiter(void 0, void 0, voi
38678
38734
  var index$5 = /*#__PURE__*/Object.freeze({
38679
38735
  __proto__: null,
38680
38736
  'default': Page$g,
38681
- getStaticProps: getStaticProps$e
38737
+ getStaticProps: getStaticProps$f
38682
38738
  });
38683
38739
 
38684
38740
  var Page$h = function (_a) {
@@ -38707,7 +38763,7 @@ var getStaticPaths$2 = function (context) { return __awaiter(void 0, void 0, voi
38707
38763
  }];
38708
38764
  });
38709
38765
  }); };
38710
- 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 () {
38711
38767
  return __generator(this, function (_a) {
38712
38768
  switch (_a.label) {
38713
38769
  case 0: return [4 /*yield*/, SettingsHelper.getStaticProps(context, undefined, [
@@ -38723,7 +38779,7 @@ var _slug_$2 = /*#__PURE__*/Object.freeze({
38723
38779
  __proto__: null,
38724
38780
  'default': _slug_$1,
38725
38781
  getStaticPaths: getStaticPaths$2,
38726
- getStaticProps: getStaticProps$f
38782
+ getStaticProps: getStaticProps$g
38727
38783
  });
38728
38784
 
38729
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.8",
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",