@pisell/utils 1.0.71 → 1.0.73

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 (202) hide show
  1. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
  2. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
  3. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
  4. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
  5. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
  6. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
  7. package/es/arrayUtils.d.ts +4 -1
  8. package/es/arrayUtils.js +15 -24
  9. package/es/common/stateHelper.d.ts +6 -2
  10. package/es/common/stateHelper.js +22 -24
  11. package/es/common/types.d.ts +13 -10
  12. package/es/componentStorage.d.ts +27 -25
  13. package/es/componentStorage.js +94 -130
  14. package/es/constants/index.js +7 -9
  15. package/es/date.d.ts +6 -3
  16. package/es/date.js +36 -53
  17. package/es/document.d.ts +6 -3
  18. package/es/document.js +43 -67
  19. package/es/escPosPrinter/EscPosPrinter.js +353 -490
  20. package/es/escPosPrinter/index.d.ts +9 -9
  21. package/es/escPosPrinter/index.js +37 -52
  22. package/es/format.d.ts +12 -11
  23. package/es/format.js +90 -116
  24. package/es/image.d.ts +13 -10
  25. package/es/image.js +48 -60
  26. package/es/index.d.ts +38 -23
  27. package/es/index.js +39 -34
  28. package/es/jsBridge/index.d.ts +8 -4
  29. package/es/jsBridge/index.js +57 -56
  30. package/es/jsBridge/regDeviceApi.js +107 -149
  31. package/es/jsBridge/types.d.ts +95 -115
  32. package/es/locales.d.ts +11 -8
  33. package/es/locales.js +77 -96
  34. package/es/log.d.ts +11 -6
  35. package/es/log.js +37 -59
  36. package/es/miniRedux.d.ts +20 -13
  37. package/es/miniRedux.js +42 -78
  38. package/es/number-input/hooks/useNumberInputState.d.ts +6 -2
  39. package/es/number-input/hooks/useNumberInputState.js +71 -128
  40. package/es/number-input/types.d.ts +88 -88
  41. package/es/number-input/utils/formatter.d.ts +13 -10
  42. package/es/number-input/utils/formatter.js +51 -77
  43. package/es/number-input/utils/validation.d.ts +7 -2
  44. package/es/number-input/utils/validation.js +51 -66
  45. package/es/otherUtils.d.ts +12 -9
  46. package/es/otherUtils.js +71 -129
  47. package/es/platform.d.ts +17 -9
  48. package/es/platform.js +78 -85
  49. package/es/select/hooks/useDebouncedSearch.d.ts +4 -1
  50. package/es/select/hooks/useDebouncedSearch.js +39 -53
  51. package/es/select/hooks/useSelectState.d.ts +7 -7
  52. package/es/select/hooks/useSelectState.js +56 -113
  53. package/es/select/index.d.ts +7 -8
  54. package/es/select/types.d.ts +211 -211
  55. package/es/select/utils/filterOptions.d.ts +7 -6
  56. package/es/select/utils/filterOptions.js +26 -31
  57. package/es/select/utils/helpers.d.ts +10 -9
  58. package/es/select/utils/helpers.js +42 -52
  59. package/es/select/utils/index.d.ts +4 -7
  60. package/es/select/utils/sortOptions.d.ts +6 -5
  61. package/es/select/utils/sortOptions.js +19 -31
  62. package/es/select/utils/tagAggregation.d.ts +6 -6
  63. package/es/select/utils/tagAggregation.js +34 -47
  64. package/es/text-input/hooks/useTextInputState.d.ts +6 -2
  65. package/es/text-input/hooks/useTextInputState.js +69 -126
  66. package/es/text-input/types.d.ts +48 -48
  67. package/es/text-input/utils/validation.d.ts +7 -2
  68. package/es/text-input/utils/validation.js +50 -70
  69. package/es/typeUtils.d.ts +11 -8
  70. package/es/typeUtils.js +61 -84
  71. package/es/walletValidity.d.ts +36 -34
  72. package/es/walletValidity.js +332 -456
  73. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
  74. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
  75. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
  76. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
  77. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
  78. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
  79. package/lib/_virtual/_rolldown/runtime.js +23 -0
  80. package/lib/arrayUtils.d.ts +4 -1
  81. package/lib/arrayUtils.js +14 -39
  82. package/lib/common/stateHelper.d.ts +6 -2
  83. package/lib/common/stateHelper.js +21 -32
  84. package/lib/common/types.d.ts +13 -10
  85. package/lib/componentStorage.d.ts +27 -25
  86. package/lib/componentStorage.js +96 -126
  87. package/lib/constants/index.js +7 -36
  88. package/lib/date.d.ts +6 -3
  89. package/lib/date.js +43 -65
  90. package/lib/document.d.ts +6 -3
  91. package/lib/document.js +46 -62
  92. package/lib/escPosPrinter/EscPosPrinter.js +327 -403
  93. package/lib/escPosPrinter/index.d.ts +9 -9
  94. package/lib/escPosPrinter/index.js +38 -84
  95. package/lib/format.d.ts +12 -11
  96. package/lib/format.js +91 -99
  97. package/lib/image.d.ts +13 -10
  98. package/lib/image.js +48 -74
  99. package/lib/index.d.ts +38 -23
  100. package/lib/index.js +115 -78
  101. package/lib/jsBridge/index.d.ts +8 -4
  102. package/lib/jsBridge/index.js +58 -77
  103. package/lib/jsBridge/regDeviceApi.js +106 -153
  104. package/lib/jsBridge/types.d.ts +95 -115
  105. package/lib/locales.d.ts +11 -8
  106. package/lib/locales.js +79 -90
  107. package/lib/log.d.ts +11 -6
  108. package/lib/log.js +37 -61
  109. package/lib/miniRedux.d.ts +20 -13
  110. package/lib/miniRedux.js +43 -92
  111. package/lib/number-input/hooks/useNumberInputState.d.ts +6 -2
  112. package/lib/number-input/hooks/useNumberInputState.js +71 -81
  113. package/lib/number-input/types.d.ts +88 -88
  114. package/lib/number-input/utils/formatter.d.ts +13 -10
  115. package/lib/number-input/utils/formatter.js +52 -49
  116. package/lib/number-input/utils/validation.d.ts +7 -2
  117. package/lib/number-input/utils/validation.js +50 -52
  118. package/lib/otherUtils.d.ts +12 -9
  119. package/lib/otherUtils.js +86 -98
  120. package/lib/platform.d.ts +17 -9
  121. package/lib/platform.js +85 -122
  122. package/lib/select/hooks/useDebouncedSearch.d.ts +4 -1
  123. package/lib/select/hooks/useDebouncedSearch.js +40 -41
  124. package/lib/select/hooks/useSelectState.d.ts +7 -7
  125. package/lib/select/hooks/useSelectState.js +58 -93
  126. package/lib/select/index.d.ts +7 -8
  127. package/lib/select/types.d.ts +211 -211
  128. package/lib/select/utils/filterOptions.d.ts +7 -6
  129. package/lib/select/utils/filterOptions.js +26 -37
  130. package/lib/select/utils/helpers.d.ts +10 -9
  131. package/lib/select/utils/helpers.js +45 -41
  132. package/lib/select/utils/index.d.ts +4 -7
  133. package/lib/select/utils/sortOptions.d.ts +6 -5
  134. package/lib/select/utils/sortOptions.js +18 -39
  135. package/lib/select/utils/tagAggregation.d.ts +6 -6
  136. package/lib/select/utils/tagAggregation.js +33 -41
  137. package/lib/text-input/hooks/useTextInputState.d.ts +6 -2
  138. package/lib/text-input/hooks/useTextInputState.js +69 -79
  139. package/lib/text-input/types.d.ts +48 -48
  140. package/lib/text-input/utils/validation.d.ts +7 -2
  141. package/lib/text-input/utils/validation.js +49 -58
  142. package/lib/typeUtils.d.ts +11 -8
  143. package/lib/typeUtils.js +68 -73
  144. package/lib/walletValidity.d.ts +36 -34
  145. package/lib/walletValidity.js +345 -317
  146. package/package.json +1 -2
  147. package/es/common/index.d.ts +0 -5
  148. package/es/common/index.js +0 -5
  149. package/es/common/types.js +0 -1
  150. package/es/constants/index.d.ts +0 -7
  151. package/es/firebase/config/index.d.ts +0 -13
  152. package/es/firebase/config/index.js +0 -54
  153. package/es/firebase/index.d.ts +0 -28
  154. package/es/firebase/index.js +0 -232
  155. package/es/jsBridge/types.js +0 -1
  156. package/es/number-input/hooks/index.d.ts +0 -4
  157. package/es/number-input/hooks/index.js +0 -5
  158. package/es/number-input/index.d.ts +0 -14
  159. package/es/number-input/index.js +0 -21
  160. package/es/number-input/types.js +0 -1
  161. package/es/number-input/utils/index.d.ts +0 -7
  162. package/es/number-input/utils/index.js +0 -8
  163. package/es/select/hooks/index.d.ts +0 -5
  164. package/es/select/hooks/index.js +0 -6
  165. package/es/select/index.js +0 -13
  166. package/es/select/types.js +0 -1
  167. package/es/select/utils/index.js +0 -8
  168. package/es/text-input/hooks/index.d.ts +0 -4
  169. package/es/text-input/hooks/index.js +0 -5
  170. package/es/text-input/index.d.ts +0 -14
  171. package/es/text-input/index.js +0 -20
  172. package/es/text-input/types.js +0 -1
  173. package/es/text-input/utils/index.d.ts +0 -5
  174. package/es/text-input/utils/index.js +0 -7
  175. package/lib/common/index.d.ts +0 -5
  176. package/lib/common/index.js +0 -29
  177. package/lib/common/types.js +0 -17
  178. package/lib/constants/index.d.ts +0 -7
  179. package/lib/firebase/config/index.d.ts +0 -13
  180. package/lib/firebase/config/index.js +0 -79
  181. package/lib/firebase/index.d.ts +0 -28
  182. package/lib/firebase/index.js +0 -180
  183. package/lib/jsBridge/types.js +0 -17
  184. package/lib/number-input/hooks/index.d.ts +0 -4
  185. package/lib/number-input/hooks/index.js +0 -29
  186. package/lib/number-input/index.d.ts +0 -14
  187. package/lib/number-input/index.js +0 -41
  188. package/lib/number-input/types.js +0 -17
  189. package/lib/number-input/utils/index.d.ts +0 -7
  190. package/lib/number-input/utils/index.js +0 -39
  191. package/lib/select/hooks/index.d.ts +0 -5
  192. package/lib/select/hooks/index.js +0 -34
  193. package/lib/select/index.js +0 -53
  194. package/lib/select/types.js +0 -17
  195. package/lib/select/utils/index.js +0 -48
  196. package/lib/text-input/hooks/index.d.ts +0 -4
  197. package/lib/text-input/hooks/index.js +0 -29
  198. package/lib/text-input/index.d.ts +0 -14
  199. package/lib/text-input/index.js +0 -35
  200. package/lib/text-input/types.js +0 -17
  201. package/lib/text-input/utils/index.d.ts +0 -5
  202. package/lib/text-input/utils/index.js +0 -32
package/lib/index.js CHANGED
@@ -1,80 +1,117 @@
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 });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_objectSpread2 = require("./_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
3
+ const require_otherUtils = require("./otherUtils.js");
4
+ const require_typeUtils = require("./typeUtils.js");
5
+ const require_componentStorage = require("./componentStorage.js");
6
+ const require_document = require("./document.js");
7
+ const require_date = require("./date.js");
8
+ const require_platform = require("./platform.js");
9
+ const require_log = require("./log.js");
10
+ const require_format = require("./format.js");
11
+ const require_EscPosPrinter = require("./escPosPrinter/EscPosPrinter.js");
12
+ const require_index = require("./escPosPrinter/index.js");
13
+ const require_miniRedux = require("./miniRedux.js");
14
+ const require_index$1 = require("./jsBridge/index.js");
15
+ const require_image = require("./image.js");
16
+ const require_locales = require("./locales.js");
17
+ const require_arrayUtils = require("./arrayUtils.js");
18
+ const require_walletValidity = require("./walletValidity.js");
19
+ const require_stateHelper = require("./common/stateHelper.js");
20
+ const require_validation = require("./text-input/utils/validation.js");
21
+ const require_useTextInputState = require("./text-input/hooks/useTextInputState.js");
22
+ const require_validation$1 = require("./number-input/utils/validation.js");
23
+ const require_useNumberInputState = require("./number-input/hooks/useNumberInputState.js");
24
+ const require_formatter = require("./number-input/utils/formatter.js");
25
+ const require_useSelectState = require("./select/hooks/useSelectState.js");
26
+ const require_useDebouncedSearch = require("./select/hooks/useDebouncedSearch.js");
27
+ const require_tagAggregation = require("./select/utils/tagAggregation.js");
28
+ const require_filterOptions = require("./select/utils/filterOptions.js");
29
+ const require_sortOptions = require("./select/utils/sortOptions.js");
30
+ const require_helpers = require("./select/utils/helpers.js");
31
+ //#region src/index.ts
32
+ const setPisellUtilsConfig = (config) => {
33
+ globalThis.pisellUtilsConfig = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, globalThis.pisellUtilsConfig || {}), config || {});
34
+ console.log("PisellUtilsConfig_set>>>>", config, globalThis);
8
35
  };
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;
36
+ const getPisellUtilsConfig = () => {
37
+ console.log("PisellUtilsConfig_get>>>>", globalThis);
38
+ return globalThis.pisellUtilsConfig || {};
16
39
  };
17
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- getPisellUtilsConfig: () => getPisellUtilsConfig,
24
- setPisellUtilsConfig: () => setPisellUtilsConfig
25
- });
26
- module.exports = __toCommonJS(src_exports);
27
- __reExport(src_exports, require("./otherUtils"), module.exports);
28
- __reExport(src_exports, require("./typeUtils"), module.exports);
29
- __reExport(src_exports, require("./componentStorage"), module.exports);
30
- __reExport(src_exports, require("./document"), module.exports);
31
- __reExport(src_exports, require("./date"), module.exports);
32
- __reExport(src_exports, require("./platform"), module.exports);
33
- __reExport(src_exports, require("./log"), module.exports);
34
- __reExport(src_exports, require("./format"), module.exports);
35
- __reExport(src_exports, require("./escPosPrinter"), module.exports);
36
- __reExport(src_exports, require("./miniRedux"), module.exports);
37
- __reExport(src_exports, require("./jsBridge"), module.exports);
38
- __reExport(src_exports, require("./image"), module.exports);
39
- __reExport(src_exports, require("./locales"), module.exports);
40
- __reExport(src_exports, require("./arrayUtils"), module.exports);
41
- __reExport(src_exports, require("./walletValidity"), module.exports);
42
- __reExport(src_exports, require("./common"), module.exports);
43
- __reExport(src_exports, require("./text-input"), module.exports);
44
- __reExport(src_exports, require("./number-input"), module.exports);
45
- __reExport(src_exports, require("./select"), module.exports);
46
- var setPisellUtilsConfig = (config) => {
47
- globalThis.pisellUtilsConfig = {
48
- ...globalThis.pisellUtilsConfig || {},
49
- ...config || {}
50
- };
51
- console.log("PisellUtilsConfig_set>>>>", config, globalThis);
52
- };
53
- var getPisellUtilsConfig = () => {
54
- console.log("PisellUtilsConfig_get>>>>", globalThis);
55
- return globalThis.pisellUtilsConfig || {};
56
- };
57
- // Annotate the CommonJS export names for ESM import in node:
58
- 0 && (module.exports = {
59
- getPisellUtilsConfig,
60
- setPisellUtilsConfig,
61
- ...require("./otherUtils"),
62
- ...require("./typeUtils"),
63
- ...require("./componentStorage"),
64
- ...require("./document"),
65
- ...require("./date"),
66
- ...require("./platform"),
67
- ...require("./log"),
68
- ...require("./format"),
69
- ...require("./escPosPrinter"),
70
- ...require("./miniRedux"),
71
- ...require("./jsBridge"),
72
- ...require("./image"),
73
- ...require("./locales"),
74
- ...require("./arrayUtils"),
75
- ...require("./walletValidity"),
76
- ...require("./common"),
77
- ...require("./text-input"),
78
- ...require("./number-input"),
79
- ...require("./select")
80
- });
40
+ //#endregion
41
+ exports.ALIGN_CENTER = require_EscPosPrinter.ALIGN_CENTER;
42
+ exports.ALIGN_LEFT = require_EscPosPrinter.ALIGN_LEFT;
43
+ exports.ALIGN_RIGHT = require_EscPosPrinter.ALIGN_RIGHT;
44
+ exports.EscPosPrinter = require_EscPosPrinter;
45
+ exports.addThousandsSeparator = require_formatter.addThousandsSeparator;
46
+ exports.calculateTagDisplay = require_tagAggregation.calculateTagDisplay;
47
+ exports.changeArray = require_otherUtils.changeArray;
48
+ exports.checkEnv = require_platform.checkEnv;
49
+ exports.clearColumnSettingFromLocal = require_componentStorage.clearColumnSettingFromLocal;
50
+ exports.clearColumnVisibilityFromLocal = require_componentStorage.clearColumnVisibilityFromLocal;
51
+ exports.columnWidthWithAlignment = require_EscPosPrinter.columnWidthWithAlignment;
52
+ exports.copyToClipboard = require_document.copyToClipboard;
53
+ exports.createArray = require_otherUtils.createArray;
54
+ exports.dataManager = require_index$1.dataManager;
55
+ exports.defaultFilterOption = require_filterOptions.defaultFilterOption;
56
+ exports.detectIncognito = require_otherUtils.detectIncognito;
57
+ exports.excelDateToJSDate = require_date.excelDateToJSDate;
58
+ exports.filterOptions = require_filterOptions.filterOptions;
59
+ exports.findOptionByValue = require_helpers.findOptionByValue;
60
+ exports.findOptionsByValues = require_helpers.findOptionsByValues;
61
+ exports.formatAmount = require_format.formatAmount;
62
+ exports.formatAmountWithOptions = require_format.formatAmountWithOptions;
63
+ exports.formatDate = require_date.formatDate;
64
+ exports.formatNumber = require_formatter.formatNumber;
65
+ exports.formatPrecision = require_formatter.formatPrecision;
66
+ exports.generateId = require_helpers.generateId;
67
+ exports.generateUniqueIdByObj = require_otherUtils.generateUniqueIdByObj;
68
+ exports.getColumnSettingFromLocal = require_componentStorage.getColumnSettingFromLocal;
69
+ exports.getColumnVisibilityFromLocal = require_componentStorage.getColumnVisibilityFromLocal;
70
+ exports.getComponentStorageKey = require_componentStorage.getComponentStorageKey;
71
+ exports.getDisplayState = require_stateHelper.getDisplayState;
72
+ exports.getItemByArray = require_otherUtils.getItemByArray;
73
+ exports.getPisellUtilsConfig = getPisellUtilsConfig;
74
+ exports.getRecordBoardColumnSettingFromLocal = require_componentStorage.getRecordBoardColumnSettingFromLocal;
75
+ exports.getScheduleSummary = require_walletValidity.getScheduleSummary;
76
+ exports.getStorageKeySuffix = require_componentStorage.getStorageKeySuffix;
77
+ exports.getUniqueId = require_otherUtils.getUniqueId;
78
+ exports.image = require_image.image;
79
+ exports.isAndroid = require_platform.isAndroid;
80
+ exports.isArr = require_typeUtils.isArr;
81
+ exports.isBoolean = require_typeUtils.isBoolean;
82
+ exports.isFunction = require_typeUtils.isFunction;
83
+ exports.isIOS = require_platform.isIOS;
84
+ exports.isIos = require_platform.isIos;
85
+ exports.isIpad = require_platform.isIpad;
86
+ exports.isJson = require_typeUtils.isJson;
87
+ exports.isMobile = require_platform.isMobile;
88
+ exports.isNumber = require_typeUtils.isNumber;
89
+ exports.isOptionSelected = require_helpers.isOptionSelected;
90
+ exports.isOptionSelectedInMultiple = require_helpers.isOptionSelectedInMultiple;
91
+ exports.isPlainObject = require_typeUtils.isPlainObject;
92
+ exports.isSafari = require_platform.isSafari;
93
+ exports.isString = require_typeUtils.isString;
94
+ exports.isUndefined = require_typeUtils.isUndefined;
95
+ exports.isWebposOsServerEnv = require_platform.isWebposOsServerEnv;
96
+ exports.isWx = require_platform.isWx;
97
+ exports.isWxApp = require_platform.isWxApp;
98
+ exports.jsDateToExcelDate = require_date.jsDateToExcelDate;
99
+ exports.locales = require_locales.locales;
100
+ exports.miniRedux = require_miniRedux.miniRedux;
101
+ exports.preparing = require_index.preparing;
102
+ exports.saveColumnSettingToLocal = require_componentStorage.saveColumnSettingToLocal;
103
+ exports.saveColumnVisibilityToLocal = require_componentStorage.saveColumnVisibilityToLocal;
104
+ exports.sendWarningLog = require_log.sendWarningLog;
105
+ exports.setPisellUtilsConfig = setPisellUtilsConfig;
106
+ exports.setTheme = require_document.setTheme;
107
+ exports.sortOptions = require_sortOptions.sortOptions;
108
+ exports.uniqueByKey = require_arrayUtils.uniqueByKey;
109
+ exports.useDebouncedSearch = require_useDebouncedSearch.useDebouncedSearch;
110
+ exports.useMultipleSelectState = require_useSelectState.useMultipleSelectState;
111
+ exports.useNumberInputState = require_useNumberInputState.useNumberInputState;
112
+ exports.useSelectState = require_useSelectState.useSelectState;
113
+ exports.useTextInputState = require_useTextInputState.useTextInputState;
114
+ exports.validateNumberValue = require_validation$1.validateValue;
115
+ exports.validateTextValue = require_validation.validateValue;
116
+ exports.webPayment = require_index$1.webPayment;
117
+ exports.webPrint = require_index$1.webPrint;
@@ -1,22 +1,26 @@
1
- import { WebPrintParams, DataManagerParams, WebPaymentParams } from './types';
1
+ import { DataManagerParams, WebPaymentParams, WebPrintParams } from "./types.js";
2
+
3
+ //#region src/jsBridge/index.d.ts
2
4
  /**
3
5
  * webView页面中调用打印机打印
4
6
  * 此api暂时只支持native app平台下ios手机
5
7
  * @param params
6
8
  * @param callback
7
9
  */
8
- export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
10
+ declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
9
11
  /**
10
12
  * webView页面中调用APP内的数据
11
13
  * 此api暂时只支持native app平台下ios手机
12
14
  * @param params
13
15
  * @param callback
14
16
  */
15
- export declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
17
+ declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
16
18
  /**
17
19
  * webView页面中调用APP内的支付
18
20
  * 此api暂时只支持native app平台下ios
19
21
  * @param params
20
22
  * @param callback
21
23
  */
22
- export declare function webPayment(params: WebPaymentParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
24
+ declare function webPayment(params: WebPaymentParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
25
+ //#endregion
26
+ export { dataManager, webPayment, webPrint };
@@ -1,83 +1,64 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
-
29
- // src/jsBridge/index.ts
30
- var jsBridge_exports = {};
31
- __export(jsBridge_exports, {
32
- dataManager: () => dataManager,
33
- webPayment: () => webPayment,
34
- webPrint: () => webPrint
35
- });
36
- module.exports = __toCommonJS(jsBridge_exports);
37
- var import_regDeviceApi = __toESM(require("./regDeviceApi"));
1
+ const require_regDeviceApi = require("./regDeviceApi.js");
2
+ //#region src/jsBridge/index.ts
3
+ /**
4
+ * webView页面中调用打印机打印
5
+ * 此api暂时只支持native app平台下ios手机
6
+ * @param params
7
+ * @param callback
8
+ */
38
9
  function webPrint(params, callback, onError) {
39
- (0, import_regDeviceApi.default)().then((jsBridge) => {
40
- jsBridge.callDeviceApi({
41
- apiName: "webPrint",
42
- params,
43
- callback: (...arg) => {
44
- callback && callback(...arg);
45
- }
46
- });
47
- }).catch((err) => {
48
- onError == null ? void 0 : onError(err);
49
- console.error("webPrint", err);
50
- });
10
+ require_regDeviceApi.default().then((jsBridge) => {
11
+ jsBridge.callDeviceApi({
12
+ apiName: "webPrint",
13
+ params,
14
+ callback: (...arg) => {
15
+ callback && callback(...arg);
16
+ }
17
+ });
18
+ }).catch((err) => {
19
+ onError === null || onError === void 0 || onError(err);
20
+ console.error("webPrint", err);
21
+ });
51
22
  }
23
+ /**
24
+ * webView页面中调用APP内的数据
25
+ * 此api暂时只支持native app平台下ios手机
26
+ * @param params
27
+ * @param callback
28
+ */
52
29
  function dataManager(params, callback, onError) {
53
- (0, import_regDeviceApi.default)().then((jsBridge) => {
54
- jsBridge.callDeviceApi({
55
- apiName: "dataManager",
56
- params,
57
- callback: (...arg) => {
58
- callback && callback(...arg);
59
- },
60
- onError
61
- });
62
- }).catch(onError);
30
+ require_regDeviceApi.default().then((jsBridge) => {
31
+ jsBridge.callDeviceApi({
32
+ apiName: "dataManager",
33
+ params,
34
+ callback: (...arg) => {
35
+ callback && callback(...arg);
36
+ },
37
+ onError
38
+ });
39
+ }).catch(onError);
63
40
  }
41
+ /**
42
+ * webView页面中调用APP内的支付
43
+ * 此api暂时只支持native app平台下ios
44
+ * @param params
45
+ * @param callback
46
+ */
64
47
  function webPayment(params, callback, onError) {
65
- (0, import_regDeviceApi.default)().then((jsBridge) => {
66
- jsBridge.callDeviceApi({
67
- apiName: "webPayment",
68
- params,
69
- callback: (...arg) => {
70
- callback && callback(...arg);
71
- }
72
- });
73
- }).catch((err) => {
74
- onError == null ? void 0 : onError(err);
75
- console.error("webPayment", err);
76
- });
48
+ require_regDeviceApi.default().then((jsBridge) => {
49
+ jsBridge.callDeviceApi({
50
+ apiName: "webPayment",
51
+ params,
52
+ callback: (...arg) => {
53
+ callback && callback(...arg);
54
+ }
55
+ });
56
+ }).catch((err) => {
57
+ onError === null || onError === void 0 || onError(err);
58
+ console.error("webPayment", err);
59
+ });
77
60
  }
78
- // Annotate the CommonJS export names for ESM import in node:
79
- 0 && (module.exports = {
80
- dataManager,
81
- webPayment,
82
- webPrint
83
- });
61
+ //#endregion
62
+ exports.dataManager = dataManager;
63
+ exports.webPayment = webPayment;
64
+ exports.webPrint = webPrint;
@@ -1,163 +1,116 @@
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/jsBridge/regDeviceApi.js
20
- var regDeviceApi_exports = {};
21
- __export(regDeviceApi_exports, {
22
- default: () => regDeviceApi
23
- });
24
- module.exports = __toCommonJS(regDeviceApi_exports);
25
- var import_platform = require("../platform");
26
- var androidRegStatus = false;
27
- var iosRegStatus = false;
28
- var androidBridge;
29
- var iosBridge;
30
- var composedBridge;
1
+ const require_platform = require("../platform.js");
2
+ //#region src/jsBridge/regDeviceApi.js
3
+ let androidRegStatus = false;
4
+ let iosRegStatus = false;
5
+ let androidBridge;
6
+ let iosBridge;
7
+ let composedBridge;
31
8
  function regIosJsBridge(callback, reject) {
32
- if (window.WebViewJavascriptBridge) {
33
- callback(window.WebViewJavascriptBridge);
34
- return;
35
- } else {
36
- reject();
37
- }
38
- if (window.WVJBCallbacks) {
39
- window.WVJBCallbacks.push(callback);
40
- return;
41
- }
42
- window.WVJBCallbacks = [callback];
43
- const WVJBIframe = document.createElement("iframe");
44
- WVJBIframe.style.display = "none";
45
- WVJBIframe.src = "https://__bridge_loaded__";
46
- document.documentElement && document.documentElement.appendChild(WVJBIframe);
47
- setTimeout(() => {
48
- try {
49
- document.documentElement && document.documentElement.removeChild(WVJBIframe);
50
- } catch (e) {
51
- console.log(e);
52
- }
53
- }, 0);
9
+ if (window.WebViewJavascriptBridge) {
10
+ callback(window.WebViewJavascriptBridge);
11
+ return;
12
+ } else reject();
13
+ if (window.WVJBCallbacks) {
14
+ window.WVJBCallbacks.push(callback);
15
+ return;
16
+ }
17
+ window.WVJBCallbacks = [callback];
18
+ const WVJBIframe = document.createElement("iframe");
19
+ WVJBIframe.style.display = "none";
20
+ WVJBIframe.src = "https://__bridge_loaded__";
21
+ document.documentElement && document.documentElement.appendChild(WVJBIframe);
22
+ setTimeout(() => {
23
+ try {
24
+ document.documentElement && document.documentElement.removeChild(WVJBIframe);
25
+ } catch (e) {
26
+ console.log(e);
27
+ }
28
+ }, 0);
54
29
  }
55
30
  function regAndroidJsBridge(extraInit) {
56
- if (window._jsBridge) {
57
- extraInit(window._jsBridge);
58
- return;
59
- }
60
- document.addEventListener(
61
- "WebViewJavascriptBridgeReady",
62
- (event) => {
63
- const { bridge } = event;
64
- window._jsBridge = bridge;
65
- if (!bridge) return;
66
- bridge.init((message, responseCallback) => {
67
- if (responseCallback) {
68
- responseCallback("init responseCallback");
69
- }
70
- });
71
- extraInit(bridge);
72
- },
73
- false
74
- );
31
+ if (window._jsBridge) {
32
+ extraInit(window._jsBridge);
33
+ return;
34
+ }
35
+ document.addEventListener("WebViewJavascriptBridgeReady", (event) => {
36
+ const { bridge } = event;
37
+ window._jsBridge = bridge;
38
+ if (!bridge) return;
39
+ bridge.init((message, responseCallback) => {
40
+ if (responseCallback) responseCallback("init responseCallback");
41
+ });
42
+ extraInit(bridge);
43
+ }, false);
75
44
  }
76
45
  function checkApiName(apiNames, apiName) {
77
- let _apiNames = apiNames || ["webPrint"];
78
- return _apiNames.includes(apiName);
46
+ return (apiNames || ["webPrint"]).includes(apiName);
79
47
  }
48
+ /**
49
+ * 通用jsBridge
50
+ * @param deviceType
51
+ */
80
52
  function getComposedBridge(deviceType) {
81
- if (composedBridge) {
82
- return composedBridge;
83
- }
84
- composedBridge = {
85
- // 主动调用设备的方法
86
- callDeviceApi: ({ apiName, callback: inCb, params = {}, onError }) => {
87
- const callback = (res, ...args) => {
88
- let result = res;
89
- try {
90
- result = JSON.parse(res);
91
- } catch (error) {
92
- console.log(`error ${apiName}`, error);
93
- }
94
- inCb(result, ...args);
95
- };
96
- if (deviceType === "iphone") {
97
- if (!checkApiName(iosBridge == null ? void 0 : iosBridge.apiNames, apiName)) {
98
- onError == null ? void 0 : onError();
99
- return;
100
- }
101
- iosBridge.callHandler(apiName, params, callback, (e) => {
102
- console.log(e, "--- 调用ios api报错:", apiName);
103
- if (onError) {
104
- onError == null ? void 0 : onError(e);
105
- }
106
- });
107
- } else if (deviceType === "android") {
108
- if (!checkApiName(androidBridge == null ? void 0 : androidBridge.apiNames, apiName)) {
109
- onError == null ? void 0 : onError();
110
- return;
111
- }
112
- const res = androidBridge.callHandler(apiName, JSON.stringify(params));
113
- callback(res);
114
- } else {
115
- onError == null ? void 0 : onError();
116
- console.log("--- 没获取到js bridge ---");
117
- }
118
- },
119
- // 被设备调用的方法
120
- calledByDevice: ({ apiName, callback }) => {
121
- if (deviceType === "iphone") {
122
- iosBridge.registerHandler(apiName, callback);
123
- } else if (deviceType === "android") {
124
- androidBridge.registerHandler(apiName, callback);
125
- }
126
- }
127
- };
128
- return composedBridge;
53
+ if (composedBridge) return composedBridge;
54
+ composedBridge = {
55
+ callDeviceApi: ({ apiName, callback: inCb, params = {}, onError }) => {
56
+ const callback = (res, ...args) => {
57
+ let result = res;
58
+ try {
59
+ result = JSON.parse(res);
60
+ } catch (error) {
61
+ console.log(`error ${apiName}`, error);
62
+ }
63
+ inCb(result, ...args);
64
+ };
65
+ if (deviceType === "iphone") {
66
+ if (!checkApiName(iosBridge === null || iosBridge === void 0 ? void 0 : iosBridge.apiNames, apiName)) {
67
+ onError === null || onError === void 0 || onError();
68
+ return;
69
+ }
70
+ iosBridge.callHandler(apiName, params, callback, (e) => {
71
+ console.log(e, "--- 调用ios api报错:", apiName);
72
+ if (onError) onError === null || onError === void 0 || onError(e);
73
+ });
74
+ } else if (deviceType === "android") {
75
+ if (!checkApiName(androidBridge === null || androidBridge === void 0 ? void 0 : androidBridge.apiNames, apiName)) {
76
+ onError === null || onError === void 0 || onError();
77
+ return;
78
+ }
79
+ callback(androidBridge.callHandler(apiName, JSON.stringify(params)));
80
+ } else {
81
+ onError === null || onError === void 0 || onError();
82
+ console.log("--- 没获取到js bridge ---");
83
+ }
84
+ },
85
+ calledByDevice: ({ apiName, callback }) => {
86
+ if (deviceType === "iphone") iosBridge.registerHandler(apiName, callback);
87
+ else if (deviceType === "android") androidBridge.registerHandler(apiName, callback);
88
+ }
89
+ };
90
+ return composedBridge;
129
91
  }
130
92
  function regDeviceApi(isWebPrint) {
131
- return new Promise((resolve, reject) => {
132
- const isOld = !navigator.userAgent.includes("jsBridge");
133
- if (isOld) {
134
- if (!isWebPrint) {
135
- reject();
136
- return;
137
- }
138
- }
139
- if ((0, import_platform.isIos)() && !iosRegStatus) {
140
- regIosJsBridge((bridge) => {
141
- iosRegStatus = true;
142
- iosBridge = bridge;
143
- const realBridge = getComposedBridge("iphone");
144
- resolve(realBridge);
145
- }, reject);
146
- } else if ((0, import_platform.isIos)() && iosRegStatus) {
147
- const realBridge = getComposedBridge("iphone");
148
- resolve(realBridge);
149
- } else if ((0, import_platform.isAndroid)() && !androidRegStatus) {
150
- regAndroidJsBridge((bridge) => {
151
- androidBridge = bridge;
152
- androidRegStatus = true;
153
- const realBridge = getComposedBridge("android");
154
- resolve(realBridge);
155
- });
156
- } else if ((0, import_platform.isAndroid)() && androidRegStatus) {
157
- const realBridge = getComposedBridge("android");
158
- resolve(realBridge);
159
- } else {
160
- reject();
161
- }
162
- });
93
+ return new Promise((resolve, reject) => {
94
+ if (!navigator.userAgent.includes("jsBridge")) {
95
+ if (!isWebPrint) {
96
+ reject();
97
+ return;
98
+ }
99
+ }
100
+ if (require_platform.isIos() && !iosRegStatus) regIosJsBridge((bridge) => {
101
+ iosRegStatus = true;
102
+ iosBridge = bridge;
103
+ resolve(getComposedBridge("iphone"));
104
+ }, reject);
105
+ else if (require_platform.isIos() && iosRegStatus) resolve(getComposedBridge("iphone"));
106
+ else if (require_platform.isAndroid() && !androidRegStatus) regAndroidJsBridge((bridge) => {
107
+ androidBridge = bridge;
108
+ androidRegStatus = true;
109
+ resolve(getComposedBridge("android"));
110
+ });
111
+ else if (require_platform.isAndroid() && androidRegStatus) resolve(getComposedBridge("android"));
112
+ else reject();
113
+ });
163
114
  }
115
+ //#endregion
116
+ exports.default = regDeviceApi;