@hylid/env 4.0.3 → 4.0.5

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/lib/checker/mp.js CHANGED
@@ -2,12 +2,9 @@ import { CLIENT } from "../constants";
2
2
  export var mpChecker = [{
3
3
  name: CLIENT.DEMO,
4
4
  match: [/demo/]
5
- }, {
6
- name: CLIENT.ALIPAY,
7
- match: [/alipay/]
8
5
  }, {
9
6
  name: CLIENT.ALIPAYHK,
10
- match: [/hk/]
7
+ match: [/alipayHK/]
11
8
  }, {
12
9
  name: CLIENT.TNGD,
13
10
  match: [/tngd/]
@@ -23,4 +20,8 @@ export var mpChecker = [{
23
20
  }, {
24
21
  name: CLIENT.TOSSPAY,
25
22
  match: [/toss/]
23
+ }, {
24
+ // 为了避免 alipayHK 被识别成 alipay, 需要把以下条件放到末尾
25
+ name: CLIENT.ALIPAY,
26
+ match: [/alipay/]
26
27
  }];
@@ -35,4 +35,7 @@ export var webChecker = [{
35
35
  }, {
36
36
  name: CLIENT.DEMO,
37
37
  match: [NO_MINIPROGRAM, HAVE_GRIVER, /GriverDemo/]
38
+ }, {
39
+ name: CLIENT.WORLDFIRST,
40
+ match: [NO_MINIPROGRAM, NO_GRIVER, /worldFirst/]
38
41
  }];
@@ -28,6 +28,7 @@ export declare const CLIENT: {
28
28
  H5: string;
29
29
  WECHAT: string;
30
30
  TNGD_H5NG: string;
31
+ WORLDFIRST: string;
31
32
  };
32
33
  export declare const HAVE_MINIPROGRAM: RegExp;
33
34
  export declare const NO_MINIPROGRAM: RegExp;
package/lib/constants.js CHANGED
@@ -28,7 +28,8 @@ export var CLIENT = {
28
28
  KASPI: 'kaspi',
29
29
  H5: 'h5',
30
30
  WECHAT: 'wechat',
31
- TNGD_H5NG: 'tngdh5ng'
31
+ TNGD_H5NG: 'tngdh5ng',
32
+ WORLDFIRST: 'worldfirst'
32
33
  };
33
34
  export var HAVE_MINIPROGRAM = /miniprogram/i;
34
35
  export var NO_MINIPROGRAM = /^((?!miniprogram).)*$/i;
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ClientEnv, PlatformEnv } from './types';
2
+ import version from './version';
2
3
  export declare function getDefaultDiscernEnv(): {
3
4
  client: string | undefined;
4
5
  platform: string | undefined;
@@ -12,5 +13,5 @@ export declare function customEnv(config: CustomEnv | ((env: CustomEnv) => Custo
12
13
  declare const clientEnv: ClientEnv;
13
14
  declare const platformEnv: PlatformEnv;
14
15
  export { CLIENT, PLATFORM } from './constants';
15
- export { client, platform, clientEnv, platformEnv };
16
+ export { client, platform, clientEnv, platformEnv, version };
16
17
  export type { ClientEnv, PlatformEnv, CustomEnv };
package/lib/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { createCommonEnv, getSettingName, isMP, notice } from "./utils";
2
2
  import { getName4MP, getName4MpWeb, getName4Web } from "./getClientName";
3
3
  import { CLIENT, PLATFORM } from "./constants";
4
+ import version from "./version";
4
5
  export function getDefaultDiscernEnv() {
5
6
  var client;
6
7
  var platform;
@@ -15,6 +16,7 @@ export function getDefaultDiscernEnv() {
15
16
  } else {
16
17
  // 如果只设置了 client,默认是套壳场景
17
18
  client = setting.client || getName4MpWeb();
19
+ // TODO: 套壳与 H5 的区分方案有待落地, 添加异步获取 env 方法
18
20
  if (client) {
19
21
  platform = PLATFORM.MPWEB;
20
22
  } else {
@@ -53,4 +55,4 @@ export function customEnv(config) {
53
55
  var clientEnv = createCommonEnv(CLIENT, client);
54
56
  var platformEnv = createCommonEnv(PLATFORM, platform);
55
57
  export { CLIENT, PLATFORM } from "./constants";
56
- export { client, platform, clientEnv, platformEnv };
58
+ export { client, platform, clientEnv, platformEnv, version };
@@ -0,0 +1,2 @@
1
+ declare const _default: "$version$";
2
+ export default _default;
package/lib/version.js ADDED
@@ -0,0 +1 @@
1
+ export default '4.0.5';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hylid/env",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
4
4
  "main": "lib/index.js",
5
5
  "files": [
6
6
  "lib"