@dcloudio/uni-cli-shared 2.0.2-alpha-4070420250630001 → 2.0.2-alpha-4070520250704002

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.
@@ -1,4 +1,4 @@
1
- /* eslint-disable no-undef */
1
+ /* eslint-disable no-undef */
2
2
  const adPlugin = requirePlugin('uni-ad')
3
3
 
4
4
  const EventType = {
@@ -54,7 +54,7 @@ export default {
54
54
  return {
55
55
  loading: false,
56
56
  userwx: false,
57
- userUnitId: '',
57
+ userUnitId: '',
58
58
  customFullscreen: '',
59
59
  wxchannel: false,
60
60
  errorMessage: null
@@ -64,7 +64,8 @@ export default {
64
64
  this._ad = null
65
65
  this._loading = false
66
66
  this._wxRewardedAd = null
67
- this._wxInterstitialAd = null
67
+ this._wxInterstitialAd = null
68
+ this._userInvokeShowFlag = false
68
69
  this._providerType = ProviderType.ShanHu
69
70
  if (this.preload && this._canCreateAd()) {
70
71
  this.load()
@@ -85,7 +86,11 @@ export default {
85
86
  },
86
87
 
87
88
  show (e) {
88
- this.errorMessage = null
89
+ this.errorMessage = null
90
+ if (this.loading) {
91
+ this._userInvokeShowFlag = true
92
+ return
93
+ }
89
94
  if (this._providerType === ProviderType.ShanHu) {
90
95
  this._showAdInPlugin(this.selectComponent('.uniad-plugin'))
91
96
  } else if (this._providerType === ProviderType.WeChat) {
@@ -120,15 +125,22 @@ export default {
120
125
 
121
126
  _onmpload (e) {
122
127
  this.loading = false
123
- this._dispatchEvent(EventType.Load, {})
128
+ this._dispatchEvent(EventType.Load, {})
129
+ if (this._userInvokeShowFlag) {
130
+ this._userInvokeShowFlag = false
131
+ setTimeout(() => {
132
+ this.show()
133
+ }, 1)
134
+ }
124
135
  },
125
136
 
126
- _onmpclose (e) {
127
- this._dispatchEvent(EventType.Close, e.detail)
128
- if (e.detail.adsdata) {
129
- const adv = e.detail.adv
130
- const adsdata = e.detail.adsdata
131
- const version = e.detail.version
137
+ _onmpclose (e) {
138
+ const detail = e.detail || e
139
+ this._dispatchEvent(EventType.Close, detail)
140
+ if (detail.adsdata) {
141
+ const adv = detail.adv
142
+ const adsdata = detail.adsdata
143
+ const version = detail.version
132
144
 
133
145
  /* eslint-disable no-undef */
134
146
  uniCloud.callFunction({
@@ -146,9 +158,9 @@ export default {
146
158
  }
147
159
  })
148
160
 
149
- delete e.detail.adv
150
- delete e.detail.adsdata
151
- delete e.detail.version
161
+ delete detail.adv
162
+ delete detail.adsdata
163
+ delete detail.version
152
164
  }
153
165
  },
154
166
 
@@ -168,9 +180,9 @@ export default {
168
180
  case 4:
169
181
  this.wxAdType = AdType.Banner
170
182
  this.userwx = true
171
- this.userUnitId = adData.posid
172
- if (adData.tmpl_type === 24) {
173
- this.customFullscreen = 'uni-ad-custom-fullscreen'
183
+ this.userUnitId = adData.posid
184
+ if (adData.tmpl_type === 24) {
185
+ this.customFullscreen = 'uni-ad-custom-fullscreen'
174
186
  }
175
187
  break
176
188
  case 9:
@@ -183,14 +195,19 @@ export default {
183
195
  break
184
196
  }
185
197
  } else if (adData.provider === 10018) {
186
- this._providerType = ProviderType.WeChat
198
+ this._providerType = ProviderType.WeChat
199
+ if (adData.tmpl_type === 24) {
200
+ this.customFullscreen = 'uni-ad-custom-fullscreen'
201
+ }
202
+ this.loading = true
187
203
  this.selectComponent('.uniad-plugin-wx').setConfig(adData)
188
204
  }
189
205
  })
190
206
  },
191
207
 
192
208
  _onwxchannelerror (e) {
193
- this.wxchannel = false
209
+ this.wxchannel = false
210
+ this._dispatchEvent(EventType.Error, e.detail)
194
211
  this.$nextTick(() => {
195
212
  this._providerType = ProviderType.ShanHu
196
213
  this.selectComponent('.uniad-plugin').shanhuChannel()
@@ -260,7 +277,7 @@ export default {
260
277
  case AdType.RewardedVideo:
261
278
  if (!this._wxRewardedAd) {
262
279
  return
263
- }
280
+ }
264
281
  // eslint-disable-next-line handle-callback-err
265
282
  this._wxRewardedAd.show().catch((err) => {
266
283
  this._wxRewardedAd.load().then(() => {
@@ -273,7 +290,7 @@ export default {
273
290
  case AdType.Interstitial:
274
291
  if (!this._wxInterstitialAd) {
275
292
  return
276
- }
293
+ }
277
294
  // eslint-disable-next-line handle-callback-err
278
295
  this._wxInterstitialAd.show().catch((err) => {
279
296
  this._wxInterstitialAd.load().then(() => {
@@ -308,13 +325,13 @@ export default {
308
325
  this._dispatchEvent(EventType.Error, err)
309
326
  })
310
327
 
311
- this._wxRewardedAd.onClose(res => {
328
+ this._wxRewardedAd.onClose(res => {
312
329
  this._dispatchEvent(EventType.Close, res)
313
330
  if (res.isEnded && this._hasCallback()) {
314
331
  this._callServer()
315
332
  }
316
- })
317
-
333
+ })
334
+
318
335
  this._wxRewardedAd.load().then(() => { }).catch((_) => { })
319
336
 
320
337
  this.loading = true
@@ -344,8 +361,8 @@ export default {
344
361
 
345
362
  this._wxInterstitialAd.onClose(res => {
346
363
  this._dispatchEvent(EventType.Close, res)
347
- })
348
-
364
+ })
365
+
349
366
  this._wxInterstitialAd.load().then(() => { }).catch((_) => { })
350
367
 
351
368
  this.loading = true
@@ -10,7 +10,7 @@
10
10
  />
11
11
  <!-- #ifdef MP-WEIXIN -->
12
12
  <ad-custom v-if="userwx" :unit-id="userUnitId" class="uni-ad-custom" data-com-type="wx" :class="[customFullscreen]" @load="_onmpload" @error="_onmperror"></ad-custom>
13
- <uniad-plugin-wx v-if="wxchannel" class="uniad-plugin-wx" data-com-type="wx" @load="_onmpload" @error="_onwxchannelerror"></uniad-plugin-wx>
13
+ <uniad-plugin-wx v-if="wxchannel" class="uniad-plugin-wx" :class="[customFullscreen]" data-com-type="wx" @load="_onmpload" @error="_onwxchannelerror"></uniad-plugin-wx>
14
14
  <!-- #endif -->
15
15
  </view>
16
16
  </template>
@@ -33,7 +33,8 @@ export default {
33
33
  </script>
34
34
 
35
35
  <style>
36
- .uni-ad-custom-fullscreen {
36
+ .uni-ad-custom-fullscreen {
37
+ display: flex;
37
38
  height: 100vh;
38
39
  }
39
40
  </style>
@@ -0,0 +1,61 @@
1
+ function resolveNativeBinding () {
2
+ const { platform, arch } = process
3
+ let nativeBinding = ''
4
+ switch (platform) {
5
+ case 'win32':
6
+ switch (arch) {
7
+ case 'x64':
8
+ nativeBinding = 'preprocessor-windows-x86_64'
9
+ break
10
+ default:
11
+ throw new Error(`Unsupported architecture on Windows: ${arch}`)
12
+ }
13
+ break
14
+ case 'darwin':
15
+ switch (arch) {
16
+ case 'x64':
17
+ nativeBinding = 'preprocessor-macos-x86_64'
18
+ break
19
+ case 'arm64':
20
+ nativeBinding = 'preprocessor-macos-arm64'
21
+ break
22
+ default:
23
+ throw new Error(`Unsupported architecture on macOS: ${arch}`)
24
+ }
25
+ break
26
+ default:
27
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
28
+ }
29
+ return require('./' + nativeBinding)
30
+ }
31
+
32
+ async function runProcess (vue3 = false) {
33
+ try {
34
+ /* eslint-disable no-undef */
35
+ globalThis.preprocessor_require = require
36
+ await resolveNativeBinding().process(vue3)
37
+ } catch (error) {
38
+ }
39
+ }
40
+
41
+ class PreprocessorWebpackPlugin {
42
+ apply (compiler) {
43
+ compiler.hooks.afterEmit.tapPromise('d', (params) => {
44
+ return runProcess(false)
45
+ })
46
+ }
47
+ }
48
+
49
+ function PreprocessorVitePlugin () {
50
+ return {
51
+ name: 'preprocessor',
52
+ async writeBundle (_) {
53
+ await runProcess(true)
54
+ }
55
+ }
56
+ }
57
+
58
+ module.exports = {
59
+ PreprocessorWebpackPlugin,
60
+ PreprocessorVitePlugin
61
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "2.0.2-alpha-4070420250630001",
3
+ "version": "2.0.2-alpha-4070520250704002",
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": "b411b2c47252aa4ed7a531fd13d0f256c113d3f3"
30
+ "gitHead": "41a563d925b63775d13a869cfbd24f9d0e269a27"
31
31
  }