@tarojs/plugin-framework-react 3.5.0-alpha.15 → 3.5.0-alpha.16

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