@lemon-fe/mini-app 0.1.103 → 0.1.122

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,29 +1,16 @@
1
1
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
-
3
2
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
3
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
-
7
4
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
8
-
9
5
  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; }
10
-
11
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
-
13
7
  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; }
14
-
15
8
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
16
-
17
9
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
18
-
19
10
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
20
-
21
11
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
22
-
23
12
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
24
-
25
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
26
-
27
14
  import React, { cloneElement, useCallback, useEffect, useMemo, useState } from 'react';
28
15
  import { TransitionGroup } from 'react-transition-group';
29
16
  import { parsePath } from '../../utils/path';
@@ -33,37 +20,31 @@ import { GO_BACK } from '../../constants';
33
20
  import { mini } from '../../global';
34
21
  import Capsule from '../Capsule';
35
22
  import './index.css';
36
-
37
23
  function App(props) {
38
24
  var pages = props.pages,
39
- children = props.children,
40
- headerStyle = props.headerStyle,
41
- _props$capsule = props.capsule,
42
- capsule = _props$capsule === void 0 ? true : _props$capsule;
43
-
25
+ children = props.children,
26
+ headerStyle = props.headerStyle,
27
+ _props$capsule = props.capsule,
28
+ capsule = _props$capsule === void 0 ? true : _props$capsule;
44
29
  var _useState = useState({
45
- routes: [{
46
- route: pages[0]
47
- }]
48
- }),
49
- _useState2 = _slicedToArray(_useState, 2),
50
- state = _useState2[0],
51
- setState = _useState2[1];
52
-
30
+ routes: [{
31
+ route: pages[0]
32
+ }]
33
+ }),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ state = _useState2[0],
36
+ setState = _useState2[1];
53
37
  var navigate = useCallback(function (path, otherParams) {
54
38
  setState(function (prev) {
55
39
  var routes = prev.routes;
56
-
57
40
  var _parsePath = parsePath(path),
58
- pathname = _parsePath.pathname,
59
- search = _parsePath.search;
60
-
41
+ pathname = _parsePath.pathname,
42
+ search = _parsePath.search;
61
43
  var params = search ? Object.fromEntries(Array.from(new URLSearchParams(search).entries())) : {};
62
44
  Object.assign(params, otherParams);
63
45
  var routeIndex = routes.findIndex(function (item) {
64
46
  return item.route.path === pathname;
65
47
  });
66
-
67
48
  if (routeIndex >= 0) {
68
49
  var nextRoutes = routes.slice(0, routeIndex + 1);
69
50
  nextRoutes[routeIndex] = _objectSpread(_objectSpread({}, routes[routeIndex]), {}, {
@@ -73,41 +54,33 @@ function App(props) {
73
54
  routes: nextRoutes
74
55
  };
75
56
  }
76
-
77
57
  var page = pages.find(function (item) {
78
58
  return item.path === pathname;
79
59
  });
80
-
81
60
  if (page !== undefined) {
82
61
  var _nextRoutes = _toConsumableArray(routes);
83
-
84
62
  _nextRoutes.push({
85
63
  route: page,
86
64
  params: params
87
65
  });
88
-
89
66
  return {
90
67
  routes: _nextRoutes
91
68
  };
92
69
  }
93
-
94
70
  return prev;
95
71
  });
96
72
  }, []);
97
73
  var replace = useCallback(function (path, otherParams) {
98
74
  setState(function (prev) {
99
75
  var routes = prev.routes;
100
-
101
76
  var _parsePath2 = parsePath(path),
102
- pathname = _parsePath2.pathname,
103
- search = _parsePath2.search;
104
-
77
+ pathname = _parsePath2.pathname,
78
+ search = _parsePath2.search;
105
79
  var params = search ? Object.fromEntries(Array.from(new URLSearchParams(search).entries())) : {};
106
80
  Object.assign(params, otherParams);
107
81
  var routeIndex = routes.findIndex(function (item) {
108
82
  return item.route.path === pathname;
109
83
  });
110
-
111
84
  if (routeIndex >= 0) {
112
85
  var nextRoutes = routes.slice(0, routeIndex + 1);
113
86
  nextRoutes[routeIndex] = _objectSpread(_objectSpread({}, routes[routeIndex]), {}, {
@@ -117,43 +90,36 @@ function App(props) {
117
90
  routes: nextRoutes
118
91
  };
119
92
  }
120
-
121
93
  var page = pages.find(function (item) {
122
94
  return item.path === pathname;
123
95
  });
124
-
125
96
  if (page !== undefined) {
126
97
  var newRoute = {
127
98
  route: page,
128
99
  params: params
129
100
  };
130
-
131
101
  if (routes.length <= 0) {
132
102
  return {
133
103
  routes: [newRoute]
134
104
  };
135
105
  }
136
-
137
106
  console.log(routes.slice(0, -1).concat(newRoute));
138
107
  return {
139
108
  routes: routes.slice(0, -1).concat(newRoute)
140
109
  };
141
110
  }
142
-
143
111
  return prev;
144
112
  });
145
113
  }, []);
146
114
  var goBack = useCallback(function () {
147
115
  setState(function (prev) {
148
116
  var nextRoutes = _toConsumableArray(prev.routes);
149
-
150
117
  if (nextRoutes.length > 1) {
151
118
  nextRoutes.pop();
152
119
  return _objectSpread(_objectSpread({}, prev), {}, {
153
120
  routes: nextRoutes
154
121
  });
155
122
  }
156
-
157
123
  mini.exit();
158
124
  return prev;
159
125
  });
@@ -194,5 +160,4 @@ function App(props) {
194
160
  value: ctx
195
161
  }, children ? /*#__PURE__*/cloneElement(children, {}, screens) : screens, window.ReactNativeWebView === undefined && /*#__PURE__*/React.createElement(Capsule, null));
196
162
  }
197
-
198
163
  export default App;
@@ -5,7 +5,6 @@ export default function Capsule() {
5
5
  var url = "nhsoft://external-apps?url=".concat(encodeURIComponent(window.location.href));
6
6
  window.alert("".concat(url, "\uFF0C\u8BF7\u590D\u5236\u5E76\u751F\u6210\u4E8C\u7EF4\u7801\u901A\u8FC7APP\u626B\u63CF"));
7
7
  };
8
-
9
8
  return /*#__PURE__*/React.createElement("div", {
10
9
  className: "lemon-capsule",
11
10
  onClick: generateCode
@@ -1,15 +1,9 @@
1
1
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
-
3
2
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
-
5
3
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
-
7
4
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
-
9
5
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
-
11
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
-
13
7
  import React, { createContext, memo, useContext, useEffect, useMemo, useState } from 'react';
14
8
  var Slot = /*#__PURE__*/memo(function Content(props) {
15
9
  return props.children;
@@ -28,7 +22,6 @@ var Context = /*#__PURE__*/createContext({
28
22
  }
29
23
  }
30
24
  });
31
-
32
25
  function Subject(initialData) {
33
26
  var observers = [];
34
27
  var data = initialData;
@@ -49,7 +42,6 @@ function Subject(initialData) {
49
42
  var index = observers.findIndex(function (item) {
50
43
  return item === observer;
51
44
  });
52
-
53
45
  if (index >= 0) {
54
46
  observers.splice(index, 1);
55
47
  }
@@ -58,15 +50,12 @@ function Subject(initialData) {
58
50
  }
59
51
  };
60
52
  }
61
-
62
53
  function PortalHost(props) {
63
54
  var children = props.children;
64
-
65
55
  var _useState = useState(new Map()),
66
- _useState2 = _slicedToArray(_useState, 2),
67
- nodes = _useState2[0],
68
- setNodes = _useState2[1];
69
-
56
+ _useState2 = _slicedToArray(_useState, 2),
57
+ nodes = _useState2[0],
58
+ setNodes = _useState2[1];
70
59
  var observable = useMemo(function () {
71
60
  return Subject(nodes);
72
61
  }, []);
@@ -96,34 +85,28 @@ function PortalHost(props) {
96
85
  value: portal
97
86
  }, /*#__PURE__*/React.createElement(Slot, null, children));
98
87
  }
99
-
100
88
  function PortalSlot(props) {
101
89
  var slot = props.slot;
102
-
103
90
  var _useContext = useContext(Context),
104
- observable = _useContext.observable;
105
-
91
+ observable = _useContext.observable;
106
92
  var _useState3 = useState(observable.get().get(slot) || null),
107
- _useState4 = _slicedToArray(_useState3, 2),
108
- node = _useState4[0],
109
- setNode = _useState4[1];
110
-
93
+ _useState4 = _slicedToArray(_useState3, 2),
94
+ node = _useState4[0],
95
+ setNode = _useState4[1];
111
96
  useEffect(function () {
112
97
  var _observable$subscribe = observable.subscribe({
113
- next: function next(state) {
114
- setNode(state.get(slot) || null);
115
- }
116
- }),
117
- unsubscribe = _observable$subscribe.unsubscribe;
118
-
98
+ next: function next(state) {
99
+ setNode(state.get(slot) || null);
100
+ }
101
+ }),
102
+ unsubscribe = _observable$subscribe.unsubscribe;
119
103
  return unsubscribe;
120
104
  }, [slot]);
121
105
  return node;
122
106
  }
123
-
124
107
  function Portal(props) {
125
108
  var slot = props.slot,
126
- children = props.children;
109
+ children = props.children;
127
110
  var portal = useContext(Context);
128
111
  useEffect(function () {
129
112
  return function () {
@@ -135,7 +118,6 @@ function Portal(props) {
135
118
  }, [slot, children]);
136
119
  return null;
137
120
  }
138
-
139
121
  Portal.Host = PortalHost;
140
122
  Portal.Slot = PortalSlot;
141
123
  export default Portal;
@@ -1,32 +1,23 @@
1
1
  var _excluded = ["params", "route", "focused"];
2
-
3
2
  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
3
  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; }
6
-
7
4
  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; }
8
-
9
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
-
11
6
  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; }
12
-
13
7
  import React, { createElement, forwardRef, memo, useContext, useMemo, useRef } from 'react';
14
8
  import { CSSTransition } from 'react-transition-group';
15
9
  import { NavigationContext, ScreenContext } from '../../context';
16
10
  import { mini } from '../../global';
17
11
  import './index.css';
18
12
  import Portal from '../Portal';
19
-
20
13
  function Content(props, ref) {
21
14
  var route = props.route;
22
15
  var statusBarHeight = useMemo(function () {
23
16
  return mini.getSystemInfoSync().statusBarHeight;
24
17
  }, []);
25
-
26
18
  var _useContext = useContext(NavigationContext),
27
- navigation = _useContext.navigation,
28
- headerStyle = _useContext.headerStyle;
29
-
19
+ navigation = _useContext.navigation,
20
+ headerStyle = _useContext.headerStyle;
30
21
  var node = useMemo(function () {
31
22
  return /*#__PURE__*/createElement(route.screen);
32
23
  }, [route.screen]);
@@ -64,14 +55,12 @@ function Content(props, ref) {
64
55
  className: "lemon-route-body"
65
56
  }, node)));
66
57
  }
67
-
68
58
  var MemoizedContent = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(Content));
69
59
  export default function Screen(props) {
70
60
  var params = props.params,
71
- route = props.route,
72
- focused = props.focused,
73
- restProps = _objectWithoutProperties(props, _excluded);
74
-
61
+ route = props.route,
62
+ focused = props.focused,
63
+ restProps = _objectWithoutProperties(props, _excluded);
75
64
  var ref = useRef(null);
76
65
  var ctx = useMemo(function () {
77
66
  return {
@@ -2,8 +2,8 @@ export var GO_BACK = 'GO_BACK';
2
2
  export var METHOD = 'METHOD';
3
3
  export var METHOD_CALLBACK = 'METHOD_CALLBACK';
4
4
  export var INIT_IFRAME = 'INIT_IFRAME';
5
- export var LEMON_APP_EXTRA_PAYLOAD = 'LEMON_APP_EXTRA_PAYLOAD'; // methods
6
-
5
+ export var LEMON_APP_EXTRA_PAYLOAD = 'LEMON_APP_EXTRA_PAYLOAD';
6
+ // methods
7
7
  export var SCAN_CODE = 'SCAN_CODE';
8
8
  export var EXIT = 'EXIT';
9
9
  export var SET_STATUS_BAR_STYLE = 'SET_STATUS_BAR_STYLE';
@@ -1,9 +1,9 @@
1
1
  import type { CSSProperties } from 'react';
2
2
  export declare const NavigationContext: import("react").Context<{
3
3
  navigation: {
4
- navigate: (path: string, params?: Record<string, any> | undefined) => void;
4
+ navigate: (path: string, params?: Record<string, any>) => void;
5
5
  goBack: () => void;
6
- replace: (path: string, params?: Record<string, any> | undefined) => void;
6
+ replace: (path: string, params?: Record<string, any>) => void;
7
7
  };
8
8
  headerStyle?: CSSProperties | undefined;
9
9
  }>;
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, value?: string | undefined) => void): () => void;
31
- postMessage(e: string, value?: string | undefined): void;
30
+ addListener(cb: (e: string, value?: string) => void): () => void;
31
+ postMessage(e: string, value?: string): void;
32
32
  scanCode(opts: {
33
33
  success: (value: string) => void;
34
34
  }): void;
package/es/global.js CHANGED
@@ -22,7 +22,6 @@ export var mini = {
22
22
  },
23
23
  methodRegister: function methodRegister(name) {
24
24
  var _window$ReactNativeWe;
25
-
26
25
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
27
26
  methods[methodID] = {
28
27
  success: opts.success,
@@ -36,7 +35,6 @@ export var mini = {
36
35
  params: opts.params
37
36
  }
38
37
  }));
39
-
40
38
  if (methodID >= Number.MAX_SAFE_INTEGER) {
41
39
  methodID = 0;
42
40
  } else {
@@ -45,23 +43,19 @@ export var mini = {
45
43
  },
46
44
  methodSuccess: function methodSuccess(id, value) {
47
45
  var method = methods[id];
48
-
49
46
  if (method !== undefined) {
50
47
  if (method.success !== undefined) {
51
48
  method.success(value);
52
49
  }
53
-
54
50
  delete methods[id];
55
51
  }
56
52
  },
57
53
  methodFail: function methodFail(id, err) {
58
54
  var method = methods[id];
59
-
60
55
  if (method !== undefined) {
61
56
  if (method.fail !== undefined) {
62
57
  method.fail(err);
63
58
  }
64
-
65
59
  delete methods[id];
66
60
  }
67
61
  },
@@ -101,13 +95,11 @@ export var mini = {
101
95
  params: opts
102
96
  });
103
97
  },
104
-
105
98
  /**
106
99
  * 监听扫码事件,常用于effect中, 并且effec重新执行需要销毁上一次注册的监听器
107
100
  * @param opts
108
101
  * @returns 监听器销毁函数
109
- */
110
- listenScanCode: function listenScanCode(opts) {
102
+ */listenScanCode: function listenScanCode(opts) {
111
103
  return mini.addListener(function (e, value) {
112
104
  if (e === SCAN_CODE && value) {
113
105
  opts.success(value);
@@ -118,7 +110,6 @@ export var mini = {
118
110
  window.mini = mini;
119
111
  window.addEventListener('message', function (evt) {
120
112
  var result = /^(([^:\/\s]+):\/?\/?([^\/\s@]*@)?([^\/@:]*)?:?(\d+)?)?(\/[^?]*)?(\?([^#]*))?(#[\s\S]*)?$/.exec(evt.origin);
121
-
122
113
  if (result !== null && whiteList.includes(result[4])) {
123
114
  if (evt.data === INIT_IFRAME) {
124
115
  window.ReactNativeWebView = {
@@ -129,14 +120,12 @@ window.addEventListener('message', function (evt) {
129
120
  mini.loaded = true;
130
121
  var nodeList = document.getElementsByTagName('link');
131
122
  var favicon = undefined;
132
-
133
123
  for (var i = 0; i < nodeList.length; i++) {
134
124
  if (nodeList[i].getAttribute('rel') == 'icon' || nodeList[i].getAttribute('rel') == 'shortcut icon') {
135
125
  favicon = nodeList[i].getAttribute('href');
136
126
  break;
137
127
  }
138
128
  }
139
-
140
129
  window.parent.postMessage(JSON.stringify({
141
130
  type: INIT_IFRAME,
142
131
  target: {
@@ -146,21 +135,17 @@ window.addEventListener('message', function (evt) {
146
135
  }), '*');
147
136
  } else {
148
137
  var action = evt.data;
149
-
150
138
  switch (action.type) {
151
139
  case SET_EXTRA_PAYLOAD:
152
140
  window.localStorage.setItem(LEMON_APP_EXTRA_PAYLOAD, JSON.stringify(action.payload));
153
141
  break;
154
-
155
142
  case METHOD_CALLBACK:
156
143
  var msg = action.payload;
157
-
158
144
  if (msg.type === 'success') {
159
145
  mini.methodSuccess(msg.id, msg.data);
160
146
  } else {
161
147
  mini.methodFail(msg.id, new Error(msg.data));
162
148
  }
163
-
164
149
  default:
165
150
  }
166
151
  }
@@ -168,7 +153,6 @@ window.addEventListener('message', function (evt) {
168
153
  }, false);
169
154
  export function createApp(render) {
170
155
  var count = 0;
171
-
172
156
  var check = function check() {
173
157
  if (mini.loaded || count >= 10) {
174
158
  render();
@@ -177,6 +161,5 @@ export function createApp(render) {
177
161
  setTimeout(check, 100);
178
162
  }
179
163
  };
180
-
181
164
  check();
182
165
  }
package/es/utils/path.js CHANGED
@@ -1,36 +1,30 @@
1
1
  export function createPath(_ref) {
2
2
  var _ref$pathname = _ref.pathname,
3
- pathname = _ref$pathname === void 0 ? '/' : _ref$pathname,
4
- _ref$search = _ref.search,
5
- search = _ref$search === void 0 ? '' : _ref$search,
6
- _ref$hash = _ref.hash,
7
- hash = _ref$hash === void 0 ? '' : _ref$hash;
3
+ pathname = _ref$pathname === void 0 ? '/' : _ref$pathname,
4
+ _ref$search = _ref.search,
5
+ search = _ref$search === void 0 ? '' : _ref$search,
6
+ _ref$hash = _ref.hash,
7
+ hash = _ref$hash === void 0 ? '' : _ref$hash;
8
8
  if (search && search !== '?') pathname += search.charAt(0) === '?' ? search : '?' + search;
9
9
  if (hash && hash !== '#') pathname += hash.charAt(0) === '#' ? hash : '#' + hash;
10
10
  return pathname;
11
11
  }
12
12
  export function parsePath(path) {
13
13
  var parsedPath = {};
14
-
15
14
  if (path) {
16
15
  var hashIndex = path.indexOf('#');
17
-
18
16
  if (hashIndex >= 0) {
19
17
  parsedPath.hash = path.substr(hashIndex);
20
18
  path = path.substr(0, hashIndex);
21
19
  }
22
-
23
20
  var searchIndex = path.indexOf('?');
24
-
25
21
  if (searchIndex >= 0) {
26
22
  parsedPath.search = path.substr(searchIndex);
27
23
  path = path.substr(0, searchIndex);
28
24
  }
29
-
30
25
  if (path) {
31
26
  parsedPath.pathname = path;
32
27
  }
33
28
  }
34
-
35
29
  return parsedPath;
36
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/mini-app",
3
- "version": "0.1.103",
3
+ "version": "0.1.122",
4
4
  "description": "> TODO: description",
5
5
  "author": "鲁盛杰 <lusj@cnlemon.net>",
6
6
  "homepage": "",
@@ -35,5 +35,5 @@
35
35
  "react": "^17.0.2",
36
36
  "react-dom": "17.0.2"
37
37
  },
38
- "gitHead": "b9730ec895f4fc20b1ff2ed94a4b974f2b62a49b"
38
+ "gitHead": "c06d24110423eabd6a1c08e69b5bebcb339e709c"
39
39
  }