@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
|
@@ -0,0 +1,181 @@
|
|
|
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/style/converter.ts
|
|
30
|
+
var converter_exports = {};
|
|
31
|
+
__export(converter_exports, {
|
|
32
|
+
convertComponentStyle: () => convertComponentStyle,
|
|
33
|
+
convertRootStyle: () => convertRootStyle,
|
|
34
|
+
convertStyleAryToCss: () => convertStyleAryToCss
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(converter_exports);
|
|
37
|
+
var import_pxtransform = __toESM(require("./pxtransform"));
|
|
38
|
+
var import_string = require("../common/string");
|
|
39
|
+
var convertRootStyle = (style) => {
|
|
40
|
+
const rootStyle = {};
|
|
41
|
+
Object.entries(style || {}).forEach(([key, value]) => {
|
|
42
|
+
if (key === "_new" || key === "themesId" || key === "visibility" || key === "styleAry") {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (key === "layout") {
|
|
46
|
+
if (typeof value === "object" && value !== null) {
|
|
47
|
+
const layoutObj = value;
|
|
48
|
+
Object.entries(layoutObj).forEach(([lKey, lValue]) => {
|
|
49
|
+
if (lKey === "position") {
|
|
50
|
+
if (lValue === "smart") {
|
|
51
|
+
rootStyle["position"] = "absolute";
|
|
52
|
+
} else if (lValue !== "inherit") {
|
|
53
|
+
rootStyle["position"] = lValue;
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
const camelLayoutKey = (0, import_string.kebabToCamel)(lKey);
|
|
57
|
+
rootStyle[camelLayoutKey] = (0, import_pxtransform.default)(lValue);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
} else if (value === "flex-row") {
|
|
61
|
+
rootStyle["display"] = "flex";
|
|
62
|
+
rootStyle["flexDirection"] = "row";
|
|
63
|
+
} else if (value === "flex-column") {
|
|
64
|
+
rootStyle["display"] = "flex";
|
|
65
|
+
rootStyle["flexDirection"] = "column";
|
|
66
|
+
} else if (value === "smart") {
|
|
67
|
+
rootStyle["position"] = "relative";
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const camelKey = key.includes("-") ? (0, import_string.kebabToCamel)(key) : key;
|
|
72
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
73
|
+
rootStyle[camelKey] = (0, import_pxtransform.default)(value);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return rootStyle;
|
|
77
|
+
};
|
|
78
|
+
var convertComponentStyle = (style) => {
|
|
79
|
+
const resultStyle = {};
|
|
80
|
+
const rootStyle = convertRootStyle(style);
|
|
81
|
+
if (style.styleAry) {
|
|
82
|
+
style.styleAry.forEach(
|
|
83
|
+
({
|
|
84
|
+
css,
|
|
85
|
+
selector
|
|
86
|
+
}) => {
|
|
87
|
+
const transformedCss = {};
|
|
88
|
+
Object.entries(css).forEach(([cssKey, cssValue]) => {
|
|
89
|
+
if (cssKey === "layout") {
|
|
90
|
+
if (typeof cssValue === "object" && cssValue !== null) {
|
|
91
|
+
const layoutObj = cssValue;
|
|
92
|
+
Object.entries(layoutObj).forEach(([lKey, lValue]) => {
|
|
93
|
+
if (lKey === "position") {
|
|
94
|
+
if (lValue === "smart") {
|
|
95
|
+
transformedCss["position"] = "absolute";
|
|
96
|
+
} else if (lValue !== "inherit") {
|
|
97
|
+
transformedCss["position"] = lValue;
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
transformedCss[(0, import_string.kebabToCamel)(lKey)] = lValue;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
} else if (cssValue === "flex-row") {
|
|
104
|
+
transformedCss["display"] = "flex";
|
|
105
|
+
transformedCss["flexDirection"] = "row";
|
|
106
|
+
} else if (cssValue === "flex-column") {
|
|
107
|
+
transformedCss["display"] = "flex";
|
|
108
|
+
transformedCss["flexDirection"] = "column";
|
|
109
|
+
} else if (cssValue === "smart") {
|
|
110
|
+
transformedCss["position"] = "relative";
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
const camelKey = cssKey.includes("-") ? (0, import_string.kebabToCamel)(cssKey) : cssKey;
|
|
114
|
+
transformedCss[camelKey] = (0, import_pxtransform.default)(cssValue);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
resultStyle[selector] = transformedCss;
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
resultStyle["root"] = rootStyle;
|
|
122
|
+
return resultStyle;
|
|
123
|
+
};
|
|
124
|
+
var convertStyleAryToCss = (styleAry, parentSelector) => {
|
|
125
|
+
if (!Array.isArray(styleAry))
|
|
126
|
+
return "";
|
|
127
|
+
const prefix = parentSelector ? `.${parentSelector} ` : "";
|
|
128
|
+
return styleAry.map(({ selector, css }) => {
|
|
129
|
+
if (!selector || !css)
|
|
130
|
+
return "";
|
|
131
|
+
let finalSelector = selector;
|
|
132
|
+
if (finalSelector.startsWith(">")) {
|
|
133
|
+
finalSelector = `${prefix}${finalSelector}`;
|
|
134
|
+
} else {
|
|
135
|
+
finalSelector = `${prefix}${finalSelector}`;
|
|
136
|
+
}
|
|
137
|
+
const transformedCss = {};
|
|
138
|
+
Object.entries(css).forEach(([key, value]) => {
|
|
139
|
+
if (key === "layout") {
|
|
140
|
+
if (typeof value === "object" && value !== null) {
|
|
141
|
+
const layoutObj = value;
|
|
142
|
+
Object.entries(layoutObj).forEach(([lKey, lValue]) => {
|
|
143
|
+
if (lKey === "position") {
|
|
144
|
+
if (lValue === "smart") {
|
|
145
|
+
transformedCss["position"] = "absolute";
|
|
146
|
+
} else if (lValue !== "inherit") {
|
|
147
|
+
transformedCss["position"] = lValue;
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
transformedCss[(0, import_string.kebabToCamel)(lKey)] = lValue;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
} else if (value === "flex-row") {
|
|
154
|
+
transformedCss["display"] = "flex";
|
|
155
|
+
transformedCss["flexDirection"] = "row";
|
|
156
|
+
} else if (value === "flex-column") {
|
|
157
|
+
transformedCss["display"] = "flex";
|
|
158
|
+
transformedCss["flexDirection"] = "column";
|
|
159
|
+
} else if (value === "smart") {
|
|
160
|
+
transformedCss["position"] = "relative";
|
|
161
|
+
}
|
|
162
|
+
} else {
|
|
163
|
+
transformedCss[(0, import_string.kebabToCamel)(key)] = value;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
const cssString = Object.entries(transformedCss).map(([key, value]) => {
|
|
167
|
+
const kebabKey = (0, import_string.camelToKebab)(key);
|
|
168
|
+
const formattedValue = typeof value === "number" ? `${value}px` : value;
|
|
169
|
+
return ` ${kebabKey}: ${formattedValue};`;
|
|
170
|
+
}).join("\n");
|
|
171
|
+
return `${finalSelector} {
|
|
172
|
+
${cssString}
|
|
173
|
+
}`;
|
|
174
|
+
}).join("\n\n");
|
|
175
|
+
};
|
|
176
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
177
|
+
0 && (module.exports = {
|
|
178
|
+
convertComponentStyle,
|
|
179
|
+
convertRootStyle,
|
|
180
|
+
convertStyleAryToCss
|
|
181
|
+
});
|
|
@@ -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/getComponentClassName.ts
|
|
19
|
+
// src/utils/style/getComponentClassName.ts
|
|
20
20
|
var getComponentClassName_exports = {};
|
|
21
21
|
__export(getComponentClassName_exports, {
|
|
22
22
|
getComponentClassName: () => getComponentClassName,
|
|
@@ -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/pxtransform.ts
|
|
19
|
+
// src/utils/style/pxtransform.ts
|
|
20
20
|
var pxtransform_exports = {};
|
|
21
21
|
__export(pxtransform_exports, {
|
|
22
22
|
MIN_PX_THRESHOLD: () => MIN_PX_THRESHOLD,
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface Style {
|
|
2
|
+
layout?: "smart" | "flex-column" | "flex-row" | {
|
|
3
|
+
display?: string;
|
|
4
|
+
position?: string;
|
|
5
|
+
flexDirection?: string;
|
|
6
|
+
alignItems?: string;
|
|
7
|
+
justifyContent?: string;
|
|
8
|
+
flexWrap?: string;
|
|
9
|
+
rowGap?: number;
|
|
10
|
+
columnGap?: number;
|
|
11
|
+
};
|
|
12
|
+
width?: string | number;
|
|
13
|
+
height?: string | number;
|
|
14
|
+
styleAry?: Array<{
|
|
15
|
+
selector: string;
|
|
16
|
+
css: Record<string, any>;
|
|
17
|
+
}>;
|
|
18
|
+
slots?: Record<string, {
|
|
19
|
+
layout?: string | object;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}>;
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}
|
|
@@ -12,6 +12,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
12
12
|
};
|
|
13
13
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
14
|
|
|
15
|
-
// src/utils/
|
|
15
|
+
// src/utils/style/types.ts
|
|
16
16
|
var types_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(types_exports);
|
|
@@ -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/
|
|
19
|
+
// src/utils/templates/component.ts
|
|
20
20
|
var component_exports = {};
|
|
21
21
|
__export(component_exports, {
|
|
22
22
|
formatSlotContent: () => formatSlotContent,
|
|
@@ -16,12 +16,12 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
};
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
|
|
19
|
-
// src/utils/
|
|
20
|
-
var
|
|
21
|
-
__export(
|
|
19
|
+
// src/utils/templates/index.ts
|
|
20
|
+
var templates_exports = {};
|
|
21
|
+
__export(templates_exports, {
|
|
22
22
|
getUiComponentCode: () => getUiComponentCode
|
|
23
23
|
});
|
|
24
|
-
module.exports = __toCommonJS(
|
|
24
|
+
module.exports = __toCommonJS(templates_exports);
|
|
25
25
|
var import__ = require("../index");
|
|
26
26
|
var getUiComponentCode = (params, config) => {
|
|
27
27
|
const {
|
|
@@ -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/
|
|
19
|
+
// src/utils/templates/renderManager.ts
|
|
20
20
|
var renderManager_exports = {};
|
|
21
21
|
__export(renderManager_exports, {
|
|
22
22
|
RenderManager: () => RenderManager
|
|
@@ -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/
|
|
19
|
+
// src/utils/templates/scene.ts
|
|
20
20
|
var scene_exports = {};
|
|
21
21
|
__export(scene_exports, {
|
|
22
22
|
genComponentTemplate: () => genComponentTemplate,
|
|
@@ -5,7 +5,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
6
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
7
7
|
var _excluded = ["root"];
|
|
8
|
-
import { SUBJECT_NEXT, SUBJECT_VALUE, VARS_MARK, BASECONTROLLER_MARK, EXE_TITLE_MAP, CONTROLLER_CONTEXT, EXCUTE_TYPE_KEY, EXCUTE_TYPE_VALUE } from "./constant";
|
|
8
|
+
import { SUBJECT_NEXT, SUBJECT_VALUE, SUBJECT_SUBSCRIBE, VARS_MARK, BASECONTROLLER_MARK, EXE_TITLE_MAP, CONTROLLER_CONTEXT, EXCUTE_TYPE_KEY, EXCUTE_TYPE_VALUE } from "./constant";
|
|
9
9
|
import { log } from "./log";
|
|
10
10
|
import { Subject } from "./Subject";
|
|
11
11
|
import { context } from "./context";
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
+
import { useState, useRef, useMemo } from 'react';
|
|
4
|
+
import { SUBJECT_SUBSCRIBE } from "../mybricks/constant";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 深度代理,支持自动路径初始化和响应式更新(鸿蒙化处理方案)
|
|
8
|
+
*/
|
|
9
|
+
export function deepProxy(target, onSet) {
|
|
10
|
+
if (target === null || _typeof(target) !== 'object' || target.__isProxy) {
|
|
11
|
+
return target;
|
|
12
|
+
}
|
|
13
|
+
return new Proxy(target, {
|
|
14
|
+
get: function get(obj, prop) {
|
|
15
|
+
if (prop === '__isProxy') return true;
|
|
16
|
+
if (prop === 'toJSON') return function () {
|
|
17
|
+
return obj;
|
|
18
|
+
};
|
|
19
|
+
var value = obj[prop];
|
|
20
|
+
|
|
21
|
+
// 只有在访问不存在的对象属性时,才自动创建(实现类似 ensure 的效果)
|
|
22
|
+
// 特意排除 MyBricks 内置的方法名,以便在生成代码中进行初始化判断
|
|
23
|
+
var mybricksMethods = ['get', 'set', 'changed', 'reset', 'registerChange', 'call', 'apply', 'bind', 'push', 'pop'];
|
|
24
|
+
if (value === undefined && typeof prop === 'string' && !mybricksMethods.includes(prop)) {
|
|
25
|
+
value = obj[prop] = {};
|
|
26
|
+
}
|
|
27
|
+
if (_typeof(value) === 'object' && value !== null && !value.__isProxy) {
|
|
28
|
+
obj[prop] = deepProxy(value, onSet);
|
|
29
|
+
}
|
|
30
|
+
return obj[prop];
|
|
31
|
+
},
|
|
32
|
+
set: function set(obj, prop, value) {
|
|
33
|
+
var result = Reflect.set(obj, prop, value);
|
|
34
|
+
if (onSet) onSet();
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export function useModel(rawData) {
|
|
40
|
+
var _useState = useState({}),
|
|
41
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
42
|
+
forceUpdate = _useState2[1];
|
|
43
|
+
var dataRef = useRef(rawData || {});
|
|
44
|
+
return useMemo(function () {
|
|
45
|
+
return deepProxy(dataRef.current, function () {
|
|
46
|
+
return forceUpdate({});
|
|
47
|
+
});
|
|
48
|
+
}, []);
|
|
49
|
+
}
|
|
50
|
+
export function useBindInputs(scope, id) {
|
|
51
|
+
var handlersRef = useRef({});
|
|
52
|
+
return useMemo(function () {
|
|
53
|
+
var proxy = new Proxy({}, {
|
|
54
|
+
get: function get(_target, pin) {
|
|
55
|
+
return function (arg) {
|
|
56
|
+
if (typeof arg === 'function') {
|
|
57
|
+
// 组件注册回调
|
|
58
|
+
handlersRef.current[pin] = arg;
|
|
59
|
+
} else {
|
|
60
|
+
// 逻辑流触发输入
|
|
61
|
+
var handler = handlersRef.current[pin];
|
|
62
|
+
if (typeof handler === 'function') {
|
|
63
|
+
if (arg && arg[SUBJECT_SUBSCRIBE]) {
|
|
64
|
+
// 如果传入的是 Subject,自动订阅并触发回调
|
|
65
|
+
arg[SUBJECT_SUBSCRIBE](function (val) {
|
|
66
|
+
handler(val);
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
handler(arg);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
// 将代理对象挂载到作用域,供外部 comRefs.current.id.pin() 调用
|
|
78
|
+
scope[id] = proxy;
|
|
79
|
+
return proxy;
|
|
80
|
+
}, [scope, id]);
|
|
81
|
+
}
|
|
82
|
+
export function useBindEvents(props) {
|
|
83
|
+
return useMemo(function () {
|
|
84
|
+
var _events = {};
|
|
85
|
+
|
|
86
|
+
// 预处理已存在的事件
|
|
87
|
+
Object.keys(props).forEach(function (key) {
|
|
88
|
+
if (key.startsWith('on') && typeof props[key] === 'function') {
|
|
89
|
+
var handler = props[key];
|
|
90
|
+
var wrapped = function wrapped() {
|
|
91
|
+
return handler.apply(void 0, arguments);
|
|
92
|
+
};
|
|
93
|
+
wrapped.getConnections = function () {
|
|
94
|
+
return [{
|
|
95
|
+
id: 'default'
|
|
96
|
+
}];
|
|
97
|
+
};
|
|
98
|
+
_events[key] = wrapped;
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return new Proxy(_events, {
|
|
102
|
+
get: function get(target, key) {
|
|
103
|
+
if (typeof key === 'string' && key.startsWith('on')) {
|
|
104
|
+
if (target[key]) {
|
|
105
|
+
return target[key];
|
|
106
|
+
}
|
|
107
|
+
// 对未连接的事件返回兜底函数
|
|
108
|
+
var emptyFn = function emptyFn() {};
|
|
109
|
+
emptyFn.getConnections = function () {
|
|
110
|
+
return [];
|
|
111
|
+
};
|
|
112
|
+
return emptyFn;
|
|
113
|
+
}
|
|
114
|
+
return target[key];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}, [props]);
|
|
118
|
+
}
|
|
@@ -1,57 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var dataRef = useRef(rawData || {});
|
|
8
|
-
return useMemo(function () {
|
|
9
|
-
return new Proxy(dataRef.current, {
|
|
10
|
-
get: function get(target, key) {
|
|
11
|
-
return Reflect.get(target, key);
|
|
12
|
-
},
|
|
13
|
-
set: function set(target, key, value) {
|
|
14
|
-
var result = Reflect.set(target, key, value);
|
|
15
|
-
forceUpdate({});
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
}, []);
|
|
20
|
-
}
|
|
21
|
-
export function useBindInputs(scope, id) {
|
|
22
|
-
return useMemo(function () {
|
|
23
|
-
var controller = scope[id] = scope[id] || {};
|
|
24
|
-
return new Proxy({}, {
|
|
25
|
-
get: function get(_target, pin) {
|
|
26
|
-
return function (arg) {
|
|
27
|
-
if (typeof arg === 'function') {
|
|
28
|
-
controller[pin] = arg;
|
|
29
|
-
} else {
|
|
30
|
-
var callback = controller[pin];
|
|
31
|
-
if (typeof callback === 'function') {
|
|
32
|
-
callback(arg);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}, [scope, id]);
|
|
39
|
-
}
|
|
40
|
-
export function useBindEvents(props) {
|
|
41
|
-
return useMemo(function () {
|
|
42
|
-
var _events = {};
|
|
43
|
-
Object.keys(props).forEach(function (key) {
|
|
44
|
-
if (key.startsWith('on')) {
|
|
45
|
-
var handler = props[key];
|
|
46
|
-
if (typeof handler === 'function') {
|
|
47
|
-
_events[key] = handler;
|
|
48
|
-
_events[key].getConnections = function () {
|
|
49
|
-
return [1];
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
return _events;
|
|
55
|
-
}, [props]);
|
|
56
|
-
}
|
|
57
|
-
export { WithCom, WithWrapper } from "./with";
|
|
1
|
+
export * from "./hooks";
|
|
2
|
+
export { WithCom, WithWrapper } from "./with";
|
|
3
|
+
export { page } from "./page";
|
|
4
|
+
export { useAppContext } from "./ComContext";
|
|
5
|
+
export { createVariable, createFx, merge } from "../mybricks";
|
|
6
|
+
export { SUBJECT_SUBSCRIBE, SUBJECT_VALUE } from "../mybricks/constant";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
3
|
+
import Taro from '@tarojs/taro';
|
|
4
|
+
import { Page } from "../mybricks";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Taro 路由实现
|
|
8
|
+
*/
|
|
9
|
+
var TaroRouter = /*#__PURE__*/function () {
|
|
10
|
+
function TaroRouter() {
|
|
11
|
+
_classCallCheck(this, TaroRouter);
|
|
12
|
+
}
|
|
13
|
+
_createClass(TaroRouter, [{
|
|
14
|
+
key: "getParams",
|
|
15
|
+
value: function getParams(name) {
|
|
16
|
+
var _instance$router;
|
|
17
|
+
var instance = Taro.getCurrentInstance();
|
|
18
|
+
return {
|
|
19
|
+
value: (_instance$router = instance.router) === null || _instance$router === void 0 ? void 0 : _instance$router.params
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
key: "push",
|
|
24
|
+
value: function push(name, _ref) {
|
|
25
|
+
var value = _ref.value;
|
|
26
|
+
var url = "/pages/".concat(name, "/index");
|
|
27
|
+
var queryString = value ? "?data=".concat(encodeURIComponent(JSON.stringify(value))) : '';
|
|
28
|
+
Taro.navigateTo({
|
|
29
|
+
url: url + queryString
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}, {
|
|
33
|
+
key: "replace",
|
|
34
|
+
value: function replace(name, _ref2) {
|
|
35
|
+
var value = _ref2.value;
|
|
36
|
+
var url = "/pages/".concat(name, "/index");
|
|
37
|
+
var queryString = value ? "?data=".concat(encodeURIComponent(JSON.stringify(value))) : '';
|
|
38
|
+
Taro.redirectTo({
|
|
39
|
+
url: url + queryString
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}, {
|
|
43
|
+
key: "pop",
|
|
44
|
+
value: function pop() {
|
|
45
|
+
Taro.navigateBack();
|
|
46
|
+
}
|
|
47
|
+
}]);
|
|
48
|
+
return TaroRouter;
|
|
49
|
+
}();
|
|
50
|
+
export var page = new Page(new TaroRouter());
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
+
import type { GenerationResult } from "../toCodeTaro";
|
|
1
2
|
interface FileNode {
|
|
2
3
|
path: string;
|
|
3
4
|
content: string | null;
|
|
4
5
|
children?: FileNode[];
|
|
5
6
|
}
|
|
6
|
-
interface GenerateItem {
|
|
7
|
-
type: string;
|
|
8
|
-
content?: string;
|
|
9
|
-
cssContent?: string;
|
|
10
|
-
pageConfigContent?: string;
|
|
11
|
-
name?: string;
|
|
12
|
-
importManager?: {
|
|
13
|
-
toCode: () => string;
|
|
14
|
-
};
|
|
15
|
-
tabBarConfig?: string;
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
}
|
|
18
7
|
/**
|
|
19
8
|
* 根据数组生成文件结构 JSON 对象
|
|
20
|
-
* @param
|
|
9
|
+
* @param result 包含 files 和 assets 的生成结果对象
|
|
21
10
|
* @returns 返回文件结构的 JSON 对象数组
|
|
22
11
|
*/
|
|
23
|
-
declare const generateTaroProjectJson: (
|
|
12
|
+
declare const generateTaroProjectJson: (result: GenerationResult) => FileNode[];
|
|
24
13
|
export default generateTaroProjectJson;
|