@mybricks/to-code-taro 1.0.3 → 1.0.5
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/dist/cjs/core/comlib/_AesEncode.js +115 -0
- package/dist/cjs/core/comlib/_BackTo.js +80 -0
- package/dist/cjs/core/comlib/_CallPhone.js +58 -0
- package/dist/cjs/core/comlib/_ChooseFile.js +103 -0
- package/dist/cjs/core/comlib/_ChooseMedia.js +70 -0
- package/dist/cjs/core/comlib/_Connector.js +92 -0
- package/dist/cjs/core/comlib/_ConnectorGlobalHeaders.js +79 -0
- package/dist/cjs/core/comlib/_Format.js +123 -0
- package/dist/cjs/core/comlib/_GetLocation.js +60 -0
- package/dist/cjs/core/comlib/_GetStorage.js +68 -0
- package/dist/cjs/core/comlib/_GetSystemInfo.js +62 -0
- package/dist/cjs/core/comlib/_OpenCamera.js +73 -0
- package/dist/cjs/core/comlib/_OpenPetalMap.js +49 -0
- package/dist/cjs/core/comlib/_OpenUrl.js +62 -0
- package/dist/cjs/core/comlib/_RemoveStorage.js +68 -0
- package/dist/cjs/core/comlib/_Router.js +100 -0
- package/dist/cjs/core/comlib/_ScanQrcode.js +9 -10
- package/dist/cjs/core/comlib/_SetStorage.js +10 -19
- package/dist/cjs/core/comlib/_Share.js +58 -0
- package/dist/cjs/core/comlib/_ShowToast.js +23 -50
- package/dist/cjs/core/comlib/_TextToSpeech.js +120 -0
- package/dist/cjs/core/comlib/_TimerDebounce.js +72 -0
- package/dist/cjs/core/comlib/_TimerDelay.js +63 -0
- package/dist/cjs/core/comlib/_TimerThrottle.js +75 -0
- package/dist/cjs/core/comlib/_Vibrate.js +60 -0
- package/dist/cjs/core/comlib/index.js +68 -2
- package/dist/cjs/core/utils/ComContext.js +3 -3
- package/dist/cjs/core/utils/PopupRenderer.js +63 -0
- package/dist/cjs/core/utils/hooks.js +16 -14
- package/dist/cjs/core/utils/index.js +15 -3
- package/dist/cjs/core/utils/{page.js → pageRouter.js} +28 -14
- package/dist/cjs/core/utils/popupRouter.js +98 -0
- package/dist/cjs/core/utils/useContext.js +9 -1
- package/dist/cjs/core/utils/with.js +37 -13
- package/dist/cjs/generate/generateTaroProjectJson.js +30 -0
- package/dist/cjs/handleSlot.d.ts +2 -0
- package/dist/cjs/handleSlot.js +19 -5
- package/dist/cjs/processors/processComEvents.js +47 -5
- package/dist/cjs/processors/processScene.js +9 -5
- package/dist/cjs/processors/processSceneLogic.js +9 -5
- package/dist/cjs/shims-taro.d.ts +20 -0
- package/dist/cjs/taro-template.json +493 -351
- package/dist/cjs/toCodeTaro.d.ts +1 -1
- package/dist/cjs/toCodeTaro.js +13 -1
- package/dist/cjs/utils/builder/buildResult.d.ts +1 -0
- package/dist/cjs/utils/builder/buildResult.js +26 -0
- package/dist/cjs/utils/config/handlePageConfig.d.ts +2 -1
- package/dist/cjs/utils/config/handlePageConfig.js +3 -2
- package/dist/cjs/utils/context/createEventQueries.js +1 -1
- package/dist/cjs/utils/logic/handleProcess.js +26 -5
- package/dist/cjs/utils/templates/scene.d.ts +3 -1
- package/dist/cjs/utils/templates/scene.js +16 -4
- package/dist/esm/core/comlib/_AesEncode.js +85 -0
- package/dist/esm/core/comlib/_BackTo.js +66 -0
- package/dist/esm/core/comlib/_CallPhone.js +30 -0
- package/dist/esm/core/comlib/_ChooseFile.js +81 -0
- package/dist/esm/core/comlib/_ChooseMedia.js +38 -0
- package/dist/esm/core/comlib/_Connector.js +60 -0
- package/dist/esm/core/comlib/_ConnectorGlobalHeaders.js +56 -0
- package/dist/esm/core/comlib/_Format.js +102 -0
- package/dist/esm/core/comlib/_GetLocation.js +26 -0
- package/dist/esm/core/comlib/_GetStorage.js +44 -0
- package/dist/esm/core/comlib/_GetSystemInfo.js +32 -0
- package/dist/esm/core/comlib/_OpenCamera.js +44 -0
- package/dist/esm/core/comlib/_OpenPetalMap.js +28 -0
- package/dist/esm/core/comlib/_OpenUrl.js +36 -0
- package/dist/esm/core/comlib/_RemoveStorage.js +42 -0
- package/dist/esm/core/comlib/_Router.js +113 -0
- package/dist/esm/core/comlib/_ScanQrcode.js +10 -11
- package/dist/esm/core/comlib/_SetStorage.js +13 -25
- package/dist/esm/core/comlib/_Share.js +28 -0
- package/dist/esm/core/comlib/_ShowToast.js +32 -55
- package/dist/esm/core/comlib/_TextToSpeech.js +117 -0
- package/dist/esm/core/comlib/_TimerDebounce.js +66 -0
- package/dist/esm/core/comlib/_TimerDelay.js +47 -0
- package/dist/esm/core/comlib/_TimerThrottle.js +69 -0
- package/dist/esm/core/comlib/_Vibrate.js +34 -0
- package/dist/esm/core/comlib/index.js +35 -1
- package/dist/esm/core/utils/ComContext.js +1 -1
- package/dist/esm/core/utils/PopupRenderer.js +27 -0
- package/dist/esm/core/utils/hooks.js +24 -16
- package/dist/esm/core/utils/index.js +3 -1
- package/dist/esm/core/utils/pageRouter.js +69 -0
- package/dist/esm/core/utils/popupRouter.js +116 -0
- package/dist/esm/core/utils/useContext.js +14 -2
- package/dist/esm/core/utils/with.js +62 -19
- package/dist/esm/generate/generateTaroProjectJson.js +35 -1
- package/dist/esm/handleSlot.d.ts +2 -0
- package/dist/esm/handleSlot.js +20 -4
- package/dist/esm/processors/processComEvents.js +62 -5
- package/dist/esm/processors/processScene.js +11 -3
- package/dist/esm/processors/processSceneLogic.js +15 -5
- package/dist/esm/shims-taro.d.ts +20 -0
- package/dist/esm/taro-template.json +493 -351
- package/dist/esm/toCodeTaro.d.ts +1 -1
- package/dist/esm/toCodeTaro.js +16 -1
- package/dist/esm/utils/builder/buildResult.d.ts +1 -0
- package/dist/esm/utils/builder/buildResult.js +21 -0
- package/dist/esm/utils/config/handlePageConfig.d.ts +2 -1
- package/dist/esm/utils/config/handlePageConfig.js +5 -1
- package/dist/esm/utils/context/createEventQueries.js +2 -1
- package/dist/esm/utils/logic/handleProcess.js +31 -4
- package/dist/esm/utils/templates/scene.d.ts +3 -1
- package/dist/esm/utils/templates/scene.js +13 -5
- package/package.json +4 -2
- package/dist/esm/core/utils/page.js +0 -50
|
@@ -0,0 +1,115 @@
|
|
|
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/core/comlib/_AesEncode.ts
|
|
30
|
+
var AesEncode_exports = {};
|
|
31
|
+
__export(AesEncode_exports, {
|
|
32
|
+
default: () => AesEncode_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(AesEncode_exports);
|
|
35
|
+
var import_crypto_js = __toESM(require("crypto-js"));
|
|
36
|
+
var AesEncode_default = (context) => {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
const data = context.data;
|
|
39
|
+
const inputs = context.inputs;
|
|
40
|
+
const outputs = context.outputs;
|
|
41
|
+
const modeMap = {
|
|
42
|
+
CBC: import_crypto_js.default.mode.CBC,
|
|
43
|
+
ECB: import_crypto_js.default.mode.ECB,
|
|
44
|
+
CFB: import_crypto_js.default.mode.CFB,
|
|
45
|
+
OFB: import_crypto_js.default.mode.OFB,
|
|
46
|
+
CTR: import_crypto_js.default.mode.CTR
|
|
47
|
+
};
|
|
48
|
+
const paddingMap = {
|
|
49
|
+
Pkcs7: import_crypto_js.default.pad.Pkcs7,
|
|
50
|
+
Iso97971: import_crypto_js.default.pad.Iso97971,
|
|
51
|
+
AnsiX923: import_crypto_js.default.pad.AnsiX923,
|
|
52
|
+
Iso10126: import_crypto_js.default.pad.Iso10126,
|
|
53
|
+
ZeroPadding: import_crypto_js.default.pad.ZeroPadding,
|
|
54
|
+
NoPadding: import_crypto_js.default.pad.NoPadding
|
|
55
|
+
};
|
|
56
|
+
(_a = inputs.encrypt) == null ? void 0 : _a.call(inputs, (val) => {
|
|
57
|
+
try {
|
|
58
|
+
const text = val.text || "";
|
|
59
|
+
const key = val.key || data.key || "defaultKey1234567890123456";
|
|
60
|
+
const iv = val.iv || data.iv;
|
|
61
|
+
const mode = modeMap[val.mode || data.mode || "CBC"];
|
|
62
|
+
const padding = paddingMap[val.padding || data.padding || "Pkcs7"];
|
|
63
|
+
if (!text) {
|
|
64
|
+
outputs.onFail("待加密文本不能为空");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const keyBytes = import_crypto_js.default.enc.Utf8.parse(key);
|
|
68
|
+
const ivBytes = iv ? import_crypto_js.default.enc.Utf8.parse(iv) : void 0;
|
|
69
|
+
const encrypted = import_crypto_js.default.AES.encrypt(text, keyBytes, {
|
|
70
|
+
mode,
|
|
71
|
+
padding,
|
|
72
|
+
iv: ivBytes
|
|
73
|
+
});
|
|
74
|
+
outputs.onEncryptSuccess({
|
|
75
|
+
encryptedText: encrypted.toString(),
|
|
76
|
+
originalText: text
|
|
77
|
+
});
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error("AES加密失败:", error);
|
|
80
|
+
outputs.onFail((error == null ? void 0 : error.message) || "AES加密失败");
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
(_b = inputs.decrypt) == null ? void 0 : _b.call(inputs, (val) => {
|
|
84
|
+
try {
|
|
85
|
+
const encryptedText = val.encryptedText || "";
|
|
86
|
+
const key = val.key || data.key || "defaultKey1234567890123456";
|
|
87
|
+
const iv = val.iv || data.iv;
|
|
88
|
+
const mode = modeMap[val.mode || data.mode || "CBC"];
|
|
89
|
+
const padding = paddingMap[val.padding || data.padding || "Pkcs7"];
|
|
90
|
+
if (!encryptedText) {
|
|
91
|
+
outputs.onFail("待解密文本不能为空");
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const keyBytes = import_crypto_js.default.enc.Utf8.parse(key);
|
|
95
|
+
const ivBytes = iv ? import_crypto_js.default.enc.Utf8.parse(iv) : void 0;
|
|
96
|
+
const decrypted = import_crypto_js.default.AES.decrypt(encryptedText, keyBytes, {
|
|
97
|
+
mode,
|
|
98
|
+
padding,
|
|
99
|
+
iv: ivBytes
|
|
100
|
+
});
|
|
101
|
+
const decryptedText = decrypted.toString(import_crypto_js.default.enc.Utf8);
|
|
102
|
+
if (!decryptedText) {
|
|
103
|
+
outputs.onFail("解密失败,可能密钥或参数不正确");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
outputs.onDecryptSuccess({
|
|
107
|
+
decryptedText,
|
|
108
|
+
encryptedText
|
|
109
|
+
});
|
|
110
|
+
} catch (error) {
|
|
111
|
+
console.error("AES解密失败:", error);
|
|
112
|
+
outputs.onFail((error == null ? void 0 : error.message) || "AES解密失败");
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
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/core/comlib/_BackTo.ts
|
|
30
|
+
var BackTo_exports = {};
|
|
31
|
+
__export(BackTo_exports, {
|
|
32
|
+
default: () => BackTo_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(BackTo_exports);
|
|
35
|
+
var import_taro = __toESM(require("@tarojs/taro"));
|
|
36
|
+
var BackTo_default = (context) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const data = context.data;
|
|
39
|
+
const inputs = context.inputs;
|
|
40
|
+
const outputs = context.outputs;
|
|
41
|
+
(_a = inputs.back) == null ? void 0 : _a.call(inputs, (val) => {
|
|
42
|
+
try {
|
|
43
|
+
const delta = (val == null ? void 0 : val.delta) ?? data.delta ?? 1;
|
|
44
|
+
const animation = (val == null ? void 0 : val.animation) !== void 0 ? val.animation : data.animation ?? true;
|
|
45
|
+
const pages = import_taro.default.getCurrentPages();
|
|
46
|
+
const currentIndex = pages.length - 1;
|
|
47
|
+
if (currentIndex === 0) {
|
|
48
|
+
outputs.onFail("已经是首页,无法返回");
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (delta > currentIndex) {
|
|
52
|
+
outputs.onFail(`页面栈深度不足,无法返回${delta}层`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (delta === 1) {
|
|
56
|
+
import_taro.default.navigateBack({
|
|
57
|
+
delta: 1,
|
|
58
|
+
animation,
|
|
59
|
+
success: () => outputs.onSuccess({ delta: 1 }),
|
|
60
|
+
fail: (err) => outputs.onFail(err.errMsg || "返回失败")
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
const targetPage = pages[currentIndex - delta];
|
|
64
|
+
if (targetPage) {
|
|
65
|
+
import_taro.default.navigateBack({
|
|
66
|
+
delta,
|
|
67
|
+
animation,
|
|
68
|
+
success: () => outputs.onSuccess({ delta, targetPage: targetPage.route }),
|
|
69
|
+
fail: (err) => outputs.onFail(err.errMsg || "返回失败")
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
outputs.onFail("目标页面不存在");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error("返回操作失败:", error);
|
|
77
|
+
outputs.onFail((error == null ? void 0 : error.message) || "返回操作失败");
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
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/core/comlib/_CallPhone.ts
|
|
30
|
+
var CallPhone_exports = {};
|
|
31
|
+
__export(CallPhone_exports, {
|
|
32
|
+
default: () => CallPhone_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(CallPhone_exports);
|
|
35
|
+
var import_taro = __toESM(require("@tarojs/taro"));
|
|
36
|
+
var CallPhone_default = (context) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const data = context.data;
|
|
39
|
+
const inputs = context.inputs;
|
|
40
|
+
const outputs = context.outputs;
|
|
41
|
+
(_a = inputs.callPhone) == null ? void 0 : _a.call(inputs, (val) => {
|
|
42
|
+
try {
|
|
43
|
+
const phoneNumber = typeof val === "string" ? val : (val == null ? void 0 : val.phoneNumber) || data.phoneNumber;
|
|
44
|
+
if (!phoneNumber) {
|
|
45
|
+
outputs.onFail("电话号码不能为空");
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
import_taro.default.makePhoneCall({
|
|
49
|
+
phoneNumber,
|
|
50
|
+
success: () => outputs.onSuccess({ phoneNumber }),
|
|
51
|
+
fail: (err) => outputs.onFail(err.errMsg || "拨打电话失败")
|
|
52
|
+
});
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error("拨打电话失败:", error);
|
|
55
|
+
outputs.onFail((error == null ? void 0 : error.message) || "拨打电话失败");
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
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/core/comlib/_ChooseFile.ts
|
|
30
|
+
var ChooseFile_exports = {};
|
|
31
|
+
__export(ChooseFile_exports, {
|
|
32
|
+
default: () => ChooseFile_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(ChooseFile_exports);
|
|
35
|
+
var import_taro = __toESM(require("@tarojs/taro"));
|
|
36
|
+
var ChooseFile_default = (context) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const data = context.data;
|
|
39
|
+
const inputs = context.inputs;
|
|
40
|
+
const outputs = context.outputs;
|
|
41
|
+
(_a = inputs.chooseFile) == null ? void 0 : _a.call(inputs, (val) => {
|
|
42
|
+
var _a2, _b, _c;
|
|
43
|
+
try {
|
|
44
|
+
const config = {
|
|
45
|
+
accept: (val == null ? void 0 : val.accept) || data.accept || "image/*",
|
|
46
|
+
multiple: (val == null ? void 0 : val.multiple) !== void 0 ? val.multiple : data.multiple || false,
|
|
47
|
+
capture: (val == null ? void 0 : val.capture) || data.capture,
|
|
48
|
+
compressed: (val == null ? void 0 : val.compressed) !== void 0 ? val.compressed : data.compressed,
|
|
49
|
+
maxDuration: (val == null ? void 0 : val.maxDuration) || data.maxDuration,
|
|
50
|
+
camera: (val == null ? void 0 : val.camera) || data.camera
|
|
51
|
+
};
|
|
52
|
+
if ((_a2 = config.accept) == null ? void 0 : _a2.startsWith("image/")) {
|
|
53
|
+
import_taro.default.chooseImage({
|
|
54
|
+
count: config.multiple ? 9 : 1,
|
|
55
|
+
sourceType: config.capture === "album" ? ["album"] : config.capture === "camera" ? ["camera"] : ["album", "camera"],
|
|
56
|
+
success: (res) => {
|
|
57
|
+
outputs.onSuccess({
|
|
58
|
+
type: "image",
|
|
59
|
+
files: res.tempFiles,
|
|
60
|
+
tempFilePaths: res.tempFilePaths
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
fail: (err) => outputs.onFail(err.errMsg || "选择图片失败")
|
|
64
|
+
});
|
|
65
|
+
} else if ((_b = config.accept) == null ? void 0 : _b.startsWith("video/")) {
|
|
66
|
+
import_taro.default.chooseVideo({
|
|
67
|
+
sourceType: config.capture === "album" ? ["album"] : config.capture === "camera" ? ["camera"] : ["album", "camera"],
|
|
68
|
+
compressed: config.compressed,
|
|
69
|
+
maxDuration: config.maxDuration,
|
|
70
|
+
camera: config.camera,
|
|
71
|
+
success: (res) => {
|
|
72
|
+
outputs.onSuccess({
|
|
73
|
+
type: "video",
|
|
74
|
+
file: res
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
fail: (err) => outputs.onFail(err.errMsg || "选择视频失败")
|
|
78
|
+
});
|
|
79
|
+
} else if ((_c = config.accept) == null ? void 0 : _c.startsWith("audio/")) {
|
|
80
|
+
outputs.onFail("小程序暂不支持直接选择音频文件");
|
|
81
|
+
} else {
|
|
82
|
+
if (import_taro.default.chooseMessageFile) {
|
|
83
|
+
import_taro.default.chooseMessageFile({
|
|
84
|
+
count: config.multiple ? 10 : 1,
|
|
85
|
+
type: "file",
|
|
86
|
+
success: (res) => {
|
|
87
|
+
outputs.onSuccess({
|
|
88
|
+
type: "file",
|
|
89
|
+
files: res.tempFiles
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
fail: (err) => outputs.onFail(err.errMsg || "选择文件失败")
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
outputs.onFail("当前环境不支持文件选择");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error("文件选择失败:", error);
|
|
100
|
+
outputs.onFail((error == null ? void 0 : error.message) || "文件选择失败");
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
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/core/comlib/_ChooseMedia.ts
|
|
30
|
+
var ChooseMedia_exports = {};
|
|
31
|
+
__export(ChooseMedia_exports, {
|
|
32
|
+
default: () => ChooseMedia_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(ChooseMedia_exports);
|
|
35
|
+
var import_taro = __toESM(require("@tarojs/taro"));
|
|
36
|
+
var ChooseMedia_default = (context) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const data = context.data;
|
|
39
|
+
const inputs = context.inputs;
|
|
40
|
+
const outputs = context.outputs;
|
|
41
|
+
(_a = inputs.chooseMedia) == null ? void 0 : _a.call(inputs, (val) => {
|
|
42
|
+
try {
|
|
43
|
+
const config = {
|
|
44
|
+
mediaType: (val == null ? void 0 : val.mediaType) || data.mediaType || ["image", "video"],
|
|
45
|
+
sourceType: (val == null ? void 0 : val.sourceType) || data.sourceType || ["album", "camera"],
|
|
46
|
+
count: (val == null ? void 0 : val.count) || data.count || 9,
|
|
47
|
+
sizeType: (val == null ? void 0 : val.sizeType) || data.sizeType || ["original", "compressed"],
|
|
48
|
+
maxDuration: (val == null ? void 0 : val.maxDuration) || data.maxDuration || 10,
|
|
49
|
+
camera: (val == null ? void 0 : val.camera) || data.camera
|
|
50
|
+
};
|
|
51
|
+
import_taro.default.chooseMedia({
|
|
52
|
+
...config,
|
|
53
|
+
success: (res) => {
|
|
54
|
+
var _a2;
|
|
55
|
+
outputs.onSuccess({
|
|
56
|
+
type: res.type,
|
|
57
|
+
tempFiles: res.tempFiles,
|
|
58
|
+
tempFilePaths: res.tempFilePaths || ((_a2 = res.tempFiles) == null ? void 0 : _a2.map((file) => file.tempFilePath))
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
fail: (err) => {
|
|
62
|
+
outputs.onFail(err.errMsg || "选择媒体失败");
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error("选择媒体失败:", error);
|
|
67
|
+
outputs.onFail((error == null ? void 0 : error.message) || "选择媒体失败");
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
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/core/comlib/_Connector.ts
|
|
30
|
+
var Connector_exports = {};
|
|
31
|
+
__export(Connector_exports, {
|
|
32
|
+
default: () => Connector_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Connector_exports);
|
|
35
|
+
var import_taro = __toESM(require("@tarojs/taro"));
|
|
36
|
+
var Connector_default = (context) => {
|
|
37
|
+
var _a;
|
|
38
|
+
const data = context.data;
|
|
39
|
+
const inputs = context.inputs;
|
|
40
|
+
const outputs = context.outputs;
|
|
41
|
+
(_a = inputs.request) == null ? void 0 : _a.call(inputs, (val) => {
|
|
42
|
+
try {
|
|
43
|
+
const config = {
|
|
44
|
+
method: (val == null ? void 0 : val.method) || data.method || "GET",
|
|
45
|
+
url: (val == null ? void 0 : val.url) || data.url,
|
|
46
|
+
header: (val == null ? void 0 : val.headers) || data.headers || {},
|
|
47
|
+
data: (val == null ? void 0 : val.data) || data.data,
|
|
48
|
+
timeout: (val == null ? void 0 : val.timeout) || data.timeout,
|
|
49
|
+
dataType: (val == null ? void 0 : val.dataType) || data.dataType || "json",
|
|
50
|
+
responseType: (val == null ? void 0 : val.responseType) || data.responseType || "text"
|
|
51
|
+
};
|
|
52
|
+
if (!config.url) {
|
|
53
|
+
outputs.onFail("请求URL不能为空");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!/^https?:\/\//.test(config.url)) {
|
|
57
|
+
outputs.onFail("URL格式不正确,请以http://或https://开头");
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
import_taro.default.request({
|
|
61
|
+
...config,
|
|
62
|
+
success: (res) => {
|
|
63
|
+
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
64
|
+
outputs.onSuccess({
|
|
65
|
+
data: res.data,
|
|
66
|
+
statusCode: res.statusCode,
|
|
67
|
+
header: res.header
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
outputs.onFail({
|
|
71
|
+
message: `请求失败: ${res.statusCode}`,
|
|
72
|
+
statusCode: res.statusCode,
|
|
73
|
+
data: res.data
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
fail: (err) => {
|
|
78
|
+
outputs.onFail({
|
|
79
|
+
message: err.errMsg || "网络请求失败",
|
|
80
|
+
error: err
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error("网络请求失败:", error);
|
|
86
|
+
outputs.onFail({
|
|
87
|
+
message: (error == null ? void 0 : error.message) || "网络请求失败",
|
|
88
|
+
error
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/core/comlib/_ConnectorGlobalHeaders.ts
|
|
20
|
+
var ConnectorGlobalHeaders_exports = {};
|
|
21
|
+
__export(ConnectorGlobalHeaders_exports, {
|
|
22
|
+
default: () => ConnectorGlobalHeaders_default,
|
|
23
|
+
getGlobalHeaders: () => getGlobalHeaders
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(ConnectorGlobalHeaders_exports);
|
|
26
|
+
var globalHeaders = {};
|
|
27
|
+
var ConnectorGlobalHeaders_default = (context) => {
|
|
28
|
+
var _a, _b, _c;
|
|
29
|
+
const data = context.data;
|
|
30
|
+
const inputs = context.inputs;
|
|
31
|
+
const outputs = context.outputs;
|
|
32
|
+
(_a = inputs.setGlobalHeaders) == null ? void 0 : _a.call(inputs, (val) => {
|
|
33
|
+
try {
|
|
34
|
+
const headers = (val == null ? void 0 : val.headers) || data.headers || {};
|
|
35
|
+
if (Object.keys(headers).length === 0) {
|
|
36
|
+
outputs.onFail("请求头不能为空");
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
globalHeaders = { ...globalHeaders, ...headers };
|
|
40
|
+
outputs.onSuccess({
|
|
41
|
+
globalHeaders: { ...globalHeaders },
|
|
42
|
+
addedHeaders: headers
|
|
43
|
+
});
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error("设置全局请求头失败:", error);
|
|
46
|
+
outputs.onFail((error == null ? void 0 : error.message) || "设置全局请求头失败");
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
(_b = inputs.getGlobalHeaders) == null ? void 0 : _b.call(inputs, () => {
|
|
50
|
+
try {
|
|
51
|
+
outputs.onSuccess({
|
|
52
|
+
globalHeaders: { ...globalHeaders }
|
|
53
|
+
});
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error("获取全局请求头失败:", error);
|
|
56
|
+
outputs.onFail((error == null ? void 0 : error.message) || "获取全局请求头失败");
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
(_c = inputs.clearGlobalHeaders) == null ? void 0 : _c.call(inputs, () => {
|
|
60
|
+
try {
|
|
61
|
+
const oldHeaders = { ...globalHeaders };
|
|
62
|
+
globalHeaders = {};
|
|
63
|
+
outputs.onSuccess({
|
|
64
|
+
clearedHeaders: oldHeaders,
|
|
65
|
+
globalHeaders: {}
|
|
66
|
+
});
|
|
67
|
+
} catch (error) {
|
|
68
|
+
console.error("清除全局请求头失败:", error);
|
|
69
|
+
outputs.onFail((error == null ? void 0 : error.message) || "清除全局请求头失败");
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
var getGlobalHeaders = () => {
|
|
74
|
+
return { ...globalHeaders };
|
|
75
|
+
};
|
|
76
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
77
|
+
0 && (module.exports = {
|
|
78
|
+
getGlobalHeaders
|
|
79
|
+
});
|