@lemon-fe/mini-app 0.1.57 → 0.1.70
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/es/components/AppContainer/index.js +4 -6
- package/es/components/Screen/index.d.ts +4 -6
- package/es/components/Screen/index.js +35 -27
- package/es/context/index.d.ts +1 -0
- package/es/context/index.js +3 -1
- package/es/global.d.ts +10 -2
- package/es/global.js +17 -5
- package/es/hooks/index.d.ts +1 -0
- package/es/hooks/index.js +4 -0
- package/es/typings.d.ts +4 -0
- package/package.json +2 -2
|
@@ -117,11 +117,9 @@ function App(props) {
|
|
|
117
117
|
});
|
|
118
118
|
}, [goBack]);
|
|
119
119
|
useEffect(function () {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
});
|
|
124
|
-
}
|
|
120
|
+
mini.setCapsule({
|
|
121
|
+
visible: capsule
|
|
122
|
+
});
|
|
125
123
|
}, []);
|
|
126
124
|
var ctx = useMemo(function () {
|
|
127
125
|
return {
|
|
@@ -139,7 +137,7 @@ function App(props) {
|
|
|
139
137
|
key: item.route.path,
|
|
140
138
|
route: item.route,
|
|
141
139
|
params: item.params,
|
|
142
|
-
|
|
140
|
+
focused: index === state.routes.length - 1
|
|
143
141
|
});
|
|
144
142
|
}));
|
|
145
143
|
return /*#__PURE__*/React.createElement(NavigationContext.Provider, {
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { NavigationStackScreen } from '../../typings';
|
|
3
2
|
import './index.css';
|
|
4
3
|
interface Props {
|
|
5
|
-
route: NavigationStackScreen;
|
|
6
4
|
params?: Record<string, any>;
|
|
7
|
-
|
|
5
|
+
focused: boolean;
|
|
6
|
+
route: NavigationStackScreen;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export default _default;
|
|
8
|
+
export default function Screen(props: Props): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
var _excluded = ["
|
|
1
|
+
var _excluded = ["params", "route", "focused"];
|
|
2
|
+
|
|
3
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
+
|
|
5
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
2
6
|
|
|
3
7
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
8
|
|
|
@@ -6,28 +10,15 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
6
10
|
|
|
7
11
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
|
-
|
|
13
|
-
import React, { createElement, memo, useContext, useMemo, useRef } from 'react';
|
|
13
|
+
import React, { createElement, forwardRef, memo, useContext, useMemo, useRef } from 'react';
|
|
14
14
|
import { CSSTransition } from 'react-transition-group';
|
|
15
15
|
import { NavigationContext, ScreenContext } from '../../context';
|
|
16
16
|
import { mini } from '../../global';
|
|
17
17
|
import './index.css';
|
|
18
18
|
import Portal from '../Portal';
|
|
19
19
|
|
|
20
|
-
function
|
|
21
|
-
var route = props.route
|
|
22
|
-
params = props.params,
|
|
23
|
-
index = props.index,
|
|
24
|
-
restProps = _objectWithoutProperties(props, _excluded);
|
|
25
|
-
|
|
26
|
-
var ctx = useMemo(function () {
|
|
27
|
-
return {
|
|
28
|
-
params: params
|
|
29
|
-
};
|
|
30
|
-
}, [params]);
|
|
20
|
+
function Content(props, ref) {
|
|
21
|
+
var route = props.route;
|
|
31
22
|
var statusBarHeight = useMemo(function () {
|
|
32
23
|
return mini.getSystemInfoSync().statusBarHeight;
|
|
33
24
|
}, []);
|
|
@@ -36,17 +27,10 @@ function Screen(props) {
|
|
|
36
27
|
navigation = _useContext.navigation,
|
|
37
28
|
headerStyle = _useContext.headerStyle;
|
|
38
29
|
|
|
39
|
-
var ref = useRef(null);
|
|
40
30
|
var node = useMemo(function () {
|
|
41
31
|
return /*#__PURE__*/createElement(route.screen);
|
|
42
32
|
}, [route.screen]);
|
|
43
|
-
return /*#__PURE__*/React.createElement(
|
|
44
|
-
timeout: 300,
|
|
45
|
-
classNames: "lemon-transition",
|
|
46
|
-
nodeRef: ref
|
|
47
|
-
}, restProps), /*#__PURE__*/React.createElement(ScreenContext.Provider, {
|
|
48
|
-
value: ctx
|
|
49
|
-
}, /*#__PURE__*/React.createElement(Portal.Host, null, /*#__PURE__*/React.createElement("div", {
|
|
33
|
+
return /*#__PURE__*/React.createElement(Portal.Host, null, /*#__PURE__*/React.createElement("div", {
|
|
50
34
|
className: "lemon-route",
|
|
51
35
|
ref: ref
|
|
52
36
|
}, /*#__PURE__*/React.createElement("div", {
|
|
@@ -78,7 +62,31 @@ function Screen(props) {
|
|
|
78
62
|
slot: "header-right"
|
|
79
63
|
})))), /*#__PURE__*/React.createElement("div", {
|
|
80
64
|
className: "lemon-route-body"
|
|
81
|
-
}, node)))
|
|
65
|
+
}, node)));
|
|
82
66
|
}
|
|
83
67
|
|
|
84
|
-
|
|
68
|
+
var MemoizedContent = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(Content));
|
|
69
|
+
export default function Screen(props) {
|
|
70
|
+
var params = props.params,
|
|
71
|
+
route = props.route,
|
|
72
|
+
focused = props.focused,
|
|
73
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
74
|
+
|
|
75
|
+
var ref = useRef(null);
|
|
76
|
+
var ctx = useMemo(function () {
|
|
77
|
+
return {
|
|
78
|
+
params: params,
|
|
79
|
+
focused: focused
|
|
80
|
+
};
|
|
81
|
+
}, [params, focused]);
|
|
82
|
+
return /*#__PURE__*/React.createElement(CSSTransition, _objectSpread({
|
|
83
|
+
timeout: 300,
|
|
84
|
+
classNames: "lemon-transition",
|
|
85
|
+
nodeRef: ref
|
|
86
|
+
}, restProps), /*#__PURE__*/React.createElement(ScreenContext.Provider, {
|
|
87
|
+
value: ctx
|
|
88
|
+
}, /*#__PURE__*/React.createElement(MemoizedContent, {
|
|
89
|
+
route: route,
|
|
90
|
+
ref: ref
|
|
91
|
+
})));
|
|
92
|
+
}
|
package/es/context/index.d.ts
CHANGED
package/es/context/index.js
CHANGED
package/es/global.d.ts
CHANGED
|
@@ -27,8 +27,8 @@ export declare const mini: {
|
|
|
27
27
|
}): void;
|
|
28
28
|
methodSuccess(id: number, value: unknown): void;
|
|
29
29
|
methodFail(id: number, err: Error): void;
|
|
30
|
-
addListener(cb: (e: string) => void): () => void;
|
|
31
|
-
postMessage(e: string): void;
|
|
30
|
+
addListener(cb: (e: string, value?: string | undefined) => void): () => void;
|
|
31
|
+
postMessage(e: string, value?: string | undefined): void;
|
|
32
32
|
scanCode(opts: {
|
|
33
33
|
success: (value: string) => void;
|
|
34
34
|
}): void;
|
|
@@ -46,5 +46,13 @@ export declare const mini: {
|
|
|
46
46
|
setCapsule(opts: {
|
|
47
47
|
visible: boolean;
|
|
48
48
|
}): void;
|
|
49
|
+
/**
|
|
50
|
+
* 监听扫码事件,常用于effect中, 并且effec重新执行需要销毁上一次注册的监听器
|
|
51
|
+
* @param opts
|
|
52
|
+
* @returns 监听器销毁函数
|
|
53
|
+
*/
|
|
54
|
+
listenScanCode(opts: {
|
|
55
|
+
success: (value: string) => void;
|
|
56
|
+
}): () => void;
|
|
49
57
|
};
|
|
50
58
|
export declare function createApp(render: () => void): void;
|
package/es/global.js
CHANGED
|
@@ -67,15 +67,14 @@ export var mini = {
|
|
|
67
67
|
addListener: function addListener(cb) {
|
|
68
68
|
listeners.push(cb);
|
|
69
69
|
return function () {
|
|
70
|
-
|
|
70
|
+
listeners.splice(listeners.findIndex(function (item) {
|
|
71
71
|
return item === cb;
|
|
72
|
-
});
|
|
73
|
-
listeners.splice(index, 1);
|
|
72
|
+
}), 1);
|
|
74
73
|
};
|
|
75
74
|
},
|
|
76
|
-
postMessage: function postMessage(e) {
|
|
75
|
+
postMessage: function postMessage(e, value) {
|
|
77
76
|
listeners.forEach(function (item) {
|
|
78
|
-
item(e);
|
|
77
|
+
item(e, value);
|
|
79
78
|
});
|
|
80
79
|
},
|
|
81
80
|
scanCode: function scanCode(opts) {
|
|
@@ -97,6 +96,19 @@ export var mini = {
|
|
|
97
96
|
mini.methodRegister('SET_CAPSULE', {
|
|
98
97
|
params: opts
|
|
99
98
|
});
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 监听扫码事件,常用于effect中, 并且effec重新执行需要销毁上一次注册的监听器
|
|
103
|
+
* @param opts
|
|
104
|
+
* @returns 监听器销毁函数
|
|
105
|
+
*/
|
|
106
|
+
listenScanCode: function listenScanCode(opts) {
|
|
107
|
+
return mini.addListener(function (e, value) {
|
|
108
|
+
if (e === 'SCAN_CODE' && value) {
|
|
109
|
+
opts.success(value);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
100
112
|
}
|
|
101
113
|
};
|
|
102
114
|
window.mini = mini;
|
package/es/hooks/index.d.ts
CHANGED
package/es/hooks/index.js
CHANGED
package/es/typings.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/mini-app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.70",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "鲁盛杰 <lusj@cnlemon.net>",
|
|
6
6
|
"homepage": "",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"react": "^17.0.2",
|
|
37
37
|
"react-dom": "17.0.2"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "46b0cf9ea5f30f15b92816311117cfb815a47330"
|
|
40
40
|
}
|