@dcloudio/uni-cli-shared 2.0.2-alpha-5010120260522001 → 2.0.2-alpha-5010220260529001
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-interstitial.web.js +30 -1
- package/lib/platform.js +4 -1
- package/lib/style.js +2 -2
- package/package.json +2 -2
|
@@ -47,10 +47,12 @@ export default {
|
|
|
47
47
|
this._loadData()
|
|
48
48
|
},
|
|
49
49
|
methods: {
|
|
50
|
+
/** 对外 load:仅派发 load 事件(与历史行为一致) */
|
|
50
51
|
load () {
|
|
51
52
|
this._dispatchEvent(EventType.Load, {})
|
|
52
53
|
},
|
|
53
54
|
|
|
55
|
+
/** 展示插屏:在 SDK 与素材就绪后调用 GDT NATIVE.renderAd */
|
|
54
56
|
show () {
|
|
55
57
|
this.errorMessage = null
|
|
56
58
|
|
|
@@ -71,10 +73,12 @@ export default {
|
|
|
71
73
|
}
|
|
72
74
|
},
|
|
73
75
|
|
|
76
|
+
/** 点击插屏区域时尝试展示广告 */
|
|
74
77
|
_onclick () {
|
|
75
78
|
this.show()
|
|
76
79
|
},
|
|
77
80
|
|
|
81
|
+
/** 按 adpid 拉取 H5 广告配置并加载优量汇脚本、预请求素材 */
|
|
78
82
|
_loadData (adpid) {
|
|
79
83
|
this.loading = true
|
|
80
84
|
const id = adpid || this.adpid
|
|
@@ -108,6 +112,7 @@ export default {
|
|
|
108
112
|
})
|
|
109
113
|
},
|
|
110
114
|
|
|
115
|
+
/** 向 TencentGDT 队列提交插屏 native 请求,onComplete 写入 _interstitialData */
|
|
111
116
|
_renderGdt (data) {
|
|
112
117
|
window.TencentGDT.push({
|
|
113
118
|
placement_id: data.a3, // 广告位ID
|
|
@@ -122,12 +127,14 @@ export default {
|
|
|
122
127
|
})
|
|
123
128
|
},
|
|
124
129
|
|
|
130
|
+
/** 以小程序风格 detail 包装后向父组件派发事件 */
|
|
125
131
|
_dispatchEvent (type, data) {
|
|
126
132
|
this.$emit(type, {
|
|
127
133
|
detail: data
|
|
128
134
|
})
|
|
129
135
|
},
|
|
130
136
|
|
|
137
|
+
/** 在容器内创建带随机 id 的 DOM 节点,供 renderAd 挂载 */
|
|
131
138
|
_createView () {
|
|
132
139
|
const id = this._randomId()
|
|
133
140
|
const adView = document.createElement('div')
|
|
@@ -137,6 +144,7 @@ export default {
|
|
|
137
144
|
return id
|
|
138
145
|
},
|
|
139
146
|
|
|
147
|
+
/** 生成 renderAd 容器 DOM id */
|
|
140
148
|
_randomId () {
|
|
141
149
|
let result = ''
|
|
142
150
|
for (let i = 0; i < 4; i++) {
|
|
@@ -151,6 +159,7 @@ export default {
|
|
|
151
159
|
// let IS = 0
|
|
152
160
|
|
|
153
161
|
class AdConfig {
|
|
162
|
+
/** @returns {AdConfig} 全局单例 */
|
|
154
163
|
static get instance () {
|
|
155
164
|
if (this._instance == null) {
|
|
156
165
|
this._instance = new AdConfig()
|
|
@@ -167,10 +176,12 @@ class AdConfig {
|
|
|
167
176
|
this._callbacks = []
|
|
168
177
|
}
|
|
169
178
|
|
|
179
|
+
/** @returns 当前内存中的配置体(服务端返回的 data) */
|
|
170
180
|
get adConfig () {
|
|
171
181
|
return this._adConfig
|
|
172
182
|
}
|
|
173
183
|
|
|
184
|
+
/** @returns {boolean} 本地缓存是否超过 CACHE_TIME */
|
|
174
185
|
get isExpired () {
|
|
175
186
|
if (this._adConfig == null) {
|
|
176
187
|
return true
|
|
@@ -178,6 +189,7 @@ class AdConfig {
|
|
|
178
189
|
return (Math.abs(Date.now() - this._adConfig.last) > this.CACHE_TIME)
|
|
179
190
|
}
|
|
180
191
|
|
|
192
|
+
/** 从 localStorage 恢复未过期的配置到内存 */
|
|
181
193
|
_init () {
|
|
182
194
|
var config = this._getConfig()
|
|
183
195
|
if (config === null || !config.last) {
|
|
@@ -189,6 +201,12 @@ class AdConfig {
|
|
|
189
201
|
}
|
|
190
202
|
}
|
|
191
203
|
|
|
204
|
+
/**
|
|
205
|
+
* 按 adpid 获取配置:优先内存/缓存命中,否则请求 ah5v2 并排队回调
|
|
206
|
+
* @param {string|number} adpid
|
|
207
|
+
* @param {(a: object, b: object[]) => void} success
|
|
208
|
+
* @param {(err: object) => void} fail
|
|
209
|
+
*/
|
|
192
210
|
get (adpid, success, fail) {
|
|
193
211
|
// IC++
|
|
194
212
|
if (this._adConfig != null) {
|
|
@@ -208,6 +226,7 @@ class AdConfig {
|
|
|
208
226
|
this._loadAdConfig(adpid)
|
|
209
227
|
}
|
|
210
228
|
|
|
229
|
+
/** 用当前 _adConfig 解析 adpid 并调用 success 或 fail */
|
|
211
230
|
_doCallback (adpid, success, fail) {
|
|
212
231
|
// IS++
|
|
213
232
|
var { a, b } = this._adConfig
|
|
@@ -218,6 +237,7 @@ class AdConfig {
|
|
|
218
237
|
}
|
|
219
238
|
}
|
|
220
239
|
|
|
240
|
+
/** 请求远端 H5 广告配置并刷新内存与等待队列 */
|
|
221
241
|
_loadAdConfig (adpid) {
|
|
222
242
|
if (this._isLoading === true) {
|
|
223
243
|
return
|
|
@@ -263,6 +283,7 @@ class AdConfig {
|
|
|
263
283
|
})
|
|
264
284
|
}
|
|
265
285
|
|
|
286
|
+
/** @returns {{ last: number, data: object }|null} localStorage 中的包装结构 */
|
|
266
287
|
_getConfig () {
|
|
267
288
|
if (!navigator.cookieEnabled || !window.localStorage) {
|
|
268
289
|
return null
|
|
@@ -271,6 +292,7 @@ class AdConfig {
|
|
|
271
292
|
return data ? JSON.parse(data) : null
|
|
272
293
|
}
|
|
273
294
|
|
|
295
|
+
/** 将服务端 data 与当前时间写入 localStorage */
|
|
274
296
|
_setConfig (data) {
|
|
275
297
|
if (!navigator.cookieEnabled || !window.localStorage) {
|
|
276
298
|
return null
|
|
@@ -282,7 +304,8 @@ class AdConfig {
|
|
|
282
304
|
}
|
|
283
305
|
}
|
|
284
306
|
Object.assign(AdConfig.prototype, {
|
|
285
|
-
|
|
307
|
+
// 旧版 https://hac1.dcloud.net.cn/ah5 已废弃,配置迁移至 v2(与 Vue3 H5 插屏一致)
|
|
308
|
+
URL: 'https://hac1.dcloud.net.cn/ah5v2',
|
|
286
309
|
KEY: 'uni_app_ad_config',
|
|
287
310
|
CACHE_TIME: 1000 * 60 * 10,
|
|
288
311
|
ERROR_INVALID_ADPID: {
|
|
@@ -291,6 +314,7 @@ Object.assign(AdConfig.prototype, {
|
|
|
291
314
|
})
|
|
292
315
|
|
|
293
316
|
class AdScript {
|
|
317
|
+
/** @returns {AdScript} 脚本加载器单例 */
|
|
294
318
|
static get instance () {
|
|
295
319
|
if (this._instance == null) {
|
|
296
320
|
this._instance = new AdScript()
|
|
@@ -304,6 +328,10 @@ class AdScript {
|
|
|
304
328
|
this._cache = {}
|
|
305
329
|
}
|
|
306
330
|
|
|
331
|
+
/**
|
|
332
|
+
* 按渠道加载广告 SDK script,已缓存则同步 success
|
|
333
|
+
* @param {string} provider 渠道标识(如优量汇为 '2')
|
|
334
|
+
*/
|
|
307
335
|
load (provider, script, success, fail) {
|
|
308
336
|
if (this._cache[provider] === undefined) {
|
|
309
337
|
this.loadScript(provider, script)
|
|
@@ -322,6 +350,7 @@ class AdScript {
|
|
|
322
350
|
}
|
|
323
351
|
}
|
|
324
352
|
|
|
353
|
+
/** 向 document 插入 script 节点并处理 onload/onerror 队列 */
|
|
325
354
|
loadScript (provider, script) {
|
|
326
355
|
this._cache[provider] = 0
|
|
327
356
|
const domid = 'uniad_provider' + provider
|
package/lib/platform.js
CHANGED
|
@@ -81,7 +81,10 @@ function isEnableConsole () {
|
|
|
81
81
|
process.env.NODE_ENV === 'development' &&
|
|
82
82
|
process.env.UNI_SOCKET_HOSTS &&
|
|
83
83
|
process.env.UNI_SOCKET_PORT &&
|
|
84
|
-
process.env.UNI_SOCKET_ID
|
|
84
|
+
process.env.UNI_SOCKET_ID &&
|
|
85
|
+
// 环境变量传入有bug,临时屏蔽安卓平台开启 uni-console
|
|
86
|
+
process.env.UNI_APP_PLATFORM !== 'android' &&
|
|
87
|
+
process.env.UNI_APP_PLATFORM !== 'ios'
|
|
85
88
|
)
|
|
86
89
|
}
|
|
87
90
|
|
package/lib/style.js
CHANGED
|
@@ -36,9 +36,9 @@ function createRpx2Unit (unit, unitRatio, unitPrecision) {
|
|
|
36
36
|
* @param {string | number} val
|
|
37
37
|
* @returns {string}
|
|
38
38
|
*/
|
|
39
|
-
return (val)
|
|
39
|
+
return function (val) {
|
|
40
40
|
if (unitRE.test(val)) {
|
|
41
|
-
return val.replace(unitRE, (m, $1)
|
|
41
|
+
return val.replace(unitRE, function (m, $1) {
|
|
42
42
|
if (!$1) {
|
|
43
43
|
return m
|
|
44
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "2.0.2-alpha-
|
|
3
|
+
"version": "2.0.2-alpha-5010220260529001",
|
|
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": "6480c1135660f0bceac8109422bb4e551d16d1b1"
|
|
31
31
|
}
|