@mybricks/to-code-taro 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/README.md +58 -0
  2. package/dist/cjs/core/comlib/_AesEncode.js +115 -0
  3. package/dist/cjs/core/comlib/_BackTo.js +80 -0
  4. package/dist/cjs/core/comlib/{Index.js → _CallPhone.js} +29 -16
  5. package/dist/cjs/core/comlib/_ChooseFile.js +103 -0
  6. package/dist/cjs/core/comlib/_ChooseMedia.js +70 -0
  7. package/dist/cjs/core/comlib/_Connector.js +92 -0
  8. package/dist/cjs/core/comlib/_ConnectorGlobalHeaders.js +79 -0
  9. package/dist/cjs/core/comlib/_Format.js +123 -0
  10. package/dist/cjs/core/comlib/_GetLocation.js +60 -0
  11. package/dist/cjs/core/comlib/_GetStorage.js +68 -0
  12. package/dist/cjs/core/comlib/_GetSystemInfo.js +62 -0
  13. package/dist/cjs/core/comlib/_OpenCamera.js +73 -0
  14. package/dist/cjs/core/comlib/_OpenPetalMap.js +49 -0
  15. package/dist/cjs/core/comlib/_OpenUrl.js +62 -0
  16. package/dist/cjs/core/comlib/_RemoveStorage.js +68 -0
  17. package/dist/cjs/core/comlib/_Router.js +100 -0
  18. package/dist/cjs/core/comlib/_ScanQrcode.js +9 -10
  19. package/dist/cjs/core/comlib/_SetStorage.js +10 -19
  20. package/dist/cjs/core/comlib/_Share.js +58 -0
  21. package/dist/cjs/core/comlib/_ShowToast.js +23 -50
  22. package/dist/cjs/core/comlib/_TextToSpeech.js +120 -0
  23. package/dist/cjs/core/comlib/_TimerDebounce.js +72 -0
  24. package/dist/cjs/core/comlib/_TimerDelay.js +63 -0
  25. package/dist/cjs/core/comlib/_TimerThrottle.js +75 -0
  26. package/dist/cjs/core/comlib/_Vibrate.js +60 -0
  27. package/dist/cjs/core/comlib/index.js +111 -0
  28. package/dist/cjs/core/mybricks/index.js +47 -47
  29. package/dist/cjs/core/utils/ComContext.js +3 -0
  30. package/dist/cjs/core/utils/PopupRenderer.js +63 -0
  31. package/dist/cjs/core/utils/hooks.js +131 -0
  32. package/dist/cjs/core/utils/index.js +33 -57
  33. package/dist/cjs/core/utils/pageRouter.js +81 -0
  34. package/dist/cjs/core/utils/popupRouter.js +98 -0
  35. package/dist/cjs/core/utils/useContext.js +11 -2
  36. package/dist/cjs/core/utils/with.js +37 -13
  37. package/dist/cjs/generate/generateTaroProjectJson.d.ts +3 -14
  38. package/dist/cjs/generate/generateTaroProjectJson.js +39 -6
  39. package/dist/cjs/generate/utils/tabBarImages.d.ts +1 -1
  40. package/dist/cjs/handleCom.d.ts +1 -1
  41. package/dist/cjs/handleCom.js +91 -177
  42. package/dist/cjs/handleDom.js +7 -44
  43. package/dist/cjs/handleExtension.d.ts +2 -2
  44. package/dist/cjs/handleExtension.js +5 -5
  45. package/dist/cjs/handleGlobal.d.ts +2 -12
  46. package/dist/cjs/handleGlobal.js +23 -7
  47. package/dist/cjs/handleModule.js +3 -3
  48. package/dist/cjs/handleSlot.d.ts +4 -9
  49. package/dist/cjs/handleSlot.js +61 -150
  50. package/dist/cjs/processors/processComEvents.d.ts +9 -0
  51. package/dist/cjs/processors/processComEvents.js +164 -0
  52. package/dist/cjs/processors/processModule.d.ts +31 -0
  53. package/dist/cjs/processors/processModule.js +125 -0
  54. package/dist/cjs/processors/processScene.d.ts +32 -0
  55. package/dist/cjs/processors/processScene.js +128 -0
  56. package/dist/cjs/processors/processSceneLogic.d.ts +4 -0
  57. package/dist/cjs/processors/processSceneLogic.js +170 -0
  58. package/dist/cjs/shims-taro.d.ts +20 -0
  59. package/dist/cjs/taro-template.json +501 -351
  60. package/dist/cjs/toCodeTaro.d.ts +27 -6
  61. package/dist/cjs/toCodeTaro.js +68 -340
  62. package/dist/cjs/utils/builder/buildResult.d.ts +22 -0
  63. package/dist/cjs/utils/builder/buildResult.js +117 -0
  64. package/dist/cjs/utils/common/ImportManager.d.ts +19 -0
  65. package/dist/cjs/utils/common/ImportManager.js +105 -0
  66. package/dist/cjs/utils/common/helper.d.ts +2 -0
  67. package/dist/cjs/utils/common/helper.js +31 -0
  68. package/dist/cjs/utils/common/object.d.ts +5 -0
  69. package/dist/cjs/utils/common/object.js +58 -0
  70. package/dist/cjs/utils/common/string.d.ts +8 -0
  71. package/dist/cjs/utils/common/string.js +46 -0
  72. package/dist/cjs/utils/{pageConfig → config/content}/converter.js +1 -1
  73. package/dist/cjs/utils/{pageConfig → config/content}/index.js +9 -9
  74. package/dist/cjs/utils/{pageConfig → config/content}/pageConfig.js +12 -22
  75. package/dist/{esm/utils/pageConfig → cjs/utils/config/content}/saveBase64Image.d.ts +1 -1
  76. package/dist/cjs/utils/{pageConfig → config/content}/saveBase64Image.js +8 -17
  77. package/dist/cjs/utils/{pageConfig → config/content}/tabBarConfig.js +9 -32
  78. package/dist/cjs/utils/config/content/types.js +17 -0
  79. package/dist/cjs/utils/{pageConfig → config/content}/validator.js +1 -1
  80. package/dist/{esm/utils → cjs/utils/config}/handlePageConfig.d.ts +3 -2
  81. package/dist/cjs/utils/{handlePageConfig.js → config/handlePageConfig.js} +7 -6
  82. package/dist/cjs/utils/context/buildContext.d.ts +24 -0
  83. package/dist/cjs/utils/context/buildContext.js +65 -0
  84. package/dist/cjs/utils/context/buildFrameMap.d.ts +16 -0
  85. package/dist/cjs/utils/context/buildFrameMap.js +106 -0
  86. package/dist/cjs/utils/context/buildGlobalData.d.ts +13 -0
  87. package/dist/cjs/utils/context/buildGlobalData.js +58 -0
  88. package/dist/cjs/utils/context/collectJSModules.d.ts +37 -0
  89. package/dist/cjs/utils/context/collectJSModules.js +91 -0
  90. package/dist/cjs/utils/context/createEventQueries.d.ts +45 -0
  91. package/dist/cjs/utils/context/createEventQueries.js +99 -0
  92. package/dist/cjs/utils/context/createProvider.d.ts +21 -0
  93. package/dist/cjs/utils/context/createProvider.js +49 -0
  94. package/dist/cjs/utils/index.d.ts +10 -62
  95. package/dist/cjs/utils/index.js +21 -282
  96. package/dist/cjs/utils/{convertNamespace.js → logic/convertNamespace.js} +1 -1
  97. package/dist/cjs/utils/{genJSModules.js → logic/genJSModules.js} +1 -1
  98. package/dist/{esm/utils → cjs/utils/logic}/handleProcess.d.ts +2 -2
  99. package/dist/cjs/utils/{handleProcess.js → logic/handleProcess.js} +40 -16
  100. package/dist/cjs/utils/logic/processChildren.d.ts +12 -0
  101. package/dist/cjs/utils/logic/processChildren.js +82 -0
  102. package/dist/cjs/utils/style/color.d.ts +4 -0
  103. package/dist/cjs/utils/style/color.js +45 -0
  104. package/dist/cjs/utils/style/converter.d.ts +7 -0
  105. package/dist/cjs/utils/style/converter.js +181 -0
  106. package/dist/cjs/utils/{getComponentClassName.js → style/getComponentClassName.js} +1 -1
  107. package/dist/cjs/utils/{pxtransform.js → style/pxtransform.js} +1 -1
  108. package/dist/cjs/utils/style/types.d.ts +23 -0
  109. package/dist/cjs/utils/{pageConfig → style}/types.js +1 -1
  110. package/dist/cjs/utils/{code → templates}/component.js +1 -1
  111. package/dist/cjs/utils/{code → templates}/index.js +4 -4
  112. package/dist/cjs/utils/{code → templates}/renderManager.js +1 -1
  113. package/dist/cjs/utils/{code → templates}/scene.d.ts +3 -1
  114. package/dist/cjs/utils/{code → templates}/scene.js +17 -5
  115. package/dist/esm/core/comlib/_AesEncode.js +85 -0
  116. package/dist/esm/core/comlib/_BackTo.js +66 -0
  117. package/dist/esm/core/comlib/_CallPhone.js +30 -0
  118. package/dist/esm/core/comlib/_ChooseFile.js +81 -0
  119. package/dist/esm/core/comlib/_ChooseMedia.js +38 -0
  120. package/dist/esm/core/comlib/_Connector.js +60 -0
  121. package/dist/esm/core/comlib/_ConnectorGlobalHeaders.js +56 -0
  122. package/dist/esm/core/comlib/_Format.js +102 -0
  123. package/dist/esm/core/comlib/_GetLocation.js +26 -0
  124. package/dist/esm/core/comlib/_GetStorage.js +44 -0
  125. package/dist/esm/core/comlib/_GetSystemInfo.js +32 -0
  126. package/dist/esm/core/comlib/_OpenCamera.js +44 -0
  127. package/dist/esm/core/comlib/_OpenPetalMap.js +28 -0
  128. package/dist/esm/core/comlib/_OpenUrl.js +36 -0
  129. package/dist/esm/core/comlib/_RemoveStorage.js +42 -0
  130. package/dist/esm/core/comlib/_Router.js +113 -0
  131. package/dist/esm/core/comlib/_ScanQrcode.js +10 -11
  132. package/dist/esm/core/comlib/_SetStorage.js +13 -25
  133. package/dist/esm/core/comlib/_Share.js +28 -0
  134. package/dist/esm/core/comlib/_ShowToast.js +32 -55
  135. package/dist/esm/core/comlib/_TextToSpeech.js +117 -0
  136. package/dist/esm/core/comlib/_TimerDebounce.js +66 -0
  137. package/dist/esm/core/comlib/_TimerDelay.js +47 -0
  138. package/dist/esm/core/comlib/_TimerThrottle.js +69 -0
  139. package/dist/esm/core/comlib/_Vibrate.js +34 -0
  140. package/dist/esm/core/comlib/index.js +37 -0
  141. package/dist/esm/core/mybricks/index.js +1 -1
  142. package/dist/esm/core/utils/ComContext.js +1 -0
  143. package/dist/esm/core/utils/PopupRenderer.js +27 -0
  144. package/dist/esm/core/utils/hooks.js +130 -0
  145. package/dist/esm/core/utils/index.js +8 -57
  146. package/dist/esm/core/utils/pageRouter.js +69 -0
  147. package/dist/esm/core/utils/popupRouter.js +116 -0
  148. package/dist/esm/core/utils/useContext.js +16 -3
  149. package/dist/esm/core/utils/with.js +62 -19
  150. package/dist/esm/generate/generateTaroProjectJson.d.ts +3 -14
  151. package/dist/esm/generate/generateTaroProjectJson.js +62 -24
  152. package/dist/esm/generate/utils/tabBarImages.d.ts +1 -1
  153. package/dist/esm/handleCom.d.ts +1 -1
  154. package/dist/esm/handleCom.js +159 -244
  155. package/dist/esm/handleDom.js +9 -48
  156. package/dist/esm/handleExtension.d.ts +2 -2
  157. package/dist/esm/handleExtension.js +5 -5
  158. package/dist/esm/handleGlobal.d.ts +2 -12
  159. package/dist/esm/handleGlobal.js +17 -3
  160. package/dist/esm/handleModule.js +3 -3
  161. package/dist/esm/handleSlot.d.ts +4 -9
  162. package/dist/esm/handleSlot.js +112 -173
  163. package/dist/esm/processors/processComEvents.d.ts +9 -0
  164. package/dist/esm/processors/processComEvents.js +167 -0
  165. package/dist/esm/processors/processModule.d.ts +31 -0
  166. package/dist/esm/processors/processModule.js +126 -0
  167. package/dist/esm/processors/processScene.d.ts +32 -0
  168. package/dist/esm/processors/processScene.js +134 -0
  169. package/dist/esm/processors/processSceneLogic.d.ts +4 -0
  170. package/dist/esm/processors/processSceneLogic.js +170 -0
  171. package/dist/esm/shims-taro.d.ts +20 -0
  172. package/dist/esm/taro-template.json +501 -351
  173. package/dist/esm/toCodeTaro.d.ts +27 -6
  174. package/dist/esm/toCodeTaro.js +110 -395
  175. package/dist/esm/utils/builder/buildResult.d.ts +22 -0
  176. package/dist/esm/utils/builder/buildResult.js +82 -0
  177. package/dist/esm/utils/common/ImportManager.d.ts +19 -0
  178. package/dist/esm/utils/common/ImportManager.js +103 -0
  179. package/dist/esm/utils/common/helper.d.ts +2 -0
  180. package/dist/esm/utils/common/helper.js +4 -0
  181. package/dist/esm/utils/common/object.d.ts +5 -0
  182. package/dist/esm/utils/common/object.js +32 -0
  183. package/dist/esm/utils/common/string.d.ts +8 -0
  184. package/dist/esm/utils/common/string.js +21 -0
  185. package/dist/esm/utils/config/content/pageConfig.js +40 -0
  186. package/dist/{cjs/utils/pageConfig → esm/utils/config/content}/saveBase64Image.d.ts +1 -1
  187. package/dist/esm/utils/{pageConfig → config/content}/saveBase64Image.js +11 -30
  188. package/dist/esm/utils/{pageConfig → config/content}/tabBarConfig.js +12 -34
  189. package/dist/{cjs/utils → esm/utils/config}/handlePageConfig.d.ts +3 -2
  190. package/dist/esm/utils/{handlePageConfig.js → config/handlePageConfig.js} +6 -2
  191. package/dist/esm/utils/context/buildContext.d.ts +24 -0
  192. package/dist/esm/utils/context/buildContext.js +53 -0
  193. package/dist/esm/utils/context/buildFrameMap.d.ts +16 -0
  194. package/dist/esm/utils/context/buildFrameMap.js +131 -0
  195. package/dist/esm/utils/context/buildGlobalData.d.ts +13 -0
  196. package/dist/esm/utils/context/buildGlobalData.js +44 -0
  197. package/dist/esm/utils/context/collectJSModules.d.ts +37 -0
  198. package/dist/esm/utils/context/collectJSModules.js +87 -0
  199. package/dist/esm/utils/context/createEventQueries.d.ts +45 -0
  200. package/dist/esm/utils/context/createEventQueries.js +99 -0
  201. package/dist/esm/utils/context/createProvider.d.ts +21 -0
  202. package/dist/esm/utils/context/createProvider.js +33 -0
  203. package/dist/esm/utils/index.d.ts +10 -62
  204. package/dist/esm/utils/index.js +12 -345
  205. package/dist/{cjs/utils → esm/utils/logic}/handleProcess.d.ts +2 -2
  206. package/dist/esm/utils/{handleProcess.js → logic/handleProcess.js} +42 -9
  207. package/dist/esm/utils/logic/processChildren.d.ts +12 -0
  208. package/dist/esm/utils/logic/processChildren.js +48 -0
  209. package/dist/esm/utils/style/color.d.ts +4 -0
  210. package/dist/esm/utils/style/color.js +17 -0
  211. package/dist/esm/utils/style/converter.d.ts +7 -0
  212. package/dist/esm/utils/style/converter.js +176 -0
  213. package/dist/esm/utils/style/types.d.ts +23 -0
  214. package/dist/esm/utils/style/types.js +1 -0
  215. package/dist/esm/utils/{code → templates}/scene.d.ts +3 -1
  216. package/dist/esm/utils/{code → templates}/scene.js +13 -5
  217. package/package.json +4 -2
  218. package/dist/esm/core/comlib/Index.js +0 -3
  219. package/dist/esm/utils/pageConfig/pageConfig.js +0 -60
  220. /package/dist/cjs/utils/{pageConfig → config/content}/converter.d.ts +0 -0
  221. /package/dist/cjs/utils/{pageConfig → config/content}/index.d.ts +0 -0
  222. /package/dist/cjs/utils/{pageConfig → config/content}/pageConfig.d.ts +0 -0
  223. /package/dist/cjs/utils/{pageConfig → config/content}/tabBarConfig.d.ts +0 -0
  224. /package/dist/cjs/utils/{pageConfig → config/content}/types.d.ts +0 -0
  225. /package/dist/cjs/utils/{pageConfig → config/content}/validator.d.ts +0 -0
  226. /package/dist/cjs/utils/{convertNamespace.d.ts → logic/convertNamespace.d.ts} +0 -0
  227. /package/dist/cjs/utils/{genJSModules.d.ts → logic/genJSModules.d.ts} +0 -0
  228. /package/dist/cjs/utils/{getComponentClassName.d.ts → style/getComponentClassName.d.ts} +0 -0
  229. /package/dist/cjs/utils/{pxtransform.d.ts → style/pxtransform.d.ts} +0 -0
  230. /package/dist/cjs/utils/{code → templates}/component.d.ts +0 -0
  231. /package/dist/cjs/utils/{code → templates}/index.d.ts +0 -0
  232. /package/dist/cjs/utils/{code → templates}/renderManager.d.ts +0 -0
  233. /package/dist/esm/utils/{pageConfig → config/content}/converter.d.ts +0 -0
  234. /package/dist/esm/utils/{pageConfig → config/content}/converter.js +0 -0
  235. /package/dist/esm/utils/{pageConfig → config/content}/index.d.ts +0 -0
  236. /package/dist/esm/utils/{pageConfig → config/content}/index.js +0 -0
  237. /package/dist/esm/utils/{pageConfig → config/content}/pageConfig.d.ts +0 -0
  238. /package/dist/esm/utils/{pageConfig → config/content}/tabBarConfig.d.ts +0 -0
  239. /package/dist/esm/utils/{pageConfig → config/content}/types.d.ts +0 -0
  240. /package/dist/esm/utils/{pageConfig → config/content}/types.js +0 -0
  241. /package/dist/esm/utils/{pageConfig → config/content}/validator.d.ts +0 -0
  242. /package/dist/esm/utils/{pageConfig → config/content}/validator.js +0 -0
  243. /package/dist/esm/utils/{convertNamespace.d.ts → logic/convertNamespace.d.ts} +0 -0
  244. /package/dist/esm/utils/{convertNamespace.js → logic/convertNamespace.js} +0 -0
  245. /package/dist/esm/utils/{genJSModules.d.ts → logic/genJSModules.d.ts} +0 -0
  246. /package/dist/esm/utils/{genJSModules.js → logic/genJSModules.js} +0 -0
  247. /package/dist/esm/utils/{getComponentClassName.d.ts → style/getComponentClassName.d.ts} +0 -0
  248. /package/dist/esm/utils/{getComponentClassName.js → style/getComponentClassName.js} +0 -0
  249. /package/dist/esm/utils/{pxtransform.d.ts → style/pxtransform.d.ts} +0 -0
  250. /package/dist/esm/utils/{pxtransform.js → style/pxtransform.js} +0 -0
  251. /package/dist/esm/utils/{code → templates}/component.d.ts +0 -0
  252. /package/dist/esm/utils/{code → templates}/component.js +0 -0
  253. /package/dist/esm/utils/{code → templates}/index.d.ts +0 -0
  254. /package/dist/esm/utils/{code → templates}/index.js +0 -0
  255. /package/dist/esm/utils/{code → templates}/renderManager.d.ts +0 -0
  256. /package/dist/esm/utils/{code → templates}/renderManager.js +0 -0
@@ -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: () => import_code.getUiComponentCode,
42
- indentation: () => indentation,
43
- kebabToCamel: () => kebabToCamel
34
+ getUiComponentCode: () => import_templates.getUiComponentCode,
35
+ pxtransform: () => import_pxtransform.default
44
36
  });
45
37
  module.exports = __toCommonJS(utils_exports);
46
- var import_pxtransform = __toESM(require("./pxtransform"));
47
- var import_code = require("./code");
48
- var import_getComponentClassName = require("./getComponentClassName");
49
- var ImportManager = class {
50
- constructor(_config) {
51
- this._config = _config;
52
- this._imports = {};
53
- }
54
- /** 添加依赖 */
55
- addImport({
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
- indentation,
320
- kebabToCamel
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 "./index";
2
- import type { BaseConfig } from "../toCodeTaro";
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 import_index = require("./index");
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, import_index.indentation)(config.codeStyle.indent * config.depth);
36
- const indent2 = (0, import_index.indentation)(config.codeStyle.indent * (config.depth + 1));
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, import_index.genObjectCode)(props.data, {
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 ? `
@@ -108,7 +109,7 @@ ${indent}}, appContext)
108
109
  `;
109
110
  });
110
111
  process.nodesInvocation.forEach((props) => {
111
- var _a, _b;
112
+ var _a, _b, _c, _d;
112
113
  const { componentType, category, runType } = props;
113
114
  let nextValue = getNextValue(props, config, event);
114
115
  const isSameScope = checkIsSameScope(event, props);
@@ -118,15 +119,36 @@ ${indent}}, appContext)
118
119
  }
119
120
  if (componentType === "js") {
120
121
  if (category === "scene") {
122
+ const _sceneId = props.meta.model.data._sceneId;
123
+ const targetScene = config.getSceneById(_sceneId);
124
+ const isPopup = (targetScene == null ? void 0 : targetScene.type) === "popup" || ((_a = targetScene == null ? void 0 : targetScene.deps) == null ? void 0 : _a.some((dep) => dep.namespace === "mybricks.taro.popup"));
125
+ const controllerName = isPopup ? "popupRouter" : "pageRouter";
121
126
  config.addParentDependencyImport({
122
127
  packageName: config.getComponentPackageName(),
123
- dependencyNames: ["page"],
128
+ dependencyNames: [controllerName],
124
129
  importType: "named"
125
130
  });
126
- const _sceneId = props.meta.model.data._sceneId;
127
131
  const operateName = props.meta.model.data.openType === "redirect" ? "replace" : "open";
128
132
  code += `${indent}/** 打开 ${props.meta.title} */
129
- ${indent}${nextCode}page.${operateName}("${((_a = config.getPageId) == null ? void 0 : _a.call(config, _sceneId)) || _sceneId}", ${nextValue})`;
133
+ ${indent}${nextCode}${controllerName}.${operateName}("${((_b = config.getPageId) == null ? void 0 : _b.call(config, _sceneId)) || _sceneId}", ${nextValue})`;
134
+ } else if (category === "frameOutput") {
135
+ const currentScene = config.getCurrentScene();
136
+ const pinProxy = (_c = currentScene == null ? void 0 : currentScene.pinProxies) == null ? void 0 : _c[`${props.meta.id}-${props.id}`];
137
+ if ((pinProxy == null ? void 0 : pinProxy.frameId) && (pinProxy == null ? void 0 : pinProxy.pinId)) {
138
+ const method = pinProxy.pinId;
139
+ const controllerName = config.isPopup ? "popupRouter" : "pageRouter";
140
+ config.addParentDependencyImport({
141
+ packageName: config.getComponentPackageName(),
142
+ dependencyNames: [controllerName],
143
+ importType: "named"
144
+ });
145
+ if (["commit", "cancel", "apply", "close"].includes(method)) {
146
+ const sceneId = pinProxy.frameId || (currentScene == null ? void 0 : currentScene.id);
147
+ const argCode = nextValue ? `, ${nextValue}` : "";
148
+ code += `${indent}/** ${props.meta.title} 输出 ${method} */
149
+ ${indent}${nextCode}${controllerName}.${method}("${sceneId}"${argCode})`;
150
+ }
151
+ }
130
152
  } else if (category === "normal") {
131
153
  let componentNameWithId = getComponentNameWithId(props, config, event);
132
154
  code += `${indent}/** 调用 ${props.meta.title} */
@@ -169,7 +191,7 @@ ${indent}${nextCode}this.${currentProvider.name}_Fxs.${props.meta.ioProxy.id}(${
169
191
  } else {
170
192
  const currentProvider = getCurrentProvider({ isSameScope, props }, config);
171
193
  currentProvider.controllers.add(props.meta.id);
172
- const componentController = ((_b = config.getComponentController) == null ? void 0 : _b.call(config, {
194
+ const componentController = ((_d = config.getComponentController) == null ? void 0 : _d.call(config, {
173
195
  com: props.meta,
174
196
  scene: config.getCurrentScene()
175
197
  })) || `controller_${props.meta.id}`;
@@ -252,6 +274,7 @@ var getNextCode = (props, config, isSameScope, event) => {
252
274
  var getNextValue = (props, config, event) => {
253
275
  const { paramSource } = props;
254
276
  const nextValue = paramSource.map((param) => {
277
+ var _a, _b, _c;
255
278
  if (param.type === "params") {
256
279
  const params = config.getParams();
257
280
  return params[param.id];
@@ -259,21 +282,22 @@ var getNextValue = (props, config, event) => {
259
282
  return JSON.stringify(param.value);
260
283
  }
261
284
  const componentNameWithId = getComponentNameWithId(param, config, event);
262
- if (param.connectId) {
263
- return `${componentNameWithId}_${param.connectId}.${param.id}`;
285
+ if ((_c = (_b = (_a = param.meta) == null ? void 0 : _a.def) == null ? void 0 : _b.namespace) == null ? void 0 : _c.includes(".var")) {
286
+ return `${componentNameWithId}_result`;
264
287
  }
265
288
  return `${componentNameWithId}_result.${param.id}`;
266
289
  });
267
290
  return nextValue.join(", ");
268
291
  };
269
292
  var getNextValueWithParam = (param, config, event) => {
293
+ var _a, _b, _c;
270
294
  if (param.type === "params") {
271
295
  const params = config.getParams();
272
296
  return params[param.id];
273
297
  }
274
298
  const componentNameWithId = getComponentNameWithId(param, config, event);
275
- if (param.connectId) {
276
- return `${componentNameWithId}_${param.connectId}.${param.id}`;
299
+ if ((_c = (_b = (_a = param.meta) == null ? void 0 : _a.def) == null ? void 0 : _b.namespace) == null ? void 0 : _c.includes(".var")) {
300
+ return `${componentNameWithId}_result`;
277
301
  }
278
302
  return `${componentNameWithId}_result.${param.id}`;
279
303
  };
@@ -306,7 +330,7 @@ var generateJsCalculationComponentCode = (params) => {
306
330
  return `${indent}/** ${meta.title} */
307
331
  ${indent}const ${componentNameWithId} = jsModules.${meta.id}({` + (config.verbose ? `
308
332
  ${indent2}title: "${meta.title}",` : "") + (Object.keys(jsData).length > 0 ? `
309
- ${indent2}data: ${(0, import_index.genObjectCode)(jsData, {
333
+ ${indent2}data: ${(0, import_object.genObjectCode)(jsData, {
310
334
  initialIndent: config.codeStyle.indent * (config.depth + 1),
311
335
  indentSize: config.codeStyle.indent
312
336
  })},` : "") + (props.inputs ? `
@@ -353,7 +377,7 @@ var generateJsApiComponentCode = (params) => {
353
377
  ${indent}const ${componentNameWithId} = createJSHandle(${callName || componentName}, {
354
378
  ${indent2}props: {` + (config.verbose ? `
355
379
  ${indent2} title: "${meta.title}",` : "") + (props.data ? `
356
- ${indent2} data: ${(0, import_index.genObjectCode)(props.data, {
380
+ ${indent2} data: ${(0, import_object.genObjectCode)(props.data, {
357
381
  initialIndent: config.codeStyle.indent * (config.depth + 2),
358
382
  indentSize: config.codeStyle.indent
359
383
  })},` : "") + (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,4 @@
1
+ /**
2
+ * 将 rgba 或 rgb 颜色转换为 hex 颜色
3
+ */
4
+ export declare function colorToHex(color: string): string;
@@ -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;