@mybricks/to-code-taro 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/README.md +58 -0
  2. package/dist/cjs/core/comlib/{Index.js → index.js} +4 -4
  3. package/dist/cjs/core/mybricks/index.js +47 -47
  4. package/dist/cjs/core/utils/ComContext.js +3 -0
  5. package/dist/cjs/core/utils/hooks.js +125 -0
  6. package/dist/cjs/core/utils/index.js +21 -57
  7. package/dist/cjs/core/utils/page.js +67 -0
  8. package/dist/cjs/core/utils/useContext.js +2 -1
  9. package/dist/cjs/generate/generateTaroProjectJson.d.ts +3 -14
  10. package/dist/cjs/generate/generateTaroProjectJson.js +9 -6
  11. package/dist/cjs/generate/utils/tabBarImages.d.ts +1 -1
  12. package/dist/cjs/handleCom.d.ts +1 -1
  13. package/dist/cjs/handleCom.js +91 -177
  14. package/dist/cjs/handleDom.js +7 -44
  15. package/dist/cjs/handleExtension.d.ts +2 -2
  16. package/dist/cjs/handleExtension.js +5 -5
  17. package/dist/cjs/handleGlobal.d.ts +2 -12
  18. package/dist/cjs/handleGlobal.js +23 -7
  19. package/dist/cjs/handleModule.js +3 -3
  20. package/dist/cjs/handleSlot.d.ts +2 -9
  21. package/dist/cjs/handleSlot.js +47 -150
  22. package/dist/cjs/index.d.ts +1 -1
  23. package/dist/cjs/index.js +4 -3
  24. package/dist/cjs/processors/processComEvents.d.ts +9 -0
  25. package/dist/cjs/processors/processComEvents.js +122 -0
  26. package/dist/cjs/processors/processModule.d.ts +31 -0
  27. package/dist/cjs/processors/processModule.js +125 -0
  28. package/dist/cjs/processors/processScene.d.ts +32 -0
  29. package/dist/cjs/processors/processScene.js +124 -0
  30. package/dist/cjs/processors/processSceneLogic.d.ts +4 -0
  31. package/dist/cjs/processors/processSceneLogic.js +166 -0
  32. package/dist/cjs/taro-template.json +15 -7
  33. package/dist/cjs/toCodeTaro.d.ts +26 -5
  34. package/dist/cjs/toCodeTaro.js +59 -343
  35. package/dist/cjs/utils/builder/buildResult.d.ts +21 -0
  36. package/dist/cjs/utils/builder/buildResult.js +91 -0
  37. package/dist/cjs/utils/common/ImportManager.d.ts +19 -0
  38. package/dist/cjs/utils/common/ImportManager.js +105 -0
  39. package/dist/cjs/utils/common/helper.d.ts +2 -0
  40. package/dist/cjs/utils/common/helper.js +31 -0
  41. package/dist/cjs/utils/common/object.d.ts +5 -0
  42. package/dist/cjs/utils/common/object.js +58 -0
  43. package/dist/cjs/utils/common/string.d.ts +8 -0
  44. package/dist/cjs/utils/common/string.js +46 -0
  45. package/dist/cjs/utils/{pageConfig → config/content}/converter.js +1 -1
  46. package/dist/cjs/utils/{pageConfig → config/content}/index.js +9 -9
  47. package/dist/cjs/utils/{pageConfig → config/content}/pageConfig.js +12 -22
  48. package/dist/{esm/utils/pageConfig → cjs/utils/config/content}/saveBase64Image.d.ts +1 -1
  49. package/dist/cjs/utils/{pageConfig → config/content}/saveBase64Image.js +8 -17
  50. package/dist/cjs/utils/{pageConfig → config/content}/tabBarConfig.js +9 -32
  51. package/dist/cjs/utils/config/content/types.js +17 -0
  52. package/dist/cjs/utils/{pageConfig → config/content}/validator.js +1 -1
  53. package/dist/{esm/utils → cjs/utils/config}/handlePageConfig.d.ts +1 -1
  54. package/dist/cjs/utils/{handlePageConfig.js → config/handlePageConfig.js} +4 -4
  55. package/dist/cjs/utils/context/buildContext.d.ts +24 -0
  56. package/dist/cjs/utils/context/buildContext.js +65 -0
  57. package/dist/cjs/utils/context/buildFrameMap.d.ts +16 -0
  58. package/dist/cjs/utils/context/buildFrameMap.js +106 -0
  59. package/dist/cjs/utils/context/buildGlobalData.d.ts +13 -0
  60. package/dist/cjs/utils/context/buildGlobalData.js +58 -0
  61. package/dist/cjs/utils/context/collectJSModules.d.ts +37 -0
  62. package/dist/cjs/utils/context/collectJSModules.js +91 -0
  63. package/dist/cjs/utils/context/createEventQueries.d.ts +45 -0
  64. package/dist/cjs/utils/context/createEventQueries.js +99 -0
  65. package/dist/cjs/utils/context/createProvider.d.ts +21 -0
  66. package/dist/cjs/utils/context/createProvider.js +49 -0
  67. package/dist/cjs/utils/index.d.ts +10 -62
  68. package/dist/cjs/utils/index.js +21 -282
  69. package/dist/cjs/utils/{convertNamespace.js → logic/convertNamespace.js} +1 -1
  70. package/dist/cjs/utils/{genJSModules.js → logic/genJSModules.js} +1 -1
  71. package/dist/{esm/utils → cjs/utils/logic}/handleProcess.d.ts +2 -2
  72. package/dist/cjs/utils/{handleProcess.js → logic/handleProcess.js} +14 -11
  73. package/dist/cjs/utils/logic/processChildren.d.ts +12 -0
  74. package/dist/cjs/utils/logic/processChildren.js +82 -0
  75. package/dist/cjs/utils/style/color.d.ts +4 -0
  76. package/dist/cjs/utils/style/color.js +45 -0
  77. package/dist/cjs/utils/style/converter.d.ts +7 -0
  78. package/dist/cjs/utils/style/converter.js +181 -0
  79. package/dist/cjs/utils/{getComponentClassName.js → style/getComponentClassName.js} +1 -1
  80. package/dist/cjs/utils/{pxtransform.js → style/pxtransform.js} +1 -1
  81. package/dist/cjs/utils/style/types.d.ts +23 -0
  82. package/dist/cjs/utils/{pageConfig → style}/types.js +1 -1
  83. package/dist/cjs/utils/{code → templates}/component.js +1 -1
  84. package/dist/cjs/utils/{code → templates}/index.js +4 -4
  85. package/dist/cjs/utils/{code → templates}/renderManager.js +1 -1
  86. package/dist/cjs/utils/{code → templates}/scene.js +1 -1
  87. package/dist/esm/core/mybricks/index.js +1 -1
  88. package/dist/esm/core/utils/ComContext.js +1 -0
  89. package/dist/esm/core/utils/hooks.js +118 -0
  90. package/dist/esm/core/utils/index.js +6 -57
  91. package/dist/esm/core/utils/page.js +50 -0
  92. package/dist/esm/core/utils/useContext.js +2 -1
  93. package/dist/esm/generate/generateTaroProjectJson.d.ts +3 -14
  94. package/dist/esm/generate/generateTaroProjectJson.js +27 -23
  95. package/dist/esm/generate/utils/tabBarImages.d.ts +1 -1
  96. package/dist/esm/handleCom.d.ts +1 -1
  97. package/dist/esm/handleCom.js +159 -244
  98. package/dist/esm/handleDom.js +9 -48
  99. package/dist/esm/handleExtension.d.ts +2 -2
  100. package/dist/esm/handleExtension.js +5 -5
  101. package/dist/esm/handleGlobal.d.ts +2 -12
  102. package/dist/esm/handleGlobal.js +17 -3
  103. package/dist/esm/handleModule.js +3 -3
  104. package/dist/esm/handleSlot.d.ts +2 -9
  105. package/dist/esm/handleSlot.js +97 -174
  106. package/dist/esm/index.d.ts +1 -1
  107. package/dist/esm/index.js +1 -1
  108. package/dist/esm/processors/processComEvents.d.ts +9 -0
  109. package/dist/esm/processors/processComEvents.js +110 -0
  110. package/dist/esm/processors/processModule.d.ts +31 -0
  111. package/dist/esm/processors/processModule.js +126 -0
  112. package/dist/esm/processors/processScene.d.ts +32 -0
  113. package/dist/esm/processors/processScene.js +126 -0
  114. package/dist/esm/processors/processSceneLogic.d.ts +4 -0
  115. package/dist/esm/processors/processSceneLogic.js +160 -0
  116. package/dist/esm/taro-template.json +15 -7
  117. package/dist/esm/toCodeTaro.d.ts +26 -5
  118. package/dist/esm/toCodeTaro.js +96 -396
  119. package/dist/esm/utils/builder/buildResult.d.ts +21 -0
  120. package/dist/esm/utils/builder/buildResult.js +61 -0
  121. package/dist/esm/utils/common/ImportManager.d.ts +19 -0
  122. package/dist/esm/utils/common/ImportManager.js +103 -0
  123. package/dist/esm/utils/common/helper.d.ts +2 -0
  124. package/dist/esm/utils/common/helper.js +4 -0
  125. package/dist/esm/utils/common/object.d.ts +5 -0
  126. package/dist/esm/utils/common/object.js +32 -0
  127. package/dist/esm/utils/common/string.d.ts +8 -0
  128. package/dist/esm/utils/common/string.js +21 -0
  129. package/dist/esm/utils/config/content/pageConfig.js +40 -0
  130. package/dist/{cjs/utils/pageConfig → esm/utils/config/content}/saveBase64Image.d.ts +1 -1
  131. package/dist/esm/utils/{pageConfig → config/content}/saveBase64Image.js +11 -30
  132. package/dist/esm/utils/{pageConfig → config/content}/tabBarConfig.js +12 -34
  133. package/dist/{cjs/utils → esm/utils/config}/handlePageConfig.d.ts +1 -1
  134. package/dist/esm/utils/{handlePageConfig.js → config/handlePageConfig.js} +1 -1
  135. package/dist/esm/utils/context/buildContext.d.ts +24 -0
  136. package/dist/esm/utils/context/buildContext.js +53 -0
  137. package/dist/esm/utils/context/buildFrameMap.d.ts +16 -0
  138. package/dist/esm/utils/context/buildFrameMap.js +131 -0
  139. package/dist/esm/utils/context/buildGlobalData.d.ts +13 -0
  140. package/dist/esm/utils/context/buildGlobalData.js +44 -0
  141. package/dist/esm/utils/context/collectJSModules.d.ts +37 -0
  142. package/dist/esm/utils/context/collectJSModules.js +87 -0
  143. package/dist/esm/utils/context/createEventQueries.d.ts +45 -0
  144. package/dist/esm/utils/context/createEventQueries.js +98 -0
  145. package/dist/esm/utils/context/createProvider.d.ts +21 -0
  146. package/dist/esm/utils/context/createProvider.js +33 -0
  147. package/dist/esm/utils/index.d.ts +10 -62
  148. package/dist/esm/utils/index.js +12 -345
  149. package/dist/{cjs/utils → esm/utils/logic}/handleProcess.d.ts +2 -2
  150. package/dist/esm/utils/{handleProcess.js → logic/handleProcess.js} +11 -5
  151. package/dist/esm/utils/logic/processChildren.d.ts +12 -0
  152. package/dist/esm/utils/logic/processChildren.js +48 -0
  153. package/dist/esm/utils/style/color.d.ts +4 -0
  154. package/dist/esm/utils/style/color.js +17 -0
  155. package/dist/esm/utils/style/converter.d.ts +7 -0
  156. package/dist/esm/utils/style/converter.js +176 -0
  157. package/dist/esm/utils/style/types.d.ts +23 -0
  158. package/dist/esm/utils/style/types.js +1 -0
  159. package/package.json +1 -1
  160. package/dist/esm/utils/pageConfig/pageConfig.js +0 -60
  161. /package/dist/cjs/utils/{pageConfig → config/content}/converter.d.ts +0 -0
  162. /package/dist/cjs/utils/{pageConfig → config/content}/index.d.ts +0 -0
  163. /package/dist/cjs/utils/{pageConfig → config/content}/pageConfig.d.ts +0 -0
  164. /package/dist/cjs/utils/{pageConfig → config/content}/tabBarConfig.d.ts +0 -0
  165. /package/dist/cjs/utils/{pageConfig → config/content}/types.d.ts +0 -0
  166. /package/dist/cjs/utils/{pageConfig → config/content}/validator.d.ts +0 -0
  167. /package/dist/cjs/utils/{convertNamespace.d.ts → logic/convertNamespace.d.ts} +0 -0
  168. /package/dist/cjs/utils/{genJSModules.d.ts → logic/genJSModules.d.ts} +0 -0
  169. /package/dist/cjs/utils/{getComponentClassName.d.ts → style/getComponentClassName.d.ts} +0 -0
  170. /package/dist/cjs/utils/{pxtransform.d.ts → style/pxtransform.d.ts} +0 -0
  171. /package/dist/cjs/utils/{code → templates}/component.d.ts +0 -0
  172. /package/dist/cjs/utils/{code → templates}/index.d.ts +0 -0
  173. /package/dist/cjs/utils/{code → templates}/renderManager.d.ts +0 -0
  174. /package/dist/cjs/utils/{code → templates}/scene.d.ts +0 -0
  175. /package/dist/esm/core/comlib/{Index.js → index.js} +0 -0
  176. /package/dist/esm/utils/{pageConfig → config/content}/converter.d.ts +0 -0
  177. /package/dist/esm/utils/{pageConfig → config/content}/converter.js +0 -0
  178. /package/dist/esm/utils/{pageConfig → config/content}/index.d.ts +0 -0
  179. /package/dist/esm/utils/{pageConfig → config/content}/index.js +0 -0
  180. /package/dist/esm/utils/{pageConfig → config/content}/pageConfig.d.ts +0 -0
  181. /package/dist/esm/utils/{pageConfig → config/content}/tabBarConfig.d.ts +0 -0
  182. /package/dist/esm/utils/{pageConfig → config/content}/types.d.ts +0 -0
  183. /package/dist/esm/utils/{pageConfig → config/content}/types.js +0 -0
  184. /package/dist/esm/utils/{pageConfig → config/content}/validator.d.ts +0 -0
  185. /package/dist/esm/utils/{pageConfig → config/content}/validator.js +0 -0
  186. /package/dist/esm/utils/{convertNamespace.d.ts → logic/convertNamespace.d.ts} +0 -0
  187. /package/dist/esm/utils/{convertNamespace.js → logic/convertNamespace.js} +0 -0
  188. /package/dist/esm/utils/{genJSModules.d.ts → logic/genJSModules.d.ts} +0 -0
  189. /package/dist/esm/utils/{genJSModules.js → logic/genJSModules.js} +0 -0
  190. /package/dist/esm/utils/{getComponentClassName.d.ts → style/getComponentClassName.d.ts} +0 -0
  191. /package/dist/esm/utils/{getComponentClassName.js → style/getComponentClassName.js} +0 -0
  192. /package/dist/esm/utils/{pxtransform.d.ts → style/pxtransform.d.ts} +0 -0
  193. /package/dist/esm/utils/{pxtransform.js → style/pxtransform.js} +0 -0
  194. /package/dist/esm/utils/{code → templates}/component.d.ts +0 -0
  195. /package/dist/esm/utils/{code → templates}/component.js +0 -0
  196. /package/dist/esm/utils/{code → templates}/index.d.ts +0 -0
  197. /package/dist/esm/utils/{code → templates}/index.js +0 -0
  198. /package/dist/esm/utils/{code → templates}/renderManager.d.ts +0 -0
  199. /package/dist/esm/utils/{code → templates}/renderManager.js +0 -0
  200. /package/dist/esm/utils/{code → templates}/scene.d.ts +0 -0
  201. /package/dist/esm/utils/{code → templates}/scene.js +0 -0
@@ -0,0 +1,31 @@
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
+ indentation: () => indentation
23
+ });
24
+ module.exports = __toCommonJS(helper_exports);
25
+ var indentation = (level) => {
26
+ return " ".repeat(level);
27
+ };
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ indentation
31
+ });
@@ -0,0 +1,5 @@
1
+ /** 生成对象代码 */
2
+ export declare const genObjectCode: (object: any, config: {
3
+ initialIndent: number;
4
+ indentSize: number;
5
+ }) => string;
@@ -0,0 +1,58 @@
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
+ });
@@ -0,0 +1,8 @@
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;
@@ -0,0 +1,46 @@
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
+ kebabToCamel: () => kebabToCamel
26
+ });
27
+ module.exports = __toCommonJS(string_exports);
28
+ var firstCharToUpperCase = (str) => {
29
+ return str.charAt(0).toUpperCase() + str.slice(1);
30
+ };
31
+ var firstCharToLowerCase = (str) => {
32
+ return str.charAt(0).toLowerCase() + str.slice(1);
33
+ };
34
+ var camelToKebab = (str) => {
35
+ return str.replace(/([A-Z])/g, "-$1").toLowerCase();
36
+ };
37
+ var kebabToCamel = (str) => {
38
+ return str.replace(/-([a-z])/g, (_, char) => char.toUpperCase());
39
+ };
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ camelToKebab,
43
+ firstCharToLowerCase,
44
+ firstCharToUpperCase,
45
+ kebabToCamel
46
+ });
@@ -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/pageConfig/converter.ts
19
+ // src/utils/config/content/converter.ts
20
20
  var converter_exports = {};
21
21
  __export(converter_exports, {
22
22
  convertToTaroTabBarConfig: () => convertToTaroTabBarConfig,
@@ -13,15 +13,15 @@ var __copyProps = (to, from, except, desc) => {
13
13
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
15
 
16
- // src/utils/pageConfig/index.ts
17
- var pageConfig_exports = {};
18
- module.exports = __toCommonJS(pageConfig_exports);
19
- __reExport(pageConfig_exports, require("./types"), module.exports);
20
- __reExport(pageConfig_exports, require("./validator"), module.exports);
21
- __reExport(pageConfig_exports, require("./converter"), module.exports);
22
- __reExport(pageConfig_exports, require("./pageConfig"), module.exports);
23
- __reExport(pageConfig_exports, require("./tabBarConfig"), module.exports);
24
- __reExport(pageConfig_exports, require("./saveBase64Image"), module.exports);
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
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  ...require("./types"),
@@ -16,12 +16,13 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // src/utils/pageConfig/pageConfig.ts
19
+ // src/utils/config/content/pageConfig.ts
20
20
  var pageConfig_exports = {};
21
21
  __export(pageConfig_exports, {
22
22
  generatePageConfigContent: () => generatePageConfigContent
23
23
  });
24
24
  module.exports = __toCommonJS(pageConfig_exports);
25
+ var import__ = require("../../index");
25
26
  var TARO_NAVIGATION_BAR_PROPERTIES = [
26
27
  "navigationBarBackgroundColor",
27
28
  "navigationBarTextStyle",
@@ -51,34 +52,23 @@ var TARO_PAGE_CONFIG_TEMPLATE_PROPERTIES = [
51
52
  function generatePageConfigContent(systemPageData) {
52
53
  const pageConfig = {};
53
54
  if (systemPageData) {
54
- const useNavigationStyle = systemPageData.useNavigationStyle;
55
- let propertiesToUse = [];
56
- if (useNavigationStyle === "default") {
57
- propertiesToUse = TARO_NAVIGATION_BAR_PROPERTIES;
58
- } else {
59
- propertiesToUse = TARO_PAGE_CONFIG_TEMPLATE_PROPERTIES;
55
+ if (systemPageData.useNavigationStyle === "none") {
56
+ pageConfig.navigationStyle = "custom";
60
57
  }
58
+ const propertiesToUse = systemPageData.useNavigationStyle === "default" ? TARO_NAVIGATION_BAR_PROPERTIES : TARO_PAGE_CONFIG_TEMPLATE_PROPERTIES;
61
59
  propertiesToUse.forEach((prop) => {
62
- if (systemPageData[prop] !== void 0 && systemPageData[prop] !== null) {
63
- const value = systemPageData[prop];
64
- if (typeof value === "string") {
65
- pageConfig[prop] = `'${value}'`;
66
- } else if (typeof value === "boolean" || typeof value === "number") {
67
- pageConfig[prop] = value;
68
- } else if (typeof value === "object") {
69
- pageConfig[prop] = JSON.stringify(value);
60
+ let value = systemPageData[prop];
61
+ if (value !== void 0 && value !== null) {
62
+ if (prop.includes("BackgroundColor") || prop === "backgroundColor" || prop === "backgroundColorTop" || prop === "backgroundColorBottom") {
63
+ value = (0, import__.colorToHex)(value);
70
64
  }
65
+ pageConfig[prop] = value;
71
66
  }
72
67
  });
73
68
  }
74
- if (Object.keys(pageConfig).length === 0) {
75
- pageConfig.navigationBarTitleText = `'页面'`;
76
- }
77
- const configLines = Object.entries(pageConfig).map(([key, value]) => {
78
- return ` ${key}: ${value}`;
79
- });
69
+ const configContent = JSON.stringify(pageConfig, null, 2).replace(/^\{/, "").replace(/\}$/, "").trim();
80
70
  return `export default definePageConfig({
81
- ${configLines.join(",\n")}
71
+ ${configContent}
82
72
  })`;
83
73
  }
84
74
  // Annotate the CommonJS export names for ESM import in node:
@@ -11,4 +11,4 @@ import type { ImageFileInfo } from './types';
11
11
  * @param imageFiles 用于收集需要保存的图片文件的数组(可选)
12
12
  * @returns 处理后的图标路径(用于 app.config.ts),如果不是 base64 则返回原路径
13
13
  */
14
- export declare function processTabBarIcon(iconPath: string | undefined, tabBarIndex: number, type: 'normal' | 'selected', imageFiles?: ImageFileInfo[]): string | undefined;
14
+ export declare function processTabBarIcon(iconPath: string | undefined, tabBarIndex: number, type: "normal" | "selected", imageFiles?: ImageFileInfo[]): string | undefined;
@@ -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/pageConfig/saveBase64Image.ts
19
+ // src/utils/config/content/saveBase64Image.ts
20
20
  var saveBase64Image_exports = {};
21
21
  __export(saveBase64Image_exports, {
22
22
  processTabBarIcon: () => processTabBarIcon
@@ -31,42 +31,33 @@ var MIME_TO_EXT = {
31
31
  svg: "svg"
32
32
  };
33
33
  function parseBase64Image(base64Str) {
34
- if (typeof base64Str !== "string" || !base64Str.startsWith("data:image/")) {
34
+ if (typeof base64Str !== "string")
35
35
  return null;
36
- }
37
36
  const match = base64Str.match(/^data:image\/([^;]+);base64,(.+)$/);
38
- if (!match) {
37
+ if (!match)
39
38
  return null;
40
- }
41
39
  return {
42
40
  mimeType: match[1],
43
41
  base64Data: match[2]
44
42
  };
45
43
  }
46
- function getFileExtension(mimeType) {
47
- return MIME_TO_EXT[mimeType.toLowerCase()] || "png";
48
- }
49
- function generateFileName(index, type, extension) {
50
- return `tabbar_${index}_${type}.${extension}`;
51
- }
44
+ var getFileExtension = (mimeType) => MIME_TO_EXT[mimeType.toLowerCase()] ?? "png";
45
+ var generateFileName = (index, type, extension) => `tabbar_${index}_${type}.${extension}`;
52
46
  function processTabBarIcon(iconPath, tabBarIndex, type, imageFiles) {
53
- if (!iconPath) {
47
+ if (!iconPath)
54
48
  return void 0;
55
- }
56
49
  const parsed = parseBase64Image(iconPath);
57
- if (!parsed) {
50
+ if (!parsed)
58
51
  return iconPath;
59
- }
60
52
  const extension = getFileExtension(parsed.mimeType);
61
53
  const fileName = generateFileName(tabBarIndex, type, extension);
62
54
  const fileSystemPath = `src/assets/tabbar/${fileName}`;
63
55
  const configPath = `assets/tabbar/${fileName}`;
64
56
  if (imageFiles) {
65
57
  try {
66
- const imageBuffer = Buffer.from(parsed.base64Data, "base64");
67
58
  imageFiles.push({
68
59
  filePath: fileSystemPath,
69
- fileContent: imageBuffer
60
+ fileContent: Buffer.from(parsed.base64Data, "base64")
70
61
  });
71
62
  } catch (error) {
72
63
  console.error(`处理 TabBar 图标失败: ${error}`);
@@ -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/pageConfig/tabBarConfig.ts
19
+ // src/utils/config/content/tabBarConfig.ts
20
20
  var tabBarConfig_exports = {};
21
21
  __export(tabBarConfig_exports, {
22
22
  generateTabBarConfigContent: () => generateTabBarConfigContent
@@ -36,37 +36,14 @@ function generateTabBarConfigContent(tabBar, pageIdToPath = (pageId) => `pages/$
36
36
  return formatTabBarConfigForAppConfig(config);
37
37
  }
38
38
  function formatTabBarConfigForAppConfig(config, indent = " ") {
39
- const lines = [];
40
- lines.push(`${indent}tabBar: {`);
41
- if (config.color) {
42
- lines.push(`${indent} color: '${config.color}',`);
43
- }
44
- if (config.selectedColor) {
45
- lines.push(`${indent} selectedColor: '${config.selectedColor}',`);
46
- }
47
- if (config.backgroundColor) {
48
- lines.push(`${indent} backgroundColor: '${config.backgroundColor}',`);
49
- }
50
- if (config.borderStyle) {
51
- lines.push(`${indent} borderStyle: '${config.borderStyle}',`);
52
- }
53
- lines.push(`${indent} list: [`);
54
- config.list.forEach((item, index) => {
55
- const isLast = index === config.list.length - 1;
56
- lines.push(`${indent} {`);
57
- lines.push(`${indent} pagePath: '${item.pagePath}',`);
58
- lines.push(`${indent} text: '${item.text}',`);
59
- if (item.iconPath) {
60
- lines.push(`${indent} iconPath: '${item.iconPath}',`);
61
- }
62
- if (item.selectedIconPath) {
63
- lines.push(`${indent} selectedIconPath: '${item.selectedIconPath}',`);
64
- }
65
- lines.push(`${indent} }${isLast ? "" : ","}`);
66
- });
67
- lines.push(`${indent} ]`);
68
- lines.push(`${indent}}`);
69
- return lines.join("\n");
39
+ const tabBarJson = JSON.stringify(config, null, 2);
40
+ const formattedJson = tabBarJson.replace(/"([^"]+)":/g, "$1:").replace(/"/g, "'");
41
+ const lines = formattedJson.split("\n");
42
+ return lines.map((line, index) => {
43
+ if (index === 0)
44
+ return `${indent}tabBar: ${line}`;
45
+ return `${indent}${line}`;
46
+ }).join("\n");
70
47
  }
71
48
  // Annotate the CommonJS export names for ESM import in node:
72
49
  0 && (module.exports = {
@@ -0,0 +1,17 @@
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+
15
+ // src/utils/config/content/types.ts
16
+ var types_exports = {};
17
+ module.exports = __toCommonJS(types_exports);
@@ -16,7 +16,7 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // src/utils/pageConfig/validator.ts
19
+ // src/utils/config/content/validator.ts
20
20
  var validator_exports = {};
21
21
  __export(validator_exports, {
22
22
  shouldUseTabBar: () => shouldUseTabBar,
@@ -1,5 +1,5 @@
1
1
  import toCode from "@mybricks/to-code-react/dist/cjs/toCode";
2
- import { type ImageFileInfo } from "./pageConfig";
2
+ import { type ImageFileInfo } from "./content";
3
3
  /**
4
4
  * 处理页面配置的类
5
5
  * 负责提取 systemPage 组件数据,生成页面配置和 TabBar 配置
@@ -16,13 +16,13 @@ var __copyProps = (to, from, except, desc) => {
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
18
 
19
- // src/utils/handlePageConfig.ts
19
+ // src/utils/config/handlePageConfig.ts
20
20
  var handlePageConfig_exports = {};
21
21
  __export(handlePageConfig_exports, {
22
22
  HandlePageConfig: () => HandlePageConfig
23
23
  });
24
24
  module.exports = __toCommonJS(handlePageConfig_exports);
25
- var import_pageConfig = require("./pageConfig");
25
+ var import_content = require("./content");
26
26
  var HandlePageConfig = class {
27
27
  constructor() {
28
28
  this.globalTabBarConfig = null;
@@ -42,10 +42,10 @@ var HandlePageConfig = class {
42
42
  });
43
43
  if ((_a = systemPageCom == null ? void 0 : systemPageCom.model) == null ? void 0 : _a.data) {
44
44
  const systemPageData = systemPageCom.model.data;
45
- pageConfigContent = (0, import_pageConfig.generatePageConfigContent)(systemPageData);
45
+ pageConfigContent = (0, import_content.generatePageConfigContent)(systemPageData);
46
46
  if (!this.globalTabBarConfig && systemPageData.tabBar && Array.isArray(systemPageData.tabBar)) {
47
47
  const pageIdToPath = (pageId) => `pages/${pageId}/index`;
48
- this.globalTabBarConfig = (0, import_pageConfig.generateTabBarConfigContent)(
48
+ this.globalTabBarConfig = (0, import_content.generateTabBarConfigContent)(
49
49
  systemPageData.tabBar,
50
50
  pageIdToPath,
51
51
  this.tabBarImageFiles
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 构建上下文数据
3
+ * 包括 sceneMap, eventsMap 等查询映射
4
+ */
5
+ /**
6
+ * 构建场景映射表
7
+ */
8
+ export declare const buildSceneMap: (scenes: any[]) => any;
9
+ /**
10
+ * 构建扩展事件映射表
11
+ */
12
+ export declare const buildEventsMap: (frames: any[]) => any;
13
+ /**
14
+ * 创建场景查询函数
15
+ */
16
+ export declare const createGetSceneById: (sceneMap: Record<string, any>) => (id: string) => any;
17
+ /**
18
+ * 创建扩展事件查询函数
19
+ */
20
+ export declare const createGetExtensionEventById: (eventsMap: Record<string, any>) => (id: string) => any;
21
+ /**
22
+ * 创建 frame 查询函数
23
+ */
24
+ export declare const createGetFrameById: (frameMap: Record<string, any>) => (id: string) => any;
@@ -0,0 +1,65 @@
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/context/buildContext.ts
20
+ var buildContext_exports = {};
21
+ __export(buildContext_exports, {
22
+ buildEventsMap: () => buildEventsMap,
23
+ buildSceneMap: () => buildSceneMap,
24
+ createGetExtensionEventById: () => createGetExtensionEventById,
25
+ createGetFrameById: () => createGetFrameById,
26
+ createGetSceneById: () => createGetSceneById
27
+ });
28
+ module.exports = __toCommonJS(buildContext_exports);
29
+ var buildSceneMap = (scenes) => {
30
+ return scenes.reduce((pre, cur) => {
31
+ pre[cur.id] = cur;
32
+ return pre;
33
+ }, {});
34
+ };
35
+ var buildEventsMap = (frames) => {
36
+ return frames.reduce((pre, cur) => {
37
+ if (cur.type === "extension-event") {
38
+ pre[cur.id] = cur;
39
+ }
40
+ return pre;
41
+ }, {});
42
+ };
43
+ var createGetSceneById = (sceneMap) => {
44
+ return (id) => {
45
+ return sceneMap[id];
46
+ };
47
+ };
48
+ var createGetExtensionEventById = (eventsMap) => {
49
+ return (id) => {
50
+ return eventsMap[id];
51
+ };
52
+ };
53
+ var createGetFrameById = (frameMap) => {
54
+ return (id) => {
55
+ return frameMap[id];
56
+ };
57
+ };
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ buildEventsMap,
61
+ buildSceneMap,
62
+ createGetExtensionEventById,
63
+ createGetFrameById,
64
+ createGetSceneById
65
+ });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 构建 frames 映射表
3
+ * 参考鸿蒙实现 handleFrame.ts
4
+ * 用于快速查找 frame 和对应的组件信息
5
+ */
6
+ export interface FrameMapItem {
7
+ frame: any;
8
+ meta: any;
9
+ }
10
+ export type FrameMap = Record<string, FrameMapItem>;
11
+ /**
12
+ * 构建完整的 frameMap
13
+ * @param tojson - 完整的 tojson 数据
14
+ * @returns frameMap 对象
15
+ */
16
+ export declare const buildFrameMap: (tojson: any) => FrameMap;
@@ -0,0 +1,106 @@
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/context/buildFrameMap.ts
20
+ var buildFrameMap_exports = {};
21
+ __export(buildFrameMap_exports, {
22
+ buildFrameMap: () => buildFrameMap
23
+ });
24
+ module.exports = __toCommonJS(buildFrameMap_exports);
25
+ var buildFrameMapRecursive = (frames, frameMap, tojson, config) => {
26
+ frames.forEach((frame) => {
27
+ var _a;
28
+ frameMap[frame.id] = {
29
+ frame,
30
+ meta: ((_a = config == null ? void 0 : config.getComInfo) == null ? void 0 : _a.call(config, "")) || void 0
31
+ };
32
+ if (frame.frames && frame.frames.length > 0) {
33
+ buildFrameMapRecursive(frame.frames, frameMap, tojson, config);
34
+ }
35
+ if (frame.coms) {
36
+ Object.entries(frame.coms).forEach(([comId, comFrame]) => {
37
+ if (comFrame.frames && comFrame.frames.length > 0) {
38
+ buildFrameMapRecursive(
39
+ comFrame.frames,
40
+ frameMap,
41
+ tojson,
42
+ {
43
+ getComInfo: (id) => {
44
+ var _a2;
45
+ for (const scene of tojson.scenes) {
46
+ const comInfo = (_a2 = scene.coms) == null ? void 0 : _a2[comId || id];
47
+ if (comInfo) {
48
+ return comInfo;
49
+ }
50
+ }
51
+ return void 0;
52
+ }
53
+ }
54
+ );
55
+ }
56
+ });
57
+ }
58
+ });
59
+ };
60
+ var buildFrameMap = (tojson) => {
61
+ const frameMap = {};
62
+ tojson.frames.forEach((frame) => {
63
+ if (frame.id && !frameMap[frame.id]) {
64
+ frameMap[frame.id] = {
65
+ frame,
66
+ meta: void 0
67
+ };
68
+ }
69
+ if (frame.frames && frame.frames.length > 0) {
70
+ buildFrameMapRecursive(frame.frames, frameMap, tojson);
71
+ }
72
+ if (frame.coms) {
73
+ Object.entries(frame.coms).forEach(([comId, comFrame]) => {
74
+ if (comFrame.frames && comFrame.frames.length > 0) {
75
+ buildFrameMapRecursive(comFrame.frames, frameMap, tojson, {
76
+ getComInfo: (id) => {
77
+ var _a;
78
+ for (const scene of tojson.scenes) {
79
+ const comInfo = (_a = scene.coms) == null ? void 0 : _a[comId || id];
80
+ if (comInfo) {
81
+ return comInfo;
82
+ }
83
+ }
84
+ return void 0;
85
+ }
86
+ });
87
+ }
88
+ });
89
+ }
90
+ });
91
+ if (tojson.global.fxFrames && tojson.global.fxFrames.length > 0) {
92
+ tojson.global.fxFrames.forEach((fxFrame) => {
93
+ if (!frameMap[fxFrame.id]) {
94
+ frameMap[fxFrame.id] = {
95
+ frame: fxFrame,
96
+ meta: void 0
97
+ };
98
+ }
99
+ });
100
+ }
101
+ return frameMap;
102
+ };
103
+ // Annotate the CommonJS export names for ESM import in node:
104
+ 0 && (module.exports = {
105
+ buildFrameMap
106
+ });