@microbt/environment 1.2.5 → 1.2.7
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 +31 -0
- package/dist/esm/gateway/factory.js +8 -0
- package/dist/esm/gateway/strategies/cinmoore.cn.d.ts +4 -0
- package/dist/esm/gateway/strategies/cinmoore.cn.js +19 -0
- package/dist/esm/gateway/strategies/cinmoore.com.d.ts +4 -0
- package/dist/esm/gateway/strategies/cinmoore.com.js +19 -0
- package/dist/esm/gateway/strategies/fronai.cn.d.ts +4 -0
- package/dist/esm/gateway/strategies/fronai.cn.js +19 -0
- package/dist/esm/gateway/strategies/index.d.ts +4 -0
- package/dist/esm/gateway/strategies/index.js +4 -0
- package/dist/esm/gateway/strategies/superacmeglobal.d.ts +4 -0
- package/dist/esm/gateway/strategies/superacmeglobal.js +19 -0
- package/dist/esm/hybrid.d.ts +4 -0
- package/dist/esm/hybrid.js +19 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,6 +160,37 @@ console.log(versionInfo);
|
|
|
160
160
|
// 在非 SuperAcme 应用中输出:{ version: "unknown" }
|
|
161
161
|
```
|
|
162
162
|
|
|
163
|
+
### `getStatusBarHeight()`
|
|
164
|
+
|
|
165
|
+
获取 SuperAcme 应用的状态栏高度信息。
|
|
166
|
+
|
|
167
|
+
**返回值**: 返回一个包含状态栏高度信息的对象:
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
top: number; // 顶部状态栏高度,单位为像素
|
|
172
|
+
bottom: number; // 底部状态栏高度,单位为像素
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
如果不在 SuperAcme 应用中或无法解析高度信息,将返回默认值:
|
|
177
|
+
|
|
178
|
+
```json
|
|
179
|
+
{
|
|
180
|
+
"top": 0,
|
|
181
|
+
"bottom": 0
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**示例** :
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
const statusBarHeight = getStatusBarHeight();
|
|
189
|
+
console.log(statusBarHeight);
|
|
190
|
+
// 可能输出:{ top: 20, bottom: 0 }
|
|
191
|
+
// 在非 SuperAcme 应用中输出:{ top: 0, bottom: 0 }
|
|
192
|
+
```
|
|
193
|
+
|
|
163
194
|
## 平台相关函数
|
|
164
195
|
|
|
165
196
|
### `iOSWebview`
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
// src/gateway/factory.ts
|
|
2
2
|
import {
|
|
3
|
+
CinmooreCnURLStrategy,
|
|
4
|
+
CinmooreComURLStrategy,
|
|
5
|
+
FronAiURLStrategy,
|
|
3
6
|
Safio365URLStrategy,
|
|
4
7
|
SensforgeURLStrategy,
|
|
8
|
+
SuperAcmeGlobalURLStrategy,
|
|
5
9
|
SuperAcmeURLStrategy
|
|
6
10
|
} from "./strategies/index";
|
|
7
11
|
var _URLStrategyFactory = class {
|
|
@@ -19,6 +23,10 @@ URLStrategyFactory.strategies = /* @__PURE__ */ new Map();
|
|
|
19
23
|
_URLStrategyFactory.strategies.set("superacme.com", new SuperAcmeURLStrategy());
|
|
20
24
|
_URLStrategyFactory.strategies.set("sensforge.com", new SensforgeURLStrategy());
|
|
21
25
|
_URLStrategyFactory.strategies.set("safio365.com", new Safio365URLStrategy());
|
|
26
|
+
_URLStrategyFactory.strategies.set("cinmoore.cn", new CinmooreCnURLStrategy());
|
|
27
|
+
_URLStrategyFactory.strategies.set("cinmoore.com", new CinmooreComURLStrategy());
|
|
28
|
+
_URLStrategyFactory.strategies.set("fronai.cn", new FronAiURLStrategy());
|
|
29
|
+
_URLStrategyFactory.strategies.set("superacmeglobal.com", new SuperAcmeGlobalURLStrategy());
|
|
22
30
|
})();
|
|
23
31
|
export {
|
|
24
32
|
URLStrategyFactory
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/gateway/strategies/cinmoore.cn.ts
|
|
2
|
+
var CinmooreCnURLStrategy = 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}.cinmoore.cn${path}`;
|
|
13
|
+
}
|
|
14
|
+
return `//${name}-${env}.cinmoore.cn${path}`;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
CinmooreCnURLStrategy
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/gateway/strategies/cinmoore.com.ts
|
|
2
|
+
var CinmooreComURLStrategy = 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}.cinmoore.com${path}`;
|
|
13
|
+
}
|
|
14
|
+
return `//${name}-${env}.cinmoore.com${path}`;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
CinmooreComURLStrategy
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/gateway/strategies/fronai.cn.ts
|
|
2
|
+
var FronAiURLStrategy = 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}.fronai.cn${path}`;
|
|
13
|
+
}
|
|
14
|
+
return `//${name}-${env}.fronai.cn${path}`;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
FronAiURLStrategy
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// src/gateway/strategies/superacmeglobal.ts
|
|
2
|
+
var SuperAcmeGlobalURLStrategy = 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}.superacmeglobal.com${path}`;
|
|
13
|
+
}
|
|
14
|
+
return `//${name}-${env}.superacmeglobal.com${path}`;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
SuperAcmeGlobalURLStrategy
|
|
19
|
+
};
|
package/dist/esm/hybrid.d.ts
CHANGED
package/dist/esm/hybrid.js
CHANGED
|
@@ -75,6 +75,8 @@ function inSuperAcme() {
|
|
|
75
75
|
return navigator.userAgent.toLowerCase().includes("superacme");
|
|
76
76
|
}
|
|
77
77
|
var VERSION_REGEX = /AppVersion\s([\d.]+)/;
|
|
78
|
+
var STATUSBAR_TOP_REGEX = /statusBarTop:([\d.]+)/;
|
|
79
|
+
var STATUSBAR_BOTTOM_REGEX = /statusBarBottom:([\d.]+)/;
|
|
78
80
|
function superAcmeVersion() {
|
|
79
81
|
const ua = navigator.userAgent;
|
|
80
82
|
const UNKNOWN = {
|
|
@@ -96,9 +98,26 @@ function superAcmeVersion() {
|
|
|
96
98
|
}
|
|
97
99
|
return UNKNOWN;
|
|
98
100
|
}
|
|
101
|
+
function getStatusBarHeight() {
|
|
102
|
+
const ua = navigator.userAgent;
|
|
103
|
+
const DEFAULT_HEIGHT = {
|
|
104
|
+
top: 0,
|
|
105
|
+
bottom: 0
|
|
106
|
+
};
|
|
107
|
+
if (!inSuperAcme()) {
|
|
108
|
+
return DEFAULT_HEIGHT;
|
|
109
|
+
}
|
|
110
|
+
const topMatch = ua.match(STATUSBAR_TOP_REGEX);
|
|
111
|
+
const bottomMatch = ua.match(STATUSBAR_BOTTOM_REGEX);
|
|
112
|
+
return {
|
|
113
|
+
top: topMatch ? parseFloat(topMatch[1]) : DEFAULT_HEIGHT.top,
|
|
114
|
+
bottom: bottomMatch ? parseFloat(bottomMatch[1]) : DEFAULT_HEIGHT.bottom
|
|
115
|
+
};
|
|
116
|
+
}
|
|
99
117
|
export {
|
|
100
118
|
bridgeBootstrap,
|
|
101
119
|
bridgeCall,
|
|
120
|
+
getStatusBarHeight,
|
|
102
121
|
inSuperAcme,
|
|
103
122
|
superAcmeVersion
|
|
104
123
|
};
|