@wzyjs/utils 0.2.36 → 0.2.37

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 (81) hide show
  1. package/dist/ai/302/axios.d.ts +2 -0
  2. package/dist/ai/302/chat/index.d.ts +1 -0
  3. package/dist/ai/302/image/index.d.ts +1 -0
  4. package/dist/ai/302/image/midjourney.d.ts +2 -0
  5. package/dist/ai/302/index.d.ts +2 -0
  6. package/dist/ai/index.d.ts +3 -0
  7. package/dist/ai/keling/axios.d.ts +2 -0
  8. package/dist/ai/keling/index.d.ts +8 -0
  9. package/dist/ai/keling/utils.d.ts +4 -0
  10. package/dist/ai/midjourney/index.d.ts +1 -0
  11. package/dist/ai/midjourney/utils.d.ts +12 -0
  12. package/dist/browser/download.d.ts +1 -0
  13. package/dist/browser/element.d.ts +6 -0
  14. package/dist/browser/index.d.ts +8 -0
  15. package/dist/browser/other.d.ts +2 -0
  16. package/dist/browser/style.d.ts +10 -0
  17. package/dist/browser.cjs.js +21010 -0
  18. package/dist/browser.esm.js +21007 -0
  19. package/dist/common/antd.d.ts +11 -0
  20. package/dist/common/array.d.ts +3 -0
  21. package/dist/common/image.d.ts +1 -0
  22. package/dist/common/index.d.ts +13 -0
  23. package/dist/common/location.d.ts +8 -0
  24. package/dist/common/number.d.ts +5 -0
  25. package/dist/common/object.d.ts +10 -0
  26. package/dist/common/other.d.ts +4 -0
  27. package/dist/common/promise.d.ts +5 -0
  28. package/dist/common/string.d.ts +22 -0
  29. package/dist/node/file/index.d.ts +2 -0
  30. package/dist/node/index.d.ts +4 -0
  31. package/dist/node/mail/index.d.ts +1 -0
  32. package/dist/node/oss/index.d.ts +9 -0
  33. package/dist/node.cjs.js +97007 -0
  34. package/dist/{cjs/node.d.ts → node.d.ts} +1 -0
  35. package/dist/node.esm.js +96989 -0
  36. package/package.json +27 -25
  37. package/dist/cjs/browser/element.js +0 -59
  38. package/dist/cjs/browser/index.js +0 -66
  39. package/dist/cjs/browser/initHttpClient.js +0 -62
  40. package/dist/cjs/browser/other.js +0 -35
  41. package/dist/cjs/browser/style.js +0 -81
  42. package/dist/cjs/browser.js +0 -25
  43. package/dist/cjs/common/array.js +0 -68
  44. package/dist/cjs/common/classs.js +0 -36
  45. package/dist/cjs/common/dayjs.js +0 -70
  46. package/dist/cjs/common/index.d.ts +0 -13
  47. package/dist/cjs/common/index.js +0 -106
  48. package/dist/cjs/common/number.js +0 -69
  49. package/dist/cjs/common/object.js +0 -65
  50. package/dist/cjs/common/other.js +0 -129
  51. package/dist/cjs/common/string.js +0 -190
  52. package/dist/cjs/node/file/index.js +0 -58
  53. package/dist/cjs/node/index.js +0 -48
  54. package/dist/cjs/node/jsonFile/index.js +0 -75
  55. package/dist/cjs/node/mail/index.js +0 -67
  56. package/dist/cjs/node.js +0 -25
  57. package/dist/esm/browser/element.js +0 -43
  58. package/dist/esm/browser/index.js +0 -16
  59. package/dist/esm/browser/initHttpClient.js +0 -67
  60. package/dist/esm/browser/other.js +0 -28
  61. package/dist/esm/browser/style.js +0 -55
  62. package/dist/esm/browser.d.ts +0 -2
  63. package/dist/esm/browser.js +0 -2
  64. package/dist/esm/common/array.js +0 -65
  65. package/dist/esm/common/classs.js +0 -33
  66. package/dist/esm/common/dayjs.d.ts +0 -19
  67. package/dist/esm/common/dayjs.js +0 -29
  68. package/dist/esm/common/index.d.ts +0 -13
  69. package/dist/esm/common/index.js +0 -14
  70. package/dist/esm/common/number.js +0 -52
  71. package/dist/esm/common/object.js +0 -84
  72. package/dist/esm/common/other.js +0 -167
  73. package/dist/esm/common/string.js +0 -180
  74. package/dist/esm/node/file/index.js +0 -52
  75. package/dist/esm/node/index.js +0 -4
  76. package/dist/esm/node/jsonFile/index.js +0 -101
  77. package/dist/esm/node/mail/index.js +0 -48
  78. package/dist/esm/node.d.ts +0 -2
  79. package/dist/esm/node.js +0 -2
  80. /package/dist/{cjs/browser.d.ts → browser.d.ts} +0 -0
  81. /package/dist/{cjs/common → common}/dayjs.d.ts +0 -0
@@ -1,75 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/node/jsonFile/index.ts
30
- var jsonFile_exports = {};
31
- __export(jsonFile_exports, {
32
- JsonFile: () => JsonFile
33
- });
34
- module.exports = __toCommonJS(jsonFile_exports);
35
- var import_fs_extra = __toESM(require("fs-extra"));
36
- var path = require("path");
37
- var JsonFile = class {
38
- constructor(filePath) {
39
- this.filePath = path.resolve(__dirname, filePath);
40
- this.ensureFileExists();
41
- }
42
- ensureFileExists() {
43
- try {
44
- if (!import_fs_extra.default.existsSync(this.filePath)) {
45
- import_fs_extra.default.writeFileSync(this.filePath, "{}", "utf-8");
46
- }
47
- } catch (error) {
48
- console.error("Error ensuring file exists:", error);
49
- }
50
- }
51
- async get(key) {
52
- try {
53
- const data = await import_fs_extra.default.readFile(this.filePath, "utf-8");
54
- const json = data ? JSON.parse(data) : {};
55
- return json[key];
56
- } catch (error) {
57
- console.error("Error reading file:", error);
58
- return null;
59
- }
60
- }
61
- async set(key, value) {
62
- try {
63
- const data = await import_fs_extra.default.readFile(this.filePath, "utf-8");
64
- const json = data ? JSON.parse(data || "{}") : {};
65
- json[key] = value;
66
- await import_fs_extra.default.writeFile(this.filePath, JSON.stringify(json, null, 2));
67
- } catch (error) {
68
- console.error("Error writing file:", error);
69
- }
70
- }
71
- };
72
- // Annotate the CommonJS export names for ESM import in node:
73
- 0 && (module.exports = {
74
- JsonFile
75
- });
@@ -1,67 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/node/mail/index.ts
30
- var mail_exports = {};
31
- __export(mail_exports, {
32
- sendMail: () => sendMail
33
- });
34
- module.exports = __toCommonJS(mail_exports);
35
- var import_nodemailer = __toESM(require("nodemailer"));
36
- var fromEmail = "15835196981@163.com";
37
- var fromPass = "KPTVCFBMRXJVTCGW";
38
- var transporter = import_nodemailer.default.createTransport({
39
- host: "smtp.163.com",
40
- port: 465,
41
- secure: true,
42
- auth: {
43
- user: fromEmail,
44
- pass: fromPass
45
- }
46
- });
47
- var sendMail = async (toEmail, title, content) => {
48
- try {
49
- await transporter.sendMail({
50
- from: fromEmail,
51
- // 发件人邮箱
52
- to: toEmail,
53
- // 收件人邮箱
54
- subject: title,
55
- // 邮件主题
56
- text: content
57
- // 邮件正文
58
- });
59
- return title + " 邮件通知成功";
60
- } catch (error) {
61
- return title + "邮件通知失败" + JSON.stringify(error);
62
- }
63
- };
64
- // Annotate the CommonJS export names for ESM import in node:
65
- 0 && (module.exports = {
66
- sendMail
67
- });
package/dist/cjs/node.js DELETED
@@ -1,25 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/node.ts
17
- var node_exports = {};
18
- module.exports = __toCommonJS(node_exports);
19
- __reExport(node_exports, require("./common"), module.exports);
20
- __reExport(node_exports, require("./node/index"), module.exports);
21
- // Annotate the CommonJS export names for ESM import in node:
22
- 0 && (module.exports = {
23
- ...require("./common"),
24
- ...require("./node/index")
25
- });
@@ -1,43 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- // 滚动到让指定元素显示出来的位置
8
- export var scrollIntoView = function scrollIntoView(el, option) {
9
- if (!el) {
10
- return;
11
- }
12
- el.scrollIntoView(_objectSpread({
13
- behavior: 'smooth',
14
- block: 'start'
15
- }, option));
16
- };
17
-
18
- // 获取指定元素 已经元素原始的样式
19
- export var getElement = function getElement(el) {
20
- var element = typeof el === 'string' ? document.querySelector(el) : el;
21
- if (!element) {
22
- return {
23
- element: null,
24
- originalStyle: {}
25
- };
26
- }
27
- // 获取元素原始的样式
28
- return {
29
- element: element,
30
- originalStyle: window.getComputedStyle(element)
31
- };
32
- };
33
-
34
- // 判断元素是否在可见范围内
35
- export var isElementInViewport = function isElementInViewport(el) {
36
- var _getElement = getElement(el),
37
- element = _getElement.element;
38
- if (!element) {
39
- return;
40
- }
41
- var rect = element.getBoundingClientRect();
42
- return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
43
- };
@@ -1,16 +0,0 @@
1
- import md5 from 'md5';
2
- import classnames from 'classnames';
3
- import copy from 'copy-to-clipboard';
4
- import { config, getItem, removeItem, setItem } from 'localforage';
5
- import anime from 'animejs';
6
- export { copy, classnames, md5, anime };
7
- export var localforage = {
8
- config: config,
9
- setItem: setItem,
10
- getItem: getItem,
11
- removeItem: removeItem
12
- };
13
- export * from "./style";
14
- export * from "./element";
15
- export * from "./other";
16
- export * from "./initHttpClient";
@@ -1,67 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
8
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
9
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
- import axios from 'axios';
11
- import { pick } from 'lodash';
12
- var ErrorMiddleware = function ErrorMiddleware(onError) {
13
- return /*#__PURE__*/function () {
14
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_, next) {
15
- return _regeneratorRuntime().wrap(function _callee$(_context) {
16
- while (1) switch (_context.prev = _context.next) {
17
- case 0:
18
- _context.prev = 0;
19
- _context.next = 3;
20
- return next();
21
- case 3:
22
- _context.next = 8;
23
- break;
24
- case 5:
25
- _context.prev = 5;
26
- _context.t0 = _context["catch"](0);
27
- onError(_context.t0);
28
- case 8:
29
- case "end":
30
- return _context.stop();
31
- }
32
- }, _callee, null, [[0, 5]]);
33
- }));
34
- return function (_x, _x2) {
35
- return _ref.apply(this, arguments);
36
- };
37
- }();
38
- };
39
- export var initHttpClient = function initHttpClient(setupHttpClient, option) {
40
- setupHttpClient({
41
- middleware: [ErrorMiddleware(option.onError)],
42
- fetcher: function () {
43
- var _fetcher = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(req, options) {
44
- var response;
45
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
46
- while (1) switch (_context2.prev = _context2.next) {
47
- case 0:
48
- _context2.next = 2;
49
- return axios(_objectSpread(_objectSpread(_objectSpread({}, pick(req, ['method', 'url', 'data', 'query', 'headers'])), pick(options, ['baseURL', 'withCredentials'])), {}, {
50
- timeout: options.timeout
51
- }));
52
- case 2:
53
- response = _context2.sent;
54
- return _context2.abrupt("return", response.data);
55
- case 4:
56
- case "end":
57
- return _context2.stop();
58
- }
59
- }, _callee2);
60
- }));
61
- function fetcher(_x3, _x4) {
62
- return _fetcher.apply(this, arguments);
63
- }
64
- return fetcher;
65
- }()
66
- });
67
- };
@@ -1,28 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
3
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
- export var readClipboard = /*#__PURE__*/function () {
6
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
7
- return _regeneratorRuntime().wrap(function _callee$(_context) {
8
- while (1) switch (_context.prev = _context.next) {
9
- case 0:
10
- _context.prev = 0;
11
- _context.next = 3;
12
- return navigator.clipboard.readText();
13
- case 3:
14
- return _context.abrupt("return", _context.sent);
15
- case 6:
16
- _context.prev = 6;
17
- _context.t0 = _context["catch"](0);
18
- return _context.abrupt("return", '');
19
- case 9:
20
- case "end":
21
- return _context.stop();
22
- }
23
- }, _callee, null, [[0, 6]]);
24
- }));
25
- return function readClipboard() {
26
- return _ref.apply(this, arguments);
27
- };
28
- }();
@@ -1,55 +0,0 @@
1
- import anime from 'animejs';
2
- import { getElement } from "./element";
3
-
4
- // 颜色值转换
5
- export var hexToRgba = function hexToRgba(hexColor) {
6
- var a = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
7
- var red = parseInt(hexColor.substr(1, 2), 16);
8
- var green = parseInt(hexColor.substr(3, 2), 16);
9
- var blue = parseInt(hexColor.substr(5, 2), 16);
10
- return {
11
- nums: {
12
- red: red,
13
- green: green,
14
- blue: blue
15
- },
16
- text: "rgba(".concat(red, ", ").concat(green, ", ").concat(blue, ", ").concat(a, ")")
17
- };
18
- };
19
-
20
- // 背景颜色闪动
21
- export var flashBackground = function flashBackground(el, color) {
22
- var a = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
23
- var _getElement = getElement(el),
24
- element = _getElement.element,
25
- originalStyle = _getElement.originalStyle;
26
- if (!element) {
27
- return;
28
- }
29
- anime({
30
- targets: element,
31
- backgroundColor: [hexToRgba(color, a).text, originalStyle.backgroundColor],
32
- duration: 1500,
33
- easing: 'easeInOutSine',
34
- direction: 'alternate',
35
- loop: false
36
- });
37
- };
38
-
39
- // 边框闪动
40
- export var flashBorder = function flashBorder(el, color) {
41
- var a = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
42
- var _getElement2 = getElement(el),
43
- element = _getElement2.element;
44
- if (!element) {
45
- return;
46
- }
47
- anime({
48
- targets: element,
49
- border: ["1px solid ".concat(hexToRgba(color, a).text), 'none'],
50
- duration: 1500,
51
- easing: 'easeInOutSine',
52
- direction: 'alternate',
53
- loop: false
54
- });
55
- };
@@ -1,2 +0,0 @@
1
- export * from './common';
2
- export * from './browser/index';
@@ -1,2 +0,0 @@
1
- export * from "./common";
2
- export * from "./browser/index";
@@ -1,65 +0,0 @@
1
- function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
5
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
6
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
- import { levenshteinDistance } from "./string";
9
-
10
- // 数组随机变换位置
11
- export var shuffleArray = function shuffleArray(array) {
12
- var shuffledArray = _toConsumableArray(array); // 创建数组的副本以避免修改原数组
13
- for (var i = shuffledArray.length - 1; i > 0; i--) {
14
- var j = Math.floor(Math.random() * (i + 1));
15
- var _ref = [shuffledArray[j], shuffledArray[i]];
16
- shuffledArray[i] = _ref[0];
17
- shuffledArray[j] = _ref[1];
18
- }
19
- return shuffledArray;
20
- };
21
-
22
- // 去重函数,接受一个字符串数组,返回一个相似程度高的去重后的数组
23
- export var removeSimilarDuplicates = function removeSimilarDuplicates(arr, threshold, isLog) {
24
- var uniqueArray = [];
25
- var similarPairs = []; // 用于存储相似的字符串对
26
- var _iterator = _createForOfIteratorHelper(arr),
27
- _step;
28
- try {
29
- var _loop = function _loop() {
30
- var str = _step.value;
31
- var isSimilar = uniqueArray.some(function (uniqueStr) {
32
- var distance = levenshteinDistance(str, uniqueStr);
33
- if (distance <= threshold) {
34
- similarPairs.push([str, uniqueStr]); // 记录相似字符串对
35
- return true;
36
- }
37
- return false;
38
- });
39
- if (!isSimilar) {
40
- uniqueArray.push(str);
41
- }
42
- };
43
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
44
- _loop();
45
- }
46
-
47
- // 打印相似的字符串
48
- } catch (err) {
49
- _iterator.e(err);
50
- } finally {
51
- _iterator.f();
52
- }
53
- if (isLog) {
54
- if (similarPairs.length > 0) {
55
- similarPairs.forEach(function (pair) {
56
- console.log(pair[0]);
57
- console.log(pair[1]);
58
- console.log();
59
- });
60
- } else {
61
- console.log('没有找到类似的字符串');
62
- }
63
- }
64
- return uniqueArray;
65
- };
@@ -1,33 +0,0 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
3
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
6
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
8
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
9
- function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
10
- function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
11
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
- function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
13
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
15
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
17
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
18
- export var CustomError = /*#__PURE__*/function (_Error) {
19
- _inherits(CustomError, _Error);
20
- var _super = _createSuper(CustomError);
21
- function CustomError(message, code, data) {
22
- var _this;
23
- _classCallCheck(this, CustomError);
24
- _this = _super.call(this, message);
25
- _defineProperty(_assertThisInitialized(_this), "code", void 0);
26
- _defineProperty(_assertThisInitialized(_this), "data", void 0);
27
- _this.code = code;
28
- _this.data = data;
29
- Error.captureStackTrace(_assertThisInitialized(_this), _this.constructor);
30
- return _this;
31
- }
32
- return _createClass(CustomError);
33
- }( /*#__PURE__*/_wrapNativeSuper(Error));
@@ -1,19 +0,0 @@
1
- import dayjs from 'dayjs';
2
- import isBetween from 'dayjs/plugin/isBetween';
3
- import updateLocale from 'dayjs/plugin/updateLocale';
4
- import timezone from 'dayjs/plugin/timezone';
5
- import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
6
- import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
7
- import 'dayjs/locale/zh-cn';
8
- export declare enum Timezone {
9
- AsiaShanghai = "Asia/Shanghai"
10
- }
11
- export { Dayjs } from 'dayjs';
12
- declare const _default: typeof dayjs & {
13
- isBetween: typeof isBetween;
14
- isSameOrAfter: typeof isSameOrAfter;
15
- isSameOrBefore: typeof isSameOrBefore;
16
- tz: typeof timezone;
17
- updateLocale: typeof updateLocale;
18
- };
19
- export default _default;
@@ -1,29 +0,0 @@
1
- import dayjs from 'dayjs';
2
- import isBetween from 'dayjs/plugin/isBetween';
3
- import weekday from 'dayjs/plugin/weekday';
4
- import localeData from 'dayjs/plugin/localeData';
5
- import isoWeek from 'dayjs/plugin/isoWeek';
6
- import updateLocale from 'dayjs/plugin/updateLocale';
7
- import timezone from 'dayjs/plugin/timezone';
8
- import isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
9
- import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
10
- import 'dayjs/locale/zh-cn';
11
- dayjs.extend(isBetween);
12
- dayjs.extend(weekday);
13
- dayjs.extend(localeData);
14
- dayjs.extend(isoWeek);
15
- dayjs.extend(updateLocale);
16
- dayjs.extend(timezone);
17
- dayjs.extend(isSameOrAfter);
18
- dayjs.extend(isSameOrBefore);
19
- dayjs.locale('zh-cn');
20
- dayjs.tz.setDefault('Asia/Shanghai');
21
- dayjs.updateLocale('zh-cn', {
22
- weekStart: 1
23
- });
24
- export var Timezone = /*#__PURE__*/function (Timezone) {
25
- Timezone["AsiaShanghai"] = "Asia/Shanghai";
26
- return Timezone;
27
- }({});
28
- export { Dayjs } from 'dayjs';
29
- export default dayjs;
@@ -1,13 +0,0 @@
1
- import { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy, noop } from 'lodash';
2
- export { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy, noop, };
3
- export * as consola from 'consola';
4
- export { default as dayjs, Dayjs, Timezone } from './dayjs';
5
- export * from 'zod';
6
- export * from './string';
7
- export * from './object';
8
- export * from './other';
9
- export * from './number';
10
- export * from './classs';
11
- export * from './array';
12
- export { default as _ } from 'lodash';
13
- export { default as axios } from 'axios';
@@ -1,14 +0,0 @@
1
- import { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy, noop } from 'lodash';
2
- export { cloneDeep, debounce, isBoolean, isEqual, isFunction, isNumber, isObject, isString, merge, omit, pick, uniq, uniqBy, uniqWith, isEmpty, isError, find, groupBy, noop };
3
- import * as _consola from 'consola';
4
- export { _consola as consola };
5
- export { default as dayjs, Dayjs, Timezone } from "./dayjs";
6
- export * from 'zod';
7
- export * from "./string";
8
- export * from "./object";
9
- export * from "./other";
10
- export * from "./number";
11
- export * from "./classs";
12
- export * from "./array";
13
- export { default as _ } from 'lodash';
14
- export { default as axios } from 'axios';