@impui/imp 1.0.16-beta.0 → 1.0.16
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/dist/axios/index.es.js +1 -143
- package/dist/config/index.es.js +1 -127
- package/dist/core/index.es.js +1 -34
- package/dist/gotool/go2/index.es.js +1 -510
- package/dist/gotool/index/index.es.js +1 -164
- package/dist/imph5/index.es.js +1 -324
- package/dist/index.es.js +1 -49
- package/dist/login/index.es.js +1 -711
- package/dist/node_modules/axios/index/index.es.js +1 -38
- package/dist/node_modules/axios/lib/adapters/adapters/index.es.js +1 -71
- package/dist/node_modules/axios/lib/adapters/fetch/index.es.js +1 -219
- package/dist/node_modules/axios/lib/adapters/xhr/index.es.js +1 -141
- package/dist/node_modules/axios/lib/axios/index.es.js +1 -50
- package/dist/node_modules/axios/lib/cancel/CancelToken/index.es.js +1 -99
- package/dist/node_modules/axios/lib/cancel/CanceledError/index.es.js +1 -12
- package/dist/node_modules/axios/lib/cancel/isCancel/index.es.js +1 -6
- package/dist/node_modules/axios/lib/core/Axios/index.es.js +1 -180
- package/dist/node_modules/axios/lib/core/AxiosError/index.es.js +1 -80
- package/dist/node_modules/axios/lib/core/AxiosHeaders/index.es.js +1 -231
- package/dist/node_modules/axios/lib/core/InterceptorManager/index.es.js +1 -65
- package/dist/node_modules/axios/lib/core/buildFullPath/index.es.js +1 -12
- package/dist/node_modules/axios/lib/core/dispatchRequest/index.es.js +1 -52
- package/dist/node_modules/axios/lib/core/mergeConfig/index.es.js +1 -83
- package/dist/node_modules/axios/lib/core/settle/index.es.js +1 -18
- package/dist/node_modules/axios/lib/core/transformData/index.es.js +1 -17
- package/dist/node_modules/axios/lib/defaults/index/index.es.js +1 -116
- package/dist/node_modules/axios/lib/defaults/transitional/index.es.js +1 -8
- package/dist/node_modules/axios/lib/env/data/index.es.js +1 -4
- package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams/index.es.js +1 -34
- package/dist/node_modules/axios/lib/helpers/HttpStatusCode/index.es.js +1 -77
- package/dist/node_modules/axios/lib/helpers/bind/index.es.js +1 -8
- package/dist/node_modules/axios/lib/helpers/buildURL/index.es.js +1 -34
- package/dist/node_modules/axios/lib/helpers/combineURLs/index.es.js +1 -6
- package/dist/node_modules/axios/lib/helpers/composeSignals/index.es.js +1 -39
- package/dist/node_modules/axios/lib/helpers/cookies/index.es.js +1 -49
- package/dist/node_modules/axios/lib/helpers/formDataToJSON/index.es.js +1 -54
- package/dist/node_modules/axios/lib/helpers/isAbsoluteURL/index.es.js +1 -6
- package/dist/node_modules/axios/lib/helpers/isAxiosError/index.es.js +1 -7
- package/dist/node_modules/axios/lib/helpers/isURLSameOrigin/index.es.js +1 -11
- package/dist/node_modules/axios/lib/helpers/null/index.es.js +1 -4
- package/dist/node_modules/axios/lib/helpers/parseHeaders/index.es.js +1 -47
- package/dist/node_modules/axios/lib/helpers/parseProtocol/index.es.js +1 -7
- package/dist/node_modules/axios/lib/helpers/progressEventReducer/index.es.js +1 -41
- package/dist/node_modules/axios/lib/helpers/resolveConfig/index.es.js +1 -46
- package/dist/node_modules/axios/lib/helpers/speedometer/index.es.js +1 -36
- package/dist/node_modules/axios/lib/helpers/spread/index.es.js +1 -8
- package/dist/node_modules/axios/lib/helpers/throttle/index.es.js +1 -35
- package/dist/node_modules/axios/lib/helpers/toFormData/index.es.js +1 -117
- package/dist/node_modules/axios/lib/helpers/toURLEncodedForm/index.es.js +1 -18
- package/dist/node_modules/axios/lib/helpers/trackStream/index.es.js +1 -80
- package/dist/node_modules/axios/lib/helpers/validator/index.es.js +1 -67
- package/dist/node_modules/axios/lib/platform/browser/classes/Blob/index.es.js +1 -4
- package/dist/node_modules/axios/lib/platform/browser/classes/FormData/index.es.js +1 -4
- package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams/index.es.js +1 -5
- package/dist/node_modules/axios/lib/platform/browser/index/index.es.js +1 -15
- package/dist/node_modules/axios/lib/platform/common/utils/index.es.js +1 -15
- package/dist/node_modules/axios/lib/platform/index/index.es.js +1 -9
- package/dist/node_modules/axios/lib/utils/index.es.js +1 -387
- package/dist/packages/com/dist/cache/index.es/index.es.js +1 -145
- package/dist/packages/com/dist/core/index.es/index.es.js +1 -154
- package/dist/packages/com/dist/data/index.es/index.es.js +1 -26
- package/dist/packages/com/dist/date/index.es/index.es.js +2 -194
- package/dist/packages/com/dist/log/index.es/index.es.js +1 -110
- package/dist/packages/com/dist/message/index.es/index.es.js +1 -90
- package/dist/packages/com/dist/req/index.es/index.es.js +1 -35
- package/dist/packages/com/dist/str/index.es/index.es.js +1 -25
- package/dist/packages/com/dist/typetool/index.es/index.es.js +1 -53
- package/dist/packages/com/dist/url/index.es/index.es.js +1 -238
- package/dist/restool/index/index.es.js +1 -266
- package/dist/restool/index.css/index.es.js +1 -4
- package/package.json +5 -1
|
@@ -1,26 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
return new Promise((resolve) => {
|
|
3
|
-
const blob = new Blob([buffer], BlobOptions);
|
|
4
|
-
const reader = new FileReader();
|
|
5
|
-
reader.onloadend = () => {
|
|
6
|
-
const base64 = reader.result.split(",")[1];
|
|
7
|
-
if (base64.length * 2 > 5 * 1024 * 1024) {
|
|
8
|
-
console.warn("WASM文件太大,localStorage可能存储失败");
|
|
9
|
-
}
|
|
10
|
-
resolve(base64);
|
|
11
|
-
};
|
|
12
|
-
reader.readAsDataURL(blob);
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
const base64ToBuffer = async function(base64) {
|
|
16
|
-
const binary = atob(base64);
|
|
17
|
-
const bytes = new Uint8Array(binary.length);
|
|
18
|
-
for (let i = 0; i < binary.length; i++) {
|
|
19
|
-
bytes[i] = binary.charCodeAt(i);
|
|
20
|
-
}
|
|
21
|
-
return bytes.buffer;
|
|
22
|
-
};
|
|
23
|
-
export {
|
|
24
|
-
base64ToBuffer,
|
|
25
|
-
bufferToBase64
|
|
26
|
-
};
|
|
1
|
+
const e=async function(e,n){return new Promise(o=>{const t=new Blob([e],n),r=new FileReader;r.onloadend=()=>{const e=r.result.split(",")[1];2*e.length>5242880&&console.warn("WASM文件太大,localStorage可能存储失败"),o(e)},r.readAsDataURL(t)})},n=async function(e){const n=atob(e),o=new Uint8Array(n.length);for(let t=0;t<n.length;t++)o[t]=n.charCodeAt(t);return o.buffer};export{n as base64ToBuffer,e as bufferToBase64};
|
|
@@ -1,194 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const getDate = function(object, n, retainTime, isMs) {
|
|
4
|
-
var retDate;
|
|
5
|
-
isMs = isMs || false;
|
|
6
|
-
if (object instanceof Date) {
|
|
7
|
-
retDate = object;
|
|
8
|
-
} else if (typeof object === "number") {
|
|
9
|
-
retDate = object < 1e12 && !isMs ? getLocalTime(object) : getLocalTimeFromMs(object);
|
|
10
|
-
} else if (typeof object === "object" && object.low >= 0 && object.high >= 0) {
|
|
11
|
-
retDate = getLocalTime(object);
|
|
12
|
-
} else if (typeof object === "string") {
|
|
13
|
-
object = object.replace("T", " ");
|
|
14
|
-
retDate = object.indexOf("/") >= 0 ? new Date(object) : (function() {
|
|
15
|
-
var processedStr = object.replace(/\d+(?=-[^-]+$)/, function(a) {
|
|
16
|
-
return parseInt(a, 10) - 1;
|
|
17
|
-
});
|
|
18
|
-
var parts = processedStr.match(/\d+/g);
|
|
19
|
-
return new Date(
|
|
20
|
-
parseInt(parts[0]),
|
|
21
|
-
// 年
|
|
22
|
-
parseInt(parts[1]),
|
|
23
|
-
// 月(已减1)
|
|
24
|
-
parseInt(parts[2]),
|
|
25
|
-
// 日
|
|
26
|
-
parseInt(parts[3] || 0),
|
|
27
|
-
// 时
|
|
28
|
-
parseInt(parts[4] || 0),
|
|
29
|
-
// 分
|
|
30
|
-
parseInt(parts[5] || 0)
|
|
31
|
-
// 秒
|
|
32
|
-
);
|
|
33
|
-
})();
|
|
34
|
-
} else {
|
|
35
|
-
throw getError("在getDate方法中获取日期对象错误,无法识别的参数类型!", object, typeof object);
|
|
36
|
-
}
|
|
37
|
-
if (n) {
|
|
38
|
-
retDate = getDate(retDate.getTime() + n * 864e5);
|
|
39
|
-
}
|
|
40
|
-
retainTime = retainTime || true;
|
|
41
|
-
if (!retainTime) {
|
|
42
|
-
retDate = new Date(retDate.toDateString());
|
|
43
|
-
}
|
|
44
|
-
return retDate;
|
|
45
|
-
};
|
|
46
|
-
const getTimestamp = function(date2) {
|
|
47
|
-
date2 = getDate(date2 || /* @__PURE__ */ new Date());
|
|
48
|
-
return parseInt(date2.getTime() / 1e3);
|
|
49
|
-
};
|
|
50
|
-
const getLocalTime = function(timestamp) {
|
|
51
|
-
return new Date(parseInt(timestamp) * 1e3);
|
|
52
|
-
};
|
|
53
|
-
const getLocalTimeFromMs = function(timestamp) {
|
|
54
|
-
return new Date(parseInt(timestamp));
|
|
55
|
-
};
|
|
56
|
-
const formatNum = function(num, fotmatArr) {
|
|
57
|
-
fotmatArr = fotmatArr || ["秒", "分", "时"];
|
|
58
|
-
var H = parseInt(num / 3600);
|
|
59
|
-
var m = parseInt(num % 3600 / 60);
|
|
60
|
-
var s = num % 3600 % 60;
|
|
61
|
-
var str = "";
|
|
62
|
-
if (H > 0 && fotmatArr.length >= 3) {
|
|
63
|
-
str += H + fotmatArr[2];
|
|
64
|
-
}
|
|
65
|
-
if ((str !== "" || m > 0) && fotmatArr.length >= 2) {
|
|
66
|
-
str += m + fotmatArr[1];
|
|
67
|
-
}
|
|
68
|
-
if ((str !== "" || s > 0) && fotmatArr.length >= 1) {
|
|
69
|
-
str += s + fotmatArr[0];
|
|
70
|
-
}
|
|
71
|
-
return str;
|
|
72
|
-
};
|
|
73
|
-
const format = function(date2, formatStr, isMs) {
|
|
74
|
-
date2 = getDate(date2, null, null, isMs);
|
|
75
|
-
formatStr = formatStr || "yyyy-MM-dd hh:mm:ss";
|
|
76
|
-
let we = date2.getDay();
|
|
77
|
-
Math.floor((date2.getMonth() + 3) / 3).toString();
|
|
78
|
-
var o = {
|
|
79
|
-
"M+": date2.getMonth() + 1,
|
|
80
|
-
//月
|
|
81
|
-
"d+": date2.getDate(),
|
|
82
|
-
//日
|
|
83
|
-
"(h|H)+": date2.getHours(),
|
|
84
|
-
//时
|
|
85
|
-
"m+": date2.getMinutes(),
|
|
86
|
-
//分
|
|
87
|
-
"s+": date2.getSeconds(),
|
|
88
|
-
//秒
|
|
89
|
-
"q+": Math.floor((date2.getMonth() + 3) / 3),
|
|
90
|
-
//季度
|
|
91
|
-
"(w|W)+": week[we],
|
|
92
|
-
//星期
|
|
93
|
-
"S": date2.getMilliseconds()
|
|
94
|
-
//毫秒
|
|
95
|
-
};
|
|
96
|
-
if (/((y|Y)+)/.test(formatStr)) {
|
|
97
|
-
formatStr = formatStr.replace(RegExp.$1, (date2.getFullYear() + "").substr(4 - RegExp.$1.length));
|
|
98
|
-
}
|
|
99
|
-
for (var k in o) {
|
|
100
|
-
if (new RegExp("(" + k + ")").test(formatStr)) {
|
|
101
|
-
formatStr = formatStr.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return formatStr;
|
|
105
|
-
};
|
|
106
|
-
const getMonthDayNum = function(date2) {
|
|
107
|
-
date2 = getDate(date2);
|
|
108
|
-
return new Date(date2.getYear(), date2.getMonth() + 1, 0).getDate();
|
|
109
|
-
};
|
|
110
|
-
const compareDate = function(d1, d2) {
|
|
111
|
-
return getDate(d1).getTime() - getDate(d2).getTime();
|
|
112
|
-
};
|
|
113
|
-
const isDateIn = function(d1, d2, now) {
|
|
114
|
-
now = getDate(now || /* @__PURE__ */ new Date());
|
|
115
|
-
d1 = getDate(d1);
|
|
116
|
-
d2 = getDate(d2);
|
|
117
|
-
return compareDate(now, d1) >= 0 && compareDate(now, d2) <= 0;
|
|
118
|
-
};
|
|
119
|
-
const diff = function(target_date, start_date) {
|
|
120
|
-
var end_time = getTimestamp(target_date);
|
|
121
|
-
var start_time = getTimestamp(start_date);
|
|
122
|
-
return Math.abs(end_time - start_time);
|
|
123
|
-
};
|
|
124
|
-
const isCurrentToday = function(date2) {
|
|
125
|
-
const currentDate = /* @__PURE__ */ new Date();
|
|
126
|
-
const currentYear = currentDate.getFullYear();
|
|
127
|
-
const currentMonth = currentDate.getMonth() + 1;
|
|
128
|
-
const currentDay = currentDate.getDate();
|
|
129
|
-
const targetDate = getDate(date2);
|
|
130
|
-
const targetYear = targetDate.getFullYear();
|
|
131
|
-
const targetMonth = targetDate.getMonth() + 1;
|
|
132
|
-
const targetDay = targetDate.getDate();
|
|
133
|
-
if (currentYear === targetYear && currentMonth === targetMonth && currentDay === targetDay) {
|
|
134
|
-
return true;
|
|
135
|
-
}
|
|
136
|
-
return false;
|
|
137
|
-
};
|
|
138
|
-
const isCurrentWeek = function(date2) {
|
|
139
|
-
const pastTime = getDate(date2);
|
|
140
|
-
const today = new Date((/* @__PURE__ */ new Date()).toLocaleDateString());
|
|
141
|
-
let day = today.getDay();
|
|
142
|
-
day = day == 0 ? 7 : day;
|
|
143
|
-
const oneDayTime = 60 * 60 * 24 * 1e3;
|
|
144
|
-
const monday = new Date(today.getTime() - oneDayTime * (day - 1));
|
|
145
|
-
const nextMonday = new Date(today.getTime() + oneDayTime * (8 - day));
|
|
146
|
-
if (monday.getTime() <= pastTime && nextMonday.getTime() > pastTime) {
|
|
147
|
-
return true;
|
|
148
|
-
} else {
|
|
149
|
-
return false;
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
const isCurrentYear = function(date2) {
|
|
153
|
-
const _date = getDate(date2);
|
|
154
|
-
return (/* @__PURE__ */ new Date()).getFullYear() === _date.getFullYear();
|
|
155
|
-
};
|
|
156
|
-
const getNextDaysZeroHour = function(days) {
|
|
157
|
-
let now = /* @__PURE__ */ new Date();
|
|
158
|
-
now.setDate(now.getDate() + days);
|
|
159
|
-
now.setHours(0, 0, 0, 0);
|
|
160
|
-
return now;
|
|
161
|
-
};
|
|
162
|
-
const date = {
|
|
163
|
-
getDate,
|
|
164
|
-
getTimestamp,
|
|
165
|
-
getLocalTime,
|
|
166
|
-
getLocalTimeFromMs,
|
|
167
|
-
formatNum,
|
|
168
|
-
format,
|
|
169
|
-
getMonthDayNum,
|
|
170
|
-
compareDate,
|
|
171
|
-
isDateIn,
|
|
172
|
-
diff,
|
|
173
|
-
isCurrentToday,
|
|
174
|
-
isCurrentWeek,
|
|
175
|
-
isCurrentYear,
|
|
176
|
-
getNextDaysZeroHour
|
|
177
|
-
};
|
|
178
|
-
export {
|
|
179
|
-
compareDate,
|
|
180
|
-
date,
|
|
181
|
-
diff,
|
|
182
|
-
format,
|
|
183
|
-
formatNum,
|
|
184
|
-
getDate,
|
|
185
|
-
getLocalTime,
|
|
186
|
-
getLocalTimeFromMs,
|
|
187
|
-
getMonthDayNum,
|
|
188
|
-
getNextDaysZeroHour,
|
|
189
|
-
getTimestamp,
|
|
190
|
-
isCurrentToday,
|
|
191
|
-
isCurrentWeek,
|
|
192
|
-
isCurrentYear,
|
|
193
|
-
isDateIn
|
|
194
|
-
};
|
|
1
|
+
import{getError as e}from"../../core/index.es/index.es.js";const t=["日","一","二","三","四","五","六"],n=function(t,a,o,g){var i,u;if(g=g||!1,t instanceof Date)i=t;else if("number"==typeof t)i=t<1e12&&!g?r(t):s(t);else if("object"==typeof t&&t.low>=0&&t.high>=0)i=r(t);else{if("string"!=typeof t)throw e("在getDate方法中获取日期对象错误,无法识别的参数类型!",t,typeof t);i=(t=t.replace("T"," ")).indexOf("/")>=0?new Date(t):(u=t.replace(/\d+(?=-[^-]+$)/,function(e){return parseInt(e,10)-1}).match(/\d+/g),new Date(parseInt(u[0]),parseInt(u[1]),parseInt(u[2]),parseInt(u[3]||0),parseInt(u[4]||0),parseInt(u[5]||0)))}return a&&(i=n(i.getTime()+864e5*a)),(o=o||!0)||(i=new Date(i.toDateString())),i},a=function(e){return e=n(e||/* @__PURE__ */new Date),parseInt(e.getTime()/1e3)},r=function(e){return new Date(1e3*parseInt(e))},s=function(e){return new Date(parseInt(e))},o=function(e,t){t=t||["秒","分","时"];var n=parseInt(e/3600),a=parseInt(e%3600/60),r=e%3600%60,s="";return n>0&&t.length>=3&&(s+=n+t[2]),(""!==s||a>0)&&t.length>=2&&(s+=a+t[1]),(""!==s||r>0)&&t.length>=1&&(s+=r+t[0]),s},g=function(e,a,r){a=a||"yyyy-MM-dd hh:mm:ss";let s=(e=n(e,null,null,r)).getDay();Math.floor((e.getMonth()+3)/3).toString();var o={"M+":e.getMonth()+1,"d+":e.getDate(),"(h|H)+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),"(w|W)+":t[s],S:e.getMilliseconds()};for(var g in/((y|Y)+)/.test(a)&&(a=a.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))),o)new RegExp("("+g+")").test(a)&&(a=a.replace(RegExp.$1,1===RegExp.$1.length?o[g]:("00"+o[g]).substr((""+o[g]).length)));return a},i=function(e){return e=n(e),new Date(e.getYear(),e.getMonth()+1,0).getDate()},u=function(e,t){return n(e).getTime()-n(t).getTime()},l=function(e,t,a){return a=n(a||/* @__PURE__ */new Date),e=n(e),t=n(t),u(a,e)>=0&&u(a,t)<=0},c=function(e,t){var n=a(e),r=a(t);return Math.abs(n-r)},f=function(e){const t=/* @__PURE__ */new Date,a=t.getFullYear(),r=t.getMonth()+1,s=t.getDate(),o=n(e),g=o.getFullYear(),i=o.getMonth()+1,u=o.getDate();return a===g&&r===i&&s===u},D=function(e){const t=n(e),a=new Date(/* @__PURE__ */ /* @__PURE__ */(new Date).toLocaleDateString());let r=a.getDay();r=0==r?7:r;const s=864e5,o=new Date(a.getTime()-s*(r-1)),g=new Date(a.getTime()+s*(8-r));return o.getTime()<=t&&g.getTime()>t},m=function(e){const t=n(e);/* @__PURE__ */
|
|
2
|
+
return(new Date).getFullYear()===t.getFullYear()},p=function(e){let t=/* @__PURE__ */new Date;return t.setDate(t.getDate()+e),t.setHours(0,0,0,0),t},h={getDate:n,getTimestamp:a,getLocalTime:r,getLocalTimeFromMs:s,formatNum:o,format:g,getMonthDayNum:i,compareDate:u,isDateIn:l,diff:c,isCurrentToday:f,isCurrentWeek:D,isCurrentYear:m,getNextDaysZeroHour:p};export{u as compareDate,h as date,c as diff,g as format,o as formatNum,n as getDate,r as getLocalTime,s as getLocalTimeFromMs,i as getMonthDayNum,p as getNextDaysZeroHour,a as getTimestamp,f as isCurrentToday,D as isCurrentWeek,m as isCurrentYear,l as isDateIn};
|
|
@@ -1,110 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
const LogLevelEnum = {
|
|
3
|
-
error: 0,
|
|
4
|
-
warn: 5,
|
|
5
|
-
info: 10,
|
|
6
|
-
log: 15,
|
|
7
|
-
debug: 100
|
|
8
|
-
};
|
|
9
|
-
const getFilteredStack = function(stack) {
|
|
10
|
-
const filteredStack = stack.split("\n").filter((line) => !line.includes("at <anonymous>") && !line.includes("at e") && !line.includes("Error") && !line.includes("at log") && !line.includes("at writeLogRecord")).join("\n");
|
|
11
|
-
return "\n堆栈:" + filteredStack;
|
|
12
|
-
};
|
|
13
|
-
let logLevel = 0;
|
|
14
|
-
const logRecord = {};
|
|
15
|
-
const getLog = async function(checkFn) {
|
|
16
|
-
logLevel = parseInt(urltool.getPar("debug") || 5);
|
|
17
|
-
checkFn = checkFn || function() {
|
|
18
|
-
return logLevel;
|
|
19
|
-
};
|
|
20
|
-
await checkFn();
|
|
21
|
-
const writeLogRecord = function(key, args) {
|
|
22
|
-
logRecord[key] = logRecord[key] || [];
|
|
23
|
-
logRecord[key].push({ args, stack: new Error().stack });
|
|
24
|
-
};
|
|
25
|
-
const log = logLevel >= LogLevelEnum.log ? console.log : function(...args) {
|
|
26
|
-
writeLogRecord("log", args);
|
|
27
|
-
};
|
|
28
|
-
const pars = {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
// 可枚举
|
|
31
|
-
configurable: true
|
|
32
|
-
// 可配置
|
|
33
|
-
};
|
|
34
|
-
Object.defineProperties(log, {
|
|
35
|
-
debug: {
|
|
36
|
-
get() {
|
|
37
|
-
return logLevel >= LogLevelEnum.debug ? console.log : function(...args) {
|
|
38
|
-
writeLogRecord("debug", args);
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
...pars
|
|
42
|
-
},
|
|
43
|
-
log: {
|
|
44
|
-
get() {
|
|
45
|
-
return logLevel >= LogLevelEnum.log ? console.log : function(...args) {
|
|
46
|
-
writeLogRecord("log", args);
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
...pars
|
|
50
|
-
},
|
|
51
|
-
info: {
|
|
52
|
-
get() {
|
|
53
|
-
return logLevel >= LogLevelEnum.info ? console.info : function(...args) {
|
|
54
|
-
writeLogRecord("info", args);
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
...pars
|
|
58
|
-
},
|
|
59
|
-
warn: {
|
|
60
|
-
get() {
|
|
61
|
-
return logLevel >= LogLevelEnum.warn ? console.warn : function(...args) {
|
|
62
|
-
writeLogRecord("warn", args);
|
|
63
|
-
};
|
|
64
|
-
},
|
|
65
|
-
...pars
|
|
66
|
-
},
|
|
67
|
-
error: {
|
|
68
|
-
get() {
|
|
69
|
-
return console.error;
|
|
70
|
-
},
|
|
71
|
-
...pars
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
log.start = function(txt, styleStr = "color: blue; font-weight: bold;font-size: 14px;") {
|
|
75
|
-
console.log("%c------------------" + txt + " 开始-----------------", styleStr);
|
|
76
|
-
};
|
|
77
|
-
log.end = function(txt, styleStr = "color: blue; font-weight: bold;font-size: 14px;") {
|
|
78
|
-
console.log("%c------------------" + txt + " 结束-----------------", styleStr);
|
|
79
|
-
};
|
|
80
|
-
return log;
|
|
81
|
-
};
|
|
82
|
-
window.setLogLevel = function(level, isStack = false, isWriteRecord = true) {
|
|
83
|
-
logLevel = level;
|
|
84
|
-
if (isWriteRecord) {
|
|
85
|
-
console.log("%c------------------开始输出历史过滤日志 开始-----------------", "color: blue; font-weight: bold;font-size: 14px;");
|
|
86
|
-
for (let key in logRecord) {
|
|
87
|
-
let list = null;
|
|
88
|
-
if (logLevel >= LogLevelEnum[key]) {
|
|
89
|
-
list = logRecord[key];
|
|
90
|
-
}
|
|
91
|
-
if (!list) {
|
|
92
|
-
console.log(`%c日志${key},暂无日志记录`, "color: orange;font-weight: bold;");
|
|
93
|
-
} else {
|
|
94
|
-
console.log("%c输出之前过滤的日志:" + key, "color: green; font-weight: bold;");
|
|
95
|
-
const MethodName = key === "debug" ? "log" : key;
|
|
96
|
-
list.forEach((item) => {
|
|
97
|
-
if (isStack) {
|
|
98
|
-
const stack = item.stack;
|
|
99
|
-
item.args.push(getFilteredStack(stack));
|
|
100
|
-
}
|
|
101
|
-
console[MethodName].apply(console, item.args);
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
console.log("%c------------------开始输出历史过滤日志 结束-----------------", "color: blue; font-weight: bold;font-size: 14px;");
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
export {
|
|
109
|
-
getLog
|
|
110
|
-
};
|
|
1
|
+
import{urltool as o}from"../../url/index.es/index.es.js";const n={error:0,warn:5,info:10,log:15,debug:100},e=function(o){return"\n堆栈:"+o.split("\n").filter(o=>!(o.includes("at <anonymous>")||o.includes("at e")||o.includes("Error")||o.includes("at log")||o.includes("at writeLogRecord"))).join("\n")};let l=0;const t={},c=async function(e){l=parseInt(o.getPar("debug")||5),e=e||function(){return l},await e();const c=function(o,n){t[o]=t[o]||[],t[o].push({args:n,stack:(new Error).stack})},r=l>=n.log?console.log:function(...o){c("log",o)},s={enumerable:!0,configurable:!0};return Object.defineProperties(r,{debug:{get:()=>l>=n.debug?console.log:function(...o){c("debug",o)},...s},log:{get:()=>l>=n.log?console.log:function(...o){c("log",o)},...s},info:{get:()=>l>=n.info?console.info:function(...o){c("info",o)},...s},warn:{get:()=>l>=n.warn?console.warn:function(...o){c("warn",o)},...s},error:{get:()=>console.error,...s}}),r.start=function(o,n="color: blue; font-weight: bold;font-size: 14px;"){console.log("%c------------------"+o+" 开始-----------------",n)},r.end=function(o,n="color: blue; font-weight: bold;font-size: 14px;"){console.log("%c------------------"+o+" 结束-----------------",n)},r};window.setLogLevel=function(o,c=!1,r=!0){if(l=o,r){console.log("%c------------------开始输出历史过滤日志 开始-----------------","color: blue; font-weight: bold;font-size: 14px;");for(let o in t){let r=null;if(l>=n[o]&&(r=t[o]),r){console.log("%c输出之前过滤的日志:"+o,"color: green; font-weight: bold;");const n="debug"===o?"log":o;r.forEach(o=>{if(c){const n=o.stack;o.args.push(e(n))}console[n].apply(console,o.args)})}else console.log(`%c日志${o},暂无日志记录`,"color: orange;font-weight: bold;")}console.log("%c------------------开始输出历史过滤日志 结束-----------------","color: blue; font-weight: bold;font-size: 14px;")}};export{c as getLog};
|
|
@@ -1,90 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { getLog } from "../../log/index.es/index.es.js";
|
|
3
|
-
const log = await getLog();
|
|
4
|
-
let messagePlug = null;
|
|
5
|
-
const message = (function() {
|
|
6
|
-
if (messagePlug) {
|
|
7
|
-
return messagePlug;
|
|
8
|
-
}
|
|
9
|
-
var msgEvent = {};
|
|
10
|
-
var regFun = {};
|
|
11
|
-
window.addEventListener("message", function(e) {
|
|
12
|
-
if (!e.data || !isString(e.data)) return;
|
|
13
|
-
try {
|
|
14
|
-
var info = JSON.parse(e.data);
|
|
15
|
-
} catch (err) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
var name = info.name;
|
|
19
|
-
if (regFun[name]) {
|
|
20
|
-
const length = regFun[name].length;
|
|
21
|
-
for (var i = 0; i < length; i++) {
|
|
22
|
-
var callback = regFun[name][i];
|
|
23
|
-
callback && callback(info.data, info);
|
|
24
|
-
}
|
|
25
|
-
} else {
|
|
26
|
-
msgEvent[name] = msgEvent[name] || [];
|
|
27
|
-
msgEvent[name].push(info);
|
|
28
|
-
}
|
|
29
|
-
}, false);
|
|
30
|
-
messagePlug = {
|
|
31
|
-
/**
|
|
32
|
-
* 发送消息
|
|
33
|
-
* @param {string} name 要发布的消息名称
|
|
34
|
-
* @param {obj} data 需要发送的数据
|
|
35
|
-
* @param {any} obj 发送postMessage的对象
|
|
36
|
-
* */
|
|
37
|
-
send: function(name, data, obj) {
|
|
38
|
-
obj = obj || parent;
|
|
39
|
-
if (!obj) return;
|
|
40
|
-
var msginfo = { "name": name, "data": data };
|
|
41
|
-
log.debug("postMessage", name, data, !!(obj && obj.postMessage));
|
|
42
|
-
obj && obj.postMessage && obj.postMessage(JSON.stringify(msginfo), "*");
|
|
43
|
-
},
|
|
44
|
-
on: function(name, callback) {
|
|
45
|
-
regFun[name] = regFun[name] || [];
|
|
46
|
-
var flag = false;
|
|
47
|
-
for (var i = 0; i < regFun[name].length; i++) {
|
|
48
|
-
if (regFun[name][i] === callback) {
|
|
49
|
-
flag = true;
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
!flag && regFun[name].push(callback);
|
|
54
|
-
if (msgEvent[name]) {
|
|
55
|
-
while (msgEvent[name].length > 0) {
|
|
56
|
-
var info = msgEvent[name][0];
|
|
57
|
-
callback && callback(info.data, info);
|
|
58
|
-
msgEvent[name].shift();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
reg: function(name, callback) {
|
|
63
|
-
return this.on(name, callback);
|
|
64
|
-
},
|
|
65
|
-
remove: function(name, callback) {
|
|
66
|
-
if (!callback) {
|
|
67
|
-
delete regFun[name];
|
|
68
|
-
delete msgEvent[name];
|
|
69
|
-
} else {
|
|
70
|
-
for (var i = 0; i < regFun[name].length; i++) {
|
|
71
|
-
if (regFun[name][i] === callback) {
|
|
72
|
-
regFun[name].splice(i, 1);
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
runOnload: function() {
|
|
79
|
-
window.name && this.send("onload_" + window.name);
|
|
80
|
-
},
|
|
81
|
-
onload: function(iframe, callback) {
|
|
82
|
-
iframe.name && this.reg("onload_" + iframe.name, callback);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
messagePlug.on("");
|
|
86
|
-
return messagePlug;
|
|
87
|
-
})();
|
|
88
|
-
export {
|
|
89
|
-
message
|
|
90
|
-
};
|
|
1
|
+
import{isString as e}from"../../typetool/index.es/index.es.js";import{getLog as n}from"../../log/index.es/index.es.js";const t=await n();let a=null;const s=function(){if(a)return a;var n={},s={};return window.addEventListener("message",function(t){if(t.data&&e(t.data)){try{var a=JSON.parse(t.data)}catch(d){return}var o=a.name;if(s[o]){const e=s[o].length;for(var r=0;r<e;r++){var i=s[o][r];i&&i(a.data,a)}}else n[o]=n[o]||[],n[o].push(a)}},!1),a={send:function(e,n,a){if(a=a||parent){var s={name:e,data:n};t.debug("postMessage",e,n,!(!a||!a.postMessage)),a&&a.postMessage&&a.postMessage(JSON.stringify(s),"*")}},on:function(e,t){s[e]=s[e]||[];for(var a=!1,o=0;o<s[e].length;o++)if(s[e][o]===t){a=!0;break}if(!a&&s[e].push(t),n[e])for(;n[e].length>0;){var r=n[e][0];t&&t(r.data,r),n[e].shift()}},reg:function(e,n){return this.on(e,n)},remove:function(e,t){if(t){for(var a=0;a<s[e].length;a++)if(s[e][a]===t){s[e].splice(a,1);break}}else delete s[e],delete n[e]},runOnload:function(){window.name&&this.send("onload_"+window.name)},onload:function(e,n){e.name&&this.reg("onload_"+e.name,n)}},a.on(""),a}();export{s as message};
|
|
@@ -1,35 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { wait } from "../../core/index.es/index.es.js";
|
|
3
|
-
import { getLog } from "../../log/index.es/index.es.js";
|
|
4
|
-
import "../../message/index.es/index.es.js";
|
|
5
|
-
const cache = new cacheClass("__req__");
|
|
6
|
-
window.removeCache = cache.remove.bind(cache);
|
|
7
|
-
window.clearCache = cache.clear.bind(cache);
|
|
8
|
-
window.cache = cache;
|
|
9
|
-
const log = await getLog();
|
|
10
|
-
const getAndWaitCacheLoadings = {};
|
|
11
|
-
const refreshStatus = {};
|
|
12
|
-
const getAndWaitCache = async (key, getFn) => {
|
|
13
|
-
let cacheData = cache.get(key);
|
|
14
|
-
if (!cacheData) {
|
|
15
|
-
if (getAndWaitCacheLoadings[key]) {
|
|
16
|
-
await wait(10);
|
|
17
|
-
return getAndWaitCache(key, getFn);
|
|
18
|
-
}
|
|
19
|
-
getAndWaitCacheLoadings[key] = true;
|
|
20
|
-
cacheData = await getFn(key);
|
|
21
|
-
cache.set(key, cacheData);
|
|
22
|
-
getAndWaitCacheLoadings[key] = false;
|
|
23
|
-
return cacheData;
|
|
24
|
-
} else if (!refreshStatus[key]) {
|
|
25
|
-
getFn(key).then((res) => {
|
|
26
|
-
cache.set(key, res);
|
|
27
|
-
});
|
|
28
|
-
refreshStatus[key] = true;
|
|
29
|
-
}
|
|
30
|
-
log.debug("命中缓存:", key);
|
|
31
|
-
return cacheData;
|
|
32
|
-
};
|
|
33
|
-
export {
|
|
34
|
-
getAndWaitCache
|
|
35
|
-
};
|
|
1
|
+
import{cacheClass as e}from"../../cache/index.es/index.es.js";import{wait as s}from"../../core/index.es/index.es.js";import{getLog as a}from"../../log/index.es/index.es.js";import"../../message/index.es/index.es.js";const i=new e("__req__");window.removeCache=i.remove.bind(i),window.clearCache=i.clear.bind(i),window.cache=i;const n=await a(),t={},o={},r=async(e,a)=>{let c=i.get(e);return c?(o[e]||(a(e).then(s=>{i.set(e,s)}),o[e]=!0),n.debug("命中缓存:",e),c):t[e]?(await s(10),r(e,a)):(t[e]=!0,c=await a(e),i.set(e,c),t[e]=!1,c)};export{r as getAndWaitCache};
|
|
@@ -1,25 +1 @@
|
|
|
1
|
-
String.prototype.TrimStart = function(
|
|
2
|
-
if (c == null || c == "") {
|
|
3
|
-
var str2 = this.replace(/^s*/, "");
|
|
4
|
-
return str2;
|
|
5
|
-
} else {
|
|
6
|
-
var rg = new RegExp("^" + c + "*");
|
|
7
|
-
var str2 = this.replace(rg, "");
|
|
8
|
-
return str2;
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
String.prototype.trimEnd = function(c) {
|
|
12
|
-
if (c == null || c == "") {
|
|
13
|
-
var str2 = this;
|
|
14
|
-
var rg = /s/;
|
|
15
|
-
var i = str2.length;
|
|
16
|
-
while (rg.test(str2.charAt(--i))) ;
|
|
17
|
-
return str2.slice(0, i + 1);
|
|
18
|
-
} else {
|
|
19
|
-
var str2 = this;
|
|
20
|
-
var rg = new RegExp(c);
|
|
21
|
-
var i = str2.length;
|
|
22
|
-
while (rg.test(str2.charAt(--i))) ;
|
|
23
|
-
return str2.slice(0, i + 1);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
1
|
+
String.prototype.TrimStart=function(t){if(null==t||""==t)return this.replace(/^s*/,"");var r=new RegExp("^"+t+"*");return this.replace(r,"")},String.prototype.trimEnd=function(t){if(null==t||""==t){for(var r=/s/,e=(n=this).length;r.test(n.charAt(--e)););return n.slice(0,e+1)}var n=this;for(r=new RegExp(t),e=n.length;r.test(n.charAt(--e)););return n.slice(0,e+1)};
|
|
@@ -1,53 +1 @@
|
|
|
1
|
-
const
|
|
2
|
-
return obj !== null && typeof obj === "object" && obj.constructor === Array;
|
|
3
|
-
};
|
|
4
|
-
const isString = function(obj) {
|
|
5
|
-
return obj !== null && typeof obj === "string" && obj.constructor === String;
|
|
6
|
-
};
|
|
7
|
-
const isNumber = function(obj) {
|
|
8
|
-
return obj !== null && typeof obj === "number" && obj.constructor === Number;
|
|
9
|
-
};
|
|
10
|
-
const isBoolean = function(obj) {
|
|
11
|
-
return obj !== null && typeof obj === "boolean" && obj.constructor === Boolean;
|
|
12
|
-
};
|
|
13
|
-
const isDate = function(obj) {
|
|
14
|
-
return obj !== null && typeof obj === "object" && obj.constructor === Date;
|
|
15
|
-
};
|
|
16
|
-
const isFunction = function(obj) {
|
|
17
|
-
return obj !== null && typeof obj === "function" && (obj.constructor === Function || obj.constructor.name === "AsyncFunction");
|
|
18
|
-
};
|
|
19
|
-
const isObject = function(obj) {
|
|
20
|
-
return obj !== null && typeof obj === "object" && obj.constructor === Object;
|
|
21
|
-
};
|
|
22
|
-
const isNodeList = function(obj) {
|
|
23
|
-
return obj !== null && typeof obj === "object" && obj.constructor === NodeList;
|
|
24
|
-
};
|
|
25
|
-
const isDom = function(obj) {
|
|
26
|
-
return obj instanceof Element || obj instanceof Node;
|
|
27
|
-
};
|
|
28
|
-
const isPromise = function(obj) {
|
|
29
|
-
return obj instanceof Promise || obj && typeof obj.then === "function";
|
|
30
|
-
};
|
|
31
|
-
const isAsyncFunction = function(fn) {
|
|
32
|
-
if (typeof fn !== "function") {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
if (fn.constructor.name === "AsyncFunction") {
|
|
36
|
-
return true;
|
|
37
|
-
}
|
|
38
|
-
const stringRepresentation = Function.prototype.toString.call(fn);
|
|
39
|
-
return stringRepresentation.startsWith("async");
|
|
40
|
-
};
|
|
41
|
-
export {
|
|
42
|
-
isArray,
|
|
43
|
-
isAsyncFunction,
|
|
44
|
-
isBoolean,
|
|
45
|
-
isDate,
|
|
46
|
-
isDom,
|
|
47
|
-
isFunction,
|
|
48
|
-
isNodeList,
|
|
49
|
-
isNumber,
|
|
50
|
-
isObject,
|
|
51
|
-
isPromise,
|
|
52
|
-
isString
|
|
53
|
-
};
|
|
1
|
+
const n=function(n){return null!==n&&"object"==typeof n&&n.constructor===Array},t=function(n){return null!==n&&"string"==typeof n&&n.constructor===String},o=function(n){return null!==n&&"number"==typeof n&&n.constructor===Number},r=function(n){return null!==n&&"boolean"==typeof n&&n.constructor===Boolean},c=function(n){return null!==n&&"object"==typeof n&&n.constructor===Date},u=function(n){return null!==n&&"function"==typeof n&&(n.constructor===Function||"AsyncFunction"===n.constructor.name)},e=function(n){return null!==n&&"object"==typeof n&&n.constructor===Object},s=function(n){return null!==n&&"object"==typeof n&&n.constructor===NodeList},i=function(n){return n instanceof Element||n instanceof Node},f=function(n){return n instanceof Promise||n&&"function"==typeof n.then},a=function(n){return"function"==typeof n&&("AsyncFunction"===n.constructor.name||Function.prototype.toString.call(n).startsWith("async"))};export{n as isArray,a as isAsyncFunction,r as isBoolean,c as isDate,i as isDom,u as isFunction,s as isNodeList,o as isNumber,e as isObject,f as isPromise,t as isString};
|