@microbt/environment 1.2.7 → 1.2.8
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/README.md +2 -0
- package/dist/esm/cookie.js +1 -1
- package/dist/esm/environment/factory.js +5 -3
- package/dist/esm/environment/index.js +1 -0
- package/dist/esm/environment/strategies/cinvue.d.ts +7 -0
- package/dist/esm/environment/strategies/cinvue.js +42 -0
- package/dist/esm/gateway/factory.js +5 -3
- package/dist/esm/gateway/strategies/cinvue.d.ts +4 -0
- package/dist/esm/gateway/strategies/cinvue.js +19 -0
- package/dist/esm/gateway/strategies/index.d.ts +1 -0
- package/dist/esm/gateway/strategies/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/esm/cookie.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/cookie.ts
|
|
2
|
-
var COOKIE_REGEX = (name) => new RegExp("(^| )" + name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "=([^;]
|
|
2
|
+
var COOKIE_REGEX = (name) => new RegExp("(^| )" + name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "=([^;]*)");
|
|
3
3
|
function getCookie(name) {
|
|
4
4
|
try {
|
|
5
5
|
const match = document.cookie.match(COOKIE_REGEX(name));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/environment/factory.ts
|
|
2
2
|
import { CinmooreEnvironmentStrategy } from "./strategies/cinmoore";
|
|
3
|
+
import { CinvueEnvironmentStrategy } from "./strategies/cinvue";
|
|
3
4
|
import { FronAIEnvironmentStrategy } from "./strategies/fronai";
|
|
4
5
|
import { LocalEnvironmentStrategy } from "./strategies/local";
|
|
5
6
|
import { Safio365EnvironmentStrategy } from "./strategies/safio365";
|
|
@@ -22,12 +23,13 @@ var EnvironmentStrategyFactory = _EnvironmentStrategyFactory;
|
|
|
22
23
|
EnvironmentStrategyFactory.strategies = /* @__PURE__ */ new Map();
|
|
23
24
|
EnvironmentStrategyFactory.localStrategy = new LocalEnvironmentStrategy();
|
|
24
25
|
(() => {
|
|
25
|
-
_EnvironmentStrategyFactory.strategies.set("superacme.com", new SuperAcmeEnvironmentStrategy());
|
|
26
|
-
_EnvironmentStrategyFactory.strategies.set("safio365.com", new Safio365EnvironmentStrategy());
|
|
27
|
-
_EnvironmentStrategyFactory.strategies.set("sensforge.com", new SensforgeEnvironmentStrategy());
|
|
28
26
|
_EnvironmentStrategyFactory.strategies.set("cinmoore.com", new CinmooreEnvironmentStrategy());
|
|
29
27
|
_EnvironmentStrategyFactory.strategies.set("cinmoore.cn", new CinmooreEnvironmentStrategy());
|
|
28
|
+
_EnvironmentStrategyFactory.strategies.set("cinvue.com", new CinvueEnvironmentStrategy());
|
|
30
29
|
_EnvironmentStrategyFactory.strategies.set("fronai.cn", new FronAIEnvironmentStrategy());
|
|
30
|
+
_EnvironmentStrategyFactory.strategies.set("safio365.com", new Safio365EnvironmentStrategy());
|
|
31
|
+
_EnvironmentStrategyFactory.strategies.set("sensforge.com", new SensforgeEnvironmentStrategy());
|
|
32
|
+
_EnvironmentStrategyFactory.strategies.set("superacme.com", new SuperAcmeEnvironmentStrategy());
|
|
31
33
|
_EnvironmentStrategyFactory.strategies.set("superacmeglobal.com", new SuperacmeGlobalEnvironmentStrategy());
|
|
32
34
|
})();
|
|
33
35
|
export {
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/environment/strategies/cinvue.ts
|
|
2
|
+
var CinvueEnvironmentStrategy = class {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.features = {
|
|
5
|
+
supportEnv: true,
|
|
6
|
+
supportRegion: false,
|
|
7
|
+
supportAWS: false
|
|
8
|
+
};
|
|
9
|
+
this.ENV_PATTERNS = {
|
|
10
|
+
// 匹配 -dev、-dev1、-dev-1、-dev. 等
|
|
11
|
+
dev: /-dev(?:\d*)?(?:-|\.|\b|$)/,
|
|
12
|
+
// 匹配 -test、-test1、-test-1、-test. 等
|
|
13
|
+
test: /-test(?:\d*)?(?:-|\.|\b|$)/,
|
|
14
|
+
// 匹配 -pre、-pre1、-pre-1、-pre. 等
|
|
15
|
+
pre: /-pre(?:\d*)?(?:-|\.|\b|$)/,
|
|
16
|
+
// 匹配 -gray、-gray1、-gray-1、-gray. 等
|
|
17
|
+
gray: /-gray(?:\d*)?(?:-|\.|\b|$)/,
|
|
18
|
+
// 本地环境
|
|
19
|
+
local: /^(localhost|127\.0\.0\.1|0\.0\.0\.0)(?::\d+)?$/
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
getEnvironment(host) {
|
|
23
|
+
if (this.ENV_PATTERNS.local.test(host)) {
|
|
24
|
+
return "local";
|
|
25
|
+
}
|
|
26
|
+
for (const [env, pattern] of Object.entries(this.ENV_PATTERNS)) {
|
|
27
|
+
if (pattern.test(host)) {
|
|
28
|
+
return env;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return "prod";
|
|
32
|
+
}
|
|
33
|
+
getRegion() {
|
|
34
|
+
return "unknown";
|
|
35
|
+
}
|
|
36
|
+
isAWS() {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
CinvueEnvironmentStrategy
|
|
42
|
+
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
CinmooreCnURLStrategy,
|
|
4
4
|
CinmooreComURLStrategy,
|
|
5
|
+
CinvueURLStrategy,
|
|
5
6
|
FronAiURLStrategy,
|
|
6
7
|
Safio365URLStrategy,
|
|
7
8
|
SensforgeURLStrategy,
|
|
@@ -20,12 +21,13 @@ var _URLStrategyFactory = class {
|
|
|
20
21
|
var URLStrategyFactory = _URLStrategyFactory;
|
|
21
22
|
URLStrategyFactory.strategies = /* @__PURE__ */ new Map();
|
|
22
23
|
(() => {
|
|
23
|
-
_URLStrategyFactory.strategies.set("superacme.com", new SuperAcmeURLStrategy());
|
|
24
|
-
_URLStrategyFactory.strategies.set("sensforge.com", new SensforgeURLStrategy());
|
|
25
|
-
_URLStrategyFactory.strategies.set("safio365.com", new Safio365URLStrategy());
|
|
26
24
|
_URLStrategyFactory.strategies.set("cinmoore.cn", new CinmooreCnURLStrategy());
|
|
27
25
|
_URLStrategyFactory.strategies.set("cinmoore.com", new CinmooreComURLStrategy());
|
|
26
|
+
_URLStrategyFactory.strategies.set("cinvue.com", new CinvueURLStrategy());
|
|
28
27
|
_URLStrategyFactory.strategies.set("fronai.cn", new FronAiURLStrategy());
|
|
28
|
+
_URLStrategyFactory.strategies.set("safio365.com", new Safio365URLStrategy());
|
|
29
|
+
_URLStrategyFactory.strategies.set("sensforge.com", new SensforgeURLStrategy());
|
|
30
|
+
_URLStrategyFactory.strategies.set("superacme.com", new SuperAcmeURLStrategy());
|
|
29
31
|
_URLStrategyFactory.strategies.set("superacmeglobal.com", new SuperAcmeGlobalURLStrategy());
|
|
30
32
|
})();
|
|
31
33
|
export {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/gateway/strategies/cinvue.ts
|
|
2
|
+
var CinvueURLStrategy = class {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.features = {
|
|
5
|
+
supportEnv: true,
|
|
6
|
+
supportRegion: false,
|
|
7
|
+
supportAWS: false
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
generateURL({ name, env = "prod", path = "" }) {
|
|
11
|
+
if (env === "prod" || !env) {
|
|
12
|
+
return `//${name}.cinvue.com${path}`;
|
|
13
|
+
}
|
|
14
|
+
return `//${name}-${env}.cinvue.com${path}`;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
CinvueURLStrategy
|
|
19
|
+
};
|