@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.
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
- package/es/arrayUtils.d.ts +4 -1
- package/es/arrayUtils.js +15 -24
- package/es/common/stateHelper.d.ts +6 -2
- package/es/common/stateHelper.js +22 -24
- package/es/common/types.d.ts +13 -10
- package/es/componentStorage.d.ts +27 -25
- package/es/componentStorage.js +94 -130
- package/es/constants/index.js +7 -9
- package/es/date.d.ts +6 -3
- package/es/date.js +36 -53
- package/es/document.d.ts +6 -3
- package/es/document.js +43 -67
- package/es/escPosPrinter/EscPosPrinter.js +353 -490
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +37 -52
- package/es/format.d.ts +12 -11
- package/es/format.js +90 -116
- package/es/image.d.ts +13 -10
- package/es/image.js +48 -60
- package/es/index.d.ts +38 -23
- package/es/index.js +39 -34
- package/es/jsBridge/index.d.ts +8 -4
- package/es/jsBridge/index.js +57 -56
- package/es/jsBridge/regDeviceApi.js +107 -149
- package/es/jsBridge/types.d.ts +95 -115
- package/es/locales.d.ts +11 -8
- package/es/locales.js +77 -96
- package/es/log.d.ts +11 -6
- package/es/log.js +37 -59
- package/es/miniRedux.d.ts +20 -13
- package/es/miniRedux.js +42 -78
- package/es/number-input/hooks/useNumberInputState.d.ts +6 -2
- package/es/number-input/hooks/useNumberInputState.js +71 -128
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/utils/formatter.d.ts +13 -10
- package/es/number-input/utils/formatter.js +51 -77
- package/es/number-input/utils/validation.d.ts +7 -2
- package/es/number-input/utils/validation.js +51 -66
- package/es/otherUtils.d.ts +12 -9
- package/es/otherUtils.js +71 -129
- package/es/platform.d.ts +17 -9
- package/es/platform.js +78 -85
- package/es/select/hooks/useDebouncedSearch.d.ts +4 -1
- package/es/select/hooks/useDebouncedSearch.js +39 -53
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +56 -113
- package/es/select/index.d.ts +7 -8
- package/es/select/types.d.ts +211 -211
- package/es/select/utils/filterOptions.d.ts +7 -6
- package/es/select/utils/filterOptions.js +26 -31
- package/es/select/utils/helpers.d.ts +10 -9
- package/es/select/utils/helpers.js +42 -52
- package/es/select/utils/index.d.ts +4 -7
- package/es/select/utils/sortOptions.d.ts +6 -5
- package/es/select/utils/sortOptions.js +19 -31
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +34 -47
- package/es/text-input/hooks/useTextInputState.d.ts +6 -2
- package/es/text-input/hooks/useTextInputState.js +69 -126
- package/es/text-input/types.d.ts +48 -48
- package/es/text-input/utils/validation.d.ts +7 -2
- package/es/text-input/utils/validation.js +50 -70
- package/es/typeUtils.d.ts +11 -8
- package/es/typeUtils.js +61 -84
- package/es/walletValidity.d.ts +36 -34
- package/es/walletValidity.js +332 -456
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
- package/lib/_virtual/_rolldown/runtime.js +23 -0
- package/lib/arrayUtils.d.ts +4 -1
- package/lib/arrayUtils.js +14 -39
- package/lib/common/stateHelper.d.ts +6 -2
- package/lib/common/stateHelper.js +21 -32
- package/lib/common/types.d.ts +13 -10
- package/lib/componentStorage.d.ts +27 -25
- package/lib/componentStorage.js +96 -126
- package/lib/constants/index.js +7 -36
- package/lib/date.d.ts +6 -3
- package/lib/date.js +43 -65
- package/lib/document.d.ts +6 -3
- package/lib/document.js +46 -62
- package/lib/escPosPrinter/EscPosPrinter.js +327 -403
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +38 -84
- package/lib/format.d.ts +12 -11
- package/lib/format.js +91 -99
- package/lib/image.d.ts +13 -10
- package/lib/image.js +48 -74
- package/lib/index.d.ts +38 -23
- package/lib/index.js +115 -78
- package/lib/jsBridge/index.d.ts +8 -4
- package/lib/jsBridge/index.js +58 -77
- package/lib/jsBridge/regDeviceApi.js +106 -153
- package/lib/jsBridge/types.d.ts +95 -115
- package/lib/locales.d.ts +11 -8
- package/lib/locales.js +79 -90
- package/lib/log.d.ts +11 -6
- package/lib/log.js +37 -61
- package/lib/miniRedux.d.ts +20 -13
- package/lib/miniRedux.js +43 -92
- package/lib/number-input/hooks/useNumberInputState.d.ts +6 -2
- package/lib/number-input/hooks/useNumberInputState.js +71 -81
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/utils/formatter.d.ts +13 -10
- package/lib/number-input/utils/formatter.js +52 -49
- package/lib/number-input/utils/validation.d.ts +7 -2
- package/lib/number-input/utils/validation.js +50 -52
- package/lib/otherUtils.d.ts +12 -9
- package/lib/otherUtils.js +86 -98
- package/lib/platform.d.ts +17 -9
- package/lib/platform.js +85 -122
- package/lib/select/hooks/useDebouncedSearch.d.ts +4 -1
- package/lib/select/hooks/useDebouncedSearch.js +40 -41
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +58 -93
- package/lib/select/index.d.ts +7 -8
- package/lib/select/types.d.ts +211 -211
- package/lib/select/utils/filterOptions.d.ts +7 -6
- package/lib/select/utils/filterOptions.js +26 -37
- package/lib/select/utils/helpers.d.ts +10 -9
- package/lib/select/utils/helpers.js +45 -41
- package/lib/select/utils/index.d.ts +4 -7
- package/lib/select/utils/sortOptions.d.ts +6 -5
- package/lib/select/utils/sortOptions.js +18 -39
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +33 -41
- package/lib/text-input/hooks/useTextInputState.d.ts +6 -2
- package/lib/text-input/hooks/useTextInputState.js +69 -79
- package/lib/text-input/types.d.ts +48 -48
- package/lib/text-input/utils/validation.d.ts +7 -2
- package/lib/text-input/utils/validation.js +49 -58
- package/lib/typeUtils.d.ts +11 -8
- package/lib/typeUtils.js +68 -73
- package/lib/walletValidity.d.ts +36 -34
- package/lib/walletValidity.js +345 -317
- package/package.json +1 -2
- package/es/common/index.d.ts +0 -5
- package/es/common/index.js +0 -5
- package/es/common/types.js +0 -1
- package/es/constants/index.d.ts +0 -7
- package/es/firebase/config/index.d.ts +0 -13
- package/es/firebase/config/index.js +0 -54
- package/es/firebase/index.d.ts +0 -28
- package/es/firebase/index.js +0 -232
- package/es/jsBridge/types.js +0 -1
- package/es/number-input/hooks/index.d.ts +0 -4
- package/es/number-input/hooks/index.js +0 -5
- package/es/number-input/index.d.ts +0 -14
- package/es/number-input/index.js +0 -21
- package/es/number-input/types.js +0 -1
- package/es/number-input/utils/index.d.ts +0 -7
- package/es/number-input/utils/index.js +0 -8
- package/es/select/hooks/index.d.ts +0 -5
- package/es/select/hooks/index.js +0 -6
- package/es/select/index.js +0 -13
- package/es/select/types.js +0 -1
- package/es/select/utils/index.js +0 -8
- package/es/text-input/hooks/index.d.ts +0 -4
- package/es/text-input/hooks/index.js +0 -5
- package/es/text-input/index.d.ts +0 -14
- package/es/text-input/index.js +0 -20
- package/es/text-input/types.js +0 -1
- package/es/text-input/utils/index.d.ts +0 -5
- package/es/text-input/utils/index.js +0 -7
- package/lib/common/index.d.ts +0 -5
- package/lib/common/index.js +0 -29
- package/lib/common/types.js +0 -17
- package/lib/constants/index.d.ts +0 -7
- package/lib/firebase/config/index.d.ts +0 -13
- package/lib/firebase/config/index.js +0 -79
- package/lib/firebase/index.d.ts +0 -28
- package/lib/firebase/index.js +0 -180
- package/lib/jsBridge/types.js +0 -17
- package/lib/number-input/hooks/index.d.ts +0 -4
- package/lib/number-input/hooks/index.js +0 -29
- package/lib/number-input/index.d.ts +0 -14
- package/lib/number-input/index.js +0 -41
- package/lib/number-input/types.js +0 -17
- package/lib/number-input/utils/index.d.ts +0 -7
- package/lib/number-input/utils/index.js +0 -39
- package/lib/select/hooks/index.d.ts +0 -5
- package/lib/select/hooks/index.js +0 -34
- package/lib/select/index.js +0 -53
- package/lib/select/types.js +0 -17
- package/lib/select/utils/index.js +0 -48
- package/lib/text-input/hooks/index.d.ts +0 -4
- package/lib/text-input/hooks/index.js +0 -29
- package/lib/text-input/index.d.ts +0 -14
- package/lib/text-input/index.js +0 -35
- package/lib/text-input/types.js +0 -17
- package/lib/text-input/utils/index.d.ts +0 -5
- package/lib/text-input/utils/index.js +0 -32
package/lib/index.js
CHANGED
|
@@ -1,80 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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;
|
package/lib/jsBridge/index.d.ts
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
24
|
+
declare function webPayment(params: WebPaymentParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
|
|
25
|
+
//#endregion
|
|
26
|
+
export { dataManager, webPayment, webPrint };
|
package/lib/jsBridge/index.js
CHANGED
|
@@ -1,83 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
webPrint
|
|
83
|
-
});
|
|
61
|
+
//#endregion
|
|
62
|
+
exports.dataManager = dataManager;
|
|
63
|
+
exports.webPayment = webPayment;
|
|
64
|
+
exports.webPrint = webPrint;
|
|
@@ -1,163 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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;
|