@mybricks/to-code-taro 1.2.6 → 1.2.8

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.
Files changed (229) hide show
  1. package/package.json +1 -1
  2. package/dist/cjs/abstractEventTypeDef.d.ts +0 -11
  3. package/dist/cjs/abstractEventTypeDef.js +0 -93
  4. package/dist/cjs/generate/compressImages.d.ts +0 -16
  5. package/dist/cjs/generate/compressImages.js +0 -76
  6. package/dist/cjs/generate/generateTaroProjectJson.d.ts +0 -13
  7. package/dist/cjs/generate/generateTaroProjectJson.js +0 -225
  8. package/dist/cjs/generate/generateTaroTempalteJson.d.ts +0 -15
  9. package/dist/cjs/generate/generateTaroTempalteJson.js +0 -103
  10. package/dist/cjs/generate/utils/appConfig.d.ts +0 -21
  11. package/dist/cjs/generate/utils/appConfig.js +0 -57
  12. package/dist/cjs/generate/utils/commonDir.d.ts +0 -21
  13. package/dist/cjs/generate/utils/commonDir.js +0 -63
  14. package/dist/cjs/generate/utils/customTabBar.d.ts +0 -11
  15. package/dist/cjs/generate/utils/customTabBar.js +0 -73
  16. package/dist/cjs/generate/utils/fileNode.d.ts +0 -21
  17. package/dist/cjs/generate/utils/fileNode.js +0 -67
  18. package/dist/cjs/generate/utils/index.d.ts +0 -7
  19. package/dist/cjs/generate/utils/index.js +0 -29
  20. package/dist/cjs/generate/utils/pageImages.d.ts +0 -14
  21. package/dist/cjs/generate/utils/pageImages.js +0 -36
  22. package/dist/cjs/generate/utils/tabBarImages.d.ts +0 -14
  23. package/dist/cjs/generate/utils/tabBarImages.js +0 -36
  24. package/dist/cjs/handleCom.d.ts +0 -8
  25. package/dist/cjs/handleCom.js +0 -280
  26. package/dist/cjs/handleDom.d.ts +0 -21
  27. package/dist/cjs/handleDom.js +0 -52
  28. package/dist/cjs/handleExtension.d.ts +0 -10
  29. package/dist/cjs/handleExtension.js +0 -300
  30. package/dist/cjs/handleGlobal.d.ts +0 -11
  31. package/dist/cjs/handleGlobal.js +0 -191
  32. package/dist/cjs/handleModule.d.ts +0 -15
  33. package/dist/cjs/handleModule.js +0 -104
  34. package/dist/cjs/handleSlot.d.ts +0 -29
  35. package/dist/cjs/handleSlot.js +0 -153
  36. package/dist/cjs/index.d.ts +0 -4
  37. package/dist/cjs/index.js +0 -48
  38. package/dist/cjs/processors/processComEvents.d.ts +0 -9
  39. package/dist/cjs/processors/processComEvents.js +0 -163
  40. package/dist/cjs/processors/processModule.d.ts +0 -31
  41. package/dist/cjs/processors/processModule.js +0 -159
  42. package/dist/cjs/processors/processScene.d.ts +0 -32
  43. package/dist/cjs/processors/processScene.js +0 -198
  44. package/dist/cjs/processors/processSceneLogic.d.ts +0 -7
  45. package/dist/cjs/processors/processSceneLogic.js +0 -230
  46. package/dist/cjs/shims-taro.d.ts +0 -20
  47. package/dist/cjs/taro-template.json +0 -154
  48. package/dist/cjs/toCodeTaro.d.ts +0 -168
  49. package/dist/cjs/toCodeTaro.js +0 -326
  50. package/dist/cjs/utils/builder/buildResult.d.ts +0 -24
  51. package/dist/cjs/utils/builder/buildResult.js +0 -163
  52. package/dist/cjs/utils/common/ImportManager.d.ts +0 -26
  53. package/dist/cjs/utils/common/ImportManager.js +0 -123
  54. package/dist/cjs/utils/common/helper.d.ts +0 -12
  55. package/dist/cjs/utils/common/helper.js +0 -52
  56. package/dist/cjs/utils/common/object.d.ts +0 -5
  57. package/dist/cjs/utils/common/object.js +0 -58
  58. package/dist/cjs/utils/common/string.d.ts +0 -18
  59. package/dist/cjs/utils/common/string.js +0 -59
  60. package/dist/cjs/utils/config/content/converter.d.ts +0 -17
  61. package/dist/cjs/utils/config/content/converter.js +0 -84
  62. package/dist/cjs/utils/config/content/index.d.ts +0 -10
  63. package/dist/cjs/utils/config/content/index.js +0 -33
  64. package/dist/cjs/utils/config/content/pageConfig.d.ts +0 -10
  65. package/dist/cjs/utils/config/content/pageConfig.js +0 -80
  66. package/dist/cjs/utils/config/content/saveBase64Image.d.ts +0 -24
  67. package/dist/cjs/utils/config/content/saveBase64Image.js +0 -113
  68. package/dist/cjs/utils/config/content/tabBarConfig.d.ts +0 -28
  69. package/dist/cjs/utils/config/content/tabBarConfig.js +0 -74
  70. package/dist/cjs/utils/config/content/types.d.ts +0 -73
  71. package/dist/cjs/utils/config/content/types.js +0 -17
  72. package/dist/cjs/utils/config/content/validator.d.ts +0 -13
  73. package/dist/cjs/utils/config/content/validator.js +0 -67
  74. package/dist/cjs/utils/config/handlePageConfig.d.ts +0 -31
  75. package/dist/cjs/utils/config/handlePageConfig.js +0 -88
  76. package/dist/cjs/utils/context/buildContext.d.ts +0 -31
  77. package/dist/cjs/utils/context/buildContext.js +0 -76
  78. package/dist/cjs/utils/context/buildFrameMap.d.ts +0 -16
  79. package/dist/cjs/utils/context/buildFrameMap.js +0 -106
  80. package/dist/cjs/utils/context/buildGlobalData.d.ts +0 -13
  81. package/dist/cjs/utils/context/buildGlobalData.js +0 -58
  82. package/dist/cjs/utils/context/collectJSModules.d.ts +0 -41
  83. package/dist/cjs/utils/context/collectJSModules.js +0 -93
  84. package/dist/cjs/utils/context/createEventQueries.d.ts +0 -45
  85. package/dist/cjs/utils/context/createEventQueries.js +0 -99
  86. package/dist/cjs/utils/context/createProvider.d.ts +0 -21
  87. package/dist/cjs/utils/context/createProvider.js +0 -49
  88. package/dist/cjs/utils/index.d.ts +0 -10
  89. package/dist/cjs/utils/index.js +0 -60
  90. package/dist/cjs/utils/logic/convertNamespace.d.ts +0 -11
  91. package/dist/cjs/utils/logic/convertNamespace.js +0 -43
  92. package/dist/cjs/utils/logic/genJSModules.d.ts +0 -16
  93. package/dist/cjs/utils/logic/genJSModules.js +0 -114
  94. package/dist/cjs/utils/logic/handleProcess.d.ts +0 -9
  95. package/dist/cjs/utils/logic/handleProcess.js +0 -462
  96. package/dist/cjs/utils/logic/processChildren.d.ts +0 -26
  97. package/dist/cjs/utils/logic/processChildren.js +0 -121
  98. package/dist/cjs/utils/style/color.d.ts +0 -4
  99. package/dist/cjs/utils/style/color.js +0 -45
  100. package/dist/cjs/utils/style/converter.d.ts +0 -7
  101. package/dist/cjs/utils/style/converter.js +0 -175
  102. package/dist/cjs/utils/style/getComponentClassName.d.ts +0 -16
  103. package/dist/cjs/utils/style/getComponentClassName.js +0 -47
  104. package/dist/cjs/utils/style/pxtransform.d.ts +0 -4
  105. package/dist/cjs/utils/style/pxtransform.js +0 -62
  106. package/dist/cjs/utils/style/types.d.ts +0 -23
  107. package/dist/cjs/utils/style/types.js +0 -17
  108. package/dist/cjs/utils/templates/component.d.ts +0 -19
  109. package/dist/cjs/utils/templates/component.js +0 -86
  110. package/dist/cjs/utils/templates/index.d.ts +0 -32
  111. package/dist/cjs/utils/templates/index.js +0 -116
  112. package/dist/cjs/utils/templates/renderManager.d.ts +0 -18
  113. package/dist/cjs/utils/templates/renderManager.js +0 -152
  114. package/dist/cjs/utils/templates/scene.d.ts +0 -23
  115. package/dist/cjs/utils/templates/scene.js +0 -113
  116. package/dist/esm/abstractEventTypeDef.d.ts +0 -11
  117. package/dist/esm/abstractEventTypeDef.js +0 -63
  118. package/dist/esm/generate/compressImages.d.ts +0 -16
  119. package/dist/esm/generate/compressImages.js +0 -108
  120. package/dist/esm/generate/generateTaroProjectJson.d.ts +0 -13
  121. package/dist/esm/generate/generateTaroProjectJson.js +0 -228
  122. package/dist/esm/generate/generateTaroTempalteJson.d.ts +0 -15
  123. package/dist/esm/generate/generateTaroTempalteJson.js +0 -94
  124. package/dist/esm/generate/utils/appConfig.d.ts +0 -21
  125. package/dist/esm/generate/utils/appConfig.js +0 -49
  126. package/dist/esm/generate/utils/commonDir.d.ts +0 -21
  127. package/dist/esm/generate/utils/commonDir.js +0 -53
  128. package/dist/esm/generate/utils/customTabBar.d.ts +0 -11
  129. package/dist/esm/generate/utils/customTabBar.js +0 -52
  130. package/dist/esm/generate/utils/fileNode.d.ts +0 -21
  131. package/dist/esm/generate/utils/fileNode.js +0 -62
  132. package/dist/esm/generate/utils/index.d.ts +0 -7
  133. package/dist/esm/generate/utils/index.js +0 -8
  134. package/dist/esm/generate/utils/pageImages.d.ts +0 -14
  135. package/dist/esm/generate/utils/pageImages.js +0 -15
  136. package/dist/esm/generate/utils/tabBarImages.d.ts +0 -14
  137. package/dist/esm/generate/utils/tabBarImages.js +0 -15
  138. package/dist/esm/handleCom.d.ts +0 -8
  139. package/dist/esm/handleCom.js +0 -350
  140. package/dist/esm/handleDom.d.ts +0 -21
  141. package/dist/esm/handleDom.js +0 -26
  142. package/dist/esm/handleExtension.d.ts +0 -10
  143. package/dist/esm/handleExtension.js +0 -243
  144. package/dist/esm/handleGlobal.d.ts +0 -11
  145. package/dist/esm/handleGlobal.js +0 -157
  146. package/dist/esm/handleModule.d.ts +0 -15
  147. package/dist/esm/handleModule.js +0 -73
  148. package/dist/esm/handleSlot.d.ts +0 -29
  149. package/dist/esm/handleSlot.js +0 -215
  150. package/dist/esm/index.d.ts +0 -4
  151. package/dist/esm/index.js +0 -4
  152. package/dist/esm/processors/processComEvents.d.ts +0 -9
  153. package/dist/esm/processors/processComEvents.js +0 -170
  154. package/dist/esm/processors/processModule.d.ts +0 -31
  155. package/dist/esm/processors/processModule.js +0 -177
  156. package/dist/esm/processors/processScene.d.ts +0 -32
  157. package/dist/esm/processors/processScene.js +0 -234
  158. package/dist/esm/processors/processSceneLogic.d.ts +0 -7
  159. package/dist/esm/processors/processSceneLogic.js +0 -247
  160. package/dist/esm/shims-taro.d.ts +0 -20
  161. package/dist/esm/taro-template.json +0 -154
  162. package/dist/esm/toCodeTaro.d.ts +0 -168
  163. package/dist/esm/toCodeTaro.js +0 -367
  164. package/dist/esm/utils/builder/buildResult.d.ts +0 -24
  165. package/dist/esm/utils/builder/buildResult.js +0 -119
  166. package/dist/esm/utils/common/ImportManager.d.ts +0 -26
  167. package/dist/esm/utils/common/ImportManager.js +0 -131
  168. package/dist/esm/utils/common/helper.d.ts +0 -12
  169. package/dist/esm/utils/common/helper.js +0 -33
  170. package/dist/esm/utils/common/object.d.ts +0 -5
  171. package/dist/esm/utils/common/object.js +0 -32
  172. package/dist/esm/utils/common/string.d.ts +0 -18
  173. package/dist/esm/utils/common/string.js +0 -37
  174. package/dist/esm/utils/config/content/converter.d.ts +0 -17
  175. package/dist/esm/utils/config/content/converter.js +0 -106
  176. package/dist/esm/utils/config/content/index.d.ts +0 -10
  177. package/dist/esm/utils/config/content/index.js +0 -11
  178. package/dist/esm/utils/config/content/pageConfig.d.ts +0 -10
  179. package/dist/esm/utils/config/content/pageConfig.js +0 -43
  180. package/dist/esm/utils/config/content/saveBase64Image.d.ts +0 -24
  181. package/dist/esm/utils/config/content/saveBase64Image.js +0 -127
  182. package/dist/esm/utils/config/content/tabBarConfig.d.ts +0 -28
  183. package/dist/esm/utils/config/content/tabBarConfig.js +0 -89
  184. package/dist/esm/utils/config/content/types.d.ts +0 -73
  185. package/dist/esm/utils/config/content/types.js +0 -1
  186. package/dist/esm/utils/config/content/validator.d.ts +0 -13
  187. package/dist/esm/utils/config/content/validator.js +0 -64
  188. package/dist/esm/utils/config/handlePageConfig.d.ts +0 -31
  189. package/dist/esm/utils/config/handlePageConfig.js +0 -89
  190. package/dist/esm/utils/context/buildContext.d.ts +0 -31
  191. package/dist/esm/utils/context/buildContext.js +0 -65
  192. package/dist/esm/utils/context/buildFrameMap.d.ts +0 -16
  193. package/dist/esm/utils/context/buildFrameMap.js +0 -131
  194. package/dist/esm/utils/context/buildGlobalData.d.ts +0 -13
  195. package/dist/esm/utils/context/buildGlobalData.js +0 -44
  196. package/dist/esm/utils/context/collectJSModules.d.ts +0 -41
  197. package/dist/esm/utils/context/collectJSModules.js +0 -87
  198. package/dist/esm/utils/context/createEventQueries.d.ts +0 -45
  199. package/dist/esm/utils/context/createEventQueries.js +0 -99
  200. package/dist/esm/utils/context/createProvider.d.ts +0 -21
  201. package/dist/esm/utils/context/createProvider.js +0 -33
  202. package/dist/esm/utils/index.d.ts +0 -10
  203. package/dist/esm/utils/index.js +0 -12
  204. package/dist/esm/utils/logic/convertNamespace.d.ts +0 -11
  205. package/dist/esm/utils/logic/convertNamespace.js +0 -27
  206. package/dist/esm/utils/logic/genJSModules.d.ts +0 -16
  207. package/dist/esm/utils/logic/genJSModules.js +0 -33
  208. package/dist/esm/utils/logic/handleProcess.d.ts +0 -9
  209. package/dist/esm/utils/logic/handleProcess.js +0 -520
  210. package/dist/esm/utils/logic/processChildren.d.ts +0 -26
  211. package/dist/esm/utils/logic/processChildren.js +0 -101
  212. package/dist/esm/utils/style/color.d.ts +0 -4
  213. package/dist/esm/utils/style/color.js +0 -17
  214. package/dist/esm/utils/style/converter.d.ts +0 -7
  215. package/dist/esm/utils/style/converter.js +0 -175
  216. package/dist/esm/utils/style/getComponentClassName.d.ts +0 -16
  217. package/dist/esm/utils/style/getComponentClassName.js +0 -37
  218. package/dist/esm/utils/style/pxtransform.d.ts +0 -4
  219. package/dist/esm/utils/style/pxtransform.js +0 -54
  220. package/dist/esm/utils/style/types.d.ts +0 -23
  221. package/dist/esm/utils/style/types.js +0 -1
  222. package/dist/esm/utils/templates/component.d.ts +0 -19
  223. package/dist/esm/utils/templates/component.js +0 -55
  224. package/dist/esm/utils/templates/index.d.ts +0 -32
  225. package/dist/esm/utils/templates/index.js +0 -97
  226. package/dist/esm/utils/templates/renderManager.d.ts +0 -18
  227. package/dist/esm/utils/templates/renderManager.js +0 -145
  228. package/dist/esm/utils/templates/scene.d.ts +0 -23
  229. package/dist/esm/utils/templates/scene.js +0 -66
@@ -1,7 +0,0 @@
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;
@@ -1,175 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _typeof from "@babel/runtime/helpers/esm/typeof";
3
- import pxtransform from "./pxtransform";
4
- import { kebabToCamel, camelToKebab } from "../common/string";
5
- /**
6
- * 鸿蒙/Taro 规范:尺寸相关属性(数值即 px,需转 rpx)
7
- */
8
- var DIMENSION_PROPS = /^(width|height|padding|margin|top|right|bottom|left|fontSize|borderRadius|borderWidth|gap|rowGap|columnGap)/i;
9
- /**
10
- * 混合属性:数值视为倍数(不转),px 字符串视为固定高度(需转 rpx)
11
- */
12
- var MIXED_PROPS = /^(lineHeight)/i;
13
- var MIN_MAX_PROPS = /^(min|max)/i;
14
-
15
- /**
16
- * 判断是否为尺寸相关属性(数值即 px)
17
- */
18
- function isDimensionProp(key) {
19
- if (DIMENSION_PROPS.test(key)) return true;
20
- if (MIN_MAX_PROPS.test(key)) {
21
- var subKey = key.replace(/^(min|max)/i, "");
22
- var normalizedSubKey = subKey.charAt(0).toLowerCase() + subKey.slice(1);
23
- return DIMENSION_PROPS.test(normalizedSubKey);
24
- }
25
- return false;
26
- }
27
-
28
- /**
29
- * 统一处理样式值的转换逻辑
30
- */
31
- function transformStyleValue(key, value) {
32
- if (typeof value !== "string" && typeof value !== "number") return value;
33
-
34
- // 1. 尺寸属性:数值/px 字符串 均转换
35
- if (isDimensionProp(key)) {
36
- return pxtransform(value);
37
- }
38
-
39
- // 2. 混合属性 (如 lineHeight):仅转换 px 字符串,数值视为倍数保持原样
40
- if (MIXED_PROPS.test(key)) {
41
- return typeof value === "string" ? pxtransform(value) : value;
42
- }
43
-
44
- // 3. 其他属性 (如 zIndex, flex, fontWeight):保持原样
45
- return value;
46
- }
47
-
48
- /**
49
- * 提取通用的 layout 属性转换逻辑
50
- */
51
- function handleLayoutProp(value, target) {
52
- if (_typeof(value) === "object" && value !== null) {
53
- var layoutObj = value;
54
- Object.entries(layoutObj).forEach(function (_ref) {
55
- var _ref2 = _slicedToArray(_ref, 2),
56
- lKey = _ref2[0],
57
- lValue = _ref2[1];
58
- if (lKey === "position") {
59
- if (lValue === "smart") {
60
- if (target["position"] === undefined) {
61
- target["position"] = "relative";
62
- }
63
- } else if (lValue !== "inherit") {
64
- target["position"] = lValue;
65
- }
66
- } else {
67
- var camelLKey = kebabToCamel(lKey);
68
- target[camelLKey] = transformStyleValue(camelLKey, lValue);
69
- }
70
- });
71
- } else if (value === "flex-row") {
72
- target["display"] = "flex";
73
- target["flexDirection"] = "row";
74
- } else if (value === "flex-column") {
75
- target["display"] = "flex";
76
- target["flexDirection"] = "column";
77
- } else if (value === "smart") {
78
- if (target["position"] === undefined) {
79
- target["position"] = "relative";
80
- }
81
- }
82
- }
83
-
84
- /** 转换根节点样式 */
85
- export var convertRootStyle = function convertRootStyle(style) {
86
- var rootStyle = {};
87
- Object.entries(style || {}).forEach(function (_ref3) {
88
- var _ref4 = _slicedToArray(_ref3, 2),
89
- key = _ref4[0],
90
- value = _ref4[1];
91
- if (key === "_new" || key === "themesId" || key === "visibility" || key === "styleAry") {
92
- return;
93
- }
94
- if (key === "layout") {
95
- handleLayoutProp(value, rootStyle);
96
- return;
97
- }
98
-
99
- // widthAuto、heightAuto、widthFull、heightFull
100
- if (key === "widthAuto" && value === true) {
101
- rootStyle["width"] = "auto";
102
- } else if (key === "heightAuto" && value === true) {
103
- rootStyle["height"] = "auto";
104
- } else if (key === "widthFull" && value === true) {
105
- rootStyle["width"] = "100%";
106
- } else if (key === "heightFull" && value === true) {
107
- rootStyle["height"] = "100%";
108
- }
109
- var camelKey = key.includes("-") ? kebabToCamel(key) : key;
110
- rootStyle[camelKey] = transformStyleValue(camelKey, value);
111
- });
112
- return rootStyle;
113
- };
114
-
115
- /** 转换组件样式为 Taro/React 样式 */
116
- export var convertComponentStyle = function convertComponentStyle(style) {
117
- var resultStyle = {};
118
- var rootStyle = convertRootStyle(style);
119
- if (style.styleAry) {
120
- style.styleAry.forEach(function (_ref5) {
121
- var css = _ref5.css,
122
- selector = _ref5.selector;
123
- var transformedCss = {};
124
- Object.entries(css).forEach(function (_ref6) {
125
- var _ref7 = _slicedToArray(_ref6, 2),
126
- cssKey = _ref7[0],
127
- cssValue = _ref7[1];
128
- if (cssKey === "layout") {
129
- handleLayoutProp(cssValue, transformedCss);
130
- } else {
131
- var camelKey = cssKey.includes("-") ? kebabToCamel(cssKey) : cssKey;
132
- transformedCss[camelKey] = transformStyleValue(camelKey, cssValue);
133
- }
134
- });
135
- resultStyle[selector] = transformedCss;
136
- });
137
- }
138
- resultStyle["root"] = rootStyle;
139
- return resultStyle;
140
- };
141
-
142
- /** 转换 styleAry 为 CSS 字符串 */
143
- export var convertStyleAryToCss = function convertStyleAryToCss(styleAry, parentSelector) {
144
- if (!Array.isArray(styleAry)) return "";
145
- return styleAry.map(function (_ref8) {
146
- var selector = _ref8.selector,
147
- css = _ref8.css;
148
- if (!selector || !css) return "";
149
- var finalSelector = selector.trim();
150
- if (parentSelector) {
151
- var prefix = ".".concat(parentSelector);
152
- finalSelector = "".concat(prefix, " ").concat(finalSelector);
153
- }
154
- var transformedCss = {};
155
- Object.entries(css).forEach(function (_ref9) {
156
- var _ref10 = _slicedToArray(_ref9, 2),
157
- key = _ref10[0],
158
- value = _ref10[1];
159
- if (key === "layout") {
160
- handleLayoutProp(value, transformedCss);
161
- } else {
162
- var camelKey = kebabToCamel(key);
163
- transformedCss[camelKey] = transformStyleValue(camelKey, value);
164
- }
165
- });
166
- var cssString = Object.entries(transformedCss).map(function (_ref11) {
167
- var _ref12 = _slicedToArray(_ref11, 2),
168
- key = _ref12[0],
169
- value = _ref12[1];
170
- var kebabKey = camelToKebab(key);
171
- return " ".concat(kebabKey, ": ").concat(value, ";");
172
- }).join("\n");
173
- return "".concat(finalSelector, " {\n").concat(cssString, "\n}");
174
- }).join("\n\n");
175
- };
@@ -1,16 +0,0 @@
1
- /**
2
- * 从组件的 namespace 转换为 className
3
- * 例如:mybricks.taro.systemPage -> mybricks_taro_systemPage
4
- * 例如:mybricks.taro.image -> mybricks_taro_image
5
- * @param namespace 组件的 namespace
6
- * @returns className(用下划线替换点)
7
- */
8
- export declare function getComponentClassName(namespace: string): string;
9
- /**
10
- * 从场景中获取根组件的 className
11
- * 获取场景中第一个组件的命名空间并转换为 className(仅用于根组件)
12
- * @param scene 场景对象
13
- * @param isRoot 是否为根组件
14
- * @returns className 字符串,如果不是根组件或未找到则返回空字符串
15
- */
16
- export declare function getRootComponentClassName(scene: any, isRoot?: boolean): string;
@@ -1,37 +0,0 @@
1
- /**
2
- * 从组件的 namespace 转换为 className
3
- * 例如:mybricks.taro.systemPage -> mybricks_taro_systemPage
4
- * 例如:mybricks.taro.image -> mybricks_taro_image
5
- * @param namespace 组件的 namespace
6
- * @returns className(用下划线替换点)
7
- */
8
- export function getComponentClassName(namespace) {
9
- if (!namespace) {
10
- return '';
11
- }
12
- // 将点替换为下划线
13
- return namespace.replace(/\./g, '_');
14
- }
15
-
16
- /**
17
- * 从场景中获取根组件的 className
18
- * 获取场景中第一个组件的命名空间并转换为 className(仅用于根组件)
19
- * @param scene 场景对象
20
- * @param isRoot 是否为根组件
21
- * @returns className 字符串,如果不是根组件或未找到则返回空字符串
22
- */
23
- export function getRootComponentClassName(scene) {
24
- var _firstCom$def;
25
- var isRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
26
- // 只在根组件时获取 className
27
- if (!isRoot || !scene || !scene.coms) {
28
- return '';
29
- }
30
-
31
- // 获取场景中第一个组件的 namespace
32
- var firstCom = Object.values(scene.coms)[0];
33
- if (firstCom !== null && firstCom !== void 0 && (_firstCom$def = firstCom.def) !== null && _firstCom$def !== void 0 && _firstCom$def.namespace) {
34
- return getComponentClassName(firstCom.def.namespace);
35
- }
36
- return '';
37
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * 样式转换主函数
3
- */
4
- export default function pxtransform(value: any, target?: "rpx" | "rem"): any;
@@ -1,54 +0,0 @@
1
- /**
2
- * px 转 rpx (Taro 标准)
3
- */
4
- function pxToRpx(value) {
5
- if (typeof value === "number") {
6
- return "".concat(value * 2, "rpx");
7
- }
8
- if (typeof value !== "string") return String(value);
9
-
10
- // 处理带有 px 的字符串,支持替换所有 px
11
- return value.replace(/(\d*\.?\d+)px/g, function (_, num) {
12
- return "".concat(parseFloat(num) * 2, "rpx");
13
- });
14
- }
15
-
16
- /**
17
- * px 转 rem (H5 标准)
18
- */
19
- function pxToRem(value) {
20
- if (typeof value === "number") {
21
- return "".concat(value / 16, "rem");
22
- }
23
- if (typeof value !== "string") return String(value);
24
- return value.replace(/(\d*\.?\d+)px/g, function (_, num) {
25
- return "".concat(parseFloat(num) / 16, "rem");
26
- });
27
- }
28
-
29
- /**
30
- * 判断是否需要转换
31
- */
32
- function isPxValue(value) {
33
- if (typeof value === "number") {
34
- return true;
35
- }
36
- if (typeof value === "string") {
37
- return /\d*\.?\d+px/.test(value); // 包含 px 的字符串或数字需要转换
38
- }
39
- return false;
40
- }
41
-
42
- /**
43
- * 样式转换主函数
44
- */
45
- export default function pxtransform(value) {
46
- var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "rpx";
47
- if (!isPxValue(value)) {
48
- return value;
49
- }
50
- if (target === "rem") {
51
- return pxToRem(value);
52
- }
53
- return pxToRpx(value);
54
- }
@@ -1,23 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- /** 生成组件 Inputs 映射代码 */
2
- export declare const genComponentInputsCode: (indent: string, providerName: string, comId: string) => string;
3
- /** 生成组件 Outputs 映射代码 */
4
- export declare const genComponentOutputsCode: (indent: string, comId: string, comEventCode: string) => string;
5
- /** 包装单个事件处理函数,注入 getConnections */
6
- export declare const wrapEventProcess: (indent: string, eventId: string, defaultValue: string, process: string) => string;
7
- /** 生成插槽渲染函数引用(使用 renderManager) */
8
- export declare const genSlotRenderRef: ({ slotId, renderId, indent, isLast }: {
9
- slotId: string;
10
- renderId: string;
11
- indent: string;
12
- isLast: boolean;
13
- }) => string;
14
- /** 格式化插槽内容为 render 函数体代码 */
15
- export declare const formatSlotContent: ({ uiContent, baseIndentSize, renderBodyIndent }: {
16
- uiContent: string;
17
- baseIndentSize: number;
18
- renderBodyIndent: string;
19
- }) => string;
@@ -1,55 +0,0 @@
1
- import { indentation, toSlotFunctionName } from "./index";
2
- /** 生成组件 Inputs 映射代码 */
3
- export var genComponentInputsCode = function genComponentInputsCode(indent, providerName, comId) {
4
- return "".concat(indent, "inputs['").concat(comId, "'] = useBindInputs(controllers.current.").concat(providerName, ", '").concat(comId, "');\n");
5
- };
6
-
7
- /** 生成组件 Outputs 映射代码 */
8
- export var genComponentOutputsCode = function genComponentOutputsCode(indent, comId, comEventCode) {
9
- if (!comEventCode) return "";
10
- return "".concat(indent, "outputs['").concat(comId, "'] = {\n") + "".concat(comEventCode) + "".concat(indent, "};\n");
11
- };
12
-
13
- /** 包装单个事件处理函数,注入 getConnections */
14
- export var wrapEventProcess = function wrapEventProcess(indent, eventId, defaultValue, process) {
15
- return "".concat(indent).concat(eventId, ": Object.assign((").concat(defaultValue, ": any) => {\n") + "".concat(process, "\n") + "".concat(indent, "}, { getConnections: () => [1] }),\n");
16
- };
17
-
18
- /** 生成插槽渲染函数引用(使用 renderManager) */
19
- export var genSlotRenderRef = function genSlotRenderRef(_ref) {
20
- var slotId = _ref.slotId,
21
- renderId = _ref.renderId,
22
- indent = _ref.indent,
23
- isLast = _ref.isLast;
24
- var renderFunctionName = toSlotFunctionName(renderId);
25
- return "".concat(indent).concat(slotId, ": {\n").concat(indent, " render: ").concat(renderFunctionName, ",\n").concat(indent, "}").concat(isLast ? '' : ',', "\n");
26
- };
27
-
28
- /** 格式化插槽内容为 render 函数体代码 */
29
- export var formatSlotContent = function formatSlotContent(_ref2) {
30
- var uiContent = _ref2.uiContent,
31
- baseIndentSize = _ref2.baseIndentSize,
32
- renderBodyIndent = _ref2.renderBodyIndent;
33
- var lines = uiContent.split('\n');
34
- var formattedLines = [];
35
- lines.forEach(function (line) {
36
- var trimmedLine = line.trim();
37
- if (!trimmedLine) {
38
- return; // 跳过空行
39
- }
40
-
41
- // 计算原有缩进(相对于 depth=1 的缩进)
42
- var originalIndentMatch = line.match(/^(\s*)/);
43
- var originalIndent = originalIndentMatch ? originalIndentMatch[1].length : 0;
44
-
45
- // 计算相对缩进层级(相对于 depth=1,即 baseIndentSize)
46
- var relativeIndentLevel = Math.floor(originalIndent / baseIndentSize);
47
-
48
- // 新的缩进 = render 函数体内部基础缩进 + 相对缩进
49
- // renderBodyIndent 已经是函数体内部的缩进(通常是 4 个空格)
50
- // 然后再加上相对缩进层级 * baseIndentSize
51
- var newIndent = renderBodyIndent + indentation(baseIndentSize * relativeIndentLevel);
52
- formattedLines.push(newIndent + trimmedLine);
53
- });
54
- return formattedLines.join('\n');
55
- };
@@ -1,32 +0,0 @@
1
- import { indentation } from "../index";
2
- export { indentation };
3
- /** 将第一个字符转大写 */
4
- export declare const firstCharToUpperCase: (str: string) => string;
5
- /** 格式化插槽内容缩进 */
6
- export declare const formatSlotContent: (uiContent: string, baseIndentSize: number, renderBodyIndent: string) => string;
7
- /** 将字符串转为大驼峰 */
8
- export declare const toPascalCase: (str: string) => string;
9
- /** 生成插槽渲染函数名:S${ID} (SCREAMING_SNAKE_CASE) */
10
- export declare const toSlotFunctionName: (renderId: string) => string;
11
- /** Taro/React UI 组件代码生成 */
12
- export declare const getUiComponentCode: (params: {
13
- componentName: string;
14
- meta: any;
15
- props: any;
16
- resultStyle: Record<string, Record<string, string | number>>;
17
- /** 可选:自定义 data 的表达式代码(用于插槽动态入参等场景) */
18
- dataCode?: string;
19
- componentInputs?: string[];
20
- componentOutputs?: string[];
21
- comEventCode?: string;
22
- slotsCode?: string;
23
- childrenUi?: string;
24
- eventHandlers?: Record<string, string>;
25
- }, config: {
26
- codeStyle: {
27
- indent: number;
28
- };
29
- depth: number;
30
- verbose?: boolean;
31
- checkIsRoot: () => boolean;
32
- }) => string;
@@ -1,97 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- import { indentation } from "../index";
4
- export { indentation };
5
-
6
- /** 将第一个字符转大写 */
7
- export var firstCharToUpperCase = function firstCharToUpperCase(str) {
8
- if (!str) return str;
9
- return str.charAt(0).toUpperCase() + str.slice(1);
10
- };
11
-
12
- /** 格式化插槽内容缩进 */
13
- export var formatSlotContent = function formatSlotContent(uiContent, baseIndentSize, renderBodyIndent) {
14
- return uiContent.split("\n").map(function (line) {
15
- return "".concat(renderBodyIndent).concat(line);
16
- }).join("\n");
17
- };
18
-
19
- /** 将字符串转为大驼峰 */
20
- export var toPascalCase = function toPascalCase(str) {
21
- return str.split(/[_-]/).map(function (word) {
22
- return word.charAt(0).toUpperCase() + word.slice(1);
23
- }).join("");
24
- };
25
-
26
- /** 生成插槽渲染函数名:S${ID} (SCREAMING_SNAKE_CASE) */
27
- export var toSlotFunctionName = function toSlotFunctionName(renderId) {
28
- return "S".concat(renderId.replace(/[^a-zA-Z0-9]/g, "_").toUpperCase());
29
- };
30
-
31
- /** 根节点data去除无用属性 */
32
- var formatData = function formatData(data, isRoot) {
33
- if (!data) return {};
34
- if (!isRoot) return data;
35
- var delKeys = ['tabBar', 'navigationStyle', 'navigationBarBackgroundColor', 'navigationBarTextStyle', 'navigationBarTitleText', 'backgroundColorTop', 'backgroundColorBottom'];
36
- return Object.fromEntries(Object.entries(data).filter(function (_ref) {
37
- var _ref2 = _slicedToArray(_ref, 1),
38
- key = _ref2[0];
39
- return !delKeys.includes(key);
40
- }));
41
- };
42
-
43
- /** Taro/React UI 组件代码生成 */
44
- export var getUiComponentCode = function getUiComponentCode(params, config) {
45
- var componentName = params.componentName,
46
- meta = params.meta,
47
- props = params.props,
48
- resultStyle = params.resultStyle,
49
- dataCode = params.dataCode,
50
- slotsCode = params.slotsCode,
51
- childrenUi = params.childrenUi,
52
- _params$eventHandlers = params.eventHandlers,
53
- eventHandlers = _params$eventHandlers === void 0 ? {} : _params$eventHandlers;
54
- var isRoot = config.checkIsRoot();
55
- var indent = indentation(config.codeStyle.indent * config.depth);
56
- var indent2 = indentation(config.codeStyle.indent * (config.depth + 1));
57
-
58
- // 使用 WithCom 包裹组件
59
- var ui = "".concat(indent, "<WithCom");
60
- ui += "\n".concat(indent2, "component={").concat(componentName, "}");
61
- ui += "\n".concat(indent2, "id='").concat(meta.id, "'");
62
- ui += "\n".concat(indent2, "className='mybricks_com ").concat(meta.id, "'");
63
- if (meta.name) {
64
- ui += "\n".concat(indent2, "name='").concat(meta.name, "'");
65
- }
66
-
67
- // 添加 style
68
- if (resultStyle.root && Object.keys(resultStyle.root).length > 0) {
69
- var styleCode = JSON.stringify(resultStyle.root);
70
- ui += "\n".concat(indent2, "style={").concat(styleCode, "}");
71
- }
72
-
73
- // 添加 data
74
- var initialDataCode = dataCode !== null && dataCode !== void 0 ? dataCode : JSON.stringify(formatData(props.data, isRoot));
75
- ui += "\n".concat(indent2, "data={").concat(initialDataCode, "}");
76
-
77
- // 添加事件处理函数
78
- Object.entries(eventHandlers).forEach(function (_ref3) {
79
- var _ref4 = _slicedToArray(_ref3, 2),
80
- eventName = _ref4[0],
81
- handlerCode = _ref4[1];
82
- ui += "\n".concat(indent2).concat(eventName, "={").concat(handlerCode, "}");
83
- });
84
-
85
- // 添加插槽
86
- if (slotsCode) {
87
- ui += "\n".concat(indent2, "slots={{\n").concat(slotsCode).concat(indent2, "}}");
88
- }
89
- if (childrenUi) {
90
- ui += "\n".concat(indent, ">");
91
- ui += "\n".concat(childrenUi);
92
- ui += "\n".concat(indent, "</WithCom>");
93
- } else {
94
- ui += "\n".concat(indent, "/>");
95
- }
96
- return ui;
97
- };
@@ -1,18 +0,0 @@
1
- /** Render 函数管理器 */
2
- export declare class RenderManager {
3
- /** 存储格式:renderId -> { renderCode, children?, logicCode?, slotType?, useWrap?, description? } */
4
- private _renders;
5
- /**
6
- * 注册一个 render 函数
7
- */
8
- register(renderId: string, renderCode: string, children?: any[], logicCode?: string, slotType?: string, useWrap?: boolean, description?: string): void;
9
- /**
10
- * 生成所有 render 函数的 definition 代码
11
- */
12
- toCode(indent: string): string;
13
- /**
14
- * 转义字符串并创建能够匹配任意空白符的正则
15
- */
16
- private createFlexibleRegex;
17
- genRenderRef(slotId: string, renderId: string, indent: string): string;
18
- }