@lemon-fe/mini-app 1.0.6 → 1.1.0-alpha.0
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/global.js +34 -30
- package/package.json +2 -2
package/es/global.js
CHANGED
|
@@ -148,35 +148,38 @@ export var mini = _objectSpread(_objectSpread({
|
|
|
148
148
|
*/
|
|
149
149
|
|
|
150
150
|
window.mini = mini;
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (result !== null && whiteList.includes(result[4])) {
|
|
155
|
-
if (evt.data === INIT_IFRAME) {
|
|
156
|
-
window.ReactNativeWebView = {
|
|
157
|
-
postMessage: function postMessage(e) {
|
|
158
|
-
window.parent.postMessage(e, '*');
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
mini.loaded = true;
|
|
162
|
-
var nodeList = document.getElementsByTagName('link');
|
|
163
|
-
var favicon = undefined;
|
|
164
|
-
|
|
165
|
-
for (var i = 0; i < nodeList.length; i++) {
|
|
166
|
-
if (nodeList[i].getAttribute('rel') == 'icon' || nodeList[i].getAttribute('rel') == 'shortcut icon') {
|
|
167
|
-
favicon = nodeList[i].getAttribute('href');
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
151
|
+
/**
|
|
152
|
+
* init web
|
|
153
|
+
*/
|
|
171
154
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
155
|
+
if (new URLSearchParams(window.location.search).has('__APP_DEV_TOOLS__')) {
|
|
156
|
+
window.ReactNativeWebView = {
|
|
157
|
+
postMessage: function postMessage(e) {
|
|
158
|
+
window.parent.postMessage(e, '*');
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
mini.loaded = true;
|
|
162
|
+
var nodeList = document.getElementsByTagName('link');
|
|
163
|
+
var favicon = undefined;
|
|
164
|
+
|
|
165
|
+
for (var i = 0; i < nodeList.length; i++) {
|
|
166
|
+
if (nodeList[i].getAttribute('rel') == 'icon' || nodeList[i].getAttribute('rel') == 'shortcut icon') {
|
|
167
|
+
favicon = nodeList[i].getAttribute('href');
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
window.parent.postMessage(JSON.stringify({
|
|
173
|
+
type: INIT_IFRAME,
|
|
174
|
+
target: {
|
|
175
|
+
title: document.title,
|
|
176
|
+
icon: favicon
|
|
177
|
+
}
|
|
178
|
+
}), '*');
|
|
179
|
+
window.addEventListener('message', function (evt) {
|
|
180
|
+
var result = /^(([^:\/\s]+):\/?\/?([^\/\s@]*@)?([^\/@:]*)?:?(\d+)?)?(\/[^?]*)?(\?([^#]*))?(#[\s\S]*)?$/.exec(evt.origin);
|
|
181
|
+
|
|
182
|
+
if (result !== null && whiteList.includes(result[4])) {
|
|
180
183
|
var action = evt.data;
|
|
181
184
|
|
|
182
185
|
switch (action.type) {
|
|
@@ -196,13 +199,14 @@ window.addEventListener('message', function (evt) {
|
|
|
196
199
|
default:
|
|
197
200
|
}
|
|
198
201
|
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
202
|
+
}, false);
|
|
203
|
+
}
|
|
201
204
|
/**
|
|
202
205
|
* deprecated
|
|
203
206
|
* @param render () => void
|
|
204
207
|
*/
|
|
205
208
|
|
|
209
|
+
|
|
206
210
|
export function createApp(render) {
|
|
207
211
|
var count = 0;
|
|
208
212
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/mini-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-alpha.0",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "鲁盛杰 <lusj@cnlemon.net>",
|
|
6
6
|
"homepage": "",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"react": "^17.0.2",
|
|
32
32
|
"react-dom": "17.0.2"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "40dcb85d39541e46f72ceaa8efe5035428c265d2"
|
|
35
35
|
}
|