@mybricks/to-code-taro 1.0.2 → 1.0.4
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/README.md +58 -0
- package/dist/cjs/core/comlib/_AesEncode.js +115 -0
- package/dist/cjs/core/comlib/_BackTo.js +80 -0
- package/dist/cjs/core/comlib/{Index.js → _CallPhone.js} +29 -16
- 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 +111 -0
- package/dist/cjs/core/mybricks/index.js +47 -47
- package/dist/cjs/core/utils/ComContext.js +3 -0
- package/dist/cjs/core/utils/PopupRenderer.js +63 -0
- package/dist/cjs/core/utils/hooks.js +131 -0
- package/dist/cjs/core/utils/index.js +33 -57
- package/dist/cjs/core/utils/pageRouter.js +81 -0
- package/dist/cjs/core/utils/popupRouter.js +98 -0
- package/dist/cjs/core/utils/useContext.js +11 -2
- package/dist/cjs/core/utils/with.js +37 -13
- package/dist/cjs/generate/generateTaroProjectJson.d.ts +3 -14
- package/dist/cjs/generate/generateTaroProjectJson.js +39 -6
- package/dist/cjs/generate/utils/tabBarImages.d.ts +1 -1
- package/dist/cjs/handleCom.d.ts +1 -1
- package/dist/cjs/handleCom.js +91 -177
- package/dist/cjs/handleDom.js +7 -44
- package/dist/cjs/handleExtension.d.ts +2 -2
- package/dist/cjs/handleExtension.js +5 -5
- package/dist/cjs/handleGlobal.d.ts +2 -12
- package/dist/cjs/handleGlobal.js +23 -7
- package/dist/cjs/handleModule.js +3 -3
- package/dist/cjs/handleSlot.d.ts +4 -9
- package/dist/cjs/handleSlot.js +61 -150
- package/dist/cjs/processors/processComEvents.d.ts +9 -0
- package/dist/cjs/processors/processComEvents.js +164 -0
- package/dist/cjs/processors/processModule.d.ts +31 -0
- package/dist/cjs/processors/processModule.js +125 -0
- package/dist/cjs/processors/processScene.d.ts +32 -0
- package/dist/cjs/processors/processScene.js +128 -0
- package/dist/cjs/processors/processSceneLogic.d.ts +4 -0
- package/dist/cjs/processors/processSceneLogic.js +170 -0
- package/dist/cjs/shims-taro.d.ts +20 -0
- package/dist/cjs/taro-template.json +501 -351
- package/dist/cjs/toCodeTaro.d.ts +27 -6
- package/dist/cjs/toCodeTaro.js +68 -340
- package/dist/cjs/utils/builder/buildResult.d.ts +22 -0
- package/dist/cjs/utils/builder/buildResult.js +117 -0
- package/dist/cjs/utils/common/ImportManager.d.ts +19 -0
- package/dist/cjs/utils/common/ImportManager.js +105 -0
- package/dist/cjs/utils/common/helper.d.ts +2 -0
- package/dist/cjs/utils/common/helper.js +31 -0
- package/dist/cjs/utils/common/object.d.ts +5 -0
- package/dist/cjs/utils/common/object.js +58 -0
- package/dist/cjs/utils/common/string.d.ts +8 -0
- package/dist/cjs/utils/common/string.js +46 -0
- package/dist/cjs/utils/{pageConfig → config/content}/converter.js +1 -1
- package/dist/cjs/utils/{pageConfig → config/content}/index.js +9 -9
- package/dist/cjs/utils/{pageConfig → config/content}/pageConfig.js +12 -22
- package/dist/{esm/utils/pageConfig → cjs/utils/config/content}/saveBase64Image.d.ts +1 -1
- package/dist/cjs/utils/{pageConfig → config/content}/saveBase64Image.js +8 -17
- package/dist/cjs/utils/{pageConfig → config/content}/tabBarConfig.js +9 -32
- package/dist/cjs/utils/config/content/types.js +17 -0
- package/dist/cjs/utils/{pageConfig → config/content}/validator.js +1 -1
- package/dist/{esm/utils → cjs/utils/config}/handlePageConfig.d.ts +3 -2
- package/dist/cjs/utils/{handlePageConfig.js → config/handlePageConfig.js} +7 -6
- package/dist/cjs/utils/context/buildContext.d.ts +24 -0
- package/dist/cjs/utils/context/buildContext.js +65 -0
- package/dist/cjs/utils/context/buildFrameMap.d.ts +16 -0
- package/dist/cjs/utils/context/buildFrameMap.js +106 -0
- package/dist/cjs/utils/context/buildGlobalData.d.ts +13 -0
- package/dist/cjs/utils/context/buildGlobalData.js +58 -0
- package/dist/cjs/utils/context/collectJSModules.d.ts +37 -0
- package/dist/cjs/utils/context/collectJSModules.js +91 -0
- package/dist/cjs/utils/context/createEventQueries.d.ts +45 -0
- package/dist/cjs/utils/context/createEventQueries.js +99 -0
- package/dist/cjs/utils/context/createProvider.d.ts +21 -0
- package/dist/cjs/utils/context/createProvider.js +49 -0
- package/dist/cjs/utils/index.d.ts +10 -62
- package/dist/cjs/utils/index.js +21 -282
- package/dist/cjs/utils/{convertNamespace.js → logic/convertNamespace.js} +1 -1
- package/dist/cjs/utils/{genJSModules.js → logic/genJSModules.js} +1 -1
- package/dist/{esm/utils → cjs/utils/logic}/handleProcess.d.ts +2 -2
- package/dist/cjs/utils/{handleProcess.js → logic/handleProcess.js} +40 -16
- package/dist/cjs/utils/logic/processChildren.d.ts +12 -0
- package/dist/cjs/utils/logic/processChildren.js +82 -0
- package/dist/cjs/utils/style/color.d.ts +4 -0
- package/dist/cjs/utils/style/color.js +45 -0
- package/dist/cjs/utils/style/converter.d.ts +7 -0
- package/dist/cjs/utils/style/converter.js +181 -0
- package/dist/cjs/utils/{getComponentClassName.js → style/getComponentClassName.js} +1 -1
- package/dist/cjs/utils/{pxtransform.js → style/pxtransform.js} +1 -1
- package/dist/cjs/utils/style/types.d.ts +23 -0
- package/dist/cjs/utils/{pageConfig → style}/types.js +1 -1
- package/dist/cjs/utils/{code → templates}/component.js +1 -1
- package/dist/cjs/utils/{code → templates}/index.js +4 -4
- package/dist/cjs/utils/{code → templates}/renderManager.js +1 -1
- package/dist/cjs/utils/{code → templates}/scene.d.ts +3 -1
- package/dist/cjs/utils/{code → templates}/scene.js +17 -5
- 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 +37 -0
- package/dist/esm/core/mybricks/index.js +1 -1
- package/dist/esm/core/utils/ComContext.js +1 -0
- package/dist/esm/core/utils/PopupRenderer.js +27 -0
- package/dist/esm/core/utils/hooks.js +130 -0
- package/dist/esm/core/utils/index.js +8 -57
- 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 +16 -3
- package/dist/esm/core/utils/with.js +62 -19
- package/dist/esm/generate/generateTaroProjectJson.d.ts +3 -14
- package/dist/esm/generate/generateTaroProjectJson.js +62 -24
- package/dist/esm/generate/utils/tabBarImages.d.ts +1 -1
- package/dist/esm/handleCom.d.ts +1 -1
- package/dist/esm/handleCom.js +159 -244
- package/dist/esm/handleDom.js +9 -48
- package/dist/esm/handleExtension.d.ts +2 -2
- package/dist/esm/handleExtension.js +5 -5
- package/dist/esm/handleGlobal.d.ts +2 -12
- package/dist/esm/handleGlobal.js +17 -3
- package/dist/esm/handleModule.js +3 -3
- package/dist/esm/handleSlot.d.ts +4 -9
- package/dist/esm/handleSlot.js +112 -173
- package/dist/esm/processors/processComEvents.d.ts +9 -0
- package/dist/esm/processors/processComEvents.js +167 -0
- package/dist/esm/processors/processModule.d.ts +31 -0
- package/dist/esm/processors/processModule.js +126 -0
- package/dist/esm/processors/processScene.d.ts +32 -0
- package/dist/esm/processors/processScene.js +134 -0
- package/dist/esm/processors/processSceneLogic.d.ts +4 -0
- package/dist/esm/processors/processSceneLogic.js +170 -0
- package/dist/esm/shims-taro.d.ts +20 -0
- package/dist/esm/taro-template.json +501 -351
- package/dist/esm/toCodeTaro.d.ts +27 -6
- package/dist/esm/toCodeTaro.js +110 -395
- package/dist/esm/utils/builder/buildResult.d.ts +22 -0
- package/dist/esm/utils/builder/buildResult.js +82 -0
- package/dist/esm/utils/common/ImportManager.d.ts +19 -0
- package/dist/esm/utils/common/ImportManager.js +103 -0
- package/dist/esm/utils/common/helper.d.ts +2 -0
- package/dist/esm/utils/common/helper.js +4 -0
- package/dist/esm/utils/common/object.d.ts +5 -0
- package/dist/esm/utils/common/object.js +32 -0
- package/dist/esm/utils/common/string.d.ts +8 -0
- package/dist/esm/utils/common/string.js +21 -0
- package/dist/esm/utils/config/content/pageConfig.js +40 -0
- package/dist/{cjs/utils/pageConfig → esm/utils/config/content}/saveBase64Image.d.ts +1 -1
- package/dist/esm/utils/{pageConfig → config/content}/saveBase64Image.js +11 -30
- package/dist/esm/utils/{pageConfig → config/content}/tabBarConfig.js +12 -34
- package/dist/{cjs/utils → esm/utils/config}/handlePageConfig.d.ts +3 -2
- package/dist/esm/utils/{handlePageConfig.js → config/handlePageConfig.js} +6 -2
- package/dist/esm/utils/context/buildContext.d.ts +24 -0
- package/dist/esm/utils/context/buildContext.js +53 -0
- package/dist/esm/utils/context/buildFrameMap.d.ts +16 -0
- package/dist/esm/utils/context/buildFrameMap.js +131 -0
- package/dist/esm/utils/context/buildGlobalData.d.ts +13 -0
- package/dist/esm/utils/context/buildGlobalData.js +44 -0
- package/dist/esm/utils/context/collectJSModules.d.ts +37 -0
- package/dist/esm/utils/context/collectJSModules.js +87 -0
- package/dist/esm/utils/context/createEventQueries.d.ts +45 -0
- package/dist/esm/utils/context/createEventQueries.js +99 -0
- package/dist/esm/utils/context/createProvider.d.ts +21 -0
- package/dist/esm/utils/context/createProvider.js +33 -0
- package/dist/esm/utils/index.d.ts +10 -62
- package/dist/esm/utils/index.js +12 -345
- package/dist/{cjs/utils → esm/utils/logic}/handleProcess.d.ts +2 -2
- package/dist/esm/utils/{handleProcess.js → logic/handleProcess.js} +42 -9
- package/dist/esm/utils/logic/processChildren.d.ts +12 -0
- package/dist/esm/utils/logic/processChildren.js +48 -0
- package/dist/esm/utils/style/color.d.ts +4 -0
- package/dist/esm/utils/style/color.js +17 -0
- package/dist/esm/utils/style/converter.d.ts +7 -0
- package/dist/esm/utils/style/converter.js +176 -0
- package/dist/esm/utils/style/types.d.ts +23 -0
- package/dist/esm/utils/style/types.js +1 -0
- package/dist/esm/utils/{code → templates}/scene.d.ts +3 -1
- package/dist/esm/utils/{code → templates}/scene.js +13 -5
- package/package.json +4 -2
- package/dist/esm/core/comlib/Index.js +0 -3
- package/dist/esm/utils/pageConfig/pageConfig.js +0 -60
- /package/dist/cjs/utils/{pageConfig → config/content}/converter.d.ts +0 -0
- /package/dist/cjs/utils/{pageConfig → config/content}/index.d.ts +0 -0
- /package/dist/cjs/utils/{pageConfig → config/content}/pageConfig.d.ts +0 -0
- /package/dist/cjs/utils/{pageConfig → config/content}/tabBarConfig.d.ts +0 -0
- /package/dist/cjs/utils/{pageConfig → config/content}/types.d.ts +0 -0
- /package/dist/cjs/utils/{pageConfig → config/content}/validator.d.ts +0 -0
- /package/dist/cjs/utils/{convertNamespace.d.ts → logic/convertNamespace.d.ts} +0 -0
- /package/dist/cjs/utils/{genJSModules.d.ts → logic/genJSModules.d.ts} +0 -0
- /package/dist/cjs/utils/{getComponentClassName.d.ts → style/getComponentClassName.d.ts} +0 -0
- /package/dist/cjs/utils/{pxtransform.d.ts → style/pxtransform.d.ts} +0 -0
- /package/dist/cjs/utils/{code → templates}/component.d.ts +0 -0
- /package/dist/cjs/utils/{code → templates}/index.d.ts +0 -0
- /package/dist/cjs/utils/{code → templates}/renderManager.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/converter.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/converter.js +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/index.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/index.js +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/pageConfig.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/tabBarConfig.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/types.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/types.js +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/validator.d.ts +0 -0
- /package/dist/esm/utils/{pageConfig → config/content}/validator.js +0 -0
- /package/dist/esm/utils/{convertNamespace.d.ts → logic/convertNamespace.d.ts} +0 -0
- /package/dist/esm/utils/{convertNamespace.js → logic/convertNamespace.js} +0 -0
- /package/dist/esm/utils/{genJSModules.d.ts → logic/genJSModules.d.ts} +0 -0
- /package/dist/esm/utils/{genJSModules.js → logic/genJSModules.js} +0 -0
- /package/dist/esm/utils/{getComponentClassName.d.ts → style/getComponentClassName.d.ts} +0 -0
- /package/dist/esm/utils/{getComponentClassName.js → style/getComponentClassName.js} +0 -0
- /package/dist/esm/utils/{pxtransform.d.ts → style/pxtransform.d.ts} +0 -0
- /package/dist/esm/utils/{pxtransform.js → style/pxtransform.js} +0 -0
- /package/dist/esm/utils/{code → templates}/component.d.ts +0 -0
- /package/dist/esm/utils/{code → templates}/component.js +0 -0
- /package/dist/esm/utils/{code → templates}/index.d.ts +0 -0
- /package/dist/esm/utils/{code → templates}/index.js +0 -0
- /package/dist/esm/utils/{code → templates}/renderManager.d.ts +0 -0
- /package/dist/esm/utils/{code → templates}/renderManager.js +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# MyBricks To Code Taro
|
|
2
|
+
|
|
3
|
+
MyBricks Taro 代码生成插件,负责将 MyBricks 的 DSL (JSON) 转换为完整的 Taro 项目代码。
|
|
4
|
+
|
|
5
|
+
## 核心功能
|
|
6
|
+
|
|
7
|
+
- **DSL 转换**: 解析 MyBricks 协议,生成符合 Taro 规范的 TSX、Less 和配置。
|
|
8
|
+
- **项目组装**: 基于内置模板,自动生成完整的 Taro 项目文件结构。
|
|
9
|
+
- **依赖管理**: 自动分析并注入页面所需的组件和工具库依赖。
|
|
10
|
+
- **响应式支持**: 深度集成 MyBricks 逻辑流,支持变量、Fx、事件流与页面生命周期的自动绑定。
|
|
11
|
+
|
|
12
|
+
## 开发指南
|
|
13
|
+
|
|
14
|
+
### 常用命令
|
|
15
|
+
|
|
16
|
+
#### 1. 开发模式
|
|
17
|
+
```bash
|
|
18
|
+
npm run dev
|
|
19
|
+
```
|
|
20
|
+
启动 `father dev`,在开发过程中实时编译代码。
|
|
21
|
+
|
|
22
|
+
#### 2. 项目构建
|
|
23
|
+
```bash
|
|
24
|
+
npm run build
|
|
25
|
+
```
|
|
26
|
+
执行生产环境构建,生成 `dist` 目录下的产物。
|
|
27
|
+
|
|
28
|
+
#### 3. 运行通用测试
|
|
29
|
+
```bash
|
|
30
|
+
npm run test
|
|
31
|
+
```
|
|
32
|
+
运行 `test/index.ts`,验证核心转换逻辑是否正确(不输出物理文件)。
|
|
33
|
+
|
|
34
|
+
#### 4. 生成测试项目 (常用)
|
|
35
|
+
```bash
|
|
36
|
+
npm run test:project
|
|
37
|
+
```
|
|
38
|
+
执行 `test/genProject.ts`,根据 `test/test-data.json` 生成完整的物理 Taro 项目。
|
|
39
|
+
生成的产物将放在 `src/_output/project` 目录下,您可以直接将该目录拷贝到 Taro 开发环境中运行。
|
|
40
|
+
|
|
41
|
+
#### 5. 重新生成项目模板
|
|
42
|
+
```bash
|
|
43
|
+
npm run test:template
|
|
44
|
+
```
|
|
45
|
+
执行 `test/genTemplate.ts`。当您修改了 `src/_template` 目录下的基础模板文件后,**必须运行此命令**,以同步更新 `src/taro-template.json`。这个 JSON 文件是生成完整项目时的骨架。
|
|
46
|
+
|
|
47
|
+
## 项目结构
|
|
48
|
+
|
|
49
|
+
- `src/core`: 运行时核心工具库(由生成项目引用)。
|
|
50
|
+
- `src/utils`: 生成器内部使用的各种转换工具。
|
|
51
|
+
- `src/processors`: 场景、模块、事件等具体维度的处理逻辑。
|
|
52
|
+
- `src/_template`: 项目生成的基础骨架模板。
|
|
53
|
+
- `test/`: 包含测试数据和用于验证生成的脚本。
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
MyBricks Team
|
|
58
|
+
|
|
@@ -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
|
+
};
|
|
@@ -26,20 +26,33 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
28
|
|
|
29
|
-
// src/core/comlib/
|
|
30
|
-
var
|
|
31
|
-
__export(
|
|
32
|
-
|
|
33
|
-
mybricks_taro_setStorage: () => import_SetStorage.default,
|
|
34
|
-
mybricks_taro_showToast: () => import_ShowToast.default
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(Index_exports);
|
|
37
|
-
var import_ShowToast = __toESM(require("./_ShowToast"));
|
|
38
|
-
var import_ScanQrcode = __toESM(require("./_ScanQrcode"));
|
|
39
|
-
var import_SetStorage = __toESM(require("./_SetStorage"));
|
|
40
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
-
0 && (module.exports = {
|
|
42
|
-
mybricks_taro_scanQrcode,
|
|
43
|
-
mybricks_taro_setStorage,
|
|
44
|
-
mybricks_taro_showToast
|
|
29
|
+
// src/core/comlib/_CallPhone.ts
|
|
30
|
+
var CallPhone_exports = {};
|
|
31
|
+
__export(CallPhone_exports, {
|
|
32
|
+
default: () => CallPhone_default
|
|
45
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
|
+
});
|