@mpxjs/webpack-plugin 2.10.17-beta.4 → 2.10.17-beta.7

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 (180) hide show
  1. package/lib/global.d.ts +240 -11
  2. package/lib/index.js +7 -0
  3. package/lib/loader.js +4 -0
  4. package/lib/platform/style/wx/index.js +1 -17
  5. package/lib/platform/template/wx/component-config/button.js +1 -1
  6. package/lib/platform/template/wx/component-config/input.js +1 -1
  7. package/lib/platform/template/wx/component-config/textarea.js +1 -1
  8. package/lib/runtime/components/react/animationHooks/useTransitionHooks.ts +34 -30
  9. package/lib/runtime/components/react/animationHooks/utils.ts +3 -2
  10. package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -1
  11. package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts +0 -1
  12. package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts +0 -1
  13. package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.js +38 -33
  14. package/lib/runtime/components/react/dist/animationHooks/utils.d.ts +0 -1
  15. package/lib/runtime/components/react/dist/animationHooks/utils.js +3 -2
  16. package/lib/runtime/components/react/dist/context.d.ts +0 -1
  17. package/lib/runtime/components/react/dist/event.config.d.ts +0 -1
  18. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +0 -1
  19. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +0 -1
  20. package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -1
  21. package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -1
  22. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +0 -1
  23. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +0 -1
  24. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +0 -1
  25. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +0 -1
  26. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +0 -1
  27. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +0 -1
  28. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +0 -1
  29. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
  30. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +0 -1
  31. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
  32. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -1
  33. package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -1
  34. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
  35. package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
  36. package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
  37. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +0 -1
  38. package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -1
  39. package/lib/runtime/components/react/dist/mpx-input.jsx +1 -1
  40. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +0 -1
  41. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +4 -2
  42. package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -1
  43. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
  44. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -1
  45. package/lib/runtime/components/react/dist/mpx-nav.d.ts +0 -1
  46. package/lib/runtime/components/react/dist/mpx-navigator.d.ts +0 -1
  47. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +0 -1
  48. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +0 -1
  49. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +0 -1
  50. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +0 -1
  51. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +0 -1
  52. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +0 -1
  53. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +0 -1
  54. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +0 -1
  55. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +0 -1
  56. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +0 -1
  57. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -1
  58. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
  59. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -1
  60. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -1
  61. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +0 -1
  62. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +0 -1
  63. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +0 -1
  64. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +0 -1
  65. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +0 -1
  66. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +0 -1
  67. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +0 -1
  68. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +0 -1
  69. package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
  70. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
  71. package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -1
  72. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +0 -1
  73. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
  74. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +0 -1
  75. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -1
  76. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +0 -1
  77. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +0 -1
  78. package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
  79. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -1
  80. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -1
  81. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -1
  82. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -1
  83. package/lib/runtime/components/react/dist/mpx-swiper.jsx +49 -28
  84. package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
  85. package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
  86. package/lib/runtime/components/react/dist/mpx-textarea.d.ts +0 -1
  87. package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
  88. package/lib/runtime/components/react/dist/mpx-view.d.ts +0 -1
  89. package/lib/runtime/components/react/dist/mpx-view.jsx +20 -6
  90. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +0 -1
  91. package/lib/runtime/components/react/dist/parser.d.ts +0 -1
  92. package/lib/runtime/components/react/dist/useNodesRef.d.ts +0 -1
  93. package/lib/runtime/components/react/dist/utils.d.ts +2 -2
  94. package/lib/runtime/components/react/dist/utils.jsx +15 -21
  95. package/lib/runtime/components/react/mpx-image.tsx +2 -2
  96. package/lib/runtime/components/react/mpx-input.tsx +1 -1
  97. package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +4 -2
  98. package/lib/runtime/components/react/mpx-swiper.tsx +49 -27
  99. package/lib/runtime/components/react/mpx-view.tsx +23 -7
  100. package/lib/runtime/components/react/tsconfig.json +26 -0
  101. package/lib/runtime/components/react/utils.tsx +18 -23
  102. package/lib/style-compiler/strip-conditional-loader.js +45 -29
  103. package/package.json +5 -4
  104. package/lib/runtime/components/react/dist/animationHooks/index.d.ts.map +0 -1
  105. package/lib/runtime/components/react/dist/animationHooks/useAnimationAPIHooks.d.ts.map +0 -1
  106. package/lib/runtime/components/react/dist/animationHooks/useTransitionHooks.d.ts.map +0 -1
  107. package/lib/runtime/components/react/dist/animationHooks/utils.d.ts.map +0 -1
  108. package/lib/runtime/components/react/dist/context.d.ts.map +0 -1
  109. package/lib/runtime/components/react/dist/event.config.d.ts.map +0 -1
  110. package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +0 -1
  111. package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +0 -1
  112. package/lib/runtime/components/react/dist/mpx-button.d.ts.map +0 -1
  113. package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +0 -1
  114. package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +0 -1
  115. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +0 -1
  116. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +0 -1
  117. package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +0 -1
  118. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +0 -1
  119. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +0 -1
  120. package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +0 -1
  121. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +0 -1
  122. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +0 -1
  123. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +0 -1
  124. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +0 -1
  125. package/lib/runtime/components/react/dist/mpx-form.d.ts.map +0 -1
  126. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +0 -1
  127. package/lib/runtime/components/react/dist/mpx-image.d.ts.map +0 -1
  128. package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +0 -1
  129. package/lib/runtime/components/react/dist/mpx-input.d.ts.map +0 -1
  130. package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +0 -1
  131. package/lib/runtime/components/react/dist/mpx-label.d.ts.map +0 -1
  132. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +0 -1
  133. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +0 -1
  134. package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +0 -1
  135. package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +0 -1
  136. package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +0 -1
  137. package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +0 -1
  138. package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +0 -1
  139. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +0 -1
  140. package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +0 -1
  141. package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +0 -1
  142. package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +0 -1
  143. package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +0 -1
  144. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +0 -1
  145. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +0 -1
  146. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +0 -1
  147. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +0 -1
  148. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +0 -1
  149. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +0 -1
  150. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +0 -1
  151. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +0 -1
  152. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +0 -1
  153. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +0 -1
  154. package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +0 -1
  155. package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +0 -1
  156. package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +0 -1
  157. package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +0 -1
  158. package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +0 -1
  159. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +0 -1
  160. package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +0 -1
  161. package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +0 -1
  162. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +0 -1
  163. package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +0 -1
  164. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +0 -1
  165. package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +0 -1
  166. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +0 -1
  167. package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +0 -1
  168. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +0 -1
  169. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +0 -1
  170. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +0 -1
  171. package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +0 -1
  172. package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +0 -1
  173. package/lib/runtime/components/react/dist/mpx-text.d.ts.map +0 -1
  174. package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +0 -1
  175. package/lib/runtime/components/react/dist/mpx-video.d.ts.map +0 -1
  176. package/lib/runtime/components/react/dist/mpx-view.d.ts.map +0 -1
  177. package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +0 -1
  178. package/lib/runtime/components/react/dist/parser.d.ts.map +0 -1
  179. package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +0 -1
  180. package/lib/runtime/components/react/dist/utils.d.ts.map +0 -1
package/lib/global.d.ts CHANGED
@@ -1,16 +1,245 @@
1
+ import * as webpack from 'webpack'
2
+
3
+ declare module 'webpack' {
4
+ interface Compilation {
5
+ __mpx__: MpxContext
6
+ }
7
+
8
+ interface Compiler {
9
+ __mpx__?: boolean
10
+ }
11
+ }
1
12
 
2
13
  declare global {
3
14
  interface MpxWebpackPluginOptions {
4
- style: {
5
- cssCondition?: {
6
- before?: boolean;
7
- after?: boolean;
8
- beforeExclude?: (string | RegExp)[];
9
- afterExclude?: (string | RegExp)[];
10
- legacy?: boolean;
11
- afterLegacy?: boolean;
12
- beforeLegacy?: boolean;
13
- }
14
- }
15
+ style: {
16
+ cssCondition?: {
17
+ before?: boolean
18
+ after?: boolean
19
+ beforeExclude?: (string | RegExp)[]
20
+ afterExclude?: (string | RegExp)[]
21
+ legacy?: boolean
22
+ afterLegacy?: boolean
23
+ beforeLegacy?: boolean
24
+ }
15
25
  }
26
+ }
27
+
28
+ type MpxLoaderContext<T> = webpack.LoaderContext<T> & {
29
+ getMpx(): MpxContext
30
+ }
31
+
32
+ interface MpxContext {
33
+ /**
34
+ * 用于使用 webpack-virtual-modules 功能,目前仅在输出 web 时支持使用
35
+ */
36
+ __vfs: any | null
37
+
38
+ /**
39
+ * app 信息,便于获取 appName
40
+ */
41
+ appInfo: {
42
+ resourcePath?: string
43
+ name?: string
44
+ [key: string]: any
45
+ }
46
+
47
+ /**
48
+ * pageConfig 信息
49
+ */
50
+ pageConfigsMap: Record<string, any>
51
+
52
+ /**
53
+ * pages 全局记录,无需区分主包/分包
54
+ */
55
+ pagesMap: Record<string, string>
56
+
57
+ /**
58
+ * 组件资源记录,按所属包进行记录(如 componentsMap.main)
59
+ */
60
+ componentsMap: Record<string, Record<string, string>>
61
+
62
+ /**
63
+ * 静态资源(图片、字体、独立样式)等,按所属包进行记录
64
+ */
65
+ staticResourcesMap: Record<string, Record<string, string>>
66
+
67
+ /**
68
+ * 用于记录命中 subpackageModulesRules 的 JS 模块分包归属,用于 JS 多分包冗余输出
69
+ */
70
+ subpackageModulesMap: Record<string, Record<string, string>>
71
+
72
+ /**
73
+ * 记录其他资源,如 pluginMain、pluginExport,无需区分主包/分包
74
+ */
75
+ otherResourcesMap: Record<string, any>
76
+
77
+ /**
78
+ * 记录独立分包
79
+ */
80
+ independentSubpackagesMap: Record<string, any>
81
+
82
+ subpackagesEntriesMap: Record<string, any>
83
+ postSubpackageEntriesMap: Record<string, any>
84
+ replacePathMap: Record<string, string>
85
+
86
+ /**
87
+ * 导出模块集合
88
+ */
89
+ exportModules: Set<any>
90
+
91
+ /**
92
+ * 记录动态添加入口的分包信息
93
+ */
94
+ dynamicEntryInfo: Record<string, any>
95
+
96
+ /**
97
+ * 记录 entryModule 与 entryNode 的对应关系,用于体积分析
98
+ */
99
+ entryNodeModulesMap: Map<any, any>
100
+
101
+ /**
102
+ * 记录与 asset 相关联的 modules,用于体积分析
103
+ */
104
+ assetsModulesMap: Map<string, Set<any>>
105
+
106
+ /**
107
+ * 记录与 asset 相关联的 AST,用于体积分析和 esCheck,避免重复 parse
108
+ */
109
+ assetsASTsMap: Map<string, any>
110
+
111
+ /**
112
+ * 记录 RequireExternalDependency 相关资源路径
113
+ */
114
+ externalRequestsMap: Map<string, any>
115
+
116
+ globalComponents: Record<string, any>
117
+ globalComponentsInfo: Record<string, any>
118
+
119
+ /**
120
+ * todo: es6 Map 读写性能高于 object,之后会逐步替换
121
+ */
122
+ wxsAssetsCache: Map<string, any>
123
+ addEntryPromiseMap: Map<string, Promise<any>>
124
+ currentPackageRoot: string
125
+ wxsContentMap: Record<string, string>
126
+
127
+ /**
128
+ * 是否强制使用页面构造函数
129
+ */
130
+ forceUsePageCtor: boolean
131
+
132
+ resolveMode: string
133
+ mode: string
134
+ srcMode: string
135
+ env: string
136
+ externalClasses: string[]
137
+ projectRoot: string
138
+ autoScopeRules: any
139
+ autoVirtualHostRules: any
140
+ customTextRules: any
141
+ transRpxRules: any
142
+ postcssInlineConfig: any
143
+ decodeHTMLText: boolean
144
+
145
+ /**
146
+ * native 文件专用配置
147
+ */
148
+ i18n: any | null
149
+ checkUsingComponentsRules: any
150
+ forceDisableBuiltInLoader: boolean
151
+
152
+ /**
153
+ * 默认的应用标题
154
+ */
155
+ appTitle: string
156
+
157
+ attributes: any[]
158
+ externals: any[]
159
+ useRelativePath: boolean
160
+ removedChunks: any[]
161
+ forceProxyEventRules: any
162
+
163
+ /**
164
+ * 若配置 disableRequireAsync=true,则全平台构建不支持异步分包
165
+ */
166
+ supportRequireAsync: boolean
167
+ partialCompileRules: any
168
+ asyncSubpackageRules: any[]
169
+ transSubpackageRules: any
170
+ optimizeRenderRules: any[]
171
+
172
+ addEntryModuleIssuer: (module: string, issuer: string) => void
173
+
174
+ /**
175
+ * 资源路径的哈希函数(用于生成输出唯一名)
176
+ */
177
+ pathHash: (resourcePath: string) => string
178
+
179
+ // 缓存与工具
180
+ loaderContentCache: Map<string, any>
181
+ extractedFilesCache: Map<string, string>
182
+
183
+ // 函数接口
184
+
185
+ /**
186
+ * 收集动态入口信息(分包、文件名、是否为页面、是否包含异步等)
187
+ */
188
+ collectDynamicEntryInfo: (info: { resource: string; packageName: string; filename: string; entryType: string; hasAsync: boolean }) => void
189
+
190
+ /**
191
+ * 添加入口(包装了 webpack 的 addEntry)
192
+ */
193
+ addEntry: (request: string, name: string, callback: (err?: Error, result?: any) => void) => any
194
+
195
+ getModuleId: (filePath: string, isApp?: boolean) => string
196
+ getEntryNode: (module: any, type?: string) => any
197
+
198
+ /**
199
+ * 根据资源路径和类型返回输出路径(支持自定义输出、冲突处理等)
200
+ */
201
+ getOutputPath: (resourcePath: string, type: string, opts?: { ext?: string; conflictPath?: string }) => string
202
+
203
+ /**
204
+ * 获取提取后的文件名(支持静态、插件、普通资源)
205
+ */
206
+ getExtractedFile: (resource: string, opts?: { error?: (err: Error) => void }) => string
207
+
208
+ recordResourceMap: (params: {
209
+ resourcePath: string
210
+ resourceType: string
211
+ outputPath?: string
212
+ packageRoot?: string
213
+ recordOnly?: boolean
214
+ warn?: (e: Error) => void
215
+ error?: (e: Error) => void
216
+ }) => { outputPath?: string; alreadyOutputted?: boolean }
217
+
218
+ getPackageInfo: (params: {
219
+ resource: string
220
+ resourceType: string
221
+ outputPath?: string
222
+ issuerResource?: string
223
+ warn?: (e: Error) => void
224
+ error?: (e: Error) => void
225
+ }) => { packageName: string; packageRoot: string; outputPath?: string; alreadyOutputted?: boolean }
226
+
227
+ // 运行时信息与注入相关
228
+ runtimeInfo: Record<string, any>
229
+ dynamicSlotDependencies: Record<string, any>
230
+ dynamicTemplateRuleRunner: any
231
+
232
+ /**
233
+ * 依据 package 注入到 mpx-custom-element-*.json 里面的组件路径
234
+ */
235
+ getPackageInjectedComponentsMap: (packageName?: string) => Record<string, string>
236
+
237
+ getPackageInjectedTemplateConfig: (packageName?: string) => any
238
+ injectDynamicSlotDependencies: (usingComponents: string, resourcePath: string) => string
239
+ changeHashNameForAstNode: (templateAst: string, componentsMap: any) => string
240
+ collectDynamicSlotDependencies: (packageName?: string) => void
241
+
242
+ // 其它任意扩展字段
243
+ [key: string]: any
244
+ }
16
245
  }
package/lib/index.js CHANGED
@@ -87,6 +87,10 @@ const isProductionLikeMode = options => {
87
87
  return options.mode === 'production' || !options.mode
88
88
  }
89
89
 
90
+ /**
91
+ * @param {import('webpack').NormalModule} module
92
+ * @returns
93
+ */
90
94
  const isStaticModule = module => {
91
95
  if (!module.resource) return false
92
96
  const { queryObj } = parseRequest(module.resource)
@@ -323,6 +327,9 @@ class MpxWebpackPlugin {
323
327
  }
324
328
  }
325
329
 
330
+ /**
331
+ * @param {import('webpack').Compiler} compiler
332
+ */
326
333
  apply (compiler) {
327
334
  // 注入 fs 代理
328
335
  startFSStripForCss(this.options.defs)
package/lib/loader.js CHANGED
@@ -19,6 +19,10 @@ const processWeb = require('./web')
19
19
  const processReact = require('./react')
20
20
  const genMpxCustomElement = require('./runtime-render/gen-mpx-custom-element')
21
21
 
22
+ /**
23
+ * @this {MpxLoaderContext<any>}
24
+ * @param {string} content
25
+ */
22
26
  module.exports = function (content) {
23
27
  this.cacheable()
24
28
 
@@ -139,11 +139,10 @@ module.exports = function getSpec ({ warn, error }) {
139
139
  const type = getValueType(prop)
140
140
  const tipsType = (type) => {
141
141
  const info = {
142
- [ValueType.number]: '2rpx,10%,30rpx',
143
142
  [ValueType.color]: 'rgb,rgba,hsl,hsla,hwb,named color,#000000',
144
143
  [ValueType.enum]: `${SUPPORTED_PROP_VAL_ARR[prop]?.join(',')}`
145
144
  }
146
- tips(`Value of ${prop} in ${selector} should be ${type}, eg ${info[type]}, received [${value}], please check again!`)
145
+ tips(`Value of ${prop} in ${selector} should be ${type}${info[type] ? `, eg ${info[type]}` : ''}, received [${value}], please check again!`)
147
146
  }
148
147
  switch (type) {
149
148
  case ValueType.number: {
@@ -549,15 +548,6 @@ module.exports = function getSpec ({ warn, error }) {
549
548
  return { prop, value: values[0].trim() }
550
549
  }
551
550
 
552
- const formatZIndex = ({ prop, value, selector }, { mode }) => {
553
- // z-index auto 报错
554
- if (value === 'auto') {
555
- error(`Property [${prop}] does not supported [${value}] on ${selector} in ${mode} environment, please check again!`)
556
- return { prop, value: 0 }
557
- }
558
- return { prop, value: value }
559
- }
560
-
561
551
  // const formatBoxShadow = ({ prop, value, selector }, { mode }) => {
562
552
  // value = value.trim()
563
553
  // if (value === 'none') {
@@ -623,12 +613,6 @@ module.exports = function getSpec ({ warn, error }) {
623
613
  android: formatFontFamily,
624
614
  harmony: formatFontFamily
625
615
  },
626
- {
627
- test: 'z-index',
628
- ios: formatZIndex,
629
- android: formatZIndex,
630
- harmony: formatZIndex
631
- },
632
616
  // {
633
617
  // test: 'box-shadow',
634
618
  // ios: formatBoxShadow,
@@ -197,7 +197,7 @@ module.exports = function ({ print }) {
197
197
  qa: qaPropLog
198
198
  },
199
199
  {
200
- test: /^(lang|from-type|hover-class|send-message-title|send-message-path|send-message-img|app-parameter|show-message-card|phone-number-no-quota-toast|bindgetuserinfo|bindcontact|createliveactivity|bindgetphonenumber|bindgetrealtimephonenumber|binderror|bindopensetting|bindlaunchapp|bindchooseavatar|bindagreeprivacyauthorization)$/,
200
+ test: /^(lang|from-type|send-message-title|send-message-path|send-message-img|app-parameter|show-message-card|phone-number-no-quota-toast|bindgetuserinfo|bindcontact|createliveactivity|bindgetphonenumber|bindgetrealtimephonenumber|binderror|bindopensetting|bindlaunchapp|bindchooseavatar|bindagreeprivacyauthorization)$/,
201
201
  ios: iosPropLog,
202
202
  android: androidPropLog,
203
203
  harmony: harmonyPropLog
@@ -107,7 +107,7 @@ module.exports = function ({ print }) {
107
107
  qa: qaPropLog
108
108
  },
109
109
  {
110
- test: /^(always-embed|hold-keyboard|safe-password-.+)$/,
110
+ test: /^(always-embed|safe-password-.+)$/,
111
111
  ios: iosPropLog,
112
112
  android: androidPropLog,
113
113
  harmony: harmonyPropLog
@@ -93,7 +93,7 @@ module.exports = function ({ print }) {
93
93
  }
94
94
  },
95
95
  {
96
- test: /^(always-embed|hold-keyboard|disable-default-padding|adjust-keyboard-to|fixed|show-confirm-bar)$/,
96
+ test: /^(always-embed|disable-default-padding|adjust-keyboard-to|fixed|show-confirm-bar)$/,
97
97
  ios: iosPropLog,
98
98
  android: androidPropLog,
99
99
  harmony: harmonyPropLog
@@ -1,4 +1,4 @@
1
- import { hasOwn, dash2hump, error } from '@mpxjs/utils'
1
+ import { hasOwn, dash2hump, error, warn } from '@mpxjs/utils'
2
2
  import { useMemo, useRef, useEffect } from 'react'
3
3
  import {
4
4
  Easing,
@@ -169,10 +169,11 @@ export default function useTransitionHooks<T, P> (props: AnimationHooksPropsType
169
169
  return parseTransitionStyle(originalStyle)
170
170
  }, [])
171
171
  // ** style prop sharedValue interpolateOutput: SharedValue<InterpolateOutput>
172
- const { shareValMap, animatedKeys, animatedKeysShareVal } = useMemo(() => {
172
+ const { shareValMap, animatedKeys, animatedStyleKeys } = useMemo(() => {
173
173
  // 记录需要执行动画的 propName
174
174
  const animatedKeys = [] as string[]
175
- const animatedKeysShareVal = [] as (string|string[])[]
175
+ // 有动画样式的 style key(useAnimatedStyle使用)
176
+ const animatedStyleKeys = [] as (string|string[])[]
176
177
  const transforms = [] as string[]
177
178
  const shareValMap = Object.keys(transitionMap).reduce((valMap, property) => {
178
179
  // const { property } = transition || {}
@@ -189,20 +190,18 @@ export default function useTransitionHooks<T, P> (props: AnimationHooksPropsType
189
190
  // console.log(`shareValMap property=${property} defaultVal=${defaultVal}`)
190
191
  valMap[property] = makeMutable(defaultVal)
191
192
  animatedKeys.push(property)
192
- animatedKeysShareVal.push(property)
193
+ animatedStyleKeys.push(property)
193
194
  }
194
195
  // console.log('shareValMap = ', valMap)
195
196
  return valMap
196
197
  }, {} as { [propName: keyof ExtendedViewStyle]: SharedValue<string|number> })
197
- if (transforms.length) animatedKeysShareVal.push(transforms)
198
+ if (transforms.length) animatedStyleKeys.push(transforms)
198
199
  return {
199
200
  shareValMap,
200
201
  animatedKeys,
201
- animatedKeysShareVal
202
+ animatedStyleKeys
202
203
  }
203
204
  }, [])
204
- // 有动画样式的 style key(useAnimatedStyle使用)
205
- const animatedStyleKeys = useSharedValue(animatedKeysShareVal)
206
205
  const runOnJSCallbackRef = useRef({})
207
206
  const runOnJSCallback = useRunOnJSCallback(runOnJSCallbackRef)
208
207
  // 根据 animation action 创建&驱动动画
@@ -228,32 +227,37 @@ export default function useTransitionHooks<T, P> (props: AnimationHooksPropsType
228
227
  toVal = `${toVal * 100}%`
229
228
  } else if (typeof toVal !== typeof shareVal) {
230
229
  // 动画起始值和终态值类型不一致报错提示一下
231
- error(`[Mpx runtime error]: Value types of property ${key} must be consistent during the animation`)
230
+ warn(`[Mpx runtime error]: Value types of property ${key} must be consistent during the animation`)
232
231
  }
233
- // console.log(`key=${key} oldVal=${shareValMap[key].value} newVal=${toVal}`)
234
- const { delay = 0, duration, easing } = transitionMap[isTransformKey ? 'transform' : key]
235
- // console.log('animationOptions=', { delay, duration, easing })
236
- let callback
237
- if (transitionend && (!isTransformKey || !transformTransitionendDone)) {
238
- runOnJSCallbackRef.current = {
239
- animationCallback: (duration: number, finished: boolean, current?: AnimatableValue) => {
240
- transitionend(finished, current, duration)
232
+ if ((toVal === 'auto' && !isNaN(+shareVal)) || (shareVal === 'auto' && !isNaN(+toVal))) {
233
+ // auto 直接赋值不做动画
234
+ shareValMap[key].value = toVal
235
+ } else {
236
+ // console.log(`key=${key} oldVal=${shareValMap[key].value} newVal=${toVal}`)
237
+ const { delay = 0, duration, easing } = transitionMap[isTransformKey ? 'transform' : key]
238
+ // console.log('animationOptions=', { delay, duration, easing })
239
+ let callback
240
+ if (transitionend && (!isTransformKey || !transformTransitionendDone)) {
241
+ runOnJSCallbackRef.current = {
242
+ animationCallback: (duration: number, finished: boolean, current?: AnimatableValue) => {
243
+ transitionend(finished, current, duration)
244
+ }
241
245
  }
242
- }
243
- callback = (finished?: boolean, current?: AnimatableValue) => {
244
- 'worklet'
245
- // 动画结束后设置下一次transformOrigin
246
- if (finished) {
247
- runOnJS(runOnJSCallback)('animationCallback', duration, finished, current)
246
+ callback = (finished?: boolean, current?: AnimatableValue) => {
247
+ 'worklet'
248
+ // 动画结束后设置下一次transformOrigin
249
+ if (finished) {
250
+ runOnJS(runOnJSCallback)('animationCallback', duration, finished, current)
251
+ }
248
252
  }
249
253
  }
254
+ const animation = getAnimation({ key, value: toVal! }, { delay, duration, easing }, callback)
255
+ // Todo transform 有多个属性时也仅执行一次 transitionend(对齐wx)
256
+ if (isTransformKey) {
257
+ transformTransitionendDone = true
258
+ }
259
+ shareValMap[key].value = animation
250
260
  }
251
- const animation = getAnimation({ key, value: toVal! }, { delay, duration, easing }, callback)
252
- // Todo transform 有多个属性时也仅执行一次 transitionend(对齐wx)
253
- if (isTransformKey) {
254
- transformTransitionendDone = true
255
- }
256
- shareValMap[key].value = animation
257
261
  // console.log(`useTransitionHooks, ${key}=`, animation)
258
262
  })
259
263
  }
@@ -278,7 +282,7 @@ export default function useTransitionHooks<T, P> (props: AnimationHooksPropsType
278
282
  // ** 生成动画样式
279
283
  return useAnimatedStyle(() => {
280
284
  // console.info(`useAnimatedStyle styles=`, originalStyle)
281
- return animatedStyleKeys.value.reduce((styles, key) => {
285
+ return animatedStyleKeys.reduce((styles, key) => {
282
286
  if (Array.isArray(key)) {
283
287
  const transformStyle = getTransformObj(originalStyle.transform || [])
284
288
  key.forEach((transformKey) => {
@@ -94,8 +94,9 @@ export const transformInitial: ExtendedViewStyle = {
94
94
  export const animationAPIInitialValue: ExtendedViewStyle = Object.assign({
95
95
  opacity: 1,
96
96
  backgroundColor: 'transparent',
97
- width: 0,
98
- height: 0,
97
+ // fixme 未设置 height 初始值定义了 transition-property height 时把动画高度值把原由子元素撑开的高度给覆盖的问题
98
+ width: 'auto',
99
+ height: 'auto',
99
100
  top: 0,
100
101
  right: 0,
101
102
  bottom: 0,
@@ -13,4 +13,3 @@ export default function useAnimationHooks<T, P>(props: _ViewProps & {
13
13
  enableStyleAnimation: boolean;
14
14
  animationStyle: import("../types/common").ExtendedViewStyle;
15
15
  };
16
- //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import type { ExtendedViewStyle } from '../types/common';
2
2
  import type { AnimationHooksPropsType } from './utils';
3
3
  export default function useAnimationAPIHooks<T, P>(props: AnimationHooksPropsType): ExtendedViewStyle;
4
- //# sourceMappingURL=useAnimationAPIHooks.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import type { ExtendedViewStyle } from '../types/common';
2
2
  import type { AnimationHooksPropsType } from './utils';
3
3
  export default function useTransitionHooks<T, P>(props: AnimationHooksPropsType): ExtendedViewStyle;
4
- //# sourceMappingURL=useTransitionHooks.d.ts.map
@@ -1,6 +1,6 @@
1
- import { hasOwn, dash2hump, error } from '@mpxjs/utils';
1
+ import { hasOwn, dash2hump, error, warn } from '@mpxjs/utils';
2
2
  import { useMemo, useRef, useEffect } from 'react';
3
- import { Easing, makeMutable, runOnJS, useSharedValue, useAnimatedStyle, cancelAnimation } from 'react-native-reanimated';
3
+ import { Easing, makeMutable, runOnJS, useAnimatedStyle, cancelAnimation } from 'react-native-reanimated';
4
4
  import { easingKey, transitionSupportedProperty, transformInitial, cubicBezierExp, secondRegExp, percentExp, getTransformObj, getUnit, getInitialVal, getAnimation, isTransform } from './utils';
5
5
  import { parseValues, useRunOnJSCallback } from '../utils';
6
6
  const propName = {
@@ -141,10 +141,11 @@ export default function useTransitionHooks(props) {
141
141
  return parseTransitionStyle(originalStyle);
142
142
  }, []);
143
143
  // ** style prop sharedValue interpolateOutput: SharedValue<InterpolateOutput>
144
- const { shareValMap, animatedKeys, animatedKeysShareVal } = useMemo(() => {
144
+ const { shareValMap, animatedKeys, animatedStyleKeys } = useMemo(() => {
145
145
  // 记录需要执行动画的 propName
146
146
  const animatedKeys = [];
147
- const animatedKeysShareVal = [];
147
+ // 有动画样式的 style key(useAnimatedStyle使用)
148
+ const animatedStyleKeys = [];
148
149
  const transforms = [];
149
150
  const shareValMap = Object.keys(transitionMap).reduce((valMap, property) => {
150
151
  // const { property } = transition || {}
@@ -162,21 +163,19 @@ export default function useTransitionHooks(props) {
162
163
  // console.log(`shareValMap property=${property} defaultVal=${defaultVal}`)
163
164
  valMap[property] = makeMutable(defaultVal);
164
165
  animatedKeys.push(property);
165
- animatedKeysShareVal.push(property);
166
+ animatedStyleKeys.push(property);
166
167
  }
167
168
  // console.log('shareValMap = ', valMap)
168
169
  return valMap;
169
170
  }, {});
170
171
  if (transforms.length)
171
- animatedKeysShareVal.push(transforms);
172
+ animatedStyleKeys.push(transforms);
172
173
  return {
173
174
  shareValMap,
174
175
  animatedKeys,
175
- animatedKeysShareVal
176
+ animatedStyleKeys
176
177
  };
177
178
  }, []);
178
- // 有动画样式的 style key(useAnimatedStyle使用)
179
- const animatedStyleKeys = useSharedValue(animatedKeysShareVal);
180
179
  const runOnJSCallbackRef = useRef({});
181
180
  const runOnJSCallback = useRunOnJSCallback(runOnJSCallbackRef);
182
181
  // 根据 animation action 创建&驱动动画
@@ -204,32 +203,38 @@ export default function useTransitionHooks(props) {
204
203
  }
205
204
  else if (typeof toVal !== typeof shareVal) {
206
205
  // 动画起始值和终态值类型不一致报错提示一下
207
- error(`[Mpx runtime error]: Value types of property ${key} must be consistent during the animation`);
206
+ warn(`[Mpx runtime error]: Value types of property ${key} must be consistent during the animation`);
208
207
  }
209
- // console.log(`key=${key} oldVal=${shareValMap[key].value} newVal=${toVal}`)
210
- const { delay = 0, duration, easing } = transitionMap[isTransformKey ? 'transform' : key];
211
- // console.log('animationOptions=', { delay, duration, easing })
212
- let callback;
213
- if (transitionend && (!isTransformKey || !transformTransitionendDone)) {
214
- runOnJSCallbackRef.current = {
215
- animationCallback: (duration, finished, current) => {
216
- transitionend(finished, current, duration);
217
- }
218
- };
219
- callback = (finished, current) => {
220
- 'worklet';
221
- // 动画结束后设置下一次transformOrigin
222
- if (finished) {
223
- runOnJS(runOnJSCallback)('animationCallback', duration, finished, current);
224
- }
225
- };
208
+ if ((toVal === 'auto' && !isNaN(+shareVal)) || (shareVal === 'auto' && !isNaN(+toVal))) {
209
+ // auto 直接赋值不做动画
210
+ shareValMap[key].value = toVal;
226
211
  }
227
- const animation = getAnimation({ key, value: toVal }, { delay, duration, easing }, callback);
228
- // Todo transform 有多个属性时也仅执行一次 transitionend(对齐wx)
229
- if (isTransformKey) {
230
- transformTransitionendDone = true;
212
+ else {
213
+ // console.log(`key=${key} oldVal=${shareValMap[key].value} newVal=${toVal}`)
214
+ const { delay = 0, duration, easing } = transitionMap[isTransformKey ? 'transform' : key];
215
+ // console.log('animationOptions=', { delay, duration, easing })
216
+ let callback;
217
+ if (transitionend && (!isTransformKey || !transformTransitionendDone)) {
218
+ runOnJSCallbackRef.current = {
219
+ animationCallback: (duration, finished, current) => {
220
+ transitionend(finished, current, duration);
221
+ }
222
+ };
223
+ callback = (finished, current) => {
224
+ 'worklet';
225
+ // 动画结束后设置下一次transformOrigin
226
+ if (finished) {
227
+ runOnJS(runOnJSCallback)('animationCallback', duration, finished, current);
228
+ }
229
+ };
230
+ }
231
+ const animation = getAnimation({ key, value: toVal }, { delay, duration, easing }, callback);
232
+ // Todo transform 有多个属性时也仅执行一次 transitionend(对齐wx)
233
+ if (isTransformKey) {
234
+ transformTransitionendDone = true;
235
+ }
236
+ shareValMap[key].value = animation;
231
237
  }
232
- shareValMap[key].value = animation;
233
238
  // console.log(`useTransitionHooks, ${key}=`, animation)
234
239
  });
235
240
  }
@@ -254,7 +259,7 @@ export default function useTransitionHooks(props) {
254
259
  // ** 生成动画样式
255
260
  return useAnimatedStyle(() => {
256
261
  // console.info(`useAnimatedStyle styles=`, originalStyle)
257
- return animatedStyleKeys.value.reduce((styles, key) => {
262
+ return animatedStyleKeys.reduce((styles, key) => {
258
263
  if (Array.isArray(key)) {
259
264
  const transformStyle = getTransformObj(originalStyle.transform || []);
260
265
  key.forEach((transformKey) => {
@@ -107,4 +107,3 @@ export declare function getAnimation({ key, value }: {
107
107
  key: string;
108
108
  value: string | number;
109
109
  }, { delay, duration, easing }: ExtendWithTimingConfig, callback?: AnimationCallback): string | number;
110
- //# sourceMappingURL=utils.d.ts.map
@@ -47,8 +47,9 @@ export const transformInitial = {
47
47
  export const animationAPIInitialValue = Object.assign({
48
48
  opacity: 1,
49
49
  backgroundColor: 'transparent',
50
- width: 0,
51
- height: 0,
50
+ // fixme 未设置 height 初始值定义了 transition-property height 时把动画高度值把原由子元素撑开的高度给覆盖的问题
51
+ width: 'auto',
52
+ height: 'auto',
52
53
  top: 0,
53
54
  right: 0,
54
55
  bottom: 0,
@@ -77,4 +77,3 @@ export declare const ScrollViewContext: import("react").Context<ScrollViewContex
77
77
  export declare const PortalContext: import("react").Context<PortalContextValue>;
78
78
  export declare const StickyContext: import("react").Context<StickyContextValue>;
79
79
  export declare const ProviderContext: import("react").Context<null>;
80
- //# sourceMappingURL=context.d.ts.map
@@ -5,4 +5,3 @@ declare const eventConfigMap: {
5
5
  };
6
6
  };
7
7
  export default eventConfigMap;
8
- //# sourceMappingURL=event.config.d.ts.map
@@ -5,4 +5,3 @@ export declare const getCustomEvent: (type: string | undefined, oe: any, { detai
5
5
  }, props?: Props) => any;
6
6
  declare const useInnerProps: (props?: Props, userRemoveProps?: RemoveProps, rawConfig?: RawConfig) => Record<string, (e: ExtendedNativeTouchEvent) => void> & Omit<Props, string>;
7
7
  export default useInnerProps;
8
- //# sourceMappingURL=getInnerListeners.d.ts.map