@lemon-fe/mini-app 0.1.5 → 0.1.24

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.
@@ -30,6 +30,7 @@ import { parsePath } from '../../utils/path';
30
30
  import { NavigationContext } from '../../context';
31
31
  import Screen from '../Screen';
32
32
  import { GO_BACK } from '../../constants';
33
+ import { mini } from '../../global';
33
34
  import './index.css';
34
35
 
35
36
  function App(props) {
@@ -91,8 +92,6 @@ function App(props) {
91
92
  }, []);
92
93
  var goBack = useCallback(function () {
93
94
  setState(function (prev) {
94
- var _window$ReactNativeWe;
95
-
96
95
  var nextRoutes = _toConsumableArray(prev.routes);
97
96
 
98
97
  if (nextRoutes.length > 1) {
@@ -102,14 +101,12 @@ function App(props) {
102
101
  });
103
102
  }
104
103
 
105
- (_window$ReactNativeWe = window.ReactNativeWebView) === null || _window$ReactNativeWe === void 0 ? void 0 : _window$ReactNativeWe.postMessage(GO_BACK);
104
+ mini.exit();
106
105
  return prev;
107
106
  });
108
107
  }, []);
109
108
  useEffect(function () {
110
- var _window$mini;
111
-
112
- return (_window$mini = window.mini) === null || _window$mini === void 0 ? void 0 : _window$mini.addListener(function (e) {
109
+ return mini.addListener(function (e) {
113
110
  if (e === GO_BACK) {
114
111
  goBack();
115
112
  }
@@ -7,6 +7,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
7
7
  import React, { createElement, memo, useMemo } from 'react';
8
8
  import { ScreenContext } from '../../context';
9
9
  import { useNavigation } from '../../hooks';
10
+ import { mini } from '../../global';
10
11
  import './index.css';
11
12
 
12
13
  function Screen(props) {
@@ -19,9 +20,7 @@ function Screen(props) {
19
20
  };
20
21
  }, [params]);
21
22
  var statusBarHeight = useMemo(function () {
22
- var _window$mini;
23
-
24
- return (_window$mini = window.mini) === null || _window$mini === void 0 ? void 0 : _window$mini.getSystemInfoSync().statusBarHeight;
23
+ return mini.getSystemInfoSync().statusBarHeight;
25
24
  }, []);
26
25
  var navigation = useNavigation();
27
26
  return /*#__PURE__*/React.createElement(ScreenContext.Provider, {
package/es/global.d.ts CHANGED
@@ -11,6 +11,10 @@ interface Mini {
11
11
  };
12
12
  addListener(cb: (e: string) => void): void;
13
13
  getExtraPayload(): unknown;
14
+ scanCode(opt: {
15
+ success: (value: string) => void;
16
+ }): void;
17
+ exit(): void;
14
18
  }
15
19
  declare global {
16
20
  interface Window {
package/es/global.js CHANGED
@@ -12,7 +12,9 @@ export var mini = {
12
12
  };
13
13
  },
14
14
  addListener: function addListener() {},
15
- getExtraPayload: function getExtraPayload() {}
15
+ getExtraPayload: function getExtraPayload() {},
16
+ scanCode: function scanCode() {},
17
+ exit: function exit() {}
16
18
  };
17
19
  export function createApp(render) {
18
20
  var count = 0;
@@ -24,7 +26,6 @@ export function createApp(render) {
24
26
  if (count <= 10) {
25
27
  setTimeout(check, 100);
26
28
  } else {
27
- window.mini = mini;
28
29
  render();
29
30
  }
30
31
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/mini-app",
3
- "version": "0.1.5",
3
+ "version": "0.1.24",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -31,5 +31,6 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/react-transition-group": "^4.4.4"
34
- }
34
+ },
35
+ "gitHead": "72377e94c49e83f586ec6e36371387291ff41843"
35
36
  }