@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
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # MyBricks To Code Taro
2
+
3
+ MyBricks Taro 代码生成插件,负责将 MyBricks 的 DSL (JSON) 转换为完整的 Taro 项目代码。
4
+
5
+ ## 核心功能
6
+
7
+ - **DSL 转换**: 解析 MyBricks 协议,生成符合 Taro 规范的 TSX、Less 和配置。
8
+ - **项目组装**: 基于内置模板,自动生成完整的 Taro 项目文件结构。
9
+ - **依赖管理**: 自动分析并注入页面所需的组件和工具库依赖。
10
+ - **响应式支持**: 深度集成 MyBricks 逻辑流,支持变量、Fx、事件流与页面生命周期的自动绑定。
11
+
12
+ ## 开发指南
13
+
14
+ ### 常用命令
15
+
16
+ #### 1. 开发模式
17
+ ```bash
18
+ npm run dev
19
+ ```
20
+ 启动 `father dev`,在开发过程中实时编译代码。
21
+
22
+ #### 2. 项目构建
23
+ ```bash
24
+ npm run build
25
+ ```
26
+ 执行生产环境构建,生成 `dist` 目录下的产物。
27
+
28
+ #### 3. 运行通用测试
29
+ ```bash
30
+ npm run test
31
+ ```
32
+ 运行 `test/index.ts`,验证核心转换逻辑是否正确(不输出物理文件)。
33
+
34
+ #### 4. 生成测试项目 (常用)
35
+ ```bash
36
+ npm run test:project
37
+ ```
38
+ 执行 `test/genProject.ts`,根据 `test/test-data.json` 生成完整的物理 Taro 项目。
39
+ 生成的产物将放在 `src/_output/project` 目录下,您可以直接将该目录拷贝到 Taro 开发环境中运行。
40
+
41
+ #### 5. 重新生成项目模板
42
+ ```bash
43
+ npm run test:template
44
+ ```
45
+ 执行 `test/genTemplate.ts`。当您修改了 `src/_template` 目录下的基础模板文件后,**必须运行此命令**,以同步更新 `src/taro-template.json`。这个 JSON 文件是生成完整项目时的骨架。
46
+
47
+ ## 项目结构
48
+
49
+ - `src/core`: 运行时核心工具库(由生成项目引用)。
50
+ - `src/utils`: 生成器内部使用的各种转换工具。
51
+ - `src/processors`: 场景、模块、事件等具体维度的处理逻辑。
52
+ - `src/_template`: 项目生成的基础骨架模板。
53
+ - `test/`: 包含测试数据和用于验证生成的脚本。
54
+
55
+ ---
56
+
57
+ MyBricks Team
58
+
@@ -26,14 +26,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
- // src/core/comlib/Index.ts
30
- var Index_exports = {};
31
- __export(Index_exports, {
29
+ // src/core/comlib/index.ts
30
+ var comlib_exports = {};
31
+ __export(comlib_exports, {
32
32
  mybricks_taro_scanQrcode: () => import_ScanQrcode.default,
33
33
  mybricks_taro_setStorage: () => import_SetStorage.default,
34
34
  mybricks_taro_showToast: () => import_ShowToast.default
35
35
  });
36
- module.exports = __toCommonJS(Index_exports);
36
+ module.exports = __toCommonJS(comlib_exports);
37
37
  var import_ShowToast = __toESM(require("./_ShowToast"));
38
38
  var import_ScanQrcode = __toESM(require("./_ScanQrcode"));
39
39
  var import_SetStorage = __toESM(require("./_SetStorage"));
@@ -56,8 +56,8 @@ __reExport(mybricks_exports, require("./event"), module.exports);
56
56
  var merge = (...subjects) => {
57
57
  const merge2 = new import_Subject.Subject();
58
58
  subjects.forEach((subject) => {
59
- if (subject == null ? void 0 : subject[SUBJECT_SUBSCRIBE]) {
60
- subject[SUBJECT_SUBSCRIBE]((value) => {
59
+ if (subject == null ? void 0 : subject[import_constant.SUBJECT_SUBSCRIBE]) {
60
+ subject[import_constant.SUBJECT_SUBSCRIBE]((value) => {
61
61
  merge2[import_constant.SUBJECT_NEXT](value);
62
62
  });
63
63
  } else {
@@ -120,8 +120,8 @@ var createInputsHandle = (params, init = false) => {
120
120
  }
121
121
  };
122
122
  if (typeof value0 === "string" && value1) {
123
- if (value1 == null ? void 0 : value1[SUBJECT_SUBSCRIBE]) {
124
- value1[SUBJECT_SUBSCRIBE]((value) => {
123
+ if (value1 == null ? void 0 : value1[import_constant.SUBJECT_SUBSCRIBE]) {
124
+ value1[import_constant.SUBJECT_SUBSCRIBE]((value) => {
125
125
  next({
126
126
  [value0]: value
127
127
  });
@@ -132,8 +132,8 @@ var createInputsHandle = (params, init = false) => {
132
132
  });
133
133
  }
134
134
  } else {
135
- if (value0 == null ? void 0 : value0[SUBJECT_SUBSCRIBE]) {
136
- value0[SUBJECT_SUBSCRIBE]((value) => {
135
+ if (value0 == null ? void 0 : value0[import_constant.SUBJECT_SUBSCRIBE]) {
136
+ value0[import_constant.SUBJECT_SUBSCRIBE]((value) => {
137
137
  next(value);
138
138
  });
139
139
  } else {
@@ -161,8 +161,8 @@ var createInputsHandle = (params, init = false) => {
161
161
  }
162
162
  });
163
163
  };
164
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
165
- value[SUBJECT_SUBSCRIBE]((value2, extra) => {
164
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
165
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2, extra) => {
166
166
  if ((extra == null ? void 0 : extra[import_constant.EXCUTE_TYPE_KEY]) === import_constant.EXCUTE_TYPE_VALUE.DATACHANGED && (extra == null ? void 0 : extra.controllerMark) === controllerContext.mark) {
167
167
  return;
168
168
  }
@@ -227,8 +227,8 @@ var createInputsHandle = (params, init = false) => {
227
227
  (_b = controllerContext.modifier.attribute) == null ? void 0 : _b.visibility(visibilityState);
228
228
  }
229
229
  };
230
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
231
- value[SUBJECT_SUBSCRIBE](setVisibility);
230
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
231
+ value[import_constant.SUBJECT_SUBSCRIBE](setVisibility);
232
232
  } else {
233
233
  setVisibility();
234
234
  }
@@ -245,8 +245,8 @@ var createInputsHandle = (params, init = false) => {
245
245
  (_b = controllerContext.modifier.attribute) == null ? void 0 : _b.visibility(!!value2 ? Visibility.Visible : Visibility.None);
246
246
  }
247
247
  };
248
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
249
- value[SUBJECT_SUBSCRIBE](setVisibility);
248
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
249
+ value[import_constant.SUBJECT_SUBSCRIBE](setVisibility);
250
250
  } else {
251
251
  setVisibility(value);
252
252
  }
@@ -338,8 +338,8 @@ var Page = class {
338
338
  /** 打开 */
339
339
  open(name, value) {
340
340
  const controller = pageController();
341
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
342
- value[SUBJECT_SUBSCRIBE]((value2) => {
341
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
342
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
343
343
  this.appRouter.push(name, { value: value2, controller });
344
344
  });
345
345
  } else {
@@ -350,8 +350,8 @@ var Page = class {
350
350
  /** 打开 */
351
351
  replace(name, value) {
352
352
  const controller = pageController();
353
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
354
- value[SUBJECT_SUBSCRIBE]((value2) => {
353
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
354
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
355
355
  this.appRouter.replace(name, { value: value2, controller });
356
356
  });
357
357
  } else {
@@ -362,8 +362,8 @@ var Page = class {
362
362
  /** 确定 */
363
363
  commit(name, value) {
364
364
  const params = this.appRouter.getParams(name);
365
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
366
- value[SUBJECT_SUBSCRIBE]((value2) => {
365
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
366
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
367
367
  this.appRouter.pop();
368
368
  setTimeout(() => {
369
369
  params.controller.commit[import_constant.SUBJECT_NEXT](value2);
@@ -379,8 +379,8 @@ var Page = class {
379
379
  /** 取消 */
380
380
  cancel(name, value) {
381
381
  const params = this.appRouter.getParams(name);
382
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
383
- value[SUBJECT_SUBSCRIBE]((value2) => {
382
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
383
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
384
384
  this.appRouter.pop();
385
385
  setTimeout(() => {
386
386
  params.controller.cancel[import_constant.SUBJECT_NEXT](value2);
@@ -396,8 +396,8 @@ var Page = class {
396
396
  /** 应用,不关闭 */
397
397
  apply(name, value) {
398
398
  const params = this.appRouter.getParams(name);
399
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
400
- value[SUBJECT_SUBSCRIBE]((value2) => {
399
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
400
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
401
401
  params.controller.apply[import_constant.SUBJECT_NEXT](value2);
402
402
  });
403
403
  } else {
@@ -407,8 +407,8 @@ var Page = class {
407
407
  /** 关闭 */
408
408
  close(name, value) {
409
409
  const params = this.appRouter.getParams(name);
410
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
411
- value[SUBJECT_SUBSCRIBE]((value2) => {
410
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
411
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
412
412
  this.appRouter.pop();
413
413
  setTimeout(() => {
414
414
  params.controller.close[import_constant.SUBJECT_NEXT](value2);
@@ -427,8 +427,8 @@ var emit = (fn, value) => {
427
427
  if (!fn) {
428
428
  return subject;
429
429
  }
430
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
431
- value[SUBJECT_SUBSCRIBE]((value2) => {
430
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
431
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
432
432
  const res = fn(value2);
433
433
  if (res instanceof Promise) {
434
434
  res.then((value3) => {
@@ -465,8 +465,8 @@ var createFx = (fx) => {
465
465
  if (!outputs[key]) {
466
466
  outputs[key] = new import_Subject.Subject();
467
467
  }
468
- if (value3 == null ? void 0 : value3[SUBJECT_SUBSCRIBE]) {
469
- value3[SUBJECT_SUBSCRIBE]((value4) => {
468
+ if (value3 == null ? void 0 : value3[import_constant.SUBJECT_SUBSCRIBE]) {
469
+ value3[import_constant.SUBJECT_SUBSCRIBE]((value4) => {
470
470
  outputs[key][import_constant.SUBJECT_NEXT](value4);
471
471
  });
472
472
  } else {
@@ -475,8 +475,8 @@ var createFx = (fx) => {
475
475
  });
476
476
  }
477
477
  };
478
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
479
- value[SUBJECT_SUBSCRIBE]((value2) => {
478
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
479
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
480
480
  next(value2);
481
481
  });
482
482
  } else {
@@ -501,8 +501,8 @@ var createSlotsIO = (params) => {
501
501
  const next = (value) => {
502
502
  inputsMap[key2][import_constant.SUBJECT_NEXT](value);
503
503
  };
504
- next[SUBJECT_SUBSCRIBE] = (next2) => {
505
- inputsMap[key2][SUBJECT_SUBSCRIBE](next2);
504
+ next[import_constant.SUBJECT_SUBSCRIBE] = (next2) => {
505
+ inputsMap[key2][import_constant.SUBJECT_SUBSCRIBE](next2);
506
506
  };
507
507
  return next;
508
508
  }
@@ -511,8 +511,8 @@ var createSlotsIO = (params) => {
511
511
  get(_2, key2) {
512
512
  return (next) => {
513
513
  return (value) => {
514
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
515
- value[SUBJECT_SUBSCRIBE]((value2) => {
514
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
515
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
516
516
  next(value2);
517
517
  });
518
518
  } else {
@@ -542,8 +542,8 @@ var createModuleInputsHandle = () => {
542
542
  outputsMap[key2] = new import_Subject.Subject();
543
543
  }
544
544
  return (value) => {
545
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
546
- value[SUBJECT_SUBSCRIBE]((value2) => {
545
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
546
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
547
547
  outputsMap[key2][import_constant.SUBJECT_NEXT](value2);
548
548
  });
549
549
  } else {
@@ -557,8 +557,8 @@ var createModuleInputsHandle = () => {
557
557
  inputsMap[key] = new import_Subject.Subject();
558
558
  }
559
559
  const next = (value) => {
560
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
561
- value[SUBJECT_SUBSCRIBE]((value2) => {
560
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
561
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
562
562
  inputsMap[key][import_constant.SUBJECT_NEXT](value2);
563
563
  });
564
564
  } else {
@@ -572,9 +572,9 @@ var createModuleInputsHandle = () => {
572
572
  };
573
573
  return new Proxy(next, {
574
574
  get(_2, proxyKey) {
575
- if (proxyKey === "subscribe" || proxyKey === SUBJECT_SUBSCRIBE) {
575
+ if (proxyKey === "subscribe" || proxyKey === import_constant.SUBJECT_SUBSCRIBE) {
576
576
  return (next2) => {
577
- inputsMap[key][SUBJECT_SUBSCRIBE](next2);
577
+ inputsMap[key][import_constant.SUBJECT_SUBSCRIBE](next2);
578
578
  };
579
579
  } else if (proxyKey === "value" || proxyKey === import_constant.SUBJECT_VALUE) {
580
580
  return inputsMap[key][import_constant.SUBJECT_VALUE];
@@ -670,8 +670,8 @@ var transformApi = (api) => {
670
670
  if (!outputs[key]) {
671
671
  outputs[key] = new import_Subject.Subject();
672
672
  }
673
- if (value2 == null ? void 0 : value2[SUBJECT_SUBSCRIBE]) {
674
- value2[SUBJECT_SUBSCRIBE]((value3) => {
673
+ if (value2 == null ? void 0 : value2[import_constant.SUBJECT_SUBSCRIBE]) {
674
+ value2[import_constant.SUBJECT_SUBSCRIBE]((value3) => {
675
675
  var _a2, _b2;
676
676
  if (isDispose) {
677
677
  return;
@@ -712,8 +712,8 @@ var transformBus = (bus) => {
712
712
  };
713
713
  }
714
714
  });
715
- if (value == null ? void 0 : value[SUBJECT_SUBSCRIBE]) {
716
- value[SUBJECT_SUBSCRIBE]((value2) => {
715
+ if (value == null ? void 0 : value[import_constant.SUBJECT_SUBSCRIBE]) {
716
+ value[import_constant.SUBJECT_SUBSCRIBE]((value2) => {
717
717
  newBus2(value2, callBack);
718
718
  });
719
719
  } else {
@@ -740,14 +740,14 @@ var createBus = (bus) => {
740
740
  var join = (lastSubject, nextSubject) => {
741
741
  const subject = new import_Subject.Subject();
742
742
  const next = () => {
743
- if (nextSubject == null ? void 0 : nextSubject[SUBJECT_SUBSCRIBE]) {
743
+ if (nextSubject == null ? void 0 : nextSubject[import_constant.SUBJECT_SUBSCRIBE]) {
744
744
  subject[import_constant.SUBJECT_NEXT](nextSubject[import_constant.SUBJECT_VALUE]);
745
745
  } else {
746
746
  subject[import_constant.SUBJECT_NEXT](nextSubject);
747
747
  }
748
748
  };
749
- if (lastSubject == null ? void 0 : lastSubject[SUBJECT_SUBSCRIBE]) {
750
- lastSubject[SUBJECT_SUBSCRIBE](() => {
749
+ if (lastSubject == null ? void 0 : lastSubject[import_constant.SUBJECT_SUBSCRIBE]) {
750
+ lastSubject[import_constant.SUBJECT_SUBSCRIBE](() => {
751
751
  next();
752
752
  });
753
753
  } else {
@@ -20,10 +20,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  var ComContext_exports = {};
21
21
  __export(ComContext_exports, {
22
22
  default: () => ComContext_default,
23
+ page: () => import_page.page,
23
24
  useAppContext: () => useAppContext
24
25
  });
25
26
  module.exports = __toCommonJS(ComContext_exports);
26
27
  var import_react = require("react");
28
+ var import_page = require("./page");
27
29
  var ComContext = (0, import_react.createContext)(void 0);
28
30
  function useAppContext() {
29
31
  const context = (0, import_react.useContext)(ComContext);
@@ -35,5 +37,6 @@ function useAppContext() {
35
37
  var ComContext_default = ComContext;
36
38
  // Annotate the CommonJS export names for ESM import in node:
37
39
  0 && (module.exports = {
40
+ page,
38
41
  useAppContext
39
42
  });
@@ -0,0 +1,125 @@
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/core/utils/hooks.ts
20
+ var hooks_exports = {};
21
+ __export(hooks_exports, {
22
+ deepProxy: () => deepProxy,
23
+ useBindEvents: () => useBindEvents,
24
+ useBindInputs: () => useBindInputs,
25
+ useModel: () => useModel
26
+ });
27
+ module.exports = __toCommonJS(hooks_exports);
28
+ var import_react = require("react");
29
+ var import_constant = require("../mybricks/constant");
30
+ function deepProxy(target, onSet) {
31
+ if (target === null || typeof target !== "object" || target.__isProxy) {
32
+ return target;
33
+ }
34
+ return new Proxy(target, {
35
+ get(obj, prop) {
36
+ if (prop === "__isProxy")
37
+ return true;
38
+ if (prop === "toJSON")
39
+ return () => obj;
40
+ let value = obj[prop];
41
+ const mybricksMethods = ["get", "set", "changed", "reset", "registerChange", "call", "apply", "bind", "push", "pop"];
42
+ if (value === void 0 && typeof prop === "string" && !mybricksMethods.includes(prop)) {
43
+ value = obj[prop] = {};
44
+ }
45
+ if (typeof value === "object" && value !== null && !value.__isProxy) {
46
+ obj[prop] = deepProxy(value, onSet);
47
+ }
48
+ return obj[prop];
49
+ },
50
+ set(obj, prop, value) {
51
+ const result = Reflect.set(obj, prop, value);
52
+ if (onSet)
53
+ onSet();
54
+ return result;
55
+ }
56
+ });
57
+ }
58
+ function useModel(rawData) {
59
+ const [, forceUpdate] = (0, import_react.useState)({});
60
+ const dataRef = (0, import_react.useRef)(rawData || {});
61
+ return (0, import_react.useMemo)(() => {
62
+ return deepProxy(dataRef.current, () => forceUpdate({}));
63
+ }, []);
64
+ }
65
+ function useBindInputs(scope, id) {
66
+ const handlersRef = (0, import_react.useRef)({});
67
+ return (0, import_react.useMemo)(() => {
68
+ const proxy = new Proxy({}, {
69
+ get: (_target, pin) => {
70
+ return (arg) => {
71
+ if (typeof arg === "function") {
72
+ handlersRef.current[pin] = arg;
73
+ } else {
74
+ const handler = handlersRef.current[pin];
75
+ if (typeof handler === "function") {
76
+ if (arg && arg[import_constant.SUBJECT_SUBSCRIBE]) {
77
+ arg[import_constant.SUBJECT_SUBSCRIBE]((val) => {
78
+ handler(val);
79
+ });
80
+ } else {
81
+ handler(arg);
82
+ }
83
+ }
84
+ }
85
+ };
86
+ }
87
+ });
88
+ scope[id] = proxy;
89
+ return proxy;
90
+ }, [scope, id]);
91
+ }
92
+ function useBindEvents(props) {
93
+ return (0, import_react.useMemo)(() => {
94
+ const _events = {};
95
+ Object.keys(props).forEach((key) => {
96
+ if (key.startsWith("on") && typeof props[key] === "function") {
97
+ const handler = props[key];
98
+ const wrapped = (...args) => handler(...args);
99
+ wrapped.getConnections = () => [{ id: "default" }];
100
+ _events[key] = wrapped;
101
+ }
102
+ });
103
+ return new Proxy(_events, {
104
+ get(target, key) {
105
+ if (typeof key === "string" && key.startsWith("on")) {
106
+ if (target[key]) {
107
+ return target[key];
108
+ }
109
+ const emptyFn = () => {
110
+ };
111
+ emptyFn.getConnections = () => [];
112
+ return emptyFn;
113
+ }
114
+ return target[key];
115
+ }
116
+ });
117
+ }, [props]);
118
+ }
119
+ // Annotate the CommonJS export names for ESM import in node:
120
+ 0 && (module.exports = {
121
+ deepProxy,
122
+ useBindEvents,
123
+ useBindInputs,
124
+ useModel
125
+ });
@@ -14,75 +14,39 @@ var __copyProps = (to, from, except, desc) => {
14
14
  }
15
15
  return to;
16
16
  };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
19
 
19
20
  // src/core/utils/index.ts
20
21
  var utils_exports = {};
21
22
  __export(utils_exports, {
23
+ SUBJECT_SUBSCRIBE: () => import_constant.SUBJECT_SUBSCRIBE,
24
+ SUBJECT_VALUE: () => import_constant.SUBJECT_VALUE,
22
25
  WithCom: () => import_with.WithCom,
23
26
  WithWrapper: () => import_with.WithWrapper,
24
- useBindEvents: () => useBindEvents,
25
- useBindInputs: () => useBindInputs,
26
- useModel: () => useModel
27
+ createFx: () => import_mybricks.createFx,
28
+ createVariable: () => import_mybricks.createVariable,
29
+ merge: () => import_mybricks.merge,
30
+ page: () => import_page.page,
31
+ useAppContext: () => import_ComContext.useAppContext
27
32
  });
28
33
  module.exports = __toCommonJS(utils_exports);
29
- var import_react = require("react");
34
+ __reExport(utils_exports, require("./hooks"), module.exports);
30
35
  var import_with = require("./with");
31
- function useModel(rawData) {
32
- const [, forceUpdate] = (0, import_react.useState)({});
33
- const dataRef = (0, import_react.useRef)(rawData || {});
34
- return (0, import_react.useMemo)(() => {
35
- return new Proxy(dataRef.current, {
36
- get(target, key) {
37
- return Reflect.get(target, key);
38
- },
39
- set(target, key, value) {
40
- const result = Reflect.set(target, key, value);
41
- forceUpdate({});
42
- return result;
43
- }
44
- });
45
- }, []);
46
- }
47
- function useBindInputs(scope, id) {
48
- return (0, import_react.useMemo)(() => {
49
- const controller = scope[id] = scope[id] || {};
50
- return new Proxy({}, {
51
- get: (_target, pin) => {
52
- return (arg) => {
53
- if (typeof arg === "function") {
54
- controller[pin] = arg;
55
- } else {
56
- const callback = controller[pin];
57
- if (typeof callback === "function") {
58
- callback(arg);
59
- }
60
- }
61
- };
62
- }
63
- });
64
- }, [scope, id]);
65
- }
66
- function useBindEvents(props) {
67
- return (0, import_react.useMemo)(() => {
68
- const _events = {};
69
- Object.keys(props).forEach((key) => {
70
- if (key.startsWith("on")) {
71
- const handler = props[key];
72
- if (typeof handler === "function") {
73
- _events[key] = handler;
74
- _events[key].getConnections = () => [1];
75
- }
76
- }
77
- });
78
- return _events;
79
- }, [props]);
80
- }
36
+ var import_page = require("./page");
37
+ var import_ComContext = require("./ComContext");
38
+ var import_mybricks = require("../mybricks");
39
+ var import_constant = require("../mybricks/constant");
81
40
  // Annotate the CommonJS export names for ESM import in node:
82
41
  0 && (module.exports = {
42
+ SUBJECT_SUBSCRIBE,
43
+ SUBJECT_VALUE,
83
44
  WithCom,
84
45
  WithWrapper,
85
- useBindEvents,
86
- useBindInputs,
87
- useModel
46
+ createFx,
47
+ createVariable,
48
+ merge,
49
+ page,
50
+ useAppContext,
51
+ ...require("./hooks")
88
52
  });
@@ -0,0 +1,67 @@
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/core/utils/page.ts
30
+ var page_exports = {};
31
+ __export(page_exports, {
32
+ page: () => page
33
+ });
34
+ module.exports = __toCommonJS(page_exports);
35
+ var import_taro = __toESM(require("@tarojs/taro"));
36
+ var import_mybricks = require("../mybricks");
37
+ var TaroRouter = class {
38
+ getParams(name) {
39
+ var _a;
40
+ const instance = import_taro.default.getCurrentInstance();
41
+ return {
42
+ value: (_a = instance.router) == null ? void 0 : _a.params
43
+ };
44
+ }
45
+ push(name, { value }) {
46
+ const url = `/pages/${name}/index`;
47
+ const queryString = value ? `?data=${encodeURIComponent(JSON.stringify(value))}` : "";
48
+ import_taro.default.navigateTo({
49
+ url: url + queryString
50
+ });
51
+ }
52
+ replace(name, { value }) {
53
+ const url = `/pages/${name}/index`;
54
+ const queryString = value ? `?data=${encodeURIComponent(JSON.stringify(value))}` : "";
55
+ import_taro.default.redirectTo({
56
+ url: url + queryString
57
+ });
58
+ }
59
+ pop() {
60
+ import_taro.default.navigateBack();
61
+ }
62
+ };
63
+ var page = new import_mybricks.Page(new TaroRouter());
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ page
67
+ });
@@ -23,8 +23,9 @@ __export(useContext_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(useContext_exports);
25
25
  var import_react = require("react");
26
+ var import_hooks = require("./hooks");
26
27
  function useAppCreateContext() {
27
- const comRefs = (0, import_react.useRef)({});
28
+ const comRefs = (0, import_react.useRef)((0, import_hooks.deepProxy)({}));
28
29
  const appContext = {
29
30
  canvas: {
30
31
  id: "u_7VvVn"