@xfe-repo/web-utils 1.0.0 → 1.0.1

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/dist/env.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- type ApiEnv = 'dev' | 'beta' | 'prod' | 'test';
1
+ type TestEnv = `test${number | ''}`;
2
+ type ApiEnv = 'dev' | 'stage' | 'beta' | 'prod' | TestEnv;
2
3
  type Business = 'erp_pc' | 'saas_pc' | 'platform_pc';
3
4
  declare const isServer: boolean;
4
5
  declare const isClient: boolean;
@@ -6,10 +7,20 @@ declare const isSSR: boolean;
6
7
  declare const isIos: boolean;
7
8
  declare const isAndroid: boolean;
8
9
  declare const isWeiXin: boolean;
9
- declare const isProd: boolean;
10
+ declare const isProduction: boolean;
11
+ declare const release: string;
10
12
  declare const apiEnv: ApiEnv;
11
- declare const business: Business;
12
- declare const getBffApi: (apiEnvFormPayload?: ApiEnv) => string;
13
+ declare const assetsHost = "https://imgs.xianghuanji.com/";
14
+ declare const getErpSaasOrigin: (_apiEnv: ApiEnv) => string;
15
+ declare const getMSaasOrigin: (_apiEnv: ApiEnv) => string;
16
+ declare const getBffApi: (_apiEnv?: ApiEnv) => string;
13
17
  declare function getEnvDomain(hostname: string): string;
18
+ declare const sentryConfig: {
19
+ dsn: string;
20
+ release: string;
21
+ enable: boolean;
22
+ enablePerformance: boolean;
23
+ debug: boolean;
24
+ };
14
25
 
15
- export { type ApiEnv, type Business, apiEnv, business, getBffApi, getEnvDomain, isAndroid, isClient, isIos, isProd, isSSR, isServer, isWeiXin };
26
+ export { type ApiEnv, type Business, type TestEnv, apiEnv, assetsHost, getBffApi, getEnvDomain, getErpSaasOrigin, getMSaasOrigin, isAndroid, isClient, isIos, isProduction, isSSR, isServer, isWeiXin, release, sentryConfig };
package/dist/env.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- type ApiEnv = 'dev' | 'beta' | 'prod' | 'test';
1
+ type TestEnv = `test${number | ''}`;
2
+ type ApiEnv = 'dev' | 'stage' | 'beta' | 'prod' | TestEnv;
2
3
  type Business = 'erp_pc' | 'saas_pc' | 'platform_pc';
3
4
  declare const isServer: boolean;
4
5
  declare const isClient: boolean;
@@ -6,10 +7,20 @@ declare const isSSR: boolean;
6
7
  declare const isIos: boolean;
7
8
  declare const isAndroid: boolean;
8
9
  declare const isWeiXin: boolean;
9
- declare const isProd: boolean;
10
+ declare const isProduction: boolean;
11
+ declare const release: string;
10
12
  declare const apiEnv: ApiEnv;
11
- declare const business: Business;
12
- declare const getBffApi: (apiEnvFormPayload?: ApiEnv) => string;
13
+ declare const assetsHost = "https://imgs.xianghuanji.com/";
14
+ declare const getErpSaasOrigin: (_apiEnv: ApiEnv) => string;
15
+ declare const getMSaasOrigin: (_apiEnv: ApiEnv) => string;
16
+ declare const getBffApi: (_apiEnv?: ApiEnv) => string;
13
17
  declare function getEnvDomain(hostname: string): string;
18
+ declare const sentryConfig: {
19
+ dsn: string;
20
+ release: string;
21
+ enable: boolean;
22
+ enablePerformance: boolean;
23
+ debug: boolean;
24
+ };
14
25
 
15
- export { type ApiEnv, type Business, apiEnv, business, getBffApi, getEnvDomain, isAndroid, isClient, isIos, isProd, isSSR, isServer, isWeiXin };
26
+ export { type ApiEnv, type Business, type TestEnv, apiEnv, assetsHost, getBffApi, getEnvDomain, getErpSaasOrigin, getMSaasOrigin, isAndroid, isClient, isIos, isProduction, isSSR, isServer, isWeiXin, release, sentryConfig };
package/dist/env.js CHANGED
@@ -21,16 +21,20 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var env_exports = {};
22
22
  __export(env_exports, {
23
23
  apiEnv: () => apiEnv,
24
- business: () => business,
24
+ assetsHost: () => assetsHost,
25
25
  getBffApi: () => getBffApi,
26
26
  getEnvDomain: () => getEnvDomain,
27
+ getErpSaasOrigin: () => getErpSaasOrigin,
28
+ getMSaasOrigin: () => getMSaasOrigin,
27
29
  isAndroid: () => isAndroid,
28
30
  isClient: () => isClient,
29
31
  isIos: () => isIos,
30
- isProd: () => isProd,
32
+ isProduction: () => isProduction,
31
33
  isSSR: () => isSSR,
32
34
  isServer: () => isServer,
33
- isWeiXin: () => isWeiXin
35
+ isWeiXin: () => isWeiXin,
36
+ release: () => release,
37
+ sentryConfig: () => sentryConfig
34
38
  });
35
39
  module.exports = __toCommonJS(env_exports);
36
40
  var isServer = typeof window === "undefined";
@@ -45,39 +49,83 @@ try {
45
49
  var isIos = /ios/i.test(navigator.userAgent);
46
50
  var isAndroid = /android/i.test(navigator.userAgent);
47
51
  var isWeiXin = /MicroMessenger/i.test(navigator.userAgent);
48
- var isProd = process.env.NODE_ENV === "production";
49
- var apiEnv = process.env.REACT_APP_API_ENV;
50
- var business = process.env.REACT_APP_BUSINESS;
52
+ var isProduction = process.env["NODE_ENV"] === "production";
53
+ var release = process.env["REACT_APP_RELEASE"] || "dev";
54
+ var apiEnv = process.env["REACT_APP_API_ENV"];
55
+ var assetsHost = "https://imgs.xianghuanji.com/";
56
+ var erpSaasOriginDic = {
57
+ dev: `http://test.erp-saas.t.eshetang.com`,
58
+ test: `http://test.erp-saas.t.eshetang.com`,
59
+ stage: "http://stage.erp-saas.t.eshetang.com",
60
+ beta: "https://erp.beta.eshetang.com",
61
+ prod: "https://erp.eshetang.com"
62
+ };
63
+ var getErpSaasOrigin = (_apiEnv) => {
64
+ if (isTestEnv(_apiEnv)) {
65
+ return erpSaasOriginDic["test"].replace("test", _apiEnv);
66
+ } else {
67
+ return erpSaasOriginDic[_apiEnv];
68
+ }
69
+ };
70
+ var mSaasOriginDic = {
71
+ dev: `http://test.m.t.eshetang.com`,
72
+ test: `http://test.m.t.eshetang.com`,
73
+ stage: "http://stage.m.t.eshetang.com",
74
+ beta: "https://beta.m.eshetang.com",
75
+ prod: "https://m.eshetang.com"
76
+ };
77
+ var getMSaasOrigin = (_apiEnv) => {
78
+ if (isTestEnv(_apiEnv)) {
79
+ return mSaasOriginDic["test"].replace("test", _apiEnv);
80
+ } else {
81
+ return mSaasOriginDic[_apiEnv];
82
+ }
83
+ };
51
84
  var bffApiList = {
52
- dev: "http://192.168.1.65:8010",
53
- test: `http://test.jarvis.t.eshetang.com`,
54
- beta: "https://jarvis.beta.eshetang.com",
55
- prod: "https://jarvis.eshetang.com"
85
+ dev: "http://localhost:6003/",
86
+ test: `http://test.bff-s.t.eshetang.com/`,
87
+ stage: "http://stage.bff-s.t.eshetang.com",
88
+ beta: "https://bff.beta.eshetang.com",
89
+ prod: "https://bff.eshetang.com/"
56
90
  };
57
- var getBffApi = (apiEnvFormPayload = apiEnv) => {
58
- let matchKey = apiEnvFormPayload;
59
- if (apiEnvFormPayload.startsWith("test")) {
60
- return bffApiList["test"].replace("test", matchKey);
91
+ function isTestEnv(_apiEnv) {
92
+ return _apiEnv.startsWith("test");
93
+ }
94
+ var getBffApi = (_apiEnv = apiEnv) => {
95
+ if (isTestEnv(_apiEnv)) {
96
+ return bffApiList["test"].replace("test", _apiEnv);
61
97
  } else {
62
- return bffApiList[apiEnvFormPayload];
98
+ return bffApiList[_apiEnv];
63
99
  }
64
100
  };
65
101
  function getEnvDomain(hostname) {
66
102
  var _a;
67
103
  const isTest = hostname.startsWith("test");
68
- return isTest ? ((_a = hostname.match(/[^(\w*)]+.*/)) == null ? void 0 : _a[0]) || hostname : hostname;
104
+ const isStage = hostname.startsWith("stage");
105
+ return isTest || isStage ? ((_a = hostname.match(/[^(\w*)]+.*/)) == null ? void 0 : _a[0]) || hostname : hostname;
69
106
  }
107
+ var sentryConfig = {
108
+ dsn: "https://cb37486fcf8d44d68080373bb354e0f6@bug.dev.cm/1",
109
+ release,
110
+ enable: release.includes("release"),
111
+ enablePerformance: release.includes("release"),
112
+ debug: !isProduction
113
+ };
70
114
  // Annotate the CommonJS export names for ESM import in node:
71
115
  0 && (module.exports = {
72
116
  apiEnv,
73
- business,
117
+ assetsHost,
74
118
  getBffApi,
75
119
  getEnvDomain,
120
+ getErpSaasOrigin,
121
+ getMSaasOrigin,
76
122
  isAndroid,
77
123
  isClient,
78
124
  isIos,
79
- isProd,
125
+ isProduction,
80
126
  isSSR,
81
127
  isServer,
82
- isWeiXin
128
+ isWeiXin,
129
+ release,
130
+ sentryConfig
83
131
  });
package/dist/env.mjs CHANGED
@@ -13,38 +13,82 @@ try {
13
13
  var isIos = /ios/i.test(navigator.userAgent);
14
14
  var isAndroid = /android/i.test(navigator.userAgent);
15
15
  var isWeiXin = /MicroMessenger/i.test(navigator.userAgent);
16
- var isProd = process.env.NODE_ENV === "production";
17
- var apiEnv = process.env.REACT_APP_API_ENV;
18
- var business = process.env.REACT_APP_BUSINESS;
16
+ var isProduction = process.env["NODE_ENV"] === "production";
17
+ var release = process.env["REACT_APP_RELEASE"] || "dev";
18
+ var apiEnv = process.env["REACT_APP_API_ENV"];
19
+ var assetsHost = "https://imgs.xianghuanji.com/";
20
+ var erpSaasOriginDic = {
21
+ dev: `http://test.erp-saas.t.eshetang.com`,
22
+ test: `http://test.erp-saas.t.eshetang.com`,
23
+ stage: "http://stage.erp-saas.t.eshetang.com",
24
+ beta: "https://erp.beta.eshetang.com",
25
+ prod: "https://erp.eshetang.com"
26
+ };
27
+ var getErpSaasOrigin = (_apiEnv) => {
28
+ if (isTestEnv(_apiEnv)) {
29
+ return erpSaasOriginDic["test"].replace("test", _apiEnv);
30
+ } else {
31
+ return erpSaasOriginDic[_apiEnv];
32
+ }
33
+ };
34
+ var mSaasOriginDic = {
35
+ dev: `http://test.m.t.eshetang.com`,
36
+ test: `http://test.m.t.eshetang.com`,
37
+ stage: "http://stage.m.t.eshetang.com",
38
+ beta: "https://beta.m.eshetang.com",
39
+ prod: "https://m.eshetang.com"
40
+ };
41
+ var getMSaasOrigin = (_apiEnv) => {
42
+ if (isTestEnv(_apiEnv)) {
43
+ return mSaasOriginDic["test"].replace("test", _apiEnv);
44
+ } else {
45
+ return mSaasOriginDic[_apiEnv];
46
+ }
47
+ };
19
48
  var bffApiList = {
20
- dev: "http://192.168.1.65:8010",
21
- test: `http://test.jarvis.t.eshetang.com`,
22
- beta: "https://jarvis.beta.eshetang.com",
23
- prod: "https://jarvis.eshetang.com"
24
- };
25
- var getBffApi = (apiEnvFormPayload = apiEnv) => {
26
- let matchKey = apiEnvFormPayload;
27
- if (apiEnvFormPayload.startsWith("test")) {
28
- return bffApiList["test"].replace("test", matchKey);
49
+ dev: "http://localhost:6003/",
50
+ test: `http://test.bff-s.t.eshetang.com/`,
51
+ stage: "http://stage.bff-s.t.eshetang.com",
52
+ beta: "https://bff.beta.eshetang.com",
53
+ prod: "https://bff.eshetang.com/"
54
+ };
55
+ function isTestEnv(_apiEnv) {
56
+ return _apiEnv.startsWith("test");
57
+ }
58
+ var getBffApi = (_apiEnv = apiEnv) => {
59
+ if (isTestEnv(_apiEnv)) {
60
+ return bffApiList["test"].replace("test", _apiEnv);
29
61
  } else {
30
- return bffApiList[apiEnvFormPayload];
62
+ return bffApiList[_apiEnv];
31
63
  }
32
64
  };
33
65
  function getEnvDomain(hostname) {
34
66
  var _a;
35
67
  const isTest = hostname.startsWith("test");
36
- return isTest ? ((_a = hostname.match(/[^(\w*)]+.*/)) == null ? void 0 : _a[0]) || hostname : hostname;
68
+ const isStage = hostname.startsWith("stage");
69
+ return isTest || isStage ? ((_a = hostname.match(/[^(\w*)]+.*/)) == null ? void 0 : _a[0]) || hostname : hostname;
37
70
  }
71
+ var sentryConfig = {
72
+ dsn: "https://cb37486fcf8d44d68080373bb354e0f6@bug.dev.cm/1",
73
+ release,
74
+ enable: release.includes("release"),
75
+ enablePerformance: release.includes("release"),
76
+ debug: !isProduction
77
+ };
38
78
  export {
39
79
  apiEnv,
40
- business,
80
+ assetsHost,
41
81
  getBffApi,
42
82
  getEnvDomain,
83
+ getErpSaasOrigin,
84
+ getMSaasOrigin,
43
85
  isAndroid,
44
86
  isClient,
45
87
  isIos,
46
- isProd,
88
+ isProduction,
47
89
  isSSR,
48
90
  isServer,
49
- isWeiXin
91
+ isWeiXin,
92
+ release,
93
+ sentryConfig
50
94
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-utils",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "sideEffects": false,
5
5
  "exports": {
6
6
  "./*": {
@@ -21,8 +21,8 @@
21
21
  "eslint": "^8.53.0",
22
22
  "tsup": "^8.0.1",
23
23
  "typescript": "^5.2.2",
24
- "@xfe-repo/eslint-config": "0.0.0",
25
- "@xfe-repo/typescript-config": "0.0.0"
24
+ "@xfe-repo/eslint-config": "0.0.1",
25
+ "@xfe-repo/typescript-config": "0.0.1"
26
26
  },
27
27
  "scripts": {
28
28
  "build": "tsup",