@xfe-repo/web-utils 1.0.0 → 1.0.2

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