@xfe-repo/web-utils 1.2.1 → 1.3.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.ts CHANGED
@@ -11,19 +11,5 @@ declare const isProduction: boolean;
11
11
  declare const release: string;
12
12
  declare const apiEnv: ApiEnv;
13
13
  declare const business: Business;
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 isTestEnv: (_apiEnv: ApiEnv) => _apiEnv is TestEnv;
18
- declare const getEnvApi: (envApis: Record<ApiEnv, string>, _apiEnv?: ApiEnv) => string;
19
- declare const getBffApi: (_apiEnv?: ApiEnv) => string;
20
- declare function getEnvDomain(hostname: string): string;
21
- declare const sentryConfig: {
22
- dsn: string;
23
- release: string;
24
- enable: boolean;
25
- enablePerformance: boolean;
26
- debug: boolean;
27
- };
28
14
 
29
- export { type ApiEnv, type Business, type TestEnv, apiEnv, assetsHost, business, getBffApi, getEnvApi, getEnvDomain, getErpSaasOrigin, getMSaasOrigin, isAndroid, isClient, isIos, isProduction, isSSR, isServer, isTestEnv, isWeiXin, release, sentryConfig };
15
+ export { type ApiEnv, type Business, type TestEnv, apiEnv, business, isAndroid, isClient, isIos, isProduction, isSSR, isServer, isWeiXin, release };
package/dist/env.js CHANGED
@@ -31,23 +31,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var env_exports = {};
32
32
  __export(env_exports, {
33
33
  apiEnv: () => apiEnv,
34
- assetsHost: () => assetsHost,
35
34
  business: () => business,
36
- getBffApi: () => getBffApi,
37
- getEnvApi: () => getEnvApi,
38
- getEnvDomain: () => getEnvDomain,
39
- getErpSaasOrigin: () => getErpSaasOrigin,
40
- getMSaasOrigin: () => getMSaasOrigin,
41
35
  isAndroid: () => isAndroid,
42
36
  isClient: () => isClient,
43
37
  isIos: () => isIos,
44
38
  isProduction: () => isProduction,
45
39
  isSSR: () => isSSR,
46
40
  isServer: () => isServer,
47
- isTestEnv: () => isTestEnv,
48
41
  isWeiXin: () => isWeiXin,
49
- release: () => release,
50
- sentryConfig: () => sentryConfig
42
+ release: () => release
51
43
  });
52
44
  module.exports = __toCommonJS(env_exports);
53
45
 
@@ -80,86 +72,16 @@ var isProduction = process.env.NODE_ENV === "production";
80
72
  var release = process.env.REACT_APP_RELEASE || "dev";
81
73
  var apiEnv = process.env.REACT_APP_API_ENV || cookies.get("apiEnv");
82
74
  var business = process.env.REACT_APP_BUSINESS;
83
- var assetsHost = "https://imgs.xianghuanji.com/";
84
- var erpSaasOriginDic = {
85
- dev: `http://test.erp-saas.t.eshetang.com`,
86
- test: `http://test.erp-saas.t.eshetang.com`,
87
- stage: "http://stage.erp-saas.t.eshetang.com",
88
- beta: "https://erp.beta.eshetang.com",
89
- prod: "https://erp.eshetang.com"
90
- };
91
- var getErpSaasOrigin = (_apiEnv) => {
92
- if (isTestEnv(_apiEnv)) {
93
- return erpSaasOriginDic["test"].replace("test", _apiEnv);
94
- } else {
95
- return erpSaasOriginDic[_apiEnv];
96
- }
97
- };
98
- var mSaasOriginDic = {
99
- dev: `http://test.m.t.eshetang.com`,
100
- test: `http://test.m.t.eshetang.com`,
101
- stage: "http://stage.m.t.eshetang.com",
102
- beta: "https://beta.m.eshetang.com",
103
- prod: "https://m.eshetang.com"
104
- };
105
- var getMSaasOrigin = (_apiEnv) => {
106
- if (isTestEnv(_apiEnv)) {
107
- return mSaasOriginDic["test"].replace("test", _apiEnv);
108
- } else {
109
- return mSaasOriginDic[_apiEnv];
110
- }
111
- };
112
- var bffApiList = {
113
- dev: "http://localhost:6003/",
114
- test: `http://test.bff-s.t.eshetang.com/`,
115
- stage: "http://stage.bff-s.t.eshetang.com/",
116
- beta: "https://bff.beta.eshetang.com/",
117
- prod: "https://bff.eshetang.com/"
118
- };
119
- var isTestEnv = (_apiEnv) => {
120
- return _apiEnv.startsWith("test");
121
- };
122
- var getEnvApi = (envApis, _apiEnv = apiEnv) => {
123
- if (isTestEnv(_apiEnv)) {
124
- return envApis["test"].replace("test", _apiEnv);
125
- } else {
126
- return envApis[_apiEnv];
127
- }
128
- };
129
- var getBffApi = (_apiEnv = apiEnv) => {
130
- return getEnvApi(bffApiList, _apiEnv);
131
- };
132
- function getEnvDomain(hostname) {
133
- var _a;
134
- const isTest = hostname.startsWith("test");
135
- const isStage = hostname.startsWith("stage");
136
- return isTest || isStage ? ((_a = hostname.match(/[^(\w*)]+.*/)) == null ? void 0 : _a[0]) || hostname : hostname;
137
- }
138
- var sentryConfig = {
139
- dsn: "https://cb37486fcf8d44d68080373bb354e0f6@bug.dev.cm/1",
140
- release,
141
- enable: release.includes("release"),
142
- enablePerformance: release.includes("release"),
143
- debug: !isProduction
144
- };
145
75
  // Annotate the CommonJS export names for ESM import in node:
146
76
  0 && (module.exports = {
147
77
  apiEnv,
148
- assetsHost,
149
78
  business,
150
- getBffApi,
151
- getEnvApi,
152
- getEnvDomain,
153
- getErpSaasOrigin,
154
- getMSaasOrigin,
155
79
  isAndroid,
156
80
  isClient,
157
81
  isIos,
158
82
  isProduction,
159
83
  isSSR,
160
84
  isServer,
161
- isTestEnv,
162
85
  isWeiXin,
163
- release,
164
- sentryConfig
86
+ release
165
87
  });
package/dist/host.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { ApiEnv, TestEnv } from './env.js';
2
+
3
+ declare const isTestEnv: (_apiEnv: ApiEnv) => _apiEnv is TestEnv;
4
+ declare const getEnvApi: (envApis: Record<ApiEnv, string>, _apiEnv: ApiEnv) => string;
5
+ declare function getEnvDomain(hostname: string): string;
6
+ declare const getBffApi: (_apiEnv: ApiEnv) => string;
7
+
8
+ export { getBffApi, getEnvApi, getEnvDomain, isTestEnv };
package/dist/host.js ADDED
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/host.ts
21
+ var host_exports = {};
22
+ __export(host_exports, {
23
+ getBffApi: () => getBffApi,
24
+ getEnvApi: () => getEnvApi,
25
+ getEnvDomain: () => getEnvDomain,
26
+ isTestEnv: () => isTestEnv
27
+ });
28
+ module.exports = __toCommonJS(host_exports);
29
+ var isTestEnv = (_apiEnv) => {
30
+ return _apiEnv.startsWith("test");
31
+ };
32
+ var getEnvApi = (envApis, _apiEnv) => {
33
+ if (isTestEnv(_apiEnv)) {
34
+ return envApis["test"].replace("test", _apiEnv);
35
+ } else {
36
+ return envApis[_apiEnv];
37
+ }
38
+ };
39
+ function getEnvDomain(hostname) {
40
+ var _a;
41
+ const isTest = hostname.startsWith("test");
42
+ const isStage = hostname.startsWith("stage");
43
+ return isTest || isStage ? ((_a = hostname.match(/[^(\w*)]+.*/)) == null ? void 0 : _a[0]) || hostname : hostname;
44
+ }
45
+ var bffApiList = {
46
+ dev: "http://localhost:6003/",
47
+ test: `http://test.bff-s.t.eshetang.com/`,
48
+ stage: "http://stage.bff-s.t.eshetang.com/",
49
+ beta: "https://bff.beta.eshetang.com/",
50
+ prod: "https://bff.eshetang.com/"
51
+ };
52
+ var getBffApi = (_apiEnv) => {
53
+ return getEnvApi(bffApiList, _apiEnv);
54
+ };
55
+ // Annotate the CommonJS export names for ESM import in node:
56
+ 0 && (module.exports = {
57
+ getBffApi,
58
+ getEnvApi,
59
+ getEnvDomain,
60
+ isTestEnv
61
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xfe-repo/web-utils",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "sideEffects": false,
5
5
  "module": "dist/*.js",
6
6
  "types": "types/*.d.ts",
@@ -28,8 +28,11 @@
28
28
  "@types/throttle-debounce": "^5.0.2",
29
29
  "@types/js-cookie": "^3.0.5",
30
30
  "@types/node": "^20.10.3",
31
- "@xfe-repo/typescript-config": "0.0.6",
32
- "@xfe-repo/eslint-config": "0.0.5"
31
+ "@xfe-repo/eslint-config": "0.0.5",
32
+ "@xfe-repo/typescript-config": "0.0.6"
33
+ },
34
+ "publishConfig": {
35
+ "registry": "https://registry.npmjs.org/"
33
36
  },
34
37
  "scripts": {
35
38
  "build": "tsup",