@pisell/utils 3.0.0 → 3.0.1

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.
@@ -0,0 +1 @@
1
+ export declare const uniqueByKey: <T>(arr: T[], key: keyof T) => T[];
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @Title: 设置主题
3
+ * @Describe: 传入字符串键值对
4
+ * @Author: Wzw
5
+ */
6
+ export declare const setTheme: (themes: {
7
+ [key: string]: string;
8
+ }) => void;
9
+ /**
10
+ * 复制到剪切板
11
+ * @param text
12
+ */
13
+ export declare const copyToClipboard: (text: string) => Promise<void>;
@@ -1,5 +1,5 @@
1
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
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
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
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
5
  import EscPosPrinter, { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, columnWidthWithAlignment } from "./EscPosPrinter";
@@ -0,0 +1,13 @@
1
+ declare type InjectedConfigType = {
2
+ apiKey: string;
3
+ authDomain: string;
4
+ projectId: string;
5
+ storageBucket: string;
6
+ messagingSenderId: string;
7
+ appId: string;
8
+ databaseURL: string;
9
+ };
10
+ export declare const injectConfig: (context: InjectedConfigType) => void;
11
+ export declare const firebaseConfig: any;
12
+ declare const _default: any;
13
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import { FirebaseApp } from 'firebase/app';
2
+ import { Auth } from 'firebase/auth';
3
+ import { ref, Database, goOnline, goOffline } from 'firebase/database';
4
+ declare let firebaseApp: FirebaseApp;
5
+ declare let auth: Auth;
6
+ declare let database: Database;
7
+ export declare const initFirebase: (config?: any) => void;
8
+ export { database, firebaseApp, auth, ref, goOnline, goOffline };
9
+ export declare const getPath: (path: string) => string;
10
+ export declare const setAuthStateChangeCallback: (callback: (user: any) => void) => void;
11
+ export declare const signUp: (email: string, password: string) => Promise<import("firebase/auth").User>;
12
+ export declare const signInUser: (email: string, password: string) => Promise<import("firebase/auth").User>;
13
+ export declare const signOutUser: () => Promise<void>;
14
+ export declare const readData: (path: string) => Promise<any>;
15
+ export declare const writeData: (path: string, data: any) => Promise<void>;
16
+ export declare const onDataChange: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
17
+ export declare const onDataChanged: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
18
+ export declare const removeDataListener: (listener: any) => void;
19
+ declare const _default: {
20
+ signInUser: (email: string, password: string) => Promise<import("firebase/auth").User>;
21
+ signOutUser: () => Promise<void>;
22
+ readData: (path: string) => Promise<any>;
23
+ writeData: (path: string, data: any) => Promise<void>;
24
+ onDataChange: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
25
+ removeDataListener: (listener: any) => void;
26
+ onDataChanged: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
27
+ };
28
+ export default _default;
package/es/format.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @title: 格式化金额
3
+ * @description:
4
+ * @param {number} amount 原金额
5
+ * @param {number} precision 小数位数
6
+ * @param {string} symbol 货币符号
7
+ * @return {*}
8
+ * @Author: zhiwei.Wang
9
+ * @Date: 2023-11-06 16:51
10
+ */
11
+ export declare const formatAmount: (amount?: number | string, precision?: number, symbol?: string) => string | number;
12
+ export declare type FormatOptions = {
13
+ /** 小数点后位数 默认是小数点后2位 */
14
+ precision?: number;
15
+ /** 显示货币符号 指的是 ¥$ 等货币符号等显隐,默认是展示 */
16
+ showCurrencySymbol?: boolean;
17
+ /** 千分位 指的是长金额的千分位逗号隔开,比如“123, 245, 315” 这种展现形式,默认是关闭 */
18
+ useThousandsSeparator?: boolean;
19
+ /** 整数位隐藏小数 指的是如果价格为整数,后面的".00" 将被省略以节省页面空间 */
20
+ hideDecimalForWholeNumbers?: boolean;
21
+ };
22
+ /**
23
+ * 根据配置格式化金额
24
+ * @param amount
25
+ * @param symbol
26
+ * @param options
27
+ */
28
+ export declare const formatAmountWithOptions: (amount: string | number | undefined, symbol: string | undefined, options: FormatOptions) => string | number;
@@ -0,0 +1,16 @@
1
+ interface MiniReduxProps<State, Namespace> {
2
+ namespace?: Namespace;
3
+ state?: State;
4
+ reducers?: any;
5
+ effects?: any;
6
+ }
7
+ export declare const miniRedux: <State extends Record<string, any>, Namespace extends string>({ namespace, state, reducers, effects, }: MiniReduxProps<State, Namespace>) => {
8
+ Context: React.Context<{ [K in Namespace]: State; } & {
9
+ dispatch: (params: {
10
+ type: string;
11
+ payload: any;
12
+ }) => void;
13
+ }>;
14
+ Provider: (ComponentUi: any) => any;
15
+ };
16
+ export {};
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @title: 判断是否无痕模式
3
+ * @description:
4
+ * @return: *
5
+ * @Author: shengjie.zuo
6
+ * @Date: 2024-09-4 09:58:22
7
+ */
8
+ export declare const detectIncognito: () => Promise<{
9
+ isPrivate: boolean;
10
+ browserName: string;
11
+ } | {
12
+ isPrivate: boolean;
13
+ }>;
14
+ /**
15
+ * @Description: 生成唯一id
16
+ * @Author: wzw
17
+ * @Date: 2020-12-01 14:20:29
18
+ * @param {*}
19
+ * @return {*}
20
+ */
21
+ export declare const getUniqueId: (prefix?: string, maxLength?: number) => string;
22
+ /**
23
+ * @title: 对数组进行增|删
24
+ * @description: 用于多选选中和取消选中的处理
25
+ * @param {any} list
26
+ * @param {any} item
27
+ * @param {string} key
28
+ * @return {*}
29
+ * @Author: zhiwei.Wang
30
+ * @Date: 2023-12-19 16:44
31
+ */
32
+ export declare const changeArray: <T>(list: T[] | undefined, item: T, key?: string) => T[];
33
+ /**
34
+ * @title: 判断某个字段是否在列表内
35
+ * @description:
36
+ * @param {*} T
37
+ * @param {boolean} param2
38
+ * @return {*}
39
+ * @Author: zhiwei.Wang
40
+ * @Date: 2023-12-19 16:54
41
+ */
42
+ export declare const getItemByArray: <T>(list: T[] | undefined, item: T, key?: string) => boolean;
43
+ export declare const createArray: (length: number, returnItem: any) => unknown[];
44
+ /**
45
+ * 根据对象内容生成唯一id
46
+ * @param obj
47
+ */
48
+ export declare const generateUniqueIdByObj: (obj: Record<string, any>) => any;
@@ -0,0 +1,9 @@
1
+ export declare const isIpad: () => boolean;
2
+ export declare const isMobile: () => boolean;
3
+ export declare const isAndroid: () => boolean;
4
+ export declare const isIos: () => boolean;
5
+ export declare const checkEnv: () => number;
6
+ export declare const isWx: () => boolean;
7
+ export declare const isIOS: () => boolean;
8
+ export declare const isWxApp: () => boolean;
9
+ export declare const isSafari: () => boolean;
@@ -0,0 +1 @@
1
+ export declare const uniqueByKey: <T>(arr: T[], key: keyof T) => T[];
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @Title: 设置主题
3
+ * @Describe: 传入字符串键值对
4
+ * @Author: Wzw
5
+ */
6
+ export declare const setTheme: (themes: {
7
+ [key: string]: string;
8
+ }) => void;
9
+ /**
10
+ * 复制到剪切板
11
+ * @param text
12
+ */
13
+ export declare const copyToClipboard: (text: string) => Promise<void>;
@@ -48,15 +48,18 @@ function _numToHexStr(n, bytes) {
48
48
  var v;
49
49
  for (var i = 0; i < bytes; i++) {
50
50
  v = n & 255;
51
- if (v < 16) str += "0" + v.toString(16);
52
- else str += v.toString(16);
51
+ if (v < 16)
52
+ str += "0" + v.toString(16);
53
+ else
54
+ str += v.toString(16);
53
55
  n >>= 8;
54
56
  }
55
57
  return str;
56
58
  }
57
59
  function _unicodeToUtf8(unicode) {
58
60
  var c1, c2, c3, c4;
59
- if (unicode < 0) return "";
61
+ if (unicode < 0)
62
+ return "";
60
63
  if (unicode <= 127) {
61
64
  c1 = unicode & 127;
62
65
  return _numToHexStr(c1, 1);
@@ -130,7 +133,8 @@ EscPosPrinter.prototype.appendText = function(str) {
130
133
  this.orderData += _unicodeToUtf8(str.charCodeAt(i));
131
134
  };
132
135
  EscPosPrinter.prototype.lineFeed = function(n) {
133
- for (var i = 0; i < n; i++) this.orderData += "0a";
136
+ for (var i = 0; i < n; i++)
137
+ this.orderData += "0a";
134
138
  };
135
139
  EscPosPrinter.prototype.restoreDefaultSettings = function() {
136
140
  this.charHSize = 1;
@@ -140,19 +144,24 @@ EscPosPrinter.prototype.restoreDefaultLineSpacing = function() {
140
144
  this.orderData += "1b32";
141
145
  };
142
146
  EscPosPrinter.prototype.setLineSpacing = function(n) {
143
- if (n >= 0 && n <= 255) this.orderData += "1b33" + _numToHexStr(n, 1);
147
+ if (n >= 0 && n <= 255)
148
+ this.orderData += "1b33" + _numToHexStr(n, 1);
144
149
  };
145
150
  EscPosPrinter.prototype.setPrintModes = function(bold, double_h, double_w) {
146
151
  var n = 0;
147
- if (bold) n |= 8;
148
- if (double_h) n |= 16;
149
- if (double_w) n |= 32;
152
+ if (bold)
153
+ n |= 8;
154
+ if (double_h)
155
+ n |= 16;
156
+ if (double_w)
157
+ n |= 32;
150
158
  this.charHSize = double_w ? 2 : 1;
151
159
  this.orderData += "1b21" + _numToHexStr(n, 1);
152
160
  };
153
161
  EscPosPrinter.prototype.setCharacterSize = function(h, w) {
154
162
  var n = 0;
155
- if (h >= 1 && h <= 8) n |= h - 1;
163
+ if (h >= 1 && h <= 8)
164
+ n |= h - 1;
156
165
  if (w >= 1 && w <= 8) {
157
166
  n |= w - 1 << 4;
158
167
  this.charHSize = w;
@@ -160,16 +169,20 @@ EscPosPrinter.prototype.setCharacterSize = function(h, w) {
160
169
  this.orderData += "1d21" + _numToHexStr(n, 1);
161
170
  };
162
171
  EscPosPrinter.prototype.horizontalTab = function(n) {
163
- for (var i = 0; i < n; i++) this.orderData += "09";
172
+ for (var i = 0; i < n; i++)
173
+ this.orderData += "09";
164
174
  };
165
175
  EscPosPrinter.prototype.setAbsolutePrintPosition = function(n) {
166
- if (n >= 0 && n <= 65535) this.orderData += "1b24" + _numToHexStr(n, 2);
176
+ if (n >= 0 && n <= 65535)
177
+ this.orderData += "1b24" + _numToHexStr(n, 2);
167
178
  };
168
179
  EscPosPrinter.prototype.setRelativePrintPosition = function(n) {
169
- if (n >= -32768 && n <= 32767) this.orderData += "1b5c" + _numToHexStr(n, 2);
180
+ if (n >= -32768 && n <= 32767)
181
+ this.orderData += "1b5c" + _numToHexStr(n, 2);
170
182
  };
171
183
  EscPosPrinter.prototype.setAlignment = function(n) {
172
- if (n >= 0 && n <= 2) this.orderData += "1b61" + _numToHexStr(n, 1);
184
+ if (n >= 0 && n <= 2)
185
+ this.orderData += "1b61" + _numToHexStr(n, 1);
173
186
  };
174
187
  EscPosPrinter.prototype.cutPaper = function(fullCut) {
175
188
  this.orderData += "1d56" + (fullCut ? "30" : "31");
@@ -200,8 +213,10 @@ function _columnAlignment(v) {
200
213
  }
201
214
  EscPosPrinter.prototype.setColumnWidths = function() {
202
215
  var i, remain, width, alignment;
203
- if (arguments.length == 0) return;
204
- for (i = 0; i < MAX_COLUMNS; i++) this.widthOfColumns[i] = 0;
216
+ if (arguments.length == 0)
217
+ return;
218
+ for (i = 0; i < MAX_COLUMNS; i++)
219
+ this.widthOfColumns[i] = 0;
205
220
  remain = this.dotsPerLine;
206
221
  for (i = 0; i < arguments.length; i++) {
207
222
  if (i == MAX_COLUMNS)
@@ -222,10 +237,12 @@ EscPosPrinter.prototype.printInColumns = function() {
222
237
  var strwidth = new Array(MAX_COLUMNS);
223
238
  var i, j, c, w, columns, width, alignment, pos;
224
239
  var done;
225
- if (arguments.length == 0) return;
240
+ if (arguments.length == 0)
241
+ return;
226
242
  columns = 0;
227
243
  for (i = 0; i < arguments.length; i++) {
228
- if (i == MAX_COLUMNS || this.widthOfColumns[i] == 0) break;
244
+ if (i == MAX_COLUMNS || this.widthOfColumns[i] == 0)
245
+ break;
229
246
  strcurr[i] = "";
230
247
  strrem[i] = arguments[i];
231
248
  columns++;
@@ -262,8 +279,10 @@ EscPosPrinter.prototype.printInColumns = function() {
262
279
  }
263
280
  }
264
281
  }
265
- if (j < strrem[i].length) strrem[i] = strrem[i].substring(j);
266
- else strrem[i] = "";
282
+ if (j < strrem[i].length)
283
+ strrem[i] = strrem[i].substring(j);
284
+ else
285
+ strrem[i] = "";
267
286
  alignment = _columnAlignment(this.widthOfColumns[i]);
268
287
  switch (alignment) {
269
288
  case ALIGN_CENTER:
@@ -279,17 +298,24 @@ EscPosPrinter.prototype.printInColumns = function() {
279
298
  this.appendText(strcurr[i]);
280
299
  pos += width;
281
300
  }
282
- if (!done) this.lineFeed(1);
301
+ if (!done)
302
+ this.lineFeed(1);
283
303
  } while (!done);
284
304
  };
285
305
  EscPosPrinter.prototype.appendBarcode = function(hri_pos, height, module_size, barcode_type, text) {
286
306
  var text_length = text.length;
287
- if (text_length == 0) return;
288
- if (text_length > 255) text_length = 255;
289
- if (height < 1) height = 1;
290
- else if (height > 255) height = 255;
291
- if (module_size < 1) module_size = 1;
292
- else if (module_size > 6) module_size = 6;
307
+ if (text_length == 0)
308
+ return;
309
+ if (text_length > 255)
310
+ text_length = 255;
311
+ if (height < 1)
312
+ height = 1;
313
+ else if (height > 255)
314
+ height = 255;
315
+ if (module_size < 1)
316
+ module_size = 1;
317
+ else if (module_size > 6)
318
+ module_size = 6;
293
319
  this.orderData += "1d48" + _numToHexStr(hri_pos & 3, 1);
294
320
  this.orderData += "1d6600";
295
321
  this.orderData += "1d68" + _numToHexStr(height, 1);
@@ -300,12 +326,18 @@ EscPosPrinter.prototype.appendBarcode = function(hri_pos, height, module_size, b
300
326
  };
301
327
  EscPosPrinter.prototype.appendQRcode = function(module_size, ec_level, text) {
302
328
  var text_length = text.length;
303
- if (text_length == 0) return;
304
- if (text_length > 65535) text_length = 65535;
305
- if (module_size < 1) module_size = 1;
306
- else if (module_size > 16) module_size = 16;
307
- if (ec_level < 0) ec_level = 0;
308
- else if (ec_level > 3) ec_level = 3;
329
+ if (text_length == 0)
330
+ return;
331
+ if (text_length > 65535)
332
+ text_length = 65535;
333
+ if (module_size < 1)
334
+ module_size = 1;
335
+ else if (module_size > 16)
336
+ module_size = 16;
337
+ if (ec_level < 0)
338
+ ec_level = 0;
339
+ else if (ec_level > 3)
340
+ ec_level = 3;
309
341
  this.orderData += "1d286b040031410000";
310
342
  this.orderData += "1d286b03003143" + _numToHexStr(module_size, 1);
311
343
  this.orderData += "1d286b03003145" + _numToHexStr(ec_level + 48, 1);
@@ -315,8 +347,10 @@ EscPosPrinter.prototype.appendQRcode = function(module_size, ec_level, text) {
315
347
  this.orderData += "1d286b0300315130";
316
348
  };
317
349
  function _diffuseDither(src_data, width, height) {
318
- if (width <= 0 || height <= 0) return null;
319
- if (src_data.length < width * height) return null;
350
+ if (width <= 0 || height <= 0)
351
+ return null;
352
+ if (src_data.length < width * height)
353
+ return null;
320
354
  var bmwidth = width + 7 >> 3;
321
355
  var dst_data = new Array(bmwidth * height);
322
356
  var line_buffer = new Array(2 * width);
@@ -370,11 +404,14 @@ function _diffuseDither(src_data, width, height) {
370
404
  e5 = err * 5 + 8 >> 4;
371
405
  e3 = err * 3 + 8 >> 4;
372
406
  e1 = err - (e7 + e5 + e3);
373
- if (x < width) line_buffer[line1 * width + b1] += e7;
407
+ if (x < width)
408
+ line_buffer[line1 * width + b1] += e7;
374
409
  if (not_last_line) {
375
410
  line_buffer[line2 * width + b2] += e5;
376
- if (x > 1) line_buffer[line2 * width + b2 - 1] += e3;
377
- if (x < width) line_buffer[line2 * width + b2 + 1] += e1;
411
+ if (x > 1)
412
+ line_buffer[line2 * width + b2 - 1] += e3;
413
+ if (x < width)
414
+ line_buffer[line2 * width + b2 + 1] += e1;
378
415
  }
379
416
  b2++;
380
417
  }
@@ -382,8 +419,10 @@ function _diffuseDither(src_data, width, height) {
382
419
  return dst_data;
383
420
  }
384
421
  function _thresholdDither(src_data, width, height) {
385
- if (width <= 0 || height <= 0) return null;
386
- if (src_data.length < width * height) return null;
422
+ if (width <= 0 || height <= 0)
423
+ return null;
424
+ if (src_data.length < width * height)
425
+ return null;
387
426
  var bmwidth = width + 7 >> 3;
388
427
  var dst_data = new Array(bmwidth * height);
389
428
  var p, q, k, x, y, mask;
@@ -427,7 +466,8 @@ EscPosPrinter.prototype.appendImage = function(imgdata, dither) {
427
466
  var w = imgdata.width;
428
467
  var h = imgdata.height;
429
468
  gray_data = _convertToGray(imgdata, w, h);
430
- if (dither == "diffuse") mono_data = _diffuseDither(gray_data, w, h);
469
+ if (dither == "diffuse")
470
+ mono_data = _diffuseDither(gray_data, w, h);
431
471
  else
432
472
  mono_data = _thresholdDither(gray_data, w, h);
433
473
  w = w + 7 >> 3;
@@ -448,13 +488,16 @@ EscPosPrinter.prototype.setPrintAreaInPageMode = function(x, y, w, h) {
448
488
  this.orderData += _numToHexStr(h, 2);
449
489
  };
450
490
  EscPosPrinter.prototype.setPrintDirectionInPageMode = function(dir) {
451
- if (dir >= 0 && dir <= 3) this.orderData += "1b54" + _numToHexStr(dir, 1);
491
+ if (dir >= 0 && dir <= 3)
492
+ this.orderData += "1b54" + _numToHexStr(dir, 1);
452
493
  };
453
494
  EscPosPrinter.prototype.setAbsolutePrintPositionInPageMode = function(n) {
454
- if (n >= 0 && n <= 65535) this.orderData += "1d24" + _numToHexStr(n, 2);
495
+ if (n >= 0 && n <= 65535)
496
+ this.orderData += "1d24" + _numToHexStr(n, 2);
455
497
  };
456
498
  EscPosPrinter.prototype.setRelativePrintPositionInPageMode = function(n) {
457
- if (n >= -32768 && n <= 32767) this.orderData += "1d5c" + _numToHexStr(n, 2);
499
+ if (n >= -32768 && n <= 32767)
500
+ this.orderData += "1d5c" + _numToHexStr(n, 2);
458
501
  };
459
502
  EscPosPrinter.prototype.printAndExitPageMode = function() {
460
503
  this.orderData += "0c";
@@ -49,7 +49,7 @@ var preparing = async (ip, sn, params) => {
49
49
  printer.lineFeed(1);
50
50
  printer.setPrintModes(false, false, false);
51
51
  printer.setAlignment(import_EscPosPrinter.ALIGN_CENTER);
52
- printer.appendText("打印测试\n");
52
+ printer.appendText("\u6253\u5370\u6D4B\u8BD5\n");
53
53
  dividing(printer);
54
54
  printer.setAlignment(import_EscPosPrinter.ALIGN_LEFT);
55
55
  printer.appendText("Order time: 2023-10-19 14:15:50\n");
@@ -64,7 +64,7 @@ var preparing = async (ip, sn, params) => {
64
64
  printer.setPrintModes(true, true, true);
65
65
  printer.printInColumns(
66
66
  "1 x",
67
- "我是很长的商品名称我是很长的商品名称我是很长的商品名称我是很长的商品名称"
67
+ "\u6211\u662F\u5F88\u957F\u7684\u5546\u54C1\u540D\u79F0\u6211\u662F\u5F88\u957F\u7684\u5546\u54C1\u540D\u79F0\u6211\u662F\u5F88\u957F\u7684\u5546\u54C1\u540D\u79F0\u6211\u662F\u5F88\u957F\u7684\u5546\u54C1\u540D\u79F0"
68
68
  );
69
69
  printer.setPrintModes(false, false, false);
70
70
  dividing(printer);
@@ -0,0 +1,13 @@
1
+ declare type InjectedConfigType = {
2
+ apiKey: string;
3
+ authDomain: string;
4
+ projectId: string;
5
+ storageBucket: string;
6
+ messagingSenderId: string;
7
+ appId: string;
8
+ databaseURL: string;
9
+ };
10
+ export declare const injectConfig: (context: InjectedConfigType) => void;
11
+ export declare const firebaseConfig: any;
12
+ declare const _default: any;
13
+ export default _default;
@@ -0,0 +1,28 @@
1
+ import { FirebaseApp } from 'firebase/app';
2
+ import { Auth } from 'firebase/auth';
3
+ import { ref, Database, goOnline, goOffline } from 'firebase/database';
4
+ declare let firebaseApp: FirebaseApp;
5
+ declare let auth: Auth;
6
+ declare let database: Database;
7
+ export declare const initFirebase: (config?: any) => void;
8
+ export { database, firebaseApp, auth, ref, goOnline, goOffline };
9
+ export declare const getPath: (path: string) => string;
10
+ export declare const setAuthStateChangeCallback: (callback: (user: any) => void) => void;
11
+ export declare const signUp: (email: string, password: string) => Promise<import("firebase/auth").User>;
12
+ export declare const signInUser: (email: string, password: string) => Promise<import("firebase/auth").User>;
13
+ export declare const signOutUser: () => Promise<void>;
14
+ export declare const readData: (path: string) => Promise<any>;
15
+ export declare const writeData: (path: string, data: any) => Promise<void>;
16
+ export declare const onDataChange: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
17
+ export declare const onDataChanged: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
18
+ export declare const removeDataListener: (listener: any) => void;
19
+ declare const _default: {
20
+ signInUser: (email: string, password: string) => Promise<import("firebase/auth").User>;
21
+ signOutUser: () => Promise<void>;
22
+ readData: (path: string) => Promise<any>;
23
+ writeData: (path: string, data: any) => Promise<void>;
24
+ onDataChange: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
25
+ removeDataListener: (listener: any) => void;
26
+ onDataChanged: (path: string, callback: (snapshot: any) => void) => import("firebase/database").Unsubscribe;
27
+ };
28
+ export default _default;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @title: 格式化金额
3
+ * @description:
4
+ * @param {number} amount 原金额
5
+ * @param {number} precision 小数位数
6
+ * @param {string} symbol 货币符号
7
+ * @return {*}
8
+ * @Author: zhiwei.Wang
9
+ * @Date: 2023-11-06 16:51
10
+ */
11
+ export declare const formatAmount: (amount?: number | string, precision?: number, symbol?: string) => string | number;
12
+ export declare type FormatOptions = {
13
+ /** 小数点后位数 默认是小数点后2位 */
14
+ precision?: number;
15
+ /** 显示货币符号 指的是 ¥$ 等货币符号等显隐,默认是展示 */
16
+ showCurrencySymbol?: boolean;
17
+ /** 千分位 指的是长金额的千分位逗号隔开,比如“123, 245, 315” 这种展现形式,默认是关闭 */
18
+ useThousandsSeparator?: boolean;
19
+ /** 整数位隐藏小数 指的是如果价格为整数,后面的".00" 将被省略以节省页面空间 */
20
+ hideDecimalForWholeNumbers?: boolean;
21
+ };
22
+ /**
23
+ * 根据配置格式化金额
24
+ * @param amount
25
+ * @param symbol
26
+ * @param options
27
+ */
28
+ export declare const formatAmountWithOptions: (amount: string | number | undefined, symbol: string | undefined, options: FormatOptions) => string | number;
package/lib/image.js CHANGED
@@ -48,7 +48,8 @@ var getImageSize = (url) => {
48
48
  success: false,
49
49
  originRatio: 1
50
50
  };
51
- if (typeof url !== "string") return size;
51
+ if (typeof url !== "string")
52
+ return size;
52
53
  try {
53
54
  let arr = url.split("__");
54
55
  if (arr[1]) {
@@ -0,0 +1,16 @@
1
+ interface MiniReduxProps<State, Namespace> {
2
+ namespace?: Namespace;
3
+ state?: State;
4
+ reducers?: any;
5
+ effects?: any;
6
+ }
7
+ export declare const miniRedux: <State extends Record<string, any>, Namespace extends string>({ namespace, state, reducers, effects, }: MiniReduxProps<State, Namespace>) => {
8
+ Context: React.Context<{ [K in Namespace]: State; } & {
9
+ dispatch: (params: {
10
+ type: string;
11
+ payload: any;
12
+ }) => void;
13
+ }>;
14
+ Provider: (ComponentUi: any) => any;
15
+ };
16
+ export {};
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @title: 判断是否无痕模式
3
+ * @description:
4
+ * @return: *
5
+ * @Author: shengjie.zuo
6
+ * @Date: 2024-09-4 09:58:22
7
+ */
8
+ export declare const detectIncognito: () => Promise<{
9
+ isPrivate: boolean;
10
+ browserName: string;
11
+ } | {
12
+ isPrivate: boolean;
13
+ }>;
14
+ /**
15
+ * @Description: 生成唯一id
16
+ * @Author: wzw
17
+ * @Date: 2020-12-01 14:20:29
18
+ * @param {*}
19
+ * @return {*}
20
+ */
21
+ export declare const getUniqueId: (prefix?: string, maxLength?: number) => string;
22
+ /**
23
+ * @title: 对数组进行增|删
24
+ * @description: 用于多选选中和取消选中的处理
25
+ * @param {any} list
26
+ * @param {any} item
27
+ * @param {string} key
28
+ * @return {*}
29
+ * @Author: zhiwei.Wang
30
+ * @Date: 2023-12-19 16:44
31
+ */
32
+ export declare const changeArray: <T>(list: T[] | undefined, item: T, key?: string) => T[];
33
+ /**
34
+ * @title: 判断某个字段是否在列表内
35
+ * @description:
36
+ * @param {*} T
37
+ * @param {boolean} param2
38
+ * @return {*}
39
+ * @Author: zhiwei.Wang
40
+ * @Date: 2023-12-19 16:54
41
+ */
42
+ export declare const getItemByArray: <T>(list: T[] | undefined, item: T, key?: string) => boolean;
43
+ export declare const createArray: (length: number, returnItem: any) => unknown[];
44
+ /**
45
+ * 根据对象内容生成唯一id
46
+ * @param obj
47
+ */
48
+ export declare const generateUniqueIdByObj: (obj: Record<string, any>) => any;
@@ -0,0 +1,9 @@
1
+ export declare const isIpad: () => boolean;
2
+ export declare const isMobile: () => boolean;
3
+ export declare const isAndroid: () => boolean;
4
+ export declare const isIos: () => boolean;
5
+ export declare const checkEnv: () => number;
6
+ export declare const isWx: () => boolean;
7
+ export declare const isIOS: () => boolean;
8
+ export declare const isWxApp: () => boolean;
9
+ export declare const isSafari: () => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/utils",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "sideEffects": false,
5
5
  "main": "./lib/index.js",
6
6
  "module": "./es/index.js",
package/es/index.d.ts DELETED
@@ -1,19 +0,0 @@
1
- export * from './otherUtils';
2
- export * from './typeUtils';
3
- export * from './document';
4
- export * from './date';
5
- export * from './platform';
6
- export * from './log';
7
- export * from './format';
8
- export * from './escPosPrinter';
9
- export * from './miniRedux';
10
- export * from './jsBridge';
11
- export * from './image';
12
- export * from './locales';
13
- export * from './arrayUtils';
14
- export declare const setPisellUtilsConfig: (config: {
15
- [key: string]: any;
16
- }) => void;
17
- export declare const getPisellUtilsConfig: () => {
18
- [key: string]: any;
19
- };
@@ -1,118 +0,0 @@
1
- declare type LanguageNumber = {
2
- en: number;
3
- zh_CN: number;
4
- zh_HK: number;
5
- };
6
- declare type LanguageString = {
7
- en: string;
8
- zh_CN: string;
9
- zh_HK: string;
10
- } | string;
11
- /**
12
- * 打印小票
13
- */
14
- declare type WebPrint0 = {
15
- /**
16
- * 打印类型
17
- * 0: 小票
18
- * 1:ITS备货单/划菜单
19
- * 2:手环
20
- */
21
- type: "0";
22
- data: {
23
- /** 订单ID */
24
- order_id: string;
25
- };
26
- /** 打印语言对应的数量 */
27
- language: LanguageNumber;
28
- };
29
- /**
30
- * 打印ITS备货单/划菜单
31
- */
32
- declare type WebPrint1 = {
33
- /**
34
- * 打印类型
35
- * 0: 小票
36
- * 1:ITS备货单/划菜单
37
- * 2:手环
38
- */
39
- type: "1";
40
- data: {
41
- /** 0:备货 1:划单 */
42
- mode: "0" | "1";
43
- resource: LanguageString;
44
- /** 订单备注 */
45
- order_note: string;
46
- /** 订单时间或商品下单时间 */
47
- time: string;
48
- /** 订单编号 */
49
- order_number?: string;
50
- /** 商品 */
51
- products: {
52
- /** 商品名称 */
53
- product_title: LanguageString;
54
- /** 商品规格 */
55
- product_option_string: LanguageString;
56
- /** 商品备注 */
57
- product_note: string;
58
- /** 商品数量 */
59
- product_quantity: number;
60
- /** 加菜标识 待定 */
61
- is_append?: boolean;
62
- /** 退菜标识 待定 */
63
- is_removed?: boolean;
64
- }[];
65
- };
66
- /** 打印语言对应的数量 */
67
- language: LanguageNumber;
68
- };
69
- declare type WebPrint2 = {
70
- /**
71
- * 打印类型
72
- * 0: 小票
73
- * 1:ITS备货单/划菜单
74
- * 2:手环
75
- */
76
- type: "2";
77
- data: {
78
- /** 0: 普通票 1:成人票 2:免费成人票 */
79
- type: "0" | "1" | "2";
80
- /** 发行编码 */
81
- encoded: string;
82
- /** 编码 */
83
- code: string;
84
- /** 到期时间 */
85
- expire_date: string;
86
- areas: {
87
- /** 区域名字 */
88
- area_name: string;
89
- /** 区域代码 */
90
- area_code: string;
91
- /** 可用次数 */
92
- limit_num: number;
93
- /** 已用次数 */
94
- used_num: number;
95
- }[];
96
- };
97
- };
98
- declare type WebPrintParams = WebPrint0 | WebPrint1 | WebPrint2;
99
- /**
100
- * webView页面中调用打印机打印
101
- * 此api暂时只支持native app平台下ios手机
102
- * @param params
103
- * @param callback
104
- */
105
- export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void): void;
106
- declare type DataManagerParams = {
107
- module: "set" | "get";
108
- key: string;
109
- data?: any;
110
- };
111
- /**
112
- * webView页面中调用APP内的数据
113
- * 此api暂时只支持native app平台下ios手机
114
- * @param params
115
- * @param callback
116
- */
117
- export declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
118
- export {};
package/es/locales.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export declare const locales: {
2
- init: (_localeMaps: any, _locale: string) => void;
3
- getText: (id: string) => any;
4
- locale: string;
5
- localeMap: any;
6
- localeMaps: {
7
- en: {};
8
- 'zh-CN': {};
9
- 'zh-HK': {};
10
- };
11
- formatLocale: (_locale: string) => string;
12
- };
package/es/log.d.ts DELETED
@@ -1,10 +0,0 @@
1
- interface contentItem {
2
- key: string;
3
- value: string;
4
- }
5
- interface sendWebhookProps {
6
- title: string;
7
- content: contentItem[];
8
- }
9
- export declare const sendWarningLog: ({ title, content }: sendWebhookProps) => Promise<any>;
10
- export {};
package/lib/index.d.ts DELETED
@@ -1,19 +0,0 @@
1
- export * from './otherUtils';
2
- export * from './typeUtils';
3
- export * from './document';
4
- export * from './date';
5
- export * from './platform';
6
- export * from './log';
7
- export * from './format';
8
- export * from './escPosPrinter';
9
- export * from './miniRedux';
10
- export * from './jsBridge';
11
- export * from './image';
12
- export * from './locales';
13
- export * from './arrayUtils';
14
- export declare const setPisellUtilsConfig: (config: {
15
- [key: string]: any;
16
- }) => void;
17
- export declare const getPisellUtilsConfig: () => {
18
- [key: string]: any;
19
- };
@@ -1,118 +0,0 @@
1
- declare type LanguageNumber = {
2
- en: number;
3
- zh_CN: number;
4
- zh_HK: number;
5
- };
6
- declare type LanguageString = {
7
- en: string;
8
- zh_CN: string;
9
- zh_HK: string;
10
- } | string;
11
- /**
12
- * 打印小票
13
- */
14
- declare type WebPrint0 = {
15
- /**
16
- * 打印类型
17
- * 0: 小票
18
- * 1:ITS备货单/划菜单
19
- * 2:手环
20
- */
21
- type: "0";
22
- data: {
23
- /** 订单ID */
24
- order_id: string;
25
- };
26
- /** 打印语言对应的数量 */
27
- language: LanguageNumber;
28
- };
29
- /**
30
- * 打印ITS备货单/划菜单
31
- */
32
- declare type WebPrint1 = {
33
- /**
34
- * 打印类型
35
- * 0: 小票
36
- * 1:ITS备货单/划菜单
37
- * 2:手环
38
- */
39
- type: "1";
40
- data: {
41
- /** 0:备货 1:划单 */
42
- mode: "0" | "1";
43
- resource: LanguageString;
44
- /** 订单备注 */
45
- order_note: string;
46
- /** 订单时间或商品下单时间 */
47
- time: string;
48
- /** 订单编号 */
49
- order_number?: string;
50
- /** 商品 */
51
- products: {
52
- /** 商品名称 */
53
- product_title: LanguageString;
54
- /** 商品规格 */
55
- product_option_string: LanguageString;
56
- /** 商品备注 */
57
- product_note: string;
58
- /** 商品数量 */
59
- product_quantity: number;
60
- /** 加菜标识 待定 */
61
- is_append?: boolean;
62
- /** 退菜标识 待定 */
63
- is_removed?: boolean;
64
- }[];
65
- };
66
- /** 打印语言对应的数量 */
67
- language: LanguageNumber;
68
- };
69
- declare type WebPrint2 = {
70
- /**
71
- * 打印类型
72
- * 0: 小票
73
- * 1:ITS备货单/划菜单
74
- * 2:手环
75
- */
76
- type: "2";
77
- data: {
78
- /** 0: 普通票 1:成人票 2:免费成人票 */
79
- type: "0" | "1" | "2";
80
- /** 发行编码 */
81
- encoded: string;
82
- /** 编码 */
83
- code: string;
84
- /** 到期时间 */
85
- expire_date: string;
86
- areas: {
87
- /** 区域名字 */
88
- area_name: string;
89
- /** 区域代码 */
90
- area_code: string;
91
- /** 可用次数 */
92
- limit_num: number;
93
- /** 已用次数 */
94
- used_num: number;
95
- }[];
96
- };
97
- };
98
- declare type WebPrintParams = WebPrint0 | WebPrint1 | WebPrint2;
99
- /**
100
- * webView页面中调用打印机打印
101
- * 此api暂时只支持native app平台下ios手机
102
- * @param params
103
- * @param callback
104
- */
105
- export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void): void;
106
- declare type DataManagerParams = {
107
- module: "set" | "get";
108
- key: string;
109
- data?: any;
110
- };
111
- /**
112
- * webView页面中调用APP内的数据
113
- * 此api暂时只支持native app平台下ios手机
114
- * @param params
115
- * @param callback
116
- */
117
- export declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
118
- export {};
package/lib/locales.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export declare const locales: {
2
- init: (_localeMaps: any, _locale: string) => void;
3
- getText: (id: string) => any;
4
- locale: string;
5
- localeMap: any;
6
- localeMaps: {
7
- en: {};
8
- 'zh-CN': {};
9
- 'zh-HK': {};
10
- };
11
- formatLocale: (_locale: string) => string;
12
- };
package/lib/log.d.ts DELETED
@@ -1,10 +0,0 @@
1
- interface contentItem {
2
- key: string;
3
- value: string;
4
- }
5
- interface sendWebhookProps {
6
- title: string;
7
- content: contentItem[];
8
- }
9
- export declare const sendWarningLog: ({ title, content }: sendWebhookProps) => Promise<any>;
10
- export {};