@tarojs/plugin-platform-swan 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/components-react.js +9 -9
- package/dist/components-react.js.map +1 -1
- package/dist/index.js +357 -356
- package/dist/index.js.map +1 -1
- package/dist/runtime-utils.js +236 -236
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +240 -240
- package/dist/runtime.js.map +1 -1
- package/index.js +1 -0
- package/package.json +9 -10
- package/types/components-react.d.ts +11 -10
- package/types/index.d.ts +69 -5
- package/types/runtime-utils.d.ts +165 -11
- package/types/runtime.d.ts +1 -1
- package/types/apis-list.d.ts +0 -1
- package/types/apis.d.ts +0 -5
- package/types/components.d.ts +0 -155
- package/types/program.d.ts +0 -29
- package/types/template.d.ts +0 -40
package/dist/index.js
CHANGED
|
@@ -7,64 +7,223 @@ var shared = require('@tarojs/shared');
|
|
|
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
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
34
|
+
const components = {
|
|
35
|
+
// ======== 调整属性 ========
|
|
36
|
+
Progress: {
|
|
37
|
+
'border-radius': '0',
|
|
38
|
+
'font-size': '16',
|
|
39
|
+
duration: '30'
|
|
40
|
+
},
|
|
41
|
+
RichText: {
|
|
42
|
+
selectable: 'false',
|
|
43
|
+
name: '',
|
|
44
|
+
attrs: '',
|
|
45
|
+
children: '[]',
|
|
46
|
+
text: '',
|
|
47
|
+
'image-menu-prevent': 'false',
|
|
48
|
+
preview: ''
|
|
49
|
+
},
|
|
50
|
+
Map: {
|
|
51
|
+
polygons: '[]',
|
|
52
|
+
'enable-3D': 'false',
|
|
53
|
+
'show-compass': 'false',
|
|
54
|
+
'enable-overlooking': 'false',
|
|
55
|
+
'enable-zoom': 'true',
|
|
56
|
+
'enable-scroll': 'true',
|
|
57
|
+
'enable-rotate': 'false',
|
|
58
|
+
bindRegionChange: '',
|
|
59
|
+
bindPoiTap: ''
|
|
60
|
+
},
|
|
61
|
+
Button: {
|
|
62
|
+
bindGetPhoneNumber: '',
|
|
63
|
+
bindGetUserInfo: '',
|
|
64
|
+
bindOpenSetting: '',
|
|
65
|
+
bindContact: '',
|
|
66
|
+
bindChooseAddress: '',
|
|
67
|
+
bindChooseInvoiceTitle: '',
|
|
68
|
+
bindLogin: ''
|
|
69
|
+
},
|
|
70
|
+
Form: {
|
|
71
|
+
'report-type': 'default',
|
|
72
|
+
'template-id': '',
|
|
73
|
+
'subscribe-id': ''
|
|
74
|
+
},
|
|
75
|
+
Input: {
|
|
76
|
+
'adjust-position': 'true'
|
|
77
|
+
},
|
|
78
|
+
Textarea: {
|
|
79
|
+
'confirm-type': shared.singleQuote('default'),
|
|
80
|
+
'confirm-hold': 'false',
|
|
81
|
+
'show-confirm-bar': 'true',
|
|
82
|
+
'adjust-position': 'true'
|
|
83
|
+
},
|
|
84
|
+
Navigator: {
|
|
85
|
+
target: shared.singleQuote('self'),
|
|
86
|
+
'app-id': '',
|
|
87
|
+
path: '',
|
|
88
|
+
'extra-data': '',
|
|
89
|
+
version: shared.singleQuote('version')
|
|
90
|
+
},
|
|
91
|
+
Image: {
|
|
92
|
+
webp: 'false',
|
|
93
|
+
'image-menu-prevent': 'false',
|
|
94
|
+
preview: '',
|
|
95
|
+
'original-src': ''
|
|
96
|
+
},
|
|
97
|
+
Video: {
|
|
98
|
+
title: '',
|
|
99
|
+
'show-no-wifi-tip': 'true',
|
|
100
|
+
'vslide-gesture': 'false',
|
|
101
|
+
'vslide-gesture-in-fullscreen': 'true',
|
|
102
|
+
'enable-play-gesture': 'false',
|
|
103
|
+
'show-rate-btn': 'false',
|
|
104
|
+
'show-vslide-btn-in-fullscreen': 'true',
|
|
105
|
+
'silent-play': 'false',
|
|
106
|
+
bindLoadedMetadata: ''
|
|
107
|
+
},
|
|
108
|
+
Ad: {
|
|
109
|
+
appid: '',
|
|
110
|
+
apid: '',
|
|
111
|
+
type: shared.singleQuote('feed'),
|
|
112
|
+
updatetime: '',
|
|
113
|
+
bindStatus: ''
|
|
114
|
+
},
|
|
115
|
+
// ======== 额外组件 ========
|
|
116
|
+
Tabs: {
|
|
117
|
+
'tabs-background-color': shared.singleQuote('#fff'),
|
|
118
|
+
'tabs-active-text-color': shared.singleQuote('#000'),
|
|
119
|
+
'tabs-inactive-text-color': shared.singleQuote('#666'),
|
|
120
|
+
'tabs-underline-color': shared.singleQuote('#333'),
|
|
121
|
+
'active-name': '',
|
|
122
|
+
'url-query-name': '',
|
|
123
|
+
'max-tab-item-amount': '5',
|
|
124
|
+
bindTabChange: ''
|
|
125
|
+
},
|
|
126
|
+
TabItem: {
|
|
127
|
+
label: '',
|
|
128
|
+
name: '',
|
|
129
|
+
'badge-type': '',
|
|
130
|
+
'badge-text': ''
|
|
131
|
+
},
|
|
132
|
+
AnimationVideo: {
|
|
133
|
+
'resource-width': '800',
|
|
134
|
+
'resource-height': '400',
|
|
135
|
+
'canvas-style': shared.singleQuote('width:400px;height:400px'),
|
|
136
|
+
path: '',
|
|
137
|
+
loop: 'fasle',
|
|
138
|
+
autoplay: 'fasle',
|
|
139
|
+
bindStarted: '',
|
|
140
|
+
bindEnded: ''
|
|
141
|
+
},
|
|
142
|
+
AnimationView: {
|
|
143
|
+
path: '',
|
|
144
|
+
loop: 'false',
|
|
145
|
+
autoplay: 'true',
|
|
146
|
+
action: shared.singleQuote('play'),
|
|
147
|
+
hidden: 'true',
|
|
148
|
+
bindEnded: ''
|
|
149
|
+
},
|
|
150
|
+
ArCamera: {
|
|
151
|
+
key: '',
|
|
152
|
+
type: '',
|
|
153
|
+
flash: shared.singleQuote('off'),
|
|
154
|
+
bindError: '',
|
|
155
|
+
bindLoad: '',
|
|
156
|
+
bindMessage: '',
|
|
157
|
+
bindScanCode: ''
|
|
158
|
+
},
|
|
159
|
+
RtcRoom: {
|
|
160
|
+
id: '',
|
|
161
|
+
'enable-camera': 'true',
|
|
162
|
+
'enable-auto-focus': 'true',
|
|
163
|
+
'enable-zoom': 'false',
|
|
164
|
+
'device-position': shared.singleQuote('front'),
|
|
165
|
+
'enable-mic': 'true',
|
|
166
|
+
'enable-agc': 'false',
|
|
167
|
+
'enable-ans': 'false',
|
|
168
|
+
bitrate: '900',
|
|
169
|
+
'video-width': '360',
|
|
170
|
+
'video-height': '640',
|
|
171
|
+
'enable-remote-mirror': 'false',
|
|
172
|
+
'local-mirror': shared.singleQuote('auto'),
|
|
173
|
+
'sound-mode': shared.singleQuote('speaker'),
|
|
174
|
+
bindStateChange: '',
|
|
175
|
+
bindError: ''
|
|
176
|
+
},
|
|
177
|
+
RtcRoomItem: {
|
|
178
|
+
id: '',
|
|
179
|
+
type: '',
|
|
180
|
+
'user-id': ''
|
|
181
|
+
},
|
|
182
|
+
OpenData: {
|
|
183
|
+
type: ''
|
|
184
|
+
},
|
|
185
|
+
Login: {
|
|
186
|
+
'button-class': '',
|
|
187
|
+
bindGetPhoneNumber: '',
|
|
188
|
+
bindLoadError: ''
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const swanSpecialAttrs = {
|
|
193
|
+
'scroll-view': ['scroll-top', 'scroll-left', 'scroll-into-view'],
|
|
194
|
+
'movable-view': ['x', 'y'],
|
|
195
|
+
slider: ['value'],
|
|
196
|
+
input: ['value'],
|
|
197
|
+
textarea: ['value']
|
|
198
|
+
};
|
|
199
|
+
class Template extends template.RecursiveTemplate {
|
|
200
|
+
constructor(options) {
|
|
201
|
+
var _a, _b, _c;
|
|
202
|
+
super();
|
|
203
|
+
this.supportXS = true;
|
|
204
|
+
this.Adapter = {
|
|
205
|
+
if: 's-if',
|
|
206
|
+
else: 's-else',
|
|
207
|
+
elseif: 's-elif',
|
|
208
|
+
for: 's-for',
|
|
209
|
+
forItem: 's-for-item',
|
|
210
|
+
forIndex: 's-for-index',
|
|
211
|
+
key: 's-key',
|
|
212
|
+
xs: 'sjs',
|
|
213
|
+
type: 'swan'
|
|
214
|
+
};
|
|
215
|
+
this.buildFlattenView = (level = this.flattenViewLevel) => {
|
|
216
|
+
if (level === 0) {
|
|
217
|
+
return '<template is="{{xs.e(0)}}" data="{{{i:item}}}" />';
|
|
218
|
+
}
|
|
219
|
+
const child = this.buildFlattenView(level - 1);
|
|
220
|
+
const componentsAlias = this.componentsAlias;
|
|
221
|
+
const viewAlias = componentsAlias.view._num;
|
|
222
|
+
const textAlias = componentsAlias.text._num;
|
|
223
|
+
const staticTextAlias = componentsAlias['static-text']._num;
|
|
224
|
+
const buttonAlias = componentsAlias.button._num;
|
|
225
|
+
const inputAlias = componentsAlias.input._num;
|
|
226
|
+
const swiperAlias = componentsAlias.swiper._num;
|
|
68
227
|
const template = `<view s-if="{{item.nn==='${viewAlias}'&&(item.st||item.cl)}}" id="{{item.uid||item.sid}}" data-sid="{{item.sid}}" ${this.buildFlattenNodeAttributes('view')}>
|
|
69
228
|
<block s-for="{{item.cn}}" s-key="sid">
|
|
70
229
|
${shared.indent(child, 4)}
|
|
@@ -93,18 +252,18 @@ class Template extends template.RecursiveTemplate {
|
|
|
93
252
|
</swiper>
|
|
94
253
|
<block s-else>
|
|
95
254
|
<template is="{{xs.e(0)}}" data="{{{i:item}}}" />
|
|
96
|
-
</block>`;
|
|
97
|
-
return template;
|
|
98
|
-
};
|
|
99
|
-
this.buildFlattenCover = (level = this.flattenCoverLevel) => {
|
|
100
|
-
if (level === 0) {
|
|
101
|
-
return '<template is="{{xs.e(0)}}" data="{{{i:item}}}" />';
|
|
102
|
-
}
|
|
103
|
-
const child = this.buildFlattenCover(level - 1);
|
|
104
|
-
const componentsAlias = this.componentsAlias;
|
|
105
|
-
const coverViewAlias = componentsAlias['cover-view']._num;
|
|
106
|
-
const coverImageAlias = componentsAlias['cover-image']._num;
|
|
107
|
-
const contentAlias = componentsAlias['#text']._num;
|
|
255
|
+
</block>`;
|
|
256
|
+
return template;
|
|
257
|
+
};
|
|
258
|
+
this.buildFlattenCover = (level = this.flattenCoverLevel) => {
|
|
259
|
+
if (level === 0) {
|
|
260
|
+
return '<template is="{{xs.e(0)}}" data="{{{i:item}}}" />';
|
|
261
|
+
}
|
|
262
|
+
const child = this.buildFlattenCover(level - 1);
|
|
263
|
+
const componentsAlias = this.componentsAlias;
|
|
264
|
+
const coverViewAlias = componentsAlias['cover-view']._num;
|
|
265
|
+
const coverImageAlias = componentsAlias['cover-image']._num;
|
|
266
|
+
const contentAlias = componentsAlias['#text']._num;
|
|
108
267
|
const template = `<cover-view s-if="{{item.nn==='${coverViewAlias}'}}" id="{{item.uid||item.sid}}" data-sid="{{item.sid}}" ${this.buildFlattenNodeAttributes('cover-view')}>
|
|
109
268
|
<block s-for="{{item.cn}}" s-key="sid">
|
|
110
269
|
${shared.indent(child, 4)}
|
|
@@ -114,322 +273,164 @@ class Template extends template.RecursiveTemplate {
|
|
|
114
273
|
<block s-elif="{{item.nn==='${contentAlias}'}}">{{item.v}}</block>
|
|
115
274
|
<block s-else>
|
|
116
275
|
<template is="{{xs.e(0)}}" data="{{{i:item}}}" />
|
|
117
|
-
</block>`;
|
|
118
|
-
return template;
|
|
119
|
-
};
|
|
120
|
-
this.buildFlattenText = (level = this.flattenTextLevel) => {
|
|
121
|
-
if (level === 0) {
|
|
122
|
-
return `<block>{{i.${"cn" /* Childnodes */}[index].${"v" /* Text */}}}</block>`;
|
|
123
|
-
}
|
|
124
|
-
const child = this.buildFlattenText(level - 1);
|
|
125
|
-
const componentsAlias = this.componentsAlias;
|
|
126
|
-
const contentAlias = componentsAlias['#text']._num;
|
|
276
|
+
</block>`;
|
|
277
|
+
return template;
|
|
278
|
+
};
|
|
279
|
+
this.buildFlattenText = (level = this.flattenTextLevel) => {
|
|
280
|
+
if (level === 0) {
|
|
281
|
+
return `<block>{{i.${"cn" /* Shortcuts.Childnodes */}[index].${"v" /* Shortcuts.Text */}}}</block>`;
|
|
282
|
+
}
|
|
283
|
+
const child = this.buildFlattenText(level - 1);
|
|
284
|
+
const componentsAlias = this.componentsAlias;
|
|
285
|
+
const contentAlias = componentsAlias['#text']._num;
|
|
127
286
|
const template = `<block s-if="item.nn === '${contentAlias}'">{{item.v}}</block>
|
|
128
287
|
<text s-else id="{{item.uid||item.sid}}" data-sid="{{item.sid}}" ${this.buildFlattenNodeAttributes('text')}>
|
|
129
288
|
<block s-for="{{item.cn}}" s-key="sid">
|
|
130
289
|
${shared.indent(child, 4)}
|
|
131
290
|
</block>
|
|
132
|
-
</text>`;
|
|
133
|
-
return template;
|
|
134
|
-
};
|
|
135
|
-
this.modifyLoopBody = (child, nodeName) => {
|
|
136
|
-
const componentsAlias = this.componentsAlias;
|
|
137
|
-
const adAlias = componentsAlias.ad._num;
|
|
138
|
-
switch (nodeName) {
|
|
139
|
-
case 'view':
|
|
140
|
-
// fix issue #6015
|
|
141
|
-
return this.buildFlattenView();
|
|
142
|
-
case 'cover-view':
|
|
143
|
-
case 'canvas':
|
|
144
|
-
case 'map':
|
|
145
|
-
case 'animation-view':
|
|
146
|
-
case 'camera':
|
|
147
|
-
case 'live-player':
|
|
148
|
-
return this.buildFlattenCover();
|
|
149
|
-
case 'video': {
|
|
291
|
+
</text>`;
|
|
292
|
+
return template;
|
|
293
|
+
};
|
|
294
|
+
this.modifyLoopBody = (child, nodeName) => {
|
|
295
|
+
const componentsAlias = this.componentsAlias;
|
|
296
|
+
const adAlias = componentsAlias.ad._num;
|
|
297
|
+
switch (nodeName) {
|
|
298
|
+
case 'view':
|
|
299
|
+
// fix issue #6015
|
|
300
|
+
return this.buildFlattenView();
|
|
301
|
+
case 'cover-view':
|
|
302
|
+
case 'canvas':
|
|
303
|
+
case 'map':
|
|
304
|
+
case 'animation-view':
|
|
305
|
+
case 'camera':
|
|
306
|
+
case 'live-player':
|
|
307
|
+
return this.buildFlattenCover();
|
|
308
|
+
case 'video': {
|
|
150
309
|
const body = `<ad s-if={{item.nn==='${adAlias}'}} id="{{item.uid||item.sid}}" data-sid="{{item.sid}}" ${this.buildFlattenNodeAttributes('ad')}></ad>
|
|
151
310
|
<block s-else>
|
|
152
311
|
${shared.indent(this.buildFlattenCover(), 2)}
|
|
153
|
-
</block>`;
|
|
154
|
-
return body;
|
|
155
|
-
}
|
|
156
|
-
case 'text':
|
|
157
|
-
case 'static-text':
|
|
158
|
-
return this.buildFlattenText();
|
|
159
|
-
case 'picker-view':
|
|
312
|
+
</block>`;
|
|
313
|
+
return body;
|
|
314
|
+
}
|
|
315
|
+
case 'text':
|
|
316
|
+
case 'static-text':
|
|
317
|
+
return this.buildFlattenText();
|
|
318
|
+
case 'picker-view':
|
|
160
319
|
return `<picker-view-column id="{{item.uid||item.sid}}" data-sid="{{item.sid}}" ${this.buildFlattenNodeAttributes('picker-view-column')}>
|
|
161
320
|
<block s-for="{{item.cn}}" s-key="sid">
|
|
162
321
|
${child}
|
|
163
322
|
</block>
|
|
164
|
-
</picker-view-column>`;
|
|
165
|
-
default:
|
|
166
|
-
return child;
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
this.modifyLoopContainer = (children, nodeName) => {
|
|
170
|
-
if (nodeName === 'swiper') {
|
|
171
|
-
return children.replace(/s-for="{{i\.cn}}"/, 's-for="{{xs.f(i.cn)}}"');
|
|
172
|
-
}
|
|
173
|
-
return children;
|
|
174
|
-
};
|
|
175
|
-
this.modifyTemplateResult = (res, nodeName) => {
|
|
176
|
-
if (nodeName === 'picker-view-column')
|
|
177
|
-
return '';
|
|
178
|
-
return res;
|
|
179
|
-
};
|
|
180
|
-
this.flattenViewLevel = (_a = options === null || options === void 0 ? void 0 : options.flattenViewLevel) !== null && _a !== void 0 ? _a : 8;
|
|
181
|
-
this.flattenCoverLevel = (_b = options === null || options === void 0 ? void 0 : options.flattenCoverLevel) !== null && _b !== void 0 ? _b : 3;
|
|
182
|
-
this.flattenTextLevel = (_c = options === null || options === void 0 ? void 0 : options.flattenTextLevel) !== null && _c !== void 0 ? _c : 3;
|
|
183
|
-
}
|
|
184
|
-
createMiniComponents(components) {
|
|
185
|
-
const result = super.createMiniComponents(components);
|
|
186
|
-
this.legacyMiniComponents = Object.assign({}, result);
|
|
187
|
-
delete result['pure-view'];
|
|
188
|
-
delete result['static-view'];
|
|
189
|
-
return result;
|
|
190
|
-
}
|
|
191
|
-
buildXsTemplate() {
|
|
192
|
-
return '<import-sjs module="xs" src="./utils.sjs" />';
|
|
193
|
-
}
|
|
194
|
-
dataKeymap(keymap) {
|
|
195
|
-
return `{ ${keymap} }`;
|
|
196
|
-
}
|
|
197
|
-
getAttrValue(value, key, nodeName) {
|
|
198
|
-
if (shared.isArray(swanSpecialAttrs[nodeName]) && swanSpecialAttrs[nodeName].includes(key)) {
|
|
199
|
-
return `= ${value} =`;
|
|
200
|
-
}
|
|
201
|
-
return `{${value}}`;
|
|
202
|
-
}
|
|
203
|
-
buildFlattenNodeAttributes(nodeName) {
|
|
204
|
-
const component = this.legacyMiniComponents[nodeName];
|
|
205
|
-
return Object.keys(component)
|
|
206
|
-
.map(k => `${k}="${k.startsWith('bind') || k.startsWith('on') || k.startsWith('catch') ? component[k] : `{{${component[k].replace('i.', 'item.')}}}`}"`)
|
|
207
|
-
.join(' ');
|
|
208
|
-
}
|
|
209
|
-
buildXSTmpExtra() {
|
|
210
|
-
const componentsAlias = this.componentsAlias;
|
|
211
|
-
const swiperAlias = componentsAlias['swiper-item']._num;
|
|
323
|
+
</picker-view-column>`;
|
|
324
|
+
default:
|
|
325
|
+
return child;
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
this.modifyLoopContainer = (children, nodeName) => {
|
|
329
|
+
if (nodeName === 'swiper') {
|
|
330
|
+
return children.replace(/s-for="{{i\.cn}}"/, 's-for="{{xs.f(i.cn)}}"');
|
|
331
|
+
}
|
|
332
|
+
return children;
|
|
333
|
+
};
|
|
334
|
+
this.modifyTemplateResult = (res, nodeName) => {
|
|
335
|
+
if (nodeName === 'picker-view-column')
|
|
336
|
+
return '';
|
|
337
|
+
return res;
|
|
338
|
+
};
|
|
339
|
+
this.flattenViewLevel = (_a = options === null || options === void 0 ? void 0 : options.flattenViewLevel) !== null && _a !== void 0 ? _a : 8;
|
|
340
|
+
this.flattenCoverLevel = (_b = options === null || options === void 0 ? void 0 : options.flattenCoverLevel) !== null && _b !== void 0 ? _b : 3;
|
|
341
|
+
this.flattenTextLevel = (_c = options === null || options === void 0 ? void 0 : options.flattenTextLevel) !== null && _c !== void 0 ? _c : 3;
|
|
342
|
+
}
|
|
343
|
+
createMiniComponents(components) {
|
|
344
|
+
const result = super.createMiniComponents(components);
|
|
345
|
+
this.legacyMiniComponents = Object.assign({}, result);
|
|
346
|
+
delete result['pure-view'];
|
|
347
|
+
delete result['static-view'];
|
|
348
|
+
return result;
|
|
349
|
+
}
|
|
350
|
+
buildXsTemplate() {
|
|
351
|
+
return '<import-sjs module="xs" src="./utils.sjs" />';
|
|
352
|
+
}
|
|
353
|
+
dataKeymap(keymap) {
|
|
354
|
+
return `{ ${keymap} }`;
|
|
355
|
+
}
|
|
356
|
+
getAttrValue(value, key, nodeName) {
|
|
357
|
+
if (shared.isArray(swanSpecialAttrs[nodeName]) && swanSpecialAttrs[nodeName].includes(key)) {
|
|
358
|
+
return `= ${value} =`;
|
|
359
|
+
}
|
|
360
|
+
return `{${value}}`;
|
|
361
|
+
}
|
|
362
|
+
buildFlattenNodeAttributes(nodeName) {
|
|
363
|
+
const component = this.legacyMiniComponents[nodeName];
|
|
364
|
+
return Object.keys(component)
|
|
365
|
+
.map(k => `${k}="${k.startsWith('bind') || k.startsWith('on') || k.startsWith('catch') ? component[k] : `{{${component[k].replace('i.', 'item.')}}}`}"`)
|
|
366
|
+
.join(' ');
|
|
367
|
+
}
|
|
368
|
+
buildXSTmpExtra() {
|
|
369
|
+
const componentsAlias = this.componentsAlias;
|
|
370
|
+
const swiperAlias = componentsAlias['swiper-item']._num;
|
|
212
371
|
return `f: function (l) {
|
|
213
372
|
return l.filter(function (i) {return i.nn === '${swiperAlias}'})
|
|
214
|
-
}`;
|
|
215
|
-
}
|
|
373
|
+
}`;
|
|
374
|
+
}
|
|
216
375
|
}
|
|
217
376
|
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
'
|
|
261
|
-
}
|
|
262
|
-
Textarea: {
|
|
263
|
-
'confirm-type': shared.singleQuote('default'),
|
|
264
|
-
'confirm-hold': 'false',
|
|
265
|
-
'show-confirm-bar': 'true',
|
|
266
|
-
'adjust-position': 'true'
|
|
267
|
-
},
|
|
268
|
-
Navigator: {
|
|
269
|
-
target: shared.singleQuote('self'),
|
|
270
|
-
'app-id': '',
|
|
271
|
-
path: '',
|
|
272
|
-
'extra-data': '',
|
|
273
|
-
version: shared.singleQuote('version')
|
|
274
|
-
},
|
|
275
|
-
Image: {
|
|
276
|
-
webp: 'false',
|
|
277
|
-
'image-menu-prevent': 'false',
|
|
278
|
-
preview: '',
|
|
279
|
-
'original-src': ''
|
|
280
|
-
},
|
|
281
|
-
Video: {
|
|
282
|
-
title: '',
|
|
283
|
-
'show-no-wifi-tip': 'true',
|
|
284
|
-
'vslide-gesture': 'false',
|
|
285
|
-
'vslide-gesture-in-fullscreen': 'true',
|
|
286
|
-
'enable-play-gesture': 'false',
|
|
287
|
-
'show-rate-btn': 'false',
|
|
288
|
-
'show-vslide-btn-in-fullscreen': 'true',
|
|
289
|
-
'silent-play': 'false',
|
|
290
|
-
bindLoadedMetadata: ''
|
|
291
|
-
},
|
|
292
|
-
Ad: {
|
|
293
|
-
appid: '',
|
|
294
|
-
apid: '',
|
|
295
|
-
type: shared.singleQuote('feed'),
|
|
296
|
-
updatetime: '',
|
|
297
|
-
bindStatus: ''
|
|
298
|
-
},
|
|
299
|
-
// ======== 额外组件 ========
|
|
300
|
-
Tabs: {
|
|
301
|
-
'tabs-background-color': shared.singleQuote('#fff'),
|
|
302
|
-
'tabs-active-text-color': shared.singleQuote('#000'),
|
|
303
|
-
'tabs-inactive-text-color': shared.singleQuote('#666'),
|
|
304
|
-
'tabs-underline-color': shared.singleQuote('#333'),
|
|
305
|
-
'active-name': '',
|
|
306
|
-
'url-query-name': '',
|
|
307
|
-
'max-tab-item-amount': '5',
|
|
308
|
-
bindTabChange: ''
|
|
309
|
-
},
|
|
310
|
-
TabItem: {
|
|
311
|
-
label: '',
|
|
312
|
-
name: '',
|
|
313
|
-
'badge-type': '',
|
|
314
|
-
'badge-text': ''
|
|
315
|
-
},
|
|
316
|
-
AnimationVideo: {
|
|
317
|
-
'resource-width': '800',
|
|
318
|
-
'resource-height': '400',
|
|
319
|
-
'canvas-style': shared.singleQuote('width:400px;height:400px'),
|
|
320
|
-
path: '',
|
|
321
|
-
loop: 'fasle',
|
|
322
|
-
autoplay: 'fasle',
|
|
323
|
-
bindStarted: '',
|
|
324
|
-
bindEnded: ''
|
|
325
|
-
},
|
|
326
|
-
AnimationView: {
|
|
327
|
-
path: '',
|
|
328
|
-
loop: 'false',
|
|
329
|
-
autoplay: 'true',
|
|
330
|
-
action: shared.singleQuote('play'),
|
|
331
|
-
hidden: 'true',
|
|
332
|
-
bindEnded: ''
|
|
333
|
-
},
|
|
334
|
-
ArCamera: {
|
|
335
|
-
key: '',
|
|
336
|
-
type: '',
|
|
337
|
-
flash: shared.singleQuote('off'),
|
|
338
|
-
bindError: '',
|
|
339
|
-
bindLoad: '',
|
|
340
|
-
bindMessage: '',
|
|
341
|
-
bindScanCode: ''
|
|
342
|
-
},
|
|
343
|
-
RtcRoom: {
|
|
344
|
-
id: '',
|
|
345
|
-
'enable-camera': 'true',
|
|
346
|
-
'enable-auto-focus': 'true',
|
|
347
|
-
'enable-zoom': 'false',
|
|
348
|
-
'device-position': shared.singleQuote('front'),
|
|
349
|
-
'enable-mic': 'true',
|
|
350
|
-
'enable-agc': 'false',
|
|
351
|
-
'enable-ans': 'false',
|
|
352
|
-
bitrate: '900',
|
|
353
|
-
'video-width': '360',
|
|
354
|
-
'video-height': '640',
|
|
355
|
-
'enable-remote-mirror': 'false',
|
|
356
|
-
'local-mirror': shared.singleQuote('auto'),
|
|
357
|
-
'sound-mode': shared.singleQuote('speaker'),
|
|
358
|
-
bindStateChange: '',
|
|
359
|
-
bindError: ''
|
|
360
|
-
},
|
|
361
|
-
RtcRoomItem: {
|
|
362
|
-
id: '',
|
|
363
|
-
type: '',
|
|
364
|
-
'user-id': ''
|
|
365
|
-
},
|
|
366
|
-
OpenData: {
|
|
367
|
-
type: ''
|
|
368
|
-
},
|
|
369
|
-
Login: {
|
|
370
|
-
'button-class': '',
|
|
371
|
-
bindGetPhoneNumber: '',
|
|
372
|
-
bindLoadError: ''
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
const PACKAGE_NAME = '@tarojs/plugin-platform-swan';
|
|
377
|
-
const PROJECT_JSON = 'project.swan.json';
|
|
378
|
-
class Swan extends service.TaroPlatformBase {
|
|
379
|
-
/**
|
|
380
|
-
* 1. setupTransaction - init
|
|
381
|
-
* 2. setup
|
|
382
|
-
* 3. setupTransaction - close
|
|
383
|
-
* 4. buildTransaction - init
|
|
384
|
-
* 5. build
|
|
385
|
-
* 6. buildTransaction - close
|
|
386
|
-
*/
|
|
387
|
-
constructor(ctx, config) {
|
|
388
|
-
super(ctx, config);
|
|
389
|
-
this.platform = 'swan';
|
|
390
|
-
this.globalObject = 'swan';
|
|
391
|
-
this.runtimePath = `${PACKAGE_NAME}/dist/runtime`;
|
|
392
|
-
this.taroComponentsPath = `${PACKAGE_NAME}/dist/components-react`;
|
|
393
|
-
this.fileType = {
|
|
394
|
-
templ: '.swan',
|
|
395
|
-
style: '.css',
|
|
396
|
-
config: '.json',
|
|
397
|
-
script: '.js',
|
|
398
|
-
xs: '.sjs'
|
|
399
|
-
};
|
|
400
|
-
this.setupTransaction.addWrapper({
|
|
401
|
-
close() {
|
|
402
|
-
this.modifyComponents();
|
|
403
|
-
ctx.generateFrameworkInfo();
|
|
404
|
-
this.generateProjectConfig(PROJECT_JSON, PROJECT_JSON);
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
this.template = new Template({
|
|
408
|
-
flattenViewLevel: config.flattenViewLevel
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* 增加组件或修改组件属性
|
|
413
|
-
*/
|
|
414
|
-
modifyComponents() {
|
|
415
|
-
this.template.mergeComponents(this.ctx, components);
|
|
416
|
-
delete this.template.internalComponents.Input.cursor;
|
|
417
|
-
delete this.template.internalComponents.Input['selection-start'];
|
|
418
|
-
delete this.template.internalComponents.Input['selection-end'];
|
|
419
|
-
}
|
|
377
|
+
const PACKAGE_NAME = '@tarojs/plugin-platform-swan';
|
|
378
|
+
const PROJECT_JSON = 'project.swan.json';
|
|
379
|
+
class Swan extends service.TaroPlatformBase {
|
|
380
|
+
/**
|
|
381
|
+
* 1. setupTransaction - init
|
|
382
|
+
* 2. setup
|
|
383
|
+
* 3. setupTransaction - close
|
|
384
|
+
* 4. buildTransaction - init
|
|
385
|
+
* 5. build
|
|
386
|
+
* 6. buildTransaction - close
|
|
387
|
+
*/
|
|
388
|
+
constructor(ctx, config) {
|
|
389
|
+
super(ctx, config);
|
|
390
|
+
this.platform = 'swan';
|
|
391
|
+
this.globalObject = 'swan';
|
|
392
|
+
this.runtimePath = `${PACKAGE_NAME}/dist/runtime`;
|
|
393
|
+
this.taroComponentsPath = `${PACKAGE_NAME}/dist/components-react`;
|
|
394
|
+
this.fileType = {
|
|
395
|
+
templ: '.swan',
|
|
396
|
+
style: '.css',
|
|
397
|
+
config: '.json',
|
|
398
|
+
script: '.js',
|
|
399
|
+
xs: '.sjs'
|
|
400
|
+
};
|
|
401
|
+
this.setupTransaction.addWrapper({
|
|
402
|
+
close() {
|
|
403
|
+
this.modifyComponents();
|
|
404
|
+
ctx.generateFrameworkInfo();
|
|
405
|
+
this.generateProjectConfig(PROJECT_JSON, PROJECT_JSON);
|
|
406
|
+
}
|
|
407
|
+
});
|
|
408
|
+
this.template = new Template({
|
|
409
|
+
flattenViewLevel: config.flattenViewLevel
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* 增加组件或修改组件属性
|
|
414
|
+
*/
|
|
415
|
+
modifyComponents() {
|
|
416
|
+
this.template.mergeComponents(this.ctx, components);
|
|
417
|
+
delete this.template.internalComponents.Input.cursor;
|
|
418
|
+
delete this.template.internalComponents.Input['selection-start'];
|
|
419
|
+
delete this.template.internalComponents.Input['selection-end'];
|
|
420
|
+
}
|
|
420
421
|
}
|
|
421
422
|
|
|
422
|
-
var index = (ctx) => {
|
|
423
|
-
ctx.registerPlatform({
|
|
424
|
-
name: 'swan',
|
|
425
|
-
useConfigName: 'mini',
|
|
426
|
-
fn({ config }) {
|
|
427
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
428
|
-
const program = new Swan(ctx, config);
|
|
429
|
-
yield program.start();
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
});
|
|
423
|
+
var index = (ctx) => {
|
|
424
|
+
ctx.registerPlatform({
|
|
425
|
+
name: 'swan',
|
|
426
|
+
useConfigName: 'mini',
|
|
427
|
+
fn({ config }) {
|
|
428
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
429
|
+
const program = new Swan(ctx, config);
|
|
430
|
+
yield program.start();
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
});
|
|
433
434
|
};
|
|
434
435
|
|
|
435
436
|
exports.Swan = Swan;
|