wargerm 0.6.12 → 0.6.13

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.
Files changed (101) hide show
  1. package/dist/index.esm.js +1490 -12
  2. package/dist/index.js +1498 -19
  3. package/dist/{components → src/components}/AutoScroll/index.d.ts +0 -0
  4. package/dist/{components → src/components}/Breadcrumb/index.d.ts +0 -0
  5. package/dist/{components → src/components}/Button/index.d.ts +0 -0
  6. package/dist/{components → src/components}/Calendar/const.d.ts +0 -0
  7. package/dist/{components → src/components}/Calendar/example/demo1.d.ts +0 -0
  8. package/dist/{components → src/components}/Calendar/example/demo2.d.ts +0 -0
  9. package/dist/{components → src/components}/Calendar/index.d.ts +0 -0
  10. package/dist/{components → src/components}/Calendar/utils.d.ts +0 -0
  11. package/dist/{components → src/components}/Card/example/demo1.d.ts +0 -0
  12. package/dist/{components → src/components}/Card/example/demo2.d.ts +0 -0
  13. package/dist/{components → src/components}/Card/example/demo3.d.ts +0 -0
  14. package/dist/{components → src/components}/Card/index.d.ts +0 -0
  15. package/dist/{components → src/components}/Cascader/index.d.ts +0 -0
  16. package/dist/{components → src/components}/Checkbox/index.d.ts +0 -0
  17. package/dist/{components → src/components}/CountUp/index.d.ts +0 -0
  18. package/dist/{components → src/components}/DatePicker/index.d.ts +0 -0
  19. package/dist/{components → src/components}/DragBox/index.d.ts +0 -0
  20. package/dist/{components → src/components}/IconFont/index.d.ts +0 -0
  21. package/dist/{components → src/components}/Input/index.d.ts +0 -0
  22. package/dist/{components → src/components}/InputNumber/index.d.ts +0 -0
  23. package/dist/{components → src/components}/Modal/dialog.d.ts +0 -0
  24. package/dist/{components → src/components}/Modal/index.d.ts +0 -0
  25. package/dist/{components → src/components}/ModalForm/index.d.ts +0 -0
  26. package/dist/{components → src/components}/ModalTips/dialog.d.ts +0 -0
  27. package/dist/{components → src/components}/ModalTips/index.d.ts +0 -0
  28. package/dist/{components → src/components}/NtTable/FrameBox/index.d.ts +0 -0
  29. package/dist/{components → src/components}/NtTable/index.d.ts +0 -0
  30. package/dist/{components → src/components}/Number/index.d.ts +0 -0
  31. package/dist/{components → src/components}/NumericInput/index.d.ts +0 -0
  32. package/dist/{components → src/components}/Radio/index.d.ts +0 -0
  33. package/dist/{components → src/components}/ReactECharts/RAF.d.ts +0 -0
  34. package/dist/{components → src/components}/ReactECharts/index.d.ts +0 -0
  35. package/dist/{components → src/components}/ReactECharts/theme.d.ts +0 -0
  36. package/dist/{components → src/components}/ReactECharts/useRAF.d.ts +0 -0
  37. package/dist/{components → src/components}/Select/index.d.ts +0 -0
  38. package/dist/{components → src/components}/Swiper/index.d.ts +0 -0
  39. package/dist/{components → src/components}/Switch/index.d.ts +0 -0
  40. package/dist/{components → src/components}/TabelCard/example/InputGroup.d.ts +0 -0
  41. package/dist/{components → src/components}/TabelCard/example/demo1.d.ts +0 -0
  42. package/dist/{components → src/components}/TabelCard/example/demo2.d.ts +0 -0
  43. package/dist/{components → src/components}/TabelCard/example/demo3.d.ts +0 -0
  44. package/dist/{components → src/components}/TabelCard/index.d.ts +0 -0
  45. package/dist/{components → src/components}/Table/FrameBox/index.d.ts +0 -0
  46. package/dist/{components → src/components}/Table/example/demo1.d.ts +0 -0
  47. package/dist/{components → src/components}/Table/example/demo2.d.ts +0 -0
  48. package/dist/{components → src/components}/Table/example/demo3.d.ts +0 -0
  49. package/dist/{components → src/components}/Table/example/demo4.d.ts +0 -0
  50. package/dist/{components → src/components}/Table/example/demo5.d.ts +0 -0
  51. package/dist/{components → src/components}/Table/index.d.ts +0 -0
  52. package/dist/{components → src/components}/TreeSelect/index.d.ts +0 -0
  53. package/dist/{components → src/components}/Upload/example/demo1.d.ts +0 -0
  54. package/dist/{components → src/components}/Upload/example/demo2.d.ts +0 -0
  55. package/dist/{components → src/components}/Upload/index.d.ts +0 -0
  56. package/dist/{components → src/components}/Video/example/VideoDemo/demo1.d.ts +0 -0
  57. package/dist/{components → src/components}/Video/example/VideoDemo/demo2.d.ts +0 -0
  58. package/dist/{components → src/components}/Video/example/VideoDemo/demo3.d.ts +0 -0
  59. package/dist/{components → src/components}/Video/example/VideoDemo/demo4.d.ts +0 -0
  60. package/dist/{components → src/components}/Video/example/VideoDemo/demo5.d.ts +0 -0
  61. package/dist/{components → src/components}/Video/example/VideoDemo/demo6.d.ts +0 -0
  62. package/dist/{components → src/components}/Video/example/VideoDemo/demo7.d.ts +0 -0
  63. package/dist/{components → src/components}/Video/example/VideoDemo/demo8.d.ts +0 -0
  64. package/dist/{components → src/components}/Video/example/VideoDemo/demo9.d.ts +0 -0
  65. package/dist/{components → src/components}/Video/index.d.ts +0 -0
  66. package/dist/{components → src/components}/VideoPlayer/example/demo1.d.ts +0 -0
  67. package/dist/{components → src/components}/VideoPlayer/example/demo2.d.ts +0 -0
  68. package/dist/{components → src/components}/VideoPlayer/index.d.ts +0 -0
  69. package/dist/{components → src/components}/VideoPlayer/xgplayer.d.ts +0 -0
  70. package/dist/{components → src/components}/WDatePicker/index.d.ts +0 -0
  71. package/dist/{components → src/components}/WForm/example/demo1.d.ts +0 -0
  72. package/dist/{components → src/components}/WForm/example/demo2.d.ts +0 -0
  73. package/dist/{components → src/components}/WForm/example/demo3.d.ts +0 -0
  74. package/dist/{components → src/components}/WForm/index.d.ts +0 -0
  75. package/dist/{components → src/components}/Wcharts/LineEcharts/index.d.ts +0 -0
  76. package/dist/{components → src/components}/Wcharts/WaterLevelCharts/index.d.ts +0 -0
  77. package/dist/{components → src/components}/WebsocketHeart/index.d.ts +0 -0
  78. package/dist/{components → src/components}/useEventEmitter/example/demo1.d.ts +0 -0
  79. package/dist/{components/whox → src/components/wTracing}/example/demo1.d.ts +0 -0
  80. package/dist/src/components/wTracing/index.d.ts +20 -0
  81. package/dist/src/components/wTracing/lib/base.d.ts +36 -0
  82. package/dist/src/components/wTracing/lib/err.d.ts +14 -0
  83. package/dist/src/components/wTracing/lib/event.d.ts +14 -0
  84. package/dist/src/components/wTracing/lib/http-request.d.ts +5 -0
  85. package/dist/src/components/wTracing/lib/performance.d.ts +12 -0
  86. package/dist/src/components/wTracing/lib/pv.d.ts +15 -0
  87. package/dist/src/components/wTracing/utils/constant.d.ts +7 -0
  88. package/dist/src/components/wTracing/utils/device.d.ts +12 -0
  89. package/dist/src/components/wTracing/utils/methods.d.ts +53 -0
  90. package/dist/src/components/wTracing/utils/session.d.ts +9 -0
  91. package/dist/{components/wmox → src/components/whox}/example/demo1.d.ts +0 -0
  92. package/dist/src/components/wmox/example/demo1.d.ts +2 -0
  93. package/dist/{hooks → src/hooks}/useClickOutside.d.ts +0 -0
  94. package/dist/{hooks → src/hooks}/useDebounce.d.ts +0 -0
  95. package/dist/{hooks → src/hooks}/useEventEmitter.d.ts +0 -0
  96. package/dist/{hooks → src/hooks}/whox.d.ts +0 -0
  97. package/dist/{hooks → src/hooks}/wmox.d.ts +0 -0
  98. package/dist/{index.d.ts → src/index.d.ts} +1 -0
  99. package/dist/{utils → src/utils}/event.d.ts +0 -0
  100. package/dist/{utils → src/utils}/index.d.ts +0 -0
  101. package/package.json +2 -2
package/dist/index.esm.js CHANGED
@@ -739,6 +739,1483 @@ wmox.config = function (_ref) {
739
739
  run$1 = batch;
740
740
  };
741
741
 
742
+ /**
743
+ * 补全字符
744
+ * @param {*} num 初始值
745
+ * @param {*} len 需要补全的位数
746
+ * @param {*} placeholder 补全的值
747
+ * @returns 补全后的值
748
+ */
749
+ function pad(num, len) {
750
+ var placeholder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '0';
751
+ var str = String(num);
752
+
753
+ if (str.length < len) {
754
+ var result = str;
755
+
756
+ for (var i = 0; i < len - str.length; i += 1) {
757
+ result = placeholder + result;
758
+ }
759
+
760
+ return result;
761
+ }
762
+
763
+ return str;
764
+ }
765
+ /**
766
+ * 获取一个随机字符串(全局唯一标识符)
767
+ */
768
+
769
+
770
+ function uuid() {
771
+ var date = new Date(); // yyyy-MM-dd的16进制表示,7位数字
772
+
773
+ var hexDate = parseInt("".concat(date.getFullYear()).concat(pad(date.getMonth() + 1, 2)).concat(pad(date.getDate(), 2)), 10).toString(16); // hh-mm-ss-ms的16进制表示,最大也是7位
774
+
775
+ var hexTime = parseInt("".concat(pad(date.getHours(), 2)).concat(pad(date.getMinutes(), 2)).concat(pad(date.getSeconds(), 2)).concat(pad(date.getMilliseconds(), 3)), 10).toString(16); // 第8位数字表示后面的time字符串的长度
776
+
777
+ var guid = hexDate + hexTime.length + hexTime; // 补充随机数,补足32位的16进制数
778
+
779
+ while (guid.length < 32) {
780
+ guid += Math.floor(Math.random() * 16).toString(16);
781
+ } // 分为三段,前两段包含时间戳信息
782
+
783
+
784
+ return "".concat(guid.slice(0, 8), "-").concat(guid.slice(8, 16), "-").concat(guid.slice(16));
785
+ }
786
+ /**
787
+ * 获取cookie中目标name的值
788
+ * @param {String} name cookie名
789
+ * @returns
790
+ */
791
+
792
+
793
+ function getCookieByName(name) {
794
+ var result = document.cookie.match(new RegExp("".concat(name, "=([^;]+)(;|$)")));
795
+ return result ? result[1] : undefined;
796
+ }
797
+ /**
798
+ * 向下兼容发送信号的方法
799
+ */
800
+
801
+
802
+ var sendBeacon = navigator.sendBeacon ? function (url, data) {
803
+ if (data) navigator.sendBeacon(url, JSON.stringify(data));
804
+ } : function (url, data) {
805
+ // 传统方式传递参数
806
+ var beacon = new Image();
807
+ beacon.src = "".concat(url, "?v=").concat(encodeURIComponent(JSON.stringify(data)));
808
+ };
809
+
810
+ var arrayMap = Array.prototype.map || function polyfillMap(fn) {
811
+ var result = [];
812
+
813
+ for (var i = 0; i < this.length; i += 1) {
814
+ result.push(fn(this[i], i, this));
815
+ }
816
+
817
+ return result;
818
+ };
819
+ /**
820
+ * map方法
821
+ * @param {Array} arr 源数组
822
+ * @param {Function} fn 条件函数
823
+ * @returns
824
+ */
825
+
826
+
827
+ function map(arr, fn) {
828
+ return arrayMap.call(arr, fn);
829
+ }
830
+
831
+ var arrayFilter = Array.prototype.filter || function filterPolyfill(fn) {
832
+ var result = [];
833
+
834
+ for (var i = 0; i < this.length; i += 1) {
835
+ if (fn(this[i], i, this)) {
836
+ result.push(this[i]);
837
+ }
838
+ }
839
+
840
+ return result;
841
+ };
842
+ /**
843
+ * filter方法
844
+ * @param {Array} arr 源数组
845
+ * @param {Function} fn 条件函数
846
+ * @returns
847
+ */
848
+
849
+
850
+ function filter(arr, fn) {
851
+ return arrayFilter.call(arr, fn);
852
+ }
853
+ /**
854
+ * 可以理解为异步执行
855
+ * requestIdleCallback 是浏览器空闲时会自动执行内部函数
856
+ * requestAnimationFrame 是浏览器必须执行的
857
+ * 关于 requestIdleCallback 和 requestAnimationFrame 可以参考 https://www.cnblogs.com/cangqinglang/p/13877078.html
858
+ */
859
+
860
+
861
+ var nextTime = window.requestIdleCallback || window.requestAnimationFrame || function (callback) {
862
+ return setTimeout(callback, 17);
863
+ };
864
+
865
+ var DEVICE_KEY = '_warden_device_id'; // deviceKey - 固定
866
+
867
+ var SESSION_KEY = '_warden_session_id'; // sessionKey(一个站点只允许运行一个埋点程序) - 固定
868
+
869
+ var SURVIVIE_MILLI_SECONDS = 1800000; // session存活时长(30minutes) - 固定
870
+
871
+ var MAX_CACHE_LEN = 5; // 最大缓存数
872
+
873
+ var MAX_WAITING_TIME = 5000; // 最大等待时间
874
+
875
+ var _window = window,
876
+ screen = _window.screen;
877
+ var _document$documentEle = document.documentElement,
878
+ clientWidth = _document$documentEle.clientWidth,
879
+ clientHeight = _document$documentEle.clientHeight;
880
+ var width = screen.width,
881
+ height = screen.height,
882
+ colorDepth = screen.colorDepth,
883
+ pixelDepth = screen.pixelDepth;
884
+ var deviceId = getCookieByName(DEVICE_KEY);
885
+
886
+ if (!deviceId) {
887
+ deviceId = "t_".concat(uuid());
888
+ document.cookie = "".concat(DEVICE_KEY, "=").concat(deviceId, ";path=/;");
889
+ }
890
+
891
+ var device = {
892
+ clientHeight: clientHeight,
893
+ clientWidth: clientWidth,
894
+ colorDepth: colorDepth,
895
+ pixelDepth: pixelDepth,
896
+ deviceId: deviceId,
897
+ screenWidth: width,
898
+ screenHeight: height,
899
+ vendor: navigator.vendor,
900
+ platform: navigator.platform // 浏览器平台的环境,不是电脑系统的x64这样的(浏览器平台的环境可能是x32)
901
+
902
+ };
903
+
904
+ /**
905
+ * 会话控制,此会话只和具体的浏览器相关,与业务无关,和业务意义上的登录态没有任何关联,只是用于追踪同一个浏览器上访问页面的动作
906
+ */
907
+ /**
908
+ * 刷新会话存续期
909
+ */
910
+
911
+ function refreshSession() {
912
+ var id = getCookieByName(SESSION_KEY) || "s_".concat(uuid());
913
+ var expires = new Date(Date.now() + SURVIVIE_MILLI_SECONDS);
914
+ document.cookie = "".concat(SESSION_KEY, "=").concat(id, ";path=/;max-age=1800;expires=").concat(expires.toUTCString());
915
+ return id;
916
+ }
917
+ /**
918
+ * 获取sessionid
919
+ */
920
+
921
+
922
+ function getSessionId() {
923
+ return getCookieByName(SESSION_KEY) || refreshSession();
924
+ }
925
+
926
+ refreshSession(); // 初始化
927
+
928
+ var version = "0.6.13";
929
+
930
+ var pageId = uuid(); // 与一般业务上理解的sessionId做区分,此session与业务无关,单纯就是浏览器端和后端直接的联系
931
+
932
+ var sessionId = getSessionId();
933
+ var requestUrl = ''; // 服务请求地址
934
+
935
+ var events = []; // 批次队列
936
+
937
+ var timer = null; // 定时发送定时器
938
+
939
+ var base = _objectSpread2(_objectSpread2({}, device), {}, {
940
+ pageId: pageId,
941
+ sessionId: sessionId,
942
+ sdkVersion: version
943
+ });
944
+ /**
945
+ * 初始化基础数据
946
+ * @param {*} options 基础配置
947
+ */
948
+
949
+
950
+ function init() {
951
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
952
+ var appName = options.appName,
953
+ appCode = options.appCode,
954
+ ext = options.ext;
955
+ requestUrl = options.requestUrl;
956
+ base.appName = appName;
957
+ base.appCode = appCode;
958
+ base.ext = ext;
959
+ }
960
+ /**
961
+ * 记录需要发送的埋点数据
962
+ * @param {*} e 需要发送的事件信息
963
+ * @param {boolean} flush 是否立即发送
964
+ */
965
+
966
+
967
+ function emit(e) {
968
+ var flush = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
969
+ events = events.concat(e); // 追加到事件队列里
970
+
971
+ refreshSession();
972
+ clearTimeout(timer); // 满足最大记录数,立即发送,否则定时发送(flush为true代表立即发送)
973
+
974
+ events.length >= MAX_CACHE_LEN || flush ? send() : timer = setTimeout(function () {
975
+ send();
976
+ }, MAX_WAITING_TIME);
977
+ }
978
+ /**
979
+ * 发送埋点信息
980
+ */
981
+
982
+
983
+ function send() {
984
+ if (events.length) {
985
+ // 选取首部的部分数据来发送,performance会一次性采集大量数据追加到events中
986
+ var sendEvents = events.slice(0, MAX_CACHE_LEN); // 需要发送的事件
987
+
988
+ events = events.slice(MAX_CACHE_LEN); // 剩下待发的事件
989
+ var time = Date.now();
990
+ sendBeacon(requestUrl, {
991
+ baseInfo: _objectSpread2(_objectSpread2({}, base), {}, {
992
+ sendTime: time
993
+ }),
994
+ eventInfo: map(sendEvents, function (e) {
995
+ e.sendTime = time; // 设置发送时间
996
+ // 补充type字段,将click、scroll、change、submit事件作为一类存储
997
+
998
+ if (e.eventType === 'click' || e.eventType === 'scroll' || e.eventType === 'submit' || e.eventType === 'change') {
999
+ e.type = 'mix';
1000
+ return e;
1001
+ }
1002
+
1003
+ if (e.eventType === 'performance') {
1004
+ // 将性能进行分类,不同类型的性能数据差异较大,分开存放,资源、页面、请求
1005
+ switch (e.eventId) {
1006
+ case 'resource':
1007
+ e.type = 'resourcePerformance';
1008
+ break;
1009
+
1010
+ case 'page':
1011
+ e.type = 'pagePerformance';
1012
+ break;
1013
+
1014
+ case 'server':
1015
+ e.type = 'serverPerformance';
1016
+ break;
1017
+ }
1018
+
1019
+ return e;
1020
+ }
1021
+
1022
+ e.type = e.eventType; // 其他类型type同eventType
1023
+
1024
+ return e;
1025
+ })
1026
+ });
1027
+ if (events.length) nextTime(send); // 继续传输剩余内容,在下一个时间择机传输
1028
+ }
1029
+ }
1030
+ /**
1031
+ * 设置额外的 customerId
1032
+ * @param {*} id 需要设置的id
1033
+ */
1034
+
1035
+
1036
+ function setCustomerId(id) {
1037
+ base.customerId = id;
1038
+ }
1039
+ /**
1040
+ * 设置额外的 userUuid
1041
+ * @param {*} id 需要设置的id
1042
+ */
1043
+
1044
+
1045
+ function setUserUuid(id) {
1046
+ base.userUuid = id;
1047
+ }
1048
+ var base$1 = {
1049
+ init: init,
1050
+ emit: emit,
1051
+ pageId: pageId,
1052
+ setCustomerId: setCustomerId,
1053
+ setUserUuid: setUserUuid
1054
+ };
1055
+
1056
+ /*
1057
+ * @Author: lijin
1058
+ * @Date: 2022-12-06 20:08:10
1059
+ * @LastEditTime: 2022-12-13 16:01:12
1060
+ * @LastEditors: lijin
1061
+ * @Description:
1062
+ * @FilePath: \wargerm-components\src\components\wTracing\lib\pv.ts
1063
+ * 可以输入预定的版权声明、个性签名、空行等
1064
+ */
1065
+ var oldURL = window.location.href; // 最后一次的url
1066
+
1067
+ var historyLength = window.history.length; // 最后一次history栈的长度
1068
+
1069
+ /**
1070
+ * 发送数据
1071
+ * option 请求参数
1072
+ */
1073
+
1074
+ function tracePageView() {
1075
+ var option = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1076
+ var _option$url = option.url,
1077
+ url = _option$url === void 0 ? window.location.href : _option$url,
1078
+ _option$referer = option.referer,
1079
+ referer = _option$referer === void 0 ? oldURL : _option$referer,
1080
+ _option$actions = option.actions,
1081
+ actions = _option$actions === void 0 ? '' : _option$actions,
1082
+ params = option.params;
1083
+ var action = actions;
1084
+
1085
+ if (!action && window.history.length < 50) {
1086
+ action = historyLength === window.history.length ? 'back_forward' : 'navigation';
1087
+ historyLength = window.history.length;
1088
+ } // 如果option.title为空,则等待框架处理document.title,延迟17ms
1089
+ // 为什么是17ms? 一秒60Hz是基准,平均1Hz是17毫秒,只要出来了页面那就有 document.title
1090
+
1091
+
1092
+ setTimeout(function () {
1093
+ emit({
1094
+ eventType: 'pv',
1095
+ eventId: pageId,
1096
+ url: url,
1097
+ referer: referer,
1098
+ params: params,
1099
+ title: option.title || document.title,
1100
+ action: action,
1101
+ triggerTime: Date.now()
1102
+ });
1103
+ }, option.title ? 0 : 17);
1104
+ oldURL = url;
1105
+ historyLength = window.history.length;
1106
+ }
1107
+ /**
1108
+ * 路由Pv采集
1109
+ * pvHashtag 是否监听hash变化
1110
+ */
1111
+
1112
+
1113
+ function init$1() {
1114
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1115
+ var pvCore = options.pvCore,
1116
+ pvHashtag = options.pvHashtag;
1117
+ var referer = document.referrer; // 获取是从哪个页面跳转来的
1118
+
1119
+ if (!pvCore) return;
1120
+ var lastIsPop = false; // 最后一次触发路由变化是否为popState触发
1121
+
1122
+ tracePageView({
1123
+ url: oldURL,
1124
+ referer: referer
1125
+ });
1126
+
1127
+ if (window.history.pushState) {
1128
+ // 劫持history.pushState history.replaceState
1129
+ var push = window.history.pushState.bind(window.history);
1130
+
1131
+ window.history.pushState = function (data, title, url) {
1132
+ lastIsPop = false;
1133
+ var result = push(data, title, url);
1134
+ tracePageView({
1135
+ actions: 'navigation'
1136
+ });
1137
+ return result;
1138
+ };
1139
+
1140
+ var repalce = window.history.replaceState.bind(window.history);
1141
+
1142
+ window.history.replaceState = function (data, title, url) {
1143
+ lastIsPop = false;
1144
+ var result = repalce(data, title, url);
1145
+ tracePageView({
1146
+ actions: 'navigation'
1147
+ });
1148
+ return result;
1149
+ }; // hash变化也会触发popstate事件,而且会先触发popstate事件
1150
+ // 可以使用popstate来代替hashchange,如果支持History H5 Api
1151
+ // https://developer.mozilla.org/zh-CN/docs/Web/API/Window/popstate_event
1152
+
1153
+
1154
+ window.addEventListener('popstate', function () {
1155
+ if (window.location.hash !== '') {
1156
+ var oldHost = oldURL.indexOf('#') > 0 // 多页面情况下 history模式刷新还是在pv页面
1157
+ ? oldURL.slice(0, oldURL.indexOf('#')) : oldURL;
1158
+ if (window.location.href.slice(0, window.location.href.indexOf('#')) === oldHost && !pvHashtag) return;
1159
+ }
1160
+
1161
+ lastIsPop = true;
1162
+ tracePageView();
1163
+ });
1164
+ } // 监听hashchange
1165
+
1166
+
1167
+ window.addEventListener('hashchange', function () {
1168
+ if (pvHashtag && !lastIsPop) tracePageView();
1169
+ lastIsPop = false;
1170
+ });
1171
+ }
1172
+
1173
+ var pv = {
1174
+ init: init$1,
1175
+ tracePageView: tracePageView
1176
+ };
1177
+
1178
+ function setFullErrInfo(errorInfo) {
1179
+ var info = _objectSpread2(_objectSpread2({}, errorInfo), {}, {
1180
+ eventType: 'error',
1181
+ url: window.location.href,
1182
+ triggerTime: Date.now()
1183
+ });
1184
+
1185
+ emit(info);
1186
+ }
1187
+
1188
+ function parseStack(err) {
1189
+ var _err$stack = err.stack,
1190
+ stack = _err$stack === void 0 ? '' : _err$stack,
1191
+ _err$message = err.message,
1192
+ message = _err$message === void 0 ? '' : _err$message;
1193
+ var result = {
1194
+ errMessage: message,
1195
+ errStack: stack
1196
+ };
1197
+
1198
+ if (stack) {
1199
+ var rChromeCallStack = /^\s*at\s*([^(]+)\s*\((.+?):(\d+):(\d+)\)$/;
1200
+ var rMozlliaCallStack = /^\s*([^@]*)@(.+?):(\d+):(\d+)$/; // chrome中包含了message信息,将其去除,并去除后面的换行符
1201
+
1202
+ var callStackStr = stack.replace(new RegExp("^[\\w\\s:]*".concat(message, "\n")), '');
1203
+ var callStackFrameList = map(filter(callStackStr.split('\n'), function (item) {
1204
+ return item;
1205
+ }), function (str) {
1206
+ var chromeErrResult = str.match(rChromeCallStack);
1207
+
1208
+ if (chromeErrResult) {
1209
+ return {
1210
+ src: chromeErrResult[2],
1211
+ line: chromeErrResult[3],
1212
+ col: chromeErrResult[4] // 错误发生位置的列数
1213
+
1214
+ };
1215
+ }
1216
+
1217
+ var mozlliaErrResult = str.match(rMozlliaCallStack);
1218
+
1219
+ if (mozlliaErrResult) {
1220
+ return {
1221
+ src: mozlliaErrResult[2],
1222
+ line: mozlliaErrResult[3],
1223
+ col: mozlliaErrResult[4]
1224
+ };
1225
+ }
1226
+
1227
+ return {};
1228
+ });
1229
+ var item = callStackFrameList[0] || {};
1230
+ return _objectSpread2(_objectSpread2({}, result), item);
1231
+ }
1232
+
1233
+ return result;
1234
+ }
1235
+
1236
+ function parseError(e) {
1237
+ if (e instanceof Error) {
1238
+ var message = e.message,
1239
+ stack = e.stack,
1240
+ lineNumber = e.lineNumber,
1241
+ fileName = e.fileName,
1242
+ columnNumber = e.columnNumber;
1243
+
1244
+ if (fileName) {
1245
+ return {
1246
+ errMessage: message,
1247
+ errStack: stack,
1248
+ line: lineNumber,
1249
+ col: columnNumber,
1250
+ src: fileName
1251
+ };
1252
+ }
1253
+
1254
+ return parseStack(e);
1255
+ }
1256
+
1257
+ if (e.message) return parseStack(e);
1258
+ if (typeof e === 'string') return {
1259
+ errMessage: e
1260
+ };
1261
+ return {};
1262
+ }
1263
+
1264
+ function parseErrorEvent(event) {
1265
+ var target = event.target,
1266
+ type = event.type; // promise异常
1267
+ // 依旧使用code,不区分是否从promise中捕获的
1268
+
1269
+ if (type === 'unhandledrejection') return _objectSpread2({
1270
+ eventId: 'code'
1271
+ }, parseError(event.reason)); // html元素上发生的异常错误
1272
+
1273
+ if (target.nodeType === 1) {
1274
+ var result = {
1275
+ eventId: target.nodeName
1276
+ };
1277
+
1278
+ switch (target.nodeName.toLowerCase()) {
1279
+ case 'link':
1280
+ result.src = target.href;
1281
+ break;
1282
+
1283
+ default:
1284
+ result.src = target.currentSrc || target.src;
1285
+ }
1286
+
1287
+ return result;
1288
+ } // 代码异常
1289
+
1290
+
1291
+ if (event.error) {
1292
+ // chrome中的error对象没有fileName等属性,将event中的补充给error对象
1293
+ var e = event.error;
1294
+ e.fileName = e.filename || event.filename;
1295
+ e.columnNumber = e.colno || event.colno;
1296
+ e.lineNumber = e.lineno || event.lineno;
1297
+ return _objectSpread2({
1298
+ eventId: 'code'
1299
+ }, parseError(e));
1300
+ } // ie9版本,从全局的event对象中获取错误信息
1301
+
1302
+
1303
+ return {
1304
+ eventId: 'code',
1305
+ line: window.event.errorLine,
1306
+ col: window.event.errorCharacter,
1307
+ message: window.event.errorMessage,
1308
+ src: window.event.errorUrl
1309
+ };
1310
+ }
1311
+
1312
+ function init$2(_ref) {
1313
+ var errorCore = _ref.errorCore;
1314
+ if (!errorCore) return; // 捕获阶段可以获取资源加载错误,script.onError link.onError img.onError,无法知道具体状态
1315
+
1316
+ window.addEventListener('error', function (e) {
1317
+ setFullErrInfo(parseErrorEvent(e));
1318
+ }, true); // promise调用链未捕获异常
1319
+
1320
+ window.addEventListener('unhandledrejection', function (e) {
1321
+ setFullErrInfo(parseErrorEvent(e));
1322
+ }); // 劫持console.error
1323
+
1324
+ var consoleError = console.error;
1325
+
1326
+ console.error = function ce() {
1327
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1328
+ args[_key] = arguments[_key];
1329
+ }
1330
+
1331
+ args.forEach(function (e) {
1332
+ setFullErrInfo(_objectSpread2({
1333
+ eventId: 'code'
1334
+ }, parseError(e)));
1335
+ });
1336
+ consoleError.apply(console, args);
1337
+ };
1338
+ }
1339
+ /**
1340
+ * 主动触发错误上报
1341
+ * @param {*} eventId 事件ID
1342
+ * @param {*} message 错误信息
1343
+ * @param {*} options 自定义配置信息
1344
+ * @returns
1345
+ */
1346
+
1347
+
1348
+ function traceError(eventId, message) {
1349
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1350
+
1351
+ var customErrorRecord = _objectSpread2({
1352
+ eventId: eventId,
1353
+ errMessage: message
1354
+ }, options); // 针对自定义的异常上报,对params对特殊处理,将其序列化为string
1355
+
1356
+
1357
+ var params = customErrorRecord.params;
1358
+
1359
+ if (params) {
1360
+ customErrorRecord.params = params;
1361
+ }
1362
+
1363
+ return setFullErrInfo(customErrorRecord);
1364
+ }
1365
+
1366
+ var err = {
1367
+ init: init$2,
1368
+ traceError: traceError
1369
+ };
1370
+
1371
+ var supported = {
1372
+ performance: !!window.performance,
1373
+ getEntriesByType: !!(window.performance && performance.getEntriesByType),
1374
+ PerformanceObserver: 'PerformanceObserver' in window,
1375
+ MutationObserver: 'MutationObserver' in window,
1376
+ PerformanceNavigationTiming: 'PerformanceNavigationTiming' in window
1377
+ }; // 资源属性
1378
+
1379
+ var performanceEntryAttrs = {
1380
+ initiatorType: '',
1381
+ transferSize: 0,
1382
+ encodedBodySize: 0,
1383
+ decodedBodySize: 0,
1384
+ duration: 0,
1385
+ redirectStart: 0,
1386
+ redirectEnd: 0,
1387
+ startTime: 0,
1388
+ fetchStart: 0,
1389
+ domainLookupStart: 0,
1390
+ domainLookupEnd: 0,
1391
+ connectStart: 0,
1392
+ connectEnd: 0,
1393
+ requestStart: 0,
1394
+ responseStart: 0,
1395
+ responseEnd: 0,
1396
+ workerStart: 0
1397
+ };
1398
+ /**
1399
+ * 格式化性能记录,小数位数保留最多两位,等于0的字段不传输,标记为undefined
1400
+ */
1401
+
1402
+ function normalizePerformanceRecord(e) {
1403
+ Object.keys(e).forEach(function (p) {
1404
+ var v = e[p];
1405
+ if (typeof v === 'number') e[p] = v === 0 ? undefined : parseFloat(v.toFixed(2));
1406
+ });
1407
+ return e;
1408
+ }
1409
+ /**
1410
+ * 发送页面追踪资源加载性能数据
1411
+ * 支持getEntriesByType的情况下才追踪
1412
+ */
1413
+
1414
+
1415
+ function traceResourcePerformance(performance) {
1416
+ // 排除xmlhttprequest类型,服务器有响应便会记录,包括404的请求,转由http-request模块负责记录请求数据,区分请求状态
1417
+ // 同时也会排除一些其他类型,比如在引入一个script后会触发一次性能监控,它的类型是beacon,这一次的要排除
1418
+ var observerTypeList = ['img', 'script', 'link', 'audio', 'video', 'css'];
1419
+ var entries = performance.getEntriesByType('resource');
1420
+ var records = [];
1421
+ entries.forEach(function (entry) {
1422
+ var _entry$initiatorType = entry.initiatorType,
1423
+ initiatorType = _entry$initiatorType === void 0 ? '' : _entry$initiatorType; // initiatorType: 通过某种方式请求的资源,比如script,link
1424
+ // 只记录observerTypeList中列出的资源类型请求,不在列表中则跳过
1425
+
1426
+ if (observerTypeList.indexOf(initiatorType.toLowerCase()) < 0) return;
1427
+ var value = {};
1428
+ var attrKeys = Object.keys(performanceEntryAttrs);
1429
+ attrKeys.forEach(function (attr) {
1430
+ value[attr] = entry[attr];
1431
+ });
1432
+ records.push(normalizePerformanceRecord(_objectSpread2(_objectSpread2({}, value), {}, {
1433
+ eventType: 'performance',
1434
+ eventId: 'resource',
1435
+ src: entry.name,
1436
+ triggerTime: Date.now(),
1437
+ url: window.location.href
1438
+ })));
1439
+ });
1440
+ if (records.length) emit(records);
1441
+ return records;
1442
+ }
1443
+ /**
1444
+ * 监听异步资源加载信息
1445
+ */
1446
+
1447
+
1448
+ function observeAsyncInfo() {
1449
+ var observer = new PerformanceObserver(traceResourcePerformance);
1450
+ observer.observe({
1451
+ entryTypes: ['resource']
1452
+ });
1453
+ }
1454
+ /**
1455
+ * 监听异步插入的script、link、img,DOM更新操作记录
1456
+ */
1457
+
1458
+
1459
+ function observeSourceInsert() {
1460
+ var tags = ['img', 'script', 'link']; // 检测异步插入的script、link、img,会有一些延迟,一些连接建立、包体大小的数据会丢失,精度下降
1461
+ // MutationObserver DOM3 Events规范,是个异步监听,只有在全部DOM操作完成之后才会调用callback
1462
+
1463
+ var observer = new MutationObserver(function (mutationsList) {
1464
+ var _loop = function _loop(i) {
1465
+ var startTime = Date.now();
1466
+ var _mutationsList$i$adde = mutationsList[i].addedNodes,
1467
+ addedNodes = _mutationsList$i$adde === void 0 ? [] : _mutationsList$i$adde;
1468
+ var records = [];
1469
+ addedNodes.forEach(function (node) {
1470
+ var nodeName = node.nodeName;
1471
+
1472
+ if (tags.indexOf(nodeName.toLowerCase()) !== -1) {
1473
+ node.addEventListener('load', function () {
1474
+ var endTime = Date.now();
1475
+ records.push(normalizePerformanceRecord({
1476
+ // 没有其他的时间属性,只记录能获取到的
1477
+ eventType: 'performance',
1478
+ eventId: 'resource',
1479
+ src: node.src || node.href,
1480
+ duration: endTime - startTime,
1481
+ triggerTime: Date.now(),
1482
+ url: window.location.href
1483
+ }));
1484
+ });
1485
+ }
1486
+ });
1487
+ emit(records);
1488
+ };
1489
+
1490
+ for (var i = 0; i < mutationsList.length; i += 1) {
1491
+ _loop(i);
1492
+ }
1493
+ });
1494
+ observer.observe(window.document, {
1495
+ subtree: true,
1496
+ childList: true // 表示观察目标子节点的变化,比如添加或者删除目标子节点,不包括修改子节点以及子节点后代的变化
1497
+ // attributes: true, // 观察属性变动
1498
+ // attributeFilter: ['src', 'href'], // 要观察的属性
1499
+
1500
+ }); // observer.disconnect();
1501
+ }
1502
+ /**
1503
+ * 兼容-异步资源
1504
+ */
1505
+
1506
+
1507
+ function observeAsyncResource() {
1508
+ if (supported.PerformanceObserver) {
1509
+ observeAsyncInfo(); // 监听异步资源加载性能数据 chrome≥52
1510
+ } else if (supported.MutationObserver) {
1511
+ observeSourceInsert(); // 监听资源、DOM更新操作记录 chrome≥26 ie11
1512
+ }
1513
+ }
1514
+ /**
1515
+ * 页面资源加载性能数据
1516
+ */
1517
+
1518
+
1519
+ function observeResource() {
1520
+ traceResourcePerformance(window.performance);
1521
+ observeAsyncResource();
1522
+ }
1523
+ /**
1524
+ * 发送首次页面性能数据
1525
+ */
1526
+
1527
+
1528
+ function observeNavigationTiming() {
1529
+ var times = {};
1530
+ var _window = window,
1531
+ performance = _window.performance;
1532
+ var t = performance.timing;
1533
+ times.fmp = 0; // 首屏时间 (渲染节点增量最大的时间点)
1534
+
1535
+ if (supported.getEntriesByType) {
1536
+ var paintEntries = performance.getEntriesByType('paint');
1537
+ if (paintEntries.length) times.fmp = paintEntries[paintEntries.length - 1].startTime; // 优先使用 navigation v2 https://www.w3.org/TR/navigation-timing-2/
1538
+
1539
+ if (supported.PerformanceNavigationTiming) {
1540
+ var nt2Timing = performance.getEntriesByType('navigation')[0];
1541
+ if (nt2Timing) t = nt2Timing;
1542
+ }
1543
+ } // 从开始发起这个页面的访问开始算起,减去重定向跳转的时间,在performanceV2版本下才进行计算,v1版本的fetchStart是时间戳而不是相对于访问起始点的相对时间
1544
+
1545
+
1546
+ if (times.fmp && supported.PerformanceNavigationTiming) times.fmp -= t.fetchStart; // 白屏时间 (从请求开始到浏览器开始解析第一批HTML文档字节的时间差)
1547
+ // times.fpt = t.responseEnd - t.fetchStart;
1548
+
1549
+ times.tti = t.domInteractive - t.fetchStart; // 首次可交互时间
1550
+
1551
+ times.ready = t.domContentLoadedEventEnd - t.fetchStart; // HTML加载完成时间
1552
+
1553
+ times.loadon = t.loadEventStart - t.fetchStart; // 页面完全加载时间
1554
+
1555
+ times.firstbyte = t.responseStart - t.domainLookupStart; // 首包时间
1556
+
1557
+ times.dns = t.domainLookupEnd - t.domainLookupStart; // dns查询耗时
1558
+
1559
+ times.appcache = t.domainLookupStart - t.fetchStart; // dns缓存时间
1560
+
1561
+ times.tcp = t.connectEnd - t.connectStart; // tcp连接耗时
1562
+
1563
+ times.ttfb = t.responseStart - t.requestStart; // 请求响应耗时
1564
+
1565
+ times.trans = t.responseEnd - t.responseStart; // 内容传输耗时
1566
+
1567
+ times.dom = t.domInteractive - t.responseEnd; // dom解析耗时
1568
+
1569
+ times.res = t.loadEventStart - t.domContentLoadedEventEnd; // 同步资源加载耗时
1570
+
1571
+ times.ssllink = t.connectEnd - t.secureConnectionStart; // SSL安全连接耗时
1572
+
1573
+ times.redirect = t.redirectEnd - t.redirectStart; // 重定向时间
1574
+
1575
+ times.unloadTime = t.unloadEventEnd - t.unloadEventStart; // 上一个页面的卸载耗时
1576
+
1577
+ emit(normalizePerformanceRecord(_objectSpread2(_objectSpread2({}, times), {}, {
1578
+ eventType: 'performance',
1579
+ eventId: 'page',
1580
+ url: window.location.href
1581
+ })));
1582
+ }
1583
+
1584
+ function init$3(_ref) {
1585
+ var performanceFirstResource = _ref.performanceFirstResource,
1586
+ performanceCore = _ref.performanceCore;
1587
+ if (!performanceFirstResource && !performanceCore) return; // 初始化方法可能在onload事件之后才执行,此时不会触发load事件了,检查document.readyState属性来判断onload事件是否会被触发
1588
+
1589
+ if (document.readyState === 'complete') {
1590
+ if (supported.performance && performanceFirstResource) observeNavigationTiming();
1591
+ if (supported.getEntriesByType && performanceCore) observeResource();
1592
+ } else {
1593
+ window.addEventListener('load', function () {
1594
+ if (supported.performance && performanceFirstResource) observeNavigationTiming();
1595
+ if (supported.getEntriesByType && performanceCore) observeResource();
1596
+ });
1597
+ }
1598
+ }
1599
+ /**
1600
+ * 主动触发性能事件上报
1601
+ * @param {*} eventId 事件ID
1602
+ * @param {*} options 自定义配置信息
1603
+ */
1604
+
1605
+
1606
+ function tracePerformance(eventId, options) {
1607
+ var record = _objectSpread2(_objectSpread2({
1608
+ triggerTime: Date.now(),
1609
+ url: window.location.href
1610
+ }, options), {}, {
1611
+ eventId: eventId,
1612
+ eventType: 'performance'
1613
+ });
1614
+
1615
+ emit(normalizePerformanceRecord(record));
1616
+ }
1617
+
1618
+ var performance$1 = {
1619
+ init: init$3,
1620
+ tracePerformance: tracePerformance
1621
+ };
1622
+
1623
+ var RequestTemplate = /*#__PURE__*/_createClass(function RequestTemplate() {
1624
+ var _this = this;
1625
+
1626
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1627
+
1628
+ _classCallCheck(this, RequestTemplate);
1629
+
1630
+ var list = ['src', 'method', 'duration', 'responseStatus'];
1631
+ list.forEach(function (key) {
1632
+ _this[key] = config[key] || null;
1633
+ });
1634
+ });
1635
+ /**
1636
+ * fetch请求拦截
1637
+ */
1638
+
1639
+
1640
+ function interceptFetch(performanceServer, errorServer) {
1641
+ var nativeFetch = window.fetch;
1642
+
1643
+ if (nativeFetch) {
1644
+ window.fetch = function traceFetch(target) {
1645
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1646
+ var fetchStart = Date.now();
1647
+ var _options$method = options.method,
1648
+ method = _options$method === void 0 ? 'GET' : _options$method;
1649
+ var result = nativeFetch(target, options);
1650
+ result.then(function (res) {
1651
+ var url = res.url,
1652
+ status = res.status,
1653
+ statusText = res.statusText;
1654
+
1655
+ if (status === 200 || status === 304) {
1656
+ if (performanceServer) {
1657
+ performance$1.tracePerformance('server', {
1658
+ src: url,
1659
+ duration: Date.now() - fetchStart,
1660
+ responseStatus: status,
1661
+ params: method.toUpperCase() === 'POST' ? options.body : undefined
1662
+ });
1663
+ }
1664
+ } else if (errorServer) {
1665
+ err.traceError('server', statusText, {
1666
+ src: url,
1667
+ responseStatus: status,
1668
+ params: method.toUpperCase() === 'POST' ? options.body : undefined
1669
+ });
1670
+ }
1671
+ }, function (e) {
1672
+ // 无法发起请求,连接失败
1673
+ err.traceError('server', e.message, {
1674
+ src: target
1675
+ });
1676
+ });
1677
+ return result;
1678
+ };
1679
+ }
1680
+ }
1681
+ /**
1682
+ * ajax, axios请求拦截
1683
+ */
1684
+
1685
+
1686
+ function interceptAjax(performanceServer, errorServer) {
1687
+ var _XMLHttpRequest$proto = XMLHttpRequest.prototype,
1688
+ open = _XMLHttpRequest$proto.open,
1689
+ send = _XMLHttpRequest$proto.send;
1690
+
1691
+ var _config = new RequestTemplate(); // 劫持 open方法
1692
+
1693
+
1694
+ XMLHttpRequest.prototype.open = function openXHR(method, url, async) {
1695
+ _config.requestMethod = method;
1696
+ _config.src = url;
1697
+ return open.call(this, method, url, async);
1698
+ }; // 劫持 send方法
1699
+
1700
+
1701
+ XMLHttpRequest.prototype.send = function (body) {
1702
+ var _this2 = this;
1703
+
1704
+ // body 就是post方法携带的参数
1705
+ // readyState发生改变时触发,也就是请求状态改变时
1706
+ // readyState 会依次变为 2,3,4 也就是会触发三次这里
1707
+ this.addEventListener('readystatechange', function () {
1708
+ var readyState = _this2.readyState,
1709
+ status = _this2.status,
1710
+ _this2$responseURL = _this2.responseURL,
1711
+ responseURL = _this2$responseURL === void 0 ? _config.src : _this2$responseURL,
1712
+ responseText = _this2.responseText;
1713
+
1714
+ if (readyState === 4) {
1715
+ // 请求已完成,且响应已就绪
1716
+ if (status === 200 || status === 304) {
1717
+ if (performanceServer) {
1718
+ performance$1.tracePerformance('server', {
1719
+ src: responseURL,
1720
+ responseStatus: status,
1721
+ duration: Date.now() - _config.triggerTime,
1722
+ params: body ? body : undefined
1723
+ });
1724
+ }
1725
+ } else if (errorServer) {
1726
+ err.traceError('server', responseText, {
1727
+ src: responseURL,
1728
+ responseStatus: status,
1729
+ params: body ? body : undefined
1730
+ });
1731
+ }
1732
+ }
1733
+ });
1734
+ _config.triggerTime = Date.now();
1735
+ return send.call(this, body);
1736
+ };
1737
+ }
1738
+
1739
+ function init$4(_ref) {
1740
+ var performanceServer = _ref.performanceServer,
1741
+ errorServer = _ref.errorServer;
1742
+ if (!performanceServer && !errorServer) return;
1743
+ interceptAjax(performanceServer, errorServer);
1744
+ interceptFetch(performanceServer, errorServer);
1745
+ }
1746
+
1747
+ var http = {
1748
+ init: init$4
1749
+ };
1750
+
1751
+ var RequestTemplate$1 = /*#__PURE__*/_createClass(function RequestTemplate() {
1752
+ var _this = this;
1753
+
1754
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1755
+
1756
+ _classCallCheck(this, RequestTemplate);
1757
+
1758
+ var list = ['eventType', 'eventId', 'url', 'referer', 'action', 'params', 'millisecond'];
1759
+ list.forEach(function (key) {
1760
+ _this[key] = config[key] || null;
1761
+ });
1762
+ });
1763
+
1764
+ var RequestTemplateClick = /*#__PURE__*/_createClass(function RequestTemplateClick() {
1765
+ var _this2 = this;
1766
+
1767
+ var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1768
+
1769
+ _classCallCheck(this, RequestTemplateClick);
1770
+
1771
+ var list = ['eventType', 'eventId', 'url', 'params', 'title', 'x', 'y'];
1772
+ list.forEach(function (key) {
1773
+ _this2[key] = config[key] || null;
1774
+ });
1775
+ });
1776
+ /**
1777
+ * 是否为简单的标签
1778
+ * 只包含下面的arr数组内的标签才是简单的标签
1779
+ */
1780
+
1781
+
1782
+ function isSimpleEl(children) {
1783
+ if (children.length > 0) {
1784
+ var arr = ['em', 'b', 'strong', 'span', 'img', 'i', 'code'];
1785
+ var a = children.filter(function (_ref) {
1786
+ var tagName = _ref.tagName;
1787
+ return arr.indexOf(tagName.toLowerCase()) >= 0;
1788
+ });
1789
+ return a.length === children.length;
1790
+ }
1791
+
1792
+ return true;
1793
+ }
1794
+ /**
1795
+ * 获取元素到最外层元素组成的数组
1796
+ */
1797
+
1798
+
1799
+ function getNodePath(node) {
1800
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1801
+ if (!node) return [];
1802
+ var _options$includeSelf = options.includeSelf,
1803
+ includeSelf = _options$includeSelf === void 0 ? true : _options$includeSelf,
1804
+ _options$order = options.order,
1805
+ order = _options$order === void 0 ? 'asc' : _options$order;
1806
+ var parent = includeSelf ? node : node.parentElement;
1807
+ var result;
1808
+
1809
+ while (parent) {
1810
+ result = order === 'asc' ? result.concat(parent) : [parent].concat(result);
1811
+ parent = parent.parentElement;
1812
+ }
1813
+
1814
+ return result;
1815
+ }
1816
+ /**
1817
+ * 获取元素的关系字符串
1818
+ * 例如两层div的关系会得到字符串: div>div
1819
+ */
1820
+
1821
+
1822
+ function getNodeXPath(node) {
1823
+ var curPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1824
+ if (!node) return curPath;
1825
+ var parent = node.parentElement;
1826
+ var index = 0; // 这个index 暂时没什么用
1827
+
1828
+ var id = node.id;
1829
+ var tagName = node.tagName.toLowerCase();
1830
+ var path = curPath ? ">".concat(curPath) : '';
1831
+ var indexBrackets = index ? ".".concat(index) : '';
1832
+ if (!parent || parent === window || parent === document.documentElement || parent === document.body) return "".concat(tagName).concat(path);
1833
+ if (id) return "#".concat(id).concat(path); // 知道了id 就不需要获取上下级关系了(id是唯一的)
1834
+
1835
+ if (parent.children.length > 1) index = Array.prototype.indexOf.call(parent.children, node);
1836
+ return getNodeXPath(parent, "".concat(tagName).concat(indexBrackets).concat(path));
1837
+ }
1838
+ /**
1839
+ * 点击事件
1840
+ */
1841
+
1842
+
1843
+ function clickCollection() {
1844
+ document.addEventListener('click', function (e) {
1845
+ // 点击事件
1846
+ var _config = new RequestTemplateClick({
1847
+ eventType: 'click'
1848
+ });
1849
+ var path = e.path;
1850
+ if (path === undefined) path = e.target ? getNodePath(e.target) : []; // 获取被点击的元素到最外层元素组成的数组
1851
+
1852
+ var target = path.find(function (el) {
1853
+ return el.hasAttribute && (el.hasAttribute('data-warden-container') || el.hasAttribute('data-warden-event-id') || el.hasAttribute('data-warden-title'));
1854
+ });
1855
+ if (!target) return;
1856
+ _config.title = extractTitleByTarget(target);
1857
+ _config.eventId = extractDataByPath(path);
1858
+ _config.params = extractParamsByPath(path);
1859
+ _config.elementPath = getNodeXPath(target).slice(-128); // 长度限制128字符
1860
+
1861
+ var _e$target$getBounding = e.target.getBoundingClientRect(),
1862
+ top = _e$target$getBounding.top,
1863
+ left = _e$target$getBounding.left; // 元素距离html的距离
1864
+
1865
+
1866
+ var _document$documentEle = document.documentElement,
1867
+ scrollTop = _document$documentEle.scrollTop,
1868
+ scrollLeft = _document$documentEle.scrollLeft; // html距离上和左侧的距离(一般都是0)
1869
+
1870
+ var x = left + scrollLeft;
1871
+ var y = top + scrollTop;
1872
+ _config.x = x;
1873
+ _config.y = y;
1874
+ _config.triggerTime = Date.now(); // 点击时间
1875
+
1876
+ _config.url = window.location.href; // 当前页面的url
1877
+
1878
+ emit(_config);
1879
+ }, true);
1880
+ }
1881
+ /**
1882
+ * 加载 & 卸载事件
1883
+ */
1884
+
1885
+
1886
+ function dwellCollector(eventUnload) {
1887
+ var _config = new RequestTemplate$1({
1888
+ eventType: 'dwell'
1889
+ });
1890
+
1891
+ window.addEventListener('load', function () {
1892
+ // 加载完成事件
1893
+ _config.entryTime = Date.now();
1894
+ }, true);
1895
+ if (!eventUnload) return;
1896
+ window.addEventListener('beforeunload', function () {
1897
+ // 卸载事件
1898
+ _config.eventId = uuid();
1899
+ _config.url = window.location.href; // 当前页面 url
1900
+
1901
+ _config.referer = document.referrer; // 上级页面 url(从哪个页面跳过来的就是上级页面)
1902
+
1903
+ _config.triggerTime = Date.now(); // 卸载时间
1904
+
1905
+ _config.millisecond = Date.now() - _config.entryTime; // 停留多久
1906
+
1907
+ var mapping = {
1908
+ 0: 'navigate',
1909
+ 1: 'reload',
1910
+ 2: 'back_forward',
1911
+ 255: 'reserved' // 任何其他来源的加载
1912
+
1913
+ };
1914
+ var type = performance.navigation.type; // 表示加载来源, type为 0,1,2,255
1915
+
1916
+ _config.operateAction = mapping[type] || null;
1917
+ emit(_config, true);
1918
+ }, false);
1919
+ }
1920
+ /**
1921
+ * 提取数据事件ID
1922
+ */
1923
+
1924
+
1925
+ function extractDataByPath() {
1926
+ var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1927
+
1928
+ /* data-warden-event-id */
1929
+ var hasIdEl = getElByAttr(list, 'data-warden-event-id');
1930
+ if (hasIdEl) return hasIdEl.getAttribute('data-warden-event-id');
1931
+ /* title */
1932
+
1933
+ var hasTitleEl = getElByAttr(list, 'title');
1934
+ if (hasTitleEl) return hasTitleEl.getAttribute('title');
1935
+ /* container */
1936
+
1937
+ var container = getElByAttr(list, 'data-warden-container');
1938
+
1939
+ if (container) {
1940
+ if (container.getAttribute('data-warden-event-id') || container.getAttribute('title')) {
1941
+ return container.getAttribute('data-warden-event-id') || container.getAttribute('title');
1942
+ }
1943
+
1944
+ var id2 = container.getAttribute('data-warden-container');
1945
+ if (typeof id2 === 'string' && id2) return id2;
1946
+ }
1947
+
1948
+ return list[0].tagName.toLowerCase();
1949
+ }
1950
+ /**
1951
+ * 提取数据参数
1952
+ * 如果本身节点没有埋点属性的话会用上一层埋点属性
1953
+ */
1954
+
1955
+
1956
+ function extractParamsByPath() {
1957
+ var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
1958
+ var regex = /^data-warden-/;
1959
+ var target;
1960
+ var targetIndex;
1961
+
1962
+ try {
1963
+ // 遍历从子节点到body下最大的节点,遍历他们的属性,直到某个节点的属性能通过校验的节点
1964
+ list.forEach(function (el, index) {
1965
+ var attributes = el && el.attributes && Array.from(el.attributes) || [];
1966
+ target = attributes.find(function (item) {
1967
+ return item.nodeName.match(regex) ? item.nodeName.match(regex) : item.nodeName.indexOf('data-warden-container') !== -1;
1968
+ });
1969
+
1970
+ if (target) {
1971
+ targetIndex = index;
1972
+ throw Error();
1973
+ }
1974
+ });
1975
+ } catch (error) {}
1976
+
1977
+ if (targetIndex < 0) return {};
1978
+ var container = list[targetIndex];
1979
+ var attrList = Array.from(container.attributes) || [];
1980
+ var params = {};
1981
+ attrList.forEach(function (item) {
1982
+ // 过滤多结构属性 如 data-warden-event-id width
1983
+ // if(item.nodeName.split("-").length != 3 )return;
1984
+ // 过滤非标准命名 如 data-v-fbcf7454
1985
+ if (item.nodeName.indexOf('data-warden') < 0) return;
1986
+ var key = item.nodeName.replace(regex, '');
1987
+ params[key] = item.nodeValue;
1988
+ }); // 过滤sdk自定义属性
1989
+
1990
+ var defaultKey = ['container', 'title', 'event-id'];
1991
+ defaultKey.forEach(function (item) {
1992
+ delete params[item];
1993
+ });
1994
+ return params;
1995
+ }
1996
+ /**
1997
+ * 根据属性查找元素
1998
+ */
1999
+
2000
+
2001
+ function getElByAttr(list, key) {
2002
+ return list.find(function (item) {
2003
+ return item.hasAttribute && item.hasAttribute(key);
2004
+ });
2005
+ }
2006
+ /**
2007
+ * 获取title属性(data-warden-title 或者 title)
2008
+ */
2009
+
2010
+
2011
+ function extractTitleByTarget() {
2012
+ var target = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2013
+ var selfTitle = getNodeTitle(target);
2014
+ if (selfTitle) return selfTitle;
2015
+ var container = target.parent; // 向上找container
2016
+
2017
+ while (container && container !== document.body) {
2018
+ if (container.hasAttribute('data-warden-container')) break;
2019
+ container = container.parent;
2020
+ }
2021
+
2022
+ var superTitle = getNodeTitle(container);
2023
+ if (superTitle) return superTitle;
2024
+ var tagName = target.tagName; // 没有container,没有任何title标记的情况下
2025
+
2026
+ return !target.hasChildNodes() || tagName.toLowerCase() === 'svg' ? handleLeafNode(target) : handleNoLeafNode(target);
2027
+ }
2028
+ /**
2029
+ * 获取元素的 data-warden-title属性或者 title属性
2030
+ */
2031
+
2032
+
2033
+ function getNodeTitle(node) {
2034
+ if (node) {
2035
+ return node.hasAttribute('data-warden-title') ? node.getAttribute('data-warden-title') : node.title;
2036
+ }
2037
+
2038
+ return null;
2039
+ }
2040
+ /**
2041
+ * 点击叶子元素(也就是不包含其他HTML元素,也不能有文本内容)
2042
+ */
2043
+
2044
+
2045
+ function handleLeafNode(target) {
2046
+ var tagName = target.tagName,
2047
+ textContent = target.textContent;
2048
+ if (tagName === 'IMG') return target.getAttribute('alt') || null;
2049
+
2050
+ if (tagName === 'svg') {
2051
+ var a = _toConsumableArray(target.children).find(function (item) {
2052
+ return item.tagName === 'use';
2053
+ });
2054
+
2055
+ if (a) return a.getAttribute('xlink:href') || null;
2056
+ }
2057
+
2058
+ return textContent;
2059
+ }
2060
+ /**
2061
+ * 点击非叶子元素
2062
+ */
2063
+
2064
+
2065
+ function handleNoLeafNode(target) {
2066
+ var tagName = target.tagName,
2067
+ textContent = target.textContent;
2068
+
2069
+ if (tagName === 'A') {
2070
+ var res = isSimpleEl(_toConsumableArray(target.children));
2071
+ return res ? textContent : target.getAttribute('href') || null;
2072
+ }
2073
+
2074
+ if (tagName === 'BUTTON') {
2075
+ var name = target.getAttribute('name');
2076
+
2077
+ var _res = isSimpleEl(_toConsumableArray(target.children));
2078
+
2079
+ return name || _res ? textContent : target.getAttribute('href') || null;
2080
+ }
2081
+
2082
+ var _filter = _toConsumableArray(target.children).filter(function () {
2083
+ return target.hasChildNodes();
2084
+ }),
2085
+ length = _filter.length;
2086
+
2087
+ return length > 0 ? null : textContent;
2088
+ }
2089
+
2090
+ function init$5(_ref2) {
2091
+ var eventCore = _ref2.eventCore,
2092
+ eventUnload = _ref2.eventUnload;
2093
+ if (!eventCore && !eventUnload) return;
2094
+ if (eventCore) clickCollection();
2095
+ dwellCollector(eventUnload);
2096
+ }
2097
+ /**
2098
+ * 主动触发事件上报
2099
+ * @param {*} eventId 事件ID
2100
+ * @param {*} title 事件标题
2101
+ * @param {*} params 自定义配置信息
2102
+ * @returns
2103
+ */
2104
+
2105
+
2106
+ function traceCustomEvent(eventId, title) {
2107
+ var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2108
+ emit({
2109
+ eventId: eventId,
2110
+ title: title,
2111
+ params: params,
2112
+ eventType: 'custom',
2113
+ triggerTime: Date.now()
2114
+ });
2115
+ }
2116
+
2117
+ var event = {
2118
+ init: init$5,
2119
+ traceCustomEvent: traceCustomEvent
2120
+ };
2121
+
2122
+ var methods = {
2123
+ setCustomerId: base$1.setCustomerId,
2124
+ setUserUuid: base$1.setUserUuid,
2125
+ traceError: err.traceError,
2126
+ tracePerformance: performance$1.tracePerformance,
2127
+ traceCustomEvent: event.traceCustomEvent,
2128
+ tracePageView: pv.tracePageView
2129
+ };
2130
+
2131
+ var init$6 = function init() {
2132
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2133
+ var _options = {
2134
+ requestUrl: '',
2135
+ appName: '',
2136
+ appCode: '',
2137
+ appVersion: '',
2138
+ ext: '',
2139
+ debug: false,
2140
+ pvCore: false,
2141
+ pvHashtag: false,
2142
+ performanceCore: false,
2143
+ performanceFirstResource: false,
2144
+ performanceServer: false,
2145
+ errorCore: false,
2146
+ errorServer: false,
2147
+ eventCore: false,
2148
+ eventUnload: false // 页面卸载-是否在页面卸载时采集页面状态信息
2149
+
2150
+ }; // 将传过来的参数转换
2151
+
2152
+ transitionOptions(_options, options);
2153
+ base$1.init(_options);
2154
+ event.init(_options);
2155
+ pv.init(_options);
2156
+ http.init(_options);
2157
+ err.init(_options);
2158
+ performance$1.init(_options);
2159
+ };
2160
+
2161
+ var transitionOptions = function transitionOptions(_options, options) {
2162
+ var requestUrl = options.requestUrl,
2163
+ appName = options.appName,
2164
+ appCode = options.appCode,
2165
+ appVersion = options.appVersion,
2166
+ ext = options.ext,
2167
+ debug = options.debug,
2168
+ _options$pv = options.pv,
2169
+ pv = _options$pv === void 0 ? {} : _options$pv,
2170
+ _options$performance = options.performance,
2171
+ performance = _options$performance === void 0 ? {} : _options$performance,
2172
+ _options$error = options.error,
2173
+ error = _options$error === void 0 ? {} : _options$error,
2174
+ _options$event = options.event,
2175
+ event = _options$event === void 0 ? {} : _options$event;
2176
+ if (!requestUrl) throw Error('请传入requestUrl参数');
2177
+ if (!appName) throw Error('请传入appName参数');
2178
+ _options.requestUrl = requestUrl;
2179
+ _options.appName = appName;
2180
+ _options.appCode = appCode;
2181
+ _options.appVersion = appVersion;
2182
+ _options.ext = ext;
2183
+ _options.debug = debug;
2184
+
2185
+ if (typeof pv === 'boolean') {
2186
+ _options.pvCore = _options.pvHashtag = pv;
2187
+ } else {
2188
+ _options.pvCore = Boolean(pv.core);
2189
+ _options.pvHashtag = Boolean(pv.server);
2190
+ }
2191
+
2192
+ if (typeof performance === 'boolean') {
2193
+ _options.performanceCore = _options.performanceFirstResource = _options.performanceServer = performance;
2194
+ } else {
2195
+ _options.performanceCore = Boolean(performance.core);
2196
+ _options.performanceFirstResource = Boolean(performance.firstResource);
2197
+ _options.performanceServer = Boolean(performance.server);
2198
+ }
2199
+
2200
+ if (typeof error === 'boolean') {
2201
+ _options.errorCore = _options.errorServer = error;
2202
+ } else {
2203
+ _options.errorCore = Boolean(error.core);
2204
+ _options.errorServer = Boolean(error.server);
2205
+ }
2206
+
2207
+ if (typeof event === 'boolean') {
2208
+ _options.eventCore = _options.eventUnload = event;
2209
+ } else {
2210
+ _options.eventCore = Boolean(event.core);
2211
+ _options.eventUnload = Boolean(event.unload);
2212
+ }
2213
+ };
2214
+
2215
+ var index = _objectSpread2({
2216
+ init: init$6
2217
+ }, methods);
2218
+
742
2219
  var _excluded = ["multiple", "children", "disabled"];
743
2220
 
744
2221
  var WButton = function WButton(props) {
@@ -780,7 +2257,7 @@ WButton.defaultProps = {};
780
2257
  // import IconFont from '@/components/IconFont';
781
2258
  // <IconFont type='icon-demo' className='xxx-xxx' />
782
2259
 
783
- var index = createFromIconfontCN({
2260
+ var index$1 = createFromIconfontCN({
784
2261
  scriptUrl: '//at.alicdn.com/t/font_3425259_s93peuz62an.js'
785
2262
  });
786
2263
 
@@ -3246,7 +4723,7 @@ function Table(_ref) {
3246
4723
  Table.defaultProps = {
3247
4724
  rowKey: 'key'
3248
4725
  };
3249
- var index$1 = /*#__PURE__*/memo(Table);
4726
+ var index$2 = /*#__PURE__*/memo(Table);
3250
4727
 
3251
4728
  var _excluded$b = ["height", "width", "count", "style", "numberStyle"],
3252
4729
  _excluded2$2 = ["count", "numberCount", "width", "height", "marginRight"];
@@ -4350,7 +5827,7 @@ var Index$d = function Index(_ref, ref) {
4350
5827
  }))));
4351
5828
  };
4352
5829
 
4353
- var index$2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(Index$d));
5830
+ var index$3 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(Index$d));
4354
5831
 
4355
5832
  var controlShow = function controlShow(f1, f2, value, timer) {
4356
5833
  f1(value);
@@ -5338,7 +6815,8 @@ var ModalForm = function ModalForm(props, ref) {
5338
6815
  }, [visible, record, formIntance]);
5339
6816
  return /*#__PURE__*/React.createElement(_Modal, _objectSpread2(_objectSpread2({
5340
6817
  title: title,
5341
- visible: visible
6818
+ visible: visible,
6819
+ forceRender: true
5342
6820
  }, disabled ? {
5343
6821
  footer: null
5344
6822
  } : {}), {}, {
@@ -6039,7 +7517,7 @@ var TabelCard = function TabelCard(props, ref) {
6039
7517
  }, extraProps)));
6040
7518
  };
6041
7519
 
6042
- var index$3 = /*#__PURE__*/React.forwardRef(TabelCard);
7520
+ var index$4 = /*#__PURE__*/React.forwardRef(TabelCard);
6043
7521
 
6044
7522
  var YEAER_MONTH_FORMAT_EN = 'YYYY-MM';
6045
7523
 
@@ -6412,7 +7890,7 @@ function Calendar(_ref, ref) {
6412
7890
  })))));
6413
7891
  }
6414
7892
 
6415
- var index$4 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(Calendar));
7893
+ var index$5 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(Calendar));
6416
7894
 
6417
7895
  var WebsocketHeart = /*#__PURE__*/_createClass(function WebsocketHeart(_ref) {
6418
7896
  var _this = this;
@@ -6863,7 +8341,7 @@ function VideoPlayer(_ref, ref) {
6863
8341
  })) : null));
6864
8342
  }
6865
8343
 
6866
- var index$5 = /*#__PURE__*/forwardRef(VideoPlayer);
8344
+ var index$6 = /*#__PURE__*/forwardRef(VideoPlayer);
6867
8345
 
6868
8346
  var _excluded$l = ["id", "videoUrls", "definitionList", "isLoop", "muted", "currentIndex", "setCurrentIndex", "className", "style", "visible", "autoplay", "videoInit", "enableMemory", "lastPlayTimeHideDelay"];
6869
8347
 
@@ -6872,7 +8350,7 @@ var DEFAULT_PLAY_BACK_RATE = [0.5, 0.75, 1, 1.5, 2]; // 默认记忆提示文字
6872
8350
  var DEFAULT_LAST_PLAY_TIME_DELAY = 5; // 默认音量大小
6873
8351
 
6874
8352
  var DEFAULT_VOLUME = 0.6;
6875
- var index$6 = (function (_ref) {
8353
+ var index$7 = (function (_ref) {
6876
8354
  var id = _ref.id,
6877
8355
  _ref$videoUrls = _ref.videoUrls,
6878
8356
  videoUrls = _ref$videoUrls === void 0 ? [] : _ref$videoUrls,
@@ -7705,7 +9183,7 @@ function NtTable(_ref) {
7705
9183
  NtTable.defaultProps = {
7706
9184
  rowKey: 'key'
7707
9185
  };
7708
- var index$7 = /*#__PURE__*/memo(NtTable);
9186
+ var index$8 = /*#__PURE__*/memo(NtTable);
7709
9187
 
7710
9188
  /*
7711
9189
  * @Author: lijin
@@ -8489,10 +9967,10 @@ function WaterLevelCharts(config) {
8489
9967
  /*
8490
9968
  * @Author: lijin
8491
9969
  * @Date: 2021-09-09 11:02:54
8492
- * @LastEditTime: 2022-11-09 19:44:46
9970
+ * @LastEditTime: 2022-12-13 16:40:57
8493
9971
  * @LastEditors: lijin
8494
9972
  * @Description:
8495
- * @FilePath: \wargem\wargerm-components\src\index.ts
9973
+ * @FilePath: \wargerm-components\src\index.ts
8496
9974
  * 可以输入预定的版权声明、个性签名、空行等
8497
9975
  */
8498
9976
  console.log(REACT_APP_ENV, 'REACT_APP_ENV');
@@ -8502,4 +9980,4 @@ if (REACT_APP_ENV == 'development') {
8502
9980
  document.documentElement.setAttribute(COLOR_ATTR_NAME, 'nt');
8503
9981
  }
8504
9982
 
8505
- export { Index$a as AutoScroll, Index$c as Breadcrumb, WButton as Button, index$4 as Calendar, index$2 as Card, WCascader as Cascader, Index$4 as Checkbox, Index$9 as CountUp, Index$2 as DatePicker, DragBox, index as IconFont, Index as Input, WInputNumber as InputNumber, LineEcharts, Modal, ModalForm$1 as ModalForm, Modal$1 as ModalTips, index$7 as NtTable, Index$8 as Number, NumericInput, Index$3 as Radio, Select, Index$b as Swiper, WSwitch as Switch, index$3 as TabelCard, index$1 as Table, Index$7 as TreeSelect, Upload, index$6 as Video, index$5 as VideoPlayer, Index$6 as WDatePicker, WForm$1 as WForm, WaterLevelCharts, WebsocketHeart, useEventEmitter, create as whox, wmox };
9983
+ export { Index$a as AutoScroll, Index$c as Breadcrumb, WButton as Button, index$5 as Calendar, index$3 as Card, WCascader as Cascader, Index$4 as Checkbox, Index$9 as CountUp, Index$2 as DatePicker, DragBox, index$1 as IconFont, Index as Input, WInputNumber as InputNumber, LineEcharts, Modal, ModalForm$1 as ModalForm, Modal$1 as ModalTips, index$8 as NtTable, Index$8 as Number, NumericInput, Index$3 as Radio, Select, Index$b as Swiper, WSwitch as Switch, index$4 as TabelCard, index$2 as Table, Index$7 as TreeSelect, Upload, index$7 as Video, index$6 as VideoPlayer, Index$6 as WDatePicker, WForm$1 as WForm, WaterLevelCharts, WebsocketHeart, useEventEmitter, index as wTracing, create as whox, wmox };