@pisell/utils 3.0.6 → 3.0.7
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 +23 -26
- package/es/arrayUtils.js +157 -97
- package/es/common/index.d.ts +5 -0
- package/es/common/index.js +5 -0
- package/es/common/stateHelper.d.ts +2 -6
- package/es/common/stateHelper.js +24 -22
- package/es/common/types.d.ts +10 -13
- package/es/common/types.js +1 -0
- package/es/componentStorage.d.ts +25 -27
- package/es/componentStorage.js +130 -94
- package/es/constants/index.js +9 -7
- package/es/date.js +53 -36
- package/es/document.js +67 -43
- package/es/escPosPrinter/EscPosPrinter.js +490 -353
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +52 -37
- package/es/firebase/config/index.js +54 -0
- package/es/firebase/index.js +232 -0
- package/es/format.d.ts +15 -12
- package/es/format.js +156 -89
- package/es/image.js +60 -48
- package/es/index.d.ts +24 -39
- package/es/index.js +35 -40
- package/es/jsBridge/index.d.ts +4 -8
- package/es/jsBridge/index.js +55 -56
- package/es/jsBridge/regDeviceApi.js +126 -87
- package/es/jsBridge/types.d.ts +115 -95
- package/es/jsBridge/types.js +1 -0
- package/es/locales.d.ts +8 -11
- package/es/locales.js +96 -77
- package/es/log.d.ts +6 -11
- package/es/log.js +59 -37
- package/es/miniRedux.d.ts +13 -20
- package/es/miniRedux.js +76 -42
- package/es/number-input/hooks/index.d.ts +4 -0
- package/es/number-input/hooks/index.js +5 -0
- package/es/number-input/hooks/useNumberInputState.d.ts +2 -6
- package/es/number-input/hooks/useNumberInputState.js +128 -71
- package/es/number-input/index.d.ts +14 -0
- package/es/number-input/index.js +21 -0
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/types.js +1 -0
- package/es/number-input/utils/formatter.d.ts +10 -13
- package/es/number-input/utils/formatter.js +77 -51
- package/es/number-input/utils/index.d.ts +7 -0
- package/es/number-input/utils/index.js +8 -0
- package/es/number-input/utils/validation.d.ts +2 -7
- package/es/number-input/utils/validation.js +66 -51
- package/es/otherUtils.d.ts +9 -12
- package/es/otherUtils.js +129 -71
- package/es/platform.d.ts +9 -12
- package/es/platform.js +85 -61
- package/es/select/hooks/index.d.ts +5 -0
- package/es/select/hooks/index.js +6 -0
- package/es/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/es/select/hooks/useDebouncedSearch.js +53 -39
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +113 -56
- package/es/select/index.d.ts +8 -7
- package/es/select/index.js +13 -0
- package/es/select/types.d.ts +211 -211
- package/es/select/types.js +1 -0
- package/es/select/utils/filterOptions.d.ts +6 -7
- package/es/select/utils/filterOptions.js +31 -26
- package/es/select/utils/helpers.d.ts +9 -10
- package/es/select/utils/helpers.js +52 -42
- package/es/select/utils/index.d.ts +7 -4
- package/es/select/utils/index.js +8 -0
- package/es/select/utils/sortOptions.d.ts +5 -6
- package/es/select/utils/sortOptions.js +31 -19
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +47 -34
- package/es/text-input/hooks/index.d.ts +4 -0
- package/es/text-input/hooks/index.js +5 -0
- package/es/text-input/hooks/useTextInputState.d.ts +2 -6
- package/es/text-input/hooks/useTextInputState.js +126 -69
- package/es/text-input/index.d.ts +14 -0
- package/es/text-input/index.js +20 -0
- package/es/text-input/types.d.ts +48 -48
- package/es/text-input/types.js +1 -0
- package/es/text-input/utils/index.d.ts +5 -0
- package/es/text-input/utils/index.js +7 -0
- package/es/text-input/utils/validation.d.ts +2 -7
- package/es/text-input/utils/validation.js +70 -50
- package/es/typeUtils.js +84 -61
- package/es/walletValidity.d.ts +42 -44
- package/es/walletValidity.js +557 -396
- package/es/weighing.d.ts +45 -48
- package/es/weighing.js +106 -83
- package/lib/arrayUtils.d.ts +23 -26
- package/lib/arrayUtils.js +111 -101
- package/lib/common/index.d.ts +5 -0
- package/lib/common/index.js +29 -0
- package/lib/common/stateHelper.d.ts +2 -6
- package/lib/common/stateHelper.js +32 -21
- package/lib/common/types.d.ts +10 -13
- package/lib/common/types.js +17 -0
- package/lib/componentStorage.d.ts +25 -27
- package/lib/componentStorage.js +126 -96
- package/lib/constants/index.js +36 -7
- package/lib/date.js +65 -43
- package/lib/document.js +62 -46
- package/lib/escPosPrinter/EscPosPrinter.js +403 -327
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +84 -38
- package/lib/firebase/config/index.js +79 -0
- package/lib/firebase/index.js +180 -0
- package/lib/format.d.ts +15 -12
- package/lib/format.js +133 -91
- package/lib/image.js +74 -48
- package/lib/index.d.ts +24 -39
- package/lib/index.js +80 -137
- package/lib/jsBridge/index.d.ts +4 -8
- package/lib/jsBridge/index.js +76 -57
- package/lib/jsBridge/regDeviceApi.js +133 -86
- package/lib/jsBridge/types.d.ts +115 -95
- package/lib/jsBridge/types.js +17 -0
- package/lib/locales.d.ts +8 -11
- package/lib/locales.js +90 -79
- package/lib/log.d.ts +6 -11
- package/lib/log.js +61 -37
- package/lib/miniRedux.d.ts +13 -20
- package/lib/miniRedux.js +89 -43
- package/lib/number-input/hooks/index.d.ts +4 -0
- package/lib/number-input/hooks/index.js +29 -0
- package/lib/number-input/hooks/useNumberInputState.d.ts +2 -6
- package/lib/number-input/hooks/useNumberInputState.js +81 -71
- package/lib/number-input/index.d.ts +14 -0
- package/lib/number-input/index.js +41 -0
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/types.js +17 -0
- package/lib/number-input/utils/formatter.d.ts +10 -13
- package/lib/number-input/utils/formatter.js +49 -52
- package/lib/number-input/utils/index.d.ts +7 -0
- package/lib/number-input/utils/index.js +39 -0
- package/lib/number-input/utils/validation.d.ts +2 -7
- package/lib/number-input/utils/validation.js +52 -50
- package/lib/otherUtils.d.ts +9 -12
- package/lib/otherUtils.js +98 -86
- package/lib/platform.d.ts +9 -12
- package/lib/platform.js +123 -68
- package/lib/select/hooks/index.d.ts +5 -0
- package/lib/select/hooks/index.js +34 -0
- package/lib/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/lib/select/hooks/useDebouncedSearch.js +41 -40
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +93 -58
- package/lib/select/index.d.ts +8 -7
- package/lib/select/index.js +53 -0
- package/lib/select/types.d.ts +211 -211
- package/lib/select/types.js +17 -0
- package/lib/select/utils/filterOptions.d.ts +6 -7
- package/lib/select/utils/filterOptions.js +37 -26
- package/lib/select/utils/helpers.d.ts +9 -10
- package/lib/select/utils/helpers.js +41 -45
- package/lib/select/utils/index.d.ts +7 -4
- package/lib/select/utils/index.js +48 -0
- package/lib/select/utils/sortOptions.d.ts +5 -6
- package/lib/select/utils/sortOptions.js +39 -18
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +41 -33
- package/lib/text-input/hooks/index.d.ts +4 -0
- package/lib/text-input/hooks/index.js +29 -0
- package/lib/text-input/hooks/useTextInputState.d.ts +2 -6
- package/lib/text-input/hooks/useTextInputState.js +79 -69
- package/lib/text-input/index.d.ts +14 -0
- package/lib/text-input/index.js +35 -0
- package/lib/text-input/types.d.ts +48 -48
- package/lib/text-input/types.js +17 -0
- package/lib/text-input/utils/index.d.ts +5 -0
- package/lib/text-input/utils/index.js +32 -0
- package/lib/text-input/utils/validation.d.ts +2 -7
- package/lib/text-input/utils/validation.js +58 -49
- package/lib/typeUtils.js +73 -68
- package/lib/walletValidity.d.ts +42 -44
- package/lib/walletValidity.js +393 -410
- package/lib/weighing.d.ts +45 -48
- package/lib/weighing.js +149 -104
- package/package.json +1 -1
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -11
- package/es/date.d.ts +0 -31
- package/es/document.d.ts +0 -16
- package/es/image.d.ts +0 -14
- package/es/typeUtils.d.ts +0 -45
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -16
- package/lib/_virtual/_rolldown/runtime.js +0 -23
- package/lib/date.d.ts +0 -31
- package/lib/document.d.ts +0 -16
- package/lib/image.d.ts +0 -14
- package/lib/typeUtils.d.ts +0 -45
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
declare const
|
|
3
|
-
declare const
|
|
4
|
-
declare const
|
|
5
|
-
declare const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
1
|
+
export declare const EscPosPrinter = any;
|
|
2
|
+
export declare const ALIGN_LEFT = number;
|
|
3
|
+
export declare const ALIGN_CENTER = number;
|
|
4
|
+
export declare const ALIGN_RIGHT = number;
|
|
5
|
+
export declare const columnWidthWithAlignment = (
|
|
6
|
+
width: number,
|
|
7
|
+
alignment: number
|
|
8
|
+
) => any;
|
|
9
|
+
export declare const preparing = any;
|
|
@@ -1,39 +1,85 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 });
|
|
7
10
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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/escPosPrinter/index.js
|
|
30
|
+
var escPosPrinter_exports = {};
|
|
31
|
+
__export(escPosPrinter_exports, {
|
|
32
|
+
ALIGN_CENTER: () => import_EscPosPrinter.ALIGN_CENTER,
|
|
33
|
+
ALIGN_LEFT: () => import_EscPosPrinter.ALIGN_LEFT,
|
|
34
|
+
ALIGN_RIGHT: () => import_EscPosPrinter.ALIGN_RIGHT,
|
|
35
|
+
EscPosPrinter: () => import_EscPosPrinter.default,
|
|
36
|
+
columnWidthWithAlignment: () => import_EscPosPrinter.columnWidthWithAlignment,
|
|
37
|
+
preparing: () => preparing
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(escPosPrinter_exports);
|
|
40
|
+
var import_EscPosPrinter = __toESM(require("./EscPosPrinter"));
|
|
41
|
+
var dividing = (printer) => {
|
|
42
|
+
printer.setAlignment(import_EscPosPrinter.ALIGN_LEFT);
|
|
43
|
+
printer.appendText("------------------------------------------------\n");
|
|
44
|
+
};
|
|
45
|
+
var preparing = async (ip, sn, params) => {
|
|
46
|
+
const printer = new import_EscPosPrinter.default(576);
|
|
47
|
+
const { title } = params;
|
|
48
|
+
printer.clear();
|
|
49
|
+
printer.lineFeed(1);
|
|
50
|
+
printer.setPrintModes(false, false, false);
|
|
51
|
+
printer.setAlignment(import_EscPosPrinter.ALIGN_CENTER);
|
|
52
|
+
printer.appendText("打印测试\n");
|
|
53
|
+
dividing(printer);
|
|
54
|
+
printer.setAlignment(import_EscPosPrinter.ALIGN_LEFT);
|
|
55
|
+
printer.appendText("Order time: 2023-10-19 14:15:50\n");
|
|
56
|
+
printer.appendText("Order number\n");
|
|
57
|
+
printer.appendText("D3012");
|
|
58
|
+
dividing(printer);
|
|
59
|
+
printer.setColumnWidths(
|
|
60
|
+
(0, import_EscPosPrinter.columnWidthWithAlignment)(150, import_EscPosPrinter.ALIGN_LEFT),
|
|
61
|
+
(0, import_EscPosPrinter.columnWidthWithAlignment)(426, import_EscPosPrinter.ALIGN_LEFT)
|
|
62
|
+
);
|
|
63
|
+
printer.printInColumns("Number", "Name");
|
|
64
|
+
printer.setPrintModes(true, true, true);
|
|
65
|
+
printer.printInColumns(
|
|
66
|
+
"1 x",
|
|
67
|
+
"我是很长的商品名称我是很长的商品名称我是很长的商品名称我是很长的商品名称"
|
|
68
|
+
);
|
|
69
|
+
printer.setPrintModes(false, false, false);
|
|
70
|
+
dividing(printer);
|
|
71
|
+
printer.lineFeed(4);
|
|
72
|
+
printer.cutPaper(false);
|
|
73
|
+
printer.printAndExitPageMode();
|
|
74
|
+
const result = await printer.print(ip, sn, 1);
|
|
75
|
+
return result;
|
|
76
|
+
};
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
ALIGN_CENTER,
|
|
80
|
+
ALIGN_LEFT,
|
|
81
|
+
ALIGN_RIGHT,
|
|
82
|
+
EscPosPrinter,
|
|
83
|
+
columnWidthWithAlignment,
|
|
84
|
+
preparing
|
|
85
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/firebase/config/index.ts
|
|
20
|
+
var config_exports = {};
|
|
21
|
+
__export(config_exports, {
|
|
22
|
+
default: () => config_default,
|
|
23
|
+
firebaseConfig: () => firebaseConfig,
|
|
24
|
+
injectConfig: () => injectConfig
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(config_exports);
|
|
27
|
+
var { REACT_APP_API_ENV } = process.env;
|
|
28
|
+
var _firebaseConfig = {
|
|
29
|
+
"release": {
|
|
30
|
+
apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
|
|
31
|
+
authDomain: "pisell-dev-d6421.firebaseapp.com",
|
|
32
|
+
databaseURL: "https://pisell-dev-d6421-default-rtdb.asia-southeast1.firebasedatabase.app",
|
|
33
|
+
projectId: "pisell-dev-d6421",
|
|
34
|
+
storageBucket: "pisell-dev-d6421.appspot.com",
|
|
35
|
+
messagingSenderId: "426955619429",
|
|
36
|
+
appId: "1:426955619429:web:17b5fc88934bebb6dc1a8c",
|
|
37
|
+
measurementId: "G-YJ5G113V4L"
|
|
38
|
+
},
|
|
39
|
+
"dev": {
|
|
40
|
+
apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
|
|
41
|
+
authDomain: "pisell-dev-d6421.firebaseapp.com",
|
|
42
|
+
databaseURL: "https://pisell-dev-d6421-default-rtdb.asia-southeast1.firebasedatabase.app",
|
|
43
|
+
projectId: "pisell-dev-d6421",
|
|
44
|
+
storageBucket: "pisell-dev-d6421.appspot.com",
|
|
45
|
+
messagingSenderId: "426955619429",
|
|
46
|
+
appId: "1:426955619429:web:17b5fc88934bebb6dc1a8c",
|
|
47
|
+
measurementId: "G-YJ5G113V4L"
|
|
48
|
+
},
|
|
49
|
+
"pre": {
|
|
50
|
+
apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
|
|
51
|
+
authDomain: "pisell-dev-d6421.firebaseapp.com",
|
|
52
|
+
databaseURL: "https://pisell-dev-d6421-default-rtdb.asia-southeast1.firebasedatabase.app",
|
|
53
|
+
projectId: "pisell-dev-d6421",
|
|
54
|
+
storageBucket: "pisell-dev-d6421.appspot.com",
|
|
55
|
+
messagingSenderId: "426955619429",
|
|
56
|
+
appId: "1:426955619429:web:17b5fc88934bebb6dc1a8c",
|
|
57
|
+
measurementId: "G-YJ5G113V4L"
|
|
58
|
+
},
|
|
59
|
+
"prod": {
|
|
60
|
+
apiKey: "AIzaSyBhWzh3z3eGW08oeUH6jKNP_H3msyuBEQc",
|
|
61
|
+
authDomain: "pisell-dev-d6421.firebaseapp.com",
|
|
62
|
+
databaseURL: "https://pisell-dev-product-test.asia-southeast1.firebasedatabase.app",
|
|
63
|
+
projectId: "pisell-dev-d6421",
|
|
64
|
+
storageBucket: "pisell-dev-d6421.appspot.com",
|
|
65
|
+
messagingSenderId: "426955619429",
|
|
66
|
+
appId: "1:426955619429:web:17b5fc88934bebb6dc1a8c",
|
|
67
|
+
measurementId: "G-YJ5G113V4L"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
var injectConfig = (context) => {
|
|
71
|
+
_firebaseConfig[REACT_APP_API_ENV] = context;
|
|
72
|
+
};
|
|
73
|
+
var firebaseConfig = _firebaseConfig[REACT_APP_API_ENV];
|
|
74
|
+
var config_default = _firebaseConfig[REACT_APP_API_ENV];
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
firebaseConfig,
|
|
78
|
+
injectConfig
|
|
79
|
+
});
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/firebase/index.ts
|
|
20
|
+
var firebase_exports = {};
|
|
21
|
+
__export(firebase_exports, {
|
|
22
|
+
auth: () => auth,
|
|
23
|
+
database: () => database,
|
|
24
|
+
default: () => firebase_default,
|
|
25
|
+
firebaseApp: () => firebaseApp,
|
|
26
|
+
getPath: () => getPath,
|
|
27
|
+
goOffline: () => import_database.goOffline,
|
|
28
|
+
goOnline: () => import_database.goOnline,
|
|
29
|
+
initFirebase: () => initFirebase,
|
|
30
|
+
onDataChange: () => onDataChange,
|
|
31
|
+
onDataChanged: () => onDataChanged,
|
|
32
|
+
readData: () => readData,
|
|
33
|
+
ref: () => import_database.ref,
|
|
34
|
+
removeDataListener: () => removeDataListener,
|
|
35
|
+
setAuthStateChangeCallback: () => setAuthStateChangeCallback,
|
|
36
|
+
signInUser: () => signInUser,
|
|
37
|
+
signOutUser: () => signOutUser,
|
|
38
|
+
signUp: () => signUp,
|
|
39
|
+
writeData: () => writeData
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(firebase_exports);
|
|
42
|
+
var import_app = require("firebase/app");
|
|
43
|
+
var import_auth = require("firebase/auth");
|
|
44
|
+
var import_database = require("firebase/database");
|
|
45
|
+
var import_config = require("./config");
|
|
46
|
+
var import_typeUtils = require("../typeUtils");
|
|
47
|
+
var isClient = typeof window != "undefined" && window.document;
|
|
48
|
+
var isDefaultInit = isClient && ((0, import_typeUtils.isUndefined)(window == null ? void 0 : window.__isDefaultInit) ? true : window == null ? void 0 : window.__isDefaultInit);
|
|
49
|
+
var isInitialized = false;
|
|
50
|
+
var firebaseApp = {};
|
|
51
|
+
var auth = {};
|
|
52
|
+
var database = {};
|
|
53
|
+
var initFirebase = (config) => {
|
|
54
|
+
isInitialized = true;
|
|
55
|
+
firebaseApp = (0, import_app.initializeApp)(config || import_config.firebaseConfig);
|
|
56
|
+
auth = (0, import_auth.getAuth)(firebaseApp);
|
|
57
|
+
database = (0, import_database.getDatabase)(firebaseApp);
|
|
58
|
+
};
|
|
59
|
+
if (isClient && window.__wxjs_environment !== "miniprogram" && isDefaultInit) {
|
|
60
|
+
initFirebase();
|
|
61
|
+
}
|
|
62
|
+
var getPath = (path) => {
|
|
63
|
+
return path;
|
|
64
|
+
};
|
|
65
|
+
var setAuthStateChangeCallback = (callback) => {
|
|
66
|
+
auth.onAuthStateChanged(callback);
|
|
67
|
+
};
|
|
68
|
+
var signUp = async (email, password) => {
|
|
69
|
+
try {
|
|
70
|
+
const userCredential = await (0, import_auth.createUserWithEmailAndPassword)(
|
|
71
|
+
auth,
|
|
72
|
+
email,
|
|
73
|
+
password
|
|
74
|
+
);
|
|
75
|
+
return userCredential.user;
|
|
76
|
+
} catch (error) {
|
|
77
|
+
console.error("Error signing up:", error);
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var signInUser = async (email, password) => {
|
|
82
|
+
try {
|
|
83
|
+
const userCredential = await (0, import_auth.signInWithEmailAndPassword)(
|
|
84
|
+
auth,
|
|
85
|
+
email,
|
|
86
|
+
password
|
|
87
|
+
);
|
|
88
|
+
return userCredential.user;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error("Error signing in:", error);
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var signOutUser = async () => {
|
|
95
|
+
try {
|
|
96
|
+
return (0, import_auth.signOut)(auth);
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error("Error signing out:", error);
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var readData = async (path) => {
|
|
103
|
+
try {
|
|
104
|
+
if (!isInitialized) {
|
|
105
|
+
initFirebase();
|
|
106
|
+
}
|
|
107
|
+
const dataSnapshot = await (0, import_database.get)((0, import_database.ref)(database, getPath(path)));
|
|
108
|
+
return dataSnapshot.val();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.error("Error reading data:", error);
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var writeData = async (path, data) => {
|
|
115
|
+
try {
|
|
116
|
+
if (!isInitialized) {
|
|
117
|
+
initFirebase();
|
|
118
|
+
}
|
|
119
|
+
return (0, import_database.set)((0, import_database.ref)(database, getPath(path)), data);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
console.error("Error writing data:", error);
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var onDataChange = (path, callback) => {
|
|
126
|
+
try {
|
|
127
|
+
if (!isInitialized) {
|
|
128
|
+
initFirebase();
|
|
129
|
+
}
|
|
130
|
+
} catch (error) {
|
|
131
|
+
console.error("init error", error);
|
|
132
|
+
}
|
|
133
|
+
const databaseRef = (0, import_database.ref)(database, getPath(path));
|
|
134
|
+
const listener = (0, import_database.onValue)(databaseRef, callback);
|
|
135
|
+
return listener;
|
|
136
|
+
};
|
|
137
|
+
var onDataChanged = (path, callback) => {
|
|
138
|
+
try {
|
|
139
|
+
if (!isInitialized) {
|
|
140
|
+
initFirebase();
|
|
141
|
+
}
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.error("init error", error);
|
|
144
|
+
}
|
|
145
|
+
const databaseRef = (0, import_database.ref)(database, getPath(path));
|
|
146
|
+
const listener = (0, import_database.onChildChanged)(databaseRef, callback);
|
|
147
|
+
return listener;
|
|
148
|
+
};
|
|
149
|
+
var removeDataListener = (listener) => {
|
|
150
|
+
(0, import_database.off)(listener);
|
|
151
|
+
};
|
|
152
|
+
var firebase_default = {
|
|
153
|
+
signInUser,
|
|
154
|
+
signOutUser,
|
|
155
|
+
readData,
|
|
156
|
+
writeData,
|
|
157
|
+
onDataChange,
|
|
158
|
+
removeDataListener,
|
|
159
|
+
onDataChanged
|
|
160
|
+
};
|
|
161
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
162
|
+
0 && (module.exports = {
|
|
163
|
+
auth,
|
|
164
|
+
database,
|
|
165
|
+
firebaseApp,
|
|
166
|
+
getPath,
|
|
167
|
+
goOffline,
|
|
168
|
+
goOnline,
|
|
169
|
+
initFirebase,
|
|
170
|
+
onDataChange,
|
|
171
|
+
onDataChanged,
|
|
172
|
+
readData,
|
|
173
|
+
ref,
|
|
174
|
+
removeDataListener,
|
|
175
|
+
setAuthStateChangeCallback,
|
|
176
|
+
signInUser,
|
|
177
|
+
signOutUser,
|
|
178
|
+
signUp,
|
|
179
|
+
writeData
|
|
180
|
+
});
|
package/lib/format.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/format.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* @title: 格式化金额
|
|
4
3
|
* @description:
|
|
@@ -9,14 +8,20 @@
|
|
|
9
8
|
* @Author: zhiwei.Wang
|
|
10
9
|
* @Date: 2023-11-06 16:51
|
|
11
10
|
*/
|
|
12
|
-
declare const formatAmount: (amount?: number | string, precision?: number, symbol?: string) => string | number;
|
|
13
|
-
type FormatOptions = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
currencyCode?: string;
|
|
23
|
+
/** 货币展示格式,支持预置值和金额模板 */
|
|
24
|
+
currencyFormat?: string;
|
|
20
25
|
};
|
|
21
26
|
/**
|
|
22
27
|
* 根据配置格式化金额
|
|
@@ -24,6 +29,4 @@ type FormatOptions = {
|
|
|
24
29
|
* @param symbol
|
|
25
30
|
* @param options
|
|
26
31
|
*/
|
|
27
|
-
declare const formatAmountWithOptions: (amount?: number | string, symbol?: string, options?: FormatOptions) => string | number;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { FormatOptions, formatAmount, formatAmountWithOptions };
|
|
32
|
+
export declare const formatAmountWithOptions: (amount?: number | string, symbol?: string, options?: FormatOptions) => string | number;
|