@dcloudio/uni-cli-shared 2.0.2-4030620241128001 → 2.0.2-4040420241231001
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/components/ad-fullscreen-video.vue +2 -1
- package/components/ad-interstitial.vue +2 -1
- package/components/ad-rewarded-video.vue +4 -3
- package/components/ad.mixin.mp-weixin.js +245 -28
- package/components/uniad.vue +13 -2
- package/components/unicloud-db.vue +1 -1
- package/lib/preprocess.js +8 -8
- package/lib/uts/uts.js +56 -28
- package/package.json +2 -2
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
<view @click="_onclick">
|
|
3
3
|
<slot :options="options" :loading="loading" :error="errorMessage" />
|
|
4
4
|
<!-- #ifdef MP-WEIXIN -->
|
|
5
|
-
<uniad-plugin class="uniad-plugin" :adpid="adpid" :unit-id="unitId" @load="_onmpload" @close="_onmpclose" @error="_onmperror"></uniad-plugin>
|
|
5
|
+
<uniad-plugin class="uniad-plugin" :adpid="adpid" :unit-id="unitId" @load="_onmpload" @close="_onmpclose" @error="_onmperror" @nextChannel="_onnextchannel"></uniad-plugin>
|
|
6
|
+
<uniad-plugin-wx v-if="wxchannel" class="uniad-plugin-wx" @error="_onwxchannelerror"></uniad-plugin-wx>
|
|
6
7
|
<!-- #endif -->
|
|
7
8
|
<!-- #ifdef MP-ALIPAY -->
|
|
8
9
|
<uniad-plugin class="uniad-plugin" :adpid="adpid" @create="_handleAdRef" @load="_onmpload" @close="_onmpclose" @error="_onmperror"></uniad-plugin>
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
<view @click="_onclick">
|
|
3
3
|
<slot :options="options" :loading="loading" :error="errorMessage" />
|
|
4
4
|
<!-- #ifdef MP-WEIXIN -->
|
|
5
|
-
<uniad-plugin class="uniad-plugin" :adpid="adpid" :unit-id="unitId" @load="_onmpload" @close="_onmpclose" @error="_onmperror"></uniad-plugin>
|
|
5
|
+
<uniad-plugin class="uniad-plugin" :adpid="adpid" :unit-id="unitId" @load="_onmpload" @close="_onmpclose" @error="_onmperror" @nextChannel="_onnextchannel"></uniad-plugin>
|
|
6
|
+
<uniad-plugin-wx v-if="wxchannel" class="uniad-plugin-wx" @error="_onwxchannelerror"></uniad-plugin-wx>
|
|
6
7
|
<!-- #endif -->
|
|
7
8
|
<!-- #ifdef MP-ALIPAY -->
|
|
8
9
|
<uniad-plugin class="uniad-plugin" :adpid="adpid" @create="_handleAdRef" @load="_onmpload" @close="_onmpclose" @error="_onmperror"></uniad-plugin>
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view @click="_onclick">
|
|
3
|
-
<slot :options="options" :loading="loading" :error="errorMessage" />
|
|
4
|
-
<!-- #ifdef MP-WEIXIN -->
|
|
5
|
-
<uniad-plugin class="uniad-plugin" :adpid="adpid" :unit-id="unitId" @load="_onmpload" @close="_onmpclose" @error="_onmperror"></uniad-plugin>
|
|
3
|
+
<slot :options="options" :loading="loading" :error="errorMessage" />
|
|
4
|
+
<!-- #ifdef MP-WEIXIN -->
|
|
5
|
+
<uniad-plugin class="uniad-plugin" :adpid="adpid" :unit-id="unitId" @load="_onmpload" @close="_onmpclose" @error="_onmperror" @nextChannel="_onnextchannel"></uniad-plugin>
|
|
6
|
+
<uniad-plugin-wx v-if="wxchannel" class="uniad-plugin-wx" @error="_onwxchannelerror"></uniad-plugin-wx>
|
|
6
7
|
<!-- #endif -->
|
|
7
8
|
<!-- #ifdef MP-ALIPAY -->
|
|
8
9
|
<uniad-plugin class="uniad-plugin" :adpid="adpid" @create="_handleAdRef" @load="_onmpload" @close="_onmpclose" @error="_onmperror"></uniad-plugin>
|
|
@@ -1,9 +1,24 @@
|
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
const adPlugin = requirePlugin('uni-ad')
|
|
3
|
+
|
|
1
4
|
const EventType = {
|
|
2
5
|
Load: 'load',
|
|
3
6
|
Close: 'close',
|
|
4
7
|
Error: 'error'
|
|
5
8
|
}
|
|
6
9
|
|
|
10
|
+
const AdType = {
|
|
11
|
+
Banner: 'banner',
|
|
12
|
+
RewardedVideo: 'rewardedVideo',
|
|
13
|
+
Interstitial: 'interstitial'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const ProviderType = {
|
|
17
|
+
WeChat: 10018,
|
|
18
|
+
UserWeChat: 10017,
|
|
19
|
+
ShanHu: 10020
|
|
20
|
+
}
|
|
21
|
+
|
|
7
22
|
export default {
|
|
8
23
|
props: {
|
|
9
24
|
options: {
|
|
@@ -38,13 +53,21 @@ export default {
|
|
|
38
53
|
data () {
|
|
39
54
|
return {
|
|
40
55
|
loading: false,
|
|
56
|
+
userwx: false,
|
|
57
|
+
userUnitId: '',
|
|
58
|
+
customFullscreen: '',
|
|
59
|
+
wxchannel: false,
|
|
41
60
|
errorMessage: null
|
|
42
61
|
}
|
|
43
62
|
},
|
|
44
63
|
created () {
|
|
45
64
|
this._ad = null
|
|
46
|
-
|
|
47
|
-
|
|
65
|
+
this._loading = false
|
|
66
|
+
this._wxRewardedAd = null
|
|
67
|
+
this._wxInterstitialAd = null
|
|
68
|
+
this._providerType = ProviderType.ShanHu
|
|
69
|
+
if (this.preload && this._canCreateAd()) {
|
|
70
|
+
this.load()
|
|
48
71
|
}
|
|
49
72
|
},
|
|
50
73
|
methods: {
|
|
@@ -53,35 +76,22 @@ export default {
|
|
|
53
76
|
return
|
|
54
77
|
}
|
|
55
78
|
this._startLoading()
|
|
79
|
+
if (this._providerType === ProviderType.ShanHu) {
|
|
80
|
+
} else if (this._providerType === ProviderType.WeChat) {
|
|
81
|
+
this.selectComponent('.uniad-plugin-wx').load()
|
|
82
|
+
} else if (this._providerType === ProviderType.UserWeChat) {
|
|
83
|
+
this._loadWxAd()
|
|
84
|
+
}
|
|
56
85
|
},
|
|
57
86
|
|
|
58
|
-
show () {
|
|
87
|
+
show (e) {
|
|
59
88
|
this.errorMessage = null
|
|
60
|
-
this.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
iv,
|
|
67
|
-
version,
|
|
68
|
-
expireTime
|
|
69
|
-
}) => {
|
|
70
|
-
this._ad.show({
|
|
71
|
-
userId: this.urlCallback.userId || '',
|
|
72
|
-
extra: this.urlCallback.extra || '',
|
|
73
|
-
encryptKey,
|
|
74
|
-
iv,
|
|
75
|
-
version,
|
|
76
|
-
expireTime
|
|
77
|
-
})
|
|
78
|
-
},
|
|
79
|
-
fail: (err) => {
|
|
80
|
-
this._dispatchEvent(EventType.Error, err)
|
|
81
|
-
}
|
|
82
|
-
})
|
|
83
|
-
} else {
|
|
84
|
-
this._ad.show()
|
|
89
|
+
if (this._providerType === ProviderType.ShanHu) {
|
|
90
|
+
this._showAdInPlugin(this.selectComponent('.uniad-plugin'))
|
|
91
|
+
} else if (this._providerType === ProviderType.WeChat) {
|
|
92
|
+
this._showAdInPlugin(this.selectComponent('.uniad-plugin-wx'))
|
|
93
|
+
} else if (this._providerType === ProviderType.UserWeChat) {
|
|
94
|
+
this._showWxAd(e)
|
|
85
95
|
}
|
|
86
96
|
},
|
|
87
97
|
|
|
@@ -148,10 +158,217 @@ export default {
|
|
|
148
158
|
this._dispatchEvent(EventType.Error, e.detail)
|
|
149
159
|
},
|
|
150
160
|
|
|
161
|
+
_onnextchannel (e) {
|
|
162
|
+
this.wxchannel = true
|
|
163
|
+
const adData = e.detail[0]
|
|
164
|
+
this.$nextTick(() => {
|
|
165
|
+
if (adData.provider === 10017) {
|
|
166
|
+
this._providerType = ProviderType.UserWeChat
|
|
167
|
+
switch (adData._nt_) {
|
|
168
|
+
case 4:
|
|
169
|
+
this.wxAdType = AdType.Banner
|
|
170
|
+
this.userwx = true
|
|
171
|
+
this.userUnitId = adData.posid
|
|
172
|
+
if (adData.tmpl_type === 24) {
|
|
173
|
+
this.customFullscreen = 'uni-ad-custom-fullscreen'
|
|
174
|
+
}
|
|
175
|
+
break
|
|
176
|
+
case 9:
|
|
177
|
+
this.wxAdType = AdType.RewardedVideo
|
|
178
|
+
this._createRewardedAd(adData.posid)
|
|
179
|
+
break
|
|
180
|
+
case 15:
|
|
181
|
+
this.wxAdType = AdType.Interstitial
|
|
182
|
+
this._createInterstitialAd(adData.posid)
|
|
183
|
+
break
|
|
184
|
+
}
|
|
185
|
+
} else if (adData.provider === 10018) {
|
|
186
|
+
this._providerType = ProviderType.WeChat
|
|
187
|
+
this.selectComponent('.uniad-plugin-wx').setConfig(adData)
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
_onwxchannelerror (e) {
|
|
193
|
+
this.wxchannel = false
|
|
194
|
+
this.$nextTick(() => {
|
|
195
|
+
this._providerType = ProviderType.ShanHu
|
|
196
|
+
this.selectComponent('.uniad-plugin').shanhuChannel()
|
|
197
|
+
})
|
|
198
|
+
},
|
|
199
|
+
|
|
151
200
|
_dispatchEvent (type, data) {
|
|
152
201
|
this.$emit(type, {
|
|
153
202
|
detail: data
|
|
154
203
|
})
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
_showAdInPlugin (adComponent) {
|
|
207
|
+
if (this._hasCallback()) {
|
|
208
|
+
const userCryptoManager = wx.getUserCryptoManager()
|
|
209
|
+
userCryptoManager.getLatestUserKey({
|
|
210
|
+
success: ({
|
|
211
|
+
encryptKey,
|
|
212
|
+
iv,
|
|
213
|
+
version,
|
|
214
|
+
expireTime
|
|
215
|
+
}) => {
|
|
216
|
+
adComponent.show({
|
|
217
|
+
userId: this.urlCallback.userId || '',
|
|
218
|
+
extra: this.urlCallback.extra || '',
|
|
219
|
+
encryptKey,
|
|
220
|
+
iv,
|
|
221
|
+
version,
|
|
222
|
+
expireTime
|
|
223
|
+
})
|
|
224
|
+
},
|
|
225
|
+
fail: (err) => {
|
|
226
|
+
this._dispatchEvent(EventType.Error, err)
|
|
227
|
+
}
|
|
228
|
+
})
|
|
229
|
+
} else {
|
|
230
|
+
adComponent.show({
|
|
231
|
+
userId: this.urlCallback.userId || '',
|
|
232
|
+
extra: this.urlCallback.extra || ''
|
|
233
|
+
})
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
_loadWxAd () {
|
|
238
|
+
switch (this.wxAdType) {
|
|
239
|
+
case AdType.RewardedVideo:
|
|
240
|
+
if (this._wxRewardedAd) {
|
|
241
|
+
this._wxRewardedAd.load()
|
|
242
|
+
}
|
|
243
|
+
break
|
|
244
|
+
case AdType.Interstitial:
|
|
245
|
+
if (this._wxInterstitialAd) {
|
|
246
|
+
this._wxInterstitialAd.load()
|
|
247
|
+
}
|
|
248
|
+
break
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
|
|
252
|
+
// 加载/显示广告
|
|
253
|
+
_showWxAd (options) {
|
|
254
|
+
this._urlCallback = options || this.urlCallback
|
|
255
|
+
if (this.loading === true) {
|
|
256
|
+
this._userInvokeShowFlag = true
|
|
257
|
+
return
|
|
258
|
+
}
|
|
259
|
+
switch (this.wxAdType) {
|
|
260
|
+
case AdType.RewardedVideo:
|
|
261
|
+
if (!this._wxRewardedAd) {
|
|
262
|
+
return
|
|
263
|
+
}
|
|
264
|
+
// eslint-disable-next-line handle-callback-err
|
|
265
|
+
this._wxRewardedAd.show().catch((err) => {
|
|
266
|
+
this._wxRewardedAd.load().then(() => {
|
|
267
|
+
this._wxRewardedAd.show()
|
|
268
|
+
}).catch((err) => {
|
|
269
|
+
this._dispatchEvent(EventType.Error, err)
|
|
270
|
+
})
|
|
271
|
+
})
|
|
272
|
+
break
|
|
273
|
+
case AdType.Interstitial:
|
|
274
|
+
if (!this._wxInterstitialAd) {
|
|
275
|
+
return
|
|
276
|
+
}
|
|
277
|
+
// eslint-disable-next-line handle-callback-err
|
|
278
|
+
this._wxInterstitialAd.show().catch((err) => {
|
|
279
|
+
this._wxInterstitialAd.load().then(() => {
|
|
280
|
+
this._wxInterstitialAd.show()
|
|
281
|
+
}).catch((err) => {
|
|
282
|
+
this._dispatchEvent(EventType.Error, err)
|
|
283
|
+
})
|
|
284
|
+
})
|
|
285
|
+
break
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
// 微信激励视频
|
|
290
|
+
_createRewardedAd (adUnitId) {
|
|
291
|
+
if (this._wxRewardedAd) {
|
|
292
|
+
return
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
this._wxRewardedAd = wx.createRewardedVideoAd({ adUnitId: adUnitId, multiton: true })
|
|
296
|
+
|
|
297
|
+
this._wxRewardedAd.onLoad(() => {
|
|
298
|
+
this.loading = false
|
|
299
|
+
this._dispatchEvent(EventType.Load, {})
|
|
300
|
+
if (this._userInvokeShowFlag) {
|
|
301
|
+
this._userInvokeShowFlag = false
|
|
302
|
+
this._wxRewardedAd.show()
|
|
303
|
+
}
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
this._wxRewardedAd.onError(err => {
|
|
307
|
+
this.loading = false
|
|
308
|
+
this._dispatchEvent(EventType.Error, err)
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
this._wxRewardedAd.onClose(res => {
|
|
312
|
+
if (res.isEnded) {
|
|
313
|
+
this._callServer()
|
|
314
|
+
} else {
|
|
315
|
+
this._dispatchEvent(EventType.Close, res)
|
|
316
|
+
}
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
this.loading = true
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
// 微信插屏
|
|
323
|
+
_createInterstitialAd (adUnitId) {
|
|
324
|
+
if (this._wxInterstitialAd) {
|
|
325
|
+
return
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
this._wxInterstitialAd = wx.createInterstitialAd({ adUnitId: adUnitId })
|
|
329
|
+
|
|
330
|
+
this._wxInterstitialAd.onLoad(() => {
|
|
331
|
+
this.loading = false
|
|
332
|
+
this._dispatchEvent(EventType.Load, {})
|
|
333
|
+
if (this._userInvokeShowFlag) {
|
|
334
|
+
this._userInvokeShowFlag = false
|
|
335
|
+
this._wxInterstitialAd.show()
|
|
336
|
+
}
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
this._wxInterstitialAd.onError(err => {
|
|
340
|
+
this.loading = false
|
|
341
|
+
this._dispatchEvent(EventType.Error, err)
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
this._wxInterstitialAd.onClose(res => {
|
|
345
|
+
this._dispatchEvent(EventType.Close, res)
|
|
346
|
+
})
|
|
347
|
+
|
|
348
|
+
this.loading = true
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
_callServer () {
|
|
352
|
+
const userCryptoManager = wx.getUserCryptoManager()
|
|
353
|
+
userCryptoManager.getLatestUserKey({
|
|
354
|
+
success: (encryptConfig) => {
|
|
355
|
+
const callbackData = adPlugin.buildCallbackData(this.adpid, this.urlCallback, {}, encryptConfig)
|
|
356
|
+
uniCloud.callFunction({
|
|
357
|
+
name: 'uniAdCallback',
|
|
358
|
+
data: callbackData,
|
|
359
|
+
secretType: 'both',
|
|
360
|
+
success: (res) => {
|
|
361
|
+
this._dispatchEvent(EventType.Close, res)
|
|
362
|
+
},
|
|
363
|
+
fail: (err) => {
|
|
364
|
+
this._dispatchEvent(EventType.Error, err)
|
|
365
|
+
}
|
|
366
|
+
})
|
|
367
|
+
},
|
|
368
|
+
fail: (err) => {
|
|
369
|
+
this._dispatchEvent(EventType.Error, err)
|
|
370
|
+
}
|
|
371
|
+
})
|
|
155
372
|
}
|
|
156
373
|
}
|
|
157
374
|
}
|
package/components/uniad.vue
CHANGED
|
@@ -5,8 +5,13 @@
|
|
|
5
5
|
:adpid="adpid"
|
|
6
6
|
@load="_onmpload"
|
|
7
7
|
@close="_onmpclose"
|
|
8
|
-
@error="_onmperror"
|
|
9
|
-
|
|
8
|
+
@error="_onmperror"
|
|
9
|
+
@nextChannel="_onnextchannel"
|
|
10
|
+
/>
|
|
11
|
+
<!-- #ifdef MP-WEIXIN -->
|
|
12
|
+
<ad-custom v-if="userwx" :unit-id="userUnitId" class="uni-ad-custom" :class="[customFullscreen]"></ad-custom>
|
|
13
|
+
<uniad-plugin-wx v-if="wxchannel" class="uniad-plugin-wx" @error="_onwxchannelerror"></uniad-plugin-wx>
|
|
14
|
+
<!-- #endif -->
|
|
10
15
|
</view>
|
|
11
16
|
</template>
|
|
12
17
|
|
|
@@ -26,3 +31,9 @@ export default {
|
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
33
|
</script>
|
|
34
|
+
|
|
35
|
+
<style>
|
|
36
|
+
.uni-ad-custom-fullscreen {
|
|
37
|
+
height: 100vh;
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
@@ -393,7 +393,7 @@
|
|
|
393
393
|
needLoading: true,
|
|
394
394
|
loadingTitle: ''
|
|
395
395
|
}, options);
|
|
396
|
-
if (
|
|
396
|
+
if (options.needConfirm) {
|
|
397
397
|
uni.showModal({
|
|
398
398
|
title: options.confirmTitle || t('uniCloud.component.update.showModal.title'),
|
|
399
399
|
content: options.confirmContent || t('uniCloud.component.update.showModal.content'),
|
package/lib/preprocess.js
CHANGED
|
@@ -52,14 +52,14 @@ module.exports = function initPreprocess (name, platforms, userDefines = {}) {
|
|
|
52
52
|
nvueContext.APP_NVUE = true
|
|
53
53
|
nvueContext.APP_PLUS_NVUE = true
|
|
54
54
|
|
|
55
|
-
if (process.env.UNI_APP_PLATFORM === 'android') {
|
|
56
|
-
|
|
57
|
-
} else if (process.env.UNI_APP_PLATFORM === 'ios') {
|
|
58
|
-
|
|
59
|
-
} else {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
55
|
+
// if (process.env.UNI_APP_PLATFORM === 'android') {
|
|
56
|
+
// defaultContext.APP_ANDROID = true
|
|
57
|
+
// } else if (process.env.UNI_APP_PLATFORM === 'ios') {
|
|
58
|
+
// defaultContext.APP_IOS = true
|
|
59
|
+
// } else {
|
|
60
|
+
// defaultContext.APP_ANDROID = true
|
|
61
|
+
// defaultContext.APP_IOS = true
|
|
62
|
+
// }
|
|
63
63
|
}
|
|
64
64
|
if (name === 'h5') {
|
|
65
65
|
defaultContext.WEB = true
|
package/lib/uts/uts.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.tscOutDir = exports.uvueOutDir = exports.genUniExtApiDeclarationFileOnce = exports.initUTSSwiftAutoImportsOnce = exports.initUTSKotlinAutoImportsOnce = exports.resolveUniTypeScript = exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.getUTSComponentAutoImports = exports.isUTSComponent = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
|
|
6
|
+
exports.isUniHelpers = exports.isUTSProxy = exports.tscOutDir = exports.uvueOutDir = exports.genUniExtApiDeclarationFileOnce = exports.initUTSSwiftAutoImportsOnce = exports.initUTSKotlinAutoImportsOnce = exports.resolveUniTypeScript = exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.getUTSComponentAutoImports = exports.isUTSComponent = exports.resolveUTSCompilerVersion = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
|
|
7
7
|
// 重要,该文件编译后的 js 需要同步到 vue2 编译器 uni-cli-shared/lib/uts
|
|
8
8
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -105,8 +105,12 @@ function resolveUTSFile(dir, extensions = ['.uts', '.ts', '.js']) {
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
function resolveUTSCompiler() {
|
|
108
|
+
function resolveUTSCompiler(throwError = false) {
|
|
109
109
|
let compilerPath = '';
|
|
110
|
+
if (process.env.UNI_COMPILE_TARGET === 'ext-api' &&
|
|
111
|
+
process.env.UNI_APP_NEXT_WORKSPACE) {
|
|
112
|
+
return require(path_1.default.resolve(process.env.UNI_APP_NEXT_WORKSPACE, 'packages/uni-uts-v1'));
|
|
113
|
+
}
|
|
110
114
|
if ((0, hbx_1.isInHBuilderX)()) {
|
|
111
115
|
try {
|
|
112
116
|
compilerPath = require.resolve(path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'uniapp-uts-v1'));
|
|
@@ -120,27 +124,34 @@ function resolveUTSCompiler() {
|
|
|
120
124
|
});
|
|
121
125
|
}
|
|
122
126
|
catch (e) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
utsCompilerVersion = require('../package.json').version;
|
|
126
|
-
}
|
|
127
|
-
catch (e) {
|
|
128
|
-
try {
|
|
129
|
-
// vue2
|
|
130
|
-
utsCompilerVersion = require('../../package.json').version;
|
|
131
|
-
}
|
|
132
|
-
catch (e) { }
|
|
133
|
-
}
|
|
134
|
-
if (utsCompilerVersion.startsWith('2.0.')) {
|
|
135
|
-
utsCompilerVersion = '^3.0.0-alpha-3060920221117001';
|
|
127
|
+
if (throwError) {
|
|
128
|
+
throw `Error: Cannot find module '@dcloudio/uni-uts-v1'`;
|
|
136
129
|
}
|
|
137
|
-
console.error((0, utils_1.installDepTips)('devDependencies', '@dcloudio/uni-uts-v1',
|
|
130
|
+
console.error((0, utils_1.installDepTips)('devDependencies', '@dcloudio/uni-uts-v1', resolveUTSCompilerVersion()));
|
|
138
131
|
process.exit(0);
|
|
139
132
|
}
|
|
140
133
|
}
|
|
141
134
|
return require(compilerPath);
|
|
142
135
|
}
|
|
143
136
|
exports.resolveUTSCompiler = resolveUTSCompiler;
|
|
137
|
+
function resolveUTSCompilerVersion() {
|
|
138
|
+
let utsCompilerVersion = '';
|
|
139
|
+
try {
|
|
140
|
+
utsCompilerVersion = require('../package.json').version;
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
try {
|
|
144
|
+
// vue2
|
|
145
|
+
utsCompilerVersion = require('../../package.json').version;
|
|
146
|
+
}
|
|
147
|
+
catch (e) { }
|
|
148
|
+
}
|
|
149
|
+
if (utsCompilerVersion.startsWith('2.0.')) {
|
|
150
|
+
utsCompilerVersion = '^3.0.0-alpha-3060920221117001';
|
|
151
|
+
}
|
|
152
|
+
return utsCompilerVersion;
|
|
153
|
+
}
|
|
154
|
+
exports.resolveUTSCompilerVersion = resolveUTSCompilerVersion;
|
|
144
155
|
const utsComponents = new Map();
|
|
145
156
|
function isUTSComponent(name) {
|
|
146
157
|
return utsComponents.has(name);
|
|
@@ -189,9 +200,14 @@ function initUTSComponents(inputDir, platform) {
|
|
|
189
200
|
? path_1.default.basename(path_1.default.dirname(dir))
|
|
190
201
|
: path_1.default.basename(dir);
|
|
191
202
|
if (is_uni_modules_utssdk || is_ussdk) {
|
|
203
|
+
// dir 是 uni_modules/test-plugin/utssdk 或者 utssdk/test-plugin
|
|
204
|
+
// 需要分平台解析,不能直接解析 utssdk 目录下的文件,因为 utssdk 目录下可能存在多个平台的文件
|
|
205
|
+
const cwd = isApp
|
|
206
|
+
? dir
|
|
207
|
+
: path_1.default.join(dir, platform === 'h5' ? 'web' : platform);
|
|
192
208
|
fast_glob_1.default
|
|
193
209
|
.sync('**/*.vue', {
|
|
194
|
-
cwd
|
|
210
|
+
cwd,
|
|
195
211
|
absolute: true,
|
|
196
212
|
})
|
|
197
213
|
.forEach((file) => {
|
|
@@ -235,17 +251,19 @@ exports.initUTSComponents = initUTSComponents;
|
|
|
235
251
|
function resolveUTSComponentDirs(inputDir) {
|
|
236
252
|
const utssdkDir = path_1.default.resolve(inputDir, 'utssdk');
|
|
237
253
|
const uniModulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
|
238
|
-
return
|
|
239
|
-
.sync('*', {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
.concat(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
254
|
+
return (fs_extra_1.default.existsSync(utssdkDir)
|
|
255
|
+
? fast_glob_1.default.sync('*', {
|
|
256
|
+
cwd: utssdkDir,
|
|
257
|
+
absolute: true,
|
|
258
|
+
onlyDirectories: true,
|
|
259
|
+
})
|
|
260
|
+
: []).concat(fs_extra_1.default.existsSync(uniModulesDir)
|
|
261
|
+
? fast_glob_1.default.sync('*/utssdk', {
|
|
262
|
+
cwd: uniModulesDir,
|
|
263
|
+
absolute: true,
|
|
264
|
+
onlyDirectories: true,
|
|
265
|
+
})
|
|
266
|
+
: []);
|
|
249
267
|
}
|
|
250
268
|
const nameRE = /name\s*:\s*['|"](.*)['|"]/;
|
|
251
269
|
function parseVueComponentName(file) {
|
|
@@ -434,3 +452,13 @@ function tscOutDir(platform) {
|
|
|
434
452
|
return path_1.default.join(process.env.UNI_APP_X_TSC_DIR, platform);
|
|
435
453
|
}
|
|
436
454
|
exports.tscOutDir = tscOutDir;
|
|
455
|
+
const UTSProxyRE = /\?uts-proxy$/;
|
|
456
|
+
const UniHelpersRE = /\?uni_helpers$/;
|
|
457
|
+
function isUTSProxy(id) {
|
|
458
|
+
return UTSProxyRE.test(id);
|
|
459
|
+
}
|
|
460
|
+
exports.isUTSProxy = isUTSProxy;
|
|
461
|
+
function isUniHelpers(id) {
|
|
462
|
+
return UniHelpersRE.test(id);
|
|
463
|
+
}
|
|
464
|
+
exports.isUniHelpers = isUniHelpers;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "2.0.2-
|
|
3
|
+
"version": "2.0.2-4040420241231001",
|
|
4
4
|
"description": "uni-cli-shared",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"postcss-urlrewrite": "^0.2.2",
|
|
28
28
|
"strip-json-comments": "^2.0.1"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "f5a282a67f3eda3204e8fa48882b129f47c17cd3"
|
|
31
31
|
}
|