@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,462 +0,0 @@
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/logic/handleProcess.ts
20
- var handleProcess_exports = {};
21
- __export(handleProcess_exports, {
22
- handleProcess: () => handleProcess
23
- });
24
- module.exports = __toCommonJS(handleProcess_exports);
25
- var import_helper = require("../common/helper");
26
- var import_string = require("../common/string");
27
- var import_object = require("../common/object");
28
- var isJsCalculationComponent = (namespace) => {
29
- return namespace === "mybricks.taro._muilt-inputJs" || namespace === "mybricks.core-comlib.js-ai";
30
- };
31
- var isJsApiComponent = (namespace, rtType) => {
32
- const jsCompNamespace = ["mybricks.taro.", "mybricks.normal-pc."];
33
- return jsCompNamespace.some((_namespace) => namespace.startsWith(_namespace)) && (rtType == null ? void 0 : rtType.match(/^js/gi)) !== null;
34
- };
35
- var handleProcess = (event, config) => {
36
- let code = "";
37
- const { process } = event;
38
- const indent = (0, import_helper.indentation)(config.codeStyle.indent * config.depth);
39
- const indent2 = (0, import_helper.indentation)(config.codeStyle.indent * (config.depth + 1));
40
- const hasJsCalculationComponent = process.nodesDeclaration.some(
41
- ({ meta }) => isJsCalculationComponent(meta.def.namespace)
42
- );
43
- if (hasJsCalculationComponent) {
44
- config.addParentDependencyImport({
45
- packageName: "./index.jsModules",
46
- dependencyNames: ["jsModules"],
47
- importType: "named"
48
- });
49
- }
50
- process.nodesDeclaration.forEach(({ meta, props }) => {
51
- var _a;
52
- if (meta.def.namespace.startsWith("mybricks.taro.module")) {
53
- return;
54
- }
55
- const isJsCalc = isJsCalculationComponent(meta.def.namespace);
56
- const isJsApi = isJsApiComponent(meta.def.namespace, meta.def.rtType);
57
- const { importInfo, name, callName } = config.getComponentMeta(meta);
58
- const componentName = name;
59
- if (isJsCalc) {
60
- code += generateJsCalculationComponentCode({
61
- meta,
62
- props,
63
- componentName,
64
- config,
65
- event,
66
- indent,
67
- indent2
68
- });
69
- return;
70
- }
71
- if (isJsApi) {
72
- code += generateJsApiComponentCode({
73
- meta,
74
- props,
75
- componentName,
76
- callName,
77
- importInfo,
78
- config,
79
- event,
80
- indent,
81
- indent2
82
- });
83
- return;
84
- }
85
- config.addParentDependencyImport({
86
- packageName: importInfo.from,
87
- dependencyNames: [importInfo.name],
88
- importType: importInfo.type
89
- });
90
- const componentNameWithId = ((_a = config.getEventNodeName) == null ? void 0 : _a.call(config, {
91
- com: meta,
92
- scene: config.getCurrentScene(),
93
- type: "declaration",
94
- event
95
- })) || `${componentName}_${meta.id}`;
96
- config.addParentDependencyImport({
97
- packageName: config.getComponentPackageName(),
98
- dependencyNames: ["useAppContext"],
99
- importType: "named"
100
- });
101
- code += `${indent}/** ${meta.title} */
102
- ${indent}const ${componentNameWithId} = ${callName || componentName}({` + (config.verbose ? `
103
- ${indent2}title: "${meta.title}",` : "") + (props.data ? `
104
- ${indent2}data: ${(0, import_object.genObjectCode)(props.data, {
105
- initialIndent: config.codeStyle.indent * (config.depth + 1),
106
- indentSize: config.codeStyle.indent
107
- })},` : "") + (props.inputs ? `
108
- ${indent2}inputs: [${props.inputs.map((input) => `"${input}"`).join(", ")}],` : "") + (props.outputs ? `
109
- ${indent2}outputs: [${props.outputs.map((output) => `"${output}"`).join(", ")}],` : "") + `
110
- ${indent}}, appContext)
111
- `;
112
- });
113
- const outputToInputPinMap = /* @__PURE__ */ new Map();
114
- const declaredVarCount = /* @__PURE__ */ new Map();
115
- process.nodesInvocation.forEach((props) => {
116
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
117
- const { componentType, category, runType } = props;
118
- const nextValue = getNextValue(props, config, event, outputToInputPinMap);
119
- const isSameScope = checkIsSameScope(event, props);
120
- const { code: nextCode, varName: declaredVarName } = getNextCode(props, config, isSameScope, event, declaredVarCount);
121
- (_a = props.nextParam) == null ? void 0 : _a.forEach((np) => {
122
- outputToInputPinMap.set(`${props.meta.id}_${np.id}`, declaredVarName);
123
- });
124
- if (code) {
125
- code += "\n";
126
- }
127
- const callTemplate = (_d = config.getCallTemplate) == null ? void 0 : _d.call(config, {
128
- com: {
129
- ...props.meta,
130
- // 鸿蒙化:透传可能的场景 ID,增强识别能力
131
- sceneId: ((_c = (_b = props.meta.model) == null ? void 0 : _b.data) == null ? void 0 : _c._sceneId) || props.meta.id
132
- },
133
- pinId: props.id,
134
- args: nextValue
135
- });
136
- if (callTemplate) {
137
- if (callTemplate.import) {
138
- config.addParentDependencyImport(callTemplate.import);
139
- }
140
- code += `${indent}/** ${props.meta.title} */
141
- ${indent}${nextCode}${callTemplate.code}`;
142
- return;
143
- }
144
- if (componentType === "js") {
145
- if (category === "scene") {
146
- const _sceneId = props.meta.model.data._sceneId;
147
- const operateName = props.meta.model.data.openType === "redirect" ? "replace" : "open";
148
- code += `${indent}/** 打开 ${props.meta.title} */
149
- ${indent}${nextCode}this.${_sceneId}.${operateName}(${nextValue})`;
150
- } else if (category === "frameOutput") {
151
- const currentScene = config.getCurrentScene();
152
- const pinProxy = (_e = currentScene == null ? void 0 : currentScene.pinProxies) == null ? void 0 : _e[`${props.meta.id}-${props.id}`];
153
- const method = (pinProxy == null ? void 0 : pinProxy.pinId) || props.id;
154
- const sceneId = (pinProxy == null ? void 0 : pinProxy.frameId) || (currentScene == null ? void 0 : currentScene.id);
155
- code += `${indent}/** ${props.meta.title} 输出 ${method} */
156
- ${indent}${nextCode}this.${sceneId}.${method}(${nextValue})`;
157
- } else if (category === "normal") {
158
- let componentNameWithId = getComponentNameWithId(props, config, event);
159
- code += `${indent}/** 调用 ${props.meta.title} */
160
- ${indent}${nextCode}${componentNameWithId}(${runType === "input" ? nextValue : ""})`;
161
- } else if (category === "var") {
162
- const varKey = (0, import_string.getSafeVarName)(props.meta);
163
- const xpath = (_f = props.extData) == null ? void 0 : _f.xpath;
164
- const xpathArg = xpath ? `, "${xpath.replace(/^\//, "").replace(/\//g, ".")}"` : "";
165
- if (props.meta.global) {
166
- config.addParentDependencyImport({
167
- packageName: "../../common/global",
168
- dependencyNames: ["globalVars"],
169
- importType: "named"
170
- });
171
- code += `${indent}/** ${props.title} 全局变量 ${props.meta.title} */
172
- ${indent}${nextCode}globalVars.${varKey}.${props.id}(${nextValue}${xpathArg})`;
173
- } else {
174
- const currentProvider = getCurrentProvider(
175
- { isSameScope, props },
176
- config
177
- );
178
- code += `${indent}/** ${props.title} 变量 ${props.meta.title} */
179
- ${indent}${nextCode}$vars.current.${varKey}.${props.id}(${nextValue}${xpathArg})`;
180
- }
181
- } else if (category === "fx") {
182
- if (props.meta.global) {
183
- config.addParentDependencyImport({
184
- packageName: "../../common/global",
185
- dependencyNames: ["globalFxs"],
186
- importType: "named"
187
- });
188
- code += `${indent}/** 调用全局Fx ${props.meta.title} */
189
- ${indent}${nextCode}globalFxs.${props.meta.ioProxy.id}(${nextValue}${nextValue ? ", " : ""}appContext)`;
190
- } else {
191
- const currentProvider = getCurrentProvider(
192
- { isSameScope, props },
193
- config
194
- );
195
- code += `${indent}/** 调用Fx ${props.meta.title} */
196
- ${indent}${nextCode}$fxs.current.${props.meta.ioProxy.id}(${nextValue})`;
197
- }
198
- }
199
- } else {
200
- if (props.type === "frameOutput") {
201
- const currentScene = config.getCurrentScene();
202
- const parentComId = event.comId || ((_g = event.meta) == null ? void 0 : _g.parentComId);
203
- const frameConEntry = Object.values(currentScene.cons || {}).flat().find((con) => {
204
- if (con.type !== "frame" || con.pinId !== props.id)
205
- return false;
206
- if (parentComId && con.comId)
207
- return con.comId === parentComId;
208
- return true;
209
- });
210
- const comId = (frameConEntry == null ? void 0 : frameConEntry.comId) || props.meta.id;
211
- const comTitle = ((_i = (_h = currentScene.coms) == null ? void 0 : _h[comId]) == null ? void 0 : _i.title) || props.meta.title || comId;
212
- code += `${indent}/** 调用 ${comTitle} 的 ${props.title} */
213
- ${indent}${nextCode}$outputs['${comId}'].${props.id}(${nextValue})`;
214
- } else {
215
- code += `${indent}/** 调用 ${props.meta.title} 的 ${props.title} */
216
- ${indent}${nextCode}this.${props.meta.id}.${props.id}(${nextValue})`;
217
- }
218
- }
219
- });
220
- if (["fx", "extension-api", "extension-bus"].includes(event.type)) {
221
- const returnCode = Object.entries(event.frameOutputs).reduce(
222
- (pre, [, { id, outputs }]) => {
223
- if (!outputs) {
224
- return pre + `${indent2}${id}: undefined,
225
- `;
226
- } else {
227
- const next = outputs.map((output) => {
228
- return getNextValueWithParam(output, config, event, outputToInputPinMap);
229
- }).join(", ");
230
- return pre + `${indent2}${id}: ${next},
231
- `;
232
- }
233
- },
234
- ""
235
- );
236
- if (returnCode) {
237
- code += `
238
- ${indent}return {
239
- ${returnCode}${indent}}`;
240
- }
241
- }
242
- return code;
243
- };
244
- var checkIsSameScope = (event, props) => {
245
- if (event.type === "com" && event.meta.parentComId === props.meta.parentComId && event.meta.frameId === props.meta.frameId) {
246
- return true;
247
- } else if (event.type === "slot" && event.comId === props.meta.parentComId && event.slotId === props.meta.frameId) {
248
- return true;
249
- } else if (event.type === "fx" && event.parentComId === props.meta.parentComId && event.parentSlotId === props.meta.frameId) {
250
- return true;
251
- }
252
- return false;
253
- };
254
- var getComponentNameWithId = (props, config, event) => {
255
- if (isJsCalculationComponent(props.meta.def.namespace)) {
256
- if (config.getEventNodeName) {
257
- const componentName = config.getEventNodeName({
258
- com: props.meta,
259
- scene: config.getCurrentScene(),
260
- event,
261
- type: "declaration"
262
- });
263
- if (componentName) {
264
- return componentName;
265
- }
266
- }
267
- return `jsModules_${props.meta.id}`;
268
- }
269
- if (config.getEventNodeName) {
270
- const componentName = config.getEventNodeName({
271
- com: props.meta,
272
- scene: config.getCurrentScene(),
273
- event,
274
- type: "declaration"
275
- });
276
- if (componentName) {
277
- return componentName;
278
- }
279
- }
280
- const { name } = config.getComponentMeta(props.meta);
281
- const sanitizedName = name.replace(/-/g, "_");
282
- return `${sanitizedName}_${props.meta.id}`;
283
- };
284
- var getNextCode = (props, config, isSameScope, event, declaredVarCount) => {
285
- const { nextParam } = props;
286
- if (!nextParam.length) {
287
- return { code: "", varName: "" };
288
- }
289
- const componentNameWithId = getComponentNameWithId(props, config, event);
290
- const pinId = props.id;
291
- const sanitizedPinId = pinId.replace(/[^a-zA-Z0-9_]/g, "_");
292
- let varName = `${componentNameWithId}_${sanitizedPinId}_result`;
293
- const count = declaredVarCount.get(varName) || 0;
294
- declaredVarCount.set(varName, count + 1);
295
- if (count > 0) {
296
- varName = `${varName}_${count}`;
297
- }
298
- return { code: `const ${varName}: any = `, varName };
299
- };
300
- function getFrameInputValueExpr(meta, config, event) {
301
- var _a, _b, _c, _d;
302
- const scene = (_a = config.getCurrentScene) == null ? void 0 : _a.call(config);
303
- const inputPinId = ((_b = meta == null ? void 0 : meta.inputs) == null ? void 0 : _b[0]) || "getCurValue";
304
- const proxyKey = `${meta == null ? void 0 : meta.id}-${inputPinId}`;
305
- const pinProxy = (_c = scene == null ? void 0 : scene.pinValueProxies) == null ? void 0 : _c[proxyKey];
306
- const pinId = pinProxy == null ? void 0 : pinProxy.pinId;
307
- if (typeof pinId === "string" && pinId) {
308
- const paramsMap = (_d = config.getParams) == null ? void 0 : _d.call(config);
309
- if (paramsMap == null ? void 0 : paramsMap[pinId]) {
310
- return paramsMap[pinId];
311
- }
312
- return `params?.inputValues?.[${JSON.stringify(pinId)}]`;
313
- }
314
- }
315
- var getNextValue = (props, config, event, outputToInputPinMap) => {
316
- const { paramSource } = props;
317
- const nextValue = paramSource.map((param) => {
318
- var _a, _b, _c, _d, _e, _f, _g;
319
- if (param.type === "params") {
320
- const params = config.getParams();
321
- return params[param.id];
322
- } else if (param.type === "constant") {
323
- return JSON.stringify(param.value);
324
- }
325
- if (((_b = (_a = param.meta) == null ? void 0 : _a.def) == null ? void 0 : _b.namespace) === "mybricks.core-comlib.frame-input" && param.id === "return") {
326
- return getFrameInputValueExpr(param.meta, config, event);
327
- }
328
- const componentNameWithId = getComponentNameWithId(param, config, event);
329
- if ((_e = (_d = (_c = param.meta) == null ? void 0 : _c.def) == null ? void 0 : _d.namespace) == null ? void 0 : _e.includes(".var")) {
330
- const key2 = `${(_f = param.meta) == null ? void 0 : _f.id}_${param.id}`;
331
- const fullVarName2 = outputToInputPinMap == null ? void 0 : outputToInputPinMap.get(key2);
332
- if (fullVarName2) {
333
- return fullVarName2;
334
- }
335
- return `${componentNameWithId}_result`;
336
- }
337
- const key = `${(_g = param.meta) == null ? void 0 : _g.id}_${param.id}`;
338
- const fullVarName = outputToInputPinMap == null ? void 0 : outputToInputPinMap.get(key);
339
- if (fullVarName) {
340
- return `${fullVarName}.${param.id}`;
341
- }
342
- return `${componentNameWithId}_result.${param.id}`;
343
- });
344
- return nextValue.join(", ");
345
- };
346
- var getNextValueWithParam = (param, config, event, outputToInputPinMap) => {
347
- var _a, _b, _c, _d, _e, _f, _g;
348
- if (param.type === "params") {
349
- const params = config.getParams();
350
- return params[param.id];
351
- }
352
- if (((_b = (_a = param.meta) == null ? void 0 : _a.def) == null ? void 0 : _b.namespace) === "mybricks.core-comlib.frame-input" && param.id === "return") {
353
- return getFrameInputValueExpr(param.meta, config, event);
354
- }
355
- const componentNameWithId = getComponentNameWithId(param, config, event);
356
- if ((_e = (_d = (_c = param.meta) == null ? void 0 : _c.def) == null ? void 0 : _d.namespace) == null ? void 0 : _e.includes(".var")) {
357
- const key2 = `${(_f = param.meta) == null ? void 0 : _f.id}_${param.id}`;
358
- const fullVarName2 = outputToInputPinMap == null ? void 0 : outputToInputPinMap.get(key2);
359
- if (fullVarName2) {
360
- return fullVarName2;
361
- }
362
- return `${componentNameWithId}_result`;
363
- }
364
- const key = `${(_g = param.meta) == null ? void 0 : _g.id}_${param.id}`;
365
- const fullVarName = outputToInputPinMap == null ? void 0 : outputToInputPinMap.get(key);
366
- if (fullVarName) {
367
- return `${fullVarName}.${param.id}`;
368
- }
369
- return `${componentNameWithId}_result.${param.id}`;
370
- };
371
- var getCurrentProvider = (params, config) => {
372
- var _a, _b, _c;
373
- const providerMap = config.getProviderMap();
374
- const { isSameScope, props } = params;
375
- const { meta } = props;
376
- const { parentComId, frameId } = meta;
377
- const providerName = ((_a = config.getProviderName) == null ? void 0 : _a.call(config, { com: meta, scene: config.getCurrentScene() })) || (!parentComId ? "slot_Index" : `slot_${frameId[0].toUpperCase() + frameId.slice(1)}_${parentComId}`);
378
- const provider = providerMap == null ? void 0 : providerMap[providerName];
379
- const safeProvider = provider || ((_b = config.getCurrentProvider) == null ? void 0 : _b.call(config));
380
- if (!isSameScope && safeProvider) {
381
- (_c = config.addConsumer) == null ? void 0 : _c.call(config, safeProvider);
382
- }
383
- return safeProvider;
384
- };
385
- var generateJsCalculationComponentCode = (params) => {
386
- var _a;
387
- const { meta, props, componentName, config, event, indent, indent2 } = params;
388
- const componentNameWithId = ((_a = config.getEventNodeName) == null ? void 0 : _a.call(config, {
389
- com: meta,
390
- scene: config.getCurrentScene(),
391
- type: "declaration",
392
- event
393
- })) || `jsModules_${meta.id}`;
394
- const jsData = {};
395
- if (props.data && "runImmediate" in props.data) {
396
- jsData.runImmediate = props.data.runImmediate;
397
- }
398
- return `${indent}/** ${meta.title} */
399
- ${indent}const ${componentNameWithId} = jsModules.${meta.id}({` + (config.verbose ? `
400
- ${indent2}title: "${meta.title}",` : "") + (Object.keys(jsData).length > 0 ? `
401
- ${indent2}data: ${(0, import_object.genObjectCode)(jsData, {
402
- initialIndent: config.codeStyle.indent * (config.depth + 1),
403
- indentSize: config.codeStyle.indent
404
- })},` : "") + (props.inputs ? `
405
- ${indent2}inputs: [${props.inputs.map((input) => `"${input}"`).join(", ")}],` : "") + (props.outputs ? `
406
- ${indent2}outputs: [${props.outputs.map((output) => `"${output}"`).join(", ")}],` : "") + `
407
- ${indent}}, appContext, '${meta.id}')
408
- `;
409
- };
410
- var generateJsApiComponentCode = (params) => {
411
- var _a;
412
- const {
413
- meta,
414
- props,
415
- componentName,
416
- callName,
417
- importInfo,
418
- config,
419
- event,
420
- indent,
421
- indent2
422
- } = params;
423
- config.addParentDependencyImport({
424
- packageName: "@mybricks/taro-core",
425
- dependencyNames: ["createJSHandle"],
426
- importType: "named"
427
- });
428
- config.addParentDependencyImport({
429
- packageName: importInfo.from,
430
- dependencyNames: [importInfo.name],
431
- importType: importInfo.type
432
- });
433
- const componentNameWithId = ((_a = config.getEventNodeName) == null ? void 0 : _a.call(config, {
434
- com: meta,
435
- scene: config.getCurrentScene(),
436
- type: "declaration",
437
- event
438
- })) || `${componentName}_${meta.id}`;
439
- config.addParentDependencyImport({
440
- packageName: config.getComponentPackageName(),
441
- dependencyNames: ["useAppContext"],
442
- importType: "named"
443
- });
444
- return `${indent}/** ${meta.title} */
445
- ${indent}const ${componentNameWithId} = createJSHandle(${callName || componentName}, {
446
- ${indent2}props: {` + (config.verbose ? `
447
- ${indent2} title: "${meta.title}",` : "") + (props.data ? `
448
- ${indent2} data: ${(0, import_object.genObjectCode)(props.data, {
449
- initialIndent: config.codeStyle.indent * (config.depth + 2),
450
- indentSize: config.codeStyle.indent
451
- })},` : "") + (props.inputs ? `
452
- ${indent2} inputs: [${props.inputs.map((input) => `"${input}"`).join(", ")}],` : "") + (props.outputs ? `
453
- ${indent2} outputs: [${props.outputs.map((output) => `"${output}"`).join(", ")}],` : "") + `
454
- ${indent2}},
455
- ${indent2}appContext
456
- ${indent}}, '${meta.id}')
457
- `;
458
- };
459
- // Annotate the CommonJS export names for ESM import in node:
460
- 0 && (module.exports = {
461
- handleProcess
462
- });
@@ -1,26 +0,0 @@
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
- childrenResults?: any[];
10
- /** 仅当前层级的直接子组件结果 */
11
- directChildren?: any[];
12
- };
13
- /**
14
- * 统一处理子节点(com, dom, module)
15
- */
16
- export declare const processChildren: (children: UI["children"] | any[], config: any) => ChildResult;
17
- /**
18
- * 归一化子节点提取逻辑
19
- * 兼容不同版本的 DSL 结构:
20
- * 1. 数组直接返回
21
- * 2. 包含 elements 的 DOM 包装层
22
- * 3. 包含 layoutTemplate 的插槽
23
- * 4. 包含 comAry 的传统插槽
24
- * 5. 包含 children 的 Slot/Dom/Com 对象
25
- */
26
- export declare function normalizeChildren(input: any): any[];
@@ -1,121 +0,0 @@
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
- normalizeChildren: () => normalizeChildren,
33
- processChildren: () => processChildren
34
- });
35
- module.exports = __toCommonJS(processChildren_exports);
36
- var import_handleCom = __toESM(require("../../handleCom"));
37
- var import_handleDom = __toESM(require("../../handleDom"));
38
- var import_handleModule = __toESM(require("../../handleModule"));
39
- var processChildren = (children, config) => {
40
- let uiCode = "";
41
- let jsCode = "";
42
- let cssContent = "";
43
- const slots = [];
44
- const scopeSlots = [];
45
- const allChildrenResults = [];
46
- const directChildren = [];
47
- const normalizedChildren = normalizeChildren(children);
48
- normalizedChildren.forEach((child) => {
49
- var _a, _b, _c, _d;
50
- let result;
51
- if (child.type === "com" || child.def) {
52
- result = (0, import_handleCom.default)(child, config);
53
- } else if (child.type === "module") {
54
- result = (0, import_handleModule.default)(child, config);
55
- } else {
56
- result = (0, import_handleDom.default)(child, config);
57
- }
58
- if (result) {
59
- if (child.type === "com" || child.def) {
60
- const comId = child.id || ((_a = child.meta) == null ? void 0 : _a.id);
61
- const childInfo = {
62
- ...result,
63
- id: comId,
64
- // 优先使用 handleCom 解析出的稳定名称 (如 comName 别名)
65
- name: result.name || child.name || ((_c = (_b = child.props) == null ? void 0 : _b.data) == null ? void 0 : _c.name) || ((_d = child.meta) == null ? void 0 : _d.title) || comId,
66
- type: child.type || "com",
67
- meta: child.meta,
68
- props: child.props
69
- };
70
- directChildren.push(childInfo);
71
- allChildrenResults.push(childInfo);
72
- if (result.childrenResults) {
73
- allChildrenResults.push(...result.childrenResults);
74
- }
75
- } else {
76
- if (result.childrenResults) {
77
- allChildrenResults.push(...result.childrenResults);
78
- }
79
- }
80
- if (result.ui) {
81
- uiCode += (uiCode ? "\n" : "") + result.ui;
82
- }
83
- if (result.js) {
84
- jsCode += result.js;
85
- }
86
- if (result.cssContent) {
87
- cssContent += (cssContent ? "\n" : "") + result.cssContent;
88
- }
89
- if (result.slots) {
90
- slots.push(...result.slots);
91
- }
92
- if (result.scopeSlots) {
93
- scopeSlots.push(...result.scopeSlots);
94
- }
95
- }
96
- });
97
- return {
98
- ui: uiCode,
99
- js: jsCode,
100
- cssContent,
101
- slots,
102
- scopeSlots,
103
- directChildren,
104
- childrenResults: allChildrenResults
105
- };
106
- };
107
- function normalizeChildren(input) {
108
- if (!input)
109
- return [];
110
- if (Array.isArray(input))
111
- return input;
112
- const list = input.elements || input.layoutTemplate || input.comAry || input.children;
113
- if (Array.isArray(list))
114
- return list;
115
- return [];
116
- }
117
- // Annotate the CommonJS export names for ESM import in node:
118
- 0 && (module.exports = {
119
- normalizeChildren,
120
- processChildren
121
- });
@@ -1,4 +0,0 @@
1
- /**
2
- * 将 rgba 或 rgb 颜色转换为 hex 颜色
3
- */
4
- export declare function colorToHex(color: string): string;
@@ -1,45 +0,0 @@
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
- });
@@ -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;