@minto-ai/tools 1.0.50 → 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.
@@ -23,6 +23,7 @@ declare const FileSuffixEnum: {
23
23
  readonly TXT: "txt";
24
24
  readonly ZIP: "zip";
25
25
  readonly RAR: "rar";
26
+ readonly HTML: "html";
26
27
  };
27
28
  /**
28
29
  * 图片后缀类型枚举
@@ -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, };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 更新文件路径的查询参数
3
+ * @param filePath 文件路径
4
+ * @param objectQuery 查询参数对象
5
+ * @returns 更新后的文件路径
6
+ */
7
+ declare function updateFilePathQuery(filePath: string, objectQuery: Record<string, string>, isAppend?: boolean): string;
8
+ export default updateFilePathQuery;
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",
@@ -13205,7 +13199,8 @@ var FileSuffixEnum = {
13205
13199
  WAV: "wav",
13206
13200
  TXT: "txt",
13207
13201
  ZIP: "zip",
13208
- RAR: "rar"
13202
+ RAR: "rar",
13203
+ HTML: "html"
13209
13204
  };
13210
13205
  var ImageFileSuffixEnum = {
13211
13206
  JPG: FileSuffixEnum.JPG,
@@ -13256,10 +13251,28 @@ function getFileName(filePath) {
13256
13251
  var fileSuffix = getFileSuffix(filePath);
13257
13252
  return fileSuffix ? "".concat(fileTitle, ".").concat(fileSuffix) : fileTitle;
13258
13253
  }
13259
- function getFilePathNotQuery(filePath) {
13260
- var _matchResult$;
13261
- var matchResult = filePath.match(filePathRegex);
13262
- return (_matchResult$ = matchResult === null || matchResult === void 0 ? void 0 : matchResult[1]) !== null && _matchResult$ !== void 0 ? _matchResult$ : "";
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("&");
13263
13276
  }
13264
13277
  function queryStringToObject(queryString) {
13265
13278
  return queryString.split("&").filter(Boolean).map(function(str) {
@@ -13270,11 +13283,28 @@ function queryStringToObject(queryString) {
13270
13283
  return obj;
13271
13284
  }, {});
13272
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
+ }
13273
13291
  function getFileQuery(filePath) {
13274
13292
  var _matchResult$;
13275
13293
  var matchResult = filePath.match(filePathRegex);
13276
13294
  return queryStringToObject((_matchResult$ = matchResult === null || matchResult === void 0 ? void 0 : matchResult[6]) !== null && _matchResult$ !== void 0 ? _matchResult$ : "");
13277
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
+ }
13278
13308
  function batchDownloadFile(_x, _x2) {
13279
13309
  return _batchDownloadFile.apply(this, arguments);
13280
13310
  }
@@ -13286,11 +13316,9 @@ function _batchDownloadFile() {
13286
13316
  case 0:
13287
13317
  fileList = fileList.map(function(_ref) {
13288
13318
  var filePath = _ref.filePath, fileName = _ref.fileName;
13289
- var queryString = objectToQueryString(_objectSpread2(_objectSpread2({}, getFileQuery(filePath)), {}, {
13319
+ filePath = updateFilePathQuery(filePath, {
13290
13320
  "response-content-type": "application/octet-stream"
13291
- }));
13292
- var filePathNotQuery = getFilePathNotQuery(filePath);
13293
- filePath = checkEmpty(queryString) ? filePathNotQuery : "".concat(filePathNotQuery, "?").concat(queryString);
13321
+ });
13294
13322
  fileName = checkEmpty(fileName) ? getFileName(filePath) : fileName;
13295
13323
  if (fileName) {
13296
13324
  return {
@@ -13465,26 +13493,25 @@ function singleDownloadFile(_x, _x2) {
13465
13493
  }
13466
13494
  function _singleDownloadFile() {
13467
13495
  _singleDownloadFile = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee(filePath, fileName) {
13468
- var queryString, filePathNotQuery, _yield$axios$get, data2;
13496
+ var _yield$axios$get, data2;
13469
13497
  return _regeneratorRuntime().wrap(function _callee$(_context) {
13470
13498
  while (1) switch (_context.prev = _context.next) {
13471
13499
  case 0:
13472
13500
  if (!fileName) {
13473
13501
  fileName = getFileName(filePath);
13474
13502
  }
13475
- queryString = objectToQueryString(_objectSpread2(_objectSpread2({}, getFileQuery(filePath)), {}, {
13503
+ filePath = updateFilePathQuery(filePath, {
13476
13504
  "response-content-type": "application/octet-stream"
13477
- }));
13478
- filePathNotQuery = getFilePathNotQuery(filePath);
13479
- _context.next = 5;
13480
- return axios.get(checkEmpty(queryString) ? filePathNotQuery : "".concat(filePathNotQuery, "?").concat(queryString), {
13505
+ });
13506
+ _context.next = 4;
13507
+ return axios.get(filePath, {
13481
13508
  responseType: "blob"
13482
13509
  });
13483
- case 5:
13510
+ case 4:
13484
13511
  _yield$axios$get = _context.sent;
13485
13512
  data2 = _yield$axios$get.data;
13486
13513
  FileSaver.saveAs(data2, fileName);
13487
- case 8:
13514
+ case 7:
13488
13515
  case "end":
13489
13516
  return _context.stop();
13490
13517
  }
@@ -13628,23 +13655,6 @@ function pickObject(obj, keys6) {
13628
13655
  });
13629
13656
  return result;
13630
13657
  }
13631
- function chunkString(str) {
13632
- var chunkSize = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : str.length;
13633
- if (chunkSize === 0) {
13634
- throw new Error("块大小不能为 0");
13635
- }
13636
- if (chunkSize < 0) {
13637
- throw new Error("块大小不能为负数");
13638
- }
13639
- if (str.length === 0) {
13640
- return [];
13641
- }
13642
- var chunks = [];
13643
- for (var i = 0; i < str.length; i += chunkSize) {
13644
- chunks.push(str.substring(i, i + chunkSize));
13645
- }
13646
- return chunks;
13647
- }
13648
13658
  function getUuid() {
13649
13659
  return window.crypto.getRandomValues(new Uint32Array(1))[0].toString(36);
13650
13660
  }
@@ -13743,5 +13753,6 @@ export {
13743
13753
  singleDownloadFile,
13744
13754
  subtract,
13745
13755
  throttle,
13746
- timeDelay
13756
+ timeDelay,
13757
+ updateFilePathQuery
13747
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@minto-ai/tools",
3
3
  "type": "module",
4
- "version": "1.0.50",
4
+ "version": "1.0.52",
5
5
  "description": "明途公共工具库",
6
6
  "author": "hcc",
7
7
  "license": "ISC",
@@ -18,8 +18,7 @@
18
18
  "dist"
19
19
  ],
20
20
  "scripts": {
21
- "build": "vite build",
22
- "up": "gulp --gulpfile ../../gulpfile.cjs --cwd ./"
21
+ "build": "vite build"
23
22
  },
24
23
  "dependencies": {
25
24
  "axios": "^1.7.9",