@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.
Files changed (200) hide show
  1. package/es/arrayUtils.d.ts +23 -26
  2. package/es/arrayUtils.js +157 -97
  3. package/es/common/index.d.ts +5 -0
  4. package/es/common/index.js +5 -0
  5. package/es/common/stateHelper.d.ts +2 -6
  6. package/es/common/stateHelper.js +24 -22
  7. package/es/common/types.d.ts +10 -13
  8. package/es/common/types.js +1 -0
  9. package/es/componentStorage.d.ts +25 -27
  10. package/es/componentStorage.js +130 -94
  11. package/es/constants/index.js +9 -7
  12. package/es/date.js +53 -36
  13. package/es/document.js +67 -43
  14. package/es/escPosPrinter/EscPosPrinter.js +490 -353
  15. package/es/escPosPrinter/index.d.ts +9 -9
  16. package/es/escPosPrinter/index.js +52 -37
  17. package/es/firebase/config/index.js +54 -0
  18. package/es/firebase/index.js +232 -0
  19. package/es/format.d.ts +15 -12
  20. package/es/format.js +156 -89
  21. package/es/image.js +60 -48
  22. package/es/index.d.ts +24 -39
  23. package/es/index.js +35 -40
  24. package/es/jsBridge/index.d.ts +4 -8
  25. package/es/jsBridge/index.js +55 -56
  26. package/es/jsBridge/regDeviceApi.js +126 -87
  27. package/es/jsBridge/types.d.ts +115 -95
  28. package/es/jsBridge/types.js +1 -0
  29. package/es/locales.d.ts +8 -11
  30. package/es/locales.js +96 -77
  31. package/es/log.d.ts +6 -11
  32. package/es/log.js +59 -37
  33. package/es/miniRedux.d.ts +13 -20
  34. package/es/miniRedux.js +76 -42
  35. package/es/number-input/hooks/index.d.ts +4 -0
  36. package/es/number-input/hooks/index.js +5 -0
  37. package/es/number-input/hooks/useNumberInputState.d.ts +2 -6
  38. package/es/number-input/hooks/useNumberInputState.js +128 -71
  39. package/es/number-input/index.d.ts +14 -0
  40. package/es/number-input/index.js +21 -0
  41. package/es/number-input/types.d.ts +88 -88
  42. package/es/number-input/types.js +1 -0
  43. package/es/number-input/utils/formatter.d.ts +10 -13
  44. package/es/number-input/utils/formatter.js +77 -51
  45. package/es/number-input/utils/index.d.ts +7 -0
  46. package/es/number-input/utils/index.js +8 -0
  47. package/es/number-input/utils/validation.d.ts +2 -7
  48. package/es/number-input/utils/validation.js +66 -51
  49. package/es/otherUtils.d.ts +9 -12
  50. package/es/otherUtils.js +129 -71
  51. package/es/platform.d.ts +9 -12
  52. package/es/platform.js +85 -61
  53. package/es/select/hooks/index.d.ts +5 -0
  54. package/es/select/hooks/index.js +6 -0
  55. package/es/select/hooks/useDebouncedSearch.d.ts +1 -4
  56. package/es/select/hooks/useDebouncedSearch.js +53 -39
  57. package/es/select/hooks/useSelectState.d.ts +7 -7
  58. package/es/select/hooks/useSelectState.js +113 -56
  59. package/es/select/index.d.ts +8 -7
  60. package/es/select/index.js +13 -0
  61. package/es/select/types.d.ts +211 -211
  62. package/es/select/types.js +1 -0
  63. package/es/select/utils/filterOptions.d.ts +6 -7
  64. package/es/select/utils/filterOptions.js +31 -26
  65. package/es/select/utils/helpers.d.ts +9 -10
  66. package/es/select/utils/helpers.js +52 -42
  67. package/es/select/utils/index.d.ts +7 -4
  68. package/es/select/utils/index.js +8 -0
  69. package/es/select/utils/sortOptions.d.ts +5 -6
  70. package/es/select/utils/sortOptions.js +31 -19
  71. package/es/select/utils/tagAggregation.d.ts +6 -6
  72. package/es/select/utils/tagAggregation.js +47 -34
  73. package/es/text-input/hooks/index.d.ts +4 -0
  74. package/es/text-input/hooks/index.js +5 -0
  75. package/es/text-input/hooks/useTextInputState.d.ts +2 -6
  76. package/es/text-input/hooks/useTextInputState.js +126 -69
  77. package/es/text-input/index.d.ts +14 -0
  78. package/es/text-input/index.js +20 -0
  79. package/es/text-input/types.d.ts +48 -48
  80. package/es/text-input/types.js +1 -0
  81. package/es/text-input/utils/index.d.ts +5 -0
  82. package/es/text-input/utils/index.js +7 -0
  83. package/es/text-input/utils/validation.d.ts +2 -7
  84. package/es/text-input/utils/validation.js +70 -50
  85. package/es/typeUtils.js +84 -61
  86. package/es/walletValidity.d.ts +42 -44
  87. package/es/walletValidity.js +557 -396
  88. package/es/weighing.d.ts +45 -48
  89. package/es/weighing.js +106 -83
  90. package/lib/arrayUtils.d.ts +23 -26
  91. package/lib/arrayUtils.js +111 -101
  92. package/lib/common/index.d.ts +5 -0
  93. package/lib/common/index.js +29 -0
  94. package/lib/common/stateHelper.d.ts +2 -6
  95. package/lib/common/stateHelper.js +32 -21
  96. package/lib/common/types.d.ts +10 -13
  97. package/lib/common/types.js +17 -0
  98. package/lib/componentStorage.d.ts +25 -27
  99. package/lib/componentStorage.js +126 -96
  100. package/lib/constants/index.js +36 -7
  101. package/lib/date.js +65 -43
  102. package/lib/document.js +62 -46
  103. package/lib/escPosPrinter/EscPosPrinter.js +403 -327
  104. package/lib/escPosPrinter/index.d.ts +9 -9
  105. package/lib/escPosPrinter/index.js +84 -38
  106. package/lib/firebase/config/index.js +79 -0
  107. package/lib/firebase/index.js +180 -0
  108. package/lib/format.d.ts +15 -12
  109. package/lib/format.js +133 -91
  110. package/lib/image.js +74 -48
  111. package/lib/index.d.ts +24 -39
  112. package/lib/index.js +80 -137
  113. package/lib/jsBridge/index.d.ts +4 -8
  114. package/lib/jsBridge/index.js +76 -57
  115. package/lib/jsBridge/regDeviceApi.js +133 -86
  116. package/lib/jsBridge/types.d.ts +115 -95
  117. package/lib/jsBridge/types.js +17 -0
  118. package/lib/locales.d.ts +8 -11
  119. package/lib/locales.js +90 -79
  120. package/lib/log.d.ts +6 -11
  121. package/lib/log.js +61 -37
  122. package/lib/miniRedux.d.ts +13 -20
  123. package/lib/miniRedux.js +89 -43
  124. package/lib/number-input/hooks/index.d.ts +4 -0
  125. package/lib/number-input/hooks/index.js +29 -0
  126. package/lib/number-input/hooks/useNumberInputState.d.ts +2 -6
  127. package/lib/number-input/hooks/useNumberInputState.js +81 -71
  128. package/lib/number-input/index.d.ts +14 -0
  129. package/lib/number-input/index.js +41 -0
  130. package/lib/number-input/types.d.ts +88 -88
  131. package/lib/number-input/types.js +17 -0
  132. package/lib/number-input/utils/formatter.d.ts +10 -13
  133. package/lib/number-input/utils/formatter.js +49 -52
  134. package/lib/number-input/utils/index.d.ts +7 -0
  135. package/lib/number-input/utils/index.js +39 -0
  136. package/lib/number-input/utils/validation.d.ts +2 -7
  137. package/lib/number-input/utils/validation.js +52 -50
  138. package/lib/otherUtils.d.ts +9 -12
  139. package/lib/otherUtils.js +98 -86
  140. package/lib/platform.d.ts +9 -12
  141. package/lib/platform.js +123 -68
  142. package/lib/select/hooks/index.d.ts +5 -0
  143. package/lib/select/hooks/index.js +34 -0
  144. package/lib/select/hooks/useDebouncedSearch.d.ts +1 -4
  145. package/lib/select/hooks/useDebouncedSearch.js +41 -40
  146. package/lib/select/hooks/useSelectState.d.ts +7 -7
  147. package/lib/select/hooks/useSelectState.js +93 -58
  148. package/lib/select/index.d.ts +8 -7
  149. package/lib/select/index.js +53 -0
  150. package/lib/select/types.d.ts +211 -211
  151. package/lib/select/types.js +17 -0
  152. package/lib/select/utils/filterOptions.d.ts +6 -7
  153. package/lib/select/utils/filterOptions.js +37 -26
  154. package/lib/select/utils/helpers.d.ts +9 -10
  155. package/lib/select/utils/helpers.js +41 -45
  156. package/lib/select/utils/index.d.ts +7 -4
  157. package/lib/select/utils/index.js +48 -0
  158. package/lib/select/utils/sortOptions.d.ts +5 -6
  159. package/lib/select/utils/sortOptions.js +39 -18
  160. package/lib/select/utils/tagAggregation.d.ts +6 -6
  161. package/lib/select/utils/tagAggregation.js +41 -33
  162. package/lib/text-input/hooks/index.d.ts +4 -0
  163. package/lib/text-input/hooks/index.js +29 -0
  164. package/lib/text-input/hooks/useTextInputState.d.ts +2 -6
  165. package/lib/text-input/hooks/useTextInputState.js +79 -69
  166. package/lib/text-input/index.d.ts +14 -0
  167. package/lib/text-input/index.js +35 -0
  168. package/lib/text-input/types.d.ts +48 -48
  169. package/lib/text-input/types.js +17 -0
  170. package/lib/text-input/utils/index.d.ts +5 -0
  171. package/lib/text-input/utils/index.js +32 -0
  172. package/lib/text-input/utils/validation.d.ts +2 -7
  173. package/lib/text-input/utils/validation.js +58 -49
  174. package/lib/typeUtils.js +73 -68
  175. package/lib/walletValidity.d.ts +42 -44
  176. package/lib/walletValidity.js +393 -410
  177. package/lib/weighing.d.ts +45 -48
  178. package/lib/weighing.js +149 -104
  179. package/package.json +1 -1
  180. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
  181. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
  182. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
  183. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
  184. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
  185. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -11
  186. package/es/date.d.ts +0 -31
  187. package/es/document.d.ts +0 -16
  188. package/es/image.d.ts +0 -14
  189. package/es/typeUtils.d.ts +0 -45
  190. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
  191. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
  192. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
  193. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
  194. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
  195. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -16
  196. package/lib/_virtual/_rolldown/runtime.js +0 -23
  197. package/lib/date.d.ts +0 -31
  198. package/lib/document.d.ts +0 -16
  199. package/lib/image.d.ts +0 -14
  200. package/lib/typeUtils.d.ts +0 -45
@@ -1,9 +1,9 @@
1
- //#region src/escPosPrinter/index.d.ts
2
- declare const EscPosPrinter = any;
3
- declare const ALIGN_LEFT = number;
4
- declare const ALIGN_CENTER = number;
5
- declare const ALIGN_RIGHT = number;
6
- declare const columnWidthWithAlignment = (width: number, alignment: number) => any;
7
- declare const preparing = any;
8
- //#endregion
9
- export { ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, EscPosPrinter, columnWidthWithAlignment, preparing };
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
- const require_asyncToGenerator = require("../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
2
- const require_EscPosPrinter = require("./EscPosPrinter.js");
3
- //#region src/escPosPrinter/index.js
4
- const dividing = (printer) => {
5
- printer.setAlignment(0);
6
- printer.appendText("------------------------------------------------\n");
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
- const preparing = function() {
9
- var _ref = require_asyncToGenerator._asyncToGenerator(function* (ip, sn, params) {
10
- const printer = new require_EscPosPrinter.default(576);
11
- const { title } = params;
12
- printer.clear();
13
- printer.lineFeed(1);
14
- printer.setPrintModes(false, false, false);
15
- printer.setAlignment(1);
16
- printer.appendText("打印测试\n");
17
- dividing(printer);
18
- printer.setAlignment(0);
19
- printer.appendText("Order time: 2023-10-19 14:15:50\n");
20
- printer.appendText("Order number\n");
21
- printer.appendText("D3012");
22
- dividing(printer);
23
- printer.setColumnWidths(require_EscPosPrinter.columnWidthWithAlignment(150, 0), require_EscPosPrinter.columnWidthWithAlignment(426, 0));
24
- printer.printInColumns("Number", "Name");
25
- printer.setPrintModes(true, true, true);
26
- printer.printInColumns("1 x", "我是很长的商品名称我是很长的商品名称我是很长的商品名称我是很长的商品名称");
27
- printer.setPrintModes(false, false, false);
28
- dividing(printer);
29
- printer.lineFeed(4);
30
- printer.cutPaper(false);
31
- printer.printAndExitPageMode();
32
- return yield printer.print(ip, sn, 1);
33
- });
34
- return function preparing(_x, _x2, _x3) {
35
- return _ref.apply(this, arguments);
36
- };
37
- }();
38
- //#endregion
39
- exports.preparing = preparing;
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
- /** 小数点后位数 默认是小数点后2位 */precision?: number; /** 显示货币符号 指的是 ¥$ 等货币符号等显隐,默认是展示 */
15
- showCurrencySymbol?: boolean; /** 千分位 指的是长金额的千分位逗号隔开,比如“123, 245, 315” 这种展现形式,默认是关闭 */
16
- useThousandsSeparator?: boolean; /** 整数位隐藏小数 指的是如果价格为整数,后面的".00" 将被省略以节省页面空间 */
17
- hideDecimalForWholeNumbers?: boolean; /** 货币代码或虚拟币单位后缀 */
18
- currencyCode?: string; /** 货币展示格式,支持预置值和金额模板 */
19
- currencyFormat?: string;
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;