@dcloudio/vue-cli-plugin-uni 2.0.2-5000720260410001 → 2.0.2-5010520260709001

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/lib/env.js CHANGED
@@ -35,6 +35,9 @@ const {
35
35
  hasPushModule,
36
36
  isEnableSecureNetwork
37
37
  } = require('@dcloudio/uni-cli-shared/lib/manifest')
38
+ const {
39
+ resolveStatEnable
40
+ } = require('@dcloudio/uni-cli-shared/lib/stat')
38
41
 
39
42
  const manifestJsonObj = getManifestJson()
40
43
 
@@ -474,62 +477,132 @@ process.env.MERGE_VIRTUAL_HOST_ATTRIBUTES = (!!platformOptions.mergeVirtualHostA
474
477
  process.env.UNI_STATISTICS_CONFIG = '""'
475
478
  process.env.UNI_STAT_UNI_CLOUD = '""'
476
479
  process.env.UNI_STAT_DEBUG = '""'
480
+
481
+ const MP_WEIXIN_USE_PRELOAD_ASSETS_REPORT = true
482
+
483
+ /** 公有版小程序 GET 上报域名 */
484
+ const STAT_MP_REQUEST_DOMAIN = 'tongji-collector.dcloud.net.cn'
485
+ const STAT_MP_DOMAIN_DOC_URL = 'https://uniapp.dcloud.net.cn/uni-stat-public.html'
486
+ const STAT_WARN_NO_APPID =
487
+ '当前应用未配置 appid,无法使用 uni 统计,详情参考:https://ask.dcloud.net.cn/article/36303'
488
+ const STAT_PRIVATE_ANDROID_WARN =
489
+ '【重要】因 HBuilderX 3.4.9 版本起,uni统计2.0 调整了安卓端 deviceId 获取方式,导致 uni统计2.0 App-Android平台部分统计数据不准确。如使用了HBuilderX 3.4.9 - 3.6.4版本且开通了uni统计2.0的应用,需要使用HBuilderX3.6.7及以上版本重新发布应用并升级 uniAdmin 云函数解决,详见:https://ask.dcloud.net.cn/article/40097'
490
+
491
+ /**
492
+ * 解析 manifest.uniStatistics 的统计类型。
493
+ * 优先 type(public/private);缺失或非法时回退 version(2=private,其余=public)。
494
+ */
495
+ function resolveUniStatType (uniStatistics) {
496
+ const type = String(uniStatistics.type || '').trim()
497
+ if (type === 'public' || type === 'private') {
498
+ return type
499
+ }
500
+ return Number(uniStatistics.version) === 2 ? 'private' : 'public'
501
+ }
502
+
503
+ /**
504
+ * 是否应向 main 入口自动 import 统计运行时。
505
+ * uni-app x 暂不自动 import;enable 按子→根→默认(true) 三级规则解析。
506
+ */
507
+ function shouldAutoImportStatRuntime (rootStat, platformStat) {
508
+ if (process.env.UNI_APP_X === 'true') {
509
+ return false
510
+ }
511
+ return resolveStatEnable(rootStat, platformStat)
512
+ }
513
+
514
+ /** 构建期统计提示输出(与 uni-stat vite 插件 uniStatLog 一致) */
515
+ function uniStatLog (text) {
516
+ console.log()
517
+ console.warn(text)
518
+ console.log()
519
+ }
520
+
521
+ /** uni 统计 2.0 构建期「已开启」基础文案 */
522
+ const STAT_ENABLED_TIP_BASE = '已开启 uni统计 2.0'
523
+
524
+ /**
525
+ * 构建期「统计已开启」简短提示。
526
+ * public → 已开启uni 统计 2.0;private → 已开启uni 统计 2.0(私有版)
527
+ */
528
+ function formatStatEnabledTip (statType) {
529
+ if (statType === 'private') {
530
+ return `${STAT_ENABLED_TIP_BASE}(私有版)`
531
+ }
532
+ return STAT_ENABLED_TIP_BASE
533
+ }
534
+
535
+ /** 小程序公有版 request 合法域名提示(合并「已开启」与域名说明) */
536
+ function formatMpStatDomainTip () {
537
+ return `${STAT_ENABLED_TIP_BASE},为保障数据正常上报,请在小程序后台配置 request 合法域名:${STAT_MP_REQUEST_DOMAIN}。详情:${STAT_MP_DOMAIN_DOC_URL}`
538
+ }
539
+
540
+ /**
541
+ * 是否需要在构建期提示配置小程序 request 合法域名。
542
+ * 微信默认 preload 信标不走 uni.request,无需配置;开关关闭时与其它小程序一致。
543
+ */
544
+ function shouldShowMpDomainTip (platform, statType) {
545
+ if (statType !== 'public' || !platform.startsWith('mp-')) {
546
+ return false
547
+ }
548
+ if (platform === 'mp-weixin' && MP_WEIXIN_USE_PRELOAD_ASSETS_REPORT) {
549
+ return false
550
+ }
551
+ return true
552
+ }
553
+
554
+ /** 输出构建期「统计已开启」提示 */
555
+ function logStatEnabledTip (platform, statType) {
556
+ if (shouldShowMpDomainTip(platform, statType)) {
557
+ uniStatLog(formatMpStatDomainTip())
558
+ return
559
+ }
560
+ uniStatLog(formatStatEnabledTip(statType))
561
+ }
562
+
477
563
  if (
478
564
  process.env.UNI_USING_COMPONENTS ||
479
565
  process.env.UNI_PLATFORM === 'h5'
480
566
  ) { // 自定义组件模式或 h5 平台
567
+ const rootStat = manifestJsonObj.uniStatistics
568
+ const platformStat = platformOptions.uniStatistics
481
569
  const uniStatistics = Object.assign(
482
- manifestJsonObj.uniStatistics || {},
483
- platformOptions.uniStatistics || {}
570
+ {},
571
+ rootStat || {},
572
+ platformStat || {}
484
573
  )
485
574
 
486
- if (uniStatistics.enable === true) {
487
- const uniStatLog = (text) => {
488
- console.log()
489
- console.warn(text)
490
- console.log()
491
- }
492
- const version = Number(uniStatistics.version) === 2 ? '2' : '1'
493
- process.env.UNI_USING_STAT = version
494
- // 获取服务空间配置信息
495
- const uniCloudConfig = uniStatistics.uniCloud || {}
496
- process.env.UNI_STATISTICS_CONFIG = JSON.stringify(uniStatistics)
497
- process.env.UNI_STAT_UNI_CLOUD = JSON.stringify(uniCloudConfig)
498
- process.env.UNI_STAT_DEBUG = uniStatistics.debug === true ? 'true' : 'false'
575
+ // 始终注入完整 manifest.uniStatisticsenable 仅控制是否自动 import
576
+ process.env.UNI_STATISTICS_CONFIG = JSON.stringify(uniStatistics)
577
+ process.env.UNI_STAT_DEBUG = uniStatistics.debug === true ? 'true' : 'false'
578
+
579
+ if (shouldAutoImportStatRuntime(rootStat, platformStat)) {
580
+ const statType = resolveUniStatType(uniStatistics)
581
+ const platform = process.env.UNI_PLATFORM
582
+ let autoImport = true
499
583
 
500
584
  if (process.env.NODE_ENV === 'production') {
501
585
  if (!process.UNI_STAT_CONFIG.appid) {
502
- uniStatLog(uniI18n.__('pluginUni.uniStatisticsNoAppid', {
503
- 0: 'https://ask.dcloud.net.cn/article/36303'
504
- }))
586
+ uniStatLog(STAT_WARN_NO_APPID)
587
+ autoImport = false
505
588
  } else {
506
- if (!uniStatistics.version) {
507
- uniStatLog(uniI18n.__('pluginUni.uniStatisticsNoVersion', {
508
- 0: 'https://uniapp.dcloud.io/uni-stat-v2.html'
509
- }))
510
- } else {
511
- uniStatLog(`已开启 uni统计${uniStatistics.version}.0 版本`)
512
- if (version === '2') {
513
- uniStatLog(
514
- '【重要】因 HBuilderX 3.4.9 版本起,uni统计2.0 调整了安卓端 deviceId 获取方式,导致 uni统计2.0 App-Android平台部分统计数据不准确。如使用了HBuilderX 3.4.9 - 3.6.4版本且开通了uni统计2.0的应用,需要使用HBuilderX3.6.7及以上版本重新发布应用并升级 uniAdmin 云函数解决,详见:https://ask.dcloud.net.cn/article/40097'
515
- )
516
- }
589
+ logStatEnabledTip(platform, statType)
590
+ if (statType === 'private') {
591
+ uniStatLog(STAT_PRIVATE_ANDROID_WARN)
517
592
  }
518
593
  }
519
594
  } else {
520
- if (!uniStatistics.version) {
521
- uniStatLog(uniI18n.__('pluginUni.uniStatisticsNoVersion', {
522
- 0: 'https://uniapp.dcloud.io/uni-stat-v2.html'
523
- }))
524
- } else {
525
- uniStatLog(`已开启 uni统计${uniStatistics.version}.0 版本`)
526
- if (version === '2') {
527
- uniStatLog(
528
- '【重要】因 HBuilderX 3.4.9 版本起,uni统计2.0 调整了安卓端 deviceId 获取方式,导致 uni统计2.0 App-Android平台部分统计数据不准确。如使用了HBuilderX 3.4.9 - 3.6.4版本且开通了uni统计2.0的应用,需要使用HBuilderX3.6.7及以上版本重新发布应用并升级 uniAdmin 云函数解决,详见:https://ask.dcloud.net.cn/article/40097'
529
- )
530
- }
595
+ logStatEnabledTip(platform, statType)
596
+ if (statType === 'private') {
597
+ uniStatLog(STAT_PRIVATE_ANDROID_WARN)
531
598
  }
532
599
  }
600
+
601
+ if (autoImport) {
602
+ process.env.UNI_USING_STAT = statType
603
+ const uniCloudConfig = uniStatistics.uniCloud || {}
604
+ process.env.UNI_STAT_UNI_CLOUD = JSON.stringify(uniCloudConfig)
605
+ }
533
606
  }
534
607
  }
535
608
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/vue-cli-plugin-uni",
3
- "version": "2.0.2-5000720260410001",
3
+ "version": "2.0.2-5010520260709001",
4
4
  "description": "uni-app plugin for vue-cli 3",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -17,7 +17,7 @@
17
17
  "author": "fxy060608",
18
18
  "license": "Apache-2.0",
19
19
  "dependencies": {
20
- "@dcloudio/uni-stat": "^2.0.2-5000720260410001",
20
+ "@dcloudio/uni-stat": "^2.0.2-5010520260709001",
21
21
  "buffer-json": "^2.0.0",
22
22
  "clone-deep": "^4.0.1",
23
23
  "cross-env": "^5.2.0",
@@ -41,5 +41,5 @@
41
41
  "copy-webpack-plugin": ">=5",
42
42
  "postcss": ">=7"
43
43
  },
44
- "gitHead": "82deb22abba40f01d10a6a4deb83b418e0adc266"
44
+ "gitHead": "f17eaf4bf390726fa12db98e6efbe0557841bed0"
45
45
  }
@@ -3,13 +3,13 @@
3
3
  Author Tobias Koppers @sokra
4
4
  Modified by Evan You @yyx990803
5
5
  */
6
- const {
7
- createRpx2Unit,
8
- getRpx2Unit
9
- } = require('@dcloudio/uni-cli-shared/lib/style')
6
+ const styleUtils = require('@dcloudio/uni-cli-shared/lib/style')
10
7
 
11
8
  import listToStyles from './listToStyles'
12
9
 
10
+ const createRpx2Unit = styleUtils.createRpx2Unit
11
+ const getRpx2Unit = styleUtils.getRpx2Unit
12
+
13
13
  var hasDocument = typeof document !== 'undefined'
14
14
 
15
15
  if (typeof DEBUG !== 'undefined' && DEBUG) {
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * Vue.js v2.6.11
3
- * (c) 2014-2022 Evan You
3
+ * (c) 2014-2026 Evan You
4
4
  * Released under the MIT License.
5
5
  */
6
6
  'use strict';
@@ -526,7 +526,7 @@ var hasProto = '__proto__' in {};
526
526
  var inBrowser = typeof window !== 'undefined';
527
527
  var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
528
528
  var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
529
- var UA = inBrowser && window.navigator.userAgent.toLowerCase();
529
+ var UA = inBrowser && window.navigator && window.navigator.userAgent && window.navigator.userAgent.toLowerCase();
530
530
  var isIE = UA && /msie|trident/.test(UA);
531
531
  var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
532
532
  var isEdge = UA && UA.indexOf('edge/') > 0;
@@ -1004,7 +1004,8 @@ function observe (value, asRootData) {
1004
1004
  !isServerRendering() &&
1005
1005
  (Array.isArray(value) || isPlainObject(value)) &&
1006
1006
  Object.isExtensible(value) &&
1007
- !value._isVue
1007
+ !value._isVue &&
1008
+ !value.__v_isMPComponent
1008
1009
  ) {
1009
1010
  ob = new Observer(value);
1010
1011
  }
@@ -2718,7 +2719,8 @@ function renderSlot (
2718
2719
  name,
2719
2720
  fallback,
2720
2721
  props,
2721
- bindObject
2722
+ bindObject,
2723
+ slotVm
2722
2724
  ) {
2723
2725
  var scopedSlotFn = this.$scopedSlots[name];
2724
2726
  var nodes;
@@ -2734,7 +2736,7 @@ function renderSlot (
2734
2736
  props = extend(extend({}, bindObject), props);
2735
2737
  }
2736
2738
  // fixed by xxxxxx app-plus scopedSlot
2737
- nodes = scopedSlotFn(props, this, props._i) || fallback;
2739
+ nodes = scopedSlotFn(props, slotVm || this, props._i) || fallback;
2738
2740
  } else {
2739
2741
  nodes = this.$slots[name] || fallback;
2740
2742
  }
@@ -7937,11 +7939,67 @@ function getStyle (vnode, checkChild) {
7937
7939
  var cssVarRE = /^--/;
7938
7940
  var importantRE = /\s*!important$/;
7939
7941
 
7942
+ // rpx2rem
7943
+ var defaultRpx2Unit = {
7944
+ unit: 'rem',
7945
+ unitRatio: 10 / 320,
7946
+ unitPrecision: 5
7947
+ };
7948
+
7949
+ var Rpx2Unit = Object.assign({}, defaultRpx2Unit);
7950
+
7951
+ function getRpx2Unit () {
7952
+ return Rpx2Unit
7953
+ }
7954
+
7955
+ function toFixed (number, precision) {
7956
+ var multiplier = Math.pow(10, precision + 1);
7957
+ var wholeNumber = Math.floor(number * multiplier);
7958
+ return (Math.round(wholeNumber / 10) * 10) / multiplier
7959
+ }
7960
+
7961
+ function _rpx2Unit (rpx, unit, unitRatio, unitPrecision) {
7962
+ if (unitRatio === 1) {
7963
+ return ("" + rpx + unit)
7964
+ }
7965
+ var value = toFixed(rpx * unitRatio, unitPrecision);
7966
+ return value === 0 ? '0' : ("" + value + unit)
7967
+ }
7968
+
7969
+ function createRpx2Unit (unit, unitRatio, unitPrecision) {
7970
+ // ignore: rpxCalcIncludeWidth
7971
+ /**
7972
+ * @param {string | number} val
7973
+ * @returns {string}
7974
+ */
7975
+ return function (val) {
7976
+ if (typeof val === 'string') {
7977
+ return val.replace(unitRE, function (m, $1) {
7978
+ if (!$1) {
7979
+ return m
7980
+ }
7981
+
7982
+ return _rpx2Unit(parseFloat($1), unit, unitRatio, unitPrecision)
7983
+ })
7984
+ } else if (typeof val === 'number') {
7985
+ return _rpx2Unit(val, unit, unitRatio, unitPrecision)
7986
+ }
7987
+ }
7988
+ }
7989
+
7990
+ var rpx2unit = createRpx2Unit(getRpx2Unit().unit, getRpx2Unit().unitRatio, getRpx2Unit().unitPrecision);
7991
+
7940
7992
  // upx,rpx 正则匹配
7941
7993
  var unitRE = /\b([+-]?\d+(\.\d+)?)[r|u]px\b/g;
7942
7994
 
7943
7995
  var transformUnit = function (val) {
7944
7996
  if (typeof val === 'string') {
7997
+ try {
7998
+ var config = __uniConfig.globalStyle || __uniConfig.window || {};
7999
+ if (config.dynamicRpx === true) {
8000
+ return rpx2unit(val)
8001
+ }
8002
+ } catch (error) {}
7945
8003
  return val.replace(unitRE, function (a, b) {
7946
8004
  /* eslint-disable no-undef */
7947
8005
  return uni.upx2px(b) + 'px'
@@ -11552,12 +11610,17 @@ function genScopedSlot (
11552
11610
  el,
11553
11611
  state
11554
11612
  ) {
11613
+ state.isInScopeSlot = true;
11555
11614
  var isLegacySyntax = el.attrsMap['slot-scope'];
11556
11615
  if (el.if && !el.ifProcessed && !isLegacySyntax) {
11557
- return genIf(el, state, genScopedSlot, "null")
11616
+ var res$1 = genIf(el, state, genScopedSlot, "null");
11617
+ state.isInScopeSlot = false;
11618
+ return res$1
11558
11619
  }
11559
11620
  if (el.for && !el.forProcessed) {
11560
- return genFor(el, state, genScopedSlot)
11621
+ var res$2 = genFor(el, state, genScopedSlot);
11622
+ state.isInScopeSlot = false;
11623
+ return res$2
11561
11624
  }
11562
11625
  var slotScope = el.slotScope === emptySlotScopeToken
11563
11626
  ? ""
@@ -11570,7 +11633,9 @@ function genScopedSlot (
11570
11633
  : genElement(el, state)) + "}";
11571
11634
  // reverse proxy v-slot without scope on this.$slots
11572
11635
  var reverseProxy = slotScope ? "" : ",proxy:true";
11573
- return ("{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}")
11636
+ var res = "{key:" + (el.slotTarget || "\"default\"") + ",fn:" + fn + reverseProxy + "}";
11637
+ state.isInScopeSlot = false;
11638
+ return res
11574
11639
  }
11575
11640
 
11576
11641
  function genChildren (
@@ -11656,7 +11721,6 @@ function genComment (comment) {
11656
11721
  function genSlot (el, state) {
11657
11722
  var slotName = el.slotName || '"default"';
11658
11723
  var children = genChildren(el, state);
11659
- var res = "_t(" + slotName + (children ? ("," + children) : '');
11660
11724
  var attrs = el.attrs || el.dynamicAttrs
11661
11725
  ? genProps((el.attrs || []).concat(el.dynamicAttrs || []).map(function (attr) { return ({
11662
11726
  // slot props are camelized
@@ -11666,16 +11730,16 @@ function genSlot (el, state) {
11666
11730
  }); }))
11667
11731
  : null;
11668
11732
  var bind$$1 = el.attrsMap['v-bind'];
11669
- if ((attrs || bind$$1) && !children) {
11670
- res += ",null";
11671
- }
11672
- if (attrs) {
11673
- res += "," + attrs;
11674
- }
11675
- if (bind$$1) {
11676
- res += (attrs ? '' : ',null') + "," + bind$$1;
11677
- }
11678
- return res + ')'
11733
+
11734
+ var args = [];
11735
+ args.push(slotName);
11736
+ args.push(children || 'null');
11737
+ args.push(attrs || 'null');
11738
+ args.push(bind$$1 || 'null');
11739
+ if (state.isInScopeSlot) {
11740
+ args.push('_svm');
11741
+ }
11742
+ return ("_t(" + (args.join(',')) + ")")
11679
11743
  }
11680
11744
 
11681
11745
  // componentName is el.component, take it as argument to shun flow's pessimistic refinement