@mybricks/to-code-taro 1.0.2 → 1.0.3
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/{Index.js → index.js} +4 -4
- package/dist/cjs/core/mybricks/index.js +47 -47
- package/dist/cjs/core/utils/ComContext.js +3 -0
- package/dist/cjs/core/utils/hooks.js +125 -0
- package/dist/cjs/core/utils/index.js +21 -57
- package/dist/cjs/core/utils/page.js +67 -0
- package/dist/cjs/core/utils/useContext.js +2 -1
- package/dist/cjs/generate/generateTaroProjectJson.d.ts +3 -14
- package/dist/cjs/generate/generateTaroProjectJson.js +9 -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 +2 -9
- package/dist/cjs/handleSlot.js +47 -150
- package/dist/cjs/processors/processComEvents.d.ts +9 -0
- package/dist/cjs/processors/processComEvents.js +122 -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 +124 -0
- package/dist/cjs/processors/processSceneLogic.d.ts +4 -0
- package/dist/cjs/processors/processSceneLogic.js +166 -0
- package/dist/cjs/taro-template.json +15 -7
- package/dist/cjs/toCodeTaro.d.ts +26 -5
- package/dist/cjs/toCodeTaro.js +59 -343
- package/dist/cjs/utils/builder/buildResult.d.ts +21 -0
- package/dist/cjs/utils/builder/buildResult.js +91 -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 +1 -1
- package/dist/cjs/utils/{handlePageConfig.js → config/handlePageConfig.js} +4 -4
- 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} +14 -11
- 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.js +1 -1
- package/dist/esm/core/mybricks/index.js +1 -1
- package/dist/esm/core/utils/ComContext.js +1 -0
- package/dist/esm/core/utils/hooks.js +118 -0
- package/dist/esm/core/utils/index.js +6 -57
- package/dist/esm/core/utils/page.js +50 -0
- package/dist/esm/core/utils/useContext.js +2 -1
- package/dist/esm/generate/generateTaroProjectJson.d.ts +3 -14
- package/dist/esm/generate/generateTaroProjectJson.js +27 -23
- 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 +2 -9
- package/dist/esm/handleSlot.js +97 -174
- package/dist/esm/processors/processComEvents.d.ts +9 -0
- package/dist/esm/processors/processComEvents.js +110 -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 +126 -0
- package/dist/esm/processors/processSceneLogic.d.ts +4 -0
- package/dist/esm/processors/processSceneLogic.js +160 -0
- package/dist/esm/taro-template.json +15 -7
- package/dist/esm/toCodeTaro.d.ts +26 -5
- package/dist/esm/toCodeTaro.js +96 -396
- package/dist/esm/utils/builder/buildResult.d.ts +21 -0
- package/dist/esm/utils/builder/buildResult.js +61 -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 +1 -1
- package/dist/esm/utils/{handlePageConfig.js → config/handlePageConfig.js} +1 -1
- 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 +98 -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} +11 -5
- 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/package.json +1 -1
- 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/cjs/utils/{code → templates}/scene.d.ts +0 -0
- /package/dist/esm/core/comlib/{Index.js → index.js} +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/{code → templates}/scene.d.ts +0 -0
- /package/dist/esm/utils/{code → templates}/scene.js +0 -0
package/dist/cjs/utils/index.js
CHANGED
|
@@ -16,6 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
21
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
22
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -29,293 +30,31 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
30
|
// src/utils/index.ts
|
|
30
31
|
var utils_exports = {};
|
|
31
32
|
__export(utils_exports, {
|
|
32
|
-
ImportManager: () => ImportManager,
|
|
33
|
-
camelToKebab: () => camelToKebab,
|
|
34
|
-
convertComponentStyle: () => convertComponentStyle,
|
|
35
|
-
convertRootStyle: () => convertRootStyle,
|
|
36
|
-
convertStyleAryToCss: () => convertStyleAryToCss,
|
|
37
|
-
firstCharToLowerCase: () => firstCharToLowerCase,
|
|
38
|
-
firstCharToUpperCase: () => firstCharToUpperCase,
|
|
39
|
-
genObjectCode: () => genObjectCode,
|
|
40
33
|
getRootComponentClassName: () => import_getComponentClassName.getRootComponentClassName,
|
|
41
|
-
getUiComponentCode: () =>
|
|
42
|
-
|
|
43
|
-
kebabToCamel: () => kebabToCamel
|
|
34
|
+
getUiComponentCode: () => import_templates.getUiComponentCode,
|
|
35
|
+
pxtransform: () => import_pxtransform.default
|
|
44
36
|
});
|
|
45
37
|
module.exports = __toCommonJS(utils_exports);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
packageName,
|
|
57
|
-
dependencyNames,
|
|
58
|
-
importType
|
|
59
|
-
}) {
|
|
60
|
-
if (!packageName) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
const { _imports } = this;
|
|
64
|
-
if (!_imports[packageName]) {
|
|
65
|
-
_imports[packageName] = {};
|
|
66
|
-
}
|
|
67
|
-
if (importType === "module" && dependencyNames.length === 0) {
|
|
68
|
-
_imports[packageName]["__module__"] = {
|
|
69
|
-
importType: "module"
|
|
70
|
-
};
|
|
71
|
-
} else {
|
|
72
|
-
dependencyNames.forEach((dependencyName) => {
|
|
73
|
-
_imports[packageName][dependencyName] = {
|
|
74
|
-
importType
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/** 依赖解析为code */
|
|
80
|
-
toCode() {
|
|
81
|
-
const indent = indentation(this._config.codeStyle.indent);
|
|
82
|
-
return Object.entries(this._imports).reduce(
|
|
83
|
-
(pre, [packageName, dependencies]) => {
|
|
84
|
-
var _a;
|
|
85
|
-
let defaultDependency = "";
|
|
86
|
-
let namedDependencies = "";
|
|
87
|
-
let moduleDependency = "";
|
|
88
|
-
const dependencyEntries = Object.entries(dependencies);
|
|
89
|
-
const hasModuleType = ((_a = dependencies["__module__"]) == null ? void 0 : _a.importType) === "module" || dependencyEntries.some(([, { importType }]) => importType === "module");
|
|
90
|
-
if (hasModuleType) {
|
|
91
|
-
return pre + `import '${packageName}';
|
|
92
|
-
`;
|
|
93
|
-
}
|
|
94
|
-
const validEntries = dependencyEntries.filter(([key]) => key !== "__module__");
|
|
95
|
-
const wrap = validEntries.length > 3;
|
|
96
|
-
validEntries.forEach(([dependencyName, { importType }], index) => {
|
|
97
|
-
if (importType === "default") {
|
|
98
|
-
defaultDependency = dependencyName;
|
|
99
|
-
} else if (importType === "named") {
|
|
100
|
-
if (wrap) {
|
|
101
|
-
namedDependencies += `${indent}${dependencyName},
|
|
102
|
-
`;
|
|
103
|
-
} else {
|
|
104
|
-
namedDependencies += `${index ? ", " : ""}${dependencyName}`;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
if (namedDependencies) {
|
|
109
|
-
if (wrap) {
|
|
110
|
-
namedDependencies = `{
|
|
111
|
-
${namedDependencies}}`;
|
|
112
|
-
} else {
|
|
113
|
-
namedDependencies = `{ ${namedDependencies} }`;
|
|
114
|
-
}
|
|
115
|
-
if (defaultDependency) {
|
|
116
|
-
defaultDependency += ", ";
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return pre + `import ${defaultDependency}${namedDependencies} from '${packageName}';
|
|
120
|
-
`;
|
|
121
|
-
},
|
|
122
|
-
""
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
var firstCharToUpperCase = (str) => {
|
|
127
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
128
|
-
};
|
|
129
|
-
var firstCharToLowerCase = (str) => {
|
|
130
|
-
return str.charAt(0).toLowerCase() + str.slice(1);
|
|
131
|
-
};
|
|
132
|
-
var indentation = (level) => {
|
|
133
|
-
return " ".repeat(level);
|
|
134
|
-
};
|
|
135
|
-
var camelToKebab = (str) => {
|
|
136
|
-
return str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
137
|
-
};
|
|
138
|
-
var kebabToCamel = (str) => {
|
|
139
|
-
return str.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
|
|
140
|
-
};
|
|
141
|
-
var convertRootStyle = (style) => {
|
|
142
|
-
const rootStyle = {};
|
|
143
|
-
Object.entries(style || {}).forEach(([key, value]) => {
|
|
144
|
-
if (key === "_new" || key === "themesId" || key === "visibility" || key === "styleAry") {
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
if (key === "layout") {
|
|
148
|
-
if (typeof value === "object" && value !== null) {
|
|
149
|
-
const layoutObj = value;
|
|
150
|
-
Object.entries(layoutObj).forEach(([lKey, lValue]) => {
|
|
151
|
-
if (lKey === "position") {
|
|
152
|
-
if (lValue === "smart") {
|
|
153
|
-
rootStyle["position"] = "absolute";
|
|
154
|
-
} else if (lValue !== "inherit") {
|
|
155
|
-
rootStyle["position"] = lValue;
|
|
156
|
-
}
|
|
157
|
-
} else {
|
|
158
|
-
const camelLayoutKey = kebabToCamel(lKey);
|
|
159
|
-
rootStyle[camelLayoutKey] = (0, import_pxtransform.default)(lValue);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
} else if (value === "flex-row") {
|
|
163
|
-
rootStyle["display"] = "flex";
|
|
164
|
-
rootStyle["flexDirection"] = "row";
|
|
165
|
-
} else if (value === "flex-column") {
|
|
166
|
-
rootStyle["display"] = "flex";
|
|
167
|
-
rootStyle["flexDirection"] = "column";
|
|
168
|
-
} else if (value === "smart") {
|
|
169
|
-
rootStyle["position"] = "relative";
|
|
170
|
-
}
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
const camelKey = key.includes("-") ? kebabToCamel(key) : key;
|
|
174
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
175
|
-
rootStyle[camelKey] = (0, import_pxtransform.default)(value);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
return rootStyle;
|
|
179
|
-
};
|
|
180
|
-
var convertComponentStyle = (style) => {
|
|
181
|
-
const resultStyle = {};
|
|
182
|
-
const rootStyle = convertRootStyle(style);
|
|
183
|
-
if (style.styleAry) {
|
|
184
|
-
style.styleAry.forEach(
|
|
185
|
-
({
|
|
186
|
-
css,
|
|
187
|
-
selector
|
|
188
|
-
}) => {
|
|
189
|
-
const transformedCss = {};
|
|
190
|
-
Object.entries(css).forEach(([cssKey, cssValue]) => {
|
|
191
|
-
if (cssKey === "layout") {
|
|
192
|
-
if (typeof cssValue === "object" && cssValue !== null) {
|
|
193
|
-
const layoutObj = cssValue;
|
|
194
|
-
Object.entries(layoutObj).forEach(([lKey, lValue]) => {
|
|
195
|
-
if (lKey === "position") {
|
|
196
|
-
if (lValue === "smart") {
|
|
197
|
-
transformedCss["position"] = "absolute";
|
|
198
|
-
} else if (lValue !== "inherit") {
|
|
199
|
-
transformedCss["position"] = lValue;
|
|
200
|
-
}
|
|
201
|
-
} else {
|
|
202
|
-
transformedCss[kebabToCamel(lKey)] = lValue;
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
} else if (cssValue === "flex-row") {
|
|
206
|
-
transformedCss["display"] = "flex";
|
|
207
|
-
transformedCss["flexDirection"] = "row";
|
|
208
|
-
} else if (cssValue === "flex-column") {
|
|
209
|
-
transformedCss["display"] = "flex";
|
|
210
|
-
transformedCss["flexDirection"] = "column";
|
|
211
|
-
} else if (cssValue === "smart") {
|
|
212
|
-
transformedCss["position"] = "relative";
|
|
213
|
-
}
|
|
214
|
-
} else {
|
|
215
|
-
const camelKey = cssKey.includes("-") ? kebabToCamel(cssKey) : cssKey;
|
|
216
|
-
transformedCss[camelKey] = (0, import_pxtransform.default)(cssValue);
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
resultStyle[selector] = transformedCss;
|
|
220
|
-
}
|
|
221
|
-
);
|
|
222
|
-
}
|
|
223
|
-
resultStyle["root"] = rootStyle;
|
|
224
|
-
return resultStyle;
|
|
225
|
-
};
|
|
226
|
-
var convertStyleAryToCss = (styleAry, parentSelector) => {
|
|
227
|
-
if (!Array.isArray(styleAry))
|
|
228
|
-
return "";
|
|
229
|
-
const prefix = parentSelector ? `.${parentSelector} ` : "";
|
|
230
|
-
return styleAry.map(({ selector, css }) => {
|
|
231
|
-
if (!selector || !css)
|
|
232
|
-
return "";
|
|
233
|
-
let finalSelector = selector;
|
|
234
|
-
if (finalSelector.startsWith(">")) {
|
|
235
|
-
finalSelector = `${prefix}${finalSelector}`;
|
|
236
|
-
} else {
|
|
237
|
-
finalSelector = `${prefix}${finalSelector}`;
|
|
238
|
-
}
|
|
239
|
-
const transformedCss = {};
|
|
240
|
-
Object.entries(css).forEach(([key, value]) => {
|
|
241
|
-
if (key === "layout") {
|
|
242
|
-
if (typeof value === "object" && value !== null) {
|
|
243
|
-
const layoutObj = value;
|
|
244
|
-
Object.entries(layoutObj).forEach(([lKey, lValue]) => {
|
|
245
|
-
if (lKey === "position") {
|
|
246
|
-
if (lValue === "smart") {
|
|
247
|
-
transformedCss["position"] = "absolute";
|
|
248
|
-
} else if (lValue !== "inherit") {
|
|
249
|
-
transformedCss["position"] = lValue;
|
|
250
|
-
}
|
|
251
|
-
} else {
|
|
252
|
-
transformedCss[kebabToCamel(lKey)] = lValue;
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
} else if (value === "flex-row") {
|
|
256
|
-
transformedCss["display"] = "flex";
|
|
257
|
-
transformedCss["flexDirection"] = "row";
|
|
258
|
-
} else if (value === "flex-column") {
|
|
259
|
-
transformedCss["display"] = "flex";
|
|
260
|
-
transformedCss["flexDirection"] = "column";
|
|
261
|
-
} else if (value === "smart") {
|
|
262
|
-
transformedCss["position"] = "relative";
|
|
263
|
-
}
|
|
264
|
-
} else {
|
|
265
|
-
transformedCss[kebabToCamel(key)] = value;
|
|
266
|
-
}
|
|
267
|
-
});
|
|
268
|
-
const cssString = Object.entries(transformedCss).map(([key, value]) => {
|
|
269
|
-
const kebabKey = camelToKebab(key);
|
|
270
|
-
const formattedValue = typeof value === "number" ? `${value}px` : value;
|
|
271
|
-
return ` ${kebabKey}: ${formattedValue};`;
|
|
272
|
-
}).join("\n");
|
|
273
|
-
return `${finalSelector} {
|
|
274
|
-
${cssString}
|
|
275
|
-
}`;
|
|
276
|
-
}).join("\n\n");
|
|
277
|
-
};
|
|
278
|
-
var genObjectCode = (object, config) => {
|
|
279
|
-
const { initialIndent, indentSize } = config;
|
|
280
|
-
const keys = Object.keys(object);
|
|
281
|
-
if (keys.length === 0)
|
|
282
|
-
return "{}";
|
|
283
|
-
let result = "{\n";
|
|
284
|
-
keys.forEach((key, idx) => {
|
|
285
|
-
const value = object[key];
|
|
286
|
-
let formattedValue;
|
|
287
|
-
if (Array.isArray(value)) {
|
|
288
|
-
formattedValue = JSON.stringify(value);
|
|
289
|
-
} else if (value && typeof value === "object") {
|
|
290
|
-
formattedValue = genObjectCode(value, {
|
|
291
|
-
initialIndent: initialIndent + indentSize,
|
|
292
|
-
indentSize
|
|
293
|
-
});
|
|
294
|
-
} else if (typeof value === "string") {
|
|
295
|
-
formattedValue = JSON.stringify(value);
|
|
296
|
-
} else {
|
|
297
|
-
formattedValue = String(value);
|
|
298
|
-
}
|
|
299
|
-
result += indentation(initialIndent + indentSize) + `${JSON.stringify(key)}: ${formattedValue}`;
|
|
300
|
-
if (idx < keys.length - 1)
|
|
301
|
-
result += ",";
|
|
302
|
-
result += "\n";
|
|
303
|
-
});
|
|
304
|
-
result += indentation(initialIndent) + "}";
|
|
305
|
-
return result;
|
|
306
|
-
};
|
|
38
|
+
__reExport(utils_exports, require("./style/types"), module.exports);
|
|
39
|
+
__reExport(utils_exports, require("./common/ImportManager"), module.exports);
|
|
40
|
+
__reExport(utils_exports, require("./common/string"), module.exports);
|
|
41
|
+
__reExport(utils_exports, require("./common/helper"), module.exports);
|
|
42
|
+
__reExport(utils_exports, require("./common/object"), module.exports);
|
|
43
|
+
__reExport(utils_exports, require("./style/color"), module.exports);
|
|
44
|
+
__reExport(utils_exports, require("./style/converter"), module.exports);
|
|
45
|
+
var import_pxtransform = __toESM(require("./style/pxtransform"));
|
|
46
|
+
var import_getComponentClassName = require("./style/getComponentClassName");
|
|
47
|
+
var import_templates = require("./templates");
|
|
307
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
308
49
|
0 && (module.exports = {
|
|
309
|
-
ImportManager,
|
|
310
|
-
camelToKebab,
|
|
311
|
-
convertComponentStyle,
|
|
312
|
-
convertRootStyle,
|
|
313
|
-
convertStyleAryToCss,
|
|
314
|
-
firstCharToLowerCase,
|
|
315
|
-
firstCharToUpperCase,
|
|
316
|
-
genObjectCode,
|
|
317
50
|
getRootComponentClassName,
|
|
318
51
|
getUiComponentCode,
|
|
319
|
-
|
|
320
|
-
|
|
52
|
+
pxtransform,
|
|
53
|
+
...require("./style/types"),
|
|
54
|
+
...require("./common/ImportManager"),
|
|
55
|
+
...require("./common/string"),
|
|
56
|
+
...require("./common/helper"),
|
|
57
|
+
...require("./common/object"),
|
|
58
|
+
...require("./style/color"),
|
|
59
|
+
...require("./style/converter")
|
|
321
60
|
});
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/utils/convertNamespace.ts
|
|
19
|
+
// src/utils/logic/convertNamespace.ts
|
|
20
20
|
var convertNamespace_exports = {};
|
|
21
21
|
__export(convertNamespace_exports, {
|
|
22
22
|
convertNamespaceToComponentName: () => convertNamespaceToComponentName,
|
|
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/utils/genJSModules.ts
|
|
19
|
+
// src/utils/logic/genJSModules.ts
|
|
20
20
|
var genJSModules_exports = {};
|
|
21
21
|
__export(genJSModules_exports, {
|
|
22
22
|
genJSModules: () => genJSModules
|
|
@@ -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>;
|
|
@@ -16,13 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/utils/handleProcess.ts
|
|
19
|
+
// src/utils/logic/handleProcess.ts
|
|
20
20
|
var handleProcess_exports = {};
|
|
21
21
|
__export(handleProcess_exports, {
|
|
22
22
|
handleProcess: () => handleProcess
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(handleProcess_exports);
|
|
25
|
-
var
|
|
25
|
+
var import_helper = require("../common/helper");
|
|
26
|
+
var import_object = require("../common/object");
|
|
26
27
|
var isJsCalculationComponent = (namespace) => {
|
|
27
28
|
return namespace === "mybricks.taro._muilt-inputJs" || namespace === "mybricks.core-comlib.js-ai";
|
|
28
29
|
};
|
|
@@ -32,8 +33,8 @@ var isJsApiComponent = (namespace, rtType) => {
|
|
|
32
33
|
var handleProcess = (event, config) => {
|
|
33
34
|
let code = "";
|
|
34
35
|
const { process } = event;
|
|
35
|
-
const indent = (0,
|
|
36
|
-
const indent2 = (0,
|
|
36
|
+
const indent = (0, import_helper.indentation)(config.codeStyle.indent * config.depth);
|
|
37
|
+
const indent2 = (0, import_helper.indentation)(config.codeStyle.indent * (config.depth + 1));
|
|
37
38
|
const hasJsCalculationComponent = process.nodesDeclaration.some(
|
|
38
39
|
({ meta }) => isJsCalculationComponent(meta.def.namespace)
|
|
39
40
|
);
|
|
@@ -98,7 +99,7 @@ var handleProcess = (event, config) => {
|
|
|
98
99
|
code += `${indent}/** ${meta.title} */
|
|
99
100
|
${indent}const ${componentNameWithId} = ${callName || componentName}({` + (config.verbose ? `
|
|
100
101
|
${indent2}title: "${meta.title}",` : "") + (props.data ? `
|
|
101
|
-
${indent2}data: ${(0,
|
|
102
|
+
${indent2}data: ${(0, import_object.genObjectCode)(props.data, {
|
|
102
103
|
initialIndent: config.codeStyle.indent * (config.depth + 1),
|
|
103
104
|
indentSize: config.codeStyle.indent
|
|
104
105
|
})},` : "") + (props.inputs ? `
|
|
@@ -252,6 +253,7 @@ var getNextCode = (props, config, isSameScope, event) => {
|
|
|
252
253
|
var getNextValue = (props, config, event) => {
|
|
253
254
|
const { paramSource } = props;
|
|
254
255
|
const nextValue = paramSource.map((param) => {
|
|
256
|
+
var _a, _b, _c;
|
|
255
257
|
if (param.type === "params") {
|
|
256
258
|
const params = config.getParams();
|
|
257
259
|
return params[param.id];
|
|
@@ -259,21 +261,22 @@ var getNextValue = (props, config, event) => {
|
|
|
259
261
|
return JSON.stringify(param.value);
|
|
260
262
|
}
|
|
261
263
|
const componentNameWithId = getComponentNameWithId(param, config, event);
|
|
262
|
-
if (param.
|
|
263
|
-
return `${componentNameWithId}
|
|
264
|
+
if ((_c = (_b = (_a = param.meta) == null ? void 0 : _a.def) == null ? void 0 : _b.namespace) == null ? void 0 : _c.includes(".var")) {
|
|
265
|
+
return `${componentNameWithId}_result`;
|
|
264
266
|
}
|
|
265
267
|
return `${componentNameWithId}_result.${param.id}`;
|
|
266
268
|
});
|
|
267
269
|
return nextValue.join(", ");
|
|
268
270
|
};
|
|
269
271
|
var getNextValueWithParam = (param, config, event) => {
|
|
272
|
+
var _a, _b, _c;
|
|
270
273
|
if (param.type === "params") {
|
|
271
274
|
const params = config.getParams();
|
|
272
275
|
return params[param.id];
|
|
273
276
|
}
|
|
274
277
|
const componentNameWithId = getComponentNameWithId(param, config, event);
|
|
275
|
-
if (param.
|
|
276
|
-
return `${componentNameWithId}
|
|
278
|
+
if ((_c = (_b = (_a = param.meta) == null ? void 0 : _a.def) == null ? void 0 : _b.namespace) == null ? void 0 : _c.includes(".var")) {
|
|
279
|
+
return `${componentNameWithId}_result`;
|
|
277
280
|
}
|
|
278
281
|
return `${componentNameWithId}_result.${param.id}`;
|
|
279
282
|
};
|
|
@@ -306,7 +309,7 @@ var generateJsCalculationComponentCode = (params) => {
|
|
|
306
309
|
return `${indent}/** ${meta.title} */
|
|
307
310
|
${indent}const ${componentNameWithId} = jsModules.${meta.id}({` + (config.verbose ? `
|
|
308
311
|
${indent2}title: "${meta.title}",` : "") + (Object.keys(jsData).length > 0 ? `
|
|
309
|
-
${indent2}data: ${(0,
|
|
312
|
+
${indent2}data: ${(0, import_object.genObjectCode)(jsData, {
|
|
310
313
|
initialIndent: config.codeStyle.indent * (config.depth + 1),
|
|
311
314
|
indentSize: config.codeStyle.indent
|
|
312
315
|
})},` : "") + (props.inputs ? `
|
|
@@ -353,7 +356,7 @@ var generateJsApiComponentCode = (params) => {
|
|
|
353
356
|
${indent}const ${componentNameWithId} = createJSHandle(${callName || componentName}, {
|
|
354
357
|
${indent2}props: {` + (config.verbose ? `
|
|
355
358
|
${indent2} title: "${meta.title}",` : "") + (props.data ? `
|
|
356
|
-
${indent2} data: ${(0,
|
|
359
|
+
${indent2} data: ${(0, import_object.genObjectCode)(props.data, {
|
|
357
360
|
initialIndent: config.codeStyle.indent * (config.depth + 2),
|
|
358
361
|
indentSize: config.codeStyle.indent
|
|
359
362
|
})},` : "") + (props.inputs ? `
|
|
@@ -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,82 @@
|
|
|
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/utils/logic/processChildren.ts
|
|
30
|
+
var processChildren_exports = {};
|
|
31
|
+
__export(processChildren_exports, {
|
|
32
|
+
processChildren: () => processChildren
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(processChildren_exports);
|
|
35
|
+
var import_handleCom = __toESM(require("../../handleCom"));
|
|
36
|
+
var import_handleDom = __toESM(require("../../handleDom"));
|
|
37
|
+
var import_handleModule = __toESM(require("../../handleModule"));
|
|
38
|
+
var processChildren = (children, config) => {
|
|
39
|
+
let uiCode = "";
|
|
40
|
+
let jsCode = "";
|
|
41
|
+
let cssContent = "";
|
|
42
|
+
const slots = [];
|
|
43
|
+
const scopeSlots = [];
|
|
44
|
+
children.forEach((child) => {
|
|
45
|
+
let result;
|
|
46
|
+
if (child.type === "com") {
|
|
47
|
+
result = (0, import_handleCom.default)(child, config);
|
|
48
|
+
} else if (child.type === "module") {
|
|
49
|
+
result = (0, import_handleModule.default)(child, config);
|
|
50
|
+
} else {
|
|
51
|
+
result = (0, import_handleDom.default)(child, config);
|
|
52
|
+
}
|
|
53
|
+
if (result) {
|
|
54
|
+
if (result.ui) {
|
|
55
|
+
uiCode += (uiCode ? "\n" : "") + result.ui;
|
|
56
|
+
}
|
|
57
|
+
if (result.js) {
|
|
58
|
+
jsCode += result.js;
|
|
59
|
+
}
|
|
60
|
+
if (result.cssContent) {
|
|
61
|
+
cssContent += (cssContent ? "\n" : "") + result.cssContent;
|
|
62
|
+
}
|
|
63
|
+
if (result.slots) {
|
|
64
|
+
slots.push(...result.slots);
|
|
65
|
+
}
|
|
66
|
+
if (result.scopeSlots) {
|
|
67
|
+
scopeSlots.push(...result.scopeSlots);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
ui: uiCode,
|
|
73
|
+
js: jsCode,
|
|
74
|
+
cssContent,
|
|
75
|
+
slots,
|
|
76
|
+
scopeSlots
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
processChildren
|
|
82
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
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/utils/style/color.ts
|
|
20
|
+
var color_exports = {};
|
|
21
|
+
__export(color_exports, {
|
|
22
|
+
colorToHex: () => colorToHex
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(color_exports);
|
|
25
|
+
function colorToHex(color) {
|
|
26
|
+
if (!color || typeof color !== "string")
|
|
27
|
+
return color;
|
|
28
|
+
if (!color.startsWith("rgb"))
|
|
29
|
+
return color;
|
|
30
|
+
const match = color.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)$/);
|
|
31
|
+
if (!match)
|
|
32
|
+
return color;
|
|
33
|
+
const r = parseInt(match[1]);
|
|
34
|
+
const g = parseInt(match[2]);
|
|
35
|
+
const b = parseInt(match[3]);
|
|
36
|
+
const toHex = (n) => {
|
|
37
|
+
const hex = n.toString(16);
|
|
38
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
39
|
+
};
|
|
40
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`.toLowerCase();
|
|
41
|
+
}
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
colorToHex
|
|
45
|
+
});
|
|
@@ -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;
|