@lemon-fe/mini-app 0.1.3 → 0.1.4
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/Screen/index.js +3 -2
- package/es/global.d.ts +13 -23
- package/es/global.js +34 -18
- package/package.json +1 -1
|
@@ -7,7 +7,6 @@ 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';
|
|
11
10
|
import './index.css';
|
|
12
11
|
|
|
13
12
|
function Screen(props) {
|
|
@@ -20,7 +19,9 @@ function Screen(props) {
|
|
|
20
19
|
};
|
|
21
20
|
}, [params]);
|
|
22
21
|
var statusBarHeight = useMemo(function () {
|
|
23
|
-
|
|
22
|
+
var _window$mini;
|
|
23
|
+
|
|
24
|
+
return (_window$mini = window.mini) === null || _window$mini === void 0 ? void 0 : _window$mini.getSystemInfoSync().statusBarHeight;
|
|
24
25
|
}, []);
|
|
25
26
|
var navigation = useNavigation();
|
|
26
27
|
return /*#__PURE__*/React.createElement(ScreenContext.Provider, {
|
package/es/global.d.ts
CHANGED
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
interface Window {
|
|
3
|
-
ReactNativeWebView?: {
|
|
4
|
-
postMessage(e: string): void;
|
|
5
|
-
};
|
|
6
|
-
mini?: {
|
|
7
|
-
getSystemInfoSync(): {
|
|
8
|
-
statusBarHeight: number;
|
|
9
|
-
pixelRatio: number;
|
|
10
|
-
safeArea: {
|
|
11
|
-
top: number;
|
|
12
|
-
right: number;
|
|
13
|
-
bottom: number;
|
|
14
|
-
left: number;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
addListener(cb: (e: string) => void): void;
|
|
18
|
-
getExtraPayload(): unknown;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export declare const mini: {
|
|
1
|
+
interface Mini {
|
|
23
2
|
getSystemInfoSync(): {
|
|
24
3
|
statusBarHeight: number;
|
|
25
4
|
pixelRatio: number;
|
|
@@ -32,4 +11,15 @@ export declare const mini: {
|
|
|
32
11
|
};
|
|
33
12
|
addListener(cb: (e: string) => void): void;
|
|
34
13
|
getExtraPayload(): unknown;
|
|
35
|
-
}
|
|
14
|
+
}
|
|
15
|
+
declare global {
|
|
16
|
+
interface Window {
|
|
17
|
+
ReactNativeWebView?: {
|
|
18
|
+
postMessage(e: string): void;
|
|
19
|
+
};
|
|
20
|
+
mini?: Mini;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export declare let mini: Mini;
|
|
24
|
+
export declare function createApp(render: () => void): void;
|
|
25
|
+
export {};
|
package/es/global.js
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
export var mini = {
|
|
2
|
+
getSystemInfoSync: function getSystemInfoSync() {
|
|
3
|
+
return {
|
|
4
|
+
statusBarHeight: 0,
|
|
5
|
+
pixelRatio: window.devicePixelRatio,
|
|
6
|
+
safeArea: {
|
|
7
|
+
top: 0,
|
|
8
|
+
right: 0,
|
|
9
|
+
bottom: 0,
|
|
10
|
+
left: 0
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
addListener: function addListener() {},
|
|
15
|
+
getExtraPayload: function getExtraPayload() {}
|
|
16
|
+
};
|
|
17
|
+
export function createApp(render) {
|
|
18
|
+
var count = 0;
|
|
19
|
+
|
|
20
|
+
var check = function check() {
|
|
21
|
+
if (window.mini === undefined) {
|
|
22
|
+
count++;
|
|
23
|
+
|
|
24
|
+
if (count <= 10) {
|
|
25
|
+
setTimeout(check, 100);
|
|
26
|
+
} else {
|
|
27
|
+
window.mini = mini;
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
mini = window.mini;
|
|
31
|
+
render();
|
|
32
|
+
}
|
|
17
33
|
};
|
|
18
|
-
}
|
|
19
34
|
|
|
20
|
-
|
|
35
|
+
check();
|
|
36
|
+
}
|