@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/dist/esm/utils/index.js
CHANGED
|
@@ -1,345 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
_classCallCheck(this, ImportManager);
|
|
14
|
-
_defineProperty(this, "_imports", {});
|
|
15
|
-
this._config = _config;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** 添加依赖 */
|
|
19
|
-
_createClass(ImportManager, [{
|
|
20
|
-
key: "addImport",
|
|
21
|
-
value: function addImport(_ref) {
|
|
22
|
-
var packageName = _ref.packageName,
|
|
23
|
-
dependencyNames = _ref.dependencyNames,
|
|
24
|
-
importType = _ref.importType;
|
|
25
|
-
if (!packageName) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
var _imports = this._imports;
|
|
29
|
-
if (!_imports[packageName]) {
|
|
30
|
-
_imports[packageName] = {};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// 对于 module 类型且 dependencyNames 为空的情况,使用特殊标记
|
|
34
|
-
if (importType === "module" && dependencyNames.length === 0) {
|
|
35
|
-
_imports[packageName]["__module__"] = {
|
|
36
|
-
importType: "module"
|
|
37
|
-
};
|
|
38
|
-
} else {
|
|
39
|
-
dependencyNames.forEach(function (dependencyName) {
|
|
40
|
-
_imports[packageName][dependencyName] = {
|
|
41
|
-
importType: importType
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/** 依赖解析为code */
|
|
48
|
-
}, {
|
|
49
|
-
key: "toCode",
|
|
50
|
-
value: function toCode() {
|
|
51
|
-
var indent = indentation(this._config.codeStyle.indent);
|
|
52
|
-
return Object.entries(this._imports).reduce(function (pre, _ref2) {
|
|
53
|
-
var _dependencies$__modul;
|
|
54
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
55
|
-
packageName = _ref3[0],
|
|
56
|
-
dependencies = _ref3[1];
|
|
57
|
-
var defaultDependency = "";
|
|
58
|
-
var namedDependencies = "";
|
|
59
|
-
var moduleDependency = "";
|
|
60
|
-
var dependencyEntries = Object.entries(dependencies);
|
|
61
|
-
|
|
62
|
-
// 检查是否有 module 类型的导入(如 import './index.less')
|
|
63
|
-
// 通过检查 __module__ 标记或依赖项中的 module 类型
|
|
64
|
-
var hasModuleType = ((_dependencies$__modul = dependencies["__module__"]) === null || _dependencies$__modul === void 0 ? void 0 : _dependencies$__modul.importType) === "module" || dependencyEntries.some(function (_ref4) {
|
|
65
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
|
66
|
-
importType = _ref5[1].importType;
|
|
67
|
-
return importType === "module";
|
|
68
|
-
});
|
|
69
|
-
if (hasModuleType) {
|
|
70
|
-
// module 类型:直接生成 import 'packageName',不再处理其他依赖
|
|
71
|
-
return pre + "import '".concat(packageName, "';\n");
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** 超过三项换行 */
|
|
75
|
-
// 排除 __module__ 标记
|
|
76
|
-
var validEntries = dependencyEntries.filter(function (_ref6) {
|
|
77
|
-
var _ref7 = _slicedToArray(_ref6, 1),
|
|
78
|
-
key = _ref7[0];
|
|
79
|
-
return key !== "__module__";
|
|
80
|
-
});
|
|
81
|
-
var wrap = validEntries.length > 3;
|
|
82
|
-
validEntries.forEach(function (_ref8, index) {
|
|
83
|
-
var _ref9 = _slicedToArray(_ref8, 2),
|
|
84
|
-
dependencyName = _ref9[0],
|
|
85
|
-
importType = _ref9[1].importType;
|
|
86
|
-
if (importType === "default") {
|
|
87
|
-
defaultDependency = dependencyName;
|
|
88
|
-
} else if (importType === "named") {
|
|
89
|
-
if (wrap) {
|
|
90
|
-
namedDependencies += "".concat(indent).concat(dependencyName, ",\n");
|
|
91
|
-
} else {
|
|
92
|
-
namedDependencies += "".concat(index ? ", " : "").concat(dependencyName);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
if (namedDependencies) {
|
|
97
|
-
if (wrap) {
|
|
98
|
-
namedDependencies = "{\n".concat(namedDependencies, "}");
|
|
99
|
-
} else {
|
|
100
|
-
namedDependencies = "{ ".concat(namedDependencies, " }");
|
|
101
|
-
}
|
|
102
|
-
if (defaultDependency) {
|
|
103
|
-
defaultDependency += ", ";
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return pre + "import ".concat(defaultDependency).concat(namedDependencies, " from '").concat(packageName, "';\n");
|
|
107
|
-
}, "");
|
|
108
|
-
}
|
|
109
|
-
}]);
|
|
110
|
-
return ImportManager;
|
|
111
|
-
}();
|
|
112
|
-
|
|
113
|
-
/** 将第一个字符转大写 */
|
|
114
|
-
export var firstCharToUpperCase = function firstCharToUpperCase(str) {
|
|
115
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/** 将第一个字符转小写 */
|
|
119
|
-
export var firstCharToLowerCase = function firstCharToLowerCase(str) {
|
|
120
|
-
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/** 缩进 */
|
|
124
|
-
export var indentation = function indentation(level) {
|
|
125
|
-
return " ".repeat(level);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
/** 驼峰转中划线 */
|
|
129
|
-
export var camelToKebab = function camelToKebab(str) {
|
|
130
|
-
return str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
/** 中划线转驼峰 */
|
|
134
|
-
export var kebabToCamel = function kebabToCamel(str) {
|
|
135
|
-
return str.replace(/-([a-z])/g, function (_, char) {
|
|
136
|
-
return char.toUpperCase();
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
/** 转换根节点样式 */
|
|
141
|
-
export var convertRootStyle = function convertRootStyle(style) {
|
|
142
|
-
var rootStyle = {};
|
|
143
|
-
Object.entries(style || {}).forEach(function (_ref10) {
|
|
144
|
-
var _ref11 = _slicedToArray(_ref10, 2),
|
|
145
|
-
key = _ref11[0],
|
|
146
|
-
value = _ref11[1];
|
|
147
|
-
// 忽略一些不需要的属性
|
|
148
|
-
if (key === "_new" || key === "themesId" || key === "visibility" || key === "styleAry") {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
if (key === "layout") {
|
|
152
|
-
if (_typeof(value) === "object" && value !== null) {
|
|
153
|
-
// 处理 layout 对象,动态转换所有属性
|
|
154
|
-
var layoutObj = value;
|
|
155
|
-
Object.entries(layoutObj).forEach(function (_ref12) {
|
|
156
|
-
var _ref13 = _slicedToArray(_ref12, 2),
|
|
157
|
-
lKey = _ref13[0],
|
|
158
|
-
lValue = _ref13[1];
|
|
159
|
-
if (lKey === "position") {
|
|
160
|
-
if (lValue === "smart") {
|
|
161
|
-
rootStyle["position"] = "absolute";
|
|
162
|
-
} else if (lValue !== "inherit") {
|
|
163
|
-
rootStyle["position"] = lValue;
|
|
164
|
-
}
|
|
165
|
-
} else {
|
|
166
|
-
// 所有布局属性转为小驼峰(React 行内样式使用 camelCase)
|
|
167
|
-
var camelLayoutKey = kebabToCamel(lKey);
|
|
168
|
-
rootStyle[camelLayoutKey] = pxtransform(lValue);
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
} else if (value === "flex-row") {
|
|
172
|
-
rootStyle["display"] = "flex";
|
|
173
|
-
rootStyle["flexDirection"] = "row";
|
|
174
|
-
} else if (value === "flex-column") {
|
|
175
|
-
rootStyle["display"] = "flex";
|
|
176
|
-
rootStyle["flexDirection"] = "column";
|
|
177
|
-
} else if (value === "smart") {
|
|
178
|
-
// 处理 layout: 'smart'
|
|
179
|
-
rootStyle["position"] = "relative";
|
|
180
|
-
}
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// 根样式转换,统一转为小驼峰(React 行内样式使用 camelCase)
|
|
185
|
-
// 如果 key 已经是 kebab-case,转换为 camelCase;如果已经是 camelCase,保持不变
|
|
186
|
-
var camelKey = key.includes('-') ? kebabToCamel(key) : key;
|
|
187
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
188
|
-
rootStyle[camelKey] = pxtransform(value);
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
return rootStyle;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
/** 转换组件样式为 Taro/React 样式 */
|
|
195
|
-
export var convertComponentStyle = function convertComponentStyle(style) {
|
|
196
|
-
var resultStyle = {};
|
|
197
|
-
var rootStyle = convertRootStyle(style);
|
|
198
|
-
if (style.styleAry) {
|
|
199
|
-
// 处理样式数组
|
|
200
|
-
style.styleAry.forEach(function (_ref14) {
|
|
201
|
-
var css = _ref14.css,
|
|
202
|
-
selector = _ref14.selector;
|
|
203
|
-
var transformedCss = {};
|
|
204
|
-
Object.entries(css).forEach(function (_ref15) {
|
|
205
|
-
var _ref16 = _slicedToArray(_ref15, 2),
|
|
206
|
-
cssKey = _ref16[0],
|
|
207
|
-
cssValue = _ref16[1];
|
|
208
|
-
if (cssKey === "layout") {
|
|
209
|
-
if (_typeof(cssValue) === "object" && cssValue !== null) {
|
|
210
|
-
var layoutObj = cssValue;
|
|
211
|
-
Object.entries(layoutObj).forEach(function (_ref17) {
|
|
212
|
-
var _ref18 = _slicedToArray(_ref17, 2),
|
|
213
|
-
lKey = _ref18[0],
|
|
214
|
-
lValue = _ref18[1];
|
|
215
|
-
if (lKey === "position") {
|
|
216
|
-
if (lValue === "smart") {
|
|
217
|
-
transformedCss["position"] = "absolute";
|
|
218
|
-
} else if (lValue !== "inherit") {
|
|
219
|
-
transformedCss["position"] = lValue;
|
|
220
|
-
}
|
|
221
|
-
} else {
|
|
222
|
-
// 布局属性转为小驼峰(React 行内样式使用 camelCase)
|
|
223
|
-
transformedCss[kebabToCamel(lKey)] = lValue;
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
} else if (cssValue === "flex-row") {
|
|
227
|
-
transformedCss["display"] = "flex";
|
|
228
|
-
transformedCss["flexDirection"] = "row";
|
|
229
|
-
} else if (cssValue === "flex-column") {
|
|
230
|
-
transformedCss["display"] = "flex";
|
|
231
|
-
transformedCss["flexDirection"] = "column";
|
|
232
|
-
} else if (cssValue === "smart") {
|
|
233
|
-
transformedCss["position"] = "relative";
|
|
234
|
-
}
|
|
235
|
-
} else {
|
|
236
|
-
// CSS 属性转为小驼峰(React 行内样式使用 camelCase)
|
|
237
|
-
// 如果 cssKey 已经是 kebab-case,转换为 camelCase;如果已经是 camelCase,保持不变
|
|
238
|
-
var camelKey = cssKey.includes('-') ? kebabToCamel(cssKey) : cssKey;
|
|
239
|
-
transformedCss[camelKey] = pxtransform(cssValue);
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
resultStyle[selector] = transformedCss;
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
resultStyle["root"] = rootStyle;
|
|
246
|
-
return resultStyle;
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
/** 转换 styleAry 为 CSS 字符串 */
|
|
250
|
-
export var convertStyleAryToCss = function convertStyleAryToCss(styleAry, parentSelector) {
|
|
251
|
-
if (!Array.isArray(styleAry)) return "";
|
|
252
|
-
var prefix = parentSelector ? ".".concat(parentSelector, " ") : "";
|
|
253
|
-
return styleAry.map(function (_ref19) {
|
|
254
|
-
var selector = _ref19.selector,
|
|
255
|
-
css = _ref19.css;
|
|
256
|
-
if (!selector || !css) return "";
|
|
257
|
-
|
|
258
|
-
// 处理选择器,如果是以 > 开头,处理空格
|
|
259
|
-
var finalSelector = selector;
|
|
260
|
-
if (finalSelector.startsWith(">")) {
|
|
261
|
-
finalSelector = "".concat(prefix).concat(finalSelector);
|
|
262
|
-
} else {
|
|
263
|
-
finalSelector = "".concat(prefix).concat(finalSelector);
|
|
264
|
-
}
|
|
265
|
-
var transformedCss = {};
|
|
266
|
-
Object.entries(css).forEach(function (_ref20) {
|
|
267
|
-
var _ref21 = _slicedToArray(_ref20, 2),
|
|
268
|
-
key = _ref21[0],
|
|
269
|
-
value = _ref21[1];
|
|
270
|
-
if (key === "layout") {
|
|
271
|
-
if (_typeof(value) === "object" && value !== null) {
|
|
272
|
-
var layoutObj = value;
|
|
273
|
-
Object.entries(layoutObj).forEach(function (_ref22) {
|
|
274
|
-
var _ref23 = _slicedToArray(_ref22, 2),
|
|
275
|
-
lKey = _ref23[0],
|
|
276
|
-
lValue = _ref23[1];
|
|
277
|
-
if (lKey === "position") {
|
|
278
|
-
if (lValue === "smart") {
|
|
279
|
-
transformedCss["position"] = "absolute";
|
|
280
|
-
} else if (lValue !== "inherit") {
|
|
281
|
-
transformedCss["position"] = lValue;
|
|
282
|
-
}
|
|
283
|
-
} else {
|
|
284
|
-
transformedCss[kebabToCamel(lKey)] = lValue;
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
} else if (value === "flex-row") {
|
|
288
|
-
transformedCss["display"] = "flex";
|
|
289
|
-
transformedCss["flexDirection"] = "row";
|
|
290
|
-
} else if (value === "flex-column") {
|
|
291
|
-
transformedCss["display"] = "flex";
|
|
292
|
-
transformedCss["flexDirection"] = "column";
|
|
293
|
-
} else if (value === "smart") {
|
|
294
|
-
transformedCss["position"] = "relative";
|
|
295
|
-
}
|
|
296
|
-
} else {
|
|
297
|
-
transformedCss[kebabToCamel(key)] = value;
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
var cssString = Object.entries(transformedCss).map(function (_ref24) {
|
|
301
|
-
var _ref25 = _slicedToArray(_ref24, 2),
|
|
302
|
-
key = _ref25[0],
|
|
303
|
-
value = _ref25[1];
|
|
304
|
-
// 使用通用工具转换驼峰为中划线
|
|
305
|
-
var kebabKey = camelToKebab(key);
|
|
306
|
-
var formattedValue = typeof value === "number" ? "".concat(value, "px") : value;
|
|
307
|
-
return " ".concat(kebabKey, ": ").concat(formattedValue, ";");
|
|
308
|
-
}).join("\n");
|
|
309
|
-
return "".concat(finalSelector, " {\n").concat(cssString, "\n}");
|
|
310
|
-
}).join("\n\n");
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
/** 生成对象代码 */
|
|
314
|
-
export var genObjectCode = function genObjectCode(object, config) {
|
|
315
|
-
var initialIndent = config.initialIndent,
|
|
316
|
-
indentSize = config.indentSize;
|
|
317
|
-
var keys = Object.keys(object);
|
|
318
|
-
if (keys.length === 0) return "{}";
|
|
319
|
-
var result = "{\n";
|
|
320
|
-
keys.forEach(function (key, idx) {
|
|
321
|
-
var value = object[key];
|
|
322
|
-
var formattedValue;
|
|
323
|
-
if (Array.isArray(value)) {
|
|
324
|
-
formattedValue = JSON.stringify(value);
|
|
325
|
-
} else if (value && _typeof(value) === "object") {
|
|
326
|
-
formattedValue = genObjectCode(value, {
|
|
327
|
-
initialIndent: initialIndent + indentSize,
|
|
328
|
-
indentSize: indentSize
|
|
329
|
-
});
|
|
330
|
-
} else if (typeof value === "string") {
|
|
331
|
-
formattedValue = JSON.stringify(value);
|
|
332
|
-
} else {
|
|
333
|
-
formattedValue = String(value);
|
|
334
|
-
}
|
|
335
|
-
result += indentation(initialIndent + indentSize) + "".concat(JSON.stringify(key), ": ").concat(formattedValue);
|
|
336
|
-
if (idx < keys.length - 1) result += ",";
|
|
337
|
-
result += "\n";
|
|
338
|
-
});
|
|
339
|
-
result += indentation(initialIndent) + "}";
|
|
340
|
-
return result;
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
// 导出 code 目录下的函数
|
|
344
|
-
export { getUiComponentCode } from "./code";
|
|
345
|
-
export { getRootComponentClassName } from "./getComponentClassName";
|
|
1
|
+
export * from "./style/types";
|
|
2
|
+
export * from "./common/ImportManager";
|
|
3
|
+
export * from "./common/string";
|
|
4
|
+
export * from "./common/helper";
|
|
5
|
+
export * from "./common/object";
|
|
6
|
+
export * from "./style/color";
|
|
7
|
+
export * from "./style/converter";
|
|
8
|
+
export { default as pxtransform } from "./style/pxtransform";
|
|
9
|
+
export { getRootComponentClassName } from "./style/getComponentClassName";
|
|
10
|
+
|
|
11
|
+
// 导出 templates 目录下的函数 (原 code 目录)
|
|
12
|
+
export { getUiComponentCode } from "./templates";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ImportManager } from "
|
|
2
|
-
import type { BaseConfig } from "
|
|
1
|
+
import { ImportManager } from "../common/ImportManager";
|
|
2
|
+
import type { BaseConfig } from "../../toCodeTaro";
|
|
3
3
|
export interface HandleProcessConfig extends BaseConfig {
|
|
4
4
|
addParentDependencyImport: (typeof ImportManager)["prototype"]["addImport"];
|
|
5
5
|
getParams: () => Record<string, string>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { indentation } from "../common/helper";
|
|
5
|
+
import { genObjectCode } from "../common/object";
|
|
4
6
|
/**
|
|
5
7
|
* 判断是否是 JS 计算组件
|
|
6
8
|
*/
|
|
@@ -117,15 +119,42 @@ export var handleProcess = function handleProcess(event, config) {
|
|
|
117
119
|
}
|
|
118
120
|
if (componentType === "js") {
|
|
119
121
|
if (category === "scene") {
|
|
120
|
-
var _config$getPageId;
|
|
122
|
+
var _targetScene$deps, _config$getPageId;
|
|
123
|
+
var _sceneId = props.meta.model.data._sceneId;
|
|
124
|
+
var targetScene = config.getSceneById(_sceneId);
|
|
125
|
+
var isPopup = (targetScene === null || targetScene === void 0 ? void 0 : targetScene.type) === 'popup' || (targetScene === null || targetScene === void 0 || (_targetScene$deps = targetScene.deps) === null || _targetScene$deps === void 0 ? void 0 : _targetScene$deps.some(function (dep) {
|
|
126
|
+
return dep.namespace === 'mybricks.taro.popup';
|
|
127
|
+
}));
|
|
128
|
+
var controllerName = isPopup ? "popupRouter" : "pageRouter";
|
|
121
129
|
config.addParentDependencyImport({
|
|
122
130
|
packageName: config.getComponentPackageName(),
|
|
123
|
-
dependencyNames: [
|
|
131
|
+
dependencyNames: [controllerName],
|
|
124
132
|
importType: "named"
|
|
125
133
|
});
|
|
126
|
-
var _sceneId = props.meta.model.data._sceneId;
|
|
127
134
|
var operateName = props.meta.model.data.openType === "redirect" ? "replace" : "open";
|
|
128
|
-
code += "".concat(indent, "/** \u6253\u5F00 ").concat(props.meta.title, " */") + "\n".concat(indent).concat(nextCode, "
|
|
135
|
+
code += "".concat(indent, "/** \u6253\u5F00 ").concat(props.meta.title, " */") + "\n".concat(indent).concat(nextCode).concat(controllerName, ".").concat(operateName, "(\"").concat(((_config$getPageId = config.getPageId) === null || _config$getPageId === void 0 ? void 0 : _config$getPageId.call(config, _sceneId)) || _sceneId, "\", ").concat(nextValue, ")");
|
|
136
|
+
} else if (category === "frameOutput") {
|
|
137
|
+
var _pinProxies;
|
|
138
|
+
// 场景/弹窗输出(commit/cancel/apply/close)
|
|
139
|
+
var currentScene = config.getCurrentScene();
|
|
140
|
+
// pinProxies 的结构在不同数据/版本里不完全一致,这里按最小字段兼容
|
|
141
|
+
var pinProxy = currentScene === null || currentScene === void 0 || (_pinProxies = currentScene.pinProxies) === null || _pinProxies === void 0 ? void 0 : _pinProxies["".concat(props.meta.id, "-").concat(props.id)];
|
|
142
|
+
if (pinProxy !== null && pinProxy !== void 0 && pinProxy.frameId && pinProxy !== null && pinProxy !== void 0 && pinProxy.pinId) {
|
|
143
|
+
var method = pinProxy.pinId;
|
|
144
|
+
var _controllerName = config.isPopup ? "popupRouter" : "pageRouter";
|
|
145
|
+
config.addParentDependencyImport({
|
|
146
|
+
packageName: config.getComponentPackageName(),
|
|
147
|
+
dependencyNames: [_controllerName],
|
|
148
|
+
importType: "named"
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// 仅支持 Page 内置的四种输出方法
|
|
152
|
+
if (["commit", "cancel", "apply", "close"].includes(method)) {
|
|
153
|
+
var sceneId = pinProxy.frameId || (currentScene === null || currentScene === void 0 ? void 0 : currentScene.id);
|
|
154
|
+
var argCode = nextValue ? ", ".concat(nextValue) : "";
|
|
155
|
+
code += "".concat(indent, "/** ").concat(props.meta.title, " \u8F93\u51FA ").concat(method, " */") + "\n".concat(indent).concat(nextCode).concat(_controllerName, ".").concat(method, "(\"").concat(sceneId, "\"").concat(argCode, ")");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
129
158
|
} else if (category === "normal") {
|
|
130
159
|
var componentNameWithId = getComponentNameWithId(props, config, event);
|
|
131
160
|
code += "".concat(indent, "/** \u8C03\u7528 ").concat(props.meta.title, " */") + "\n".concat(indent).concat(nextCode).concat(componentNameWithId, "(").concat(runType === "input" ? nextValue : "", ")");
|
|
@@ -251,6 +280,7 @@ var getNextCode = function getNextCode(props, config, isSameScope, event) {
|
|
|
251
280
|
var getNextValue = function getNextValue(props, config, event) {
|
|
252
281
|
var paramSource = props.paramSource;
|
|
253
282
|
var nextValue = paramSource.map(function (param) {
|
|
283
|
+
var _param$meta;
|
|
254
284
|
if (param.type === "params") {
|
|
255
285
|
var params = config.getParams();
|
|
256
286
|
return params[param.id];
|
|
@@ -258,21 +288,24 @@ var getNextValue = function getNextValue(props, config, event) {
|
|
|
258
288
|
return JSON.stringify(param.value);
|
|
259
289
|
}
|
|
260
290
|
var componentNameWithId = getComponentNameWithId(param, config, event);
|
|
261
|
-
|
|
262
|
-
|
|
291
|
+
// 变量组件直接返回 Subject,不加 .id 后缀
|
|
292
|
+
if ((_param$meta = param.meta) !== null && _param$meta !== void 0 && (_param$meta = _param$meta.def) !== null && _param$meta !== void 0 && (_param$meta = _param$meta.namespace) !== null && _param$meta !== void 0 && _param$meta.includes(".var")) {
|
|
293
|
+
return "".concat(componentNameWithId, "_result");
|
|
263
294
|
}
|
|
264
295
|
return "".concat(componentNameWithId, "_result.").concat(param.id);
|
|
265
296
|
});
|
|
266
297
|
return nextValue.join(", ");
|
|
267
298
|
};
|
|
268
299
|
var getNextValueWithParam = function getNextValueWithParam(param, config, event) {
|
|
300
|
+
var _param$meta2;
|
|
269
301
|
if (param.type === "params") {
|
|
270
302
|
var params = config.getParams();
|
|
271
303
|
return params[param.id];
|
|
272
304
|
}
|
|
273
305
|
var componentNameWithId = getComponentNameWithId(param, config, event);
|
|
274
|
-
|
|
275
|
-
|
|
306
|
+
// 变量组件直接返回 Subject
|
|
307
|
+
if ((_param$meta2 = param.meta) !== null && _param$meta2 !== void 0 && (_param$meta2 = _param$meta2.def) !== null && _param$meta2 !== void 0 && (_param$meta2 = _param$meta2.namespace) !== null && _param$meta2 !== void 0 && _param$meta2.includes(".var")) {
|
|
308
|
+
return "".concat(componentNameWithId, "_result");
|
|
276
309
|
}
|
|
277
310
|
return "".concat(componentNameWithId, "_result.").concat(param.id);
|
|
278
311
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { UI } from "../../toCodeTaro";
|
|
2
|
+
export type ChildResult = {
|
|
3
|
+
ui: string;
|
|
4
|
+
js: string;
|
|
5
|
+
cssContent: string;
|
|
6
|
+
slots: string[];
|
|
7
|
+
scopeSlots: string[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* 统一处理子节点(com, dom, module)
|
|
11
|
+
*/
|
|
12
|
+
export declare const processChildren: (children: UI["children"], config: any) => ChildResult;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import handleCom from "../../handleCom";
|
|
3
|
+
import handleDom from "../../handleDom";
|
|
4
|
+
import handleModule from "../../handleModule";
|
|
5
|
+
/**
|
|
6
|
+
* 统一处理子节点(com, dom, module)
|
|
7
|
+
*/
|
|
8
|
+
export var processChildren = function processChildren(children, config) {
|
|
9
|
+
var uiCode = "";
|
|
10
|
+
var jsCode = "";
|
|
11
|
+
var cssContent = "";
|
|
12
|
+
var slots = [];
|
|
13
|
+
var scopeSlots = [];
|
|
14
|
+
children.forEach(function (child) {
|
|
15
|
+
var result;
|
|
16
|
+
if (child.type === "com") {
|
|
17
|
+
result = handleCom(child, config);
|
|
18
|
+
} else if (child.type === "module") {
|
|
19
|
+
result = handleModule(child, config);
|
|
20
|
+
} else {
|
|
21
|
+
result = handleDom(child, config);
|
|
22
|
+
}
|
|
23
|
+
if (result) {
|
|
24
|
+
if (result.ui) {
|
|
25
|
+
uiCode += (uiCode ? "\n" : "") + result.ui;
|
|
26
|
+
}
|
|
27
|
+
if (result.js) {
|
|
28
|
+
jsCode += result.js;
|
|
29
|
+
}
|
|
30
|
+
if (result.cssContent) {
|
|
31
|
+
cssContent += (cssContent ? "\n" : "") + result.cssContent;
|
|
32
|
+
}
|
|
33
|
+
if (result.slots) {
|
|
34
|
+
slots.push.apply(slots, _toConsumableArray(result.slots));
|
|
35
|
+
}
|
|
36
|
+
if (result.scopeSlots) {
|
|
37
|
+
scopeSlots.push.apply(scopeSlots, _toConsumableArray(result.scopeSlots));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
ui: uiCode,
|
|
43
|
+
js: jsCode,
|
|
44
|
+
cssContent: cssContent,
|
|
45
|
+
slots: slots,
|
|
46
|
+
scopeSlots: scopeSlots
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将 rgba 或 rgb 颜色转换为 hex 颜色
|
|
3
|
+
*/
|
|
4
|
+
export function colorToHex(color) {
|
|
5
|
+
if (!color || typeof color !== "string") return color;
|
|
6
|
+
if (!color.startsWith("rgb")) return color;
|
|
7
|
+
var match = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)$/);
|
|
8
|
+
if (!match) return color;
|
|
9
|
+
var r = parseInt(match[1]);
|
|
10
|
+
var g = parseInt(match[2]);
|
|
11
|
+
var b = parseInt(match[3]);
|
|
12
|
+
var toHex = function toHex(n) {
|
|
13
|
+
var hex = n.toString(16);
|
|
14
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
15
|
+
};
|
|
16
|
+
return "#".concat(toHex(r)).concat(toHex(g)).concat(toHex(b)).toLowerCase();
|
|
17
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Style } from "./types";
|
|
2
|
+
/** 转换根节点样式 */
|
|
3
|
+
export declare const convertRootStyle: (style: Style) => Record<string, string | number>;
|
|
4
|
+
/** 转换组件样式为 Taro/React 样式 */
|
|
5
|
+
export declare const convertComponentStyle: (style: Style) => Record<string, Record<string, string | number>>;
|
|
6
|
+
/** 转换 styleAry 为 CSS 字符串 */
|
|
7
|
+
export declare const convertStyleAryToCss: (styleAry: any[], parentSelector?: string) => string;
|