@dcloudio/uni-cli-shared 2.0.2-4070620250821001 → 2.0.2-4080520251106001

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.
@@ -70,6 +70,7 @@ export default {
70
70
  if (this.preload && this._canCreateAd()) {
71
71
  this.load()
72
72
  }
73
+ this._dispatchEvent('adcreated', { instance: this })
73
74
  },
74
75
  methods: {
75
76
  load () {
@@ -199,14 +200,17 @@ export default {
199
200
  if (adData.tmpl_type === 24) {
200
201
  this.customFullscreen = 'uni-ad-custom-fullscreen'
201
202
  }
202
- this.loading = true
203
+ this.loading = true
204
+ if (!adData.dcloudAdpid) {
205
+ adData.dcloudAdpid = this.adpid
206
+ }
203
207
  this.selectComponent('.uniad-plugin-wx').setConfig(adData)
204
208
  }
205
209
  })
206
210
  },
207
211
 
208
212
  _onwxchannelerror (e) {
209
- this._dispatchEvent(EventType.Error, e.detail)
213
+ this._dispatchEvent(EventType.Error, e.detail || e)
210
214
  },
211
215
 
212
216
  _dispatchEvent (type, data) {
@@ -224,14 +228,18 @@ export default {
224
228
  iv,
225
229
  version,
226
230
  expireTime
227
- }) => {
231
+ }) => {
232
+ const uniOptions = {
233
+ adpid: this.adpid
234
+ }
228
235
  adComponent.show({
229
236
  userId: this.urlCallback.userId || '',
230
237
  extra: this.urlCallback.extra || '',
231
238
  encryptKey,
232
239
  iv,
233
240
  version,
234
- expireTime
241
+ expireTime,
242
+ uniOptions
235
243
  })
236
244
  },
237
245
  fail: (err) => {
@@ -250,12 +258,16 @@ export default {
250
258
  switch (this.wxAdType) {
251
259
  case AdType.RewardedVideo:
252
260
  if (this._wxRewardedAd) {
253
- this._wxRewardedAd.load()
261
+ this._wxRewardedAd.load().catch((err) => {
262
+ this._dispatchEvent(EventType.Error, err)
263
+ })
254
264
  }
255
265
  break
256
266
  case AdType.Interstitial:
257
267
  if (this._wxInterstitialAd) {
258
- this._wxInterstitialAd.load()
268
+ this._wxInterstitialAd.load().catch((err) => {
269
+ this._dispatchEvent(EventType.Error, err)
270
+ })
259
271
  }
260
272
  break
261
273
  }
@@ -275,11 +287,7 @@ export default {
275
287
  }
276
288
  // eslint-disable-next-line handle-callback-err
277
289
  this._wxRewardedAd.show().catch((err) => {
278
- this._wxRewardedAd.load().then(() => {
279
- this._wxRewardedAd.show()
280
- }).catch((err) => {
281
- this._dispatchEvent(EventType.Error, err)
282
- })
290
+ this._dispatchEvent(EventType.Error, err)
283
291
  })
284
292
  break
285
293
  case AdType.Interstitial:
@@ -288,11 +296,7 @@ export default {
288
296
  }
289
297
  // eslint-disable-next-line handle-callback-err
290
298
  this._wxInterstitialAd.show().catch((err) => {
291
- this._wxInterstitialAd.load().then(() => {
292
- this._wxInterstitialAd.show()
293
- }).catch((err) => {
294
- this._dispatchEvent(EventType.Error, err)
295
- })
299
+ this._dispatchEvent(EventType.Error, err)
296
300
  })
297
301
  break
298
302
  }
@@ -316,7 +320,8 @@ export default {
316
320
  })
317
321
 
318
322
  this._wxRewardedAd.onError(err => {
319
- this.loading = false
323
+ this.loading = false
324
+ this.errorMessage = JSON.stringify(err)
320
325
  this._dispatchEvent(EventType.Error, err)
321
326
  })
322
327
 
@@ -327,7 +332,9 @@ export default {
327
332
  }
328
333
  })
329
334
 
330
- this._wxRewardedAd.load().then(() => { }).catch((_) => { })
335
+ this._wxRewardedAd.load().then(() => {
336
+ }).catch((_) => {
337
+ })
331
338
 
332
339
  this.loading = true
333
340
  },
@@ -345,12 +352,15 @@ export default {
345
352
  this._dispatchEvent(EventType.Load, {})
346
353
  if (this._userInvokeShowFlag) {
347
354
  this._userInvokeShowFlag = false
348
- this._wxInterstitialAd.show()
355
+ this._wxInterstitialAd.show().catch((err) => {
356
+ this._dispatchEvent(EventType.Error, err)
357
+ })
349
358
  }
350
359
  })
351
360
 
352
361
  this._wxInterstitialAd.onError(err => {
353
- this.loading = false
362
+ this.loading = false
363
+ this.errorMessage = JSON.stringify(err)
354
364
  this._dispatchEvent(EventType.Error, err)
355
365
  })
356
366
 
@@ -358,7 +368,9 @@ export default {
358
368
  this._dispatchEvent(EventType.Close, res)
359
369
  })
360
370
 
361
- this._wxInterstitialAd.load().then(() => { }).catch((_) => { })
371
+ this._wxInterstitialAd.load().catch((err) => {
372
+ this._dispatchEvent(EventType.Error, err)
373
+ })
362
374
 
363
375
  this.loading = true
364
376
  },
@@ -384,6 +396,10 @@ export default {
384
396
  this._dispatchEvent(EventType.Error, err)
385
397
  }
386
398
  })
399
+ },
400
+
401
+ toJSON () {
402
+ return ''
387
403
  }
388
404
  }
389
405
  }
@@ -64,8 +64,9 @@ export default {
64
64
  }
65
65
  },
66
66
  created () {
67
- const page = getCurrentPages()[0]
68
- this.$pageVm = page.$vm || page
67
+ const pages = getCurrentPages()
68
+ const currentPage = pages[pages.length - 1]
69
+ this.$pageVm = currentPage.$vm || currentPage
69
70
  // event
70
71
  // h5 暂不支持生命周期 onResize,补充后,可以移除该条件编译
71
72
  // #ifdef H5
@@ -84,7 +85,7 @@ export default {
84
85
  })
85
86
 
86
87
  // #ifdef APP-PLUS
87
- this._currentWebview = page.$getAppWebview()
88
+ this._currentWebview = currentPage.$getAppWebview()
88
89
  if (this.enablePullDownRefresh) {
89
90
  this.setPullDownRefresh(this._currentWebview, true)
90
91
  }
@@ -102,7 +103,7 @@ export default {
102
103
  this.rootFontSize,
103
104
  this.pageStyle
104
105
  ], () => {
105
- this.setPageMeta()
106
+ this.setPageMeta(currentPage.$page.id)
106
107
  })
107
108
  this.$watch(() => [
108
109
  this.backgroundColor,
@@ -128,6 +129,11 @@ export default {
128
129
  mounted () {
129
130
  this.scrollTop && this.pageScrollTo()
130
131
  },
132
+ // #ifdef H5
133
+ activated () {
134
+ this.setPageMeta()
135
+ },
136
+ // #endif
131
137
  methods: {
132
138
  setPullDownRefresh (webview, enabled) {
133
139
  webview.setStyle({
@@ -137,12 +143,15 @@ export default {
137
143
  }
138
144
  })
139
145
  },
140
- setPageMeta () {
146
+ setPageMeta (pageId) {
141
147
  // h5 和 app-plus 设置 rootFontSize
142
148
  // #ifdef H5 || APP-PLUS
143
- uni.setPageMeta({
144
- pageStyle: this.pageStyle,
145
- rootFontSize: this.rootFontSize
149
+ this.$nextTick(() => {
150
+ uni.setPageMeta({
151
+ pageStyle: this.pageStyle,
152
+ rootFontSize: this.rootFontSize,
153
+ pageId
154
+ })
146
155
  })
147
156
  // #endif
148
157
  },
@@ -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) => {
@@ -124,27 +149,44 @@ module.exports = async function (content) {
124
149
  )
125
150
  }
126
151
 
127
- if (!utsPlugins.has(pluginId)) {
128
- utsPlugins.add(pluginId)
129
- if (uniXKotlinCompiler) {
130
- const indexFileName = resolveTscUniModuleIndexFileName(
131
- 'app-android',
132
- pluginDir
133
- )
134
- if (indexFileName) {
135
- await uniXKotlinCompiler.addRootFile(indexFileName)
136
- }
152
+ // 不判重了,不然nvue,vue并发同一个插件时,其中一个会跳过tsc编译,直接走到rust那里,导致一些文件还没有生成,比如vue兼容模式组件之类的
153
+ // if (!utsPlugins.has(pluginId)) {
154
+ utsPlugins.add(pluginId)
155
+ if (uniXKotlinCompiler) {
156
+ const platform = 'app-android'
157
+ const vueFiles = resolveTscUniModuleUTSSDKVueFileNames(
158
+ platform,
159
+ pluginDir
160
+ )
161
+ for (const vueFile of vueFiles) {
162
+ await uniXKotlinCompiler.addRootFile(vueFile)
137
163
  }
138
- if (uniXSwiftCompiler) {
139
- const indexFileName = resolveTscUniModuleIndexFileName(
140
- 'app-ios',
141
- pluginDir
142
- )
143
- if (indexFileName) {
144
- await uniXSwiftCompiler.addRootFile(indexFileName)
145
- }
164
+ const indexFileName = resolveTscUniModuleIndexFileName(
165
+ platform,
166
+ pluginDir
167
+ )
168
+ if (indexFileName) {
169
+ await uniXKotlinCompiler.addRootFile(indexFileName)
170
+ }
171
+ }
172
+ if (uniXSwiftCompiler) {
173
+ const platform = 'app-ios'
174
+ const vueFiles = resolveTscUniModuleUTSSDKVueFileNames(
175
+ platform,
176
+ pluginDir
177
+ )
178
+ for (const vueFile of vueFiles) {
179
+ await uniXSwiftCompiler.addRootFile(vueFile)
180
+ }
181
+ const indexFileName = resolveTscUniModuleIndexFileName(
182
+ platform,
183
+ pluginDir
184
+ )
185
+ if (indexFileName) {
186
+ await uniXSwiftCompiler.addRootFile(indexFileName)
146
187
  }
147
188
  }
189
+ // }
148
190
 
149
191
  // 处理uni_modules中的文件变更
150
192
  const files = changedFiles.get(pluginId)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "2.0.2-4070620250821001",
3
+ "version": "2.0.2-4080520251106001",
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": "83322ec9f7cc592b2052ff78370e12f4689f5966"
30
+ "gitHead": "a2b8fa284e37aed693ed2b394e1d72c33f45728f"
31
31
  }