@tarojs/plugin-platform-alipay 3.5.0-alpha.14 → 3.5.0-alpha.17
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/components-react.js +6 -5
- package/dist/components-react.js.map +1 -1
- package/dist/index.js +434 -391
- package/dist/index.js.map +1 -1
- package/dist/runtime-utils.js +671 -661
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +681 -671
- package/dist/runtime.js.map +1 -1
- package/index.js +1 -0
- package/package.json +9 -10
- package/types/components-react.d.ts +7 -5
- package/types/index.d.ts +78 -5
- package/types/runtime-utils.d.ts +151 -10
- package/types/runtime.d.ts +1 -1
- package/types/apis-list.d.ts +0 -1
- package/types/apis.d.ts +0 -9
- package/types/components.d.ts +0 -124
- package/types/program.d.ts +0 -45
- package/types/template.d.ts +0 -32
package/dist/index.js
CHANGED
|
@@ -2,67 +2,205 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var service = require('@tarojs/service');
|
|
6
5
|
var shared = require('@tarojs/shared');
|
|
6
|
+
var service = require('@tarojs/service');
|
|
7
7
|
var template = require('@tarojs/shared/dist/template');
|
|
8
8
|
|
|
9
9
|
/*! *****************************************************************************
|
|
10
|
-
Copyright (c) Microsoft Corporation.
|
|
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
|
-
|
|
16
|
-
|
|
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
|
-
|
|
21
|
-
|
|
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) :
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
+
ArCamera: {
|
|
160
|
+
devicePosition: shared.singleQuote('back'),
|
|
161
|
+
marker: '',
|
|
162
|
+
mode: shared.singleQuote('imageTracking'),
|
|
163
|
+
useCapturedImage: 'false',
|
|
164
|
+
bindInit: '',
|
|
165
|
+
bindStop: '',
|
|
166
|
+
bindError: '',
|
|
167
|
+
bindARFrame: ''
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
class Template extends template.RecursiveTemplate {
|
|
172
|
+
constructor() {
|
|
173
|
+
super(...arguments);
|
|
174
|
+
this.exportExpr = 'export default';
|
|
175
|
+
this.supportXS = true;
|
|
176
|
+
this.Adapter = {
|
|
177
|
+
if: 'a:if',
|
|
178
|
+
else: 'a:else',
|
|
179
|
+
elseif: 'a:elif',
|
|
180
|
+
for: 'a:for',
|
|
181
|
+
forItem: 'a:for-item',
|
|
182
|
+
forIndex: 'a:for-index',
|
|
183
|
+
key: 'a:key',
|
|
184
|
+
xs: 'sjs',
|
|
185
|
+
type: 'alipay'
|
|
186
|
+
};
|
|
187
|
+
this.modifyLoopBody = (child, nodeName) => {
|
|
188
|
+
if (nodeName === 'picker-view') {
|
|
189
|
+
return `<picker-view-column class="{{item.cl}}" style="{{item.st}}">
|
|
52
190
|
<view a:for="{{item.cn}}" a:key="sid">
|
|
53
191
|
${child}
|
|
54
192
|
</view>
|
|
55
|
-
</picker-view-column>`;
|
|
56
|
-
}
|
|
57
|
-
return child;
|
|
58
|
-
};
|
|
59
|
-
this.modifyLoopContainer = (children, nodeName) => {
|
|
60
|
-
if (nodeName === 'picker') {
|
|
193
|
+
</picker-view-column>`;
|
|
194
|
+
}
|
|
195
|
+
return child;
|
|
196
|
+
};
|
|
197
|
+
this.modifyLoopContainer = (children, nodeName) => {
|
|
198
|
+
if (nodeName === 'picker') {
|
|
61
199
|
return `
|
|
62
200
|
<view>${children}</view>
|
|
63
|
-
`;
|
|
64
|
-
}
|
|
65
|
-
if (nodeName === 'swiper') {
|
|
201
|
+
`;
|
|
202
|
+
}
|
|
203
|
+
if (nodeName === 'swiper') {
|
|
66
204
|
return `
|
|
67
205
|
<block a:for="{{xs.f(i.cn)}}" a:key="sid">
|
|
68
206
|
<swiper-item class="{{item.cl}}" style="{{item.st}}" id="{{item.uid||item.sid}}" data-sid="{{item.sid}}">
|
|
@@ -71,367 +209,272 @@ class Template extends template.RecursiveTemplate {
|
|
|
71
209
|
</block>
|
|
72
210
|
</swiper-item>
|
|
73
211
|
</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
|
-
|
|
212
|
+
`;
|
|
213
|
+
}
|
|
214
|
+
return children;
|
|
215
|
+
};
|
|
216
|
+
this.modifyTemplateResult = (res, nodeName) => {
|
|
217
|
+
if (nodeName === 'picker-view-column' || nodeName === 'swiper-item')
|
|
218
|
+
return '';
|
|
219
|
+
return res;
|
|
220
|
+
};
|
|
221
|
+
this.modifyThirdPartyLoopBody = () => {
|
|
222
|
+
// 兼容支付宝 2.0 构建
|
|
223
|
+
const slot = this.componentsAlias.slot;
|
|
224
|
+
const slotAlias = slot._num;
|
|
225
|
+
const slotNamePropAlias = slot.name;
|
|
226
|
+
return `<view a:if="{{item.nn==='${slotAlias}'}}" slot="{{item.${slotNamePropAlias}}}" id="{{item.uid||item.sid}}" data-sid="{{item.sid}}">
|
|
86
227
|
<block a:for="{{item.cn}}" a:key="sid">
|
|
87
228
|
<template is="{{xs.e(0)}}" data="{{i:item}}" />
|
|
88
229
|
</block>
|
|
89
230
|
</view>
|
|
90
|
-
<template a:else is="{{xs.e(0)}}" data="{{i:item}}" />`;
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
buildXsTemplate() {
|
|
94
|
-
return '<import-sjs name="xs" from="./utils.sjs" />';
|
|
95
|
-
}
|
|
96
|
-
replacePropName(name, value, compName) {
|
|
97
|
-
if (value === 'eh')
|
|
98
|
-
return name.replace('bind', 'on');
|
|
99
|
-
if (compName === 'map'
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return str +
|
|
120
|
-
}
|
|
121
|
-
else if (attr.startsWith('
|
|
122
|
-
return str + `${attr}="eh" `;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
231
|
+
<template a:else is="{{xs.e(0)}}" data="{{i:item}}" />`;
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
buildXsTemplate() {
|
|
235
|
+
return '<import-sjs name="xs" from="./utils.sjs" />';
|
|
236
|
+
}
|
|
237
|
+
replacePropName(name, value, compName, componentAlias) {
|
|
238
|
+
if (value === 'eh')
|
|
239
|
+
return name.replace('bind', 'on');
|
|
240
|
+
if (compName === 'map') {
|
|
241
|
+
const polygonsAlias = componentAlias.polygons;
|
|
242
|
+
if (value.includes(polygonsAlias)) {
|
|
243
|
+
name = 'polygon';
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return name;
|
|
247
|
+
}
|
|
248
|
+
getEvents() {
|
|
249
|
+
return {
|
|
250
|
+
onTap: 'eh',
|
|
251
|
+
onTouchMove: 'eh',
|
|
252
|
+
onTouchEnd: 'eh',
|
|
253
|
+
onTouchCancel: 'eh',
|
|
254
|
+
onLongTap: 'eh'
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
buildThirdPartyAttr(attrs) {
|
|
258
|
+
return [...attrs].reduce((str, attr) => {
|
|
259
|
+
if (attr.startsWith('@')) {
|
|
260
|
+
return str + `on${shared.capitalize(attr.slice(1))}="eh" `;
|
|
261
|
+
}
|
|
262
|
+
else if (attr.startsWith('bind')) {
|
|
263
|
+
return str + `${attr}="eh" `;
|
|
264
|
+
}
|
|
265
|
+
else if (attr.startsWith('on')) {
|
|
266
|
+
return str + `${attr}="eh" `;
|
|
267
|
+
}
|
|
268
|
+
return str + `${attr}="{{ i.${shared.toCamelCase(attr)} }}" `;
|
|
269
|
+
}, '');
|
|
270
|
+
}
|
|
271
|
+
createMiniComponents(components) {
|
|
272
|
+
const result = super.createMiniComponents(components);
|
|
273
|
+
// 兼容支付宝 2.0 构建
|
|
274
|
+
delete result.slot;
|
|
275
|
+
delete result['slot-view'];
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
buildXSTmpExtra() {
|
|
279
|
+
const swiperItemAlias = this.componentsAlias['swiper-item']._num;
|
|
135
280
|
return `f: function (l) {
|
|
136
|
-
return l.filter(function (i) {return i.nn === '
|
|
137
|
-
}`;
|
|
138
|
-
}
|
|
281
|
+
return l.filter(function (i) {return i.nn === '${swiperItemAlias}'})
|
|
282
|
+
}`;
|
|
283
|
+
}
|
|
139
284
|
}
|
|
140
285
|
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
assetsPath: '',
|
|
234
|
-
placeholder: '',
|
|
235
|
-
djangoId: '',
|
|
236
|
-
md5: '',
|
|
237
|
-
optimize: 'false',
|
|
238
|
-
bindDataReady: '',
|
|
239
|
-
bindDataFailed: '',
|
|
240
|
-
bindAnimationStart: '',
|
|
241
|
-
bindAnimationEnd: '',
|
|
242
|
-
bindAnimationRepeat: '',
|
|
243
|
-
bindAnimationCancel: '',
|
|
244
|
-
bindDataLoadReady: ''
|
|
245
|
-
},
|
|
246
|
-
Lifestyle: {
|
|
247
|
-
'public-id': '',
|
|
248
|
-
memo: '',
|
|
249
|
-
bindFollow: ''
|
|
250
|
-
},
|
|
251
|
-
LifeFollow: {
|
|
252
|
-
sceneId: '',
|
|
253
|
-
checkFollow: '',
|
|
254
|
-
bindCheckFollow: '',
|
|
255
|
-
bindClose: ''
|
|
256
|
-
},
|
|
257
|
-
ContactButton: {
|
|
258
|
-
'tnt-inst-id': '',
|
|
259
|
-
scene: '',
|
|
260
|
-
size: '25',
|
|
261
|
-
color: shared.singleQuote('#00A3FF'),
|
|
262
|
-
icon: '',
|
|
263
|
-
'alipay-card-no': '',
|
|
264
|
-
'ext-info': ''
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
const PACKAGE_NAME = '@tarojs/plugin-platform-alipay';
|
|
269
|
-
class Alipay extends service.TaroPlatformBase {
|
|
270
|
-
/**
|
|
271
|
-
* 1. setupTransaction - init
|
|
272
|
-
* 2. setup
|
|
273
|
-
* 3. setupTransaction - close
|
|
274
|
-
* 4. buildTransaction - init
|
|
275
|
-
* 5. build
|
|
276
|
-
* 6. buildTransaction - close
|
|
277
|
-
*/
|
|
278
|
-
constructor(ctx, config) {
|
|
279
|
-
super(ctx, config);
|
|
280
|
-
this.platform = 'alipay';
|
|
281
|
-
this.globalObject = 'my';
|
|
282
|
-
this.runtimePath = `${PACKAGE_NAME}/dist/runtime`;
|
|
283
|
-
this.taroComponentsPath = `${PACKAGE_NAME}/dist/components-react`;
|
|
284
|
-
this.fileType = {
|
|
285
|
-
templ: '.axml',
|
|
286
|
-
style: '.acss',
|
|
287
|
-
config: '.json',
|
|
288
|
-
script: '.js',
|
|
289
|
-
xs: '.sjs'
|
|
290
|
-
};
|
|
291
|
-
this.template = new Template();
|
|
292
|
-
this.setupTransaction.addWrapper({
|
|
293
|
-
close() {
|
|
294
|
-
this.modifyMiniConfigs();
|
|
295
|
-
this.modifyComponents();
|
|
296
|
-
this.modifyWebpackConfig();
|
|
297
|
-
this.generateProjectConfig('project.alipay.json', 'mini.project.json');
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* 转换用户编写的配置(微信小程序标准)为支付宝小程序标准
|
|
303
|
-
*/
|
|
304
|
-
modifyMiniConfigs() {
|
|
305
|
-
this.ctx.modifyMiniConfigs(({ configMap }) => {
|
|
306
|
-
const replaceKeyMap = {
|
|
307
|
-
navigationBarTitleText: 'defaultTitle',
|
|
308
|
-
navigationBarBackgroundColor: 'titleBarColor',
|
|
309
|
-
enablePullDownRefresh: 'pullRefresh',
|
|
310
|
-
list: 'items',
|
|
311
|
-
text: 'name',
|
|
312
|
-
iconPath: 'icon',
|
|
313
|
-
selectedIconPath: 'activeIcon',
|
|
314
|
-
color: 'textColor'
|
|
315
|
-
};
|
|
316
|
-
Object.keys(configMap).forEach(key => {
|
|
317
|
-
const item = configMap[key];
|
|
318
|
-
if (item.content) {
|
|
319
|
-
this.recursiveReplaceObjectKeys(item.content, replaceKeyMap);
|
|
320
|
-
}
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* 增加组件或修改组件属性
|
|
326
|
-
*/
|
|
327
|
-
modifyComponents() {
|
|
328
|
-
const { internalComponents } = this.template;
|
|
329
|
-
this.template.mergeComponents(this.ctx, components);
|
|
330
|
-
this.modifySlider(internalComponents.Slider);
|
|
331
|
-
this.modifySwiper(internalComponents.Swiper);
|
|
332
|
-
}
|
|
333
|
-
/**
|
|
334
|
-
* 修改 Slider 组件属性
|
|
335
|
-
*/
|
|
336
|
-
modifySlider(slider) {
|
|
337
|
-
delete slider['block-size'];
|
|
338
|
-
delete slider['block-color'];
|
|
339
|
-
}
|
|
340
|
-
/**
|
|
341
|
-
* 修改 Swiper 组件属性
|
|
342
|
-
*/
|
|
343
|
-
modifySwiper(swiper) {
|
|
344
|
-
delete swiper.bindAnimationFinish;
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* 修改 Webpack 配置
|
|
348
|
-
*/
|
|
349
|
-
modifyWebpackConfig() {
|
|
350
|
-
this.ctx.modifyWebpackChain(({ chain }) => {
|
|
351
|
-
// 支付宝系小程序全局就有 navigator 对象,不需要模拟
|
|
352
|
-
chain.plugin('providerPlugin')
|
|
353
|
-
.tap(args => {
|
|
354
|
-
const newArgs = Object.assign({}, args[0]);
|
|
355
|
-
delete newArgs.navigator;
|
|
356
|
-
return [newArgs];
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
}
|
|
286
|
+
const PACKAGE_NAME = '@tarojs/plugin-platform-alipay';
|
|
287
|
+
class Alipay extends service.TaroPlatformBase {
|
|
288
|
+
/**
|
|
289
|
+
* 1. setupTransaction - init
|
|
290
|
+
* 2. setup
|
|
291
|
+
* 3. setupTransaction - close
|
|
292
|
+
* 4. buildTransaction - init
|
|
293
|
+
* 5. build
|
|
294
|
+
* 6. buildTransaction - close
|
|
295
|
+
*/
|
|
296
|
+
constructor(ctx, config) {
|
|
297
|
+
super(ctx, config);
|
|
298
|
+
this.platform = 'alipay';
|
|
299
|
+
this.globalObject = 'my';
|
|
300
|
+
this.runtimePath = `${PACKAGE_NAME}/dist/runtime`;
|
|
301
|
+
this.taroComponentsPath = `${PACKAGE_NAME}/dist/components-react`;
|
|
302
|
+
this.fileType = {
|
|
303
|
+
templ: '.axml',
|
|
304
|
+
style: '.acss',
|
|
305
|
+
config: '.json',
|
|
306
|
+
script: '.js',
|
|
307
|
+
xs: '.sjs'
|
|
308
|
+
};
|
|
309
|
+
this.template = new Template();
|
|
310
|
+
this.setupTransaction.addWrapper({
|
|
311
|
+
close() {
|
|
312
|
+
this.modifyMiniConfigs();
|
|
313
|
+
this.modifyComponents();
|
|
314
|
+
this.modifyWebpackConfig();
|
|
315
|
+
this.generateProjectConfig('project.alipay.json', 'mini.project.json');
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* 转换用户编写的配置(微信小程序标准)为支付宝小程序标准
|
|
321
|
+
*/
|
|
322
|
+
modifyMiniConfigs() {
|
|
323
|
+
this.ctx.modifyMiniConfigs(({ configMap }) => {
|
|
324
|
+
const replaceKeyMap = {
|
|
325
|
+
navigationBarTitleText: 'defaultTitle',
|
|
326
|
+
navigationBarBackgroundColor: 'titleBarColor',
|
|
327
|
+
enablePullDownRefresh: 'pullRefresh',
|
|
328
|
+
list: 'items',
|
|
329
|
+
text: 'name',
|
|
330
|
+
iconPath: 'icon',
|
|
331
|
+
selectedIconPath: 'activeIcon',
|
|
332
|
+
color: 'textColor'
|
|
333
|
+
};
|
|
334
|
+
Object.keys(configMap).forEach(key => {
|
|
335
|
+
const item = configMap[key];
|
|
336
|
+
if (item.content) {
|
|
337
|
+
this.recursiveReplaceObjectKeys(item.content, replaceKeyMap);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* 增加组件或修改组件属性
|
|
344
|
+
*/
|
|
345
|
+
modifyComponents() {
|
|
346
|
+
const { internalComponents } = this.template;
|
|
347
|
+
this.template.mergeComponents(this.ctx, components);
|
|
348
|
+
this.modifySlider(internalComponents.Slider);
|
|
349
|
+
this.modifySwiper(internalComponents.Swiper);
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* 修改 Slider 组件属性
|
|
353
|
+
*/
|
|
354
|
+
modifySlider(slider) {
|
|
355
|
+
delete slider['block-size'];
|
|
356
|
+
delete slider['block-color'];
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* 修改 Swiper 组件属性
|
|
360
|
+
*/
|
|
361
|
+
modifySwiper(swiper) {
|
|
362
|
+
delete swiper.bindAnimationFinish;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* 修改 Webpack 配置
|
|
366
|
+
*/
|
|
367
|
+
modifyWebpackConfig() {
|
|
368
|
+
this.ctx.modifyWebpackChain(({ chain }) => {
|
|
369
|
+
// 支付宝系小程序全局就有 navigator 对象,不需要模拟
|
|
370
|
+
chain.plugin('providerPlugin')
|
|
371
|
+
.tap(args => {
|
|
372
|
+
const newArgs = Object.assign({}, args[0]);
|
|
373
|
+
delete newArgs.navigator;
|
|
374
|
+
return [newArgs];
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
}
|
|
360
378
|
}
|
|
361
379
|
|
|
362
|
-
let
|
|
363
|
-
var index = (ctx) => {
|
|
364
|
-
ctx.registerPlatform({
|
|
365
|
-
name: 'alipay',
|
|
366
|
-
useConfigName: 'mini',
|
|
367
|
-
fn({ config }) {
|
|
368
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
369
|
-
!
|
|
370
|
-
const program = new Alipay(ctx, config);
|
|
371
|
-
yield program.start();
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
});
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
380
|
+
let registeredModifyPageTemplate = false;
|
|
381
|
+
var index = (ctx) => {
|
|
382
|
+
ctx.registerPlatform({
|
|
383
|
+
name: 'alipay',
|
|
384
|
+
useConfigName: 'mini',
|
|
385
|
+
fn({ config }) {
|
|
386
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
387
|
+
!registeredModifyPageTemplate && modifyPageTemplate(ctx);
|
|
388
|
+
const program = new Alipay(ctx, config);
|
|
389
|
+
yield program.start();
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
ctx.modifyRunnerOpts(({ opts }) => {
|
|
394
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.compiler))
|
|
395
|
+
return;
|
|
396
|
+
if (shared.isString(opts.compiler)) {
|
|
397
|
+
opts.compiler = {
|
|
398
|
+
type: opts.compiler
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
const { compiler } = opts;
|
|
402
|
+
if (compiler.type === 'webpack5') {
|
|
403
|
+
compiler.prebundle || (compiler.prebundle = {});
|
|
404
|
+
const prebundleOptions = compiler.prebundle;
|
|
405
|
+
if (prebundleOptions.enable === false)
|
|
406
|
+
return;
|
|
407
|
+
prebundleOptions.swc || (prebundleOptions.swc = {
|
|
408
|
+
jsc: {
|
|
409
|
+
target: 'es5'
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
prebundleOptions.exclude || (prebundleOptions.exclude = []);
|
|
413
|
+
prebundleOptions.exclude.push('@tarojs/plugin-platform-alipay/dist/runtime');
|
|
414
|
+
prebundleOptions.include || (prebundleOptions.include = []);
|
|
415
|
+
prebundleOptions.include.push('@tarojs/shared');
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
};
|
|
419
|
+
function getIsBuildPluginPath(filePath, isBuildPlugin) {
|
|
420
|
+
return isBuildPlugin ? `plugin/${filePath}` : filePath;
|
|
421
|
+
}
|
|
422
|
+
// 支付宝小程序中,如果某个页面依赖了原生小程序组件,
|
|
423
|
+
// 那么这个页面不能使用公共模板 base.axml,
|
|
424
|
+
// 而需要把公共模板的内容在此页面的模板中复制一份, 。
|
|
425
|
+
function modifyPageTemplate(ctx) {
|
|
426
|
+
registeredModifyPageTemplate = true;
|
|
427
|
+
ctx.modifyBuildAssets(({ assets, miniPlugin }) => {
|
|
428
|
+
const pages = [];
|
|
429
|
+
// 筛选出使用了自定义组件的页面
|
|
430
|
+
miniPlugin.pages.forEach(page => {
|
|
431
|
+
const config = miniPlugin.filesConfig[miniPlugin.getConfigFilePath(page.name)].content;
|
|
432
|
+
if (!page.isNative && (config === null || config === void 0 ? void 0 : config.hasOwnProperty('usingComponents')) && Object.keys(config.usingComponents).length) {
|
|
433
|
+
pages.push(page.name);
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
if (!pages.length)
|
|
437
|
+
return;
|
|
438
|
+
const baseXml = assets[getIsBuildPluginPath('base.axml', miniPlugin.options.isBuildPlugin)].source();
|
|
439
|
+
pages.forEach(page => {
|
|
440
|
+
const templateName = `${page}.axml`;
|
|
441
|
+
const assetsItem = assets[templateName];
|
|
442
|
+
const src = assetsItem._value ? assetsItem._value.toString() : assetsItem.source();
|
|
443
|
+
let relativePath;
|
|
444
|
+
const templateCaller = src.replace(/<import src="(.*)base\.axml"\/>/, function (_, $1) {
|
|
445
|
+
relativePath = $1;
|
|
446
|
+
return '';
|
|
447
|
+
});
|
|
448
|
+
const main = baseXml.replace(/<import-sjs name="xs" from="(.*)utils.sjs" \/>/, function () {
|
|
449
|
+
return `<import-sjs name="xs" from="${relativePath}utils.sjs" />`;
|
|
450
|
+
});
|
|
408
451
|
const res = `${templateCaller}
|
|
409
|
-
${main}`;
|
|
410
|
-
assets[templateName] = {
|
|
411
|
-
size: () => res.length,
|
|
412
|
-
source: () => res
|
|
413
|
-
};
|
|
414
|
-
});
|
|
415
|
-
if (miniPlugin.options.isBuildPlugin) {
|
|
416
|
-
const miniProjectJSONStr = JSON.stringify({
|
|
417
|
-
miniprogramRoot: 'miniprogram',
|
|
418
|
-
pluginRoot: 'plugin',
|
|
419
|
-
compileType: 'plugin'
|
|
420
|
-
}, null, 2);
|
|
421
|
-
assets['mini.project.json'] = {
|
|
422
|
-
size: () => miniProjectJSONStr.length,
|
|
423
|
-
source: () => miniProjectJSONStr
|
|
424
|
-
};
|
|
425
|
-
const pluginJSON = JSON.parse(assets['/plugin/plugin.json'].source());
|
|
426
|
-
pluginJSON.publicPages = pluginJSON.pages;
|
|
427
|
-
pluginJSON.pages = Object.values(pluginJSON.publicPages);
|
|
428
|
-
const pluginJSONStr = JSON.stringify(pluginJSON, null, 2);
|
|
429
|
-
assets['/plugin/plugin.json'] = {
|
|
430
|
-
size: () => pluginJSONStr.length,
|
|
431
|
-
source: () => pluginJSONStr
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
});
|
|
452
|
+
${main}`;
|
|
453
|
+
assets[templateName] = {
|
|
454
|
+
size: () => res.length,
|
|
455
|
+
source: () => res
|
|
456
|
+
};
|
|
457
|
+
});
|
|
458
|
+
if (miniPlugin.options.isBuildPlugin) {
|
|
459
|
+
const miniProjectJSONStr = JSON.stringify({
|
|
460
|
+
miniprogramRoot: 'miniprogram',
|
|
461
|
+
pluginRoot: 'plugin',
|
|
462
|
+
compileType: 'plugin'
|
|
463
|
+
}, null, 2);
|
|
464
|
+
assets['mini.project.json'] = {
|
|
465
|
+
size: () => miniProjectJSONStr.length,
|
|
466
|
+
source: () => miniProjectJSONStr
|
|
467
|
+
};
|
|
468
|
+
const pluginJSON = JSON.parse(assets['/plugin/plugin.json'].source());
|
|
469
|
+
pluginJSON.publicPages = pluginJSON.pages;
|
|
470
|
+
pluginJSON.pages = Object.values(pluginJSON.publicPages);
|
|
471
|
+
const pluginJSONStr = JSON.stringify(pluginJSON, null, 2);
|
|
472
|
+
assets['/plugin/plugin.json'] = {
|
|
473
|
+
size: () => pluginJSONStr.length,
|
|
474
|
+
source: () => pluginJSONStr
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
});
|
|
435
478
|
}
|
|
436
479
|
|
|
437
480
|
exports.Alipay = Alipay;
|