@tarojs/plugin-platform-alipay 3.5.0-beta.4 → 3.5.0-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.
package/dist/index.js CHANGED
@@ -7,62 +7,190 @@ var service = require('@tarojs/service');
7
7
  var template = require('@tarojs/shared/dist/template');
8
8
 
9
9
  /*! *****************************************************************************
10
- Copyright (c) Microsoft Corporation. All rights reserved.
11
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
12
- this file except in compliance with the License. You may obtain a copy of the
13
- License at http://www.apache.org/licenses/LICENSE-2.0
10
+ Copyright (c) Microsoft Corporation.
14
11
 
15
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
17
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
18
- MERCHANTABLITY OR NON-INFRINGEMENT.
12
+ Permission to use, copy, modify, and/or distribute this software for any
13
+ purpose with or without fee is hereby granted.
19
14
 
20
- See the Apache Version 2.0 License for specific language governing permissions
21
- and limitations under the License.
15
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
16
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
+ PERFORMANCE OF THIS SOFTWARE.
22
22
  ***************************************************************************** */
23
23
 
24
24
  function __awaiter(thisArg, _arguments, P, generator) {
25
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
25
26
  return new (P || (P = Promise))(function (resolve, reject) {
26
27
  function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
27
28
  function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
28
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
29
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
29
30
  step((generator = generator.apply(thisArg, _arguments || [])).next());
30
31
  });
31
32
  }
32
33
 
33
- class Template extends template.RecursiveTemplate {
34
- constructor() {
35
- super(...arguments);
36
- this.exportExpr = 'export default';
37
- this.supportXS = true;
38
- this.Adapter = {
39
- if: 'a:if',
40
- else: 'a:else',
41
- elseif: 'a:elif',
42
- for: 'a:for',
43
- forItem: 'a:for-item',
44
- forIndex: 'a:for-index',
45
- key: 'a:key',
46
- xs: 'sjs',
47
- type: 'alipay'
48
- };
49
- this.modifyLoopBody = (child, nodeName) => {
50
- if (nodeName === 'picker-view') {
34
+ const components = {
35
+ // ======== 调整属性 ========
36
+ View: {
37
+ 'disable-scroll': 'false',
38
+ hidden: 'false',
39
+ bindAppear: '',
40
+ bindDisappear: '',
41
+ bindFirstAppear: ''
42
+ },
43
+ Text: {
44
+ 'number-of-lines': ''
45
+ },
46
+ Map: {
47
+ skew: '0',
48
+ rotate: '0',
49
+ polygons: '[]',
50
+ 'include-padding': '',
51
+ 'ground-overlays': '',
52
+ 'tile-overlay': '',
53
+ 'custom-map-style': '',
54
+ setting: '{}',
55
+ optimize: '',
56
+ bindRegionChange: '',
57
+ bindPanelTap: ''
58
+ },
59
+ Button: {
60
+ scope: '',
61
+ 'public-id': '',
62
+ bindGetAuthorize: '',
63
+ bindError: ''
64
+ },
65
+ Checkbox: {
66
+ bindChange: ''
67
+ },
68
+ Input: {
69
+ 'random-number': 'false',
70
+ controlled: 'false',
71
+ enableNative: 'false'
72
+ },
73
+ Slider: {
74
+ 'track-size': '4',
75
+ 'handle-size': '22',
76
+ 'handle-color': shared.singleQuote('#ffffff')
77
+ },
78
+ Switch: {
79
+ controlled: 'false'
80
+ },
81
+ Textarea: {
82
+ 'show-count': 'true',
83
+ controlled: 'false',
84
+ enableNative: 'false'
85
+ },
86
+ MovableView: {
87
+ bindChangeEnd: ''
88
+ },
89
+ ScrollView: {
90
+ 'scroll-animation-duration': '',
91
+ 'trap-scroll': 'false'
92
+ },
93
+ Swiper: {
94
+ 'active-class': '',
95
+ 'changing-class': '',
96
+ acceleration: 'false',
97
+ 'disable-programmatic-animation': 'false',
98
+ 'disable-touch': 'false',
99
+ bindAnimationEnd: ''
100
+ },
101
+ Image: {
102
+ 'default-source': ''
103
+ },
104
+ Canvas: {
105
+ type: '',
106
+ width: shared.singleQuote('300px'),
107
+ height: shared.singleQuote('225px'),
108
+ bindReady: ''
109
+ },
110
+ Video: {
111
+ 'poster-size': shared.singleQuote('contain'),
112
+ 'mobilenet-hint-type': '1',
113
+ enableNative: 'false',
114
+ bindLoading: '',
115
+ bindUserAction: '',
116
+ bindStop: '',
117
+ bindRenderStart: ''
118
+ },
119
+ // ======== 额外组件 ========
120
+ Lottie: {
121
+ autoplay: 'false',
122
+ path: '',
123
+ speed: '1.0',
124
+ repeatCount: '0',
125
+ autoReverse: 'false',
126
+ assetsPath: '',
127
+ placeholder: '',
128
+ djangoId: '',
129
+ md5: '',
130
+ optimize: 'false',
131
+ bindDataReady: '',
132
+ bindDataFailed: '',
133
+ bindAnimationStart: '',
134
+ bindAnimationEnd: '',
135
+ bindAnimationRepeat: '',
136
+ bindAnimationCancel: '',
137
+ bindDataLoadReady: ''
138
+ },
139
+ Lifestyle: {
140
+ 'public-id': '',
141
+ memo: '',
142
+ bindFollow: ''
143
+ },
144
+ LifeFollow: {
145
+ sceneId: '',
146
+ checkFollow: '',
147
+ bindCheckFollow: '',
148
+ bindClose: ''
149
+ },
150
+ ContactButton: {
151
+ 'tnt-inst-id': '',
152
+ scene: '',
153
+ size: '25',
154
+ color: shared.singleQuote('#00A3FF'),
155
+ icon: '',
156
+ 'alipay-card-no': '',
157
+ 'ext-info': ''
158
+ }
159
+ };
160
+
161
+ class Template extends template.RecursiveTemplate {
162
+ constructor() {
163
+ super(...arguments);
164
+ this.exportExpr = 'export default';
165
+ this.supportXS = true;
166
+ this.Adapter = {
167
+ if: 'a:if',
168
+ else: 'a:else',
169
+ elseif: 'a:elif',
170
+ for: 'a:for',
171
+ forItem: 'a:for-item',
172
+ forIndex: 'a:for-index',
173
+ key: 'a:key',
174
+ xs: 'sjs',
175
+ type: 'alipay'
176
+ };
177
+ this.modifyLoopBody = (child, nodeName) => {
178
+ if (nodeName === 'picker-view') {
51
179
  return `<picker-view-column class="{{item.cl}}" style="{{item.st}}">
52
180
  <view a:for="{{item.cn}}" a:key="sid">
53
181
  ${child}
54
182
  </view>
55
- </picker-view-column>`;
56
- }
57
- return child;
58
- };
59
- this.modifyLoopContainer = (children, nodeName) => {
60
- if (nodeName === 'picker') {
183
+ </picker-view-column>`;
184
+ }
185
+ return child;
186
+ };
187
+ this.modifyLoopContainer = (children, nodeName) => {
188
+ if (nodeName === 'picker') {
61
189
  return `
62
190
  <view>${children}</view>
63
- `;
64
- }
65
- if (nodeName === 'swiper') {
191
+ `;
192
+ }
193
+ if (nodeName === 'swiper') {
66
194
  return `
67
195
  <block a:for="{{xs.f(i.cn)}}" a:key="sid">
68
196
  <swiper-item class="{{item.cl}}" style="{{item.st}}" id="{{item.uid||item.sid}}" data-sid="{{item.sid}}">
@@ -71,395 +199,270 @@ class Template extends template.RecursiveTemplate {
71
199
  </block>
72
200
  </swiper-item>
73
201
  </block>
74
- `;
75
- }
76
- return children;
77
- };
78
- this.modifyTemplateResult = (res, nodeName) => {
79
- if (nodeName === 'picker-view-column' || nodeName === 'swiper-item')
80
- return '';
81
- return res;
82
- };
83
- this.modifyThirdPartyLoopBody = () => {
84
- // 兼容支付宝 2.0 构建
85
- const slot = this.componentsAlias.slot;
86
- const slotAlias = slot._num;
87
- const slotNamePropAlias = slot.name;
202
+ `;
203
+ }
204
+ return children;
205
+ };
206
+ this.modifyTemplateResult = (res, nodeName) => {
207
+ if (nodeName === 'picker-view-column' || nodeName === 'swiper-item')
208
+ return '';
209
+ return res;
210
+ };
211
+ this.modifyThirdPartyLoopBody = () => {
212
+ // 兼容支付宝 2.0 构建
213
+ const slot = this.componentsAlias.slot;
214
+ const slotAlias = slot._num;
215
+ const slotNamePropAlias = slot.name;
88
216
  return `<view a:if="{{item.nn==='${slotAlias}'}}" slot="{{item.${slotNamePropAlias}}}" id="{{item.uid||item.sid}}" data-sid="{{item.sid}}">
89
217
  <block a:for="{{item.cn}}" a:key="sid">
90
218
  <template is="{{xs.e(0)}}" data="{{i:item}}" />
91
219
  </block>
92
220
  </view>
93
- <template a:else is="{{xs.e(0)}}" data="{{i:item}}" />`;
94
- };
95
- }
96
- buildXsTemplate() {
97
- return '<import-sjs name="xs" from="./utils.sjs" />';
98
- }
99
- replacePropName(name, value, compName, componentAlias) {
100
- if (value === 'eh')
101
- return name.replace('bind', 'on');
102
- if (compName === 'map') {
103
- const polygonsAlias = componentAlias.polygons;
104
- if (value.includes(polygonsAlias)) {
105
- name = 'polygon';
106
- }
107
- }
108
- return name;
109
- }
110
- getEvents() {
111
- return {
112
- onTap: 'eh',
113
- onTouchMove: 'eh',
114
- onTouchEnd: 'eh',
115
- onTouchCancel: 'eh',
116
- onLongTap: 'eh'
117
- };
118
- }
119
- buildThirdPartyAttr(attrs) {
120
- return [...attrs].reduce((str, attr) => {
121
- if (attr.startsWith('@')) {
122
- return str + `on${shared.capitalize(attr.slice(1))}="eh" `;
123
- }
124
- else if (attr.startsWith('bind')) {
125
- return str + `${attr}="eh" `;
126
- }
127
- else if (attr.startsWith('on')) {
128
- return str + `${attr}="eh" `;
129
- }
130
- return str + `${attr}="{{ i.${shared.toCamelCase(attr)} }}" `;
131
- }, '');
132
- }
133
- createMiniComponents(components) {
134
- const result = super.createMiniComponents(components);
135
- // 兼容支付宝 2.0 构建
136
- delete result.slot;
137
- delete result['slot-view'];
138
- return result;
139
- }
140
- buildXSTmpExtra() {
141
- const swiperItemAlias = this.componentsAlias['swiper-item']._num;
221
+ <template a:else is="{{xs.e(0)}}" data="{{i:item}}" />`;
222
+ };
223
+ }
224
+ buildXsTemplate() {
225
+ return '<import-sjs name="xs" from="./utils.sjs" />';
226
+ }
227
+ replacePropName(name, value, compName, componentAlias) {
228
+ if (value === 'eh')
229
+ return name.replace('bind', 'on');
230
+ if (compName === 'map') {
231
+ const polygonsAlias = componentAlias.polygons;
232
+ if (value.includes(polygonsAlias)) {
233
+ name = 'polygon';
234
+ }
235
+ }
236
+ return name;
237
+ }
238
+ getEvents() {
239
+ return {
240
+ onTap: 'eh',
241
+ onTouchMove: 'eh',
242
+ onTouchEnd: 'eh',
243
+ onTouchCancel: 'eh',
244
+ onLongTap: 'eh'
245
+ };
246
+ }
247
+ buildThirdPartyAttr(attrs) {
248
+ return [...attrs].reduce((str, attr) => {
249
+ if (attr.startsWith('@')) {
250
+ return str + `on${shared.capitalize(attr.slice(1))}="eh" `;
251
+ }
252
+ else if (attr.startsWith('bind')) {
253
+ return str + `${attr}="eh" `;
254
+ }
255
+ else if (attr.startsWith('on')) {
256
+ return str + `${attr}="eh" `;
257
+ }
258
+ return str + `${attr}="{{ i.${shared.toCamelCase(attr)} }}" `;
259
+ }, '');
260
+ }
261
+ createMiniComponents(components) {
262
+ const result = super.createMiniComponents(components);
263
+ // 兼容支付宝 2.0 构建
264
+ delete result.slot;
265
+ delete result['slot-view'];
266
+ return result;
267
+ }
268
+ buildXSTmpExtra() {
269
+ const swiperItemAlias = this.componentsAlias['swiper-item']._num;
142
270
  return `f: function (l) {
143
271
  return l.filter(function (i) {return i.nn === '${swiperItemAlias}'})
144
- }`;
145
- }
272
+ }`;
273
+ }
146
274
  }
147
275
 
148
- const components = {
149
- // ======== 调整属性 ========
150
- View: {
151
- 'disable-scroll': 'false',
152
- hidden: 'false',
153
- bindAppear: '',
154
- bindDisappear: '',
155
- bindFirstAppear: ''
156
- },
157
- Text: {
158
- 'number-of-lines': ''
159
- },
160
- Map: {
161
- skew: '0',
162
- rotate: '0',
163
- polygons: '[]',
164
- 'include-padding': '',
165
- 'ground-overlays': '',
166
- 'tile-overlay': '',
167
- 'custom-map-style': '',
168
- setting: '{}',
169
- optimize: '',
170
- bindRegionChange: '',
171
- bindPanelTap: ''
172
- },
173
- Button: {
174
- scope: '',
175
- 'public-id': '',
176
- bindGetAuthorize: '',
177
- bindError: ''
178
- },
179
- Checkbox: {
180
- bindChange: ''
181
- },
182
- Input: {
183
- 'random-number': 'false',
184
- controlled: 'false',
185
- enableNative: 'false'
186
- },
187
- Slider: {
188
- 'track-size': '4',
189
- 'handle-size': '22',
190
- 'handle-color': shared.singleQuote('#ffffff')
191
- },
192
- Switch: {
193
- controlled: 'false'
194
- },
195
- Textarea: {
196
- 'show-count': 'true',
197
- controlled: 'false',
198
- enableNative: 'false'
199
- },
200
- MovableView: {
201
- bindChangeEnd: ''
202
- },
203
- ScrollView: {
204
- 'scroll-animation-duration': '',
205
- 'trap-scroll': 'false'
206
- },
207
- Swiper: {
208
- 'active-class': '',
209
- 'changing-class': '',
210
- acceleration: 'false',
211
- 'disable-programmatic-animation': 'false',
212
- 'disable-touch': 'false',
213
- bindAnimationEnd: ''
214
- },
215
- Image: {
216
- 'default-source': ''
217
- },
218
- Canvas: {
219
- type: '',
220
- width: shared.singleQuote('300px'),
221
- height: shared.singleQuote('225px'),
222
- bindReady: ''
223
- },
224
- Video: {
225
- 'poster-size': shared.singleQuote('contain'),
226
- 'mobilenet-hint-type': '1',
227
- enableNative: 'false',
228
- bindLoading: '',
229
- bindUserAction: '',
230
- bindStop: '',
231
- bindRenderStart: ''
232
- },
233
- // ======== 额外组件 ========
234
- Lottie: {
235
- autoplay: 'false',
236
- path: '',
237
- speed: '1.0',
238
- repeatCount: '0',
239
- autoReverse: 'false',
240
- assetsPath: '',
241
- placeholder: '',
242
- djangoId: '',
243
- md5: '',
244
- optimize: 'false',
245
- bindDataReady: '',
246
- bindDataFailed: '',
247
- bindAnimationStart: '',
248
- bindAnimationEnd: '',
249
- bindAnimationRepeat: '',
250
- bindAnimationCancel: '',
251
- bindDataLoadReady: ''
252
- },
253
- Lifestyle: {
254
- 'public-id': '',
255
- memo: '',
256
- bindFollow: ''
257
- },
258
- LifeFollow: {
259
- sceneId: '',
260
- checkFollow: '',
261
- bindCheckFollow: '',
262
- bindClose: ''
263
- },
264
- ContactButton: {
265
- 'tnt-inst-id': '',
266
- scene: '',
267
- size: '25',
268
- color: shared.singleQuote('#00A3FF'),
269
- icon: '',
270
- 'alipay-card-no': '',
271
- 'ext-info': ''
272
- }
273
- };
274
-
275
- const PACKAGE_NAME = '@tarojs/plugin-platform-alipay';
276
- class Alipay extends service.TaroPlatformBase {
277
- /**
278
- * 1. setupTransaction - init
279
- * 2. setup
280
- * 3. setupTransaction - close
281
- * 4. buildTransaction - init
282
- * 5. build
283
- * 6. buildTransaction - close
284
- */
285
- constructor(ctx, config) {
286
- super(ctx, config);
287
- this.platform = 'alipay';
288
- this.globalObject = 'my';
289
- this.runtimePath = `${PACKAGE_NAME}/dist/runtime`;
290
- this.taroComponentsPath = `${PACKAGE_NAME}/dist/components-react`;
291
- this.fileType = {
292
- templ: '.axml',
293
- style: '.acss',
294
- config: '.json',
295
- script: '.js',
296
- xs: '.sjs'
297
- };
298
- this.template = new Template();
299
- this.setupTransaction.addWrapper({
300
- close() {
301
- this.modifyMiniConfigs();
302
- this.modifyComponents();
303
- this.modifyWebpackConfig();
304
- this.generateProjectConfig('project.alipay.json', 'mini.project.json');
305
- }
306
- });
307
- }
308
- /**
309
- * 转换用户编写的配置(微信小程序标准)为支付宝小程序标准
310
- */
311
- modifyMiniConfigs() {
312
- this.ctx.modifyMiniConfigs(({ configMap }) => {
313
- const replaceKeyMap = {
314
- navigationBarTitleText: 'defaultTitle',
315
- navigationBarBackgroundColor: 'titleBarColor',
316
- enablePullDownRefresh: 'pullRefresh',
317
- list: 'items',
318
- text: 'name',
319
- iconPath: 'icon',
320
- selectedIconPath: 'activeIcon',
321
- color: 'textColor'
322
- };
323
- Object.keys(configMap).forEach(key => {
324
- const item = configMap[key];
325
- if (item.content) {
326
- this.recursiveReplaceObjectKeys(item.content, replaceKeyMap);
327
- }
328
- });
329
- });
330
- }
331
- /**
332
- * 增加组件或修改组件属性
333
- */
334
- modifyComponents() {
335
- const { internalComponents } = this.template;
336
- this.template.mergeComponents(this.ctx, components);
337
- this.modifySlider(internalComponents.Slider);
338
- this.modifySwiper(internalComponents.Swiper);
339
- }
340
- /**
341
- * 修改 Slider 组件属性
342
- */
343
- modifySlider(slider) {
344
- delete slider['block-size'];
345
- delete slider['block-color'];
346
- }
347
- /**
348
- * 修改 Swiper 组件属性
349
- */
350
- modifySwiper(swiper) {
351
- delete swiper.bindAnimationFinish;
352
- }
353
- /**
354
- * 修改 Webpack 配置
355
- */
356
- modifyWebpackConfig() {
357
- this.ctx.modifyWebpackChain(({ chain }) => {
358
- // 支付宝系小程序全局就有 navigator 对象,不需要模拟
359
- chain.plugin('providerPlugin')
360
- .tap(args => {
361
- const newArgs = Object.assign({}, args[0]);
362
- delete newArgs.navigator;
363
- return [newArgs];
364
- });
365
- });
366
- }
276
+ const PACKAGE_NAME = '@tarojs/plugin-platform-alipay';
277
+ class Alipay extends service.TaroPlatformBase {
278
+ /**
279
+ * 1. setupTransaction - init
280
+ * 2. setup
281
+ * 3. setupTransaction - close
282
+ * 4. buildTransaction - init
283
+ * 5. build
284
+ * 6. buildTransaction - close
285
+ */
286
+ constructor(ctx, config) {
287
+ super(ctx, config);
288
+ this.platform = 'alipay';
289
+ this.globalObject = 'my';
290
+ this.runtimePath = `${PACKAGE_NAME}/dist/runtime`;
291
+ this.taroComponentsPath = `${PACKAGE_NAME}/dist/components-react`;
292
+ this.fileType = {
293
+ templ: '.axml',
294
+ style: '.acss',
295
+ config: '.json',
296
+ script: '.js',
297
+ xs: '.sjs'
298
+ };
299
+ this.template = new Template();
300
+ this.setupTransaction.addWrapper({
301
+ close() {
302
+ this.modifyMiniConfigs();
303
+ this.modifyComponents();
304
+ this.modifyWebpackConfig();
305
+ this.generateProjectConfig('project.alipay.json', 'mini.project.json');
306
+ }
307
+ });
308
+ }
309
+ /**
310
+ * 转换用户编写的配置(微信小程序标准)为支付宝小程序标准
311
+ */
312
+ modifyMiniConfigs() {
313
+ this.ctx.modifyMiniConfigs(({ configMap }) => {
314
+ const replaceKeyMap = {
315
+ navigationBarTitleText: 'defaultTitle',
316
+ navigationBarBackgroundColor: 'titleBarColor',
317
+ enablePullDownRefresh: 'pullRefresh',
318
+ list: 'items',
319
+ text: 'name',
320
+ iconPath: 'icon',
321
+ selectedIconPath: 'activeIcon',
322
+ color: 'textColor'
323
+ };
324
+ Object.keys(configMap).forEach(key => {
325
+ const item = configMap[key];
326
+ if (item.content) {
327
+ this.recursiveReplaceObjectKeys(item.content, replaceKeyMap);
328
+ }
329
+ });
330
+ });
331
+ }
332
+ /**
333
+ * 增加组件或修改组件属性
334
+ */
335
+ modifyComponents() {
336
+ const { internalComponents } = this.template;
337
+ this.template.mergeComponents(this.ctx, components);
338
+ this.modifySlider(internalComponents.Slider);
339
+ this.modifySwiper(internalComponents.Swiper);
340
+ }
341
+ /**
342
+ * 修改 Slider 组件属性
343
+ */
344
+ modifySlider(slider) {
345
+ delete slider['block-size'];
346
+ delete slider['block-color'];
347
+ }
348
+ /**
349
+ * 修改 Swiper 组件属性
350
+ */
351
+ modifySwiper(swiper) {
352
+ delete swiper.bindAnimationFinish;
353
+ }
354
+ /**
355
+ * 修改 Webpack 配置
356
+ */
357
+ modifyWebpackConfig() {
358
+ this.ctx.modifyWebpackChain(({ chain }) => {
359
+ // 支付宝系小程序全局就有 navigator 对象,不需要模拟
360
+ chain.plugin('providerPlugin')
361
+ .tap(args => {
362
+ const newArgs = Object.assign({}, args[0]);
363
+ delete newArgs.navigator;
364
+ return [newArgs];
365
+ });
366
+ });
367
+ }
367
368
  }
368
369
 
369
- let registeredModifyPageTemplate = false;
370
- var index = (ctx) => {
371
- ctx.registerPlatform({
372
- name: 'alipay',
373
- useConfigName: 'mini',
374
- fn({ config }) {
375
- return __awaiter(this, void 0, void 0, function* () {
376
- !registeredModifyPageTemplate && modifyPageTemplate(ctx);
377
- const program = new Alipay(ctx, config);
378
- yield program.start();
379
- });
380
- }
381
- });
382
- ctx.modifyRunnerOpts(({ opts }) => {
383
- if (!(opts === null || opts === void 0 ? void 0 : opts.compiler))
384
- return;
385
- if (shared.isString(opts.compiler)) {
386
- opts.compiler = {
387
- type: opts.compiler
388
- };
389
- }
390
- const { compiler } = opts;
391
- if (compiler.type === 'webpack5') {
392
- compiler.prebundle || (compiler.prebundle = {});
393
- const prebundleOptions = compiler.prebundle;
394
- if (prebundleOptions.enable === false)
395
- return;
396
- prebundleOptions.swc || (prebundleOptions.swc = {
397
- jsc: {
398
- target: 'es5'
399
- }
400
- });
401
- }
402
- });
403
- };
404
- function getIsBuildPluginPath(filePath, isBuildPlugin) {
405
- return isBuildPlugin ? `plugin/${filePath}` : filePath;
406
- }
407
- // 支付宝小程序中,如果某个页面依赖了原生小程序组件,
408
- // 那么这个页面不能使用公共模板 base.axml,
409
- // 而需要把公共模板的内容在此页面的模板中复制一份, 。
410
- function modifyPageTemplate(ctx) {
411
- registeredModifyPageTemplate = true;
412
- ctx.modifyBuildAssets(({ assets, miniPlugin }) => {
413
- const pages = [];
414
- // 筛选出使用了自定义组件的页面
415
- miniPlugin.pages.forEach(page => {
416
- const config = miniPlugin.filesConfig[miniPlugin.getConfigFilePath(page.name)].content;
417
- if (!page.isNative && (config === null || config === void 0 ? void 0 : config.hasOwnProperty('usingComponents')) && Object.keys(config.usingComponents).length) {
418
- pages.push(page.name);
419
- }
420
- });
421
- if (!pages.length)
422
- return;
423
- const baseXml = assets[getIsBuildPluginPath('base.axml', miniPlugin.options.isBuildPlugin)].source();
424
- pages.forEach(page => {
425
- const templateName = `${page}.axml`;
426
- const assetsItem = assets[templateName];
427
- const src = assetsItem._value ? assetsItem._value.toString() : assetsItem.source();
428
- let relativePath;
429
- const templateCaller = src.replace(/<import src="(.*)base\.axml"\/>/, function (_, $1) {
430
- relativePath = $1;
431
- return '';
432
- });
433
- const main = baseXml.replace(/<import-sjs name="xs" from="(.*)utils.sjs" \/>/, function () {
434
- return `<import-sjs name="xs" from="${relativePath}utils.sjs" />`;
435
- });
370
+ let registeredModifyPageTemplate = false;
371
+ var index = (ctx) => {
372
+ ctx.registerPlatform({
373
+ name: 'alipay',
374
+ useConfigName: 'mini',
375
+ fn({ config }) {
376
+ return __awaiter(this, void 0, void 0, function* () {
377
+ !registeredModifyPageTemplate && modifyPageTemplate(ctx);
378
+ const program = new Alipay(ctx, config);
379
+ yield program.start();
380
+ });
381
+ }
382
+ });
383
+ ctx.modifyRunnerOpts(({ opts }) => {
384
+ if (!(opts === null || opts === void 0 ? void 0 : opts.compiler))
385
+ return;
386
+ if (shared.isString(opts.compiler)) {
387
+ opts.compiler = {
388
+ type: opts.compiler
389
+ };
390
+ }
391
+ const { compiler } = opts;
392
+ if (compiler.type === 'webpack5') {
393
+ compiler.prebundle || (compiler.prebundle = {});
394
+ const prebundleOptions = compiler.prebundle;
395
+ if (prebundleOptions.enable === false)
396
+ return;
397
+ prebundleOptions.swc || (prebundleOptions.swc = {
398
+ jsc: {
399
+ target: 'es5'
400
+ }
401
+ });
402
+ prebundleOptions.exclude || (prebundleOptions.exclude = []);
403
+ prebundleOptions.exclude.push('@tarojs/plugin-platform-alipay/dist/runtime');
404
+ }
405
+ });
406
+ };
407
+ function getIsBuildPluginPath(filePath, isBuildPlugin) {
408
+ return isBuildPlugin ? `plugin/${filePath}` : filePath;
409
+ }
410
+ // 支付宝小程序中,如果某个页面依赖了原生小程序组件,
411
+ // 那么这个页面不能使用公共模板 base.axml,
412
+ // 而需要把公共模板的内容在此页面的模板中复制一份,
413
+ function modifyPageTemplate(ctx) {
414
+ registeredModifyPageTemplate = true;
415
+ ctx.modifyBuildAssets(({ assets, miniPlugin }) => {
416
+ const pages = [];
417
+ // 筛选出使用了自定义组件的页面
418
+ miniPlugin.pages.forEach(page => {
419
+ const config = miniPlugin.filesConfig[miniPlugin.getConfigFilePath(page.name)].content;
420
+ if (!page.isNative && (config === null || config === void 0 ? void 0 : config.hasOwnProperty('usingComponents')) && Object.keys(config.usingComponents).length) {
421
+ pages.push(page.name);
422
+ }
423
+ });
424
+ if (!pages.length)
425
+ return;
426
+ const baseXml = assets[getIsBuildPluginPath('base.axml', miniPlugin.options.isBuildPlugin)].source();
427
+ pages.forEach(page => {
428
+ const templateName = `${page}.axml`;
429
+ const assetsItem = assets[templateName];
430
+ const src = assetsItem._value ? assetsItem._value.toString() : assetsItem.source();
431
+ let relativePath;
432
+ const templateCaller = src.replace(/<import src="(.*)base\.axml"\/>/, function (_, $1) {
433
+ relativePath = $1;
434
+ return '';
435
+ });
436
+ const main = baseXml.replace(/<import-sjs name="xs" from="(.*)utils.sjs" \/>/, function () {
437
+ return `<import-sjs name="xs" from="${relativePath}utils.sjs" />`;
438
+ });
436
439
  const res = `${templateCaller}
437
- ${main}`;
438
- assets[templateName] = {
439
- size: () => res.length,
440
- source: () => res
441
- };
442
- });
443
- if (miniPlugin.options.isBuildPlugin) {
444
- const miniProjectJSONStr = JSON.stringify({
445
- miniprogramRoot: 'miniprogram',
446
- pluginRoot: 'plugin',
447
- compileType: 'plugin'
448
- }, null, 2);
449
- assets['mini.project.json'] = {
450
- size: () => miniProjectJSONStr.length,
451
- source: () => miniProjectJSONStr
452
- };
453
- const pluginJSON = JSON.parse(assets['/plugin/plugin.json'].source());
454
- pluginJSON.publicPages = pluginJSON.pages;
455
- pluginJSON.pages = Object.values(pluginJSON.publicPages);
456
- const pluginJSONStr = JSON.stringify(pluginJSON, null, 2);
457
- assets['/plugin/plugin.json'] = {
458
- size: () => pluginJSONStr.length,
459
- source: () => pluginJSONStr
460
- };
461
- }
462
- });
440
+ ${main}`;
441
+ assets[templateName] = {
442
+ size: () => res.length,
443
+ source: () => res
444
+ };
445
+ });
446
+ if (miniPlugin.options.isBuildPlugin) {
447
+ const miniProjectJSONStr = JSON.stringify({
448
+ miniprogramRoot: 'miniprogram',
449
+ pluginRoot: 'plugin',
450
+ compileType: 'plugin'
451
+ }, null, 2);
452
+ assets['mini.project.json'] = {
453
+ size: () => miniProjectJSONStr.length,
454
+ source: () => miniProjectJSONStr
455
+ };
456
+ const pluginJSON = JSON.parse(assets['/plugin/plugin.json'].source());
457
+ pluginJSON.publicPages = pluginJSON.pages;
458
+ pluginJSON.pages = Object.values(pluginJSON.publicPages);
459
+ const pluginJSONStr = JSON.stringify(pluginJSON, null, 2);
460
+ assets['/plugin/plugin.json'] = {
461
+ size: () => pluginJSONStr.length,
462
+ source: () => pluginJSONStr
463
+ };
464
+ }
465
+ });
463
466
  }
464
467
 
465
468
  exports.Alipay = Alipay;