@pisell/utils 3.0.6 → 3.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/arrayUtils.d.ts +23 -26
- package/es/arrayUtils.js +157 -97
- package/es/common/index.d.ts +5 -0
- package/es/common/index.js +5 -0
- package/es/common/stateHelper.d.ts +2 -6
- package/es/common/stateHelper.js +24 -22
- package/es/common/types.d.ts +10 -13
- package/es/common/types.js +1 -0
- package/es/componentStorage.d.ts +25 -27
- package/es/componentStorage.js +130 -94
- package/es/constants/index.js +9 -7
- package/es/date.js +53 -36
- package/es/document.js +67 -43
- package/es/escPosPrinter/EscPosPrinter.js +490 -353
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +52 -37
- package/es/firebase/config/index.js +54 -0
- package/es/firebase/index.js +232 -0
- package/es/format.d.ts +15 -12
- package/es/format.js +156 -89
- package/es/image.js +60 -48
- package/es/index.d.ts +24 -39
- package/es/index.js +35 -40
- package/es/jsBridge/index.d.ts +4 -8
- package/es/jsBridge/index.js +55 -56
- package/es/jsBridge/regDeviceApi.js +126 -87
- package/es/jsBridge/types.d.ts +115 -95
- package/es/jsBridge/types.js +1 -0
- package/es/locales.d.ts +8 -11
- package/es/locales.js +96 -77
- package/es/log.d.ts +6 -11
- package/es/log.js +59 -37
- package/es/miniRedux.d.ts +13 -20
- package/es/miniRedux.js +76 -42
- package/es/number-input/hooks/index.d.ts +4 -0
- package/es/number-input/hooks/index.js +5 -0
- package/es/number-input/hooks/useNumberInputState.d.ts +2 -6
- package/es/number-input/hooks/useNumberInputState.js +128 -71
- package/es/number-input/index.d.ts +14 -0
- package/es/number-input/index.js +21 -0
- package/es/number-input/types.d.ts +88 -88
- package/es/number-input/types.js +1 -0
- package/es/number-input/utils/formatter.d.ts +10 -13
- package/es/number-input/utils/formatter.js +77 -51
- package/es/number-input/utils/index.d.ts +7 -0
- package/es/number-input/utils/index.js +8 -0
- package/es/number-input/utils/validation.d.ts +2 -7
- package/es/number-input/utils/validation.js +66 -51
- package/es/otherUtils.d.ts +9 -12
- package/es/otherUtils.js +129 -71
- package/es/platform.d.ts +9 -12
- package/es/platform.js +85 -61
- package/es/select/hooks/index.d.ts +5 -0
- package/es/select/hooks/index.js +6 -0
- package/es/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/es/select/hooks/useDebouncedSearch.js +53 -39
- package/es/select/hooks/useSelectState.d.ts +7 -7
- package/es/select/hooks/useSelectState.js +113 -56
- package/es/select/index.d.ts +8 -7
- package/es/select/index.js +13 -0
- package/es/select/types.d.ts +211 -211
- package/es/select/types.js +1 -0
- package/es/select/utils/filterOptions.d.ts +6 -7
- package/es/select/utils/filterOptions.js +31 -26
- package/es/select/utils/helpers.d.ts +9 -10
- package/es/select/utils/helpers.js +52 -42
- package/es/select/utils/index.d.ts +7 -4
- package/es/select/utils/index.js +8 -0
- package/es/select/utils/sortOptions.d.ts +5 -6
- package/es/select/utils/sortOptions.js +31 -19
- package/es/select/utils/tagAggregation.d.ts +6 -6
- package/es/select/utils/tagAggregation.js +47 -34
- package/es/text-input/hooks/index.d.ts +4 -0
- package/es/text-input/hooks/index.js +5 -0
- package/es/text-input/hooks/useTextInputState.d.ts +2 -6
- package/es/text-input/hooks/useTextInputState.js +126 -69
- package/es/text-input/index.d.ts +14 -0
- package/es/text-input/index.js +20 -0
- package/es/text-input/types.d.ts +48 -48
- package/es/text-input/types.js +1 -0
- package/es/text-input/utils/index.d.ts +5 -0
- package/es/text-input/utils/index.js +7 -0
- package/es/text-input/utils/validation.d.ts +2 -7
- package/es/text-input/utils/validation.js +70 -50
- package/es/typeUtils.js +84 -61
- package/es/walletValidity.d.ts +42 -44
- package/es/walletValidity.js +557 -396
- package/es/weighing.d.ts +45 -48
- package/es/weighing.js +106 -83
- package/lib/arrayUtils.d.ts +23 -26
- package/lib/arrayUtils.js +111 -101
- package/lib/common/index.d.ts +5 -0
- package/lib/common/index.js +29 -0
- package/lib/common/stateHelper.d.ts +2 -6
- package/lib/common/stateHelper.js +32 -21
- package/lib/common/types.d.ts +10 -13
- package/lib/common/types.js +17 -0
- package/lib/componentStorage.d.ts +25 -27
- package/lib/componentStorage.js +126 -96
- package/lib/constants/index.js +36 -7
- package/lib/date.js +65 -43
- package/lib/document.js +62 -46
- package/lib/escPosPrinter/EscPosPrinter.js +403 -327
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +84 -38
- package/lib/firebase/config/index.js +79 -0
- package/lib/firebase/index.js +180 -0
- package/lib/format.d.ts +15 -12
- package/lib/format.js +133 -91
- package/lib/image.js +74 -48
- package/lib/index.d.ts +24 -39
- package/lib/index.js +80 -137
- package/lib/jsBridge/index.d.ts +4 -8
- package/lib/jsBridge/index.js +76 -57
- package/lib/jsBridge/regDeviceApi.js +133 -86
- package/lib/jsBridge/types.d.ts +115 -95
- package/lib/jsBridge/types.js +17 -0
- package/lib/locales.d.ts +8 -11
- package/lib/locales.js +90 -79
- package/lib/log.d.ts +6 -11
- package/lib/log.js +61 -37
- package/lib/miniRedux.d.ts +13 -20
- package/lib/miniRedux.js +89 -43
- package/lib/number-input/hooks/index.d.ts +4 -0
- package/lib/number-input/hooks/index.js +29 -0
- package/lib/number-input/hooks/useNumberInputState.d.ts +2 -6
- package/lib/number-input/hooks/useNumberInputState.js +81 -71
- package/lib/number-input/index.d.ts +14 -0
- package/lib/number-input/index.js +41 -0
- package/lib/number-input/types.d.ts +88 -88
- package/lib/number-input/types.js +17 -0
- package/lib/number-input/utils/formatter.d.ts +10 -13
- package/lib/number-input/utils/formatter.js +49 -52
- package/lib/number-input/utils/index.d.ts +7 -0
- package/lib/number-input/utils/index.js +39 -0
- package/lib/number-input/utils/validation.d.ts +2 -7
- package/lib/number-input/utils/validation.js +52 -50
- package/lib/otherUtils.d.ts +9 -12
- package/lib/otherUtils.js +98 -86
- package/lib/platform.d.ts +9 -12
- package/lib/platform.js +123 -68
- package/lib/select/hooks/index.d.ts +5 -0
- package/lib/select/hooks/index.js +34 -0
- package/lib/select/hooks/useDebouncedSearch.d.ts +1 -4
- package/lib/select/hooks/useDebouncedSearch.js +41 -40
- package/lib/select/hooks/useSelectState.d.ts +7 -7
- package/lib/select/hooks/useSelectState.js +93 -58
- package/lib/select/index.d.ts +8 -7
- package/lib/select/index.js +53 -0
- package/lib/select/types.d.ts +211 -211
- package/lib/select/types.js +17 -0
- package/lib/select/utils/filterOptions.d.ts +6 -7
- package/lib/select/utils/filterOptions.js +37 -26
- package/lib/select/utils/helpers.d.ts +9 -10
- package/lib/select/utils/helpers.js +41 -45
- package/lib/select/utils/index.d.ts +7 -4
- package/lib/select/utils/index.js +48 -0
- package/lib/select/utils/sortOptions.d.ts +5 -6
- package/lib/select/utils/sortOptions.js +39 -18
- package/lib/select/utils/tagAggregation.d.ts +6 -6
- package/lib/select/utils/tagAggregation.js +41 -33
- package/lib/text-input/hooks/index.d.ts +4 -0
- package/lib/text-input/hooks/index.js +29 -0
- package/lib/text-input/hooks/useTextInputState.d.ts +2 -6
- package/lib/text-input/hooks/useTextInputState.js +79 -69
- package/lib/text-input/index.d.ts +14 -0
- package/lib/text-input/index.js +35 -0
- package/lib/text-input/types.d.ts +48 -48
- package/lib/text-input/types.js +17 -0
- package/lib/text-input/utils/index.d.ts +5 -0
- package/lib/text-input/utils/index.js +32 -0
- package/lib/text-input/utils/validation.d.ts +2 -7
- package/lib/text-input/utils/validation.js +58 -49
- package/lib/typeUtils.js +73 -68
- package/lib/walletValidity.d.ts +42 -44
- package/lib/walletValidity.js +393 -410
- package/lib/weighing.d.ts +45 -48
- package/lib/weighing.js +149 -104
- package/package.json +1 -1
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -11
- package/es/date.d.ts +0 -31
- package/es/document.d.ts +0 -16
- package/es/image.d.ts +0 -14
- package/es/typeUtils.d.ts +0 -45
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -16
- package/lib/_virtual/_rolldown/runtime.js +0 -23
- package/lib/date.d.ts +0 -31
- package/lib/document.d.ts +0 -16
- package/lib/image.d.ts +0 -14
- package/lib/typeUtils.d.ts +0 -45
package/lib/index.js
CHANGED
|
@@ -1,139 +1,82 @@
|
|
|
1
|
-
Object.defineProperty
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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_weighing = require("./weighing.js");
|
|
20
|
-
const require_stateHelper = require("./common/stateHelper.js");
|
|
21
|
-
const require_validation = require("./text-input/utils/validation.js");
|
|
22
|
-
const require_useTextInputState = require("./text-input/hooks/useTextInputState.js");
|
|
23
|
-
const require_validation$1 = require("./number-input/utils/validation.js");
|
|
24
|
-
const require_useNumberInputState = require("./number-input/hooks/useNumberInputState.js");
|
|
25
|
-
const require_formatter = require("./number-input/utils/formatter.js");
|
|
26
|
-
const require_useSelectState = require("./select/hooks/useSelectState.js");
|
|
27
|
-
const require_useDebouncedSearch = require("./select/hooks/useDebouncedSearch.js");
|
|
28
|
-
const require_tagAggregation = require("./select/utils/tagAggregation.js");
|
|
29
|
-
const require_filterOptions = require("./select/utils/filterOptions.js");
|
|
30
|
-
const require_sortOptions = require("./select/utils/sortOptions.js");
|
|
31
|
-
const require_helpers = require("./select/utils/helpers.js");
|
|
32
|
-
//#region src/index.ts
|
|
33
|
-
const setPisellUtilsConfig = (config) => {
|
|
34
|
-
globalThis.pisellUtilsConfig = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, globalThis.pisellUtilsConfig || {}), config || {});
|
|
35
|
-
console.log("PisellUtilsConfig_set>>>>", config, globalThis);
|
|
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 });
|
|
36
8
|
};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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;
|
|
40
16
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
exports
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
exports
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
exports.isMobile = require_platform.isMobile;
|
|
108
|
-
exports.isNumber = require_typeUtils.isNumber;
|
|
109
|
-
exports.isOptionSelected = require_helpers.isOptionSelected;
|
|
110
|
-
exports.isOptionSelectedInMultiple = require_helpers.isOptionSelectedInMultiple;
|
|
111
|
-
exports.isPlainObject = require_typeUtils.isPlainObject;
|
|
112
|
-
exports.isSafari = require_platform.isSafari;
|
|
113
|
-
exports.isString = require_typeUtils.isString;
|
|
114
|
-
exports.isSupportedWeightUnit = require_weighing.isSupportedWeightUnit;
|
|
115
|
-
exports.isUndefined = require_typeUtils.isUndefined;
|
|
116
|
-
exports.isWx = require_platform.isWx;
|
|
117
|
-
exports.isWxApp = require_platform.isWxApp;
|
|
118
|
-
exports.jsDateToExcelDate = require_date.jsDateToExcelDate;
|
|
119
|
-
exports.locales = require_locales.locales;
|
|
120
|
-
exports.miniRedux = require_miniRedux.miniRedux;
|
|
121
|
-
exports.normalizeWeightUnit = require_weighing.normalizeWeightUnit;
|
|
122
|
-
exports.preparing = require_index.preparing;
|
|
123
|
-
exports.resolveWeighingSnapshot = require_weighing.resolveWeighingSnapshot;
|
|
124
|
-
exports.saveColumnSettingToLocal = require_componentStorage.saveColumnSettingToLocal;
|
|
125
|
-
exports.saveColumnVisibilityToLocal = require_componentStorage.saveColumnVisibilityToLocal;
|
|
126
|
-
exports.sendWarningLog = require_log.sendWarningLog;
|
|
127
|
-
exports.setPisellUtilsConfig = setPisellUtilsConfig;
|
|
128
|
-
exports.setTheme = require_document.setTheme;
|
|
129
|
-
exports.sortOptions = require_sortOptions.sortOptions;
|
|
130
|
-
exports.uniqueByKey = require_arrayUtils.uniqueByKey;
|
|
131
|
-
exports.useDebouncedSearch = require_useDebouncedSearch.useDebouncedSearch;
|
|
132
|
-
exports.useMultipleSelectState = require_useSelectState.useMultipleSelectState;
|
|
133
|
-
exports.useNumberInputState = require_useNumberInputState.useNumberInputState;
|
|
134
|
-
exports.useSelectState = require_useSelectState.useSelectState;
|
|
135
|
-
exports.useTextInputState = require_useTextInputState.useTextInputState;
|
|
136
|
-
exports.validateNumberValue = require_validation$1.validateValue;
|
|
137
|
-
exports.validateTextValue = require_validation.validateValue;
|
|
138
|
-
exports.webPayment = require_index$1.webPayment;
|
|
139
|
-
exports.webPrint = require_index$1.webPrint;
|
|
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("./weighing"), module.exports);
|
|
43
|
+
__reExport(src_exports, require("./common"), module.exports);
|
|
44
|
+
__reExport(src_exports, require("./text-input"), module.exports);
|
|
45
|
+
__reExport(src_exports, require("./number-input"), module.exports);
|
|
46
|
+
__reExport(src_exports, require("./select"), module.exports);
|
|
47
|
+
var setPisellUtilsConfig = (config) => {
|
|
48
|
+
globalThis.pisellUtilsConfig = {
|
|
49
|
+
...globalThis.pisellUtilsConfig || {},
|
|
50
|
+
...config || {}
|
|
51
|
+
};
|
|
52
|
+
console.log("PisellUtilsConfig_set>>>>", config, globalThis);
|
|
53
|
+
};
|
|
54
|
+
var getPisellUtilsConfig = () => {
|
|
55
|
+
console.log("PisellUtilsConfig_get>>>>", globalThis);
|
|
56
|
+
return globalThis.pisellUtilsConfig || {};
|
|
57
|
+
};
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
getPisellUtilsConfig,
|
|
61
|
+
setPisellUtilsConfig,
|
|
62
|
+
...require("./otherUtils"),
|
|
63
|
+
...require("./typeUtils"),
|
|
64
|
+
...require("./componentStorage"),
|
|
65
|
+
...require("./document"),
|
|
66
|
+
...require("./date"),
|
|
67
|
+
...require("./platform"),
|
|
68
|
+
...require("./log"),
|
|
69
|
+
...require("./format"),
|
|
70
|
+
...require("./escPosPrinter"),
|
|
71
|
+
...require("./miniRedux"),
|
|
72
|
+
...require("./jsBridge"),
|
|
73
|
+
...require("./image"),
|
|
74
|
+
...require("./locales"),
|
|
75
|
+
...require("./arrayUtils"),
|
|
76
|
+
...require("./walletValidity"),
|
|
77
|
+
...require("./weighing"),
|
|
78
|
+
...require("./common"),
|
|
79
|
+
...require("./text-input"),
|
|
80
|
+
...require("./number-input"),
|
|
81
|
+
...require("./select")
|
|
82
|
+
});
|
package/lib/jsBridge/index.d.ts
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import { DataManagerParams, WebPaymentParams
|
|
2
|
-
|
|
3
|
-
//#region src/jsBridge/index.d.ts
|
|
1
|
+
import { WebPrintParams, DataManagerParams, WebPaymentParams } from './types';
|
|
4
2
|
/**
|
|
5
3
|
* webView页面中调用打印机打印
|
|
6
4
|
* 此api暂时只支持native app平台下ios手机
|
|
7
5
|
* @param params
|
|
8
6
|
* @param callback
|
|
9
7
|
*/
|
|
10
|
-
declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
|
|
8
|
+
export declare function webPrint(params: WebPrintParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
|
|
11
9
|
/**
|
|
12
10
|
* webView页面中调用APP内的数据
|
|
13
11
|
* 此api暂时只支持native app平台下ios手机
|
|
14
12
|
* @param params
|
|
15
13
|
* @param callback
|
|
16
14
|
*/
|
|
17
|
-
declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
|
|
15
|
+
export declare function dataManager(params: DataManagerParams, callback: (...arg: any) => void, onError: () => void): void;
|
|
18
16
|
/**
|
|
19
17
|
* webView页面中调用APP内的支付
|
|
20
18
|
* 此api暂时只支持native app平台下ios
|
|
21
19
|
* @param params
|
|
22
20
|
* @param callback
|
|
23
21
|
*/
|
|
24
|
-
declare function webPayment(params: WebPaymentParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
|
|
25
|
-
//#endregion
|
|
26
|
-
export { dataManager, webPayment, webPrint };
|
|
22
|
+
export declare function webPayment(params: WebPaymentParams, callback: (...arg: any) => void, onError?: (error: any) => void): void;
|
package/lib/jsBridge/index.js
CHANGED
|
@@ -1,63 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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"));
|
|
9
38
|
function webPrint(params, callback, onError) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
+
});
|
|
22
51
|
}
|
|
23
|
-
/**
|
|
24
|
-
* webView页面中调用APP内的数据
|
|
25
|
-
* 此api暂时只支持native app平台下ios手机
|
|
26
|
-
* @param params
|
|
27
|
-
* @param callback
|
|
28
|
-
*/
|
|
29
52
|
function dataManager(params, callback, onError) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
53
|
+
(0, import_regDeviceApi.default)().then((jsBridge) => {
|
|
54
|
+
jsBridge.callDeviceApi({
|
|
55
|
+
apiName: "dataManager",
|
|
56
|
+
params,
|
|
57
|
+
callback: (...arg) => {
|
|
58
|
+
callback && callback(...arg);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}).catch(onError);
|
|
39
62
|
}
|
|
40
|
-
/**
|
|
41
|
-
* webView页面中调用APP内的支付
|
|
42
|
-
* 此api暂时只支持native app平台下ios
|
|
43
|
-
* @param params
|
|
44
|
-
* @param callback
|
|
45
|
-
*/
|
|
46
63
|
function webPayment(params, callback, onError) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
64
|
+
(0, import_regDeviceApi.default)().then((jsBridge) => {
|
|
65
|
+
jsBridge.callDeviceApi({
|
|
66
|
+
apiName: "webPayment",
|
|
67
|
+
params,
|
|
68
|
+
callback: (...arg) => {
|
|
69
|
+
callback && callback(...arg);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}).catch((err) => {
|
|
73
|
+
onError == null ? void 0 : onError(err);
|
|
74
|
+
console.error("webPayment", err);
|
|
75
|
+
});
|
|
59
76
|
}
|
|
60
|
-
|
|
61
|
-
exports
|
|
62
|
-
|
|
63
|
-
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
dataManager,
|
|
80
|
+
webPayment,
|
|
81
|
+
webPrint
|
|
82
|
+
});
|
|
@@ -1,94 +1,141 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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;
|
|
8
31
|
function regIosJsBridge(callback) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
if (window.WebViewJavascriptBridge) {
|
|
33
|
+
callback(window.WebViewJavascriptBridge);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (window.WVJBCallbacks) {
|
|
37
|
+
window.WVJBCallbacks.push(callback);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
window.WVJBCallbacks = [callback];
|
|
41
|
+
const WVJBIframe = document.createElement("iframe");
|
|
42
|
+
WVJBIframe.style.display = "none";
|
|
43
|
+
WVJBIframe.src = "https://__bridge_loaded__";
|
|
44
|
+
document.documentElement && document.documentElement.appendChild(WVJBIframe);
|
|
45
|
+
setTimeout(() => {
|
|
46
|
+
try {
|
|
47
|
+
document.documentElement && document.documentElement.removeChild(WVJBIframe);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
console.log(e);
|
|
50
|
+
}
|
|
51
|
+
}, 0);
|
|
29
52
|
}
|
|
30
53
|
function regAndroidJsBridge(extraInit) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
if (window._jsBridge) {
|
|
55
|
+
extraInit(window._jsBridge);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
document.addEventListener(
|
|
59
|
+
"WebViewJavascriptBridgeReady",
|
|
60
|
+
(event) => {
|
|
61
|
+
const { bridge } = event;
|
|
62
|
+
window._jsBridge = bridge;
|
|
63
|
+
if (!bridge) return;
|
|
64
|
+
bridge.init((message, responseCallback) => {
|
|
65
|
+
if (responseCallback) {
|
|
66
|
+
responseCallback("init responseCallback");
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
extraInit(bridge);
|
|
70
|
+
},
|
|
71
|
+
false
|
|
72
|
+
);
|
|
44
73
|
}
|
|
45
|
-
/**
|
|
46
|
-
* 通用jsBridge
|
|
47
|
-
* @param deviceType
|
|
48
|
-
*/
|
|
49
74
|
function getComposedBridge(deviceType) {
|
|
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
|
+
if (composedBridge) {
|
|
76
|
+
return composedBridge;
|
|
77
|
+
}
|
|
78
|
+
composedBridge = {
|
|
79
|
+
// 主动调用设备的方法
|
|
80
|
+
callDeviceApi: ({ apiName, callback: inCb, params = {}, onError }) => {
|
|
81
|
+
const callback = (res, ...args) => {
|
|
82
|
+
let result = res;
|
|
83
|
+
try {
|
|
84
|
+
result = JSON.parse(res);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
console.log(`error ${apiName}`, error);
|
|
87
|
+
}
|
|
88
|
+
inCb(result, ...args);
|
|
89
|
+
};
|
|
90
|
+
if (deviceType === "iphone") {
|
|
91
|
+
iosBridge.callHandler(apiName, params, callback, (e) => {
|
|
92
|
+
console.log(e, "--- 调用ios api报错:", apiName);
|
|
93
|
+
if (onError) {
|
|
94
|
+
onError(e);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
} else if (deviceType === "android") {
|
|
98
|
+
const res = androidBridge.callHandler(apiName, JSON.stringify(params));
|
|
99
|
+
callback(res);
|
|
100
|
+
} else {
|
|
101
|
+
console.log("--- 没获取到js bridge ---");
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
// 被设备调用的方法
|
|
105
|
+
calledByDevice: ({ apiName, callback }) => {
|
|
106
|
+
if (deviceType === "iphone") {
|
|
107
|
+
iosBridge.registerHandler(apiName, callback);
|
|
108
|
+
} else if (deviceType === "android") {
|
|
109
|
+
androidBridge.registerHandler(apiName, callback);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
return composedBridge;
|
|
75
114
|
}
|
|
76
115
|
function regDeviceApi() {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
116
|
+
return new Promise((resolve, reject) => {
|
|
117
|
+
if ((0, import_platform.isIos)() && !iosRegStatus) {
|
|
118
|
+
regIosJsBridge((bridge) => {
|
|
119
|
+
iosRegStatus = true;
|
|
120
|
+
iosBridge = bridge;
|
|
121
|
+
const realBridge = getComposedBridge("iphone");
|
|
122
|
+
resolve(realBridge);
|
|
123
|
+
});
|
|
124
|
+
} else if ((0, import_platform.isIos)() && iosRegStatus) {
|
|
125
|
+
const realBridge = getComposedBridge("iphone");
|
|
126
|
+
resolve(realBridge);
|
|
127
|
+
} else if ((0, import_platform.isAndroid)() && !androidRegStatus) {
|
|
128
|
+
regAndroidJsBridge((bridge) => {
|
|
129
|
+
androidBridge = bridge;
|
|
130
|
+
androidRegStatus = true;
|
|
131
|
+
const realBridge = getComposedBridge("android");
|
|
132
|
+
resolve(realBridge);
|
|
133
|
+
});
|
|
134
|
+
} else if ((0, import_platform.isAndroid)() && androidRegStatus) {
|
|
135
|
+
const realBridge = getComposedBridge("android");
|
|
136
|
+
resolve(realBridge);
|
|
137
|
+
} else {
|
|
138
|
+
reject();
|
|
139
|
+
}
|
|
140
|
+
});
|
|
92
141
|
}
|
|
93
|
-
//#endregion
|
|
94
|
-
exports.default = regDeviceApi;
|