@mybricks/to-code-taro 1.1.5 → 1.1.7

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 (126) hide show
  1. package/dist/cjs/core/mybricks/Subject.js +9 -5
  2. package/dist/cjs/core/mybricks/createJSHandle.js +43 -3
  3. package/dist/cjs/core/utils/comRefResolver.js +112 -0
  4. package/dist/cjs/core/utils/event.js +53 -0
  5. package/dist/cjs/core/utils/hooks.js +71 -29
  6. package/dist/cjs/core/utils/index.js +3 -0
  7. package/dist/cjs/core/utils/pageRouter.js +34 -11
  8. package/dist/cjs/core/utils/slots.js +55 -9
  9. package/dist/cjs/core/utils/tabbar.js +56 -0
  10. package/dist/cjs/core/utils/useContext.js +42 -2
  11. package/dist/cjs/core/utils/with.js +9 -34
  12. package/dist/cjs/generate/generateTaroProjectJson.js +3 -18
  13. package/dist/cjs/generate/utils/appConfig.d.ts +1 -1
  14. package/dist/cjs/generate/utils/appConfig.js +22 -12
  15. package/dist/cjs/generate/utils/commonDir.js +9 -0
  16. package/dist/cjs/generate/utils/customTabBar.d.ts +11 -0
  17. package/dist/cjs/generate/utils/customTabBar.js +73 -0
  18. package/dist/cjs/generate/utils/fileNode.d.ts +4 -0
  19. package/dist/cjs/generate/utils/fileNode.js +12 -2
  20. package/dist/cjs/handleCom.js +15 -16
  21. package/dist/cjs/handleGlobal.d.ts +1 -1
  22. package/dist/cjs/handleGlobal.js +6 -0
  23. package/dist/cjs/handleSlot.js +5 -10
  24. package/dist/cjs/processors/processScene.js +13 -1
  25. package/dist/cjs/processors/processSceneLogic.js +2 -6
  26. package/dist/cjs/taro-template.json +364 -66
  27. package/dist/cjs/toCodeTaro.d.ts +1 -2
  28. package/dist/cjs/utils/builder/buildResult.js +1 -2
  29. package/dist/cjs/utils/common/ImportManager.d.ts +7 -0
  30. package/dist/cjs/utils/common/ImportManager.js +19 -1
  31. package/dist/cjs/utils/logic/genJSModules.js +2 -2
  32. package/dist/cjs/utils/logic/handleProcess.js +59 -13
  33. package/dist/cjs/utils/templates/index.js +1 -1
  34. package/dist/cjs/utils/templates/renderManager.js +5 -5
  35. package/dist/cjs/utils/templates/scene.js +4 -4
  36. package/dist/esm/core/mybricks/Subject.js +11 -5
  37. package/dist/esm/core/mybricks/createJSHandle.js +55 -5
  38. package/dist/esm/core/utils/comRefResolver.js +134 -0
  39. package/dist/esm/core/utils/event.js +32 -0
  40. package/dist/esm/core/utils/hooks.js +109 -39
  41. package/dist/esm/core/utils/index.js +1 -0
  42. package/dist/esm/core/utils/pageRouter.js +56 -13
  43. package/dist/esm/core/utils/slots.js +78 -12
  44. package/dist/esm/core/utils/tabbar.js +47 -0
  45. package/dist/esm/core/utils/useContext.js +42 -2
  46. package/dist/esm/core/utils/with.js +19 -53
  47. package/dist/esm/generate/generateTaroProjectJson.js +2 -20
  48. package/dist/esm/generate/utils/appConfig.d.ts +1 -1
  49. package/dist/esm/generate/utils/appConfig.js +28 -9
  50. package/dist/esm/generate/utils/commonDir.js +13 -0
  51. package/dist/esm/generate/utils/customTabBar.d.ts +11 -0
  52. package/dist/esm/generate/utils/customTabBar.js +52 -0
  53. package/dist/esm/generate/utils/fileNode.d.ts +4 -0
  54. package/dist/esm/generate/utils/fileNode.js +13 -0
  55. package/dist/esm/handleCom.js +24 -21
  56. package/dist/esm/handleGlobal.d.ts +1 -1
  57. package/dist/esm/handleGlobal.js +6 -1
  58. package/dist/esm/handleSlot.js +7 -12
  59. package/dist/esm/processors/processScene.js +23 -3
  60. package/dist/esm/processors/processSceneLogic.js +3 -5
  61. package/dist/esm/taro-template.json +364 -66
  62. package/dist/esm/toCodeTaro.d.ts +1 -2
  63. package/dist/esm/toCodeTaro.js +1 -1
  64. package/dist/esm/utils/builder/buildResult.js +1 -2
  65. package/dist/esm/utils/common/ImportManager.d.ts +7 -0
  66. package/dist/esm/utils/common/ImportManager.js +42 -14
  67. package/dist/esm/utils/logic/genJSModules.js +2 -2
  68. package/dist/esm/utils/logic/handleProcess.js +73 -12
  69. package/dist/esm/utils/templates/index.js +1 -1
  70. package/dist/esm/utils/templates/renderManager.js +4 -7
  71. package/dist/esm/utils/templates/scene.js +2 -2
  72. package/package.json +1 -1
  73. package/dist/cjs/core/comlib/Index.js +0 -114
  74. package/dist/cjs/core/comlib/_AesEncode.js +0 -115
  75. package/dist/cjs/core/comlib/_BackTo.js +0 -80
  76. package/dist/cjs/core/comlib/_CallPhone.js +0 -58
  77. package/dist/cjs/core/comlib/_ChooseFile.js +0 -103
  78. package/dist/cjs/core/comlib/_ChooseMedia.js +0 -70
  79. package/dist/cjs/core/comlib/_Connector.js +0 -79
  80. package/dist/cjs/core/comlib/_ConnectorGlobalHeaders.js +0 -79
  81. package/dist/cjs/core/comlib/_Format.js +0 -123
  82. package/dist/cjs/core/comlib/_GetLocation.js +0 -60
  83. package/dist/cjs/core/comlib/_GetStorage.js +0 -68
  84. package/dist/cjs/core/comlib/_GetSystemInfo.js +0 -62
  85. package/dist/cjs/core/comlib/_Modal.js +0 -68
  86. package/dist/cjs/core/comlib/_OpenCamera.js +0 -73
  87. package/dist/cjs/core/comlib/_OpenPetalMap.js +0 -49
  88. package/dist/cjs/core/comlib/_OpenUrl.js +0 -62
  89. package/dist/cjs/core/comlib/_RemoveStorage.js +0 -68
  90. package/dist/cjs/core/comlib/_Router.js +0 -100
  91. package/dist/cjs/core/comlib/_ScanQrcode.js +0 -59
  92. package/dist/cjs/core/comlib/_SetStorage.js +0 -67
  93. package/dist/cjs/core/comlib/_Share.js +0 -58
  94. package/dist/cjs/core/comlib/_ShowToast.js +0 -69
  95. package/dist/cjs/core/comlib/_TextToSpeech.js +0 -120
  96. package/dist/cjs/core/comlib/_TimerDebounce.js +0 -72
  97. package/dist/cjs/core/comlib/_TimerDelay.js +0 -88
  98. package/dist/cjs/core/comlib/_TimerThrottle.js +0 -75
  99. package/dist/cjs/core/comlib/_Vibrate.js +0 -60
  100. package/dist/esm/core/comlib/Index.js +0 -39
  101. package/dist/esm/core/comlib/_AesEncode.js +0 -85
  102. package/dist/esm/core/comlib/_BackTo.js +0 -66
  103. package/dist/esm/core/comlib/_CallPhone.js +0 -30
  104. package/dist/esm/core/comlib/_ChooseFile.js +0 -81
  105. package/dist/esm/core/comlib/_ChooseMedia.js +0 -38
  106. package/dist/esm/core/comlib/_Connector.js +0 -77
  107. package/dist/esm/core/comlib/_ConnectorGlobalHeaders.js +0 -56
  108. package/dist/esm/core/comlib/_Format.js +0 -102
  109. package/dist/esm/core/comlib/_GetLocation.js +0 -26
  110. package/dist/esm/core/comlib/_GetStorage.js +0 -44
  111. package/dist/esm/core/comlib/_GetSystemInfo.js +0 -32
  112. package/dist/esm/core/comlib/_Modal.js +0 -51
  113. package/dist/esm/core/comlib/_OpenCamera.js +0 -44
  114. package/dist/esm/core/comlib/_OpenPetalMap.js +0 -28
  115. package/dist/esm/core/comlib/_OpenUrl.js +0 -36
  116. package/dist/esm/core/comlib/_RemoveStorage.js +0 -42
  117. package/dist/esm/core/comlib/_Router.js +0 -113
  118. package/dist/esm/core/comlib/_ScanQrcode.js +0 -26
  119. package/dist/esm/core/comlib/_SetStorage.js +0 -40
  120. package/dist/esm/core/comlib/_Share.js +0 -28
  121. package/dist/esm/core/comlib/_ShowToast.js +0 -45
  122. package/dist/esm/core/comlib/_TextToSpeech.js +0 -117
  123. package/dist/esm/core/comlib/_TimerDebounce.js +0 -66
  124. package/dist/esm/core/comlib/_TimerDelay.js +0 -79
  125. package/dist/esm/core/comlib/_TimerThrottle.js +0 -69
  126. package/dist/esm/core/comlib/_Vibrate.js +0 -34
@@ -1,67 +0,0 @@
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/_SetStorage.ts
30
- var SetStorage_exports = {};
31
- __export(SetStorage_exports, {
32
- default: () => SetStorage_default
33
- });
34
- module.exports = __toCommonJS(SetStorage_exports);
35
- var import_taro = __toESM(require("@tarojs/taro"));
36
- var SetStorage_default = (context) => {
37
- var _a;
38
- const data = context.data;
39
- const inputs = context.inputs;
40
- const outputs = context.outputs;
41
- (_a = inputs.setStorage) == null ? void 0 : _a.call(inputs, (val) => {
42
- try {
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
- if (!key) {
47
- outputs.onFail("存储 key 不能为空");
48
- return;
49
- }
50
- const result = { key, value };
51
- if (useSync) {
52
- import_taro.default.setStorageSync(key, value);
53
- outputs.onSuccess(result);
54
- } else {
55
- import_taro.default.setStorage({
56
- key,
57
- data: value,
58
- success: () => outputs.onSuccess(result),
59
- fail: (err) => outputs.onFail(err.errMsg || "写入本地缓存失败")
60
- });
61
- }
62
- } catch (error) {
63
- console.error("写入本地缓存失败:", error);
64
- outputs.onFail((error == null ? void 0 : error.message) || "写入本地缓存失败");
65
- }
66
- });
67
- };
@@ -1,58 +0,0 @@
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
- };
@@ -1,69 +0,0 @@
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/_ShowToast.ts
30
- var ShowToast_exports = {};
31
- __export(ShowToast_exports, {
32
- default: () => ShowToast_default
33
- });
34
- module.exports = __toCommonJS(ShowToast_exports);
35
- var import_taro = __toESM(require("@tarojs/taro"));
36
- var ShowToast_default = (context) => {
37
- var _a;
38
- const data = context.data;
39
- const inputs = context.inputs;
40
- const outputs = context.outputs;
41
- (_a = inputs.showToast) == null ? void 0 : _a.call(inputs, (val) => {
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;
52
- }
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;
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);
67
- }
68
- });
69
- };
@@ -1,120 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/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
- };
@@ -1,72 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/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
- };
@@ -1,88 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/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, _c;
27
- const data = context.data;
28
- const inputs = context.inputs;
29
- const outputs = context.outputs;
30
- let timeoutId = null;
31
- const inputPins = new Set(Object.keys(inputs));
32
- const outputPins = new Set(Object.keys(outputs));
33
- const hasIn = (pin) => inputPins.has(pin);
34
- const hasOut = (pin) => outputPins.has(pin);
35
- const clear = () => {
36
- if (timeoutId) {
37
- clearTimeout(timeoutId);
38
- timeoutId = null;
39
- }
40
- };
41
- if (hasIn("trigger"))
42
- (_a = inputs.trigger) == null ? void 0 : _a.call(inputs, (payload) => {
43
- var _a2;
44
- try {
45
- const delay = (payload == null ? void 0 : payload.delay) || data.delay || 1e3;
46
- clear();
47
- (_a2 = outputs.onStart) == null ? void 0 : _a2.call(outputs, { delay, timestamp: Date.now() });
48
- timeoutId = setTimeout(() => {
49
- var _a3, _b2;
50
- if (hasOut("trigger"))
51
- (_a3 = outputs.trigger) == null ? void 0 : _a3.call(outputs, payload);
52
- (_b2 = outputs.onExecute) == null ? void 0 : _b2.call(outputs, { delay, timestamp: Date.now() });
53
- timeoutId = null;
54
- }, delay);
55
- } catch (error) {
56
- console.error("延迟执行失败:", error);
57
- clear();
58
- }
59
- });
60
- if (hasIn("delay"))
61
- (_b = inputs.delay) == null ? void 0 : _b.call(inputs, (val) => {
62
- try {
63
- const delay = (val == null ? void 0 : val.delay) || data.delay || 1e3;
64
- clear();
65
- outputs.onStart({ delay, timestamp: Date.now() });
66
- timeoutId = setTimeout(() => {
67
- outputs.onExecute({ delay, timestamp: Date.now() });
68
- timeoutId = null;
69
- }, delay);
70
- } catch (error) {
71
- console.error("延迟执行失败:", error);
72
- clear();
73
- }
74
- });
75
- if (hasIn("cancel"))
76
- (_c = inputs.cancel) == null ? void 0 : _c.call(inputs, () => {
77
- try {
78
- if (timeoutId) {
79
- clear();
80
- outputs.onCancel("延迟任务已取消");
81
- } else {
82
- outputs.onCancel("没有正在执行的延迟任务");
83
- }
84
- } catch (error) {
85
- console.error("取消延迟失败:", error);
86
- }
87
- });
88
- };
@@ -1,75 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/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
- };
@@ -1,60 +0,0 @@
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
- };
@@ -1,39 +0,0 @@
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
- // 模态对话框
22
- export { default as mybricks_taro_modal } from "./_Modal";
23
- export { default as mybricks_taro_format } from "./_Format";
24
- // 文件和媒体
25
- export { default as mybricks_taro_chooseFile } from "./_ChooseFile";
26
- export { default as mybricks_taro_chooseMedia } from "./_ChooseMedia";
27
- // 网络请求
28
- export { default as mybricks_taro_connector } from "./_Connector";
29
- export { default as mybricks_taro_connectorGlobalHeaders } from "./_ConnectorGlobalHeaders";
30
- // 导航和路由
31
- export { default as mybricks_taro_navigateBack } from "./_BackTo";
32
- export { default as mybricks_taro_router } from "./_Router";
33
- export { default as mybricks_taro_openPetalMap } from "./_OpenPetalMap";
34
- // 语音和多媒体
35
- export { default as mybricks_taro_textToSpeech } from "./_TextToSpeech";
36
- // 定时器
37
- export { default as mybricks_taro_timerDebounce } from "./_TimerDebounce";
38
- export { default as mybricks_taro_timerDelay } from "./_TimerDelay";
39
- export { default as mybricks_taro_timerThrottle } from "./_TimerThrottle";