@mpxjs/webpack-plugin 2.10.21 → 2.10.24-beta.1

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.
Files changed (34) hide show
  1. package/lib/index.js +4 -1
  2. package/lib/loader.js +2 -0
  3. package/lib/react/index.js +3 -1
  4. package/lib/react/processTemplate.js +3 -1
  5. package/lib/resolver/AddEnvPlugin.js +1 -1
  6. package/lib/resolver/AddModePlugin.js +1 -1
  7. package/lib/resolver/ExtendComponentsPlugin.js +91 -0
  8. package/lib/runtime/components/extends/section-list.mpx +14 -0
  9. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +3 -1
  10. package/lib/runtime/components/react/dist/mpx-section-list.d.ts +56 -0
  11. package/lib/runtime/components/react/dist/mpx-section-list.jsx +484 -0
  12. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +12 -12
  13. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -1
  14. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +12 -12
  15. package/lib/runtime/components/react/dist/mpx-text.jsx +15 -15
  16. package/lib/runtime/components/react/dist/mpx-view.jsx +15 -15
  17. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +2 -1
  18. package/lib/runtime/components/react/dist/utils.d.ts +1 -0
  19. package/lib/runtime/components/react/dist/utils.jsx +4 -1
  20. package/lib/runtime/components/react/mpx-canvas/index.tsx +4 -2
  21. package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
  22. package/lib/runtime/components/react/mpx-section-list.tsx +734 -0
  23. package/lib/runtime/components/react/mpx-simple-text.tsx +12 -12
  24. package/lib/runtime/components/react/mpx-simple-view.tsx +12 -12
  25. package/lib/runtime/components/react/mpx-text.tsx +15 -15
  26. package/lib/runtime/components/react/mpx-view.tsx +15 -15
  27. package/lib/runtime/components/react/mpx-web-view.tsx +4 -3
  28. package/lib/runtime/components/react/utils.tsx +5 -1
  29. package/lib/template-compiler/compiler.js +5 -1
  30. package/lib/utils/source-location.js +9 -13
  31. package/lib/web/index.js +3 -1
  32. package/lib/web/processTemplate.js +3 -1
  33. package/package.json +6 -4
  34. package/LICENSE +0 -433
@@ -0,0 +1,484 @@
1
+ import { forwardRef, useRef, useMemo, createElement, useImperativeHandle, useEffect } from 'react';
2
+ import { SectionList, RefreshControl } from 'react-native';
3
+ import { Gesture, GestureDetector } from 'react-native-gesture-handler';
4
+ import { hasOwn, error } from '@mpxjs/utils';
5
+ import useInnerProps, { getCustomEvent } from './getInnerListeners';
6
+ import { extendObject, useLayout, useTransformStyle, flatGesture } from './utils';
7
+ const TypedSectionList = SectionList;
8
+ const getGeneric = (generichash, generickey) => {
9
+ if (!generichash || !generickey)
10
+ return null;
11
+ return global.__mpxGenericsMap?.[generichash]?.[generickey]?.() || null;
12
+ };
13
+ const getExposurePercentThreshold = (threshold = 0) => {
14
+ return Math.max(0, Math.min(100, threshold));
15
+ };
16
+ const _SectionList = forwardRef((props = {}, ref) => {
17
+ const { enhanced = false, bounces = true, height, width, generichash, style = {}, 'list-data': listData, 'scroll-event-throttle': scrollEventThrottle = 0, 'item-height': itemHeight = {}, 'section-header-height': sectionHeaderHeight = {}, 'section-footer-height': sectionFooterHeight = {}, 'list-header-height': listHeaderHeight = 0, 'list-header-data': listHeaderData = null, 'use-list-header': useListHeader = false, 'list-footer-data': listFooterData = null, 'use-list-footer': useListFooter = false, 'genericrecycle-item': genericrecycleItem, 'genericsection-header': genericsectionHeader, 'genericsection-footer': genericsectionFooter, 'genericlist-header': genericListHeader, 'genericlist-footer': genericListFooter, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'enable-sticky': enableSticky = false, 'enable-back-to-top': enableBackToTop = false, 'end-reached-threshold': onEndReachedThreshold = 0.1, 'refresher-enabled': refresherEnabled, 'show-scrollbar': showScrollbar = true, 'refresher-triggered': refresherTriggered, 'enable-item-exposure': enableItemExposure = false, 'item-exposure-threshold': itemExposureThreshold = 0, 'simultaneous-handlers': originSimultaneousHandlers, 'wait-for': waitFor, binditemexposure } = props;
18
+ const refreshing = !!refresherTriggered;
19
+ const scrollViewRef = useRef(null);
20
+ const sectionListGestureRef = useRef();
21
+ const indexMap = useRef({});
22
+ const reverseIndexMap = useRef({});
23
+ const exposureIndexMap = useRef({});
24
+ const itemLayoutsRef = useRef([]);
25
+ const itemExposureState = useRef({});
26
+ const enableStickyRef = useRef(enableSticky);
27
+ const bindItemExposureRef = useRef();
28
+ const propsRef = useRef(props);
29
+ const initialEnableItemExposureRef = useRef(enableItemExposure);
30
+ const itemExposureViewabilityConfig = useRef();
31
+ if (!itemExposureViewabilityConfig.current) {
32
+ itemExposureViewabilityConfig.current = {
33
+ itemVisiblePercentThreshold: getExposurePercentThreshold(itemExposureThreshold)
34
+ };
35
+ }
36
+ const itemExposureViewabilityConfigValue = itemExposureViewabilityConfig.current;
37
+ const { hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
38
+ const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef });
39
+ if (initialEnableItemExposureRef.current !== enableItemExposure) {
40
+ error('[Mpx runtime error]: [enable-item-exposure] cannot be toggled at runtime. Set its value once at component initialization.');
41
+ }
42
+ enableStickyRef.current = enableSticky;
43
+ bindItemExposureRef.current = binditemexposure;
44
+ propsRef.current = props;
45
+ const onRefresh = () => {
46
+ const { bindrefresherrefresh } = props;
47
+ bindrefresherrefresh &&
48
+ bindrefresherrefresh(getCustomEvent('refresherrefresh', {}, { layoutRef }, props));
49
+ };
50
+ const onEndReached = () => {
51
+ const { bindscrolltolower } = props;
52
+ bindscrolltolower &&
53
+ bindscrolltolower(getCustomEvent('scrolltolower', {}, { layoutRef }, props));
54
+ };
55
+ const onScroll = (event) => {
56
+ const { bindscroll } = props;
57
+ bindscroll &&
58
+ bindscroll(getCustomEvent('scroll', event.nativeEvent, { layoutRef }, props));
59
+ };
60
+ const itemExposureViewabilityPairs = useRef();
61
+ if (!itemExposureViewabilityPairs.current) {
62
+ itemExposureViewabilityPairs.current = [
63
+ {
64
+ viewabilityConfig: itemExposureViewabilityConfigValue,
65
+ onViewableItemsChanged: ({ changed }) => {
66
+ const bindItemExposure = bindItemExposureRef.current;
67
+ if (!bindItemExposure)
68
+ return;
69
+ const exposedItems = [];
70
+ changed.forEach((viewToken) => {
71
+ const exposureInfo = getItemExposureInfo(viewToken);
72
+ if (!exposureInfo)
73
+ return;
74
+ const { index, itemData, layout } = exposureInfo;
75
+ const key = `${index}`;
76
+ if (!viewToken.isViewable) {
77
+ delete itemExposureState.current[key];
78
+ return;
79
+ }
80
+ if (!itemExposureState.current[key]) {
81
+ itemExposureState.current[key] = true;
82
+ exposedItems.push({
83
+ index,
84
+ itemData,
85
+ layout,
86
+ threshold: itemExposureViewabilityConfigValue.itemVisiblePercentThreshold
87
+ });
88
+ }
89
+ });
90
+ if (exposedItems.length) {
91
+ bindItemExposure(getCustomEvent('itemexposure', {}, {
92
+ detail: {
93
+ items: exposedItems,
94
+ time: Date.now()
95
+ },
96
+ layoutRef
97
+ }, propsRef.current));
98
+ }
99
+ }
100
+ }
101
+ ];
102
+ }
103
+ // 通过sectionIndex和rowIndex获取原始索引
104
+ const getOriginalIndex = (sectionIndex, rowIndex) => {
105
+ const key = `${sectionIndex}_${rowIndex}`;
106
+ return reverseIndexMap.current[key] ?? -1; // 如果找不到,返回-1
107
+ };
108
+ const getItemExposureInfo = (viewToken) => {
109
+ const item = viewToken.item;
110
+ if (!item)
111
+ return null;
112
+ const viewIndex = viewToken.index;
113
+ if (viewIndex == null)
114
+ return null;
115
+ const indexInfo = exposureIndexMap.current[viewIndex];
116
+ if (!indexInfo)
117
+ return null;
118
+ if (indexInfo.type === 'header' && enableStickyRef.current)
119
+ return null;
120
+ const layoutInfo = itemLayoutsRef.current[viewIndex];
121
+ const layout = {
122
+ offset: layoutInfo ? layoutInfo.offset : 0,
123
+ length: layoutInfo ? layoutInfo.length : 0
124
+ };
125
+ if (indexInfo.type === 'header') {
126
+ const section = item;
127
+ return {
128
+ index: indexInfo.index,
129
+ itemData: section.headerData || null,
130
+ layout
131
+ };
132
+ }
133
+ if (indexInfo.type === 'footer') {
134
+ const section = item;
135
+ return {
136
+ index: indexInfo.index,
137
+ itemData: section.footerData || null,
138
+ layout
139
+ };
140
+ }
141
+ return {
142
+ index: indexInfo.index,
143
+ itemData: item,
144
+ layout
145
+ };
146
+ };
147
+ const scrollToIndex = ({ index, animated, viewOffset = 0, viewPosition = 0 }) => {
148
+ if (!scrollViewRef.current)
149
+ return;
150
+ // 通过索引映射表快速定位位置
151
+ const position = indexMap.current[index];
152
+ if (!position)
153
+ return;
154
+ const [sectionIndex, itemIndex] = position.split('_');
155
+ const targetSectionIndex = Number(sectionIndex) || 0;
156
+ const targetItemIndex = itemIndex === 'header'
157
+ ? 0
158
+ : itemIndex === 'footer'
159
+ ? convertedListData[targetSectionIndex].data.length + 1
160
+ : Number(itemIndex) + 1;
161
+ scrollViewRef.current.scrollToLocation?.({
162
+ itemIndex: targetItemIndex,
163
+ sectionIndex: targetSectionIndex,
164
+ animated,
165
+ viewOffset,
166
+ viewPosition
167
+ });
168
+ };
169
+ const getItemHeight = ({ sectionIndex, rowIndex }) => {
170
+ if (!itemHeight) {
171
+ return 0;
172
+ }
173
+ if (itemHeight.getter) {
174
+ const item = convertedListData[sectionIndex].data[rowIndex];
175
+ return itemHeight.getter?.(item, getOriginalIndex(sectionIndex, rowIndex)) || 0;
176
+ }
177
+ else {
178
+ return itemHeight.value || 0;
179
+ }
180
+ };
181
+ const getSectionExtraHeight = ({ sectionIndex, type }) => {
182
+ const item = convertedListData[sectionIndex];
183
+ const isHeader = type === 'header';
184
+ if (!(isHeader ? item.hasSectionHeader : item.hasSectionFooter))
185
+ return 0;
186
+ const sectionExtraHeight = (isHeader ? sectionHeaderHeight : sectionFooterHeight);
187
+ if (sectionExtraHeight.getter) {
188
+ const sectionExtraData = isHeader ? item.headerData : item.footerData;
189
+ return sectionExtraHeight.getter?.(sectionExtraData, getOriginalIndex(sectionIndex, type)) || 0;
190
+ }
191
+ return sectionExtraHeight.value || 0;
192
+ };
193
+ const convertedListData = useMemo(() => {
194
+ const sections = [];
195
+ let currentSection = null;
196
+ // 清空之前的索引映射
197
+ indexMap.current = {};
198
+ // 清空反向索引映射
199
+ reverseIndexMap.current = {};
200
+ exposureIndexMap.current = {};
201
+ // 处理 listData 为空的情况
202
+ if (!listData || !listData.length) {
203
+ return sections;
204
+ }
205
+ let exposureIndex = 0;
206
+ // 需与 RN SectionList 和 getItemLayout 的扁平顺序保持一致:每个 section 都是 [header, ...items, footer]
207
+ const createSection = (headerInfo) => {
208
+ const sectionIndex = sections.length;
209
+ const section = {
210
+ headerData: headerInfo?.data || null,
211
+ footerData: null,
212
+ data: [],
213
+ hasSectionHeader: !!headerInfo,
214
+ hasSectionFooter: false
215
+ };
216
+ if (headerInfo) {
217
+ const { index } = headerInfo;
218
+ indexMap.current[index] = `${sectionIndex}_header`;
219
+ reverseIndexMap.current[`${sectionIndex}_header`] = index;
220
+ exposureIndexMap.current[exposureIndex] = {
221
+ index,
222
+ type: 'header'
223
+ };
224
+ }
225
+ exposureIndex++;
226
+ return section;
227
+ };
228
+ const closeSection = () => {
229
+ const section = currentSection;
230
+ if (!section)
231
+ return;
232
+ if (section.hasSectionFooter) {
233
+ const sectionIndex = sections.length;
234
+ const index = getOriginalIndex(sectionIndex, 'footer');
235
+ if (index > -1) {
236
+ exposureIndexMap.current[exposureIndex] = {
237
+ index,
238
+ type: 'footer'
239
+ };
240
+ }
241
+ }
242
+ // RN SectionList 即使没有真实 footer,也会为每个 section 保留 footer slot
243
+ exposureIndex++;
244
+ sections.push(section);
245
+ currentSection = null;
246
+ };
247
+ listData.forEach((item, index) => {
248
+ if (item.isSectionHeader) {
249
+ // 如果已经存在一个 section,先把它添加到 sections 中
250
+ if (currentSection) {
251
+ closeSection();
252
+ }
253
+ currentSection = createSection({ data: item, index });
254
+ }
255
+ else if (item.isSectionFooter) {
256
+ // 如果没有当前 section,创建一个默认的
257
+ if (!currentSection) {
258
+ // 创建默认section (无header的section)
259
+ currentSection = createSection();
260
+ }
261
+ const sectionIndex = sections.length;
262
+ currentSection.footerData = item;
263
+ currentSection.hasSectionFooter = true;
264
+ indexMap.current[index] = `${sectionIndex}_footer`;
265
+ // 添加反向索引映射
266
+ reverseIndexMap.current[`${sectionIndex}_footer`] = index;
267
+ closeSection();
268
+ }
269
+ else {
270
+ // 如果没有当前 section,创建一个默认的
271
+ if (!currentSection) {
272
+ // 创建默认section (无header的section)
273
+ currentSection = createSection();
274
+ }
275
+ // 将 item 添加到当前 section 的 data 中
276
+ const itemIndex = currentSection.data.length;
277
+ currentSection.data.push(item);
278
+ const sectionIndex = sections.length;
279
+ // 为 item 添加索引映射 - 存储格式为: "sectionIndex_itemIndex"
280
+ indexMap.current[index] = `${sectionIndex}_${itemIndex}`;
281
+ // 添加反向索引映射
282
+ reverseIndexMap.current[`${sectionIndex}_${itemIndex}`] = index;
283
+ exposureIndexMap.current[exposureIndex] = {
284
+ index,
285
+ type: 'item'
286
+ };
287
+ exposureIndex++;
288
+ }
289
+ });
290
+ // 添加最后一个 section
291
+ if (currentSection) {
292
+ closeSection();
293
+ }
294
+ return sections;
295
+ }, [listData]);
296
+ const { getItemLayout } = useMemo(() => {
297
+ const layouts = [];
298
+ let offset = 0;
299
+ if (useListHeader) {
300
+ // 计算列表头部的高度
301
+ offset += listHeaderHeight;
302
+ }
303
+ // 遍历所有 sections
304
+ convertedListData.forEach((section, sectionIndex) => {
305
+ // 添加 section header 的位置信息
306
+ const headerHeight = getSectionExtraHeight({ sectionIndex, type: 'header' });
307
+ layouts.push({
308
+ length: headerHeight,
309
+ offset,
310
+ index: layouts.length
311
+ });
312
+ offset += headerHeight;
313
+ // 添加该 section 中所有 items 的位置信息
314
+ section.data.forEach((item, itemIndex) => {
315
+ const contentHeight = getItemHeight({ sectionIndex, rowIndex: itemIndex });
316
+ layouts.push({
317
+ length: contentHeight,
318
+ offset,
319
+ index: layouts.length
320
+ });
321
+ offset += contentHeight;
322
+ });
323
+ // 添加该 section 尾部位置信息
324
+ // 因为即使 sectionList 没传 renderSectionFooter,getItemLayout 中的 index 的计算也会包含尾部节点
325
+ const footerHeight = getSectionExtraHeight({ sectionIndex, type: 'footer' });
326
+ layouts.push({
327
+ length: footerHeight,
328
+ offset,
329
+ index: layouts.length
330
+ });
331
+ offset += footerHeight;
332
+ });
333
+ itemLayoutsRef.current = layouts;
334
+ return {
335
+ getItemLayout: (data, index) => layouts[index]
336
+ };
337
+ }, [convertedListData, useListHeader, itemHeight.value, itemHeight.getter, sectionHeaderHeight.value, sectionHeaderHeight.getter, sectionFooterHeight.value, sectionFooterHeight.getter, listHeaderHeight]);
338
+ useEffect(() => {
339
+ itemExposureState.current = {};
340
+ }, [convertedListData, enableSticky]);
341
+ const scrollAdditionalProps = extendObject({
342
+ style: [
343
+ hasOwn(style, 'flex') || hasOwn(style, 'flexGrow') ? null : { flexGrow: 0 },
344
+ { height, width },
345
+ style,
346
+ layoutStyle
347
+ ],
348
+ alwaysBounceVertical: false,
349
+ alwaysBounceHorizontal: false,
350
+ scrollEventThrottle: scrollEventThrottle,
351
+ scrollsToTop: enableBackToTop,
352
+ showsHorizontalScrollIndicator: showScrollbar,
353
+ onEndReachedThreshold,
354
+ ref: scrollViewRef,
355
+ bounces: enhanced ? bounces : false,
356
+ stickySectionHeadersEnabled: enableSticky,
357
+ onScroll: onScroll,
358
+ onEndReached: onEndReached
359
+ }, refresherEnabled ? { refreshing } : null, layoutProps);
360
+ if (initialEnableItemExposureRef.current) {
361
+ extendObject(scrollAdditionalProps, {
362
+ viewabilityConfigCallbackPairs: itemExposureViewabilityPairs.current
363
+ });
364
+ }
365
+ const nativeGesture = useMemo(() => {
366
+ const simultaneousHandlers = flatGesture(originSimultaneousHandlers);
367
+ const waitForHandlers = flatGesture(waitFor);
368
+ const gesture = Gesture.Native().withRef(sectionListGestureRef);
369
+ if (simultaneousHandlers && simultaneousHandlers.length) {
370
+ gesture.simultaneousWithExternalGesture(...simultaneousHandlers);
371
+ }
372
+ if (waitForHandlers && waitForHandlers.length) {
373
+ gesture.requireExternalGestureToFail(...waitForHandlers);
374
+ }
375
+ return gesture;
376
+ }, [originSimultaneousHandlers, waitFor]);
377
+ useImperativeHandle(ref, () => {
378
+ return {
379
+ gestureRef: sectionListGestureRef,
380
+ scrollToIndex
381
+ };
382
+ });
383
+ const innerProps = useInnerProps(extendObject({}, props, scrollAdditionalProps), [
384
+ 'id',
385
+ 'enhanced',
386
+ 'height',
387
+ 'width',
388
+ 'list-data',
389
+ 'item-height',
390
+ 'section-header-height',
391
+ 'section-footer-height',
392
+ 'list-header-height',
393
+ 'list-header-data',
394
+ 'use-list-header',
395
+ 'list-footer-data',
396
+ 'use-list-footer',
397
+ 'genericrecycle-item',
398
+ 'genericsection-header',
399
+ 'genericsection-footer',
400
+ 'genericlist-header',
401
+ 'genericlist-footer',
402
+ 'show-scrollbar',
403
+ 'lower-threshold',
404
+ 'scroll-event-throttle',
405
+ 'enable-sticky',
406
+ 'enable-back-to-top',
407
+ 'end-reached-threshold',
408
+ 'refresher-triggered',
409
+ 'refresher-enabled',
410
+ 'enable-item-exposure',
411
+ 'item-exposure-threshold',
412
+ 'bindrefresherrefresh',
413
+ 'bindscrolltolower',
414
+ 'bindscroll',
415
+ 'binditemexposure',
416
+ 'simultaneous-handlers',
417
+ 'wait-for'
418
+ ], { layoutRef });
419
+ // 使用 useMemo 获取 GenericComponent 并创建渲染函数,避免每次组件更新都重新创建函数引用导致不必要的重新渲染
420
+ const renderItem = useMemo(() => {
421
+ const ItemComponent = getGeneric(generichash, genericrecycleItem);
422
+ if (!ItemComponent)
423
+ return undefined;
424
+ return ({ item }) => createElement(ItemComponent, { itemData: item });
425
+ }, [generichash, genericrecycleItem]);
426
+ const renderSectionHeader = useMemo(() => {
427
+ const SectionHeaderComponent = getGeneric(generichash, genericsectionHeader);
428
+ if (!SectionHeaderComponent)
429
+ return undefined;
430
+ return (sectionData) => {
431
+ if (!sectionData.section.hasSectionHeader)
432
+ return null;
433
+ return createElement(SectionHeaderComponent, { itemData: sectionData.section.headerData });
434
+ };
435
+ }, [generichash, genericsectionHeader]);
436
+ const renderSectionFooter = useMemo(() => {
437
+ const SectionFooterComponent = getGeneric(generichash, genericsectionFooter);
438
+ if (!SectionFooterComponent)
439
+ return undefined;
440
+ return (sectionData) => {
441
+ if (!sectionData.section.hasSectionFooter)
442
+ return null;
443
+ return createElement(SectionFooterComponent, { itemData: sectionData.section.footerData });
444
+ };
445
+ }, [generichash, genericsectionFooter]);
446
+ const ListHeaderGenericComponent = useMemo(() => {
447
+ if (!useListHeader)
448
+ return null;
449
+ return getGeneric(generichash, genericListHeader);
450
+ }, [useListHeader, generichash, genericListHeader]);
451
+ const ListFooterGenericComponent = useMemo(() => {
452
+ if (!useListFooter)
453
+ return null;
454
+ return getGeneric(generichash, genericListFooter);
455
+ }, [useListFooter, generichash, genericListFooter]);
456
+ const ListHeaderComponent = useMemo(() => {
457
+ if (!ListHeaderGenericComponent)
458
+ return null;
459
+ return createElement(ListHeaderGenericComponent, { listHeaderData });
460
+ }, [ListHeaderGenericComponent, listHeaderData]);
461
+ const ListFooterComponent = useMemo(() => {
462
+ if (!ListFooterGenericComponent)
463
+ return null;
464
+ return createElement(ListFooterGenericComponent, { listFooterData });
465
+ }, [ListFooterGenericComponent, listFooterData]);
466
+ const sectionListProps = extendObject({
467
+ sections: convertedListData,
468
+ renderItem: renderItem,
469
+ getItemLayout: getItemLayout,
470
+ ListHeaderComponent: useListHeader ? ListHeaderComponent : null,
471
+ ListFooterComponent: useListFooter ? ListFooterComponent : null,
472
+ renderSectionHeader: renderSectionHeader,
473
+ renderSectionFooter: renderSectionFooter,
474
+ refreshControl: refresherEnabled
475
+ ? createElement(RefreshControl, {
476
+ onRefresh: onRefresh,
477
+ refreshing: refreshing
478
+ })
479
+ : undefined
480
+ }, innerProps);
481
+ return createElement(GestureDetector, { gesture: nativeGesture }, createElement(TypedSectionList, sectionListProps));
482
+ });
483
+ _SectionList.displayName = 'MpxSectionList';
484
+ export default _SectionList;
@@ -5,13 +5,13 @@ import { extendObject, getDefaultAllowFontScaling, useTextPassThroughValue, wrap
5
5
  import { TextPassThroughContext } from './context';
6
6
  import * as perf from '@mpxjs/perf';
7
7
  const SimpleText = (props) => {
8
- let stopTotal;
8
+ let idTotal = -1;
9
9
  if (__mpx_perf_framework__)
10
- stopTotal = perf.scope('simple-text:render:total');
10
+ idTotal = perf.scopeStart('simple-text:render:total');
11
11
  // ───── style 阶段 ─────
12
- let stopStyle;
12
+ let idStyle = -1;
13
13
  if (__mpx_perf_framework__)
14
- stopStyle = perf.scope('simple-text:render:style');
14
+ idStyle = perf.scopeStart('simple-text:render:style');
15
15
  const inheritedText = useContext(TextPassThroughContext);
16
16
  const mergedStyle = extendObject({}, inheritedText?.textStyle, props.style);
17
17
  let hasBoxSizingAffectingStyle = false;
@@ -30,29 +30,29 @@ const SimpleText = (props) => {
30
30
  disabled: isStringOnly
31
31
  });
32
32
  if (__mpx_perf_framework__)
33
- stopStyle();
33
+ perf.scopeEnd(idStyle);
34
34
  // ───── innerProps 阶段 ─────
35
- let stopInnerProps;
35
+ let idInnerProps = -1;
36
36
  if (__mpx_perf_framework__)
37
- stopInnerProps = perf.scope('simple-text:render:innerProps');
37
+ idInnerProps = perf.scopeStart('simple-text:render:innerProps');
38
38
  const innerProps = useInnerProps(extendObject({}, mergedProps, {
39
39
  allowFontScaling: allowFontScaling ?? getDefaultAllowFontScaling(),
40
40
  style: finalStyle
41
41
  }));
42
42
  if (__mpx_perf_framework__)
43
- stopInnerProps();
43
+ perf.scopeEnd(idInnerProps);
44
44
  // ───── createElement 阶段 ─────
45
- let stopCreate;
45
+ let idCreate = -1;
46
46
  if (__mpx_perf_framework__)
47
- stopCreate = perf.scope('simple-text:render:createElement');
47
+ idCreate = perf.scopeStart('simple-text:render:createElement');
48
48
  const result = createElement(Text, innerProps, wrapChildren({ children }, {
49
49
  hasVarDec: false,
50
50
  textPassThrough: childTextPassThrough
51
51
  }));
52
52
  if (__mpx_perf_framework__)
53
- stopCreate();
53
+ perf.scopeEnd(idCreate);
54
54
  if (__mpx_perf_framework__)
55
- stopTotal();
55
+ perf.scopeEnd(idTotal);
56
56
  return result;
57
57
  };
58
58
  SimpleText.displayName = 'MpxSimpleText';
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ViewProps } from 'react-native';
3
2
  declare const SimpleView: {
4
3
  (simpleViewProps: ViewProps): JSX.Element;
@@ -4,13 +4,13 @@ import { splitProps, splitStyle, wrapChildren, extendObject, useTextPassThroughV
4
4
  import useInnerProps from './getInnerListeners';
5
5
  import * as perf from '@mpxjs/perf';
6
6
  const SimpleView = (simpleViewProps) => {
7
- let stopTotal;
7
+ let idTotal = -1;
8
8
  if (__mpx_perf_framework__)
9
- stopTotal = perf.scope('simple-view:render:total');
9
+ idTotal = perf.scopeStart('simple-view:render:total');
10
10
  // ───── style 阶段 ─────
11
- let stopStyle;
11
+ let idStyle = -1;
12
12
  if (__mpx_perf_framework__)
13
- stopStyle = perf.scope('simple-view:render:style');
13
+ idStyle = perf.scopeStart('simple-view:render:style');
14
14
  const { textProps, innerProps: props = {} } = splitProps(simpleViewProps);
15
15
  let hasBoxSizingAffectingStyle = false;
16
16
  const { textStyle, innerStyle = {} } = splitStyle(props.style || {}, (key) => {
@@ -20,28 +20,28 @@ const SimpleView = (simpleViewProps) => {
20
20
  });
21
21
  const textPassThrough = useTextPassThroughValue(textStyle, textProps);
22
22
  if (__mpx_perf_framework__)
23
- stopStyle();
23
+ perf.scopeEnd(idStyle);
24
24
  // ───── innerProps 阶段 ─────
25
- let stopInnerProps;
25
+ let idInnerProps = -1;
26
26
  if (__mpx_perf_framework__)
27
- stopInnerProps = perf.scope('simple-view:render:innerProps');
27
+ idInnerProps = perf.scopeStart('simple-view:render:innerProps');
28
28
  const innerProps = useInnerProps(extendObject({}, props, {
29
29
  style: transformBoxSizing(extendObject({}, innerStyle), hasBoxSizingAffectingStyle)
30
30
  }));
31
31
  if (__mpx_perf_framework__)
32
- stopInnerProps();
32
+ perf.scopeEnd(idInnerProps);
33
33
  // ───── createElement 阶段 ─────
34
- let stopCreate;
34
+ let idCreate = -1;
35
35
  if (__mpx_perf_framework__)
36
- stopCreate = perf.scope('simple-view:render:createElement');
36
+ idCreate = perf.scopeStart('simple-view:render:createElement');
37
37
  const result = createElement(View, innerProps, wrapChildren(props, {
38
38
  hasVarDec: false,
39
39
  textPassThrough
40
40
  }));
41
41
  if (__mpx_perf_framework__)
42
- stopCreate();
42
+ perf.scopeEnd(idCreate);
43
43
  if (__mpx_perf_framework__)
44
- stopTotal();
44
+ perf.scopeEnd(idTotal);
45
45
  return result;
46
46
  };
47
47
  SimpleView.displayName = 'MpxSimpleView';
@@ -36,22 +36,22 @@ function getDecodedChildren(children) {
36
36
  });
37
37
  }
38
38
  const _Text = forwardRef((props, ref) => {
39
- let stopTotal;
39
+ let idTotal = -1;
40
40
  if (__mpx_perf_framework__)
41
- stopTotal = perf.scope('text:render:total');
41
+ idTotal = perf.scopeStart('text:render:total');
42
42
  // ───── props 阶段 ─────
43
- let stopProps;
43
+ let idProps = -1;
44
44
  if (__mpx_perf_framework__)
45
- stopProps = perf.scope('text:render:props');
45
+ idProps = perf.scopeStart('text:render:props');
46
46
  const inheritedText = useContext(TextPassThroughContext);
47
47
  const mergedProps = extendObject({}, inheritedText?.pendingTextProps, props);
48
48
  const { style: currentStyle = {}, allowFontScaling, selectable, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, decode } = mergedProps;
49
49
  if (__mpx_perf_framework__)
50
- stopProps();
50
+ perf.scopeEnd(idProps);
51
51
  // ───── style 阶段 ─────
52
- let stopStyle;
52
+ let idStyle = -1;
53
53
  if (__mpx_perf_framework__)
54
- stopStyle = perf.scope('text:render:style');
54
+ idStyle = perf.scopeStart('text:render:style');
55
55
  const { normalStyle, hasVarDec, varContextRef, hasPositionFixed } = useTransformStyle(currentStyle, {
56
56
  enableVar,
57
57
  externalVarContext,
@@ -76,11 +76,11 @@ const _Text = forwardRef((props, ref) => {
76
76
  disabled: isStringOnly
77
77
  });
78
78
  if (__mpx_perf_framework__)
79
- stopStyle();
79
+ perf.scopeEnd(idStyle);
80
80
  // ───── innerProps 阶段 ─────
81
- let stopInnerProps;
81
+ let idInnerProps = -1;
82
82
  if (__mpx_perf_framework__)
83
- stopInnerProps = perf.scope('text:render:innerProps');
83
+ idInnerProps = perf.scopeStart('text:render:innerProps');
84
84
  const innerProps = useInnerProps(extendObject({}, mergedProps, {
85
85
  ref: nodeRef,
86
86
  style: finalStyle,
@@ -91,11 +91,11 @@ const _Text = forwardRef((props, ref) => {
91
91
  'decode'
92
92
  ]);
93
93
  if (__mpx_perf_framework__)
94
- stopInnerProps();
94
+ perf.scopeEnd(idInnerProps);
95
95
  // ───── createElement 阶段 ─────
96
- let stopCreate;
96
+ let idCreate = -1;
97
97
  if (__mpx_perf_framework__)
98
- stopCreate = perf.scope('text:render:createElement');
98
+ idCreate = perf.scopeStart('text:render:createElement');
99
99
  let finalComponent = createElement(Text, innerProps, wrapChildren(extendObject({}, mergedProps, {
100
100
  children
101
101
  }), {
@@ -107,9 +107,9 @@ const _Text = forwardRef((props, ref) => {
107
107
  finalComponent = createElement(Portal, null, finalComponent);
108
108
  }
109
109
  if (__mpx_perf_framework__)
110
- stopCreate();
110
+ perf.scopeEnd(idCreate);
111
111
  if (__mpx_perf_framework__)
112
- stopTotal();
112
+ perf.scopeEnd(idTotal);
113
113
  return finalComponent;
114
114
  });
115
115
  _Text.displayName = 'MpxText';