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