@spcsn/taro-cli 0.1.6 → 1.0.0

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 (188) hide show
  1. package/README.md +10 -7
  2. package/define-config.d.ts +1 -0
  3. package/define-config.js +1 -0
  4. package/dist/cli.js +140 -110
  5. package/dist/cli.js.map +1 -1
  6. package/dist/commands/{customCommand.d.ts → custom-command.d.ts} +1 -1
  7. package/dist/commands/custom-command.js +23 -0
  8. package/dist/commands/custom-command.js.map +1 -0
  9. package/dist/create/creator.js +2 -0
  10. package/dist/create/creator.js.map +1 -1
  11. package/dist/create/{fetchTemplate.js → fetch-template.js} +26 -33
  12. package/dist/create/fetch-template.js.map +1 -0
  13. package/dist/create/project.d.ts +2 -6
  14. package/dist/create/project.js +240 -285
  15. package/dist/create/project.js.map +1 -1
  16. package/dist/create/template-creator.d.ts +75 -0
  17. package/dist/create/template-creator.js +275 -0
  18. package/dist/create/template-creator.js.map +1 -0
  19. package/dist/doctor/validators.d.ts +7 -6
  20. package/dist/doctor/validators.js +6 -7
  21. package/dist/doctor/validators.js.map +1 -1
  22. package/dist/platform-weapp/apis-list.d.ts +1 -0
  23. package/dist/platform-weapp/apis-list.js +37 -0
  24. package/dist/platform-weapp/apis-list.js.map +1 -0
  25. package/dist/platform-weapp/apis.d.ts +16 -0
  26. package/dist/platform-weapp/apis.js +34 -0
  27. package/dist/platform-weapp/apis.js.map +1 -0
  28. package/dist/platform-weapp/components-react.d.ts +80 -0
  29. package/dist/platform-weapp/components-react.js +86 -0
  30. package/dist/platform-weapp/components-react.js.map +1 -0
  31. package/dist/platform-weapp/components.d.ts +4 -0
  32. package/dist/platform-weapp/components.js +520 -0
  33. package/dist/platform-weapp/components.js.map +1 -0
  34. package/dist/platform-weapp/index.d.ts +11 -0
  35. package/dist/platform-weapp/index.js +17 -0
  36. package/dist/platform-weapp/index.js.map +1 -0
  37. package/dist/platform-weapp/program.d.ts +35 -0
  38. package/dist/platform-weapp/program.js +64 -0
  39. package/dist/platform-weapp/program.js.map +1 -0
  40. package/dist/platform-weapp/runtime-utils.d.ts +27 -0
  41. package/dist/platform-weapp/runtime-utils.js +48 -0
  42. package/dist/platform-weapp/runtime-utils.js.map +1 -0
  43. package/dist/platform-weapp/runtime.d.ts +1 -0
  44. package/dist/platform-weapp/runtime.js +7 -0
  45. package/dist/platform-weapp/runtime.js.map +1 -0
  46. package/dist/platform-weapp/template.d.ts +39 -0
  47. package/dist/platform-weapp/template.js +119 -0
  48. package/dist/platform-weapp/template.js.map +1 -0
  49. package/dist/presets/commands/build.js +25 -45
  50. package/dist/presets/commands/build.js.map +1 -1
  51. package/dist/presets/commands/init.js +2 -4
  52. package/dist/presets/commands/init.js.map +1 -1
  53. package/dist/presets/constant/hooks.d.ts +0 -2
  54. package/dist/presets/constant/hooks.js +1 -3
  55. package/dist/presets/constant/hooks.js.map +1 -1
  56. package/dist/presets/files/generate-framework-info.js +68 -0
  57. package/dist/presets/files/generate-framework-info.js.map +1 -0
  58. package/dist/presets/files/{generateProjectConfig.js → generate-project-config.js} +1 -1
  59. package/dist/presets/files/generate-project-config.js.map +1 -0
  60. package/dist/presets/files/{writeFileToDist.js → write-file-to-dist.js} +1 -1
  61. package/dist/presets/files/write-file-to-dist.js.map +1 -0
  62. package/dist/presets/hooks/build.js +1 -3
  63. package/dist/presets/hooks/build.js.map +1 -1
  64. package/dist/presets/index.js +3 -5
  65. package/dist/presets/index.js.map +1 -1
  66. package/dist/util/{appConfig.d.ts → app-config.d.ts} +2 -2
  67. package/dist/util/{appConfig.js → app-config.js} +4 -3
  68. package/dist/util/app-config.js.map +1 -0
  69. package/dist/util/defineConfig.d.ts +5 -5
  70. package/dist/util/defineConfig.js.map +1 -1
  71. package/dist/util/index.d.ts +9 -1
  72. package/dist/util/index.js +54 -23
  73. package/dist/util/index.js.map +1 -1
  74. package/package.json +36 -39
  75. package/postinstall.js +1 -17
  76. package/src/cli.ts +185 -132
  77. package/src/commands/custom-command.ts +22 -0
  78. package/src/create/{fetchTemplate.ts → fetch-template.ts} +30 -35
  79. package/src/create/project.ts +31 -78
  80. package/src/create/template-creator.ts +325 -0
  81. package/src/doctor/validators.js +1 -0
  82. package/src/doctor/validators.ts +8 -6
  83. package/src/platform-weapp/apis-list.ts +33 -0
  84. package/src/platform-weapp/apis.ts +48 -0
  85. package/src/platform-weapp/components-react.ts +81 -0
  86. package/src/platform-weapp/components.ts +521 -0
  87. package/src/platform-weapp/index.ts +25 -0
  88. package/src/platform-weapp/program.ts +70 -0
  89. package/src/platform-weapp/runtime-utils.ts +57 -0
  90. package/src/platform-weapp/runtime.ts +6 -0
  91. package/src/platform-weapp/template.ts +150 -0
  92. package/src/presets/commands/build.ts +20 -40
  93. package/src/presets/commands/init.ts +1 -4
  94. package/src/presets/constant/hooks.js +12 -0
  95. package/src/presets/constant/hooks.ts +0 -2
  96. package/src/presets/files/{generateFrameworkInfo.ts → generate-framework-info.ts} +7 -1
  97. package/src/presets/hooks/build.ts +1 -3
  98. package/src/presets/index.ts +3 -5
  99. package/src/util/app-config.js +1 -0
  100. package/src/util/{appConfig.ts → app-config.ts} +5 -4
  101. package/src/util/defineConfig.ts +6 -6
  102. package/src/util/index.ts +67 -25
  103. package/templates/default/config/dev.js +1 -1
  104. package/templates/default/config/index.js +28 -40
  105. package/templates/default/config/prod.js +1 -1
  106. package/templates/default/package.json.tmpl +2 -17
  107. package/templates/default/types/global.d.ts +0 -4
  108. package/templates/plugin-compile/README.md +3 -1
  109. package/templates/plugin-compile/package.json.tmpl +1 -2
  110. package/templates/plugin-compile/src/index.ts +18 -28
  111. package/LICENSE +0 -174
  112. package/dist/commands/customCommand.js +0 -23
  113. package/dist/commands/customCommand.js.map +0 -1
  114. package/dist/config/packagesManagement.d.ts +0 -19
  115. package/dist/config/packagesManagement.js +0 -22
  116. package/dist/config/packagesManagement.js.map +0 -1
  117. package/dist/create/fetchTemplate.js.map +0 -1
  118. package/dist/create/page.d.ts +0 -65
  119. package/dist/create/page.js +0 -266
  120. package/dist/create/page.js.map +0 -1
  121. package/dist/create/plugin.d.ts +0 -16
  122. package/dist/create/plugin.js +0 -77
  123. package/dist/create/plugin.js.map +0 -1
  124. package/dist/presets/commands/config.js +0 -121
  125. package/dist/presets/commands/config.js.map +0 -1
  126. package/dist/presets/commands/create.js +0 -112
  127. package/dist/presets/commands/create.js.map +0 -1
  128. package/dist/presets/commands/doctor.js +0 -15
  129. package/dist/presets/commands/doctor.js.map +0 -1
  130. package/dist/presets/commands/global-config.d.ts +0 -3
  131. package/dist/presets/commands/global-config.js +0 -175
  132. package/dist/presets/commands/global-config.js.map +0 -1
  133. package/dist/presets/commands/help.d.ts +0 -3
  134. package/dist/presets/commands/help.js +0 -16
  135. package/dist/presets/commands/help.js.map +0 -1
  136. package/dist/presets/commands/info.d.ts +0 -3
  137. package/dist/presets/commands/info.js +0 -96
  138. package/dist/presets/commands/info.js.map +0 -1
  139. package/dist/presets/commands/inspect.d.ts +0 -3
  140. package/dist/presets/commands/inspect.js +0 -155
  141. package/dist/presets/commands/inspect.js.map +0 -1
  142. package/dist/presets/commands/update.d.ts +0 -3
  143. package/dist/presets/commands/update.js +0 -187
  144. package/dist/presets/commands/update.js.map +0 -1
  145. package/dist/presets/files/generateFrameworkInfo.d.ts +0 -3
  146. package/dist/presets/files/generateFrameworkInfo.js +0 -30
  147. package/dist/presets/files/generateFrameworkInfo.js.map +0 -1
  148. package/dist/presets/files/generateProjectConfig.d.ts +0 -3
  149. package/dist/presets/files/generateProjectConfig.js.map +0 -1
  150. package/dist/presets/files/writeFileToDist.d.ts +0 -3
  151. package/dist/presets/files/writeFileToDist.js.map +0 -1
  152. package/dist/presets/hooks/create.d.ts +0 -3
  153. package/dist/presets/hooks/create.js +0 -42
  154. package/dist/presets/hooks/create.js.map +0 -1
  155. package/dist/presets/platforms/plugin.d.ts +0 -3
  156. package/dist/presets/platforms/plugin.js +0 -106
  157. package/dist/presets/platforms/plugin.js.map +0 -1
  158. package/dist/presets/platforms/rn.d.ts +0 -3
  159. package/dist/presets/platforms/rn.js +0 -130
  160. package/dist/presets/platforms/rn.js.map +0 -1
  161. package/dist/util/appConfig.js.map +0 -1
  162. package/dist/util/createPage.d.ts +0 -9
  163. package/dist/util/createPage.js +0 -114
  164. package/dist/util/createPage.js.map +0 -1
  165. package/src/commands/customCommand.ts +0 -22
  166. package/src/config/packagesManagement.ts +0 -20
  167. package/src/config/rn-stylelint.json +0 -4
  168. package/src/create/page.ts +0 -325
  169. package/src/create/plugin.ts +0 -55
  170. package/src/presets/commands/config.ts +0 -86
  171. package/src/presets/commands/create.ts +0 -104
  172. package/src/presets/commands/doctor.ts +0 -21
  173. package/src/presets/commands/global-config.ts +0 -140
  174. package/src/presets/commands/help.ts +0 -17
  175. package/src/presets/commands/info.ts +0 -81
  176. package/src/presets/commands/inspect.ts +0 -137
  177. package/src/presets/commands/update.ts +0 -175
  178. package/src/presets/hooks/create.ts +0 -9
  179. package/src/presets/platforms/plugin.ts +0 -75
  180. package/src/presets/platforms/rn.ts +0 -125
  181. package/src/util/createPage.ts +0 -139
  182. package/templates/default/babel.config.js +0 -14
  183. /package/dist/create/{fetchTemplate.d.ts → fetch-template.d.ts} +0 -0
  184. /package/dist/presets/{commands/config.d.ts → files/generate-framework-info.d.ts} +0 -0
  185. /package/dist/presets/{commands/create.d.ts → files/generate-project-config.d.ts} +0 -0
  186. /package/dist/presets/{commands/doctor.d.ts → files/write-file-to-dist.d.ts} +0 -0
  187. /package/src/presets/files/{generateProjectConfig.ts → generate-project-config.ts} +0 -0
  188. /package/src/presets/files/{writeFileToDist.ts → write-file-to-dist.ts} +0 -0
@@ -0,0 +1,521 @@
1
+ type ComponentAttributeMap = Record<string, string>;
2
+
3
+ type ComponentMap = Record<string, ComponentAttributeMap>;
4
+
5
+ const _true = 'true';
6
+ const _false = 'false';
7
+ const _empty = '';
8
+ const _zero = '0';
9
+ const _object = '{}';
10
+
11
+ export const components: ComponentMap = {
12
+ // ======== 调整属性 ========
13
+ Progress: {
14
+ 'border-radius': _zero,
15
+ 'font-size': '16',
16
+ duration: '30',
17
+ bindActiveEnd: _empty,
18
+ },
19
+ RichText: {
20
+ space: _empty,
21
+ 'user-select': _false,
22
+ mode: "'default'",
23
+ },
24
+ Text: {
25
+ 'user-select': _false,
26
+ overflow: 'visible',
27
+ 'max-lines': '',
28
+ },
29
+ Map: {
30
+ polygons: '[]',
31
+ subkey: _empty,
32
+ rotate: _zero,
33
+ skew: _zero,
34
+ 'max-scale': '20',
35
+ 'min-scale': '3',
36
+ 'enable-3D': _false,
37
+ 'show-compass': _false,
38
+ 'show-scale': _false,
39
+ 'enable-overlooking': _false,
40
+ 'enable-auto-max-overlooking': _false,
41
+ 'enable-zoom': _true,
42
+ 'enable-scroll': _true,
43
+ 'enable-rotate': _false,
44
+ 'enable-satellite': _false,
45
+ 'enable-traffic': _false,
46
+ 'enable-poi': _true,
47
+ 'enable-building': _true,
48
+ setting: _object,
49
+ bindLabelTap: _empty,
50
+ bindRegionChange: _empty,
51
+ bindPoiTap: _empty,
52
+ bindPolylineTap: _empty,
53
+ bindAbilitySuccess: _empty,
54
+ bindAbilityFailed: _empty,
55
+ bindAuthSuccess: _empty,
56
+ bindInterpolatePoint: _empty,
57
+ bindError: _empty,
58
+ bindAnchorPointTap: _empty,
59
+ },
60
+ Button: {
61
+ lang: 'en',
62
+ 'session-from': _empty,
63
+ 'send-message-title': _empty,
64
+ 'send-message-path': _empty,
65
+ 'send-message-img': _empty,
66
+ 'app-parameter': _empty,
67
+ 'show-message-card': _false,
68
+ 'business-id': _empty,
69
+ bindGetUserInfo: _empty,
70
+ bindContact: _empty,
71
+ bindGetPhoneNumber: _empty,
72
+ bindGetRealTimePhoneNumber: _empty,
73
+ bindChooseAvatar: _empty,
74
+ bindError: _empty,
75
+ bindOpenSetting: _empty,
76
+ bindLaunchApp: _empty,
77
+ bindAgreePrivacyAuthorization: _empty,
78
+ },
79
+ Form: {
80
+ 'report-submit-timeout': _zero,
81
+ },
82
+ Input: {
83
+ 'always-embed': _false,
84
+ 'adjust-position': _true,
85
+ 'hold-keyboard': _false,
86
+ 'safe-password-cert-path': '',
87
+ 'safe-password-length': '',
88
+ 'safe-password-time-stamp': '',
89
+ 'safe-password-nonce': '',
90
+ 'safe-password-salt': '',
91
+ 'safe-password-custom-hash': '',
92
+ 'auto-fill': _empty,
93
+ 'cursor-color': '',
94
+ bindKeyboardHeightChange: _empty,
95
+ bindNicknameReview: _empty,
96
+ bindSelectionChange: _empty,
97
+ bindKeyboardCompositionStart: _empty,
98
+ bindKeyboardCompositionUpdate: _empty,
99
+ bindKeyboardCompositionEnd: _empty,
100
+ },
101
+ Picker: {
102
+ 'header-text': _empty,
103
+ level: 'region',
104
+ },
105
+ PickerView: {
106
+ 'immediate-change': _false,
107
+ bindPickStart: _empty,
108
+ bindPickEnd: _empty,
109
+ },
110
+ Slider: {
111
+ color: "'#e9e9e9'",
112
+ 'selected-color': "'#1aad19'",
113
+ },
114
+ Textarea: {
115
+ 'show-confirm-bar': _true,
116
+ 'adjust-position': _true,
117
+ 'hold-keyboard': _false,
118
+ 'disable-default-padding': _false,
119
+ 'confirm-type': "'return'",
120
+ 'confirm-hold': _false,
121
+ 'adjust-keyboard-to': "'cursor'",
122
+ bindKeyboardHeightChange: _empty,
123
+ bindSelectionChange: _empty,
124
+ bindKeyboardCompositionStart: _empty,
125
+ bindKeyboardCompositionUpdate: _empty,
126
+ bindKeyboardCompositionEnd: _empty,
127
+ },
128
+ ScrollView: {
129
+ 'enable-flex': _false,
130
+ 'scroll-anchoring': _false,
131
+ enhanced: _false,
132
+ 'using-sticky': _false,
133
+ 'paging-enabled': _false,
134
+ 'enable-passive': _false,
135
+ 'refresher-enabled': _false,
136
+ 'refresher-threshold': '45',
137
+ 'refresher-default-style': "'black'",
138
+ 'refresher-background': "'#FFF'",
139
+ 'refresher-triggered': _false,
140
+ bounces: _true,
141
+ 'show-scrollbar': _true,
142
+ 'fast-deceleration': _false,
143
+ type: "'list'",
144
+ 'associative-container': "''",
145
+ reverse: _false,
146
+ clip: _true,
147
+ 'enable-back-to-top': _false,
148
+ 'cache-extent': _empty,
149
+ 'min-drag-distance': '18',
150
+ 'scroll-into-view-within-extent': _false,
151
+ 'scroll-into-view-alignment': "'start'",
152
+ padding: '[0,0,0,0]',
153
+ 'refresher-two-level-enabled': _false,
154
+ 'refresher-two-level-triggered': _false,
155
+ 'refresher-two-level-threshold': '150',
156
+ 'refresher-two-level-close-threshold': '80',
157
+ 'refresher-two-level-scroll-enabled': _false,
158
+ 'refresher-ballistic-refresh-enabled': _false,
159
+ 'refresher-two-level-pinned': _false,
160
+ bindDragStart: _empty,
161
+ bindDragging: _empty,
162
+ bindDragEnd: _empty,
163
+ bindRefresherPulling: _empty,
164
+ bindRefresherRefresh: _empty,
165
+ bindRefresherRestore: _empty,
166
+ bindRefresherAbort: _empty,
167
+ bindScrollStart: _empty,
168
+ bindScrollEnd: _empty,
169
+ bindRefresherWillRefresh: _empty,
170
+ bindRefresherStatusChange: _empty,
171
+ },
172
+ StickySection: {
173
+ 'push-pinned-header': _true,
174
+ padding: '[0, 0, 0, 0]',
175
+ },
176
+ GridView: {
177
+ type: "'aligned'",
178
+ 'cross-axis-count': '2',
179
+ 'max-cross-axis-extent': _zero,
180
+ 'main-axis-gap': _zero,
181
+ 'cross-axis-gap': _zero,
182
+ padding: '[0, 0, 0, 0]',
183
+ },
184
+ GridBuilder: {
185
+ type: "'aligned'",
186
+ list: '[]',
187
+ 'cross-axis-count': '2',
188
+ 'max-cross-axis-extent': _zero,
189
+ 'main-axis-gap': _zero,
190
+ 'cross-axis-gap': _zero,
191
+ padding: '[0, 0, 0, 0]',
192
+ bindItemBuild: _empty,
193
+ bindItemDispose: _empty,
194
+ },
195
+ ListView: {
196
+ padding: '[0, 0, 0, 0]',
197
+ },
198
+ ListBuilder: {
199
+ list: '[]',
200
+ type: 'static',
201
+ padding: '[0, 0, 0, 0]',
202
+ 'child-count': _empty,
203
+ 'child-height': _empty,
204
+ bindItemBuild: _empty,
205
+ bindItemDispose: _empty,
206
+ },
207
+ StickyHeader: {
208
+ 'offset-top': '0',
209
+ padding: '[0, 0, 0, 0]',
210
+ },
211
+ Swiper: {
212
+ 'snap-to-edge': _false,
213
+ 'easing-function': "'default'",
214
+ 'layout-type': "'normal'",
215
+ 'transformer-type': "'scaleAndFade'",
216
+ 'indicator-type': "'normal'",
217
+ 'indicator-margin': '10',
218
+ 'indicator-spacing': '4',
219
+ 'indicator-radius': '4',
220
+ 'indicator-width': '8',
221
+ 'indicator-height': '8',
222
+ 'indicator-alignment': "'auto'",
223
+ 'indicator-offset': '[0, 0]',
224
+ 'scroll-with-animation': _true,
225
+ 'cache-extent': '0',
226
+ },
227
+ SwiperItem: {
228
+ 'skip-hidden-item-layout': _false,
229
+ },
230
+ Navigator: {
231
+ target: "'self'",
232
+ 'app-id': _empty,
233
+ path: _empty,
234
+ 'extra-data': _empty,
235
+ version: "'version'",
236
+ },
237
+ Camera: {
238
+ mode: "'normal'",
239
+ resolution: "'medium'",
240
+ 'frame-size': "'medium'",
241
+ bindInitDone: _empty,
242
+ bindScanCode: _empty,
243
+ },
244
+ Image: {
245
+ webp: _false,
246
+ 'show-menu-by-longpress': _false,
247
+ 'fade-in': _false,
248
+ },
249
+ LivePlayer: {
250
+ mode: "'live'",
251
+ 'sound-mode': "'speaker'",
252
+ 'auto-pause-if-navigate': _true,
253
+ 'auto-pause-if-open-native': _true,
254
+ 'picture-in-picture-mode': '[]',
255
+ 'enable-auto-rotation': _false,
256
+ 'referrer-policy': "'no-referrer'",
257
+ 'enable-casting': _false,
258
+ bindstatechange: _empty,
259
+ bindfullscreenchange: _empty,
260
+ bindnetstatus: _empty,
261
+ bindAudioVolumeNotify: _empty,
262
+ bindEnterPictureInPicture: _empty,
263
+ bindLeavePictureInPicture: _empty,
264
+ bindCastingUserSelect: _empty,
265
+ bindCastingStateChange: _empty,
266
+ bindCastingInterrupt: _empty,
267
+ },
268
+ Video: {
269
+ title: _empty,
270
+ 'play-btn-position': "'bottom'",
271
+ 'enable-play-gesture': _false,
272
+ 'auto-pause-if-navigate': _true,
273
+ 'auto-pause-if-open-native': _true,
274
+ 'vslide-gesture': _false,
275
+ 'vslide-gesture-in-fullscreen': _true,
276
+ 'show-bottom-progress': _true,
277
+ 'ad-unit-id': _empty,
278
+ 'poster-for-crawler': _empty,
279
+ 'show-casting-button': _false,
280
+ 'picture-in-picture-mode': '[]',
281
+ // picture-in-picture-show-progress 属性先注释掉的原因如下:
282
+ // 该属性超过了 wxml 属性的长度限制,实际无法使用且导致编译报错。可等微信官方修复后再放开。
283
+ // 参考1:https://developers.weixin.qq.com/community/develop/doc/000a429beb87f0eac07acc0fc5b400
284
+ // 参考2: https://developers.weixin.qq.com/community/develop/doc/0006883619c48054286a4308258c00?_at=vyxqpllafi
285
+ // 'picture-in-picture-show-progress': 'false',
286
+ 'enable-auto-rotation': _false,
287
+ 'show-screen-lock-button': _false,
288
+ 'show-snapshot-button': _false,
289
+ 'show-background-playback-button': _false,
290
+ 'background-poster': _empty,
291
+ 'referrer-policy': "'no-referrer'",
292
+ 'is-drm': _false,
293
+ 'is-live': _false,
294
+ 'provision-url': _empty,
295
+ 'certificate-url': _empty,
296
+ 'license-url': _empty,
297
+ 'preferred-peak-bit-rate': _empty,
298
+ bindProgress: _empty,
299
+ bindLoadedMetadata: _empty,
300
+ bindControlsToggle: _empty,
301
+ bindEnterPictureInPicture: _empty,
302
+ bindLeavePictureInPicture: _empty,
303
+ bindSeekComplete: _empty,
304
+ bindCastingUserSelect: _empty,
305
+ bindCastingStateChange: _empty,
306
+ bindCastingInterrupt: _empty,
307
+ bindAdLoad: _empty,
308
+ bindAdError: _empty,
309
+ bindAdClose: _empty,
310
+ bindAdPlay: _empty,
311
+ },
312
+ Canvas: {
313
+ type: _empty,
314
+ },
315
+ Ad: {
316
+ 'ad-type': "'banner'",
317
+ 'ad-theme': "'white'",
318
+ },
319
+ CoverView: {
320
+ 'marker-id': _empty,
321
+ slot: _empty,
322
+ },
323
+ // ======== 额外组件 ========
324
+ Editor: {
325
+ 'read-only': _false,
326
+ placeholder: _empty,
327
+ 'show-img-size': _false,
328
+ 'show-img-toolbar': _false,
329
+ 'show-img-resize': _false,
330
+ focus: _false,
331
+ bindReady: _empty,
332
+ bindFocus: _empty,
333
+ bindBlur: _empty,
334
+ bindInput: _empty,
335
+ bindStatusChange: _empty,
336
+ name: _empty,
337
+ },
338
+ MatchMedia: {
339
+ 'min-width': _empty,
340
+ 'max-width': _empty,
341
+ width: _empty,
342
+ 'min-height': _empty,
343
+ 'max-height': _empty,
344
+ height: _empty,
345
+ orientation: _empty,
346
+ },
347
+ FunctionalPageNavigator: {
348
+ version: "'release'",
349
+ name: _empty,
350
+ args: _empty,
351
+ bindSuccess: _empty,
352
+ bindFail: _empty,
353
+ bindCancel: _empty,
354
+ },
355
+ LivePusher: {
356
+ url: _empty,
357
+ mode: "'RTC'",
358
+ autopush: _false,
359
+ muted: _false,
360
+ 'enable-camera': _true,
361
+ 'auto-focus': _true,
362
+ orientation: "'vertical'",
363
+ beauty: _zero,
364
+ whiteness: _zero,
365
+ aspect: "'9:16'",
366
+ 'min-bitrate': '200',
367
+ 'max-bitrate': '1000',
368
+ 'audio-quality': "'high'",
369
+ 'waiting-image': _empty,
370
+ 'waiting-image-hash': _empty,
371
+ zoom: _false,
372
+ 'device-position': "'front'",
373
+ 'background-mute': _false,
374
+ mirror: _false,
375
+ 'remote-mirror': _false,
376
+ 'local-mirror': _false,
377
+ 'audio-reverb-type': _zero,
378
+ 'enable-mic': _true,
379
+ 'enable-agc': _false,
380
+ 'enable-ans': _false,
381
+ 'audio-volume-type': "'voicecall'",
382
+ 'video-width': '360',
383
+ 'video-height': '640',
384
+ 'beauty-style': "'smooth'",
385
+ filter: "'standard'",
386
+ 'picture-in-picture-mode': '[]',
387
+ animation: _empty,
388
+ bindStateChange: _empty,
389
+ bindNetStatus: _empty,
390
+ bindBgmStart: _empty,
391
+ bindBgmProgress: _empty,
392
+ bindBgmComplete: _empty,
393
+ bindAudioVolumeNotify: _empty,
394
+ },
395
+ OfficialAccount: {
396
+ bindLoad: _empty,
397
+ bindError: _empty,
398
+ },
399
+ OpenData: {
400
+ type: _empty,
401
+ 'open-gid': _empty,
402
+ lang: "'en'",
403
+ 'default-text': _empty,
404
+ 'default-avatar': _empty,
405
+ bindError: _empty,
406
+ },
407
+ NavigationBar: {
408
+ title: _empty,
409
+ loading: _false,
410
+ 'front-color': "'#000000'",
411
+ 'background-color': _empty,
412
+ 'color-animation-duration': _zero,
413
+ 'color-animation-timing-func': "'linear'",
414
+ },
415
+ PageMeta: {
416
+ 'background-text-style': _empty,
417
+ 'background-color': _empty,
418
+ 'background-color-top': _empty,
419
+ 'background-color-bottom': _empty,
420
+ 'root-background-color': _empty,
421
+ 'scroll-top': "''",
422
+ 'scroll-duration': '300',
423
+ 'page-style': "''",
424
+ 'root-font-size': "''",
425
+ 'page-orientation': "''",
426
+ bindResize: _empty,
427
+ bindScroll: _empty,
428
+ bindScrollDone: _empty,
429
+ },
430
+ VoipRoom: {
431
+ openid: _empty,
432
+ mode: "'camera'",
433
+ 'device-position': "'front'",
434
+ bindError: _empty,
435
+ },
436
+ AdCustom: {
437
+ 'unit-id': _empty,
438
+ 'ad-intervals': _empty,
439
+ bindLoad: _empty,
440
+ bindError: _empty,
441
+ },
442
+ PageContainer: {
443
+ show: _false,
444
+ duration: '300',
445
+ 'z-index': '100',
446
+ overlay: _true,
447
+ position: "'bottom'",
448
+ round: _false,
449
+ 'close-on-slide-down': _false,
450
+ 'overlay-style': _empty,
451
+ 'custom-style': _empty,
452
+ bindBeforeEnter: _empty,
453
+ bindEnter: _empty,
454
+ bindAfterEnter: _empty,
455
+ bindBeforeLeave: _empty,
456
+ bindLeave: _empty,
457
+ bindAfterLeave: _empty,
458
+ bindClickOverlay: _empty,
459
+ },
460
+ ShareElement: {
461
+ mapkey: _empty,
462
+ transform: _false,
463
+ duration: '300',
464
+ 'easing-function': "'ease-out'",
465
+ 'transition-on-gesture': _false,
466
+ 'shuttle-on-push': "'to'",
467
+ 'shuttle-on-pop': "'to'",
468
+ 'rect-tween-type': "'materialRectArc'",
469
+ },
470
+ KeyboardAccessory: {},
471
+ RootPortal: {
472
+ enable: _true,
473
+ },
474
+ ChannelLive: {
475
+ 'feed-id': _empty,
476
+ 'finder-user-name': _empty,
477
+ },
478
+ ChannelVideo: {
479
+ 'feed-id': _empty,
480
+ 'finder-user-name': _empty,
481
+ 'feed-token': _empty,
482
+ autoplay: _false,
483
+ loop: _false,
484
+ muted: _false,
485
+ 'object-fit': "'contain'",
486
+ bindError: _empty,
487
+ },
488
+ Snapshot: {
489
+ mode: "'view'",
490
+ },
491
+ Span: {},
492
+ OpenContainer: {
493
+ transitionType: "'fade'",
494
+ transitionDuration: '300',
495
+ closedColor: "'white'",
496
+ closedElevation: _zero,
497
+ closeBorderRadius: _zero,
498
+ middleColor: _empty,
499
+ openColor: "'white'",
500
+ openElevation: _zero,
501
+ openBorderRadius: _zero,
502
+ },
503
+ DraggableSheet: {
504
+ initialChildSize: '0.5',
505
+ minChildSize: '0.25',
506
+ maxChildSize: '1.0',
507
+ snap: _false,
508
+ snapSizes: '[]',
509
+ },
510
+ NestedScrollHeader: {},
511
+ NestedScrollBody: {},
512
+ // skyline手势组件
513
+ DoubleTapGestureHandler: {},
514
+ ForcePressGestureHandler: {},
515
+ HorizontalDragGestureHandler: {},
516
+ LongPressGestureHandler: {},
517
+ PanGestureHandler: {},
518
+ ScaleGestureHandler: {},
519
+ TapGestureHandler: {},
520
+ VerticalDragGestureHandler: {},
521
+ };
@@ -0,0 +1,25 @@
1
+ const WeappPlatform = require('./program').default;
2
+
3
+ interface PlatformPluginContext {
4
+ registerPlatform(platform: {
5
+ name: string;
6
+ useConfigName: string;
7
+ fn(params: { config: unknown }): Promise<void>;
8
+ }): void;
9
+ }
10
+
11
+ const platformWeappPlugin = (ctx: PlatformPluginContext, options: Record<string, unknown> = {}) => {
12
+ ctx.registerPlatform({
13
+ name: 'weapp',
14
+ useConfigName: 'mini',
15
+ async fn({ config }) {
16
+ const program = new WeappPlatform(ctx, config, options || {});
17
+ await program.start();
18
+ },
19
+ });
20
+ };
21
+
22
+ // 让其它平台插件可以继承此平台
23
+ module.exports = platformWeappPlugin;
24
+ module.exports.default = platformWeappPlugin;
25
+ module.exports.Weapp = WeappPlatform;
@@ -0,0 +1,70 @@
1
+ const path = require('node:path');
2
+ const { TaroPlatformBase } = require('@spcsn/taro-service');
3
+ const { components } = require('./components');
4
+ const { Template } = require('./template');
5
+
6
+ interface WeappPluginOptions {
7
+ enablekeyboardAccessory?: boolean;
8
+ }
9
+
10
+ class Weapp extends TaroPlatformBase {
11
+ template: InstanceType<typeof Template>;
12
+ platform = 'weapp';
13
+ globalObject = 'wx';
14
+ projectConfigJson: string = this.config.projectConfigName || 'project.config.json';
15
+ runtimePath: string;
16
+ taroComponentsPath: string;
17
+ fileType = {
18
+ templ: '.wxml',
19
+ style: '.wxss',
20
+ config: '.json',
21
+ script: '.js',
22
+ xs: '.wxs',
23
+ };
24
+
25
+ /**
26
+ * 1. setupTransaction - init
27
+ * 2. setup
28
+ * 3. setupTransaction - close
29
+ * 4. buildTransaction - init
30
+ * 5. build
31
+ * 6. buildTransaction - close
32
+ */
33
+ constructor(ctx, config, pluginOptions?: WeappPluginOptions) {
34
+ super(ctx, config);
35
+ const platformDirectory = path.dirname(ctx.path);
36
+ this.runtimePath = path.join(platformDirectory, 'runtime');
37
+ this.taroComponentsPath = path.join(platformDirectory, 'components-react');
38
+ this.template = new Template(pluginOptions);
39
+ // Skyline / glass-easel 默认配置(用户可在 project config 中覆盖)
40
+ this.config = {
41
+ renderer: 'skyline',
42
+ componentFramework: 'glass-easel',
43
+ lazyCodeLoading: 'requiredComponents',
44
+ style: 'v2',
45
+ ...this.config,
46
+ };
47
+ this.setupTransaction.addWrapper({
48
+ close: () => {
49
+ this.modifyTemplate(pluginOptions);
50
+ },
51
+ });
52
+ }
53
+
54
+ /**
55
+ * 增加组件或修改组件属性
56
+ */
57
+ modifyTemplate(pluginOptions?: WeappPluginOptions) {
58
+ const template = this.template;
59
+ template.mergeComponents(this.ctx, components);
60
+ template.voidElements.add('voip-room');
61
+ template.voidElements.add('native-slot');
62
+ template.focusComponents.add('editor');
63
+ if (pluginOptions?.enablekeyboardAccessory) {
64
+ template.voidElements.delete('input');
65
+ template.voidElements.delete('textarea');
66
+ }
67
+ }
68
+ }
69
+
70
+ module.exports.default = Weapp;
@@ -0,0 +1,57 @@
1
+ import { Shortcuts, toCamelCase } from '@spcsn/taro-shared';
2
+
3
+ import { initNativeApi } from './apis';
4
+
5
+ interface MiniPageInstance {
6
+ setData(data: Record<string, unknown>): void;
7
+ }
8
+
9
+ interface MiniLifecycleConfig {
10
+ page: string[][];
11
+ }
12
+
13
+ interface TransferHydrateData {
14
+ nn: string;
15
+ [key: string]: unknown;
16
+ }
17
+
18
+ interface TransferElement {
19
+ isTransferElement?: boolean;
20
+ dataName: string;
21
+ sid: string;
22
+ }
23
+
24
+ declare const getCurrentPages: () => MiniPageInstance[];
25
+
26
+ export { initNativeApi };
27
+ export * from './apis-list';
28
+ export * from './components';
29
+ export const hostConfig = {
30
+ initNativeApi,
31
+ getMiniLifecycle(config: MiniLifecycleConfig) {
32
+ const methods = config.page[5];
33
+ if (methods.indexOf('onSaveExitState') === -1) {
34
+ methods.push('onSaveExitState');
35
+ }
36
+ return config;
37
+ },
38
+ transferHydrateData(
39
+ data: TransferHydrateData,
40
+ element: TransferElement,
41
+ componentsAlias: Record<string, { _num?: string } | undefined>,
42
+ ) {
43
+ if (element.isTransferElement) {
44
+ const pages = getCurrentPages();
45
+ const page = pages[pages.length - 1];
46
+ data[Shortcuts.NodeName] = element.dataName;
47
+ page.setData({
48
+ [toCamelCase(data.nn)]: data,
49
+ });
50
+ return {
51
+ sid: element.sid,
52
+ [Shortcuts.Text]: '',
53
+ [Shortcuts.NodeName]: componentsAlias['#text']?._num || '8',
54
+ };
55
+ }
56
+ },
57
+ };
@@ -0,0 +1,6 @@
1
+ import { mergeInternalComponents, mergeReconciler } from '@spcsn/taro-shared';
2
+
3
+ import { components, hostConfig } from './runtime-utils';
4
+
5
+ mergeReconciler(hostConfig);
6
+ mergeInternalComponents(components);