@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 CHANGED
@@ -162,6 +162,8 @@ console.log(versionInfo);
162
162
 
163
163
  ### `getStatusBarHeight()`
164
164
 
165
+ > 2.6.0 新增
166
+
165
167
  获取 SuperAcme 应用的状态栏高度信息。
166
168
 
167
169
  **返回值**: 返回一个包含状态栏高度信息的对象:
@@ -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 {
@@ -8,6 +8,7 @@ var SUPPORTED_DOMAINS = [
8
8
  "sensforge.com",
9
9
  "fronai.cn",
10
10
  "superacmeglobal.com",
11
+ "cinvue.com",
11
12
  "0.0.0.0",
12
13
  "127.0.0.1",
13
14
  "localhost"
@@ -0,0 +1,7 @@
1
+ export declare class CinvueEnvironmentStrategy implements EnvironmentStrategy {
2
+ features: EnvironmentFeatures;
3
+ private readonly ENV_PATTERNS;
4
+ getEnvironment(host: string): string;
5
+ getRegion(): string;
6
+ isAWS(): boolean;
7
+ }
@@ -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,4 @@
1
+ export declare class CinvueURLStrategy implements URLStrategy {
2
+ features: DomainFeatures;
3
+ generateURL({ name, env, path }: URLStrategyConfig): string;
4
+ }
@@ -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
+ };
@@ -1,5 +1,6 @@
1
1
  export * from './cinmoore.cn';
2
2
  export * from './cinmoore.com';
3
+ export * from './cinvue';
3
4
  export * from './fronai.cn';
4
5
  export * from './safio365';
5
6
  export * from './sensforge';
@@ -1,6 +1,7 @@
1
1
  // src/gateway/strategies/index.ts
2
2
  export * from "./cinmoore.cn";
3
3
  export * from "./cinmoore.com";
4
+ export * from "./cinvue";
4
5
  export * from "./fronai.cn";
5
6
  export * from "./safio365";
6
7
  export * from "./sensforge";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microbt/environment",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "microbt app library for environment",
5
5
  "keywords": [],
6
6
  "license": "MIT",