@base-web-kits/base-tools-web 1.2.5 → 1.2.7
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/base-tools-web.umd.global.js +7 -20
- package/dist/base-tools-web.umd.global.js.map +1 -1
- package/dist/index.cjs +14 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +640 -0
- package/dist/index.js +25 -209
- package/dist/index.js.map +1 -1
- package/dist/network/download.d.ts +0 -14
- package/dist/network/download.d.ts.map +1 -1
- package/dist/network/request.d.ts.map +1 -1
- package/package.json +1 -12
- package/src/web/async/index.ts +1 -1
- package/src/web/network/download.ts +0 -27
- package/src/web/network/request.ts +4 -7
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
6
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -17,6 +19,15 @@ var __spreadValues = (a, b) => {
|
|
|
17
19
|
return a;
|
|
18
20
|
};
|
|
19
21
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(from))
|
|
25
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
26
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
|
+
}
|
|
28
|
+
return to;
|
|
29
|
+
};
|
|
30
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
31
|
var __async = (__this, __arguments, generator) => {
|
|
21
32
|
return new Promise((resolve, reject) => {
|
|
22
33
|
var fulfilled = (value) => {
|
|
@@ -240,10 +251,10 @@ function execCopyFromHtml(html) {
|
|
|
240
251
|
div.innerHTML = html;
|
|
241
252
|
document.body.appendChild(div);
|
|
242
253
|
const selection = window.getSelection();
|
|
243
|
-
const
|
|
244
|
-
|
|
254
|
+
const range = document.createRange();
|
|
255
|
+
range.selectNodeContents(div);
|
|
245
256
|
selection == null ? void 0 : selection.removeAllRanges();
|
|
246
|
-
selection == null ? void 0 : selection.addRange(
|
|
257
|
+
selection == null ? void 0 : selection.addRange(range);
|
|
247
258
|
const ok = document.execCommand("copy");
|
|
248
259
|
document.body.removeChild(div);
|
|
249
260
|
selection == null ? void 0 : selection.removeAllRanges();
|
|
@@ -458,18 +469,6 @@ function download(url, fileName = "") {
|
|
|
458
469
|
}
|
|
459
470
|
});
|
|
460
471
|
}
|
|
461
|
-
function parseAxiosBlob(res) {
|
|
462
|
-
return __async(this, null, function* () {
|
|
463
|
-
const { data, headers, status, statusText, config } = res;
|
|
464
|
-
if (status < 200 || status >= 300) throw new Error(`${status}\uFF0C${statusText}\uFF1A${config.url}`);
|
|
465
|
-
if (data.type.includes("application/json")) {
|
|
466
|
-
const txt = yield data.text();
|
|
467
|
-
throw JSON.parse(txt);
|
|
468
|
-
}
|
|
469
|
-
const fileName = getDispositionFileName(headers["content-disposition"]);
|
|
470
|
-
return { blob: data, fileName };
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
472
|
function getDispositionFileName(disposition) {
|
|
474
473
|
var _a;
|
|
475
474
|
if (!disposition) return "";
|
|
@@ -588,191 +587,9 @@ function toDayjs(t, fmt) {
|
|
|
588
587
|
}
|
|
589
588
|
|
|
590
589
|
// src/ts/es-toolkit/index.ts
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
Semaphore,
|
|
595
|
-
TimeoutError,
|
|
596
|
-
after,
|
|
597
|
-
ary,
|
|
598
|
-
assert,
|
|
599
|
-
asyncNoop,
|
|
600
|
-
at,
|
|
601
|
-
attempt,
|
|
602
|
-
attemptAsync,
|
|
603
|
-
before,
|
|
604
|
-
camelCase,
|
|
605
|
-
capitalize,
|
|
606
|
-
chunk,
|
|
607
|
-
clamp,
|
|
608
|
-
clone,
|
|
609
|
-
cloneDeep,
|
|
610
|
-
cloneDeepWith,
|
|
611
|
-
compact,
|
|
612
|
-
constantCase,
|
|
613
|
-
countBy,
|
|
614
|
-
curry,
|
|
615
|
-
curryRight,
|
|
616
|
-
debounce,
|
|
617
|
-
deburr,
|
|
618
|
-
delay,
|
|
619
|
-
difference,
|
|
620
|
-
differenceBy,
|
|
621
|
-
differenceWith,
|
|
622
|
-
drop,
|
|
623
|
-
dropRight,
|
|
624
|
-
dropRightWhile,
|
|
625
|
-
dropWhile,
|
|
626
|
-
escape,
|
|
627
|
-
escapeRegExp,
|
|
628
|
-
fill,
|
|
629
|
-
filterAsync,
|
|
630
|
-
findKey,
|
|
631
|
-
flatMap,
|
|
632
|
-
flatMapAsync,
|
|
633
|
-
flatMapDeep,
|
|
634
|
-
flatten,
|
|
635
|
-
flattenDeep,
|
|
636
|
-
flattenObject,
|
|
637
|
-
flow,
|
|
638
|
-
flowRight,
|
|
639
|
-
forEachAsync,
|
|
640
|
-
forEachRight,
|
|
641
|
-
groupBy,
|
|
642
|
-
head,
|
|
643
|
-
identity,
|
|
644
|
-
inRange,
|
|
645
|
-
initial,
|
|
646
|
-
intersection,
|
|
647
|
-
intersectionBy,
|
|
648
|
-
intersectionWith,
|
|
649
|
-
invariant,
|
|
650
|
-
invert,
|
|
651
|
-
isArrayBuffer,
|
|
652
|
-
isBlob,
|
|
653
|
-
isBoolean,
|
|
654
|
-
isBrowser,
|
|
655
|
-
isBuffer,
|
|
656
|
-
isDate,
|
|
657
|
-
isEmptyObject,
|
|
658
|
-
isEqual,
|
|
659
|
-
isEqualWith,
|
|
660
|
-
isError,
|
|
661
|
-
isFile,
|
|
662
|
-
isFunction,
|
|
663
|
-
isJSON,
|
|
664
|
-
isJSONArray,
|
|
665
|
-
isJSONObject,
|
|
666
|
-
isJSONValue,
|
|
667
|
-
isLength,
|
|
668
|
-
isMap,
|
|
669
|
-
isNil,
|
|
670
|
-
isNode,
|
|
671
|
-
isNotNil,
|
|
672
|
-
isNull,
|
|
673
|
-
isNumber,
|
|
674
|
-
isPlainObject,
|
|
675
|
-
isPrimitive,
|
|
676
|
-
isPromise,
|
|
677
|
-
isRegExp,
|
|
678
|
-
isSet,
|
|
679
|
-
isString,
|
|
680
|
-
isSubset,
|
|
681
|
-
isSubsetWith,
|
|
682
|
-
isSymbol,
|
|
683
|
-
isTypedArray,
|
|
684
|
-
isUndefined,
|
|
685
|
-
isWeakMap,
|
|
686
|
-
isWeakSet,
|
|
687
|
-
kebabCase,
|
|
688
|
-
keyBy,
|
|
689
|
-
last,
|
|
690
|
-
limitAsync,
|
|
691
|
-
lowerCase,
|
|
692
|
-
lowerFirst,
|
|
693
|
-
mapAsync,
|
|
694
|
-
mapKeys,
|
|
695
|
-
mapValues,
|
|
696
|
-
maxBy,
|
|
697
|
-
mean,
|
|
698
|
-
meanBy,
|
|
699
|
-
median,
|
|
700
|
-
medianBy,
|
|
701
|
-
memoize,
|
|
702
|
-
merge,
|
|
703
|
-
mergeWith,
|
|
704
|
-
minBy,
|
|
705
|
-
negate,
|
|
706
|
-
noop,
|
|
707
|
-
omit,
|
|
708
|
-
omitBy,
|
|
709
|
-
once,
|
|
710
|
-
orderBy,
|
|
711
|
-
pad,
|
|
712
|
-
partial,
|
|
713
|
-
partialRight,
|
|
714
|
-
partition,
|
|
715
|
-
pascalCase,
|
|
716
|
-
pick,
|
|
717
|
-
pickBy,
|
|
718
|
-
pull,
|
|
719
|
-
pullAt,
|
|
720
|
-
random,
|
|
721
|
-
randomInt,
|
|
722
|
-
range,
|
|
723
|
-
rangeRight,
|
|
724
|
-
reduceAsync,
|
|
725
|
-
remove,
|
|
726
|
-
rest,
|
|
727
|
-
retry,
|
|
728
|
-
reverseString,
|
|
729
|
-
round,
|
|
730
|
-
sample,
|
|
731
|
-
sampleSize,
|
|
732
|
-
shuffle,
|
|
733
|
-
snakeCase,
|
|
734
|
-
sortBy,
|
|
735
|
-
spread,
|
|
736
|
-
startCase,
|
|
737
|
-
sum,
|
|
738
|
-
sumBy,
|
|
739
|
-
tail,
|
|
740
|
-
take,
|
|
741
|
-
takeRight,
|
|
742
|
-
takeRightWhile,
|
|
743
|
-
takeWhile,
|
|
744
|
-
throttle,
|
|
745
|
-
timeout,
|
|
746
|
-
toCamelCaseKeys,
|
|
747
|
-
toFilled,
|
|
748
|
-
toMerged,
|
|
749
|
-
toSnakeCaseKeys,
|
|
750
|
-
trim,
|
|
751
|
-
trimEnd,
|
|
752
|
-
trimStart,
|
|
753
|
-
unary,
|
|
754
|
-
unescape,
|
|
755
|
-
union,
|
|
756
|
-
unionBy,
|
|
757
|
-
unionWith,
|
|
758
|
-
uniq,
|
|
759
|
-
uniqBy,
|
|
760
|
-
uniqWith,
|
|
761
|
-
unzip,
|
|
762
|
-
unzipWith,
|
|
763
|
-
upperCase,
|
|
764
|
-
upperFirst,
|
|
765
|
-
windowed,
|
|
766
|
-
withTimeout,
|
|
767
|
-
without,
|
|
768
|
-
words,
|
|
769
|
-
xor,
|
|
770
|
-
xorBy,
|
|
771
|
-
xorWith,
|
|
772
|
-
zip,
|
|
773
|
-
zipObject,
|
|
774
|
-
zipWith
|
|
775
|
-
} from "es-toolkit";
|
|
590
|
+
var es_toolkit_exports = {};
|
|
591
|
+
__reExport(es_toolkit_exports, es_toolkit_star);
|
|
592
|
+
import * as es_toolkit_star from "es-toolkit";
|
|
776
593
|
|
|
777
594
|
// src/ts/object/index.ts
|
|
778
595
|
import { get, set } from "es-toolkit/compat";
|
|
@@ -817,7 +634,7 @@ function request(config) {
|
|
|
817
634
|
cacheTime,
|
|
818
635
|
resMap,
|
|
819
636
|
responseType = "json",
|
|
820
|
-
timeout
|
|
637
|
+
timeout = 6e4,
|
|
821
638
|
onTaskReady
|
|
822
639
|
} = config;
|
|
823
640
|
const controller = new AbortController();
|
|
@@ -837,7 +654,7 @@ function request(config) {
|
|
|
837
654
|
const execute = () => __async(null, null, function* () {
|
|
838
655
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
839
656
|
const isGet = method === "GET";
|
|
840
|
-
const isObjectData = isPlainObject(data);
|
|
657
|
+
const isObjectData = (0, es_toolkit_exports.isPlainObject)(data);
|
|
841
658
|
const isArrayData = !isObjectData && Array.isArray(data);
|
|
842
659
|
const fillData = isObjectData ? filterRequestData(data) : data;
|
|
843
660
|
const fillHeader = filterRequestHeader(header);
|
|
@@ -887,7 +704,7 @@ function request(config) {
|
|
|
887
704
|
const timeoutId = setTimeout(() => {
|
|
888
705
|
isTimeout = true;
|
|
889
706
|
controller.abort();
|
|
890
|
-
},
|
|
707
|
+
}, timeout);
|
|
891
708
|
try {
|
|
892
709
|
const response = yield fetch(fillUrl, {
|
|
893
710
|
method,
|
|
@@ -982,7 +799,7 @@ function logRequestInfo(options) {
|
|
|
982
799
|
duration: endTime - startTime
|
|
983
800
|
}, logExtra);
|
|
984
801
|
if (status === "success") {
|
|
985
|
-
info.res = cloneDeep(res);
|
|
802
|
+
info.res = (0, es_toolkit_exports.cloneDeep)(res);
|
|
986
803
|
log("info", info);
|
|
987
804
|
} else {
|
|
988
805
|
info.e = e;
|
|
@@ -1100,9 +917,9 @@ function enhanceWebApi(webApi, apiName) {
|
|
|
1100
917
|
const logData = __spreadValues({ name: fname, status: "success", option }, logExtra);
|
|
1101
918
|
if (resMap) {
|
|
1102
919
|
logData.res = res;
|
|
1103
|
-
logData.resMap = cloneDeep(finalRes);
|
|
920
|
+
logData.resMap = (0, es_toolkit_exports.cloneDeep)(finalRes);
|
|
1104
921
|
} else {
|
|
1105
|
-
logData.res = cloneDeep(res);
|
|
922
|
+
logData.res = (0, es_toolkit_exports.cloneDeep)(res);
|
|
1106
923
|
}
|
|
1107
924
|
log == null ? void 0 : log("info", logData);
|
|
1108
925
|
}
|
|
@@ -1130,7 +947,7 @@ function upload(option, config) {
|
|
|
1130
947
|
return new Promise((resolve, reject) => {
|
|
1131
948
|
var _a;
|
|
1132
949
|
const xhr = new XMLHttpRequest();
|
|
1133
|
-
const { url, file, name = "file", header, formData, timeout
|
|
950
|
+
const { url, file, name = "file", header, formData, timeout = 0 } = option;
|
|
1134
951
|
const fail = (error) => reject(error);
|
|
1135
952
|
const success = (responseText) => {
|
|
1136
953
|
resolve(responseText);
|
|
@@ -1168,7 +985,7 @@ function upload(option, config) {
|
|
|
1168
985
|
if (v !== void 0 && v !== null && v !== "") xhr.setRequestHeader(k, String(v));
|
|
1169
986
|
});
|
|
1170
987
|
}
|
|
1171
|
-
xhr.timeout =
|
|
988
|
+
xhr.timeout = timeout;
|
|
1172
989
|
const data = new FormData();
|
|
1173
990
|
if (formData) {
|
|
1174
991
|
Object.entries(formData).forEach(([k, v]) => {
|
|
@@ -1290,7 +1107,6 @@ export {
|
|
|
1290
1107
|
loadCss,
|
|
1291
1108
|
loadJs,
|
|
1292
1109
|
lockBodyScroll,
|
|
1293
|
-
parseAxiosBlob,
|
|
1294
1110
|
preloadImage,
|
|
1295
1111
|
removeCookie,
|
|
1296
1112
|
removeLocalStorage,
|