@tarojs/plugin-framework-react 3.5.0-beta.2 → 3.5.0-beta.5

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/dist/runtime.js CHANGED
@@ -1,639 +1,674 @@
1
1
  import { EMPTY_OBJ, isFunction, isArray, hooks, ensure } from '@tarojs/shared';
2
2
  import { Current, getPageInstance, injectPageInstance, incrementId, document, safeExecute, eventHandler, addLeadingSlash } from '@tarojs/runtime';
3
3
 
4
- const reactMeta = {
5
- PageContext: EMPTY_OBJ,
6
- R: EMPTY_OBJ
4
+ const reactMeta = {
5
+ PageContext: EMPTY_OBJ,
6
+ R: EMPTY_OBJ
7
7
  };
8
8
 
9
- const HOOKS_APP_ID = 'taro-app';
10
- function isClassComponent(R, component) {
11
- var _a;
12
- const prototype = component.prototype;
13
- // For React Redux
14
- if ((_a = component.displayName) === null || _a === void 0 ? void 0 : _a.includes('Connect'))
15
- return false;
16
- return (isFunction(component.render) ||
17
- !!(prototype === null || prototype === void 0 ? void 0 : prototype.isReactComponent) ||
18
- prototype instanceof R.Component // compat for some others react-like library
19
- );
20
- }
21
- function ensureIsArray(item) {
22
- if (isArray(item)) {
23
- return item;
24
- }
25
- else {
26
- return item ? [item] : [];
27
- }
28
- }
29
- /**
30
- * set writable, enumerable to true
31
- */
32
- function setDefaultDescriptor(obj) {
33
- obj.writable = true;
34
- obj.enumerable = true;
35
- return obj;
36
- }
37
- /**
38
- * 设置入口的路由参数
39
- * @param options 小程序传入的参数
40
- */
41
- function setRouterParams(options) {
42
- Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
9
+ const HOOKS_APP_ID = 'taro-app';
10
+ function isClassComponent(R, component) {
11
+ var _a;
12
+ const prototype = component.prototype;
13
+ // For React Redux
14
+ if ((_a = component.displayName) === null || _a === void 0 ? void 0 : _a.includes('Connect'))
15
+ return false;
16
+ return (isFunction(component.render) ||
17
+ !!(prototype === null || prototype === void 0 ? void 0 : prototype.isReactComponent) ||
18
+ prototype instanceof R.Component // compat for some others react-like library
19
+ );
20
+ }
21
+ function ensureIsArray(item) {
22
+ if (isArray(item)) {
23
+ return item;
24
+ }
25
+ else {
26
+ return item ? [item] : [];
27
+ }
28
+ }
29
+ /**
30
+ * set writable, enumerable to true
31
+ */
32
+ function setDefaultDescriptor(obj) {
33
+ obj.writable = true;
34
+ obj.enumerable = true;
35
+ return obj;
36
+ }
37
+ /**
38
+ * 设置入口的路由参数
39
+ * @param options 小程序传入的参数
40
+ */
41
+ function setRouterParams(options) {
42
+ Current.router = Object.assign({ params: options === null || options === void 0 ? void 0 : options.query }, options);
43
43
  }
44
44
 
45
- const taroHooks = (lifecycle) => {
46
- return (fn) => {
47
- const { R: React, PageContext } = reactMeta;
48
- const id = React.useContext(PageContext) || HOOKS_APP_ID;
49
- // hold fn ref and keep up to date
50
- const fnRef = React.useRef(fn);
51
- if (fnRef.current !== fn)
52
- fnRef.current = fn;
53
- React.useLayoutEffect(() => {
54
- let inst = getPageInstance(id);
55
- let first = false;
56
- if (inst == null) {
57
- first = true;
58
- inst = Object.create(null);
59
- }
60
- inst = inst;
61
- // callback is immutable but inner function is up to date
62
- const callback = (...args) => fnRef.current(...args);
63
- if (isFunction(inst[lifecycle])) {
64
- inst[lifecycle] = [inst[lifecycle], callback];
65
- }
66
- else {
67
- inst[lifecycle] = [
68
- ...(inst[lifecycle] || []),
69
- callback
70
- ];
71
- }
72
- if (first) {
73
- injectPageInstance(inst, id);
74
- }
75
- return () => {
76
- const inst = getPageInstance(id);
77
- const list = inst[lifecycle];
78
- if (list === callback) {
79
- inst[lifecycle] = undefined;
80
- }
81
- else if (isArray(list)) {
82
- inst[lifecycle] = list.filter(item => item !== callback);
83
- }
84
- };
85
- }, []);
86
- };
87
- };
88
- const useDidShow = taroHooks('componentDidShow');
89
- const useDidHide = taroHooks('componentDidHide');
90
- const usePullDownRefresh = taroHooks('onPullDownRefresh');
91
- const useReachBottom = taroHooks('onReachBottom');
92
- const usePageScroll = taroHooks('onPageScroll');
93
- const useResize = taroHooks('onResize');
94
- const useShareAppMessage = taroHooks('onShareAppMessage');
95
- const useTabItemTap = taroHooks('onTabItemTap');
96
- const useTitleClick = taroHooks('onTitleClick');
97
- const useOptionMenuClick = taroHooks('onOptionMenuClick');
98
- const usePullIntercept = taroHooks('onPullIntercept');
99
- const useShareTimeline = taroHooks('onShareTimeline');
100
- const useAddToFavorites = taroHooks('onAddToFavorites');
101
- const useReady = taroHooks('onReady');
102
- const useLoad = taroHooks('onLoad');
103
- const useUnload = taroHooks('onUnload');
104
- const useRouter = (dynamic = false) => {
105
- const React = reactMeta.R;
106
- return dynamic ? Current.router : React.useMemo(() => Current.router, []);
107
- };
45
+ const createTaroHook = (lifecycle) => {
46
+ return (fn) => {
47
+ const { R: React, PageContext } = reactMeta;
48
+ const id = React.useContext(PageContext) || HOOKS_APP_ID;
49
+ // hold fn ref and keep up to date
50
+ const fnRef = React.useRef(fn);
51
+ if (fnRef.current !== fn)
52
+ fnRef.current = fn;
53
+ React.useLayoutEffect(() => {
54
+ let inst = getPageInstance(id);
55
+ let first = false;
56
+ if (inst == null) {
57
+ first = true;
58
+ inst = Object.create(null);
59
+ }
60
+ inst = inst;
61
+ // callback is immutable but inner function is up to date
62
+ const callback = (...args) => fnRef.current(...args);
63
+ if (isFunction(inst[lifecycle])) {
64
+ inst[lifecycle] = [inst[lifecycle], callback];
65
+ }
66
+ else {
67
+ inst[lifecycle] = [
68
+ ...(inst[lifecycle] || []),
69
+ callback
70
+ ];
71
+ }
72
+ if (first) {
73
+ injectPageInstance(inst, id);
74
+ }
75
+ return () => {
76
+ const inst = getPageInstance(id);
77
+ const list = inst[lifecycle];
78
+ if (list === callback) {
79
+ inst[lifecycle] = undefined;
80
+ }
81
+ else if (isArray(list)) {
82
+ inst[lifecycle] = list.filter(item => item !== callback);
83
+ }
84
+ };
85
+ }, []);
86
+ };
87
+ };
88
+ /** LifeCycle */
89
+ const useDidHide = createTaroHook('componentDidHide');
90
+ const useDidShow = createTaroHook('componentDidShow');
91
+ /** App */
92
+ const useError = createTaroHook('onError');
93
+ const useLaunch = createTaroHook('onLaunch');
94
+ const usePageNotFound = createTaroHook('onPageNotFound');
95
+ /** Page */
96
+ const useLoad = createTaroHook('onLoad');
97
+ const usePageScroll = createTaroHook('onPageScroll');
98
+ const usePullDownRefresh = createTaroHook('onPullDownRefresh');
99
+ const usePullIntercept = createTaroHook('onPullIntercept');
100
+ const useReachBottom = createTaroHook('onReachBottom');
101
+ const useResize = createTaroHook('onResize');
102
+ const useUnload = createTaroHook('onUnload');
103
+ /** Mini-Program */
104
+ const useAddToFavorites = createTaroHook('onAddToFavorites');
105
+ const useOptionMenuClick = createTaroHook('onOptionMenuClick');
106
+ const useSaveExitState = createTaroHook('onSaveExitState');
107
+ const useShareAppMessage = createTaroHook('onShareAppMessage');
108
+ const useShareTimeline = createTaroHook('onShareTimeline');
109
+ const useTitleClick = createTaroHook('onTitleClick');
110
+ /** Router */
111
+ const useReady = createTaroHook('onReady');
112
+ const useRouter = (dynamic = false) => {
113
+ const React = reactMeta.R;
114
+ return dynamic ? Current.router : React.useMemo(() => Current.router, []);
115
+ };
116
+ const useTabItemTap = createTaroHook('onTabItemTap');
108
117
  const useScope = () => undefined;
109
118
 
110
- var taroHooks$1 = /*#__PURE__*/Object.freeze({
119
+ var taroHooks = /*#__PURE__*/Object.freeze({
111
120
  __proto__: null,
112
- useDidShow: useDidShow,
113
121
  useDidHide: useDidHide,
122
+ useDidShow: useDidShow,
123
+ useError: useError,
124
+ useLaunch: useLaunch,
125
+ usePageNotFound: usePageNotFound,
126
+ useLoad: useLoad,
127
+ usePageScroll: usePageScroll,
114
128
  usePullDownRefresh: usePullDownRefresh,
129
+ usePullIntercept: usePullIntercept,
115
130
  useReachBottom: useReachBottom,
116
- usePageScroll: usePageScroll,
117
131
  useResize: useResize,
118
- useShareAppMessage: useShareAppMessage,
119
- useTabItemTap: useTabItemTap,
120
- useTitleClick: useTitleClick,
132
+ useUnload: useUnload,
133
+ useAddToFavorites: useAddToFavorites,
121
134
  useOptionMenuClick: useOptionMenuClick,
122
- usePullIntercept: usePullIntercept,
135
+ useSaveExitState: useSaveExitState,
136
+ useShareAppMessage: useShareAppMessage,
123
137
  useShareTimeline: useShareTimeline,
124
- useAddToFavorites: useAddToFavorites,
138
+ useTitleClick: useTitleClick,
125
139
  useReady: useReady,
126
- useLoad: useLoad,
127
- useUnload: useUnload,
128
140
  useRouter: useRouter,
141
+ useTabItemTap: useTabItemTap,
129
142
  useScope: useScope
130
143
  });
131
144
 
132
- let h$1;
133
- let ReactDOM$1;
134
- const pageKeyId = incrementId();
135
- function setReconciler(ReactDOM) {
136
- hooks.tap('getLifecycle', function (instance, lifecycle) {
137
- lifecycle = lifecycle.replace(/^on(Show|Hide)$/, 'componentDid$1');
138
- return instance[lifecycle];
139
- });
140
- hooks.tap('modifyMpEvent', function (event) {
141
- event.type = event.type.replace(/-/g, '');
142
- });
143
- hooks.tap('batchedEventUpdates', function (cb) {
144
- ReactDOM.unstable_batchedUpdates(cb);
145
- });
146
- hooks.tap('mergePageInstance', function (prev, next) {
147
- if (!prev || !next)
148
- return;
149
- // 子组件使用 lifecycle hooks 注册了生命周期后,会存在 prev,里面是注册的生命周期回调。
150
- // prev 使用 Object.create(null) 创建,H5 的 fast-refresh 可能也会导致存在 prev,要排除这些意外产生的 prev
151
- if ('constructor' in prev)
152
- return;
153
- Object.keys(prev).forEach(item => {
154
- const prevList = prev[item];
155
- const nextList = ensureIsArray(next[item]);
156
- next[item] = nextList.concat(prevList);
157
- });
158
- });
159
- if (process.env.TARO_ENV === 'h5') {
160
- hooks.tap('createPullDownComponent', (el, _, R, customWrapper) => {
161
- const isReactComponent = isClassComponent(R, el);
162
- return R.forwardRef((props, ref) => {
163
- const newProps = Object.assign({}, props);
164
- const refs = isReactComponent ? { ref: ref } : {
165
- forwardedRef: ref,
166
- // 兼容 react-redux 7.20.1+
167
- reactReduxForwardedRef: ref
168
- };
169
- return h$1(customWrapper || 'taro-pull-to-refresh', null, h$1(el, Object.assign(Object.assign({}, newProps), refs)));
170
- });
171
- });
172
- hooks.tap('getDOMNode', inst => {
173
- return ReactDOM.findDOMNode(inst);
174
- });
175
- }
176
- }
177
- function connectReactPage(R, id) {
178
- return (Page) => {
179
- // eslint-disable-next-line dot-notation
180
- const isReactComponent = isClassComponent(R, Page);
181
- const inject = (node) => node && injectPageInstance(node, id);
182
- const refs = isReactComponent ? { ref: inject } : {
183
- forwardedRef: inject,
184
- // 兼容 react-redux 7.20.1+
185
- reactReduxForwardedRef: inject
186
- };
187
- if (reactMeta.PageContext === EMPTY_OBJ) {
188
- reactMeta.PageContext = R.createContext('');
189
- }
190
- return class PageWrapper extends R.Component {
191
- constructor() {
192
- super(...arguments);
193
- this.state = {
194
- hasError: false
195
- };
196
- }
197
- static getDerivedStateFromError(error) {
198
- process.env.NODE_ENV !== 'production' && console.warn(error);
199
- return { hasError: true };
200
- }
201
- // React 16 uncaught error 会导致整个应用 crash,
202
- // 目前把错误缩小到页面
203
- componentDidCatch(error, info) {
204
- if (process.env.NODE_ENV !== 'production') {
205
- console.warn(error);
206
- console.error(info.componentStack);
207
- }
208
- }
209
- render() {
210
- const children = this.state.hasError
211
- ? []
212
- : h$1(reactMeta.PageContext.Provider, { value: id }, h$1(Page, Object.assign(Object.assign({}, this.props), refs)));
213
- if (process.env.TARO_ENV === 'h5') {
214
- return h$1('div', { id, className: 'taro_page' }, children);
215
- }
216
- else {
217
- return h$1('root', { id }, children);
218
- }
219
- }
220
- };
221
- };
222
- }
223
- /**
224
- * 桥接小程序 App 构造器和 React 渲染流程
225
- * @param App 用户编写的入口组件
226
- * @param react 框架
227
- * @param dom 框架渲染器
228
- * @param config 入口组件配置 app.config.js 的内容
229
- * @returns 传递给 App 构造器的对象 obj :App(obj)
230
- */
231
- function createReactApp(App, react, dom, config) {
232
- if (process.env.NODE_ENV !== 'production') {
233
- ensure(!!dom, '构建 React/Nerv 项目请把 process.env.FRAMEWORK 设置为 \'react\'/\'nerv\' ');
234
- }
235
- reactMeta.R = react;
236
- h$1 = react.createElement;
237
- ReactDOM$1 = dom;
238
- const appInstanceRef = react.createRef();
239
- const isReactComponent = isClassComponent(react, App);
240
- let appWrapper;
241
- setReconciler(ReactDOM$1);
242
- function getAppInstance() {
243
- return appInstanceRef.current;
244
- }
245
- function renderReactRoot() {
246
- var _a, _b;
247
- const reactMode = __TARO_FRAMEWORK_REACT_MODE__;
248
- let appId = 'app';
249
- if (process.env.TARO_ENV === 'h5') {
250
- appId = (config === null || config === void 0 ? void 0 : config.appId) || appId;
251
- }
252
- else {
253
- ReactDOM$1.version = react.version;
254
- }
255
- const container = document.getElementById(appId);
256
- const version = Number((ReactDOM$1.version || '').split('.')[0]);
257
- if (version >= 18 && reactMode === 'concurrent') {
258
- const root = ReactDOM$1.createRoot(container);
259
- (_a = root.render) === null || _a === void 0 ? void 0 : _a.call(root, h$1(AppWrapper));
260
- }
261
- else {
262
- (_b = ReactDOM$1.render) === null || _b === void 0 ? void 0 : _b.call(ReactDOM$1, h$1(AppWrapper), container);
263
- }
264
- }
265
- class AppWrapper extends react.Component {
266
- constructor(props) {
267
- super(props);
268
- // run createElement() inside the render function to make sure that owner is right
269
- this.pages = [];
270
- this.elements = [];
271
- appWrapper = this;
272
- }
273
- mount(pageComponent, id, cb) {
274
- const pageWrapper = connectReactPage(react, id)(pageComponent);
275
- const key = id + pageKeyId();
276
- const page = () => h$1(pageWrapper, { key, tid: id });
277
- this.pages.push(page);
278
- this.forceUpdate(cb);
279
- }
280
- unmount(id, cb) {
281
- const elements = this.elements;
282
- const idx = elements.findIndex(item => item.props.tid === id);
283
- elements.splice(idx, 1);
284
- this.forceUpdate(cb);
285
- }
286
- render() {
287
- const { pages, elements } = this;
288
- while (pages.length > 0) {
289
- const page = pages.pop();
290
- elements.push(page());
291
- }
292
- let props = null;
293
- if (isReactComponent) {
294
- props = { ref: appInstanceRef };
295
- }
296
- return h$1(App, props, process.env.TARO_ENV === 'h5' ? h$1('div', null, elements.slice()) : elements.slice());
297
- }
298
- }
299
- if (process.env.TARO_ENV !== 'h5') {
300
- renderReactRoot();
301
- }
302
- const [ONLAUNCH, ONSHOW, ONHIDE] = hooks.call('getMiniLifecycleImpl').app;
303
- const appObj = Object.create({
304
- render(cb) {
305
- appWrapper.forceUpdate(cb);
306
- },
307
- mount(component, id, cb) {
308
- appWrapper.mount(component, id, cb);
309
- },
310
- unmount(id, cb) {
311
- appWrapper.unmount(id, cb);
312
- }
313
- }, {
314
- config: setDefaultDescriptor({
315
- configurable: true,
316
- value: config
317
- }),
318
- [ONLAUNCH]: setDefaultDescriptor({
319
- value(options) {
320
- var _a;
321
- setRouterParams(options);
322
- if (process.env.TARO_ENV === 'h5') {
323
- // 由于 H5 路由初始化的时候会清除 app 下的 dom 元素,所以需要在路由初始化后执行 render
324
- renderReactRoot();
325
- }
326
- // 用户编写的入口组件实例
327
- const app = getAppInstance();
328
- this.$app = app;
329
- if (app) {
330
- // App Class 上挂载的额外属性同步到全局 app 对象中
331
- if (app.taroGlobalData) {
332
- const globalData = app.taroGlobalData;
333
- const keys = Object.keys(globalData);
334
- const descriptors = Object.getOwnPropertyDescriptors(globalData);
335
- keys.forEach(key => {
336
- Object.defineProperty(this, key, {
337
- configurable: true,
338
- enumerable: true,
339
- get() {
340
- return globalData[key];
341
- },
342
- set(value) {
343
- globalData[key] = value;
344
- }
345
- });
346
- });
347
- Object.defineProperties(this, descriptors);
348
- }
349
- (_a = app.onLaunch) === null || _a === void 0 ? void 0 : _a.call(app, options);
350
- }
351
- }
352
- }),
353
- [ONSHOW]: setDefaultDescriptor({
354
- value(options) {
355
- var _a;
356
- setRouterParams(options);
357
- /**
358
- * trigger lifecycle
359
- */
360
- const app = getAppInstance();
361
- // class component, componentDidShow
362
- (_a = app === null || app === void 0 ? void 0 : app.componentDidShow) === null || _a === void 0 ? void 0 : _a.call(app, options);
363
- // functional component, useDidShow
364
- triggerAppHook('onShow', options);
365
- }
366
- }),
367
- [ONHIDE]: setDefaultDescriptor({
368
- value() {
369
- var _a;
370
- /**
371
- * trigger lifecycle
372
- */
373
- const app = getAppInstance();
374
- // class component, componentDidHide
375
- (_a = app === null || app === void 0 ? void 0 : app.componentDidHide) === null || _a === void 0 ? void 0 : _a.call(app);
376
- // functional component, useDidHide
377
- triggerAppHook('onHide');
378
- }
379
- }),
380
- onPageNotFound: setDefaultDescriptor({
381
- value(res) {
382
- var _a;
383
- const app = getAppInstance();
384
- (_a = app === null || app === void 0 ? void 0 : app.onPageNotFound) === null || _a === void 0 ? void 0 : _a.call(app, res);
385
- }
386
- })
387
- });
388
- function triggerAppHook(lifecycle, ...option) {
389
- const instance = getPageInstance(HOOKS_APP_ID);
390
- if (instance) {
391
- const app = getAppInstance();
392
- const func = hooks.call('getLifecycle', instance, lifecycle);
393
- if (Array.isArray(func)) {
394
- func.forEach(cb => cb.apply(app, option));
395
- }
396
- }
397
- }
398
- Current.app = appObj;
399
- return appObj;
145
+ let h$1;
146
+ let ReactDOM$1;
147
+ let Fragment;
148
+ const pageKeyId = incrementId();
149
+ function setReconciler(ReactDOM) {
150
+ hooks.tap('getLifecycle', function (instance, lifecycle) {
151
+ lifecycle = lifecycle.replace(/^on(Show|Hide)$/, 'componentDid$1');
152
+ return instance[lifecycle];
153
+ });
154
+ hooks.tap('modifyMpEvent', function (event) {
155
+ event.type = event.type.replace(/-/g, '');
156
+ });
157
+ hooks.tap('batchedEventUpdates', function (cb) {
158
+ ReactDOM.unstable_batchedUpdates(cb);
159
+ });
160
+ hooks.tap('mergePageInstance', function (prev, next) {
161
+ if (!prev || !next)
162
+ return;
163
+ // 子组件使用 lifecycle hooks 注册了生命周期后,会存在 prev,里面是注册的生命周期回调。
164
+ // prev 使用 Object.create(null) 创建,H5 的 fast-refresh 可能也会导致存在 prev,要排除这些意外产生的 prev
165
+ if ('constructor' in prev)
166
+ return;
167
+ Object.keys(prev).forEach(item => {
168
+ const prevList = prev[item];
169
+ const nextList = ensureIsArray(next[item]);
170
+ next[item] = nextList.concat(prevList);
171
+ });
172
+ });
173
+ if (process.env.TARO_ENV === 'h5') {
174
+ hooks.tap('createPullDownComponent', (el, _, R, customWrapper) => {
175
+ const isReactComponent = isClassComponent(R, el);
176
+ return R.forwardRef((props, ref) => {
177
+ const newProps = Object.assign({}, props);
178
+ const refs = isReactComponent ? { ref: ref } : {
179
+ forwardedRef: ref,
180
+ // 兼容 react-redux 7.20.1+
181
+ reactReduxForwardedRef: ref
182
+ };
183
+ return h$1(customWrapper || 'taro-pull-to-refresh', null, h$1(el, Object.assign(Object.assign({}, newProps), refs)));
184
+ });
185
+ });
186
+ hooks.tap('getDOMNode', inst => {
187
+ return ReactDOM.findDOMNode(inst);
188
+ });
189
+ }
190
+ }
191
+ function connectReactPage(R, id) {
192
+ return (Page) => {
193
+ // eslint-disable-next-line dot-notation
194
+ const isReactComponent = isClassComponent(R, Page);
195
+ const inject = (node) => node && injectPageInstance(node, id);
196
+ const refs = isReactComponent ? { ref: inject } : {
197
+ forwardedRef: inject,
198
+ // 兼容 react-redux 7.20.1+
199
+ reactReduxForwardedRef: inject
200
+ };
201
+ if (reactMeta.PageContext === EMPTY_OBJ) {
202
+ reactMeta.PageContext = R.createContext('');
203
+ }
204
+ return class PageWrapper extends R.Component {
205
+ constructor() {
206
+ super(...arguments);
207
+ this.state = {
208
+ hasError: false
209
+ };
210
+ }
211
+ static getDerivedStateFromError(error) {
212
+ var _a, _b;
213
+ (_b = (_a = Current.app) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error.message + error.stack);
214
+ return { hasError: true };
215
+ }
216
+ // React 16 uncaught error 会导致整个应用 crash,
217
+ // 目前把错误缩小到页面
218
+ componentDidCatch(error, info) {
219
+ if (process.env.NODE_ENV !== 'production') {
220
+ console.warn(error);
221
+ console.error(info.componentStack);
222
+ }
223
+ }
224
+ render() {
225
+ const children = this.state.hasError
226
+ ? []
227
+ : h$1(reactMeta.PageContext.Provider, { value: id }, h$1(Page, Object.assign(Object.assign({}, this.props), refs)));
228
+ if (process.env.TARO_ENV === 'h5') {
229
+ return h$1('div', { id, className: 'taro_page' }, children);
230
+ }
231
+ else {
232
+ return h$1('root', { id }, children);
233
+ }
234
+ }
235
+ };
236
+ };
237
+ }
238
+ /**
239
+ * 桥接小程序 App 构造器和 React 渲染流程
240
+ * @param App 用户编写的入口组件
241
+ * @param react 框架
242
+ * @param dom 框架渲染器
243
+ * @param config 入口组件配置 app.config.js 的内容
244
+ * @returns 传递给 App 构造器的对象 obj :App(obj)
245
+ */
246
+ function createReactApp(App, react, dom, config) {
247
+ if (process.env.NODE_ENV !== 'production') {
248
+ ensure(!!dom, '构建 React/Nerv 项目请把 process.env.FRAMEWORK 设置为 \'react\'/\'nerv\' ');
249
+ }
250
+ reactMeta.R = react;
251
+ h$1 = react.createElement;
252
+ ReactDOM$1 = dom;
253
+ Fragment = react.Fragment;
254
+ const appInstanceRef = react.createRef();
255
+ const isReactComponent = isClassComponent(react, App);
256
+ let appWrapper;
257
+ setReconciler(ReactDOM$1);
258
+ function getAppInstance() {
259
+ return appInstanceRef.current;
260
+ }
261
+ function renderReactRoot() {
262
+ var _a, _b;
263
+ const reactMode = __TARO_FRAMEWORK_REACT_MODE__;
264
+ let appId = 'app';
265
+ if (process.env.TARO_ENV === 'h5') {
266
+ appId = (config === null || config === void 0 ? void 0 : config.appId) || appId;
267
+ }
268
+ else {
269
+ ReactDOM$1.version = react.version;
270
+ }
271
+ const container = document.getElementById(appId);
272
+ const version = Number((ReactDOM$1.version || '').split('.')[0]);
273
+ if (version >= 18 && reactMode === 'concurrent') {
274
+ const root = ReactDOM$1.createRoot(container);
275
+ (_a = root.render) === null || _a === void 0 ? void 0 : _a.call(root, h$1(AppWrapper));
276
+ }
277
+ else {
278
+ (_b = ReactDOM$1.render) === null || _b === void 0 ? void 0 : _b.call(ReactDOM$1, h$1(AppWrapper), container);
279
+ }
280
+ }
281
+ class AppWrapper extends react.Component {
282
+ constructor(props) {
283
+ super(props);
284
+ // run createElement() inside the render function to make sure that owner is right
285
+ this.pages = [];
286
+ this.elements = [];
287
+ appWrapper = this;
288
+ }
289
+ mount(pageComponent, id, cb) {
290
+ const pageWrapper = connectReactPage(react, id)(pageComponent);
291
+ const key = id + pageKeyId();
292
+ const page = () => h$1(pageWrapper, { key, tid: id });
293
+ this.pages.push(page);
294
+ this.forceUpdate(cb);
295
+ }
296
+ unmount(id, cb) {
297
+ const elements = this.elements;
298
+ const idx = elements.findIndex(item => item.props.tid === id);
299
+ elements.splice(idx, 1);
300
+ this.forceUpdate(cb);
301
+ }
302
+ render() {
303
+ const { pages, elements } = this;
304
+ while (pages.length > 0) {
305
+ const page = pages.pop();
306
+ elements.push(page());
307
+ }
308
+ let props = null;
309
+ if (isReactComponent) {
310
+ props = { ref: appInstanceRef };
311
+ }
312
+ return h$1(App, props, process.env.TARO_ENV === 'h5' ? h$1(Fragment !== null && Fragment !== void 0 ? Fragment : 'div', null, elements.slice()) : elements.slice());
313
+ }
314
+ }
315
+ if (process.env.TARO_ENV !== 'h5') {
316
+ renderReactRoot();
317
+ }
318
+ const [ONLAUNCH, ONSHOW, ONHIDE] = hooks.call('getMiniLifecycleImpl').app;
319
+ const appObj = Object.create({
320
+ render(cb) {
321
+ appWrapper.forceUpdate(cb);
322
+ },
323
+ mount(component, id, cb) {
324
+ appWrapper.mount(component, id, cb);
325
+ },
326
+ unmount(id, cb) {
327
+ appWrapper.unmount(id, cb);
328
+ }
329
+ }, {
330
+ config: setDefaultDescriptor({
331
+ configurable: true,
332
+ value: config
333
+ }),
334
+ [ONLAUNCH]: setDefaultDescriptor({
335
+ value(options) {
336
+ var _a;
337
+ setRouterParams(options);
338
+ if (process.env.TARO_ENV === 'h5') {
339
+ // 由于 H5 路由初始化的时候会清除 app 下的 dom 元素,所以需要在路由初始化后执行 render
340
+ renderReactRoot();
341
+ }
342
+ // 用户编写的入口组件实例
343
+ const app = getAppInstance();
344
+ this.$app = app;
345
+ if (app) {
346
+ // App Class 上挂载的额外属性同步到全局 app 对象中
347
+ if (app.taroGlobalData) {
348
+ const globalData = app.taroGlobalData;
349
+ const keys = Object.keys(globalData);
350
+ const descriptors = Object.getOwnPropertyDescriptors(globalData);
351
+ keys.forEach(key => {
352
+ Object.defineProperty(this, key, {
353
+ configurable: true,
354
+ enumerable: true,
355
+ get() {
356
+ return globalData[key];
357
+ },
358
+ set(value) {
359
+ globalData[key] = value;
360
+ }
361
+ });
362
+ });
363
+ Object.defineProperties(this, descriptors);
364
+ }
365
+ (_a = app.onLaunch) === null || _a === void 0 ? void 0 : _a.call(app, options);
366
+ }
367
+ triggerAppHook('onLaunch', options);
368
+ }
369
+ }),
370
+ [ONSHOW]: setDefaultDescriptor({
371
+ value(options) {
372
+ var _a;
373
+ setRouterParams(options);
374
+ /**
375
+ * trigger lifecycle
376
+ */
377
+ const app = getAppInstance();
378
+ // class component, componentDidShow
379
+ (_a = app === null || app === void 0 ? void 0 : app.componentDidShow) === null || _a === void 0 ? void 0 : _a.call(app, options);
380
+ // functional component, useDidShow
381
+ triggerAppHook('onShow', options);
382
+ }
383
+ }),
384
+ [ONHIDE]: setDefaultDescriptor({
385
+ value() {
386
+ var _a;
387
+ /**
388
+ * trigger lifecycle
389
+ */
390
+ const app = getAppInstance();
391
+ // class component, componentDidHide
392
+ (_a = app === null || app === void 0 ? void 0 : app.componentDidHide) === null || _a === void 0 ? void 0 : _a.call(app);
393
+ // functional component, useDidHide
394
+ triggerAppHook('onHide');
395
+ }
396
+ }),
397
+ onError: setDefaultDescriptor({
398
+ value(error) {
399
+ var _a;
400
+ const app = getAppInstance();
401
+ (_a = app === null || app === void 0 ? void 0 : app.onError) === null || _a === void 0 ? void 0 : _a.call(app, error);
402
+ triggerAppHook('onError', error);
403
+ if (process.env.NODE_ENV !== 'production' && error.includes('Minified React error')) {
404
+ console.warn('React 出现报错,请打开编译配置 mini.debugReact 查看报错详情:https://docs.taro.zone/docs/config-detail#minidebugreact');
405
+ }
406
+ }
407
+ }),
408
+ onPageNotFound: setDefaultDescriptor({
409
+ value(res) {
410
+ var _a;
411
+ const app = getAppInstance();
412
+ (_a = app === null || app === void 0 ? void 0 : app.onPageNotFound) === null || _a === void 0 ? void 0 : _a.call(app, res);
413
+ triggerAppHook('onPageNotFound', res);
414
+ }
415
+ })
416
+ });
417
+ function triggerAppHook(lifecycle, ...option) {
418
+ const instance = getPageInstance(HOOKS_APP_ID);
419
+ if (instance) {
420
+ const app = getAppInstance();
421
+ const func = hooks.call('getLifecycle', instance, lifecycle);
422
+ if (Array.isArray(func)) {
423
+ func.forEach(cb => cb.apply(app, option));
424
+ }
425
+ }
426
+ }
427
+ Current.app = appObj;
428
+ return appObj;
400
429
  }
401
430
 
402
- const getNativeCompId = incrementId();
403
- let h;
404
- let ReactDOM;
405
- function initNativeComponentEntry(R, ReactDOM) {
406
- class NativeComponentWrapper extends R.Component {
407
- constructor() {
408
- super(...arguments);
409
- this.root = R.createRef();
410
- this.ctx = this.props.getCtx();
411
- }
412
- componentDidMount() {
413
- this.ctx.component = this;
414
- const rootElement = this.root.current;
415
- rootElement.ctx = this.ctx;
416
- rootElement.performUpdate(true);
417
- }
418
- render() {
419
- return (h('root', {
420
- ref: this.root
421
- }, this.props.renderComponent(this.ctx)));
422
- }
423
- }
424
- class Entry extends R.Component {
425
- constructor() {
426
- super(...arguments);
427
- this.state = {
428
- components: []
429
- };
430
- }
431
- componentDidMount() {
432
- Current.app = this;
433
- }
434
- mount(Component, compId, getCtx) {
435
- const isReactComponent = isClassComponent(R, Component);
436
- const inject = (node) => node && injectPageInstance(node, compId);
437
- const refs = isReactComponent ? { ref: inject } : {
438
- forwardedRef: inject,
439
- reactReduxForwardedRef: inject
440
- };
441
- if (reactMeta.PageContext === EMPTY_OBJ) {
442
- reactMeta.PageContext = R.createContext('');
443
- }
444
- const item = {
445
- compId,
446
- element: h(NativeComponentWrapper, {
447
- key: compId,
448
- getCtx,
449
- renderComponent(ctx) {
450
- return h(reactMeta.PageContext.Provider, { value: compId }, h(Component, Object.assign(Object.assign(Object.assign({}, (ctx.data || (ctx.data = {})).props), refs), { $scope: ctx })));
451
- }
452
- })
453
- };
454
- this.setState({
455
- components: [...this.state.components, item]
456
- });
457
- }
458
- unmount(compId) {
459
- const components = this.state.components;
460
- const index = components.findIndex(item => item.compId === compId);
461
- const next = [...components.slice(0, index), ...components.slice(index + 1)];
462
- this.setState({
463
- components: next
464
- });
465
- }
466
- render() {
467
- const components = this.state.components;
468
- return (components.map(({ element }) => element));
469
- }
470
- }
471
- setReconciler(ReactDOM);
472
- const app = document.getElementById('app');
473
- ReactDOM.render(h(Entry, {}), app);
474
- }
475
- function createNativeComponentConfig(Component, react, reactdom, componentConfig) {
476
- var _a, _b;
477
- reactMeta.R = react;
478
- h = react.createElement;
479
- ReactDOM = reactdom;
480
- setReconciler(ReactDOM);
481
- const componentObj = {
482
- options: componentConfig,
483
- properties: {
484
- props: {
485
- type: null,
486
- value: null,
487
- observer(_newVal, oldVal) {
488
- oldVal && this.component.forceUpdate();
489
- }
490
- }
491
- },
492
- created() {
493
- if (!Current.app) {
494
- initNativeComponentEntry(react, ReactDOM);
495
- }
496
- },
497
- attached() {
498
- const compId = this.compId = getNativeCompId();
499
- setCurrent(compId);
500
- this.config = componentConfig;
501
- Current.app.mount(Component, compId, () => this);
502
- },
503
- ready() {
504
- safeExecute(this.compId, 'onReady');
505
- },
506
- detached() {
507
- Current.app.unmount(this.compId);
508
- },
509
- pageLifetimes: {
510
- show(options) {
511
- safeExecute(this.compId, 'onShow', options);
512
- },
513
- hide() {
514
- safeExecute(this.compId, 'onHide');
515
- }
516
- },
517
- methods: {
518
- eh: eventHandler
519
- }
520
- };
521
- function setCurrent(compId) {
522
- const pages = getCurrentPages();
523
- const currentPage = pages[pages.length - 1];
524
- if (Current.page === currentPage)
525
- return;
526
- Current.page = currentPage;
527
- const route = currentPage.route || currentPage.__route__;
528
- const router = {
529
- params: currentPage.options || {},
530
- path: addLeadingSlash(route),
531
- $taroPath: compId,
532
- onReady: '',
533
- onHide: '',
534
- onShow: ''
535
- };
536
- Current.router = router;
537
- if (!currentPage.options) {
538
- // 例如在微信小程序中,页面 options 的设置时机比组件 attached 慢
539
- Object.defineProperty(currentPage, 'options', {
540
- enumerable: true,
541
- configurable: true,
542
- get() {
543
- return this._optionsValue;
544
- },
545
- set(value) {
546
- router.params = value;
547
- this._optionsValue = value;
548
- }
549
- });
550
- }
551
- }
552
- // onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
553
- if (Component.onShareAppMessage ||
554
- ((_a = Component.prototype) === null || _a === void 0 ? void 0 : _a.onShareAppMessage) ||
555
- Component.enableShareAppMessage) {
556
- componentObj.methods.onShareAppMessage = function (options) {
557
- const target = options === null || options === void 0 ? void 0 : options.target;
558
- if (target) {
559
- const id = target.id;
560
- const element = document.getElementById(id);
561
- if (element) {
562
- target.dataset = element.dataset;
563
- }
564
- }
565
- return safeExecute(this.compId, 'onShareAppMessage', options);
566
- };
567
- }
568
- if (Component.onShareTimeline ||
569
- ((_b = Component.prototype) === null || _b === void 0 ? void 0 : _b.onShareTimeline) ||
570
- Component.enableShareTimeline) {
571
- componentObj.methods.onShareTimeline = function () {
572
- return safeExecute(this.compId, 'onShareTimeline');
573
- };
574
- }
575
- return componentObj;
431
+ const getNativeCompId = incrementId();
432
+ let h;
433
+ let ReactDOM;
434
+ function initNativeComponentEntry(R, ReactDOM) {
435
+ class NativeComponentWrapper extends R.Component {
436
+ constructor() {
437
+ super(...arguments);
438
+ this.root = R.createRef();
439
+ this.ctx = this.props.getCtx();
440
+ }
441
+ componentDidMount() {
442
+ this.ctx.component = this;
443
+ const rootElement = this.root.current;
444
+ rootElement.ctx = this.ctx;
445
+ rootElement.performUpdate(true);
446
+ }
447
+ render() {
448
+ return (h('root', {
449
+ ref: this.root
450
+ }, this.props.renderComponent(this.ctx)));
451
+ }
452
+ }
453
+ class Entry extends R.Component {
454
+ constructor() {
455
+ super(...arguments);
456
+ this.state = {
457
+ components: []
458
+ };
459
+ }
460
+ componentDidMount() {
461
+ Current.app = this;
462
+ }
463
+ mount(Component, compId, getCtx) {
464
+ const isReactComponent = isClassComponent(R, Component);
465
+ const inject = (node) => node && injectPageInstance(node, compId);
466
+ const refs = isReactComponent ? { ref: inject } : {
467
+ forwardedRef: inject,
468
+ reactReduxForwardedRef: inject
469
+ };
470
+ if (reactMeta.PageContext === EMPTY_OBJ) {
471
+ reactMeta.PageContext = R.createContext('');
472
+ }
473
+ const item = {
474
+ compId,
475
+ element: h(NativeComponentWrapper, {
476
+ key: compId,
477
+ getCtx,
478
+ renderComponent(ctx) {
479
+ return h(reactMeta.PageContext.Provider, { value: compId }, h(Component, Object.assign(Object.assign(Object.assign({}, (ctx.data || (ctx.data = {})).props), refs), { $scope: ctx })));
480
+ }
481
+ })
482
+ };
483
+ this.setState({
484
+ components: [...this.state.components, item]
485
+ });
486
+ }
487
+ unmount(compId) {
488
+ const components = this.state.components;
489
+ const index = components.findIndex(item => item.compId === compId);
490
+ const next = [...components.slice(0, index), ...components.slice(index + 1)];
491
+ this.setState({
492
+ components: next
493
+ });
494
+ }
495
+ render() {
496
+ const components = this.state.components;
497
+ return (components.map(({ element }) => element));
498
+ }
499
+ }
500
+ setReconciler(ReactDOM);
501
+ const app = document.getElementById('app');
502
+ ReactDOM.render(h(Entry, {}), app);
503
+ }
504
+ function createNativeComponentConfig(Component, react, reactdom, componentConfig) {
505
+ var _a, _b;
506
+ reactMeta.R = react;
507
+ h = react.createElement;
508
+ ReactDOM = reactdom;
509
+ setReconciler(ReactDOM);
510
+ const componentObj = {
511
+ options: componentConfig,
512
+ properties: {
513
+ props: {
514
+ type: null,
515
+ value: null,
516
+ observer(_newVal, oldVal) {
517
+ oldVal && this.component.forceUpdate();
518
+ }
519
+ }
520
+ },
521
+ created() {
522
+ if (!Current.app) {
523
+ initNativeComponentEntry(react, ReactDOM);
524
+ }
525
+ },
526
+ attached() {
527
+ const compId = this.compId = getNativeCompId();
528
+ setCurrent(compId);
529
+ this.config = componentConfig;
530
+ Current.app.mount(Component, compId, () => this);
531
+ },
532
+ ready() {
533
+ safeExecute(this.compId, 'onReady');
534
+ },
535
+ detached() {
536
+ Current.app.unmount(this.compId);
537
+ },
538
+ pageLifetimes: {
539
+ show(options) {
540
+ safeExecute(this.compId, 'onShow', options);
541
+ },
542
+ hide() {
543
+ safeExecute(this.compId, 'onHide');
544
+ }
545
+ },
546
+ methods: {
547
+ eh: eventHandler
548
+ }
549
+ };
550
+ function setCurrent(compId) {
551
+ const pages = getCurrentPages();
552
+ const currentPage = pages[pages.length - 1];
553
+ if (Current.page === currentPage)
554
+ return;
555
+ Current.page = currentPage;
556
+ const route = currentPage.route || currentPage.__route__;
557
+ const router = {
558
+ params: currentPage.options || {},
559
+ path: addLeadingSlash(route),
560
+ $taroPath: compId,
561
+ onReady: '',
562
+ onHide: '',
563
+ onShow: ''
564
+ };
565
+ Current.router = router;
566
+ if (!currentPage.options) {
567
+ // 例如在微信小程序中,页面 options 的设置时机比组件 attached 慢
568
+ Object.defineProperty(currentPage, 'options', {
569
+ enumerable: true,
570
+ configurable: true,
571
+ get() {
572
+ return this._optionsValue;
573
+ },
574
+ set(value) {
575
+ router.params = value;
576
+ this._optionsValue = value;
577
+ }
578
+ });
579
+ }
580
+ }
581
+ // onShareAppMessage 和 onShareTimeline 一样,会影响小程序右上方按钮的选项,因此不能默认注册。
582
+ if (Component.onShareAppMessage ||
583
+ ((_a = Component.prototype) === null || _a === void 0 ? void 0 : _a.onShareAppMessage) ||
584
+ Component.enableShareAppMessage) {
585
+ componentObj.methods.onShareAppMessage = function (options) {
586
+ const target = options === null || options === void 0 ? void 0 : options.target;
587
+ if (target) {
588
+ const id = target.id;
589
+ const element = document.getElementById(id);
590
+ if (element) {
591
+ target.dataset = element.dataset;
592
+ }
593
+ }
594
+ return safeExecute(this.compId, 'onShareAppMessage', options);
595
+ };
596
+ }
597
+ if (Component.onShareTimeline ||
598
+ ((_b = Component.prototype) === null || _b === void 0 ? void 0 : _b.onShareTimeline) ||
599
+ Component.enableShareTimeline) {
600
+ componentObj.methods.onShareTimeline = function () {
601
+ return safeExecute(this.compId, 'onShareTimeline');
602
+ };
603
+ }
604
+ return componentObj;
576
605
  }
577
606
 
578
- hooks.tap('initNativeApi', function (taro) {
579
- for (const hook in taroHooks$1) {
580
- taro[hook] = taroHooks$1[hook];
581
- }
582
- });
583
- if (__TARO_FRAMEWORK__ === 'preact') {
584
- const options = require('preact').options;
585
- const oldVNodeHook = options.vnode;
586
- const oldDiffedHook = options.diffed;
587
- options.vnode = vnode => {
588
- const { type, props } = vnode;
589
- let normalizedProps = props;
590
- // only normalize props on Element nodes
591
- if (typeof type === 'string') {
592
- normalizedProps = {};
593
- for (let i in props) {
594
- const value = props[i];
595
- if (/^on/.test(i)) {
596
- i = i.toLowerCase();
597
- }
598
- normalizedProps[i] = value;
599
- }
600
- vnode.props = normalizedProps;
601
- }
602
- if (oldVNodeHook)
603
- oldVNodeHook(vnode);
604
- };
605
- options.diffed = function (newVNode) {
606
- const dom = newVNode._dom;
607
- const newVNodeProps = newVNode.props;
608
- if (dom) { /** ElementNode */
609
- for (const propName in newVNodeProps) {
610
- const propValue = newVNodeProps[propName];
611
- if (propValue === false && dom.props[propName] === undefined) {
612
- // 值为 false 的属性在 Preact 的 diff 中被 removeAttribute 了,这里手动 setAttribute
613
- // fix https://github.com/NervJS/taro/issues/11197
614
- dom.setAttribute(propName, propValue);
615
- }
616
- }
617
- }
618
- if (oldDiffedHook)
619
- oldDiffedHook(newVNode);
620
- };
621
- hooks.tap('modifyMpEvent', e => {
622
- const type = e.type;
623
- if (type === 'tap') {
624
- e.type = 'click';
625
- }
626
- else if (type === 'focus') {
627
- // 兼容 preact/compat/src/render.js options.vnode 的处理逻辑
628
- e.type = 'focusin';
629
- }
630
- else if (type === 'blur') {
631
- e.type = 'focusout';
632
- }
633
- });
634
- // hooks.modifyDispatchEventImpls?.push(e => {
635
- // })
607
+ hooks.tap('initNativeApi', function (taro) {
608
+ for (const hook in taroHooks) {
609
+ taro[hook] = taroHooks[hook];
610
+ }
611
+ });
612
+ if (__TARO_FRAMEWORK__ === 'preact') {
613
+ const options = require('preact').options;
614
+ const oldVNodeHook = options.vnode;
615
+ const oldDiffedHook = options.diffed;
616
+ options.vnode = vnode => {
617
+ const { type, props } = vnode;
618
+ let normalizedProps = props;
619
+ // only normalize props on Element nodes
620
+ if (typeof type === 'string') {
621
+ normalizedProps = {};
622
+ for (let i in props) {
623
+ const value = props[i];
624
+ if (/^on/.test(i)) {
625
+ i = i.toLowerCase();
626
+ }
627
+ if (type === 'map' && i === 'onregionchange') {
628
+ // map 组件的 regionchange 事件非常特殊,详情:https://github.com/NervJS/taro/issues/5766
629
+ normalizedProps.onbegin = value;
630
+ normalizedProps.onend = value;
631
+ continue;
632
+ }
633
+ normalizedProps[i] = value;
634
+ }
635
+ vnode.props = normalizedProps;
636
+ }
637
+ if (oldVNodeHook)
638
+ oldVNodeHook(vnode);
639
+ };
640
+ options.diffed = function (newVNode) {
641
+ const dom = newVNode._dom;
642
+ const newVNodeProps = newVNode.props;
643
+ if (dom) { /** ElementNode */
644
+ for (const propName in newVNodeProps) {
645
+ const propValue = newVNodeProps[propName];
646
+ if (propValue === false && dom.props[propName] === undefined) {
647
+ // 值为 false 的属性在 Preact 的 diff 中被 removeAttribute 了,这里手动 setAttribute
648
+ // fix https://github.com/NervJS/taro/issues/11197
649
+ dom.setAttribute(propName, propValue);
650
+ }
651
+ }
652
+ }
653
+ if (oldDiffedHook)
654
+ oldDiffedHook(newVNode);
655
+ };
656
+ hooks.tap('modifyMpEvent', e => {
657
+ const type = e.type;
658
+ if (type === 'tap') {
659
+ e.type = 'click';
660
+ }
661
+ else if (type === 'focus') {
662
+ // 兼容 preact/compat/src/render.js options.vnode 的处理逻辑
663
+ e.type = 'focusin';
664
+ }
665
+ else if (type === 'blur') {
666
+ e.type = 'focusout';
667
+ }
668
+ });
669
+ // hooks.modifyDispatchEventImpls?.push(e => {
670
+ // })
636
671
  }
637
672
 
638
- export { connectReactPage, createNativeComponentConfig, createReactApp, setReconciler, useAddToFavorites, useDidHide, useDidShow, useLoad, useOptionMenuClick, usePageScroll, usePullDownRefresh, usePullIntercept, useReachBottom, useReady, useResize, useRouter, useScope, useShareAppMessage, useShareTimeline, useTabItemTap, useTitleClick, useUnload };
673
+ export { connectReactPage, createNativeComponentConfig, createReactApp, setReconciler, useAddToFavorites, useDidHide, useDidShow, useError, useLaunch, useLoad, useOptionMenuClick, usePageNotFound, usePageScroll, usePullDownRefresh, usePullIntercept, useReachBottom, useReady, useResize, useRouter, useSaveExitState, useScope, useShareAppMessage, useShareTimeline, useTabItemTap, useTitleClick, useUnload };
639
674
  //# sourceMappingURL=runtime.js.map