@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
@@ -566,13 +566,13 @@ function wrapWithChildren(props, { hasVarDec, enableBackground, backgroundStyle,
566
566
  }
567
567
  const _View = forwardRef((viewProps, ref) => {
568
568
  // 性能探针 - total
569
- let stopTotal;
569
+ let idTotal = -1;
570
570
  if (__mpx_perf_framework__)
571
- stopTotal = perf.scope('view:render:total');
571
+ idTotal = perf.scopeStart('view:render:total');
572
572
  // ───── props 阶段 ─────
573
- let stopProps;
573
+ let idProps = -1;
574
574
  if (__mpx_perf_framework__)
575
- stopProps = perf.scope('view:render:props');
575
+ idProps = perf.scopeStart('view:render:props');
576
576
  const { textProps, innerProps: props = {} } = splitProps(viewProps);
577
577
  let { style = {}, 'hover-style': hoverStyle, 'hover-start-time': hoverStartTime = 50, 'hover-stay-time': hoverStayTime = 400, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'enable-background': enableBackground, 'enable-fast-image': enableFastImage, 'enable-animation': enableAnimation, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, animation, catchtransitionend, bindtransitionend } = props;
578
578
  // 默认样式
@@ -588,11 +588,11 @@ const _View = forwardRef((viewProps, ref) => {
588
588
  const { isHover, gesture } = useHover({ enableHover, hoverStartTime, hoverStayTime });
589
589
  const styleObj = extendObject({}, defaultStyle, style, isHover ? hoverStyle : {});
590
590
  if (__mpx_perf_framework__)
591
- stopProps();
591
+ perf.scopeEnd(idProps);
592
592
  // ───── style 阶段 ─────
593
- let stopStyle;
593
+ let idStyle = -1;
594
594
  if (__mpx_perf_framework__)
595
- stopStyle = perf.scope('view:render:style');
595
+ idStyle = perf.scopeStart('view:render:style');
596
596
  const { normalStyle, hasSelfPercent, hasPositionFixed, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, {
597
597
  enableVar,
598
598
  externalVarContext,
@@ -626,11 +626,11 @@ const _View = forwardRef((viewProps, ref) => {
626
626
  transitionend
627
627
  });
628
628
  if (__mpx_perf_framework__)
629
- stopStyle();
629
+ perf.scopeEnd(idStyle);
630
630
  // ───── innerProps 阶段 ─────
631
- let stopInnerProps;
631
+ let idInnerProps = -1;
632
632
  if (__mpx_perf_framework__)
633
- stopInnerProps = perf.scope('view:render:innerProps');
633
+ idInnerProps = perf.scopeStart('view:render:innerProps');
634
634
  const innerProps = useInnerProps(extendObject({}, props, layoutProps, {
635
635
  ref: nodeRef,
636
636
  style: enableStyleAnimation ? [viewStyle, animationStyle] : viewStyle
@@ -648,11 +648,11 @@ const _View = forwardRef((viewProps, ref) => {
648
648
  layoutRef
649
649
  });
650
650
  if (__mpx_perf_framework__)
651
- stopInnerProps();
651
+ perf.scopeEnd(idInnerProps);
652
652
  // ───── createElement 阶段 ─────
653
- let stopCreate;
653
+ let idCreate = -1;
654
654
  if (__mpx_perf_framework__)
655
- stopCreate = perf.scope('view:render:createElement');
655
+ idCreate = perf.scopeStart('view:render:createElement');
656
656
  const childNode = wrapWithChildren(props, {
657
657
  hasVarDec,
658
658
  enableBackground: enableBackgroundRef.current,
@@ -672,9 +672,9 @@ const _View = forwardRef((viewProps, ref) => {
672
672
  finalComponent = createElement(Portal, null, finalComponent);
673
673
  }
674
674
  if (__mpx_perf_framework__)
675
- stopCreate();
675
+ perf.scopeEnd(idCreate);
676
676
  if (__mpx_perf_framework__)
677
- stopTotal();
677
+ perf.scopeEnd(idTotal);
678
678
  return finalComponent;
679
679
  });
680
680
  _View.displayName = 'MpxView';
@@ -18,5 +18,6 @@ interface WebViewProps {
18
18
  binderror?: (event: CommonCallbackEvent) => void;
19
19
  [x: string]: any;
20
20
  }
21
- declare const _WebView: import("react").ForwardRefExoticComponent<Omit<WebViewProps, "ref"> & import("react").RefAttributes<HandlerRef<WebView<{}>, WebViewProps>>>;
21
+ type WebViewInstance = WebView<{}>;
22
+ declare const _WebView: import("react").ForwardRefExoticComponent<Omit<WebViewProps, "ref"> & import("react").RefAttributes<HandlerRef<WebViewInstance, WebViewProps>>>;
22
23
  export default _WebView;
@@ -113,6 +113,7 @@ export interface GestureHandler {
113
113
  };
114
114
  }>;
115
115
  current?: unknown;
116
+ handlerTag?: number;
116
117
  }
117
118
  export declare function flatGesture(gestures?: Array<GestureHandler>): any[];
118
119
  export declare function getCurrentPage(pageId: number | null | undefined): any;
@@ -698,7 +698,10 @@ export function flatGesture(gestures = []) {
698
698
  return gesture.nodeRefs
699
699
  .map((item) => item.getNodeInstance()?.instance?.gestureRef || {});
700
700
  }
701
- return gesture?.current ? [gesture] : [];
701
+ if (gesture && (gesture.current || gesture.handlerTag !== undefined)) {
702
+ return [gesture];
703
+ }
704
+ return [];
702
705
  })) || [];
703
706
  }
704
707
  export function getCurrentPage(pageId) {
@@ -33,6 +33,8 @@ import { createImageData as canvasCreateImageData } from './ImageData'
33
33
  import { useConstructorsRegistry } from './constructorsRegistry'
34
34
  import Portal from '../mpx-portal'
35
35
 
36
+ type WebViewInstance = WebView<{}>
37
+
36
38
  const stylesheet = StyleSheet.create({
37
39
  container: { overflow: 'hidden', flex: 0 },
38
40
  webview: {
@@ -268,7 +270,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
268
270
  canvasComponent = createElement(View, innerProps, createElement(
269
271
  WebView,
270
272
  {
271
- ref: (element) => {
273
+ ref: (element: WebViewInstance | null) => {
272
274
  if (canvasRef.current) {
273
275
  canvasRef.current.webview = element
274
276
  }
@@ -293,7 +295,7 @@ const _Canvas = forwardRef<HandlerRef<CanvasProps & View, CanvasProps>, CanvasPr
293
295
  }
294
296
 
295
297
  canvasComponent = createElement(View, innerProps, createElement(WebView, {
296
- ref: (element) => {
298
+ ref: (element: WebViewInstance | null) => {
297
299
  if (canvasRef.current) {
298
300
  canvasRef.current.webview = element
299
301
  }
@@ -2,6 +2,8 @@ import { useEffect, useRef } from 'react'
2
2
  import { WebView } from 'react-native-webview'
3
3
  import Bus from './Bus'
4
4
 
5
+ type WebViewInstance = WebView<{}>
6
+
5
7
  export const WEBVIEW_TARGET = '@@WEBVIEW_TARGET'
6
8
 
7
9
  export const constructors: Record<string, any> = {}
@@ -42,7 +44,7 @@ export interface WebviewMessage {
42
44
  }
43
45
 
44
46
  export interface CanvasInstance {
45
- webview: WebView | null;
47
+ webview: WebViewInstance | null;
46
48
  bus: Bus | null;
47
49
  context2D: CanvasRenderingContext2D;
48
50
  getContext: (contextType: string) => CanvasRenderingContext2D | null;