@mybricks/to-code-taro 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/README.md +58 -0
  2. package/dist/cjs/core/comlib/_AesEncode.js +115 -0
  3. package/dist/cjs/core/comlib/_BackTo.js +80 -0
  4. package/dist/cjs/core/comlib/{Index.js → _CallPhone.js} +29 -16
  5. package/dist/cjs/core/comlib/_ChooseFile.js +103 -0
  6. package/dist/cjs/core/comlib/_ChooseMedia.js +70 -0
  7. package/dist/cjs/core/comlib/_Connector.js +92 -0
  8. package/dist/cjs/core/comlib/_ConnectorGlobalHeaders.js +79 -0
  9. package/dist/cjs/core/comlib/_Format.js +123 -0
  10. package/dist/cjs/core/comlib/_GetLocation.js +60 -0
  11. package/dist/cjs/core/comlib/_GetStorage.js +68 -0
  12. package/dist/cjs/core/comlib/_GetSystemInfo.js +62 -0
  13. package/dist/cjs/core/comlib/_OpenCamera.js +73 -0
  14. package/dist/cjs/core/comlib/_OpenPetalMap.js +49 -0
  15. package/dist/cjs/core/comlib/_OpenUrl.js +62 -0
  16. package/dist/cjs/core/comlib/_RemoveStorage.js +68 -0
  17. package/dist/cjs/core/comlib/_Router.js +100 -0
  18. package/dist/cjs/core/comlib/_ScanQrcode.js +9 -10
  19. package/dist/cjs/core/comlib/_SetStorage.js +10 -19
  20. package/dist/cjs/core/comlib/_Share.js +58 -0
  21. package/dist/cjs/core/comlib/_ShowToast.js +23 -50
  22. package/dist/cjs/core/comlib/_TextToSpeech.js +120 -0
  23. package/dist/cjs/core/comlib/_TimerDebounce.js +72 -0
  24. package/dist/cjs/core/comlib/_TimerDelay.js +63 -0
  25. package/dist/cjs/core/comlib/_TimerThrottle.js +75 -0
  26. package/dist/cjs/core/comlib/_Vibrate.js +60 -0
  27. package/dist/cjs/core/comlib/index.js +111 -0
  28. package/dist/cjs/core/mybricks/index.js +47 -47
  29. package/dist/cjs/core/utils/ComContext.js +3 -0
  30. package/dist/cjs/core/utils/PopupRenderer.js +63 -0
  31. package/dist/cjs/core/utils/hooks.js +131 -0
  32. package/dist/cjs/core/utils/index.js +33 -57
  33. package/dist/cjs/core/utils/pageRouter.js +81 -0
  34. package/dist/cjs/core/utils/popupRouter.js +98 -0
  35. package/dist/cjs/core/utils/useContext.js +11 -2
  36. package/dist/cjs/core/utils/with.js +37 -13
  37. package/dist/cjs/generate/generateTaroProjectJson.d.ts +3 -14
  38. package/dist/cjs/generate/generateTaroProjectJson.js +39 -6
  39. package/dist/cjs/generate/utils/tabBarImages.d.ts +1 -1
  40. package/dist/cjs/handleCom.d.ts +1 -1
  41. package/dist/cjs/handleCom.js +91 -177
  42. package/dist/cjs/handleDom.js +7 -44
  43. package/dist/cjs/handleExtension.d.ts +2 -2
  44. package/dist/cjs/handleExtension.js +5 -5
  45. package/dist/cjs/handleGlobal.d.ts +2 -12
  46. package/dist/cjs/handleGlobal.js +23 -7
  47. package/dist/cjs/handleModule.js +3 -3
  48. package/dist/cjs/handleSlot.d.ts +4 -9
  49. package/dist/cjs/handleSlot.js +61 -150
  50. package/dist/cjs/processors/processComEvents.d.ts +9 -0
  51. package/dist/cjs/processors/processComEvents.js +164 -0
  52. package/dist/cjs/processors/processModule.d.ts +31 -0
  53. package/dist/cjs/processors/processModule.js +125 -0
  54. package/dist/cjs/processors/processScene.d.ts +32 -0
  55. package/dist/cjs/processors/processScene.js +128 -0
  56. package/dist/cjs/processors/processSceneLogic.d.ts +4 -0
  57. package/dist/cjs/processors/processSceneLogic.js +170 -0
  58. package/dist/cjs/shims-taro.d.ts +20 -0
  59. package/dist/cjs/taro-template.json +501 -351
  60. package/dist/cjs/toCodeTaro.d.ts +27 -6
  61. package/dist/cjs/toCodeTaro.js +68 -340
  62. package/dist/cjs/utils/builder/buildResult.d.ts +22 -0
  63. package/dist/cjs/utils/builder/buildResult.js +117 -0
  64. package/dist/cjs/utils/common/ImportManager.d.ts +19 -0
  65. package/dist/cjs/utils/common/ImportManager.js +105 -0
  66. package/dist/cjs/utils/common/helper.d.ts +2 -0
  67. package/dist/cjs/utils/common/helper.js +31 -0
  68. package/dist/cjs/utils/common/object.d.ts +5 -0
  69. package/dist/cjs/utils/common/object.js +58 -0
  70. package/dist/cjs/utils/common/string.d.ts +8 -0
  71. package/dist/cjs/utils/common/string.js +46 -0
  72. package/dist/cjs/utils/{pageConfig → config/content}/converter.js +1 -1
  73. package/dist/cjs/utils/{pageConfig → config/content}/index.js +9 -9
  74. package/dist/cjs/utils/{pageConfig → config/content}/pageConfig.js +12 -22
  75. package/dist/{esm/utils/pageConfig → cjs/utils/config/content}/saveBase64Image.d.ts +1 -1
  76. package/dist/cjs/utils/{pageConfig → config/content}/saveBase64Image.js +8 -17
  77. package/dist/cjs/utils/{pageConfig → config/content}/tabBarConfig.js +9 -32
  78. package/dist/cjs/utils/config/content/types.js +17 -0
  79. package/dist/cjs/utils/{pageConfig → config/content}/validator.js +1 -1
  80. package/dist/{esm/utils → cjs/utils/config}/handlePageConfig.d.ts +3 -2
  81. package/dist/cjs/utils/{handlePageConfig.js → config/handlePageConfig.js} +7 -6
  82. package/dist/cjs/utils/context/buildContext.d.ts +24 -0
  83. package/dist/cjs/utils/context/buildContext.js +65 -0
  84. package/dist/cjs/utils/context/buildFrameMap.d.ts +16 -0
  85. package/dist/cjs/utils/context/buildFrameMap.js +106 -0
  86. package/dist/cjs/utils/context/buildGlobalData.d.ts +13 -0
  87. package/dist/cjs/utils/context/buildGlobalData.js +58 -0
  88. package/dist/cjs/utils/context/collectJSModules.d.ts +37 -0
  89. package/dist/cjs/utils/context/collectJSModules.js +91 -0
  90. package/dist/cjs/utils/context/createEventQueries.d.ts +45 -0
  91. package/dist/cjs/utils/context/createEventQueries.js +99 -0
  92. package/dist/cjs/utils/context/createProvider.d.ts +21 -0
  93. package/dist/cjs/utils/context/createProvider.js +49 -0
  94. package/dist/cjs/utils/index.d.ts +10 -62
  95. package/dist/cjs/utils/index.js +21 -282
  96. package/dist/cjs/utils/{convertNamespace.js → logic/convertNamespace.js} +1 -1
  97. package/dist/cjs/utils/{genJSModules.js → logic/genJSModules.js} +1 -1
  98. package/dist/{esm/utils → cjs/utils/logic}/handleProcess.d.ts +2 -2
  99. package/dist/cjs/utils/{handleProcess.js → logic/handleProcess.js} +40 -16
  100. package/dist/cjs/utils/logic/processChildren.d.ts +12 -0
  101. package/dist/cjs/utils/logic/processChildren.js +82 -0
  102. package/dist/cjs/utils/style/color.d.ts +4 -0
  103. package/dist/cjs/utils/style/color.js +45 -0
  104. package/dist/cjs/utils/style/converter.d.ts +7 -0
  105. package/dist/cjs/utils/style/converter.js +181 -0
  106. package/dist/cjs/utils/{getComponentClassName.js → style/getComponentClassName.js} +1 -1
  107. package/dist/cjs/utils/{pxtransform.js → style/pxtransform.js} +1 -1
  108. package/dist/cjs/utils/style/types.d.ts +23 -0
  109. package/dist/cjs/utils/{pageConfig → style}/types.js +1 -1
  110. package/dist/cjs/utils/{code → templates}/component.js +1 -1
  111. package/dist/cjs/utils/{code → templates}/index.js +4 -4
  112. package/dist/cjs/utils/{code → templates}/renderManager.js +1 -1
  113. package/dist/cjs/utils/{code → templates}/scene.d.ts +3 -1
  114. package/dist/cjs/utils/{code → templates}/scene.js +17 -5
  115. package/dist/esm/core/comlib/_AesEncode.js +85 -0
  116. package/dist/esm/core/comlib/_BackTo.js +66 -0
  117. package/dist/esm/core/comlib/_CallPhone.js +30 -0
  118. package/dist/esm/core/comlib/_ChooseFile.js +81 -0
  119. package/dist/esm/core/comlib/_ChooseMedia.js +38 -0
  120. package/dist/esm/core/comlib/_Connector.js +60 -0
  121. package/dist/esm/core/comlib/_ConnectorGlobalHeaders.js +56 -0
  122. package/dist/esm/core/comlib/_Format.js +102 -0
  123. package/dist/esm/core/comlib/_GetLocation.js +26 -0
  124. package/dist/esm/core/comlib/_GetStorage.js +44 -0
  125. package/dist/esm/core/comlib/_GetSystemInfo.js +32 -0
  126. package/dist/esm/core/comlib/_OpenCamera.js +44 -0
  127. package/dist/esm/core/comlib/_OpenPetalMap.js +28 -0
  128. package/dist/esm/core/comlib/_OpenUrl.js +36 -0
  129. package/dist/esm/core/comlib/_RemoveStorage.js +42 -0
  130. package/dist/esm/core/comlib/_Router.js +113 -0
  131. package/dist/esm/core/comlib/_ScanQrcode.js +10 -11
  132. package/dist/esm/core/comlib/_SetStorage.js +13 -25
  133. package/dist/esm/core/comlib/_Share.js +28 -0
  134. package/dist/esm/core/comlib/_ShowToast.js +32 -55
  135. package/dist/esm/core/comlib/_TextToSpeech.js +117 -0
  136. package/dist/esm/core/comlib/_TimerDebounce.js +66 -0
  137. package/dist/esm/core/comlib/_TimerDelay.js +47 -0
  138. package/dist/esm/core/comlib/_TimerThrottle.js +69 -0
  139. package/dist/esm/core/comlib/_Vibrate.js +34 -0
  140. package/dist/esm/core/comlib/index.js +37 -0
  141. package/dist/esm/core/mybricks/index.js +1 -1
  142. package/dist/esm/core/utils/ComContext.js +1 -0
  143. package/dist/esm/core/utils/PopupRenderer.js +27 -0
  144. package/dist/esm/core/utils/hooks.js +130 -0
  145. package/dist/esm/core/utils/index.js +8 -57
  146. package/dist/esm/core/utils/pageRouter.js +69 -0
  147. package/dist/esm/core/utils/popupRouter.js +116 -0
  148. package/dist/esm/core/utils/useContext.js +16 -3
  149. package/dist/esm/core/utils/with.js +62 -19
  150. package/dist/esm/generate/generateTaroProjectJson.d.ts +3 -14
  151. package/dist/esm/generate/generateTaroProjectJson.js +62 -24
  152. package/dist/esm/generate/utils/tabBarImages.d.ts +1 -1
  153. package/dist/esm/handleCom.d.ts +1 -1
  154. package/dist/esm/handleCom.js +159 -244
  155. package/dist/esm/handleDom.js +9 -48
  156. package/dist/esm/handleExtension.d.ts +2 -2
  157. package/dist/esm/handleExtension.js +5 -5
  158. package/dist/esm/handleGlobal.d.ts +2 -12
  159. package/dist/esm/handleGlobal.js +17 -3
  160. package/dist/esm/handleModule.js +3 -3
  161. package/dist/esm/handleSlot.d.ts +4 -9
  162. package/dist/esm/handleSlot.js +112 -173
  163. package/dist/esm/processors/processComEvents.d.ts +9 -0
  164. package/dist/esm/processors/processComEvents.js +167 -0
  165. package/dist/esm/processors/processModule.d.ts +31 -0
  166. package/dist/esm/processors/processModule.js +126 -0
  167. package/dist/esm/processors/processScene.d.ts +32 -0
  168. package/dist/esm/processors/processScene.js +134 -0
  169. package/dist/esm/processors/processSceneLogic.d.ts +4 -0
  170. package/dist/esm/processors/processSceneLogic.js +170 -0
  171. package/dist/esm/shims-taro.d.ts +20 -0
  172. package/dist/esm/taro-template.json +501 -351
  173. package/dist/esm/toCodeTaro.d.ts +27 -6
  174. package/dist/esm/toCodeTaro.js +110 -395
  175. package/dist/esm/utils/builder/buildResult.d.ts +22 -0
  176. package/dist/esm/utils/builder/buildResult.js +82 -0
  177. package/dist/esm/utils/common/ImportManager.d.ts +19 -0
  178. package/dist/esm/utils/common/ImportManager.js +103 -0
  179. package/dist/esm/utils/common/helper.d.ts +2 -0
  180. package/dist/esm/utils/common/helper.js +4 -0
  181. package/dist/esm/utils/common/object.d.ts +5 -0
  182. package/dist/esm/utils/common/object.js +32 -0
  183. package/dist/esm/utils/common/string.d.ts +8 -0
  184. package/dist/esm/utils/common/string.js +21 -0
  185. package/dist/esm/utils/config/content/pageConfig.js +40 -0
  186. package/dist/{cjs/utils/pageConfig → esm/utils/config/content}/saveBase64Image.d.ts +1 -1
  187. package/dist/esm/utils/{pageConfig → config/content}/saveBase64Image.js +11 -30
  188. package/dist/esm/utils/{pageConfig → config/content}/tabBarConfig.js +12 -34
  189. package/dist/{cjs/utils → esm/utils/config}/handlePageConfig.d.ts +3 -2
  190. package/dist/esm/utils/{handlePageConfig.js → config/handlePageConfig.js} +6 -2
  191. package/dist/esm/utils/context/buildContext.d.ts +24 -0
  192. package/dist/esm/utils/context/buildContext.js +53 -0
  193. package/dist/esm/utils/context/buildFrameMap.d.ts +16 -0
  194. package/dist/esm/utils/context/buildFrameMap.js +131 -0
  195. package/dist/esm/utils/context/buildGlobalData.d.ts +13 -0
  196. package/dist/esm/utils/context/buildGlobalData.js +44 -0
  197. package/dist/esm/utils/context/collectJSModules.d.ts +37 -0
  198. package/dist/esm/utils/context/collectJSModules.js +87 -0
  199. package/dist/esm/utils/context/createEventQueries.d.ts +45 -0
  200. package/dist/esm/utils/context/createEventQueries.js +99 -0
  201. package/dist/esm/utils/context/createProvider.d.ts +21 -0
  202. package/dist/esm/utils/context/createProvider.js +33 -0
  203. package/dist/esm/utils/index.d.ts +10 -62
  204. package/dist/esm/utils/index.js +12 -345
  205. package/dist/{cjs/utils → esm/utils/logic}/handleProcess.d.ts +2 -2
  206. package/dist/esm/utils/{handleProcess.js → logic/handleProcess.js} +42 -9
  207. package/dist/esm/utils/logic/processChildren.d.ts +12 -0
  208. package/dist/esm/utils/logic/processChildren.js +48 -0
  209. package/dist/esm/utils/style/color.d.ts +4 -0
  210. package/dist/esm/utils/style/color.js +17 -0
  211. package/dist/esm/utils/style/converter.d.ts +7 -0
  212. package/dist/esm/utils/style/converter.js +176 -0
  213. package/dist/esm/utils/style/types.d.ts +23 -0
  214. package/dist/esm/utils/style/types.js +1 -0
  215. package/dist/esm/utils/{code → templates}/scene.d.ts +3 -1
  216. package/dist/esm/utils/{code → templates}/scene.js +13 -5
  217. package/package.json +4 -2
  218. package/dist/esm/core/comlib/Index.js +0 -3
  219. package/dist/esm/utils/pageConfig/pageConfig.js +0 -60
  220. /package/dist/cjs/utils/{pageConfig → config/content}/converter.d.ts +0 -0
  221. /package/dist/cjs/utils/{pageConfig → config/content}/index.d.ts +0 -0
  222. /package/dist/cjs/utils/{pageConfig → config/content}/pageConfig.d.ts +0 -0
  223. /package/dist/cjs/utils/{pageConfig → config/content}/tabBarConfig.d.ts +0 -0
  224. /package/dist/cjs/utils/{pageConfig → config/content}/types.d.ts +0 -0
  225. /package/dist/cjs/utils/{pageConfig → config/content}/validator.d.ts +0 -0
  226. /package/dist/cjs/utils/{convertNamespace.d.ts → logic/convertNamespace.d.ts} +0 -0
  227. /package/dist/cjs/utils/{genJSModules.d.ts → logic/genJSModules.d.ts} +0 -0
  228. /package/dist/cjs/utils/{getComponentClassName.d.ts → style/getComponentClassName.d.ts} +0 -0
  229. /package/dist/cjs/utils/{pxtransform.d.ts → style/pxtransform.d.ts} +0 -0
  230. /package/dist/cjs/utils/{code → templates}/component.d.ts +0 -0
  231. /package/dist/cjs/utils/{code → templates}/index.d.ts +0 -0
  232. /package/dist/cjs/utils/{code → templates}/renderManager.d.ts +0 -0
  233. /package/dist/esm/utils/{pageConfig → config/content}/converter.d.ts +0 -0
  234. /package/dist/esm/utils/{pageConfig → config/content}/converter.js +0 -0
  235. /package/dist/esm/utils/{pageConfig → config/content}/index.d.ts +0 -0
  236. /package/dist/esm/utils/{pageConfig → config/content}/index.js +0 -0
  237. /package/dist/esm/utils/{pageConfig → config/content}/pageConfig.d.ts +0 -0
  238. /package/dist/esm/utils/{pageConfig → config/content}/tabBarConfig.d.ts +0 -0
  239. /package/dist/esm/utils/{pageConfig → config/content}/types.d.ts +0 -0
  240. /package/dist/esm/utils/{pageConfig → config/content}/types.js +0 -0
  241. /package/dist/esm/utils/{pageConfig → config/content}/validator.d.ts +0 -0
  242. /package/dist/esm/utils/{pageConfig → config/content}/validator.js +0 -0
  243. /package/dist/esm/utils/{convertNamespace.d.ts → logic/convertNamespace.d.ts} +0 -0
  244. /package/dist/esm/utils/{convertNamespace.js → logic/convertNamespace.js} +0 -0
  245. /package/dist/esm/utils/{genJSModules.d.ts → logic/genJSModules.d.ts} +0 -0
  246. /package/dist/esm/utils/{genJSModules.js → logic/genJSModules.js} +0 -0
  247. /package/dist/esm/utils/{getComponentClassName.d.ts → style/getComponentClassName.d.ts} +0 -0
  248. /package/dist/esm/utils/{getComponentClassName.js → style/getComponentClassName.js} +0 -0
  249. /package/dist/esm/utils/{pxtransform.d.ts → style/pxtransform.d.ts} +0 -0
  250. /package/dist/esm/utils/{pxtransform.js → style/pxtransform.js} +0 -0
  251. /package/dist/esm/utils/{code → templates}/component.d.ts +0 -0
  252. /package/dist/esm/utils/{code → templates}/component.js +0 -0
  253. /package/dist/esm/utils/{code → templates}/index.d.ts +0 -0
  254. /package/dist/esm/utils/{code → templates}/index.js +0 -0
  255. /package/dist/esm/utils/{code → templates}/renderManager.d.ts +0 -0
  256. /package/dist/esm/utils/{code → templates}/renderManager.js +0 -0
@@ -6,47 +6,35 @@ export default (function (context) {
6
6
  var outputs = context.outputs;
7
7
  (_inputs$setStorage = inputs.setStorage) === null || _inputs$setStorage === void 0 || _inputs$setStorage.call(inputs, function (val) {
8
8
  try {
9
- var _data$sync;
10
- // 优先使用动态输入的值,否则使用配置的值
11
- var key = (val === null || val === void 0 ? void 0 : val.key) || (data === null || data === void 0 ? void 0 : data.key);
12
- var _value = (val === null || val === void 0 ? void 0 : val.value) !== undefined ? val.value : data === null || data === void 0 ? void 0 : data.value;
13
- var useSync = (val === null || val === void 0 ? void 0 : val.sync) !== undefined ? val.sync : (_data$sync = data === null || data === void 0 ? void 0 : data.sync) !== null && _data$sync !== void 0 ? _data$sync : false;
9
+ var key = (val === null || val === void 0 ? void 0 : val.key) || data.key;
10
+ var _value = (val === null || val === void 0 ? void 0 : val.value) !== undefined ? val.value : data.value;
11
+ var useSync = (val === null || val === void 0 ? void 0 : val.sync) !== undefined ? val.sync : data.sync || false;
14
12
  if (!key) {
15
- outputs === null || outputs === void 0 || outputs.onFail('存储 key 不能为空');
13
+ outputs.onFail('存储 key 不能为空');
16
14
  return;
17
15
  }
16
+ var result = {
17
+ key: key,
18
+ value: _value
19
+ };
18
20
  if (useSync) {
19
- // 使用同步方法
20
- try {
21
- Taro.setStorageSync(key, _value);
22
- outputs === null || outputs === void 0 || outputs.onSuccess({
23
- key: key,
24
- value: _value
25
- });
26
- } catch (error) {
27
- console.error('写入本地缓存失败:', error);
28
- outputs === null || outputs === void 0 || outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '写入本地缓存失败');
29
- }
21
+ Taro.setStorageSync(key, _value);
22
+ outputs.onSuccess(result);
30
23
  } else {
31
- // 使用异步方法
32
24
  Taro.setStorage({
33
25
  key: key,
34
26
  data: _value,
35
27
  success: function success() {
36
- outputs === null || outputs === void 0 || outputs.onSuccess({
37
- key: key,
38
- value: _value
39
- });
28
+ return outputs.onSuccess(result);
40
29
  },
41
30
  fail: function fail(err) {
42
- console.error('写入本地缓存失败:', err);
43
- outputs === null || outputs === void 0 || outputs.onFail(err.errMsg || '写入本地缓存失败');
31
+ return outputs.onFail(err.errMsg || '写入本地缓存失败');
44
32
  }
45
33
  });
46
34
  }
47
35
  } catch (error) {
48
36
  console.error('写入本地缓存失败:', error);
49
- outputs === null || outputs === void 0 || outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '写入本地缓存失败');
37
+ outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '写入本地缓存失败');
50
38
  }
51
39
  });
52
40
  });
@@ -0,0 +1,28 @@
1
+ import Taro from '@tarojs/taro';
2
+ export default (function (context) {
3
+ var _inputs$share;
4
+ var data = context.data;
5
+ var inputs = context.inputs;
6
+ var outputs = context.outputs;
7
+ (_inputs$share = inputs.share) === null || _inputs$share === void 0 || _inputs$share.call(inputs, function (val) {
8
+ try {
9
+ var shareData = {
10
+ title: (val === null || val === void 0 ? void 0 : val.title) || data.title || '分享',
11
+ path: (val === null || val === void 0 ? void 0 : val.path) || data.path || '/pages/index/index',
12
+ imageUrl: (val === null || val === void 0 ? void 0 : val.imageUrl) || data.imageUrl
13
+ };
14
+ Taro.showShareMenu({
15
+ withShareTicket: true,
16
+ success: function success() {
17
+ return outputs.onSuccess(shareData);
18
+ },
19
+ fail: function fail(err) {
20
+ return outputs.onFail(err.errMsg || '分享失败');
21
+ }
22
+ });
23
+ } catch (error) {
24
+ console.error('分享失败:', error);
25
+ outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '分享失败');
26
+ }
27
+ });
28
+ });
@@ -6,63 +6,40 @@ export default (function (context) {
6
6
  var inputs = context.inputs;
7
7
  var outputs = context.outputs;
8
8
  (_inputs$showToast = inputs.showToast) === null || _inputs$showToast === void 0 || _inputs$showToast.call(inputs, function (val) {
9
- if (data !== null && data !== void 0 && data.dynamic) {
10
- // 动态输入
11
- try {
12
- var _ref, _val$duration, _data$duration, _ref2, _val$mask, _data$mask;
13
- var toastConfig = {
14
- title: typeof val === 'string' ? val : (val === null || val === void 0 ? void 0 : val.title) || data.title || '',
15
- duration: Number(val && _typeof(val) === 'object' ? (_ref = (_val$duration = val === null || val === void 0 ? void 0 : val.duration) !== null && _val$duration !== void 0 ? _val$duration : data.duration) !== null && _ref !== void 0 ? _ref : 1000 : (_data$duration = data.duration) !== null && _data$duration !== void 0 ? _data$duration : 1000),
16
- mask: val && _typeof(val) === 'object' ? (_ref2 = (_val$mask = val === null || val === void 0 ? void 0 : val.mask) !== null && _val$mask !== void 0 ? _val$mask : data.mask) !== null && _ref2 !== void 0 ? _ref2 : false : (_data$mask = data.mask) !== null && _data$mask !== void 0 ? _data$mask : false
17
- };
18
- if (val && _typeof(val) === 'object' && val.icon) {
19
- toastConfig.icon = val.icon;
20
- } else if (data.icon) {
21
- toastConfig.icon = data.icon;
22
- }
23
- if (val && _typeof(val) === 'object' && val.image) {
24
- toastConfig.image = val.image;
25
- } else if (data.image) {
26
- toastConfig.image = data.image;
27
- }
28
- Taro.showToast(toastConfig);
29
- if (data.asynchronous) {
30
- var _ref3, _val$duration2, _data$duration2;
31
- setTimeout(function () {
32
- outputs.afterShowToast(val);
33
- }, Number(val && _typeof(val) === 'object' ? (_ref3 = (_val$duration2 = val === null || val === void 0 ? void 0 : val.duration) !== null && _val$duration2 !== void 0 ? _val$duration2 : data.duration) !== null && _ref3 !== void 0 ? _ref3 : 1000 : (_data$duration2 = data.duration) !== null && _data$duration2 !== void 0 ? _data$duration2 : 1000));
34
- } else {
35
- outputs.afterShowToast(val);
36
- }
37
- } catch (error) {
38
- console.error('显示 Toast 失败:', error);
9
+ try {
10
+ // 构建 Toast 配置
11
+ var toastConfig = {
12
+ title: typeof val === 'string' ? val : (val === null || val === void 0 ? void 0 : val.title) || data.title || '',
13
+ duration: Number(_typeof(val) === 'object' && val !== null && val !== void 0 && val.duration ? val.duration : data.duration || 1000),
14
+ mask: _typeof(val) === 'object' && (val === null || val === void 0 ? void 0 : val.mask) !== undefined ? val.mask : data.mask || false
15
+ };
16
+
17
+ // 图标配置
18
+ if (_typeof(val) === 'object' && val !== null && val !== void 0 && val.icon) {
19
+ toastConfig.icon = val.icon;
20
+ } else if (data.icon) {
21
+ toastConfig.icon = data.icon;
39
22
  }
40
- } else {
41
- // 非动态输入
42
- try {
43
- var _data$mask2;
44
- var _toastConfig = {
45
- title: data.title || '',
46
- duration: Number(data.duration || 1000),
47
- mask: (_data$mask2 = data.mask) !== null && _data$mask2 !== void 0 ? _data$mask2 : false
48
- };
49
- if (data.icon) {
50
- _toastConfig.icon = data.icon;
51
- }
52
- if (data.image) {
53
- _toastConfig.image = data.image;
54
- }
55
- Taro.showToast(_toastConfig);
56
- if (data.asynchronous) {
57
- setTimeout(function () {
58
- outputs.afterShowToast(val);
59
- }, Number(data.duration || 1000));
60
- } else {
61
- outputs.afterShowToast(val);
62
- }
63
- } catch (error) {
64
- console.error('显示 Toast 失败:', error);
23
+
24
+ // 图片配置
25
+ if (_typeof(val) === 'object' && val !== null && val !== void 0 && val.image) {
26
+ toastConfig.image = val.image;
27
+ } else if (data.image) {
28
+ toastConfig.image = data.image;
65
29
  }
30
+ Taro.showToast(toastConfig);
31
+
32
+ // 处理输出回调
33
+ var triggerOutput = function triggerOutput() {
34
+ return outputs.afterShowToast(val);
35
+ };
36
+ if (data.asynchronous) {
37
+ setTimeout(triggerOutput, toastConfig.duration);
38
+ } else {
39
+ triggerOutput();
40
+ }
41
+ } catch (error) {
42
+ console.error('显示 Toast 失败:', error);
66
43
  }
67
44
  });
68
45
  });
@@ -0,0 +1,117 @@
1
+ // 检查浏览器是否支持Web Speech API
2
+ var speechSupported = typeof window !== 'undefined' && 'speechSynthesis' in window;
3
+ var currentUtterance = null;
4
+ export default (function (context) {
5
+ var _inputs$speak, _inputs$stop, _inputs$pause, _inputs$resume;
6
+ var data = context.data;
7
+ var inputs = context.inputs;
8
+ var outputs = context.outputs;
9
+ if (!speechSupported) {
10
+ console.warn('当前环境不支持语音合成功能');
11
+ }
12
+ (_inputs$speak = inputs.speak) === null || _inputs$speak === void 0 || _inputs$speak.call(inputs, function (val) {
13
+ try {
14
+ var text = (val === null || val === void 0 ? void 0 : val.text) || data.text;
15
+ var lang = (val === null || val === void 0 ? void 0 : val.lang) || data.lang || 'zh-CN';
16
+ var rate = (val === null || val === void 0 ? void 0 : val.rate) || data.rate || 1;
17
+ var pitch = (val === null || val === void 0 ? void 0 : val.pitch) || data.pitch || 1;
18
+ var volume = (val === null || val === void 0 ? void 0 : val.volume) || data.volume || 1;
19
+ if (!text) {
20
+ outputs.onFail('待合成的文本不能为空');
21
+ return;
22
+ }
23
+ if (!speechSupported) {
24
+ outputs.onFail('当前环境不支持语音合成功能');
25
+ return;
26
+ }
27
+
28
+ // 如果有正在播放的语音,先停止
29
+ if (currentUtterance && window.speechSynthesis.speaking) {
30
+ window.speechSynthesis.cancel();
31
+ }
32
+ currentUtterance = new SpeechSynthesisUtterance(text);
33
+ currentUtterance.lang = lang;
34
+ currentUtterance.rate = Math.max(0.1, Math.min(10, rate));
35
+ currentUtterance.pitch = Math.max(0, Math.min(2, pitch));
36
+ currentUtterance.volume = Math.max(0, Math.min(1, volume));
37
+ currentUtterance.onstart = function () {
38
+ outputs.onStart({
39
+ text: text,
40
+ lang: lang,
41
+ rate: rate,
42
+ pitch: pitch,
43
+ volume: volume
44
+ });
45
+ };
46
+ currentUtterance.onend = function () {
47
+ outputs.onEnd({
48
+ text: text,
49
+ lang: lang,
50
+ rate: rate,
51
+ pitch: pitch,
52
+ volume: volume
53
+ });
54
+ currentUtterance = null;
55
+ };
56
+ currentUtterance.onerror = function (event) {
57
+ outputs.onError({
58
+ error: event.error,
59
+ text: text,
60
+ message: '语音合成失败'
61
+ });
62
+ currentUtterance = null;
63
+ };
64
+ window.speechSynthesis.speak(currentUtterance);
65
+ outputs.onSuccess({
66
+ text: text,
67
+ lang: lang,
68
+ rate: rate,
69
+ pitch: pitch,
70
+ volume: volume
71
+ });
72
+ } catch (error) {
73
+ console.error('语音合成失败:', error);
74
+ outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '语音合成失败');
75
+ }
76
+ });
77
+ (_inputs$stop = inputs.stop) === null || _inputs$stop === void 0 || _inputs$stop.call(inputs, function () {
78
+ try {
79
+ if (speechSupported && currentUtterance) {
80
+ window.speechSynthesis.cancel();
81
+ currentUtterance = null;
82
+ outputs.onSuccess('已停止语音播放');
83
+ } else {
84
+ outputs.onFail('没有正在播放的语音');
85
+ }
86
+ } catch (error) {
87
+ console.error('停止语音失败:', error);
88
+ outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '停止语音失败');
89
+ }
90
+ });
91
+ (_inputs$pause = inputs.pause) === null || _inputs$pause === void 0 || _inputs$pause.call(inputs, function () {
92
+ try {
93
+ if (speechSupported && window.speechSynthesis.pause) {
94
+ window.speechSynthesis.pause();
95
+ outputs.onSuccess('已暂停语音播放');
96
+ } else {
97
+ outputs.onFail('当前环境不支持暂停功能');
98
+ }
99
+ } catch (error) {
100
+ console.error('暂停语音失败:', error);
101
+ outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '暂停语音失败');
102
+ }
103
+ });
104
+ (_inputs$resume = inputs.resume) === null || _inputs$resume === void 0 || _inputs$resume.call(inputs, function () {
105
+ try {
106
+ if (speechSupported && window.speechSynthesis.resume) {
107
+ window.speechSynthesis.resume();
108
+ outputs.onSuccess('已恢复语音播放');
109
+ } else {
110
+ outputs.onFail('当前环境不支持恢复功能');
111
+ }
112
+ } catch (error) {
113
+ console.error('恢复语音失败:', error);
114
+ outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '恢复语音失败');
115
+ }
116
+ });
117
+ });
@@ -0,0 +1,66 @@
1
+ // 防抖函数实现
2
+ function debounce(func, delay) {
3
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4
+ var timeoutId = null;
5
+ var lastExecTime = 0;
6
+ var _options$leading = options.leading,
7
+ leading = _options$leading === void 0 ? false : _options$leading,
8
+ _options$trailing = options.trailing,
9
+ trailing = _options$trailing === void 0 ? true : _options$trailing;
10
+ return function () {
11
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
12
+ args[_key] = arguments[_key];
13
+ }
14
+ var currentTime = Date.now();
15
+ if (!timeoutId && leading) {
16
+ func.apply(null, args);
17
+ lastExecTime = currentTime;
18
+ }
19
+ if (timeoutId) {
20
+ clearTimeout(timeoutId);
21
+ }
22
+ timeoutId = setTimeout(function () {
23
+ if (trailing && (!leading || currentTime - lastExecTime >= delay)) {
24
+ func.apply(null, args);
25
+ }
26
+ timeoutId = null;
27
+ }, delay);
28
+ };
29
+ }
30
+ export default (function (context) {
31
+ var _inputs$debounce;
32
+ var data = context.data;
33
+ var inputs = context.inputs;
34
+ var outputs = context.outputs;
35
+ var debouncedFn = null;
36
+ (_inputs$debounce = inputs.debounce) === null || _inputs$debounce === void 0 || _inputs$debounce.call(inputs, function (val) {
37
+ try {
38
+ var delay = (val === null || val === void 0 ? void 0 : val.delay) || data.delay || 300;
39
+ var leading = (val === null || val === void 0 ? void 0 : val.leading) !== undefined ? val.leading : data.leading || false;
40
+ var trailing = (val === null || val === void 0 ? void 0 : val.trailing) !== undefined ? val.trailing : data.trailing || true;
41
+ if (!debouncedFn) {
42
+ debouncedFn = debounce(function () {
43
+ outputs.onExecute({
44
+ delay: delay,
45
+ leading: leading,
46
+ trailing: trailing,
47
+ timestamp: Date.now()
48
+ });
49
+ }, delay, {
50
+ leading: leading,
51
+ trailing: trailing
52
+ });
53
+ }
54
+
55
+ // 执行防抖函数
56
+ debouncedFn();
57
+ outputs.onComplete({
58
+ delay: delay,
59
+ leading: leading,
60
+ trailing: trailing
61
+ });
62
+ } catch (error) {
63
+ console.error('防抖执行失败:', error);
64
+ }
65
+ });
66
+ });
@@ -0,0 +1,47 @@
1
+ export default (function (context) {
2
+ var _inputs$delay, _inputs$cancel;
3
+ var data = context.data;
4
+ var inputs = context.inputs;
5
+ var outputs = context.outputs;
6
+ var timeoutId = null;
7
+ (_inputs$delay = inputs.delay) === null || _inputs$delay === void 0 || _inputs$delay.call(inputs, function (val) {
8
+ try {
9
+ var delay = (val === null || val === void 0 ? void 0 : val.delay) || data.delay || 1000;
10
+
11
+ // 清除之前的定时器
12
+ if (timeoutId) {
13
+ clearTimeout(timeoutId);
14
+ }
15
+ outputs.onStart({
16
+ delay: delay,
17
+ timestamp: Date.now()
18
+ });
19
+ timeoutId = setTimeout(function () {
20
+ outputs.onExecute({
21
+ delay: delay,
22
+ timestamp: Date.now()
23
+ });
24
+ timeoutId = null;
25
+ }, delay);
26
+ } catch (error) {
27
+ console.error('延迟执行失败:', error);
28
+ if (timeoutId) {
29
+ clearTimeout(timeoutId);
30
+ timeoutId = null;
31
+ }
32
+ }
33
+ });
34
+ (_inputs$cancel = inputs.cancel) === null || _inputs$cancel === void 0 || _inputs$cancel.call(inputs, function () {
35
+ try {
36
+ if (timeoutId) {
37
+ clearTimeout(timeoutId);
38
+ timeoutId = null;
39
+ outputs.onCancel('延迟任务已取消');
40
+ } else {
41
+ outputs.onCancel('没有正在执行的延迟任务');
42
+ }
43
+ } catch (error) {
44
+ console.error('取消延迟失败:', error);
45
+ }
46
+ });
47
+ });
@@ -0,0 +1,69 @@
1
+ // 节流函数实现
2
+ function throttle(func, delay) {
3
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
4
+ var timeoutId = null;
5
+ var lastExecTime = 0;
6
+ var _options$leading = options.leading,
7
+ leading = _options$leading === void 0 ? true : _options$leading,
8
+ _options$trailing = options.trailing,
9
+ trailing = _options$trailing === void 0 ? true : _options$trailing;
10
+ return function () {
11
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
12
+ args[_key] = arguments[_key];
13
+ }
14
+ var currentTime = Date.now();
15
+ if (currentTime - lastExecTime > delay) {
16
+ if (leading) {
17
+ func.apply(null, args);
18
+ lastExecTime = currentTime;
19
+ }
20
+ if (timeoutId) {
21
+ clearTimeout(timeoutId);
22
+ timeoutId = null;
23
+ }
24
+ } else if (trailing && !timeoutId) {
25
+ timeoutId = setTimeout(function () {
26
+ func.apply(null, args);
27
+ lastExecTime = Date.now();
28
+ timeoutId = null;
29
+ }, delay - (currentTime - lastExecTime));
30
+ }
31
+ };
32
+ }
33
+ export default (function (context) {
34
+ var _inputs$throttle;
35
+ var data = context.data;
36
+ var inputs = context.inputs;
37
+ var outputs = context.outputs;
38
+ var throttledFn = null;
39
+ (_inputs$throttle = inputs.throttle) === null || _inputs$throttle === void 0 || _inputs$throttle.call(inputs, function (val) {
40
+ try {
41
+ var interval = (val === null || val === void 0 ? void 0 : val.interval) || data.interval || 1000;
42
+ var leading = (val === null || val === void 0 ? void 0 : val.leading) !== undefined ? val.leading : data.leading || true;
43
+ var trailing = (val === null || val === void 0 ? void 0 : val.trailing) !== undefined ? val.trailing : data.trailing || true;
44
+ if (!throttledFn) {
45
+ throttledFn = throttle(function () {
46
+ outputs.onExecute({
47
+ interval: interval,
48
+ leading: leading,
49
+ trailing: trailing,
50
+ timestamp: Date.now()
51
+ });
52
+ }, interval, {
53
+ leading: leading,
54
+ trailing: trailing
55
+ });
56
+ }
57
+
58
+ // 执行节流函数
59
+ throttledFn();
60
+ outputs.onComplete({
61
+ interval: interval,
62
+ leading: leading,
63
+ trailing: trailing
64
+ });
65
+ } catch (error) {
66
+ console.error('节流执行失败:', error);
67
+ }
68
+ });
69
+ });
@@ -0,0 +1,34 @@
1
+ import Taro from '@tarojs/taro';
2
+ export default (function (context) {
3
+ var _inputs$vibrate;
4
+ var data = context.data;
5
+ var inputs = context.inputs;
6
+ var outputs = context.outputs;
7
+ (_inputs$vibrate = inputs.vibrate) === null || _inputs$vibrate === void 0 || _inputs$vibrate.call(inputs, function (val) {
8
+ try {
9
+ var type = (val === null || val === void 0 ? void 0 : val.type) || data.type || 'short';
10
+ if (type === 'long') {
11
+ Taro.vibrateLong({
12
+ success: function success() {
13
+ return outputs.onSuccess('长振动成功');
14
+ },
15
+ fail: function fail(err) {
16
+ return outputs.onFail(err.errMsg || '长振动失败');
17
+ }
18
+ });
19
+ } else {
20
+ Taro.vibrateShort({
21
+ success: function success() {
22
+ return outputs.onSuccess('短振动成功');
23
+ },
24
+ fail: function fail(err) {
25
+ return outputs.onFail(err.errMsg || '短振动失败');
26
+ }
27
+ });
28
+ }
29
+ } catch (error) {
30
+ console.error('设备振动失败:', error);
31
+ outputs.onFail((error === null || error === void 0 ? void 0 : error.message) || '设备振动失败');
32
+ }
33
+ });
34
+ });
@@ -0,0 +1,37 @@
1
+ // 显示提示消息
2
+ export { default as mybricks_taro_showToast } from "./_ShowToast";
3
+ // 扫码
4
+ export { default as mybricks_taro_scanQrcode } from "./_ScanQrcode";
5
+ // 本地存储
6
+ export { default as mybricks_taro_setStorage } from "./_SetStorage";
7
+ export { default as mybricks_taro_getStorage } from "./_GetStorage";
8
+ export { default as mybricks_taro_removeStorage } from "./_RemoveStorage";
9
+ // 地理位置
10
+ export { default as mybricks_taro_getLocation } from "./_GetLocation";
11
+ // 设备功能
12
+ export { default as mybricks_taro_vibrate } from "./_Vibrate";
13
+ export { default as mybricks_taro_callPhone } from "./_CallPhone";
14
+ export { default as mybricks_taro_openCamera } from "./_OpenCamera";
15
+ // 系统功能
16
+ export { default as mybricks_taro_openUrl } from "./_OpenUrl";
17
+ export { default as mybricks_taro_share } from "./_Share";
18
+ export { default as mybricks_taro_getSystemInfo } from "./_GetSystemInfo";
19
+ // 数据处理
20
+ export { default as mybricks_taro_aesEncode } from "./_AesEncode";
21
+ export { default as mybricks_taro_format } from "./_Format";
22
+ // 文件和媒体
23
+ export { default as mybricks_taro_chooseFile } from "./_ChooseFile";
24
+ export { default as mybricks_taro_chooseMedia } from "./_ChooseMedia";
25
+ // 网络请求
26
+ export { default as mybricks_taro_connector } from "./_Connector";
27
+ export { default as mybricks_taro_connectorGlobalHeaders } from "./_ConnectorGlobalHeaders";
28
+ // 导航和路由
29
+ export { default as mybricks_taro_backTo } from "./_BackTo";
30
+ export { default as mybricks_taro_router } from "./_Router";
31
+ export { default as mybricks_taro_openPetalMap } from "./_OpenPetalMap";
32
+ // 语音和多媒体
33
+ export { default as mybricks_taro_textToSpeech } from "./_TextToSpeech";
34
+ // 定时器
35
+ export { default as mybricks_taro_timerDebounce } from "./_TimerDebounce";
36
+ export { default as mybricks_taro_timerDelay } from "./_TimerDelay";
37
+ export { default as mybricks_taro_timerThrottle } from "./_TimerThrottle";
@@ -5,7 +5,7 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
5
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
6
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
7
7
  var _excluded = ["root"];
8
- import { SUBJECT_NEXT, SUBJECT_VALUE, VARS_MARK, BASECONTROLLER_MARK, EXE_TITLE_MAP, CONTROLLER_CONTEXT, EXCUTE_TYPE_KEY, EXCUTE_TYPE_VALUE } from "./constant";
8
+ import { SUBJECT_NEXT, SUBJECT_VALUE, SUBJECT_SUBSCRIBE, VARS_MARK, BASECONTROLLER_MARK, EXE_TITLE_MAP, CONTROLLER_CONTEXT, EXCUTE_TYPE_KEY, EXCUTE_TYPE_VALUE } from "./constant";
9
9
  import { log } from "./log";
10
10
  import { Subject } from "./Subject";
11
11
  import { context } from "./context";
@@ -1,4 +1,5 @@
1
1
  import { createContext, useContext } from 'react';
2
+ export { pageRouter } from "./pageRouter";
2
3
  var ComContext = /*#__PURE__*/createContext(undefined);
3
4
  export function useAppContext() {
4
5
  var context = useContext(ComContext);
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { View } from '@tarojs/components';
3
+ import { useAppContext } from "./ComContext";
4
+ export var PopupRenderer = function PopupRenderer(_ref) {
5
+ var popupMap = _ref.popupMap;
6
+ var _useAppContext = useAppContext(),
7
+ popupState = _useAppContext.popupState;
8
+ var ActivePopup = popupState.visible && popupMap[popupState.name] ? popupMap[popupState.name] : null;
9
+ if (!ActivePopup) return null;
10
+ return /*#__PURE__*/React.createElement(View, {
11
+ className: "global-popup-container",
12
+ style: {
13
+ position: 'fixed',
14
+ top: 0,
15
+ left: 0,
16
+ right: 0,
17
+ bottom: 0,
18
+ zIndex: 999999,
19
+ pointerEvents: 'auto'
20
+ }
21
+ }, /*#__PURE__*/React.createElement(View, {
22
+ style: {
23
+ width: '100%',
24
+ height: '100%'
25
+ }
26
+ }, /*#__PURE__*/React.createElement(ActivePopup, null)));
27
+ };