@mybricks/to-code-taro 1.2.7 → 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,52 +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/common/helper.ts
20
- var helper_exports = {};
21
- __export(helper_exports, {
22
- getInitValueBySchema: () => getInitValueBySchema,
23
- indentation: () => indentation
24
- });
25
- module.exports = __toCommonJS(helper_exports);
26
- var indentation = (level) => {
27
- return " ".repeat(level);
28
- };
29
- var getInitValueBySchema = (schema, initValue) => {
30
- if (initValue !== void 0)
31
- return initValue;
32
- const type = schema == null ? void 0 : schema.type;
33
- switch (type) {
34
- case "string":
35
- return "";
36
- case "number":
37
- return 0;
38
- case "boolean":
39
- return false;
40
- case "array":
41
- return [];
42
- case "object":
43
- return {};
44
- default:
45
- return {};
46
- }
47
- };
48
- // Annotate the CommonJS export names for ESM import in node:
49
- 0 && (module.exports = {
50
- getInitValueBySchema,
51
- indentation
52
- });
@@ -1,5 +0,0 @@
1
- /** 生成对象代码 */
2
- export declare const genObjectCode: (object: any, config: {
3
- initialIndent: number;
4
- indentSize: number;
5
- }) => string;
@@ -1,58 +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/common/object.ts
20
- var object_exports = {};
21
- __export(object_exports, {
22
- genObjectCode: () => genObjectCode
23
- });
24
- module.exports = __toCommonJS(object_exports);
25
- var import_helper = require("./helper");
26
- var genObjectCode = (object, config) => {
27
- const { initialIndent, indentSize } = config;
28
- const keys = Object.keys(object);
29
- if (keys.length === 0)
30
- return "{}";
31
- let result = "{\n";
32
- keys.forEach((key, idx) => {
33
- const value = object[key];
34
- let formattedValue;
35
- if (Array.isArray(value)) {
36
- formattedValue = JSON.stringify(value);
37
- } else if (value && typeof value === "object") {
38
- formattedValue = genObjectCode(value, {
39
- initialIndent: initialIndent + indentSize,
40
- indentSize
41
- });
42
- } else if (typeof value === "string") {
43
- formattedValue = JSON.stringify(value);
44
- } else {
45
- formattedValue = String(value);
46
- }
47
- result += (0, import_helper.indentation)(initialIndent + indentSize) + `${JSON.stringify(key)}: ${formattedValue}`;
48
- if (idx < keys.length - 1)
49
- result += ",";
50
- result += "\n";
51
- });
52
- result += (0, import_helper.indentation)(initialIndent) + "}";
53
- return result;
54
- };
55
- // Annotate the CommonJS export names for ESM import in node:
56
- 0 && (module.exports = {
57
- genObjectCode
58
- });
@@ -1,18 +0,0 @@
1
- /** 将第一个字符转大写 */
2
- export declare const firstCharToUpperCase: (str: string) => string;
3
- /** 将第一个字符转小写 */
4
- export declare const firstCharToLowerCase: (str: string) => string;
5
- /** 驼峰转中划线 */
6
- export declare const camelToKebab: (str: string) => string;
7
- /** 中划线转驼峰 */
8
- export declare const kebabToCamel: (str: string) => string;
9
- /** 检查字符串是否包含中文 */
10
- export declare const hasChinese: (str: string) => boolean;
11
- /**
12
- * 获取安全的变量名
13
- * 优先使用 title,如果 title 包含中文则使用 id
14
- */
15
- export declare const getSafeVarName: (com: {
16
- title?: string;
17
- id: string;
18
- }) => string;
@@ -1,59 +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/common/string.ts
20
- var string_exports = {};
21
- __export(string_exports, {
22
- camelToKebab: () => camelToKebab,
23
- firstCharToLowerCase: () => firstCharToLowerCase,
24
- firstCharToUpperCase: () => firstCharToUpperCase,
25
- getSafeVarName: () => getSafeVarName,
26
- hasChinese: () => hasChinese,
27
- kebabToCamel: () => kebabToCamel
28
- });
29
- module.exports = __toCommonJS(string_exports);
30
- var firstCharToUpperCase = (str) => {
31
- return str.charAt(0).toUpperCase() + str.slice(1);
32
- };
33
- var firstCharToLowerCase = (str) => {
34
- return str.charAt(0).toLowerCase() + str.slice(1);
35
- };
36
- var camelToKebab = (str) => {
37
- return str.replace(/([A-Z])/g, "-$1").toLowerCase();
38
- };
39
- var kebabToCamel = (str) => {
40
- return str.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
41
- };
42
- var hasChinese = (str) => {
43
- return /[\u4e00-\u9fa5]/.test(str);
44
- };
45
- var getSafeVarName = (com) => {
46
- if (com.title && !hasChinese(com.title)) {
47
- return com.title;
48
- }
49
- return com.id;
50
- };
51
- // Annotate the CommonJS export names for ESM import in node:
52
- 0 && (module.exports = {
53
- camelToKebab,
54
- firstCharToLowerCase,
55
- firstCharToUpperCase,
56
- getSafeVarName,
57
- hasChinese,
58
- kebabToCamel
59
- });
@@ -1,17 +0,0 @@
1
- import type { TabBarItemSource, TaroTabBarConfig } from './types';
2
- /**
3
- * 将 TabBar 数据转换为 Taro 配置格式
4
- * @param tabBar TabBar 项数组(来自 toJson.tabbar)
5
- * @param pageIdToPath 页面 ID 到路径的映射函数,默认格式为 `pages/${pageId}/index`
6
- * @param processIcon 处理图标的函数(可选,用于处理 base64 图片)
7
- * @returns Taro TabBar 配置,如果验证失败则返回 null
8
- */
9
- export declare function convertToTaroTabBarConfig(tabBar: TabBarItemSource[] | undefined | null, pageIdToPath?: (pageId: string) => string, processIcon?: (iconPath: string | undefined, index: number, type: 'normal' | 'selected') => string | undefined): TaroTabBarConfig | null;
10
- /**
11
- * 获取入口页面 ID
12
- * 如果启用 TabBar,返回第一个 TabBar 项的页面 ID;否则返回 null
13
- * @param tabBar TabBar 项数组
14
- * @param defaultEntryPageId 默认入口页面 ID(当 TabBar 未启用时使用)
15
- * @returns 入口页面 ID
16
- */
17
- export declare function getEntryPageId(tabBar: TabBarItemSource[] | undefined | null, defaultEntryPageId?: string): string | null;
@@ -1,84 +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/config/content/converter.ts
20
- var converter_exports = {};
21
- __export(converter_exports, {
22
- convertToTaroTabBarConfig: () => convertToTaroTabBarConfig,
23
- getEntryPageId: () => getEntryPageId
24
- });
25
- module.exports = __toCommonJS(converter_exports);
26
- var import_validator = require("./validator");
27
- function convertTabBarItem(item, pageIdToPath, index = 0, processIcon) {
28
- const pagePath = pageIdToPath(item.scene.id);
29
- const text = item.text || item.scene.title || "";
30
- const taroItem = {
31
- pagePath,
32
- text
33
- };
34
- if (item.normalIconPath) {
35
- taroItem.iconPath = processIcon ? processIcon(item.normalIconPath, index, "normal") : item.normalIconPath.replace(/^\/?@\//, "");
36
- }
37
- if (item.selectedIconPath) {
38
- taroItem.selectedIconPath = processIcon ? processIcon(item.selectedIconPath, index, "selected") : item.selectedIconPath.replace(/^\/?@\//, "");
39
- }
40
- return taroItem;
41
- }
42
- function extractColorFromTextStyle(textStyle) {
43
- if (!textStyle || typeof textStyle !== "object") {
44
- return void 0;
45
- }
46
- return textStyle.color || textStyle.colorValue;
47
- }
48
- function convertToTaroTabBarConfig(tabBar, pageIdToPath = (pageId) => `pages/${pageId}/index`, processIcon) {
49
- const validation = (0, import_validator.validateTabBar)(tabBar);
50
- if (!validation.useTabBar) {
51
- return null;
52
- }
53
- const list = validation.validItems.map(
54
- (item, index) => convertTabBarItem(item, pageIdToPath, index, processIcon)
55
- );
56
- const config = {
57
- custom: true,
58
- list
59
- };
60
- const firstItem = validation.validItems[0];
61
- if (firstItem) {
62
- const normalColor = extractColorFromTextStyle(firstItem.normalTextStyle);
63
- const selectedColor = extractColorFromTextStyle(firstItem.selectedTextStyle);
64
- if (normalColor) {
65
- config.color = normalColor;
66
- }
67
- if (selectedColor) {
68
- config.selectedColor = selectedColor;
69
- }
70
- }
71
- return config;
72
- }
73
- function getEntryPageId(tabBar, defaultEntryPageId) {
74
- const validation = (0, import_validator.validateTabBar)(tabBar);
75
- if (validation.useTabBar && validation.validItems.length > 0) {
76
- return validation.validItems[0].scene.id;
77
- }
78
- return defaultEntryPageId || null;
79
- }
80
- // Annotate the CommonJS export names for ESM import in node:
81
- 0 && (module.exports = {
82
- convertToTaroTabBarConfig,
83
- getEntryPageId
84
- });
@@ -1,10 +0,0 @@
1
- /**
2
- * 页面配置工具模块
3
- * 提供页面配置、TabBar 配置等相关功能
4
- */
5
- export * from './types';
6
- export * from './validator';
7
- export * from './converter';
8
- export * from './pageConfig';
9
- export * from './tabBarConfig';
10
- export * from './saveBase64Image';
@@ -1,33 +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 __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
-
16
- // src/utils/config/content/index.ts
17
- var content_exports = {};
18
- module.exports = __toCommonJS(content_exports);
19
- __reExport(content_exports, require("./types"), module.exports);
20
- __reExport(content_exports, require("./validator"), module.exports);
21
- __reExport(content_exports, require("./converter"), module.exports);
22
- __reExport(content_exports, require("./pageConfig"), module.exports);
23
- __reExport(content_exports, require("./tabBarConfig"), module.exports);
24
- __reExport(content_exports, require("./saveBase64Image"), module.exports);
25
- // Annotate the CommonJS export names for ESM import in node:
26
- 0 && (module.exports = {
27
- ...require("./types"),
28
- ...require("./validator"),
29
- ...require("./converter"),
30
- ...require("./pageConfig"),
31
- ...require("./tabBarConfig"),
32
- ...require("./saveBase64Image")
33
- });
@@ -1,10 +0,0 @@
1
- /**
2
- * 页面配置工具
3
- * 负责从 systemPage 组件数据生成 definePageConfig 配置字符串
4
- */
5
- /**
6
- * 从 systemPage 组件数据生成 definePageConfig 配置字符串
7
- * @param systemPageData systemPage 组件的 model.data
8
- * @returns definePageConfig 配置字符串
9
- */
10
- export declare function generatePageConfigContent(systemPageData?: any): string;
@@ -1,80 +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/config/content/pageConfig.ts
20
- var pageConfig_exports = {};
21
- __export(pageConfig_exports, {
22
- generatePageConfigContent: () => generatePageConfigContent
23
- });
24
- module.exports = __toCommonJS(pageConfig_exports);
25
- var import__ = require("../../index");
26
- var TARO_NAVIGATION_BAR_PROPERTIES = [
27
- "navigationBarBackgroundColor",
28
- "navigationBarTextStyle",
29
- "navigationBarTitleText",
30
- "navigationStyle"
31
- ];
32
- var TARO_PAGE_CONFIG_TEMPLATE_PROPERTIES = [
33
- "navigationBarBackgroundColor",
34
- "navigationBarTextStyle",
35
- "navigationBarTitleText",
36
- "navigationStyle",
37
- "transparentTitle",
38
- "backgroundColor",
39
- "backgroundTextStyle",
40
- "backgroundColorTop",
41
- "backgroundColorBottom",
42
- "enablePullDownRefresh",
43
- "onReachBottomDistance",
44
- "pageOrientation",
45
- "disableScroll",
46
- "disableSwipeBack",
47
- "enableShareAppMessage",
48
- "enableShareTimeline",
49
- "usingComponents",
50
- "renderer"
51
- ];
52
- function generatePageConfigContent(systemPageData) {
53
- const pageConfig = {
54
- enableShareAppMessage: true,
55
- enableShareTimeline: true
56
- };
57
- if (systemPageData) {
58
- if (systemPageData.useNavigationStyle === "none") {
59
- pageConfig.navigationStyle = "custom";
60
- }
61
- const propertiesToUse = systemPageData.useNavigationStyle === "default" ? TARO_NAVIGATION_BAR_PROPERTIES : TARO_PAGE_CONFIG_TEMPLATE_PROPERTIES;
62
- propertiesToUse.forEach((prop) => {
63
- let value = systemPageData[prop];
64
- if (value !== void 0 && value !== null) {
65
- if (prop.includes("BackgroundColor") || prop === "backgroundColor" || prop === "backgroundColorTop" || prop === "backgroundColorBottom") {
66
- value = (0, import__.colorToHex)(value);
67
- }
68
- pageConfig[prop] = value;
69
- }
70
- });
71
- }
72
- const configContent = JSON.stringify(pageConfig, null, 2).replace(/^\{/, "").replace(/\}$/, "").trim();
73
- return `export default definePageConfig({
74
- ${configContent}
75
- })`;
76
- }
77
- // Annotate the CommonJS export names for ESM import in node:
78
- 0 && (module.exports = {
79
- generatePageConfigContent
80
- });
@@ -1,24 +0,0 @@
1
- /**
2
- * Base64 图片处理工具
3
- * 负责将 base64 图片保存为本地文件
4
- */
5
- import type { ImageFileInfo } from './types';
6
- /**
7
- * 处理 TabBar 图标,如果是 base64 则准备保存为文件
8
- * @param iconPath 图标路径(可能是 base64 或普通路径)
9
- * @param tabBarIndex TabBar 项的索引
10
- * @param type 图标类型('normal' 或 'selected')
11
- * @param imageFiles 用于收集需要保存的图片文件的数组(可选)
12
- * @returns 处理后的图标路径(用于 app.config.ts),如果不是 base64 则返回原路径
13
- */
14
- export declare function processTabBarIcon(iconPath: string | undefined, tabBarIndex: number, type: "normal" | "selected", imageFiles?: ImageFileInfo[]): string | undefined;
15
- /**
16
- * 处理页面/组件 data 中的 base64 图片
17
- * - 图片文件保存到 src/assets/<pageId>/ 目录(与 tabbar 同级)
18
- * - data 中替换为 "@/assets/<pageId>/<fileName>"
19
- */
20
- export declare function processPageBase64Image(value: string, pageId: string, imageFiles: ImageFileInfo[], nameHint: string, index: number): string;
21
- /**
22
- * 替换字符串中的 base64 图片(支持 url(data:image/...) 形式)
23
- */
24
- export declare function replaceBase64InText(value: string, pageId: string, imageFiles: ImageFileInfo[], nameHint: string, getIndex: () => number): string;
@@ -1,113 +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/config/content/saveBase64Image.ts
20
- var saveBase64Image_exports = {};
21
- __export(saveBase64Image_exports, {
22
- processPageBase64Image: () => processPageBase64Image,
23
- processTabBarIcon: () => processTabBarIcon,
24
- replaceBase64InText: () => replaceBase64InText
25
- });
26
- module.exports = __toCommonJS(saveBase64Image_exports);
27
- var MIME_TO_EXT = {
28
- png: "png",
29
- jpg: "jpg",
30
- jpeg: "jpg",
31
- gif: "gif",
32
- webp: "webp",
33
- svg: "svg"
34
- };
35
- function parseBase64Image(base64Str) {
36
- if (typeof base64Str !== "string")
37
- return null;
38
- const match = base64Str.match(/^data:image\/([^;]+);base64,(.+)$/);
39
- if (!match)
40
- return null;
41
- return {
42
- mimeType: match[1],
43
- base64Data: match[2]
44
- };
45
- }
46
- var getFileExtension = (mimeType) => MIME_TO_EXT[mimeType.toLowerCase()] ?? "png";
47
- var sanitizeName = (name) => name.replace(/[^a-zA-Z0-9_]/g, "_").slice(0, 64) || "img";
48
- var generateFileName = (index, type, extension) => `tabbar_${index}_${type}.${extension}`;
49
- function processTabBarIcon(iconPath, tabBarIndex, type, imageFiles) {
50
- if (!iconPath)
51
- return void 0;
52
- const parsed = parseBase64Image(iconPath);
53
- if (!parsed)
54
- return iconPath.replace(/^\/?@\//, "");
55
- const extension = getFileExtension(parsed.mimeType);
56
- const fileName = generateFileName(tabBarIndex, type, extension);
57
- const fileSystemPath = `src/assets/tabbar/${fileName}`;
58
- const configPath = `assets/tabbar/${fileName}`;
59
- if (imageFiles) {
60
- try {
61
- imageFiles.push({
62
- filePath: fileSystemPath,
63
- fileContent: Buffer.from(parsed.base64Data, "base64")
64
- });
65
- } catch (error) {
66
- console.error(`处理 TabBar 图标失败: ${error}`);
67
- return iconPath;
68
- }
69
- }
70
- return configPath;
71
- }
72
- function processPageBase64Image(value, pageId, imageFiles, nameHint, index) {
73
- const parsed = parseBase64Image(value);
74
- if (!parsed)
75
- return value;
76
- const extension = getFileExtension(parsed.mimeType);
77
- const safeName = sanitizeName(nameHint);
78
- const finalName = index > 1 ? `${safeName}_${index}` : safeName;
79
- const fileName = `${finalName}.${extension}`;
80
- const fileSystemPath = `src/assets/${pageId}/${fileName}`;
81
- const aliasPath = `@/assets/${pageId}/${fileName}`;
82
- imageFiles.push({
83
- filePath: fileSystemPath,
84
- fileContent: Buffer.from(parsed.base64Data, "base64")
85
- });
86
- return aliasPath;
87
- }
88
- function replaceBase64InText(value, pageId, imageFiles, nameHint, getIndex) {
89
- if (typeof value !== "string")
90
- return value;
91
- let result = value;
92
- while (true) {
93
- const match = result.match(/data:image\/[^;]+;base64,[a-zA-Z0-9+/=]+/);
94
- if (!match)
95
- break;
96
- const currentIndex = getIndex();
97
- const replaced = processPageBase64Image(
98
- match[0],
99
- pageId,
100
- imageFiles,
101
- nameHint,
102
- currentIndex
103
- );
104
- result = result.replace(match[0], replaced);
105
- }
106
- return result;
107
- }
108
- // Annotate the CommonJS export names for ESM import in node:
109
- 0 && (module.exports = {
110
- processPageBase64Image,
111
- processTabBarIcon,
112
- replaceBase64InText
113
- });
@@ -1,28 +0,0 @@
1
- /**
2
- * TabBar 配置工具
3
- * 负责从 tabBar 数据生成 app.config.ts 中的 tabBar 配置字符串
4
- */
5
- import type { TaroTabBarConfig, ImageFileInfo } from './types';
6
- /**
7
- * 从 tabBar 数据生成 TabBar 配置JSON(用于 app.config.ts)
8
- * @param tabBar tabBar 数据数组(来自 scenes[x].coms[id].model.data.tabBar)
9
- * @param pageIdToPath 页面 ID 到路径的映射函数(默认使用 pages/${pageId}/index)
10
- * @param imageFiles 用于收集需要保存的图片文件的数组(可选)
11
- * @returns TabBar 配置JSON,如果验证失败则返回 null
12
- */
13
- export declare function generateTabBarConfigContent(tabBar: any[] | undefined, pageIdToPath?: (pageId: string) => string, imageFiles?: ImageFileInfo[]): TaroTabBarConfig | null;
14
- /**
15
- * 将 TabBar 配置转换为 app.config.ts 中的字符串格式
16
- * @param config TabBar 配置
17
- * @param indent 缩进字符串,默认为 2 个空格
18
- * @returns 配置字符串
19
- */
20
- export declare function formatTabBarConfigForAppConfig(config: TaroTabBarConfig, indent?: string): string;
21
- /**
22
- * 生成转换后的自定义Tabbar项配置文件内容
23
- * 增加页面路径pagePath
24
- * normalIconPath/selectedIconPath替换成本地图片路径
25
- * @param tabBar tabBar 数据数组(来自 scenes[x].coms[id].model.data.tabBar)
26
- * @param config TabBar 配置
27
- */
28
- export declare function generateCustomTabBarFileContent(tabBar: any[] | undefined, config: TaroTabBarConfig): string;