@minto-ai/tools 1.0.51 → 1.0.52
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/file/index.d.ts
CHANGED
|
@@ -16,5 +16,6 @@ import { default as isMusicFilePath } from './is-music-file-path';
|
|
|
16
16
|
import { default as isPptFilePath } from './is-ppt-file-path';
|
|
17
17
|
import { default as isVideoFilePath } from './is-video-file-path';
|
|
18
18
|
import { default as singleDownloadFile } from './single-download-file';
|
|
19
|
+
import { default as updateFilePathQuery } from './update-file-path-query';
|
|
19
20
|
export type { CompressFileSuffix, DocumentFileSuffix, FileSuffix, ImageFileSuffix, MusicFileSuffix, PptFileSuffix, VideoFileSuffix, };
|
|
20
|
-
export { batchDownloadFile, CompressFileSuffixEnum, DocumentFileSuffixEnum, FileSuffixEnum, getFileIcon, getFileName, getFilePathNotQuery, getFileQuery, getFileSuffix, getFileSuffixIcon, getFileTitle, ImageFileSuffixEnum, isCompressFilePath, isDocumentFilePath, isFilePath, isImageFilePath, isMusicFilePath, isPptFilePath, isVideoFilePath, MusicFileSuffixEnum, PptFileSuffixEnum, singleDownloadFile, VideoFileSuffixEnum, };
|
|
21
|
+
export { batchDownloadFile, CompressFileSuffixEnum, DocumentFileSuffixEnum, FileSuffixEnum, getFileIcon, getFileName, getFilePathNotQuery, getFileQuery, getFileSuffix, getFileSuffixIcon, getFileTitle, ImageFileSuffixEnum, isCompressFilePath, isDocumentFilePath, isFilePath, isImageFilePath, isMusicFilePath, isPptFilePath, isVideoFilePath, MusicFileSuffixEnum, PptFileSuffixEnum, singleDownloadFile, updateFilePathQuery, VideoFileSuffixEnum, };
|
package/dist/index.js
CHANGED
|
@@ -13178,12 +13178,6 @@ function isNullOrUndefined2(value) {
|
|
|
13178
13178
|
function isUndefined(value) {
|
|
13179
13179
|
return value === void 0;
|
|
13180
13180
|
}
|
|
13181
|
-
function objectToQueryString(obj) {
|
|
13182
|
-
return Object.entries(obj).map(function(_ref) {
|
|
13183
|
-
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
13184
|
-
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
|
|
13185
|
-
}).join("&");
|
|
13186
|
-
}
|
|
13187
13181
|
var FileSuffixEnum = {
|
|
13188
13182
|
DOCX: "docx",
|
|
13189
13183
|
DOC: "doc",
|
|
@@ -13257,10 +13251,28 @@ function getFileName(filePath) {
|
|
|
13257
13251
|
var fileSuffix = getFileSuffix(filePath);
|
|
13258
13252
|
return fileSuffix ? "".concat(fileTitle, ".").concat(fileSuffix) : fileTitle;
|
|
13259
13253
|
}
|
|
13260
|
-
function
|
|
13261
|
-
var
|
|
13262
|
-
|
|
13263
|
-
|
|
13254
|
+
function chunkString(str) {
|
|
13255
|
+
var chunkSize = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : str.length;
|
|
13256
|
+
if (chunkSize === 0) {
|
|
13257
|
+
throw new Error("块大小不能为 0");
|
|
13258
|
+
}
|
|
13259
|
+
if (chunkSize < 0) {
|
|
13260
|
+
throw new Error("块大小不能为负数");
|
|
13261
|
+
}
|
|
13262
|
+
if (str.length === 0) {
|
|
13263
|
+
return [];
|
|
13264
|
+
}
|
|
13265
|
+
var chunks = [];
|
|
13266
|
+
for (var i = 0; i < str.length; i += chunkSize) {
|
|
13267
|
+
chunks.push(str.substring(i, i + chunkSize));
|
|
13268
|
+
}
|
|
13269
|
+
return chunks;
|
|
13270
|
+
}
|
|
13271
|
+
function objectToQueryString(obj) {
|
|
13272
|
+
return Object.entries(obj).map(function(_ref) {
|
|
13273
|
+
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
13274
|
+
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
|
|
13275
|
+
}).join("&");
|
|
13264
13276
|
}
|
|
13265
13277
|
function queryStringToObject(queryString) {
|
|
13266
13278
|
return queryString.split("&").filter(Boolean).map(function(str) {
|
|
@@ -13271,11 +13283,28 @@ function queryStringToObject(queryString) {
|
|
|
13271
13283
|
return obj;
|
|
13272
13284
|
}, {});
|
|
13273
13285
|
}
|
|
13286
|
+
function getFilePathNotQuery(filePath) {
|
|
13287
|
+
var _matchResult$;
|
|
13288
|
+
var matchResult = filePath.match(filePathRegex);
|
|
13289
|
+
return (_matchResult$ = matchResult === null || matchResult === void 0 ? void 0 : matchResult[1]) !== null && _matchResult$ !== void 0 ? _matchResult$ : "";
|
|
13290
|
+
}
|
|
13274
13291
|
function getFileQuery(filePath) {
|
|
13275
13292
|
var _matchResult$;
|
|
13276
13293
|
var matchResult = filePath.match(filePathRegex);
|
|
13277
13294
|
return queryStringToObject((_matchResult$ = matchResult === null || matchResult === void 0 ? void 0 : matchResult[6]) !== null && _matchResult$ !== void 0 ? _matchResult$ : "");
|
|
13278
13295
|
}
|
|
13296
|
+
function updateFilePathQuery(filePath, objectQuery) {
|
|
13297
|
+
var isAppend = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
13298
|
+
var filePathNotQuery = getFilePathNotQuery(filePath);
|
|
13299
|
+
var queryString = "";
|
|
13300
|
+
if (isAppend) {
|
|
13301
|
+
var fileQuery = getFileQuery(filePath);
|
|
13302
|
+
queryString = objectToQueryString(_objectSpread2(_objectSpread2({}, fileQuery), objectQuery));
|
|
13303
|
+
} else {
|
|
13304
|
+
queryString = objectToQueryString(objectQuery);
|
|
13305
|
+
}
|
|
13306
|
+
return checkEmpty(queryString) ? filePathNotQuery : "".concat(filePathNotQuery, "?").concat(queryString);
|
|
13307
|
+
}
|
|
13279
13308
|
function batchDownloadFile(_x, _x2) {
|
|
13280
13309
|
return _batchDownloadFile.apply(this, arguments);
|
|
13281
13310
|
}
|
|
@@ -13287,11 +13316,9 @@ function _batchDownloadFile() {
|
|
|
13287
13316
|
case 0:
|
|
13288
13317
|
fileList = fileList.map(function(_ref) {
|
|
13289
13318
|
var filePath = _ref.filePath, fileName = _ref.fileName;
|
|
13290
|
-
|
|
13319
|
+
filePath = updateFilePathQuery(filePath, {
|
|
13291
13320
|
"response-content-type": "application/octet-stream"
|
|
13292
|
-
})
|
|
13293
|
-
var filePathNotQuery = getFilePathNotQuery(filePath);
|
|
13294
|
-
filePath = checkEmpty(queryString) ? filePathNotQuery : "".concat(filePathNotQuery, "?").concat(queryString);
|
|
13321
|
+
});
|
|
13295
13322
|
fileName = checkEmpty(fileName) ? getFileName(filePath) : fileName;
|
|
13296
13323
|
if (fileName) {
|
|
13297
13324
|
return {
|
|
@@ -13466,26 +13493,25 @@ function singleDownloadFile(_x, _x2) {
|
|
|
13466
13493
|
}
|
|
13467
13494
|
function _singleDownloadFile() {
|
|
13468
13495
|
_singleDownloadFile = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(filePath, fileName) {
|
|
13469
|
-
var
|
|
13496
|
+
var _yield$axios$get, data2;
|
|
13470
13497
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
13471
13498
|
while (1) switch (_context.prev = _context.next) {
|
|
13472
13499
|
case 0:
|
|
13473
13500
|
if (!fileName) {
|
|
13474
13501
|
fileName = getFileName(filePath);
|
|
13475
13502
|
}
|
|
13476
|
-
|
|
13503
|
+
filePath = updateFilePathQuery(filePath, {
|
|
13477
13504
|
"response-content-type": "application/octet-stream"
|
|
13478
|
-
})
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
return axios.get(checkEmpty(queryString) ? filePathNotQuery : "".concat(filePathNotQuery, "?").concat(queryString), {
|
|
13505
|
+
});
|
|
13506
|
+
_context.next = 4;
|
|
13507
|
+
return axios.get(filePath, {
|
|
13482
13508
|
responseType: "blob"
|
|
13483
13509
|
});
|
|
13484
|
-
case
|
|
13510
|
+
case 4:
|
|
13485
13511
|
_yield$axios$get = _context.sent;
|
|
13486
13512
|
data2 = _yield$axios$get.data;
|
|
13487
13513
|
FileSaver.saveAs(data2, fileName);
|
|
13488
|
-
case
|
|
13514
|
+
case 7:
|
|
13489
13515
|
case "end":
|
|
13490
13516
|
return _context.stop();
|
|
13491
13517
|
}
|
|
@@ -13629,23 +13655,6 @@ function pickObject(obj, keys6) {
|
|
|
13629
13655
|
});
|
|
13630
13656
|
return result;
|
|
13631
13657
|
}
|
|
13632
|
-
function chunkString(str) {
|
|
13633
|
-
var chunkSize = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : str.length;
|
|
13634
|
-
if (chunkSize === 0) {
|
|
13635
|
-
throw new Error("块大小不能为 0");
|
|
13636
|
-
}
|
|
13637
|
-
if (chunkSize < 0) {
|
|
13638
|
-
throw new Error("块大小不能为负数");
|
|
13639
|
-
}
|
|
13640
|
-
if (str.length === 0) {
|
|
13641
|
-
return [];
|
|
13642
|
-
}
|
|
13643
|
-
var chunks = [];
|
|
13644
|
-
for (var i = 0; i < str.length; i += chunkSize) {
|
|
13645
|
-
chunks.push(str.substring(i, i + chunkSize));
|
|
13646
|
-
}
|
|
13647
|
-
return chunks;
|
|
13648
|
-
}
|
|
13649
13658
|
function getUuid() {
|
|
13650
13659
|
return window.crypto.getRandomValues(new Uint32Array(1))[0].toString(36);
|
|
13651
13660
|
}
|
|
@@ -13744,5 +13753,6 @@ export {
|
|
|
13744
13753
|
singleDownloadFile,
|
|
13745
13754
|
subtract,
|
|
13746
13755
|
throttle,
|
|
13747
|
-
timeDelay
|
|
13756
|
+
timeDelay,
|
|
13757
|
+
updateFilePathQuery
|
|
13748
13758
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 流式打字机
|
|
3
|
+
* @param speed 打字速度
|
|
4
|
+
*/
|
|
5
|
+
declare class TypeWriter {
|
|
6
|
+
private speed;
|
|
7
|
+
private state;
|
|
8
|
+
private onEndCallback;
|
|
9
|
+
private onChangeCallback;
|
|
10
|
+
constructor(speed?: number);
|
|
11
|
+
private processQueue;
|
|
12
|
+
private init;
|
|
13
|
+
append(text: string): void;
|
|
14
|
+
stop(): void;
|
|
15
|
+
onEnd(callback: (text?: string) => void): void;
|
|
16
|
+
onChange(callback: (text?: string) => void): void;
|
|
17
|
+
}
|
|
18
|
+
export default TypeWriter;
|