@dcloudio/uni-cli-shared 2.0.2-alpha-4070620250731001 → 2.0.2-alpha-4080120250905001

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.
@@ -199,14 +199,17 @@ export default {
199
199
  if (adData.tmpl_type === 24) {
200
200
  this.customFullscreen = 'uni-ad-custom-fullscreen'
201
201
  }
202
- this.loading = true
202
+ this.loading = true
203
+ if (!adData.dcloudAdpid) {
204
+ adData.dcloudAdpid = this.adpid
205
+ }
203
206
  this.selectComponent('.uniad-plugin-wx').setConfig(adData)
204
207
  }
205
208
  })
206
209
  },
207
210
 
208
211
  _onwxchannelerror (e) {
209
- this._dispatchEvent(EventType.Error, e.detail)
212
+ this._dispatchEvent(EventType.Error, e.detail || e)
210
213
  },
211
214
 
212
215
  _dispatchEvent (type, data) {
@@ -224,14 +227,18 @@ export default {
224
227
  iv,
225
228
  version,
226
229
  expireTime
227
- }) => {
230
+ }) => {
231
+ const uniOptions = {
232
+ adpid: this.adpid
233
+ }
228
234
  adComponent.show({
229
235
  userId: this.urlCallback.userId || '',
230
236
  extra: this.urlCallback.extra || '',
231
237
  encryptKey,
232
238
  iv,
233
239
  version,
234
- expireTime
240
+ expireTime,
241
+ uniOptions
235
242
  })
236
243
  },
237
244
  fail: (err) => {
@@ -250,12 +257,16 @@ export default {
250
257
  switch (this.wxAdType) {
251
258
  case AdType.RewardedVideo:
252
259
  if (this._wxRewardedAd) {
253
- this._wxRewardedAd.load()
260
+ this._wxRewardedAd.load().catch((err) => {
261
+ this._dispatchEvent(EventType.Error, err)
262
+ })
254
263
  }
255
264
  break
256
265
  case AdType.Interstitial:
257
266
  if (this._wxInterstitialAd) {
258
- this._wxInterstitialAd.load()
267
+ this._wxInterstitialAd.load().catch((err) => {
268
+ this._dispatchEvent(EventType.Error, err)
269
+ })
259
270
  }
260
271
  break
261
272
  }
@@ -275,11 +286,7 @@ export default {
275
286
  }
276
287
  // eslint-disable-next-line handle-callback-err
277
288
  this._wxRewardedAd.show().catch((err) => {
278
- this._wxRewardedAd.load().then(() => {
279
- this._wxRewardedAd.show()
280
- }).catch((err) => {
281
- this._dispatchEvent(EventType.Error, err)
282
- })
289
+ this._dispatchEvent(EventType.Error, err)
283
290
  })
284
291
  break
285
292
  case AdType.Interstitial:
@@ -288,11 +295,7 @@ export default {
288
295
  }
289
296
  // eslint-disable-next-line handle-callback-err
290
297
  this._wxInterstitialAd.show().catch((err) => {
291
- this._wxInterstitialAd.load().then(() => {
292
- this._wxInterstitialAd.show()
293
- }).catch((err) => {
294
- this._dispatchEvent(EventType.Error, err)
295
- })
298
+ this._dispatchEvent(EventType.Error, err)
296
299
  })
297
300
  break
298
301
  }
@@ -326,8 +329,6 @@ export default {
326
329
  this._callServer()
327
330
  }
328
331
  })
329
-
330
- this._wxRewardedAd.load().then(() => { }).catch((_) => { })
331
332
 
332
333
  this.loading = true
333
334
  },
@@ -345,7 +346,9 @@ export default {
345
346
  this._dispatchEvent(EventType.Load, {})
346
347
  if (this._userInvokeShowFlag) {
347
348
  this._userInvokeShowFlag = false
348
- this._wxInterstitialAd.show()
349
+ this._wxInterstitialAd.show().catch((err) => {
350
+ this._dispatchEvent(EventType.Error, err)
351
+ })
349
352
  }
350
353
  })
351
354
 
@@ -358,7 +361,9 @@ export default {
358
361
  this._dispatchEvent(EventType.Close, res)
359
362
  })
360
363
 
361
- this._wxInterstitialAd.load().then(() => { }).catch((_) => { })
364
+ this._wxInterstitialAd.load().catch((err) => {
365
+ this._dispatchEvent(EventType.Error, err)
366
+ })
362
367
 
363
368
  this.loading = true
364
369
  },
@@ -59,12 +59,36 @@ function createUniModulesSyncFilePreprocessor (
59
59
  } else if (extname === '.uts' || extname === '.ts') {
60
60
  return preJs(content)
61
61
  } else if (extname === '.uvue' || extname === '.vue') {
62
- return preJs(preHtml(content))
62
+ return preUTSSDKVueFile(fileName, preJs(preHtml(content)))
63
63
  }
64
64
  return content
65
65
  }
66
66
  }
67
67
 
68
+ function preUTSSDKVueFile (filename, content) {
69
+ if (
70
+ filename.includes('utssdk') &&
71
+ (filename.includes('app-android') || filename.includes('app-ios'))
72
+ ) {
73
+ const {
74
+ parseComponent
75
+ } = require('vue-template-compiler')
76
+ const descriptor = parseComponent(content, {
77
+ sourceMap: false,
78
+ pad: 'line'
79
+ })
80
+ if (descriptor.script?.content) {
81
+ return (
82
+ descriptor.script.content +
83
+ // 补充 template 内容
84
+ `/*${descriptor.template?.content}*/`
85
+ )
86
+ }
87
+ return content
88
+ }
89
+ return content
90
+ }
91
+
68
92
  function once (fn, ctx = null) {
69
93
  let res
70
94
  return (...args) => {
@@ -96,7 +120,8 @@ module.exports = async function (content) {
96
120
 
97
121
  const {
98
122
  syncUniModuleFilesByCompiler,
99
- resolveTscUniModuleIndexFileName
123
+ resolveTscUniModuleIndexFileName,
124
+ resolveTscUniModuleUTSSDKVueFileNames
100
125
  } = resolveUTSCompiler()
101
126
 
102
127
  const compilePlugin = async (pluginDir) => {
@@ -127,8 +152,16 @@ module.exports = async function (content) {
127
152
  if (!utsPlugins.has(pluginId)) {
128
153
  utsPlugins.add(pluginId)
129
154
  if (uniXKotlinCompiler) {
155
+ const platform = 'app-android'
156
+ const vueFiles = resolveTscUniModuleUTSSDKVueFileNames(
157
+ platform,
158
+ pluginDir
159
+ )
160
+ for (const vueFile of vueFiles) {
161
+ await uniXKotlinCompiler.addRootFile(vueFile)
162
+ }
130
163
  const indexFileName = resolveTscUniModuleIndexFileName(
131
- 'app-android',
164
+ platform,
132
165
  pluginDir
133
166
  )
134
167
  if (indexFileName) {
@@ -136,8 +169,16 @@ module.exports = async function (content) {
136
169
  }
137
170
  }
138
171
  if (uniXSwiftCompiler) {
172
+ const platform = 'app-ios'
173
+ const vueFiles = resolveTscUniModuleUTSSDKVueFileNames(
174
+ platform,
175
+ pluginDir
176
+ )
177
+ for (const vueFile of vueFiles) {
178
+ await uniXSwiftCompiler.addRootFile(vueFile)
179
+ }
139
180
  const indexFileName = resolveTscUniModuleIndexFileName(
140
- 'app-ios',
181
+ platform,
141
182
  pluginDir
142
183
  )
143
184
  if (indexFileName) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "2.0.2-alpha-4070620250731001",
3
+ "version": "2.0.2-alpha-4080120250905001",
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": "19d2e9fb70abf2e0f6bd14e7ea2074eccdc2b749"
30
+ "gitHead": "2b970c1e601c12ec3cfa696bd0c3ee546a731434"
31
31
  }