@mpxjs/webpack-plugin 2.10.7-beta.9 → 2.10.8-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 (46) hide show
  1. package/lib/dependencies/RequireExternalDependency.js +61 -0
  2. package/lib/file-loader.js +3 -2
  3. package/lib/index.js +60 -15
  4. package/lib/json-compiler/index.js +1 -0
  5. package/lib/parser.js +1 -1
  6. package/lib/platform/json/wx/index.js +43 -25
  7. package/lib/platform/template/wx/component-config/fix-component-name.js +2 -2
  8. package/lib/platform/template/wx/component-config/index.js +2 -0
  9. package/lib/platform/template/wx/component-config/movable-view.js +10 -1
  10. package/lib/platform/template/wx/component-config/page-container.js +19 -0
  11. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  12. package/lib/platform/template/wx/index.js +2 -1
  13. package/lib/react/LoadAsyncChunkModule.js +74 -0
  14. package/lib/react/index.js +3 -1
  15. package/lib/react/processJSON.js +74 -13
  16. package/lib/react/processScript.js +6 -6
  17. package/lib/react/script-helper.js +100 -41
  18. package/lib/runtime/components/react/context.ts +2 -12
  19. package/lib/runtime/components/react/dist/context.js +1 -1
  20. package/lib/runtime/components/react/dist/getInnerListeners.js +1 -1
  21. package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +135 -0
  22. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +9 -63
  23. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +58 -301
  24. package/lib/runtime/components/react/dist/mpx-page-container.jsx +255 -0
  25. package/lib/runtime/components/react/dist/mpx-swiper.jsx +30 -55
  26. package/lib/runtime/components/react/dist/mpx-web-view.jsx +14 -28
  27. package/lib/runtime/components/react/dist/useAnimationHooks.js +2 -87
  28. package/lib/runtime/components/react/getInnerListeners.ts +1 -1
  29. package/lib/runtime/components/react/mpx-async-suspense.tsx +180 -0
  30. package/lib/runtime/components/react/mpx-movable-area.tsx +11 -98
  31. package/lib/runtime/components/react/mpx-movable-view.tsx +60 -350
  32. package/lib/runtime/components/react/mpx-page-container.tsx +394 -0
  33. package/lib/runtime/components/react/mpx-swiper.tsx +29 -55
  34. package/lib/runtime/components/react/mpx-web-view.tsx +13 -33
  35. package/lib/runtime/components/react/types/global.d.ts +15 -0
  36. package/lib/runtime/components/react/useAnimationHooks.ts +2 -85
  37. package/lib/runtime/optionProcessorReact.d.ts +18 -0
  38. package/lib/runtime/optionProcessorReact.js +30 -0
  39. package/lib/script-setup-compiler/index.js +27 -5
  40. package/lib/template-compiler/compiler.js +27 -6
  41. package/lib/utils/dom-tag-config.js +18 -4
  42. package/lib/utils/trans-async-sub-rules.js +19 -0
  43. package/lib/web/script-helper.js +1 -1
  44. package/package.json +3 -3
  45. package/lib/runtime/components/react/AsyncContainer.tsx +0 -189
  46. package/lib/runtime/components/react/dist/AsyncContainer.jsx +0 -141
@@ -1,141 +0,0 @@
1
- import { Component, Suspense } from 'react';
2
- import { View, Text, Image, StyleSheet, TouchableOpacity } from 'react-native';
3
- import FastImage from '@d11/react-native-fast-image';
4
- const styles = StyleSheet.create({
5
- container: {
6
- flex: 1,
7
- padding: 20,
8
- backgroundColor: '#fff'
9
- },
10
- loadingImage: {
11
- width: 100,
12
- height: 100,
13
- marginTop: 220,
14
- alignSelf: 'center'
15
- },
16
- buttonText: {
17
- color: '#fff',
18
- fontSize: 16,
19
- fontWeight: '500',
20
- textAlign: 'center'
21
- },
22
- errorImage: {
23
- marginTop: 80,
24
- width: 220,
25
- aspectRatio: 1,
26
- alignSelf: 'center'
27
- },
28
- errorText: {
29
- fontSize: 16,
30
- textAlign: 'center',
31
- color: '#333',
32
- marginBottom: 20
33
- },
34
- retryButton: {
35
- position: 'absolute',
36
- bottom: 54,
37
- left: 20,
38
- right: 20,
39
- backgroundColor: '#fff',
40
- paddingVertical: 15,
41
- borderRadius: 30,
42
- marginTop: 40,
43
- borderWidth: 1,
44
- borderColor: '#FF5F00'
45
- },
46
- retryButtonText: {
47
- color: '#FF5F00',
48
- fontSize: 16,
49
- fontWeight: '500',
50
- textAlign: 'center'
51
- }
52
- });
53
- const DefaultLoading = () => {
54
- return (<View style={styles.container}>
55
- <FastImage style={styles.loadingImage} source={{ uri: 'https://dpubstatic.udache.com/static/dpubimg/439jiCVOtNOnEv9F2LaDs_loading.gif' }} resizeMode={FastImage.resizeMode.contain}></FastImage>
56
- </View>);
57
- };
58
- const DefaultFallback = ({ onReload }) => {
59
- return (<View style={styles.container}>
60
- <Image source={{ uri: 'https://dpubstatic.udache.com/static/dpubimg/Vak5mZvezPpKV5ZJI6P9b_drn-fallbak.png' }} style={styles.errorImage} resizeMode="contain"/>
61
- <Text style={styles.errorText}>网络出了点问题,请查看网络环境</Text>
62
- <TouchableOpacity style={styles.retryButton} onPress={onReload} activeOpacity={0.7}>
63
- <Text style={styles.retryButtonText}>点击重试</Text>
64
- </TouchableOpacity>
65
- </View>);
66
- };
67
- export default class AsyncContainer extends Component {
68
- suspenseFallback;
69
- errorFallback;
70
- constructor(props) {
71
- super(props);
72
- this.state = {
73
- hasError: false,
74
- key: 0
75
- };
76
- this.suspenseFallback = this.getSuspenseFallback();
77
- this.errorFallback = this.getErrorFallback();
78
- }
79
- // render 阶段收集到的错误
80
- static getDerivedStateFromError(error) {
81
- if (error.name === 'ChunkLoadError') {
82
- return {
83
- hasError: true,
84
- key: 0
85
- };
86
- }
87
- else {
88
- // 被外层捕获
89
- throw error;
90
- }
91
- }
92
- componentDidCatch(error) {
93
- if (error.name === 'ChunkLoadError' && this.props.type === 'component') {
94
- const request = error.request || '';
95
- const subpackage = request.split('/').filter((i) => !!i)[0];
96
- global.onLazyLoadError({
97
- type: 'subpackage',
98
- subpackage: [subpackage],
99
- errMsg: `loadSubpackage: ${error.type}`
100
- });
101
- }
102
- }
103
- reloadPage() {
104
- this.setState((prevState) => {
105
- return {
106
- hasError: false,
107
- key: prevState.key + 1
108
- };
109
- });
110
- }
111
- getSuspenseFallback() {
112
- if (this.props.type === 'page') {
113
- const Fallback = this.props.loading || DefaultLoading;
114
- return <Fallback />;
115
- }
116
- else {
117
- const Fallback = this.props.loading;
118
- return <Fallback {...this.props.props}></Fallback>;
119
- }
120
- }
121
- getErrorFallback() {
122
- if (this.props.type === 'page') {
123
- const Fallback = this.props.fallback || DefaultFallback;
124
- return <Fallback onReload={this.reloadPage.bind(this)}></Fallback>;
125
- }
126
- else {
127
- const Fallback = this.props.loading;
128
- return <Fallback {...this.props.props}></Fallback>;
129
- }
130
- }
131
- render() {
132
- if (this.state.hasError) {
133
- return this.errorFallback;
134
- }
135
- else {
136
- return (<Suspense fallback={this.suspenseFallback} key={this.state.key}>
137
- {this.props.children(this.props.props)}
138
- </Suspense>);
139
- }
140
- }
141
- }