@pisell/utils 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/arrayUtils.d.ts +1 -0
- package/es/constants/index.d.ts +7 -0
- package/es/document.d.ts +13 -0
- package/es/firebase/config/index.d.ts +13 -0
- package/es/firebase/index.d.ts +28 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/jsBridge/index.d.ts +118 -0
- package/es/jsBridge/index.js +12 -28
- package/es/locales.d.ts +12 -0
- package/es/locales.js +1 -0
- package/es/miniRedux.d.ts +16 -0
- package/es/miniRedux.js +2 -7
- package/es/otherUtils.d.ts +48 -0
- package/es/platform.d.ts +9 -0
- package/es/walletValidity.js +499 -0
- package/lib/arrayUtils.d.ts +1 -0
- package/lib/constants/index.d.ts +7 -0
- package/lib/document.d.ts +13 -0
- package/lib/firebase/config/index.d.ts +13 -0
- package/lib/firebase/index.d.ts +28 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/jsBridge/index.d.ts +118 -0
- package/lib/jsBridge/index.js +1 -20
- package/lib/locales.d.ts +12 -0
- package/lib/locales.js +1 -0
- package/lib/miniRedux.d.ts +16 -0
- package/lib/miniRedux.js +7 -5
- package/lib/otherUtils.d.ts +48 -0
- package/lib/platform.d.ts +9 -0
- package/lib/walletValidity.js +349 -0
- package/package.json +5 -5
- package/es/jsBridge/types.js +0 -1
- package/lib/jsBridge/types.js +0 -17
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const uniqueByKey: <T>(arr: T[], key: keyof T) => T[];
|
package/es/document.d.ts
ADDED
|
@@ -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>;
|
|
@@ -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/index.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export * from "./jsBridge";
|
|
|
17
17
|
export * from "./image";
|
|
18
18
|
export * from "./locales";
|
|
19
19
|
export * from "./arrayUtils";
|
|
20
|
+
export * from "./walletValidity";
|
|
20
21
|
// export { default as firebase } from './firebase';
|
|
21
22
|
|
|
22
23
|
export var setPisellUtilsConfig = function setPisellUtilsConfig(config) {
|
|
@@ -0,0 +1,118 @@
|
|
|
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/jsBridge/index.js
CHANGED
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import regDeviceApi from "./regDeviceApi";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 打印小票
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 打印ITS备货单/划菜单
|
|
9
|
+
*/
|
|
10
|
+
|
|
2
11
|
/**
|
|
3
12
|
* webView页面中调用打印机打印
|
|
4
13
|
* 此api暂时只支持native app平台下ios手机
|
|
5
14
|
* @param params
|
|
6
15
|
* @param callback
|
|
7
16
|
*/
|
|
8
|
-
export function webPrint(params, _callback
|
|
17
|
+
export function webPrint(params, _callback) {
|
|
9
18
|
regDeviceApi().then(function (jsBridge) {
|
|
10
19
|
jsBridge.callDeviceApi({
|
|
11
|
-
apiName:
|
|
20
|
+
apiName: "webPrint",
|
|
12
21
|
params: params,
|
|
13
22
|
callback: function callback() {
|
|
14
23
|
_callback && _callback.apply(void 0, arguments);
|
|
15
24
|
}
|
|
16
25
|
});
|
|
17
|
-
}).catch(function (err) {
|
|
18
|
-
onError === null || onError === void 0 || onError(err);
|
|
19
|
-
console.error('webPrint', err);
|
|
20
26
|
});
|
|
21
27
|
}
|
|
22
|
-
|
|
23
28
|
/**
|
|
24
29
|
* webView页面中调用APP内的数据
|
|
25
30
|
* 此api暂时只支持native app平台下ios手机
|
|
@@ -29,32 +34,11 @@ export function webPrint(params, _callback, onError) {
|
|
|
29
34
|
export function dataManager(params, _callback2, onError) {
|
|
30
35
|
regDeviceApi().then(function (jsBridge) {
|
|
31
36
|
jsBridge.callDeviceApi({
|
|
32
|
-
apiName:
|
|
37
|
+
apiName: "dataManager",
|
|
33
38
|
params: params,
|
|
34
39
|
callback: function callback() {
|
|
35
40
|
_callback2 && _callback2.apply(void 0, arguments);
|
|
36
41
|
}
|
|
37
42
|
});
|
|
38
43
|
}).catch(onError);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* webView页面中调用APP内的支付
|
|
43
|
-
* 此api暂时只支持native app平台下ios
|
|
44
|
-
* @param params
|
|
45
|
-
* @param callback
|
|
46
|
-
*/
|
|
47
|
-
export function webPayment(params, _callback3, onError) {
|
|
48
|
-
regDeviceApi().then(function (jsBridge) {
|
|
49
|
-
jsBridge.callDeviceApi({
|
|
50
|
-
apiName: 'webPayment',
|
|
51
|
-
params: params,
|
|
52
|
-
callback: function callback() {
|
|
53
|
-
_callback3 && _callback3.apply(void 0, arguments);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}).catch(function (err) {
|
|
57
|
-
onError === null || onError === void 0 || onError(err);
|
|
58
|
-
console.error('webPayment', err);
|
|
59
|
-
});
|
|
60
44
|
}
|
package/es/locales.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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/locales.js
CHANGED
|
@@ -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 {};
|
package/es/miniRedux.js
CHANGED
|
@@ -10,7 +10,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
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; }
|
|
11
11
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
import React, { createContext, useCallback,
|
|
13
|
+
import React, { createContext, useCallback, useReducer, forwardRef, useRef } from 'react';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
export var miniRedux = function miniRedux(_ref2) {
|
|
16
16
|
var _ref2$namespace = _ref2.namespace,
|
|
@@ -49,11 +49,6 @@ export var miniRedux = function miniRedux(_ref2) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
}, []);
|
|
52
|
-
|
|
53
|
-
// 缓存Context value,避免不必要的重新渲染
|
|
54
|
-
var contextValue = useMemo(function () {
|
|
55
|
-
return _defineProperty(_defineProperty({}, namespace, providerState), "dispatch", _dispatch);
|
|
56
|
-
}, [providerState, _dispatch]);
|
|
57
52
|
var _props = _objectSpread(_objectSpread({}, props), {}, _defineProperty(_defineProperty({}, namespace, providerState), "dispatch", _dispatch));
|
|
58
53
|
var _ref = null;
|
|
59
54
|
if (_props.forwardedRef) {
|
|
@@ -61,7 +56,7 @@ export var miniRedux = function miniRedux(_ref2) {
|
|
|
61
56
|
delete _props.forwardedRef;
|
|
62
57
|
}
|
|
63
58
|
return /*#__PURE__*/_jsx(Context.Provider, {
|
|
64
|
-
value:
|
|
59
|
+
value: _defineProperty(_defineProperty({}, namespace, providerState), "dispatch", _dispatch),
|
|
65
60
|
children: /*#__PURE__*/_jsx(ComponentUi, _objectSpread(_objectSpread({}, _props), {}, {
|
|
66
61
|
ref: ref
|
|
67
62
|
}))
|
|
@@ -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;
|
package/es/platform.d.ts
ADDED
|
@@ -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;
|