@ikas/storefront 0.0.62 → 0.0.64

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
@@ -1,4 +1,5 @@
1
1
  import { makeAutoObservable, toJS, runInAction, reaction, makeObservable, computed, observable, action, configure } from 'mobx';
2
+ import fs from 'fs';
2
3
  import React, { createElement, useState, useEffect, Fragment, useCallback, useRef, useMemo } from 'react';
3
4
  import { observer } from 'mobx-react-lite';
4
5
  import { useRouter } from 'next/router';
@@ -10864,11 +10865,10 @@ function setContext(setter) {
10864
10865
  var IkasStorefrontConfig = /** @class */ (function () {
10865
10866
  function IkasStorefrontConfig() {
10866
10867
  }
10867
- IkasStorefrontConfig.init = function (store, components, config, localTheme, apiUrlOverride) {
10868
+ IkasStorefrontConfig.init = function (store, components, config, apiUrlOverride) {
10868
10869
  IkasStorefrontConfig.store = store;
10869
10870
  IkasStorefrontConfig.components = components;
10870
10871
  IkasStorefrontConfig.config = config;
10871
- IkasStorefrontConfig.localTheme = localTheme;
10872
10872
  IkasStorefrontConfig.apiUrlOverride = apiUrlOverride || null;
10873
10873
  };
10874
10874
  IkasStorefrontConfig.components = {};
@@ -10891,12 +10891,8 @@ var Apollo = /** @class */ (function () {
10891
10891
  headers: newHeaders,
10892
10892
  };
10893
10893
  });
10894
- var hostname = typeof window !== "undefined" ? window.location.hostname : null;
10895
10894
  var httpLink = createHttpLink({
10896
- uri: IkasStorefrontConfig.apiUrlOverride ||
10897
- (hostname && hostname !== "localhost"
10898
- ? "https://" + hostname + "/api/sf/graphql"
10899
- : process.env.NEXT_PUBLIC_GQL_URL),
10895
+ uri: IkasStorefrontConfig.apiUrlOverride || process.env.NEXT_PUBLIC_GQL_URL,
10900
10896
  });
10901
10897
  _this._client = new ApolloClient({
10902
10898
  link: authLink.concat(httpLink),
@@ -24069,9 +24065,16 @@ var IkasThemeAPI = /** @class */ (function () {
24069
24065
  function IkasThemeAPI() {
24070
24066
  }
24071
24067
  IkasThemeAPI.fetchTheme = function () {
24072
- return __awaiter(this, void 0, void 0, function () {
24073
- return __generator(this, function (_a) {
24074
- return [2 /*return*/, IkasStorefrontConfig.localTheme];
24068
+ return new Promise(function (resolve, reject) {
24069
+ var themeJSONPath = "./public/theme.json";
24070
+ fs.readFile(themeJSONPath, {
24071
+ flag: "a+",
24072
+ }, function (err, file) {
24073
+ if (err) {
24074
+ return reject(err);
24075
+ }
24076
+ var result = file.length ? JSON.parse(file.toString()) : {};
24077
+ resolve(new IkasTheme(result));
24075
24078
  });
24076
24079
  });
24077
24080
  };
package/build/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var mobx = require('mobx');
6
+ var fs = require('fs');
6
7
  var React = require('react');
7
8
  var mobxReactLite = require('mobx-react-lite');
8
9
  var router = require('next/router');
@@ -13,6 +14,7 @@ var dynamic = require('next/dynamic');
13
14
 
14
15
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
16
 
17
+ var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
16
18
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
17
19
  var Image__default = /*#__PURE__*/_interopDefaultLegacy(Image$1);
18
20
  var Link__default = /*#__PURE__*/_interopDefaultLegacy(Link);
@@ -10876,11 +10878,10 @@ function setContext(setter) {
10876
10878
  var IkasStorefrontConfig = /** @class */ (function () {
10877
10879
  function IkasStorefrontConfig() {
10878
10880
  }
10879
- IkasStorefrontConfig.init = function (store, components, config, localTheme, apiUrlOverride) {
10881
+ IkasStorefrontConfig.init = function (store, components, config, apiUrlOverride) {
10880
10882
  IkasStorefrontConfig.store = store;
10881
10883
  IkasStorefrontConfig.components = components;
10882
10884
  IkasStorefrontConfig.config = config;
10883
- IkasStorefrontConfig.localTheme = localTheme;
10884
10885
  IkasStorefrontConfig.apiUrlOverride = apiUrlOverride || null;
10885
10886
  };
10886
10887
  IkasStorefrontConfig.components = {};
@@ -10903,12 +10904,8 @@ var Apollo = /** @class */ (function () {
10903
10904
  headers: newHeaders,
10904
10905
  };
10905
10906
  });
10906
- var hostname = typeof window !== "undefined" ? window.location.hostname : null;
10907
10907
  var httpLink = createHttpLink({
10908
- uri: IkasStorefrontConfig.apiUrlOverride ||
10909
- (hostname && hostname !== "localhost"
10910
- ? "https://" + hostname + "/api/sf/graphql"
10911
- : process.env.NEXT_PUBLIC_GQL_URL),
10908
+ uri: IkasStorefrontConfig.apiUrlOverride || process.env.NEXT_PUBLIC_GQL_URL,
10912
10909
  });
10913
10910
  _this._client = new ApolloClient({
10914
10911
  link: authLink.concat(httpLink),
@@ -24047,9 +24044,16 @@ var IkasThemeAPI = /** @class */ (function () {
24047
24044
  function IkasThemeAPI() {
24048
24045
  }
24049
24046
  IkasThemeAPI.fetchTheme = function () {
24050
- return __awaiter(this, void 0, void 0, function () {
24051
- return __generator(this, function (_a) {
24052
- return [2 /*return*/, IkasStorefrontConfig.localTheme];
24047
+ return new Promise(function (resolve, reject) {
24048
+ var themeJSONPath = "./public/theme.json";
24049
+ fs__default['default'].readFile(themeJSONPath, {
24050
+ flag: "a+",
24051
+ }, function (err, file) {
24052
+ if (err) {
24053
+ return reject(err);
24054
+ }
24055
+ var result = file.length ? JSON.parse(file.toString()) : {};
24056
+ resolve(new IkasTheme(result));
24053
24057
  });
24054
24058
  });
24055
24059
  };
@@ -1,10 +1,8 @@
1
- import { IkasTheme } from "../models/index";
2
1
  import { IkasBaseStore } from "../store/index";
3
2
  export declare class IkasStorefrontConfig {
4
3
  static store: IkasBaseStore;
5
4
  static components: any;
6
5
  static config: Record<string, any>;
7
- static localTheme: IkasTheme;
8
6
  static apiUrlOverride: string | null;
9
- static init(store: IkasBaseStore, components: any, config: Record<string, any>, localTheme: IkasTheme, apiUrlOverride?: string): void;
7
+ static init(store: IkasBaseStore, components: any, config: Record<string, any>, apiUrlOverride?: string): void;
10
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.62",
3
+ "version": "0.0.64",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",