@mybricks/to-code-taro 1.1.4 → 1.1.6
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/mybricks/Subject.js +9 -5
- package/dist/cjs/core/mybricks/createJSHandle.js +45 -4
- package/dist/cjs/core/utils/comRefResolver.js +112 -0
- package/dist/cjs/core/utils/event.js +53 -0
- package/dist/cjs/core/utils/hooks.js +76 -39
- package/dist/cjs/core/utils/index.js +6 -0
- package/dist/cjs/core/utils/pageRouter.js +34 -11
- package/dist/cjs/core/utils/pool.js +63 -0
- package/dist/cjs/core/utils/slots.js +59 -13
- package/dist/cjs/core/utils/tabbar.js +56 -0
- package/dist/cjs/core/utils/useContext.js +46 -4
- package/dist/cjs/core/utils/with.js +9 -34
- package/dist/cjs/generate/generateTaroProjectJson.js +11 -18
- package/dist/cjs/generate/utils/appConfig.d.ts +1 -1
- package/dist/cjs/generate/utils/appConfig.js +23 -12
- package/dist/cjs/generate/utils/commonDir.js +9 -0
- package/dist/cjs/generate/utils/customTabBar.d.ts +11 -0
- package/dist/cjs/generate/utils/customTabBar.js +73 -0
- package/dist/cjs/generate/utils/fileNode.d.ts +4 -0
- package/dist/cjs/generate/utils/fileNode.js +12 -2
- package/dist/cjs/handleCom.js +15 -16
- package/dist/cjs/handleGlobal.d.ts +1 -1
- package/dist/cjs/handleGlobal.js +6 -0
- package/dist/cjs/handleSlot.js +4 -9
- package/dist/cjs/processors/processScene.js +13 -1
- package/dist/cjs/processors/processSceneLogic.js +2 -6
- package/dist/cjs/taro-template.json +1318 -1016
- package/dist/cjs/toCodeTaro.d.ts +1 -2
- package/dist/cjs/toCodeTaro.js +2 -0
- package/dist/cjs/utils/builder/buildResult.d.ts +1 -0
- package/dist/cjs/utils/builder/buildResult.js +54 -2
- package/dist/cjs/utils/common/ImportManager.d.ts +7 -0
- package/dist/cjs/utils/common/ImportManager.js +19 -1
- package/dist/cjs/utils/context/buildContext.d.ts +7 -0
- package/dist/cjs/utils/context/buildContext.js +11 -0
- package/dist/cjs/utils/logic/genJSModules.js +2 -2
- package/dist/cjs/utils/logic/handleProcess.js +54 -12
- package/dist/cjs/utils/templates/renderManager.js +4 -2
- package/dist/esm/core/mybricks/Subject.js +11 -5
- package/dist/esm/core/mybricks/createJSHandle.js +57 -6
- package/dist/esm/core/utils/comRefResolver.js +134 -0
- package/dist/esm/core/utils/event.js +32 -0
- package/dist/esm/core/utils/hooks.js +114 -51
- package/dist/esm/core/utils/index.js +2 -0
- package/dist/esm/core/utils/pageRouter.js +56 -13
- package/dist/esm/core/utils/pool.js +52 -0
- package/dist/esm/core/utils/slots.js +82 -16
- package/dist/esm/core/utils/tabbar.js +47 -0
- package/dist/esm/core/utils/useContext.js +53 -4
- package/dist/esm/core/utils/with.js +19 -53
- package/dist/esm/generate/generateTaroProjectJson.js +14 -20
- package/dist/esm/generate/utils/appConfig.d.ts +1 -1
- package/dist/esm/generate/utils/appConfig.js +29 -9
- package/dist/esm/generate/utils/commonDir.js +13 -0
- package/dist/esm/generate/utils/customTabBar.d.ts +11 -0
- package/dist/esm/generate/utils/customTabBar.js +52 -0
- package/dist/esm/generate/utils/fileNode.d.ts +4 -0
- package/dist/esm/generate/utils/fileNode.js +13 -0
- package/dist/esm/handleCom.js +24 -21
- package/dist/esm/handleGlobal.d.ts +1 -1
- package/dist/esm/handleGlobal.js +6 -1
- package/dist/esm/handleSlot.js +6 -11
- package/dist/esm/processors/processScene.js +23 -3
- package/dist/esm/processors/processSceneLogic.js +3 -5
- package/dist/esm/taro-template.json +1318 -1016
- package/dist/esm/toCodeTaro.d.ts +1 -2
- package/dist/esm/toCodeTaro.js +4 -2
- package/dist/esm/utils/builder/buildResult.d.ts +1 -0
- package/dist/esm/utils/builder/buildResult.js +42 -3
- package/dist/esm/utils/common/ImportManager.d.ts +7 -0
- package/dist/esm/utils/common/ImportManager.js +42 -14
- package/dist/esm/utils/context/buildContext.d.ts +7 -0
- package/dist/esm/utils/context/buildContext.js +12 -0
- package/dist/esm/utils/logic/genJSModules.js +2 -2
- package/dist/esm/utils/logic/handleProcess.js +66 -12
- package/dist/esm/utils/templates/renderManager.js +4 -4
- package/package.json +1 -1
- package/dist/cjs/core/comlib/Index.js +0 -114
- package/dist/cjs/core/comlib/_AesEncode.js +0 -115
- package/dist/cjs/core/comlib/_BackTo.js +0 -80
- package/dist/cjs/core/comlib/_CallPhone.js +0 -58
- package/dist/cjs/core/comlib/_ChooseFile.js +0 -103
- package/dist/cjs/core/comlib/_ChooseMedia.js +0 -70
- package/dist/cjs/core/comlib/_Connector.js +0 -92
- package/dist/cjs/core/comlib/_ConnectorGlobalHeaders.js +0 -79
- package/dist/cjs/core/comlib/_Format.js +0 -123
- package/dist/cjs/core/comlib/_GetLocation.js +0 -60
- package/dist/cjs/core/comlib/_GetStorage.js +0 -68
- package/dist/cjs/core/comlib/_GetSystemInfo.js +0 -62
- package/dist/cjs/core/comlib/_Modal.js +0 -68
- package/dist/cjs/core/comlib/_OpenCamera.js +0 -73
- package/dist/cjs/core/comlib/_OpenPetalMap.js +0 -49
- package/dist/cjs/core/comlib/_OpenUrl.js +0 -62
- package/dist/cjs/core/comlib/_RemoveStorage.js +0 -68
- package/dist/cjs/core/comlib/_Router.js +0 -100
- package/dist/cjs/core/comlib/_ScanQrcode.js +0 -59
- package/dist/cjs/core/comlib/_SetStorage.js +0 -67
- package/dist/cjs/core/comlib/_Share.js +0 -58
- package/dist/cjs/core/comlib/_ShowToast.js +0 -69
- package/dist/cjs/core/comlib/_TextToSpeech.js +0 -120
- package/dist/cjs/core/comlib/_TimerDebounce.js +0 -72
- package/dist/cjs/core/comlib/_TimerDelay.js +0 -88
- package/dist/cjs/core/comlib/_TimerThrottle.js +0 -75
- package/dist/cjs/core/comlib/_Vibrate.js +0 -60
- package/dist/esm/abstractEventTypeDef.d.ts.map +0 -1
- package/dist/esm/core/comlib/Index.js +0 -39
- package/dist/esm/core/comlib/_AesEncode.js +0 -85
- package/dist/esm/core/comlib/_BackTo.js +0 -66
- package/dist/esm/core/comlib/_CallPhone.js +0 -30
- package/dist/esm/core/comlib/_ChooseFile.js +0 -81
- package/dist/esm/core/comlib/_ChooseMedia.js +0 -38
- package/dist/esm/core/comlib/_Connector.js +0 -60
- package/dist/esm/core/comlib/_ConnectorGlobalHeaders.js +0 -56
- package/dist/esm/core/comlib/_Format.js +0 -102
- package/dist/esm/core/comlib/_GetLocation.js +0 -26
- package/dist/esm/core/comlib/_GetStorage.js +0 -44
- package/dist/esm/core/comlib/_GetSystemInfo.js +0 -32
- package/dist/esm/core/comlib/_Modal.js +0 -51
- package/dist/esm/core/comlib/_OpenCamera.js +0 -44
- package/dist/esm/core/comlib/_OpenPetalMap.js +0 -28
- package/dist/esm/core/comlib/_OpenUrl.js +0 -36
- package/dist/esm/core/comlib/_RemoveStorage.js +0 -42
- package/dist/esm/core/comlib/_Router.js +0 -113
- package/dist/esm/core/comlib/_ScanQrcode.js +0 -26
- package/dist/esm/core/comlib/_SetStorage.js +0 -40
- package/dist/esm/core/comlib/_Share.js +0 -28
- package/dist/esm/core/comlib/_ShowToast.js +0 -45
- package/dist/esm/core/comlib/_TextToSpeech.js +0 -117
- package/dist/esm/core/comlib/_TimerDebounce.js +0 -66
- package/dist/esm/core/comlib/_TimerDelay.js +0 -79
- package/dist/esm/core/comlib/_TimerThrottle.js +0 -69
- package/dist/esm/core/comlib/_Vibrate.js +0 -34
- package/dist/esm/generate/generateTaroTempalteJson.d.ts.map +0 -1
- package/dist/esm/generate/utils/appConfig.d.ts.map +0 -1
- package/dist/esm/generate/utils/fileNode.d.ts.map +0 -1
- package/dist/esm/generate/utils/index.d.ts.map +0 -1
- package/dist/esm/generate/utils/pageImages.d.ts.map +0 -1
- package/dist/esm/generate/utils/tabBarImages.d.ts.map +0 -1
- package/dist/esm/handleExtension.d.ts.map +0 -1
- package/dist/esm/handleModule.d.ts.map +0 -1
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/processors/processComEvents.d.ts.map +0 -1
- package/dist/esm/processors/processModule.d.ts.map +0 -1
- package/dist/esm/processors/processScene.d.ts.map +0 -1
- package/dist/esm/processors/processSceneLogic.d.ts.map +0 -1
- package/dist/esm/toCodeTaro.d.ts.map +0 -1
- package/dist/esm/utils/builder/buildResult.d.ts.map +0 -1
- package/dist/esm/utils/common/ImportManager.d.ts.map +0 -1
- package/dist/esm/utils/common/helper.d.ts.map +0 -1
- package/dist/esm/utils/common/object.d.ts.map +0 -1
- package/dist/esm/utils/common/string.d.ts.map +0 -1
- package/dist/esm/utils/config/content/index.d.ts.map +0 -1
- package/dist/esm/utils/config/content/types.d.ts.map +0 -1
- package/dist/esm/utils/config/content/validator.d.ts.map +0 -1
- package/dist/esm/utils/config/handlePageConfig.d.ts.map +0 -1
- package/dist/esm/utils/context/buildContext.d.ts.map +0 -1
- package/dist/esm/utils/context/buildFrameMap.d.ts.map +0 -1
- package/dist/esm/utils/context/buildGlobalData.d.ts.map +0 -1
- package/dist/esm/utils/context/collectJSModules.d.ts.map +0 -1
- package/dist/esm/utils/context/createEventQueries.d.ts.map +0 -1
- package/dist/esm/utils/context/createProvider.d.ts.map +0 -1
- package/dist/esm/utils/index.d.ts.map +0 -1
- package/dist/esm/utils/logic/convertNamespace.d.ts.map +0 -1
- package/dist/esm/utils/logic/genJSModules.d.ts.map +0 -1
- package/dist/esm/utils/style/color.d.ts.map +0 -1
- package/dist/esm/utils/style/getComponentClassName.d.ts.map +0 -1
- package/dist/esm/utils/style/pxtransform.d.ts.map +0 -1
- package/dist/esm/utils/style/types.d.ts.map +0 -1
- package/dist/esm/utils/templates/component.d.ts.map +0 -1
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
4
|
+
import { EventEmitter } from "./event";
|
|
5
|
+
var isDefine = function isDefine(val) {
|
|
6
|
+
return val !== undefined && val !== null && val !== '';
|
|
7
|
+
};
|
|
8
|
+
var TabbarInstance = /*#__PURE__*/_createClass(function TabbarInstance() {
|
|
9
|
+
var _this = this;
|
|
10
|
+
_classCallCheck(this, TabbarInstance);
|
|
11
|
+
_defineProperty(this, "list", []);
|
|
12
|
+
_defineProperty(this, "eventEmitter", new EventEmitter());
|
|
13
|
+
_defineProperty(this, "setTabBarBadge", function (_ref) {
|
|
14
|
+
var index = _ref.index,
|
|
15
|
+
text = _ref.text;
|
|
16
|
+
return new Promise(function (resolve, reject) {
|
|
17
|
+
if (isDefine(index)) {
|
|
18
|
+
_this.list[index].active = true;
|
|
19
|
+
_this.list[index].activeText = text;
|
|
20
|
+
console.log('change', _this.list);
|
|
21
|
+
_this.eventEmitter.dispatch('change', _this.list);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
_defineProperty(this, "hideTabBarRedDot", function (_ref2) {
|
|
26
|
+
var index = _ref2.index;
|
|
27
|
+
return new Promise(function (resolve, reject) {
|
|
28
|
+
if (isDefine(index)) {
|
|
29
|
+
_this.list[index].active = false;
|
|
30
|
+
_this.list[index].activeText = 0;
|
|
31
|
+
_this.eventEmitter.dispatch('change', _this.list);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
_defineProperty(this, "removeTabBarBadge", this.hideTabBarRedDot);
|
|
36
|
+
_defineProperty(this, "initWithLength", function (len) {
|
|
37
|
+
_this.list = new Array(len).fill(function (t) {
|
|
38
|
+
return null;
|
|
39
|
+
}).map(function () {
|
|
40
|
+
return {
|
|
41
|
+
active: false,
|
|
42
|
+
activeText: ''
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
export var tabbarIns = new TabbarInstance();
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
1
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
var _excluded = ["success", "fail"];
|
|
2
5
|
import { useRef, useState, useMemo } from 'react';
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
import * as Taro from '@tarojs/taro';
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
import { request as _request } from '@/common/request';
|
|
10
|
+
import { tabbarIns } from "@/core/utils/tabbar";
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
import rootConfig from '@/common/rootConfig';
|
|
3
13
|
import { proxyRefs } from "./hooks";
|
|
4
|
-
|
|
14
|
+
import { TodoPool } from "./pool";
|
|
5
15
|
export function useAppCreateContext(id) {
|
|
6
|
-
var
|
|
16
|
+
var todoPool = useMemo(function () {
|
|
17
|
+
return new TodoPool();
|
|
18
|
+
}, []);
|
|
7
19
|
var comRefs = useRef(proxyRefs({
|
|
8
20
|
$inputs: {},
|
|
9
21
|
$outputs: {}
|
|
10
|
-
}, undefined,
|
|
22
|
+
}, undefined, todoPool));
|
|
11
23
|
var $vars = useRef({});
|
|
12
24
|
var $fxs = useRef({});
|
|
13
25
|
var _useState = useState({
|
|
@@ -26,6 +38,43 @@ export function useAppCreateContext(id) {
|
|
|
26
38
|
runtime: {
|
|
27
39
|
debug: false
|
|
28
40
|
},
|
|
41
|
+
env: {
|
|
42
|
+
runtime: true,
|
|
43
|
+
request: function request(connector, params, config) {
|
|
44
|
+
return _request(connector, params, config, {
|
|
45
|
+
$vars: $vars
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
tabbar: tabbarIns,
|
|
49
|
+
uploadFile: function uploadFile(params) {
|
|
50
|
+
var _rootConfig$status;
|
|
51
|
+
var header = {};
|
|
52
|
+
var mybricksGlobalHeaders = Taro.getStorageSync("_MYBRICKS_GLOBAL_HEADERS_");
|
|
53
|
+
if (mybricksGlobalHeaders) {
|
|
54
|
+
header = _objectSpread(_objectSpread({}, mybricksGlobalHeaders), header);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 如果 url 不以 http 开头,添加默认域名
|
|
59
|
+
*/
|
|
60
|
+
if (!/^(http|https):\/\/.*/.test(params.url) && rootConfig !== null && rootConfig !== void 0 && (_rootConfig$status = rootConfig.status) !== null && _rootConfig$status !== void 0 && _rootConfig$status.defaultCallServiceHost) {
|
|
61
|
+
var _rootConfig$status2;
|
|
62
|
+
params.url = "".concat(rootConfig === null || rootConfig === void 0 || (_rootConfig$status2 = rootConfig.status) === null || _rootConfig$status2 === void 0 ? void 0 : _rootConfig$status2.defaultCallServiceHost).concat(params.url);
|
|
63
|
+
}
|
|
64
|
+
var _success = params.success,
|
|
65
|
+
_fail = params.fail,
|
|
66
|
+
rest = _objectWithoutProperties(params, _excluded);
|
|
67
|
+
Taro.uploadFile(_objectSpread(_objectSpread({}, rest), {}, {
|
|
68
|
+
success: function success(res) {
|
|
69
|
+
return _success === null || _success === void 0 ? void 0 : _success(res);
|
|
70
|
+
},
|
|
71
|
+
fail: function fail(err) {
|
|
72
|
+
return _fail === null || _fail === void 0 ? void 0 : _fail(err);
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
rootScroll: {},
|
|
29
78
|
edit: false,
|
|
30
79
|
isH5: false,
|
|
31
80
|
isDesigner: false,
|
|
@@ -42,7 +91,7 @@ export function useAppCreateContext(id) {
|
|
|
42
91
|
comRefs: comRefs,
|
|
43
92
|
$vars: $vars,
|
|
44
93
|
$fxs: $fxs,
|
|
45
|
-
|
|
94
|
+
todoPool: todoPool,
|
|
46
95
|
appContext: appContext,
|
|
47
96
|
popupState: popupState,
|
|
48
97
|
setPopupState: setPopupState
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
5
|
var _excluded = ["component", "id", "data", "className", "style"],
|
|
@@ -7,14 +7,14 @@ var _excluded = ["component", "id", "data", "className", "style"],
|
|
|
7
7
|
import React, { useState, useEffect } from 'react';
|
|
8
8
|
// @ts-ignore 运行时由宿主项目提供 @tarojs/components
|
|
9
9
|
import { View } from '@tarojs/components';
|
|
10
|
-
import { useModel, useBindInputs,
|
|
10
|
+
import { useModel, useBindInputs, useBuiltinHandlers, useBindOutputs, subscribePopupRouter, closeActivePopupRouter } from "./index";
|
|
11
11
|
import { useAppCreateContext } from "./useContext";
|
|
12
12
|
import ComContext, { useAppContext } from "./ComContext";
|
|
13
13
|
import { useEnhancedSlots, useResolvedParentSlot } from "./slots";
|
|
14
14
|
// @ts-ignore 运行时由宿主项目提供 @tarojs/taro
|
|
15
15
|
import { useTabItemTap } from '@tarojs/taro';
|
|
16
16
|
export var WithCom = function WithCom(props) {
|
|
17
|
-
var
|
|
17
|
+
var _parentSlot$params;
|
|
18
18
|
var Component = props.component,
|
|
19
19
|
_props$id = props.id,
|
|
20
20
|
id = _props$id === void 0 ? '' : _props$id,
|
|
@@ -39,66 +39,33 @@ export var WithCom = function WithCom(props) {
|
|
|
39
39
|
|
|
40
40
|
//数据模型
|
|
41
41
|
var _data = useModel(data || {});
|
|
42
|
-
|
|
43
|
-
// 内置通用能力
|
|
44
|
-
var handlers = {
|
|
45
|
-
_setStyle: function _setStyle(style) {
|
|
46
|
-
setDynamicStyle(function (prev) {
|
|
47
|
-
return _objectSpread(_objectSpread({}, prev), style);
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
_setData: function _setData(path, value) {
|
|
51
|
-
var paths = path.split('.');
|
|
52
|
-
var current = _data;
|
|
53
|
-
for (var i = 0; i < paths.length - 1; i++) {
|
|
54
|
-
if (!current[paths[i]]) current[paths[i]] = {};
|
|
55
|
-
current = current[paths[i]];
|
|
56
|
-
}
|
|
57
|
-
current[paths[paths.length - 1]] = value;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
if (!isPopup) {
|
|
61
|
-
Object.assign(handlers, {
|
|
62
|
-
show: function show() {
|
|
63
|
-
return setShow(true);
|
|
64
|
-
},
|
|
65
|
-
hide: function hide() {
|
|
66
|
-
return setShow(false);
|
|
67
|
-
},
|
|
68
|
-
showOrHide: function showOrHide() {
|
|
69
|
-
return setShow(function (prev) {
|
|
70
|
-
return !prev;
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// 绑定输入,传入初始 handlers
|
|
77
|
-
var inputProxy = useBindInputs(comRefs, id, handlers);
|
|
78
42
|
var _ref = rest,
|
|
79
43
|
rawSlots = _ref.slots,
|
|
80
44
|
parentSlotProp = _ref.parentSlot,
|
|
81
45
|
restProps = _objectWithoutProperties(_ref, _excluded2);
|
|
82
46
|
var parentSlot = useResolvedParentSlot(parentSlotProp);
|
|
47
|
+
var enhancedSlots = useEnhancedSlots(rawSlots, id);
|
|
83
48
|
|
|
84
|
-
//
|
|
85
|
-
var
|
|
49
|
+
// ---- inputs ----
|
|
50
|
+
var handlers = useBuiltinHandlers({
|
|
51
|
+
data: _data,
|
|
52
|
+
setDynamicStyle: setDynamicStyle,
|
|
53
|
+
setShow: setShow,
|
|
54
|
+
isPopup: isPopup
|
|
55
|
+
});
|
|
56
|
+
var inputProxy = useBindInputs(comRefs, id, handlers);
|
|
57
|
+
|
|
58
|
+
// ---- outputs ----
|
|
59
|
+
var outputProxy = useBindOutputs(comRefs, id, restProps, enhancedSlots, {
|
|
86
60
|
id: id,
|
|
87
61
|
name: props.name || id,
|
|
88
62
|
parentSlot: parentSlot
|
|
89
63
|
});
|
|
90
64
|
|
|
91
|
-
//
|
|
92
|
-
if (comRefs !== null && comRefs !== void 0 && (_comRefs$current = comRefs.current) !== null && _comRefs$current !== void 0 && _comRefs$current.$outputs) {
|
|
93
|
-
comRefs.current.$outputs[id] = eventProxy;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// 鸿蒙规范:确保 comRefs 中挂载的是最新的 inputProxy
|
|
97
|
-
comRefs.current[id] = inputProxy;
|
|
98
|
-
var enhancedSlots = useEnhancedSlots(rawSlots, id);
|
|
65
|
+
// ---- render ----
|
|
99
66
|
var jsx = /*#__PURE__*/React.createElement(Component, _extends({}, restProps, {
|
|
100
67
|
inputs: inputProxy,
|
|
101
|
-
outputs:
|
|
68
|
+
outputs: outputProxy,
|
|
102
69
|
slots: enhancedSlots,
|
|
103
70
|
parentSlot: parentSlot,
|
|
104
71
|
data: _data,
|
|
@@ -106,8 +73,6 @@ export var WithCom = function WithCom(props) {
|
|
|
106
73
|
id: id,
|
|
107
74
|
style: style
|
|
108
75
|
}));
|
|
109
|
-
|
|
110
|
-
// 鸿蒙化处理:支持 itemWrap 协议
|
|
111
76
|
if (parentSlot !== null && parentSlot !== void 0 && (_parentSlot$params = parentSlot.params) !== null && _parentSlot$params !== void 0 && _parentSlot$params.itemWrap) {
|
|
112
77
|
return parentSlot.params.itemWrap({
|
|
113
78
|
id: id,
|
|
@@ -115,11 +80,12 @@ export var WithCom = function WithCom(props) {
|
|
|
115
80
|
jsx: jsx,
|
|
116
81
|
def: Component.def,
|
|
117
82
|
inputs: inputProxy,
|
|
118
|
-
outputs:
|
|
83
|
+
outputs: outputProxy,
|
|
119
84
|
style: style
|
|
120
85
|
});
|
|
121
86
|
}
|
|
122
87
|
return show || isPopup ? /*#__PURE__*/React.createElement(View, {
|
|
88
|
+
id: id,
|
|
123
89
|
className: className,
|
|
124
90
|
style: _objectSpread(_objectSpread({}, style), dynamicStyle)
|
|
125
91
|
}, jsx, props.children) : null;
|
|
@@ -6,6 +6,7 @@ import { handleCommonDir } from "./utils/commonDir";
|
|
|
6
6
|
import { handleTabBarImages } from "./utils/tabBarImages";
|
|
7
7
|
import { handlePageImages } from "./utils/pageImages";
|
|
8
8
|
import { updateAppConfig } from "./utils/appConfig";
|
|
9
|
+
import { updateCustomTabBar } from "./utils/customTabBar";
|
|
9
10
|
import { genScopedJSModules } from "../utils/logic/genJSModules";
|
|
10
11
|
/**
|
|
11
12
|
* 根据数组生成文件结构 JSON 对象
|
|
@@ -143,30 +144,23 @@ var generateTaroProjectJson = function generateTaroProjectJson(result) {
|
|
|
143
144
|
handlePageImages(assetsDir, pageImages);
|
|
144
145
|
|
|
145
146
|
// 替换自定义 Tabbar 配置文件
|
|
146
|
-
|
|
147
|
-
var customTabBarItem = files.find(function (item) {
|
|
148
|
-
return item.type === 'customTabBar';
|
|
149
|
-
});
|
|
150
|
-
if (customTabBarItem !== null && customTabBarItem !== void 0 && customTabBarItem.content) {
|
|
151
|
-
var _mybricksDir$children;
|
|
152
|
-
var customTabBarDir = ensureDir(srcDir, "src/custom-tab-bar");
|
|
153
|
-
var mybricksDir = ensureDir(customTabBarDir, "src/custom-tab-bar/mybricks");
|
|
154
|
-
var tabbarConfigFileIndex = (_mybricksDir$children = mybricksDir.children) === null || _mybricksDir$children === void 0 ? void 0 : _mybricksDir$children.findIndex(function (node) {
|
|
155
|
-
return node.path === CUSTOM_TAB_BAR_CONFIG_PATH;
|
|
156
|
-
});
|
|
157
|
-
if (tabbarConfigFileIndex === -1) {
|
|
158
|
-
mybricksDir.children.push({
|
|
159
|
-
path: CUSTOM_TAB_BAR_CONFIG_PATH,
|
|
160
|
-
content: customTabBarItem.content
|
|
161
|
-
});
|
|
162
|
-
} else {
|
|
163
|
-
mybricksDir.children[tabbarConfigFileIndex].content = customTabBarItem.content;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
147
|
+
updateCustomTabBar(srcDir, files);
|
|
166
148
|
|
|
167
149
|
// 处理 common 目录下的文件
|
|
168
150
|
handleCommonDir(commonDir, files);
|
|
169
151
|
|
|
152
|
+
// 处理 common 目录下的 api.ts
|
|
153
|
+
var apiItem = files.find(function (item) {
|
|
154
|
+
return item.type === 'connector-api';
|
|
155
|
+
});
|
|
156
|
+
if (apiItem) {
|
|
157
|
+
commonDir.children = commonDir.children || [];
|
|
158
|
+
commonDir.children.push({
|
|
159
|
+
path: 'src/common/api.ts',
|
|
160
|
+
content: apiItem.content
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
170
164
|
// 处理 popup 汇总文件 (type 为 popup 且无 meta)
|
|
171
165
|
var popupFile = files.find(function (f) {
|
|
172
166
|
return f.type === "popup" && !f.meta;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { parseLooseObject } from "./fileNode";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* app.config.ts 更新工具
|
|
3
5
|
*/
|
|
@@ -6,25 +8,43 @@
|
|
|
6
8
|
* 更新 app.config.ts
|
|
7
9
|
*/
|
|
8
10
|
export function updateAppConfig(appConfigFile, normalItems, items) {
|
|
11
|
+
var _appConfigFile$conten;
|
|
9
12
|
if (!appConfigFile.content) {
|
|
10
13
|
return;
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
|
|
16
|
+
// 提取export default defineAppConfig()里的内容
|
|
17
|
+
var content = parseLooseObject(((_appConfigFile$conten = appConfigFile.content.match(/defineAppConfig\(([\s\S]*?)\)/)) === null || _appConfigFile$conten === void 0 ? void 0 : _appConfigFile$conten[1]) || '{}');
|
|
13
18
|
|
|
14
19
|
// 更新 pages 配置(使用 scene id)
|
|
15
20
|
var newPagePaths = normalItems.map(function (item) {
|
|
16
|
-
return "
|
|
17
|
-
})
|
|
18
|
-
content
|
|
21
|
+
return "pages/".concat(item.meta.id, "/index");
|
|
22
|
+
});
|
|
23
|
+
content.pages = newPagePaths;
|
|
24
|
+
|
|
25
|
+
// 提取首页
|
|
26
|
+
var entryPagePath = '';
|
|
27
|
+
normalItems.forEach(function (item) {
|
|
28
|
+
var _Object$values, _item$meta;
|
|
29
|
+
(_Object$values = Object.values((_item$meta = item.meta) === null || _item$meta === void 0 ? void 0 : _item$meta.coms)) === null || _Object$values === void 0 || _Object$values.forEach(function (com) {
|
|
30
|
+
var _com$model;
|
|
31
|
+
if (com !== null && com !== void 0 && com.asRoot && com !== null && com !== void 0 && (_com$model = com.model) !== null && _com$model !== void 0 && (_com$model = _com$model.data) !== null && _com$model !== void 0 && _com$model.isEntryPagePath) {
|
|
32
|
+
entryPagePath = "pages/".concat(item.meta.id, "/index");
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
if (entryPagePath) {
|
|
37
|
+
content.entryPagePath = entryPagePath;
|
|
38
|
+
}
|
|
39
|
+
content.window = content.window || {};
|
|
19
40
|
|
|
20
41
|
// 添加 TabBar 配置(从 items 中读取)
|
|
21
42
|
var tabBarConfigItem = items.find(function (item) {
|
|
22
43
|
return item.type === 'tabBarConfig';
|
|
23
44
|
});
|
|
24
|
-
if (tabBarConfigItem !== null && tabBarConfigItem !== void 0 && tabBarConfigItem.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
45
|
+
if (tabBarConfigItem !== null && tabBarConfigItem !== void 0 && tabBarConfigItem.content) {
|
|
46
|
+
var tabBar = parseLooseObject("{".concat(tabBarConfigItem.content, "}"));
|
|
47
|
+
Object.assign(content.window, tabBar);
|
|
28
48
|
}
|
|
29
|
-
appConfigFile.content = content;
|
|
49
|
+
appConfigFile.content = "export default defineAppConfig(".concat(JSON.stringify(content, null, 2), ")");
|
|
30
50
|
}
|
|
@@ -37,4 +37,17 @@ export function handleCommonDir(commonDir, items) {
|
|
|
37
37
|
content: _fullContent
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
// 处理rootConfig
|
|
42
|
+
var rootConfigItem = items.find(function (item) {
|
|
43
|
+
return item.type === 'rootConfig';
|
|
44
|
+
});
|
|
45
|
+
if (rootConfigItem) {
|
|
46
|
+
var _fileContent2 = rootConfigItem.content || '{}';
|
|
47
|
+
var _fullContent2 = "export default ".concat(_fileContent2);
|
|
48
|
+
commonDir.children.push({
|
|
49
|
+
path: 'src/common/rootConfig.ts',
|
|
50
|
+
content: _fullContent2
|
|
51
|
+
});
|
|
52
|
+
}
|
|
40
53
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 更新自定义 TabBar 配置文件
|
|
3
|
+
*/
|
|
4
|
+
import { GeneratedFile } from '../../toCodeTaro';
|
|
5
|
+
interface FileNode {
|
|
6
|
+
path: string;
|
|
7
|
+
content: string | null;
|
|
8
|
+
children?: FileNode[];
|
|
9
|
+
}
|
|
10
|
+
export declare function updateCustomTabBar(srcDir: FileNode, files: GeneratedFile[]): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 更新自定义 TabBar 配置文件
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { ensureDir } from "./fileNode";
|
|
6
|
+
import { parseLooseObject } from "./fileNode";
|
|
7
|
+
export function updateCustomTabBar(srcDir, files) {
|
|
8
|
+
var customTabBarDir = ensureDir(srcDir, 'src/custom-tab-bar');
|
|
9
|
+
|
|
10
|
+
// 将mybricks的tabbar数据写入/custom-tab-bar/mybricks/tabbar-config.ts
|
|
11
|
+
var customTabBarItem = files.find(function (item) {
|
|
12
|
+
return item.type === 'customTabBar';
|
|
13
|
+
});
|
|
14
|
+
if (customTabBarItem !== null && customTabBarItem !== void 0 && customTabBarItem.content) {
|
|
15
|
+
var _mybricksDir$children;
|
|
16
|
+
var CUSTOM_TAB_BAR_CONFIG_PATH = 'src/custom-tab-bar/mybricks/tabbar-config.ts';
|
|
17
|
+
var mybricksDir = ensureDir(customTabBarDir, 'src/custom-tab-bar/mybricks');
|
|
18
|
+
var tabbarConfigFileIndex = (_mybricksDir$children = mybricksDir.children) === null || _mybricksDir$children === void 0 ? void 0 : _mybricksDir$children.findIndex(function (node) {
|
|
19
|
+
return node.path === CUSTOM_TAB_BAR_CONFIG_PATH;
|
|
20
|
+
});
|
|
21
|
+
if (tabbarConfigFileIndex === -1) {
|
|
22
|
+
mybricksDir.children.push({
|
|
23
|
+
path: CUSTOM_TAB_BAR_CONFIG_PATH,
|
|
24
|
+
content: customTabBarItem.content
|
|
25
|
+
});
|
|
26
|
+
} else {
|
|
27
|
+
mybricksDir.children[tabbarConfigFileIndex].content = customTabBarItem.content;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 将app.config.ts中的tabbar配置写入/custom-tab-bar/tabBar.json
|
|
32
|
+
// 后续可以用来判断页面是否标签页
|
|
33
|
+
var tabBarConfigItem = files.find(function (item) {
|
|
34
|
+
return item.type === 'tabBarConfig';
|
|
35
|
+
});
|
|
36
|
+
if (tabBarConfigItem !== null && tabBarConfigItem !== void 0 && tabBarConfigItem.content) {
|
|
37
|
+
var _customTabBarDir$chil;
|
|
38
|
+
var contentStr = JSON.stringify(parseLooseObject("{".concat(tabBarConfigItem.content, "}")), null, 2);
|
|
39
|
+
var tabBarJsonPath = "".concat(customTabBarDir.path, "/tabBar.json");
|
|
40
|
+
var tabBarJsonIndex = (_customTabBarDir$chil = customTabBarDir.children) === null || _customTabBarDir$chil === void 0 ? void 0 : _customTabBarDir$chil.findIndex(function (node) {
|
|
41
|
+
return node.path === tabBarJsonPath;
|
|
42
|
+
});
|
|
43
|
+
if (tabBarJsonIndex === -1) {
|
|
44
|
+
customTabBarDir.children.push({
|
|
45
|
+
path: tabBarJsonPath,
|
|
46
|
+
content: contentStr
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
customTabBarDir.children[tabBarJsonIndex].content = contentStr;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -14,4 +14,8 @@ export declare function findDir(nodes: FileNode[], targetPath: string): FileNode
|
|
|
14
14
|
* 确保目录存在,如果不存在则创建
|
|
15
15
|
*/
|
|
16
16
|
export declare function ensureDir(parentDir: FileNode, dirPath: string): FileNode;
|
|
17
|
+
/**
|
|
18
|
+
* 解析宽松格式的对象字符串
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseLooseObject(raw: string): any;
|
|
17
21
|
export {};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
|
+
import { runInNewContext } from 'node:vm';
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* 文件节点相关工具函数
|
|
4
6
|
*/
|
|
@@ -46,4 +48,15 @@ export function ensureDir(parentDir, dirPath) {
|
|
|
46
48
|
}
|
|
47
49
|
dir.children = dir.children || [];
|
|
48
50
|
return dir;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 解析宽松格式的对象字符串
|
|
55
|
+
*/
|
|
56
|
+
export function parseLooseObject(raw) {
|
|
57
|
+
try {
|
|
58
|
+
return JSON.parse(raw);
|
|
59
|
+
} catch (_unused) {
|
|
60
|
+
return runInNewContext("(".concat(raw, ")"), Object.create(null));
|
|
61
|
+
}
|
|
49
62
|
}
|
package/dist/esm/handleCom.js
CHANGED
|
@@ -17,10 +17,9 @@ import { handleProcess } from "./utils/logic/handleProcess";
|
|
|
17
17
|
var COM_PROTOCOL = {
|
|
18
18
|
"mybricks.taro.formContainer": {
|
|
19
19
|
useWrap: true
|
|
20
|
-
},
|
|
21
|
-
"mybricks.taro.formAdditionContainer": {
|
|
22
|
-
useWrap: true
|
|
23
20
|
}
|
|
21
|
+
// 移除 FormAdditionContainer 的配置,因为它的 runtime 没有传递 wrap 函数
|
|
22
|
+
// "mybricks.taro.formAdditionContainer": { useWrap: true },
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
/**
|
|
@@ -127,15 +126,11 @@ var prepareComponent = function prepareComponent(com, config) {
|
|
|
127
126
|
* 准备样式转换
|
|
128
127
|
*/
|
|
129
128
|
var prepareStyles = function prepareStyles(com) {
|
|
130
|
-
var _props$
|
|
129
|
+
var _props$style;
|
|
131
130
|
var meta = com.meta,
|
|
132
131
|
props = com.props;
|
|
133
|
-
|
|
134
|
-
var
|
|
135
|
-
layout: ((_props$data = props.data) === null || _props$data === void 0 ? void 0 : _props$data.layout) || ((_props$style = props.style) === null || _props$style === void 0 ? void 0 : _props$style.layout)
|
|
136
|
-
});
|
|
137
|
-
var resultStyle = convertComponentStyle(styleWithLayout);
|
|
138
|
-
var cssContent = convertStyleAryToCss((_props$style2 = props.style) === null || _props$style2 === void 0 ? void 0 : _props$style2.styleAry, meta.id);
|
|
132
|
+
var resultStyle = convertComponentStyle(props.style || {});
|
|
133
|
+
var cssContent = convertStyleAryToCss((_props$style = props.style) === null || _props$style === void 0 ? void 0 : _props$style.styleAry, meta.id);
|
|
139
134
|
return {
|
|
140
135
|
cssContent: cssContent,
|
|
141
136
|
rootStyle: resultStyle.root || {}
|
|
@@ -162,15 +157,23 @@ var processComSlots = function processComSlots(com, config, initialCss) {
|
|
|
162
157
|
var renderManager = config.renderManager || new RenderManager();
|
|
163
158
|
var slotEntries = Object.entries(slots);
|
|
164
159
|
slotEntries.forEach(function (_ref2, index) {
|
|
165
|
-
var _com$props$data, _props$
|
|
160
|
+
var _config$getEffectEven, _effectEvent$process, _effectEvent$process2, _com$props$data, _props$data, _COM_PROTOCOL$meta$de;
|
|
166
161
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
167
162
|
slotId = _ref3[0],
|
|
168
163
|
slot = _ref3[1];
|
|
169
|
-
// 鸿蒙规范:如果插槽内没有组件,直接渲染空
|
|
170
164
|
var children = slot.comAry || slot.children || [];
|
|
171
165
|
var isLast = index === slotEntries.length - 1;
|
|
172
166
|
var slotIndent = indentation(config.codeStyle.indent * (config.depth + 2));
|
|
173
|
-
|
|
167
|
+
|
|
168
|
+
// 检查是否有插槽级别的 effectEvent(即使 children 为空也可能有逻辑代码)
|
|
169
|
+
var effectEvent = (_config$getEffectEven = config.getEffectEvent) === null || _config$getEffectEven === void 0 ? void 0 : _config$getEffectEven.call(config, {
|
|
170
|
+
comId: meta.id,
|
|
171
|
+
slotId: slotId
|
|
172
|
+
});
|
|
173
|
+
var hasSlotLogic = effectEvent && (((_effectEvent$process = effectEvent.process) === null || _effectEvent$process === void 0 || (_effectEvent$process = _effectEvent$process.nodesDeclaration) === null || _effectEvent$process === void 0 ? void 0 : _effectEvent$process.length) > 0 || ((_effectEvent$process2 = effectEvent.process) === null || _effectEvent$process2 === void 0 || (_effectEvent$process2 = _effectEvent$process2.nodesInvocation) === null || _effectEvent$process2 === void 0 ? void 0 : _effectEvent$process2.length) > 0);
|
|
174
|
+
|
|
175
|
+
// 如果插槽内没有组件且没有逻辑代码,直接渲染空
|
|
176
|
+
if (children.length === 0 && !hasSlotLogic) {
|
|
174
177
|
slotsCode += "".concat(slotIndent).concat(slotId, ": {\n").concat(slotIndent, " render: () => null\n").concat(slotIndent, "}").concat(isLast ? '' : ',', "\n");
|
|
175
178
|
return;
|
|
176
179
|
}
|
|
@@ -198,9 +201,9 @@ var processComSlots = function processComSlots(com, config, initialCss) {
|
|
|
198
201
|
var rawContent = result.ui;
|
|
199
202
|
|
|
200
203
|
// 鸿蒙化处理:针对表单容器进行别名对齐
|
|
201
|
-
if (meta.def.namespace === "mybricks.taro.formContainer" && Array.isArray((_props$
|
|
202
|
-
var _props$
|
|
203
|
-
var items = (_props$
|
|
204
|
+
if (meta.def.namespace === "mybricks.taro.formContainer" && Array.isArray((_props$data = props.data) === null || _props$data === void 0 ? void 0 : _props$data.items) && result.directChildren) {
|
|
205
|
+
var _props$data2;
|
|
206
|
+
var items = (_props$data2 = props.data) === null || _props$data2 === void 0 ? void 0 : _props$data2.items;
|
|
204
207
|
result.directChildren.forEach(function (childRes) {
|
|
205
208
|
var itemConfig = items.find(function (it) {
|
|
206
209
|
return it.id === childRes.id;
|
|
@@ -248,7 +251,7 @@ var processComSlots = function processComSlots(com, config, initialCss) {
|
|
|
248
251
|
* 生成插槽内部的驱动逻辑 (useEffect 监听 inputValues 并调用子组件 inputs)
|
|
249
252
|
*/
|
|
250
253
|
var buildSlotLogicCode = function buildSlotLogicCode(args) {
|
|
251
|
-
var _config$
|
|
254
|
+
var _config$getEffectEven2;
|
|
252
255
|
var parentComId = args.parentComId,
|
|
253
256
|
slotKey = args.slotKey,
|
|
254
257
|
config = args.config;
|
|
@@ -257,7 +260,7 @@ var buildSlotLogicCode = function buildSlotLogicCode(args) {
|
|
|
257
260
|
|
|
258
261
|
// 更直接:用 to-code-react 已经解析好的“effect event”(底层来自 diagrams[].conAry)
|
|
259
262
|
// buildSlotLogicCode 只负责包一层 useEffect,不再自己扫描/猜测 cons/pinValueProxies
|
|
260
|
-
var effectEvent = (_config$
|
|
263
|
+
var effectEvent = (_config$getEffectEven2 = config.getEffectEvent) === null || _config$getEffectEven2 === void 0 ? void 0 : _config$getEffectEven2.call(config, {
|
|
261
264
|
comId: parentComId,
|
|
262
265
|
slotId: slotKey
|
|
263
266
|
});
|
|
@@ -277,7 +280,7 @@ var buildSlotLogicCode = function buildSlotLogicCode(args) {
|
|
|
277
280
|
getParams: function getParams() {
|
|
278
281
|
return paramsProxy;
|
|
279
282
|
}
|
|
280
|
-
})).replace(/this\./g, "comRefs.current.").replace(/comRefs\.current\.([a-zA-Z0-9_]+)\.controller_/g, "comRefs.current.$1.").replace(/comRefs\.current\.slot_Index\./g, "comRefs.current.");
|
|
283
|
+
})).replace(/this\.\$vars\./g, "$vars.current.").replace(/this\.\$fxs\./g, "$fxs.current.").replace(/this\./g, "comRefs.current.").replace(/comRefs\.current\.([a-zA-Z0-9_]+)\.controller_/g, "comRefs.current.$1.").replace(/comRefs\.current\.slot_Index\./g, "comRefs.current.");
|
|
281
284
|
if (!process.trim()) return "";
|
|
282
285
|
var code = "".concat(indent, "useEffect(() => {\n");
|
|
283
286
|
code += "".concat(indent2, "if (!params?.inputValues) return;\n");
|
|
@@ -320,10 +323,10 @@ var generateUiCode = function generateUiCode(com, config, componentName, rootSty
|
|
|
320
323
|
* JS 计算组件专用处理
|
|
321
324
|
*/
|
|
322
325
|
var handleJsCalculation = function handleJsCalculation(com, config) {
|
|
323
|
-
var _props$
|
|
326
|
+
var _props$data3, _props$data4, _props$data5;
|
|
324
327
|
var meta = com.meta,
|
|
325
328
|
props = com.props;
|
|
326
|
-
var transformCode = ((_props$
|
|
329
|
+
var transformCode = ((_props$data3 = props.data) === null || _props$data3 === void 0 || (_props$data3 = _props$data3.fns) === null || _props$data3 === void 0 ? void 0 : _props$data3.code) || ((_props$data4 = props.data) === null || _props$data4 === void 0 || (_props$data4 = _props$data4.fns) === null || _props$data4 === void 0 ? void 0 : _props$data4.transformCode) || ((_props$data5 = props.data) === null || _props$data5 === void 0 ? void 0 : _props$data5.fns);
|
|
327
330
|
if (transformCode && config.addJSModule) {
|
|
328
331
|
var _meta$model, _meta$model2;
|
|
329
332
|
config.addJSModule({
|
package/dist/esm/handleGlobal.js
CHANGED
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* 处理全局变量、全局Fx、其他全局配置
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -124,6 +124,11 @@ var handleGlobal = function handleGlobal(params, config) {
|
|
|
124
124
|
});
|
|
125
125
|
}
|
|
126
126
|
return [{
|
|
127
|
+
type: "rootConfig",
|
|
128
|
+
content: JSON.stringify(tojson.rootConfig, null, 2),
|
|
129
|
+
importManager: null,
|
|
130
|
+
name: "rootConfig"
|
|
131
|
+
}, {
|
|
127
132
|
type: "global",
|
|
128
133
|
content: varCode + "\n\n" + fxCode,
|
|
129
134
|
importManager: globalImportManager,
|