@hylid/env 4.0.28 → 4.0.30

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.
@@ -1,9 +1,5 @@
1
1
  import { mpChecker } from "../checker";
2
- import { CLIENT } from "../constants";
3
2
  import { getMatchName } from "../utils";
4
3
  export function getName4MP() {
5
- // 微信小程序
6
- // @ts-ignore
7
- if (typeof wx !== 'undefined') return CLIENT.WECHAT;
8
4
  return getMatchName(mpChecker, my.getSystemInfoSync().app);
9
5
  }
package/lib/utils.js CHANGED
@@ -9,8 +9,6 @@ var __assign = this && this.__assign || function () {
9
9
  return __assign.apply(this, arguments);
10
10
  };
11
11
  export function isMP() {
12
- // @ts-ignore
13
- if (typeof wx !== 'undefined') return true;
14
12
  // 小程序一定有 my
15
13
  if (typeof my === 'undefined') return false;
16
14
  // SDKVersion 只在小程序有
@@ -44,23 +42,26 @@ export function notice(text) {
44
42
  }
45
43
  export function getSettingName() {
46
44
  var _a;
45
+ var ENV_KEY = '__hy_env__';
47
46
  var clientMatch = ((_a = window.location.search) === null || _a === void 0 ? void 0 : _a.match(/__app__=([^&]*)/)) || [];
48
47
  var client = clientMatch[1];
49
48
  var platformMatch = window.location.search.match(/__platform__=([^&]*)/) || [];
50
49
  var platform = platformMatch[1];
51
- if (client || platform) {
52
- localStorage.setItem('__hy_env__', JSON.stringify({
53
- client: client,
54
- platform: platform
55
- }));
50
+ var env = JSON.parse(localStorage.getItem(ENV_KEY) || '{}') || {};
51
+ if (client) {
52
+ env.client = client;
56
53
  }
54
+ if (platform) {
55
+ env.platform = platform;
56
+ }
57
+ localStorage.setItem(ENV_KEY, JSON.stringify(env));
57
58
  if (clientMatch[1]) {
58
59
  var search = window.location.search.replace(new RegExp("".concat(clientMatch[0], "(&)*")), '');
59
60
  var hash = window.location.hash || '';
60
61
  var newUrl = "".concat(window.location.pathname).concat(search).concat(hash);
61
62
  history.replaceState(null, '', newUrl);
62
63
  }
63
- var cached = JSON.parse(localStorage.getItem('__hy_env__') || '{}');
64
+ var cached = JSON.parse(localStorage.getItem(ENV_KEY) || '{}');
64
65
  var crossBridgeStorage = localStorage.getItem('_CB__app__');
65
66
  return crossBridgeStorage ? __assign(__assign({}, cached), {
66
67
  client: crossBridgeStorage
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export default '4.0.28-alpha.2';
1
+ export default '4.0.30';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hylid/env",
3
- "version": "4.0.28",
3
+ "version": "4.0.30",
4
4
  "main": "lib/index.js",
5
5
  "files": [
6
6
  "lib"
@@ -10,5 +10,6 @@
10
10
  },
11
11
  "license": "MIT",
12
12
  "sideEffects": false,
13
- "registry": "https://registry.npmjs.org/"
13
+ "registry": "https://registry.npmjs.org/",
14
+ "repository": "git@code.alipay.com:ant-ife/hylid-bridge.git"
14
15
  }