@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
@@ -38,23 +38,22 @@ var ScanQrcode_default = (context) => {
38
38
  const data = context.data;
39
39
  const inputs = context.inputs;
40
40
  const outputs = context.outputs;
41
- (_a = inputs == null ? void 0 : inputs.scan) == null ? void 0 : _a.call(inputs, (val) => {
41
+ (_a = inputs.scan) == null ? void 0 : _a.call(inputs, (val) => {
42
42
  try {
43
- const scanType = (data == null ? void 0 : data.scanType) || ["barCode", "qrCode"];
44
- const onlyFromCamera = (data == null ? void 0 : data.onlyFromCamera) ?? false;
45
- import_taro.default.scanCode({
46
- onlyFromCamera,
47
- scanType,
43
+ const scanConfig = {
44
+ onlyFromCamera: (val == null ? void 0 : val.onlyFromCamera) ?? data.onlyFromCamera ?? false,
45
+ scanType: (val == null ? void 0 : val.scanType) ?? data.scanType ?? ["barCode", "qrCode"],
48
46
  success: (res) => {
49
- outputs == null ? void 0 : outputs.onSuccess(res.result || res);
47
+ outputs.onSuccess(res.result || res);
50
48
  },
51
49
  fail: (err) => {
52
- outputs == null ? void 0 : outputs.onFail(err.errMsg || "扫码失败");
50
+ outputs.onFail(err.errMsg || "扫码失败");
53
51
  }
54
- });
52
+ };
53
+ import_taro.default.scanCode(scanConfig);
55
54
  } catch (error) {
56
55
  console.error("扫码失败:", error);
57
- outputs == null ? void 0 : outputs.onFail((error == null ? void 0 : error.message) || "扫码失败");
56
+ outputs.onFail((error == null ? void 0 : error.message) || "扫码失败");
58
57
  }
59
58
  });
60
59
  };
@@ -40,37 +40,28 @@ var SetStorage_default = (context) => {
40
40
  const outputs = context.outputs;
41
41
  (_a = inputs.setStorage) == null ? void 0 : _a.call(inputs, (val) => {
42
42
  try {
43
- const key = (val == null ? void 0 : val.key) || (data == null ? void 0 : data.key);
44
- const value = (val == null ? void 0 : val.value) !== void 0 ? val.value : data == null ? void 0 : data.value;
45
- const useSync = (val == null ? void 0 : val.sync) !== void 0 ? val.sync : (data == null ? void 0 : data.sync) ?? false;
43
+ const key = (val == null ? void 0 : val.key) || data.key;
44
+ const value = (val == null ? void 0 : val.value) !== void 0 ? val.value : data.value;
45
+ const useSync = (val == null ? void 0 : val.sync) !== void 0 ? val.sync : data.sync || false;
46
46
  if (!key) {
47
- outputs == null ? void 0 : outputs.onFail("存储 key 不能为空");
47
+ outputs.onFail("存储 key 不能为空");
48
48
  return;
49
49
  }
50
+ const result = { key, value };
50
51
  if (useSync) {
51
- try {
52
- import_taro.default.setStorageSync(key, value);
53
- outputs == null ? void 0 : outputs.onSuccess({ key, value });
54
- } catch (error) {
55
- console.error("写入本地缓存失败:", error);
56
- outputs == null ? void 0 : outputs.onFail((error == null ? void 0 : error.message) || "写入本地缓存失败");
57
- }
52
+ import_taro.default.setStorageSync(key, value);
53
+ outputs.onSuccess(result);
58
54
  } else {
59
55
  import_taro.default.setStorage({
60
56
  key,
61
57
  data: value,
62
- success: () => {
63
- outputs == null ? void 0 : outputs.onSuccess({ key, value });
64
- },
65
- fail: (err) => {
66
- console.error("写入本地缓存失败:", err);
67
- outputs == null ? void 0 : outputs.onFail(err.errMsg || "写入本地缓存失败");
68
- }
58
+ success: () => outputs.onSuccess(result),
59
+ fail: (err) => outputs.onFail(err.errMsg || "写入本地缓存失败")
69
60
  });
70
61
  }
71
62
  } catch (error) {
72
63
  console.error("写入本地缓存失败:", error);
73
- outputs == null ? void 0 : outputs.onFail((error == null ? void 0 : error.message) || "写入本地缓存失败");
64
+ outputs.onFail((error == null ? void 0 : error.message) || "写入本地缓存失败");
74
65
  }
75
66
  });
76
67
  };
@@ -0,0 +1,58 @@
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/comlib/_Share.ts
30
+ var Share_exports = {};
31
+ __export(Share_exports, {
32
+ default: () => Share_default
33
+ });
34
+ module.exports = __toCommonJS(Share_exports);
35
+ var import_taro = __toESM(require("@tarojs/taro"));
36
+ var Share_default = (context) => {
37
+ var _a;
38
+ const data = context.data;
39
+ const inputs = context.inputs;
40
+ const outputs = context.outputs;
41
+ (_a = inputs.share) == null ? void 0 : _a.call(inputs, (val) => {
42
+ try {
43
+ const shareData = {
44
+ title: (val == null ? void 0 : val.title) || data.title || "分享",
45
+ path: (val == null ? void 0 : val.path) || data.path || "/pages/index/index",
46
+ imageUrl: (val == null ? void 0 : val.imageUrl) || data.imageUrl
47
+ };
48
+ import_taro.default.showShareMenu({
49
+ withShareTicket: true,
50
+ success: () => outputs.onSuccess(shareData),
51
+ fail: (err) => outputs.onFail(err.errMsg || "分享失败")
52
+ });
53
+ } catch (error) {
54
+ console.error("分享失败:", error);
55
+ outputs.onFail((error == null ? void 0 : error.message) || "分享失败");
56
+ }
57
+ });
58
+ };
@@ -39,58 +39,31 @@ var ShowToast_default = (context) => {
39
39
  const inputs = context.inputs;
40
40
  const outputs = context.outputs;
41
41
  (_a = inputs.showToast) == null ? void 0 : _a.call(inputs, (val) => {
42
- if (data == null ? void 0 : data.dynamic) {
43
- try {
44
- const toastConfig = {
45
- title: typeof val === "string" ? val : (val == null ? void 0 : val.title) || data.title || "",
46
- duration: Number(val && typeof val === "object" ? (val == null ? void 0 : val.duration) ?? data.duration ?? 1e3 : data.duration ?? 1e3),
47
- mask: val && typeof val === "object" ? (val == null ? void 0 : val.mask) ?? data.mask ?? false : data.mask ?? false
48
- };
49
- if (val && typeof val === "object" && val.icon) {
50
- toastConfig.icon = val.icon;
51
- } else if (data.icon) {
52
- toastConfig.icon = data.icon;
53
- }
54
- if (val && typeof val === "object" && val.image) {
55
- toastConfig.image = val.image;
56
- } else if (data.image) {
57
- toastConfig.image = data.image;
58
- }
59
- import_taro.default.showToast(toastConfig);
60
- if (data.asynchronous) {
61
- setTimeout(() => {
62
- outputs.afterShowToast(val);
63
- }, Number(val && typeof val === "object" ? (val == null ? void 0 : val.duration) ?? data.duration ?? 1e3 : data.duration ?? 1e3));
64
- } else {
65
- outputs.afterShowToast(val);
66
- }
67
- } catch (error) {
68
- console.error("显示 Toast 失败:", error);
42
+ try {
43
+ const toastConfig = {
44
+ title: typeof val === "string" ? val : (val == null ? void 0 : val.title) || data.title || "",
45
+ duration: Number(typeof val === "object" && (val == null ? void 0 : val.duration) ? val.duration : data.duration || 1e3),
46
+ mask: typeof val === "object" && (val == null ? void 0 : val.mask) !== void 0 ? val.mask : data.mask || false
47
+ };
48
+ if (typeof val === "object" && (val == null ? void 0 : val.icon)) {
49
+ toastConfig.icon = val.icon;
50
+ } else if (data.icon) {
51
+ toastConfig.icon = data.icon;
69
52
  }
70
- } else {
71
- try {
72
- const toastConfig = {
73
- title: data.title || "",
74
- duration: Number(data.duration || 1e3),
75
- mask: data.mask ?? false
76
- };
77
- if (data.icon) {
78
- toastConfig.icon = data.icon;
79
- }
80
- if (data.image) {
81
- toastConfig.image = data.image;
82
- }
83
- import_taro.default.showToast(toastConfig);
84
- if (data.asynchronous) {
85
- setTimeout(() => {
86
- outputs.afterShowToast(val);
87
- }, Number(data.duration || 1e3));
88
- } else {
89
- outputs.afterShowToast(val);
90
- }
91
- } catch (error) {
92
- console.error("显示 Toast 失败:", error);
53
+ if (typeof val === "object" && (val == null ? void 0 : val.image)) {
54
+ toastConfig.image = val.image;
55
+ } else if (data.image) {
56
+ toastConfig.image = data.image;
93
57
  }
58
+ import_taro.default.showToast(toastConfig);
59
+ const triggerOutput = () => outputs.afterShowToast(val);
60
+ if (data.asynchronous) {
61
+ setTimeout(triggerOutput, toastConfig.duration);
62
+ } else {
63
+ triggerOutput();
64
+ }
65
+ } catch (error) {
66
+ console.error("显示 Toast 失败:", error);
94
67
  }
95
68
  });
96
69
  };
@@ -0,0 +1,120 @@
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/comlib/_TextToSpeech.ts
20
+ var TextToSpeech_exports = {};
21
+ __export(TextToSpeech_exports, {
22
+ default: () => TextToSpeech_default
23
+ });
24
+ module.exports = __toCommonJS(TextToSpeech_exports);
25
+ var speechSupported = typeof window !== "undefined" && "speechSynthesis" in window;
26
+ var currentUtterance = null;
27
+ var TextToSpeech_default = (context) => {
28
+ var _a, _b, _c, _d;
29
+ const data = context.data;
30
+ const inputs = context.inputs;
31
+ const outputs = context.outputs;
32
+ if (!speechSupported) {
33
+ console.warn("当前环境不支持语音合成功能");
34
+ }
35
+ (_a = inputs.speak) == null ? void 0 : _a.call(inputs, (val) => {
36
+ try {
37
+ const text = (val == null ? void 0 : val.text) || data.text;
38
+ const lang = (val == null ? void 0 : val.lang) || data.lang || "zh-CN";
39
+ const rate = (val == null ? void 0 : val.rate) || data.rate || 1;
40
+ const pitch = (val == null ? void 0 : val.pitch) || data.pitch || 1;
41
+ const volume = (val == null ? void 0 : val.volume) || data.volume || 1;
42
+ if (!text) {
43
+ outputs.onFail("待合成的文本不能为空");
44
+ return;
45
+ }
46
+ if (!speechSupported) {
47
+ outputs.onFail("当前环境不支持语音合成功能");
48
+ return;
49
+ }
50
+ if (currentUtterance && window.speechSynthesis.speaking) {
51
+ window.speechSynthesis.cancel();
52
+ }
53
+ currentUtterance = new SpeechSynthesisUtterance(text);
54
+ currentUtterance.lang = lang;
55
+ currentUtterance.rate = Math.max(0.1, Math.min(10, rate));
56
+ currentUtterance.pitch = Math.max(0, Math.min(2, pitch));
57
+ currentUtterance.volume = Math.max(0, Math.min(1, volume));
58
+ currentUtterance.onstart = () => {
59
+ outputs.onStart({ text, lang, rate, pitch, volume });
60
+ };
61
+ currentUtterance.onend = () => {
62
+ outputs.onEnd({ text, lang, rate, pitch, volume });
63
+ currentUtterance = null;
64
+ };
65
+ currentUtterance.onerror = (event) => {
66
+ outputs.onError({
67
+ error: event.error,
68
+ text,
69
+ message: "语音合成失败"
70
+ });
71
+ currentUtterance = null;
72
+ };
73
+ window.speechSynthesis.speak(currentUtterance);
74
+ outputs.onSuccess({ text, lang, rate, pitch, volume });
75
+ } catch (error) {
76
+ console.error("语音合成失败:", error);
77
+ outputs.onFail((error == null ? void 0 : error.message) || "语音合成失败");
78
+ }
79
+ });
80
+ (_b = inputs.stop) == null ? void 0 : _b.call(inputs, () => {
81
+ try {
82
+ if (speechSupported && currentUtterance) {
83
+ window.speechSynthesis.cancel();
84
+ currentUtterance = null;
85
+ outputs.onSuccess("已停止语音播放");
86
+ } else {
87
+ outputs.onFail("没有正在播放的语音");
88
+ }
89
+ } catch (error) {
90
+ console.error("停止语音失败:", error);
91
+ outputs.onFail((error == null ? void 0 : error.message) || "停止语音失败");
92
+ }
93
+ });
94
+ (_c = inputs.pause) == null ? void 0 : _c.call(inputs, () => {
95
+ try {
96
+ if (speechSupported && window.speechSynthesis.pause) {
97
+ window.speechSynthesis.pause();
98
+ outputs.onSuccess("已暂停语音播放");
99
+ } else {
100
+ outputs.onFail("当前环境不支持暂停功能");
101
+ }
102
+ } catch (error) {
103
+ console.error("暂停语音失败:", error);
104
+ outputs.onFail((error == null ? void 0 : error.message) || "暂停语音失败");
105
+ }
106
+ });
107
+ (_d = inputs.resume) == null ? void 0 : _d.call(inputs, () => {
108
+ try {
109
+ if (speechSupported && window.speechSynthesis.resume) {
110
+ window.speechSynthesis.resume();
111
+ outputs.onSuccess("已恢复语音播放");
112
+ } else {
113
+ outputs.onFail("当前环境不支持恢复功能");
114
+ }
115
+ } catch (error) {
116
+ console.error("恢复语音失败:", error);
117
+ outputs.onFail((error == null ? void 0 : error.message) || "恢复语音失败");
118
+ }
119
+ });
120
+ };
@@ -0,0 +1,72 @@
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/comlib/_TimerDebounce.ts
20
+ var TimerDebounce_exports = {};
21
+ __export(TimerDebounce_exports, {
22
+ default: () => TimerDebounce_default
23
+ });
24
+ module.exports = __toCommonJS(TimerDebounce_exports);
25
+ function debounce(func, delay, options = {}) {
26
+ let timeoutId = null;
27
+ let lastExecTime = 0;
28
+ const { leading = false, trailing = true } = options;
29
+ return function(...args) {
30
+ const currentTime = Date.now();
31
+ if (!timeoutId && leading) {
32
+ func.apply(null, args);
33
+ lastExecTime = currentTime;
34
+ }
35
+ if (timeoutId) {
36
+ clearTimeout(timeoutId);
37
+ }
38
+ timeoutId = setTimeout(() => {
39
+ if (trailing && (!leading || currentTime - lastExecTime >= delay)) {
40
+ func.apply(null, args);
41
+ }
42
+ timeoutId = null;
43
+ }, delay);
44
+ };
45
+ }
46
+ var TimerDebounce_default = (context) => {
47
+ var _a;
48
+ const data = context.data;
49
+ const inputs = context.inputs;
50
+ const outputs = context.outputs;
51
+ let debouncedFn = null;
52
+ (_a = inputs.debounce) == null ? void 0 : _a.call(inputs, (val) => {
53
+ try {
54
+ const delay = (val == null ? void 0 : val.delay) || data.delay || 300;
55
+ const leading = (val == null ? void 0 : val.leading) !== void 0 ? val.leading : data.leading || false;
56
+ const trailing = (val == null ? void 0 : val.trailing) !== void 0 ? val.trailing : data.trailing || true;
57
+ if (!debouncedFn) {
58
+ debouncedFn = debounce(
59
+ () => {
60
+ outputs.onExecute({ delay, leading, trailing, timestamp: Date.now() });
61
+ },
62
+ delay,
63
+ { leading, trailing }
64
+ );
65
+ }
66
+ debouncedFn();
67
+ outputs.onComplete({ delay, leading, trailing });
68
+ } catch (error) {
69
+ console.error("防抖执行失败:", error);
70
+ }
71
+ });
72
+ };
@@ -0,0 +1,63 @@
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/comlib/_TimerDelay.ts
20
+ var TimerDelay_exports = {};
21
+ __export(TimerDelay_exports, {
22
+ default: () => TimerDelay_default
23
+ });
24
+ module.exports = __toCommonJS(TimerDelay_exports);
25
+ var TimerDelay_default = (context) => {
26
+ var _a, _b;
27
+ const data = context.data;
28
+ const inputs = context.inputs;
29
+ const outputs = context.outputs;
30
+ let timeoutId = null;
31
+ (_a = inputs.delay) == null ? void 0 : _a.call(inputs, (val) => {
32
+ try {
33
+ const delay = (val == null ? void 0 : val.delay) || data.delay || 1e3;
34
+ if (timeoutId) {
35
+ clearTimeout(timeoutId);
36
+ }
37
+ outputs.onStart({ delay, timestamp: Date.now() });
38
+ timeoutId = setTimeout(() => {
39
+ outputs.onExecute({ delay, timestamp: Date.now() });
40
+ timeoutId = null;
41
+ }, delay);
42
+ } catch (error) {
43
+ console.error("延迟执行失败:", error);
44
+ if (timeoutId) {
45
+ clearTimeout(timeoutId);
46
+ timeoutId = null;
47
+ }
48
+ }
49
+ });
50
+ (_b = inputs.cancel) == null ? void 0 : _b.call(inputs, () => {
51
+ try {
52
+ if (timeoutId) {
53
+ clearTimeout(timeoutId);
54
+ timeoutId = null;
55
+ outputs.onCancel("延迟任务已取消");
56
+ } else {
57
+ outputs.onCancel("没有正在执行的延迟任务");
58
+ }
59
+ } catch (error) {
60
+ console.error("取消延迟失败:", error);
61
+ }
62
+ });
63
+ };
@@ -0,0 +1,75 @@
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/comlib/_TimerThrottle.ts
20
+ var TimerThrottle_exports = {};
21
+ __export(TimerThrottle_exports, {
22
+ default: () => TimerThrottle_default
23
+ });
24
+ module.exports = __toCommonJS(TimerThrottle_exports);
25
+ function throttle(func, delay, options = {}) {
26
+ let timeoutId = null;
27
+ let lastExecTime = 0;
28
+ const { leading = true, trailing = true } = options;
29
+ return function(...args) {
30
+ const currentTime = Date.now();
31
+ if (currentTime - lastExecTime > delay) {
32
+ if (leading) {
33
+ func.apply(null, args);
34
+ lastExecTime = currentTime;
35
+ }
36
+ if (timeoutId) {
37
+ clearTimeout(timeoutId);
38
+ timeoutId = null;
39
+ }
40
+ } else if (trailing && !timeoutId) {
41
+ timeoutId = setTimeout(() => {
42
+ func.apply(null, args);
43
+ lastExecTime = Date.now();
44
+ timeoutId = null;
45
+ }, delay - (currentTime - lastExecTime));
46
+ }
47
+ };
48
+ }
49
+ var TimerThrottle_default = (context) => {
50
+ var _a;
51
+ const data = context.data;
52
+ const inputs = context.inputs;
53
+ const outputs = context.outputs;
54
+ let throttledFn = null;
55
+ (_a = inputs.throttle) == null ? void 0 : _a.call(inputs, (val) => {
56
+ try {
57
+ const interval = (val == null ? void 0 : val.interval) || data.interval || 1e3;
58
+ const leading = (val == null ? void 0 : val.leading) !== void 0 ? val.leading : data.leading || true;
59
+ const trailing = (val == null ? void 0 : val.trailing) !== void 0 ? val.trailing : data.trailing || true;
60
+ if (!throttledFn) {
61
+ throttledFn = throttle(
62
+ () => {
63
+ outputs.onExecute({ interval, leading, trailing, timestamp: Date.now() });
64
+ },
65
+ interval,
66
+ { leading, trailing }
67
+ );
68
+ }
69
+ throttledFn();
70
+ outputs.onComplete({ interval, leading, trailing });
71
+ } catch (error) {
72
+ console.error("节流执行失败:", error);
73
+ }
74
+ });
75
+ };
@@ -0,0 +1,60 @@
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/comlib/_Vibrate.ts
30
+ var Vibrate_exports = {};
31
+ __export(Vibrate_exports, {
32
+ default: () => Vibrate_default
33
+ });
34
+ module.exports = __toCommonJS(Vibrate_exports);
35
+ var import_taro = __toESM(require("@tarojs/taro"));
36
+ var Vibrate_default = (context) => {
37
+ var _a;
38
+ const data = context.data;
39
+ const inputs = context.inputs;
40
+ const outputs = context.outputs;
41
+ (_a = inputs.vibrate) == null ? void 0 : _a.call(inputs, (val) => {
42
+ try {
43
+ const type = (val == null ? void 0 : val.type) || data.type || "short";
44
+ if (type === "long") {
45
+ import_taro.default.vibrateLong({
46
+ success: () => outputs.onSuccess("长振动成功"),
47
+ fail: (err) => outputs.onFail(err.errMsg || "长振动失败")
48
+ });
49
+ } else {
50
+ import_taro.default.vibrateShort({
51
+ success: () => outputs.onSuccess("短振动成功"),
52
+ fail: (err) => outputs.onFail(err.errMsg || "短振动失败")
53
+ });
54
+ }
55
+ } catch (error) {
56
+ console.error("设备振动失败:", error);
57
+ outputs.onFail((error == null ? void 0 : error.message) || "设备振动失败");
58
+ }
59
+ });
60
+ };