@mybricks/to-code-taro 1.0.8 → 1.1.0

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 (120) hide show
  1. package/dist/cjs/core/comlib/_Modal.js +68 -0
  2. package/dist/cjs/core/comlib/_TimerDelay.js +55 -30
  3. package/dist/cjs/core/comlib/index.js +3 -0
  4. package/dist/cjs/core/mybricks/log.js +0 -1
  5. package/dist/cjs/core/utils/hooks.js +3 -2
  6. package/dist/cjs/core/utils/slots.js +11 -5
  7. package/dist/cjs/core/utils/useContext.js +5 -3
  8. package/dist/cjs/core/utils/with.js +5 -6
  9. package/dist/cjs/generate/generateTaroProjectJson.js +18 -1
  10. package/dist/cjs/handleCom.js +47 -73
  11. package/dist/cjs/handleSlot.js +5 -3
  12. package/dist/cjs/processors/processComEvents.js +2 -3
  13. package/dist/cjs/processors/processModule.js +23 -0
  14. package/dist/cjs/processors/processScene.js +23 -0
  15. package/dist/cjs/processors/processSceneLogic.d.ts +4 -1
  16. package/dist/cjs/processors/processSceneLogic.js +72 -12
  17. package/dist/cjs/taro-template.json +68 -42
  18. package/dist/cjs/toCodeTaro.d.ts +14 -1
  19. package/dist/cjs/toCodeTaro.js +1 -0
  20. package/dist/cjs/utils/builder/buildResult.d.ts +1 -0
  21. package/dist/cjs/utils/builder/buildResult.js +8 -1
  22. package/dist/cjs/utils/common/helper.d.ts +10 -0
  23. package/dist/cjs/utils/common/helper.js +21 -0
  24. package/dist/cjs/utils/common/string.d.ts +10 -0
  25. package/dist/cjs/utils/common/string.js +13 -0
  26. package/dist/cjs/utils/config/content/converter.js +1 -0
  27. package/dist/cjs/utils/config/content/tabBarConfig.d.ts +19 -4
  28. package/dist/cjs/utils/config/content/tabBarConfig.js +18 -1
  29. package/dist/cjs/utils/config/content/types.d.ts +15 -10
  30. package/dist/cjs/utils/config/handlePageConfig.d.ts +6 -0
  31. package/dist/cjs/utils/config/handlePageConfig.js +13 -1
  32. package/dist/cjs/utils/logic/handleProcess.js +50 -33
  33. package/dist/cjs/utils/style/converter.js +1 -6
  34. package/dist/cjs/utils/templates/index.d.ts +1 -0
  35. package/dist/cjs/utils/templates/index.js +11 -4
  36. package/dist/cjs/utils/templates/renderManager.js +4 -2
  37. package/dist/cjs/utils/templates/scene.d.ts +2 -1
  38. package/dist/cjs/utils/templates/scene.js +4 -3
  39. package/dist/esm/abstractEventTypeDef.d.ts.map +1 -0
  40. package/dist/esm/core/comlib/_Modal.js +51 -0
  41. package/dist/esm/core/comlib/_TimerDelay.js +46 -14
  42. package/dist/esm/core/comlib/index.js +2 -0
  43. package/dist/esm/core/mybricks/log.js +1 -5
  44. package/dist/esm/core/utils/hooks.js +7 -2
  45. package/dist/esm/core/utils/slots.js +28 -10
  46. package/dist/esm/core/utils/useContext.js +9 -3
  47. package/dist/esm/core/utils/with.js +5 -9
  48. package/dist/esm/generate/generateTaroProjectJson.d.ts.map +1 -0
  49. package/dist/esm/generate/generateTaroProjectJson.js +22 -0
  50. package/dist/esm/generate/generateTaroTempalteJson.d.ts.map +1 -0
  51. package/dist/esm/generate/utils/appConfig.d.ts.map +1 -0
  52. package/dist/esm/generate/utils/commonDir.d.ts.map +1 -0
  53. package/dist/esm/generate/utils/fileNode.d.ts.map +1 -0
  54. package/dist/esm/generate/utils/index.d.ts.map +1 -0
  55. package/dist/esm/generate/utils/tabBarImages.d.ts.map +1 -0
  56. package/dist/esm/handleCom.js +60 -95
  57. package/dist/esm/handleDom.d.ts.map +1 -0
  58. package/dist/esm/handleExtension.d.ts.map +1 -0
  59. package/dist/esm/handleGlobal.d.ts.map +1 -0
  60. package/dist/esm/handleModule.d.ts.map +1 -0
  61. package/dist/esm/handleSlot.js +9 -4
  62. package/dist/esm/index.d.ts.map +1 -0
  63. package/dist/esm/processors/processComEvents.js +6 -3
  64. package/dist/esm/processors/processModule.d.ts.map +1 -0
  65. package/dist/esm/processors/processModule.js +35 -0
  66. package/dist/esm/processors/processScene.d.ts.map +1 -0
  67. package/dist/esm/processors/processScene.js +35 -0
  68. package/dist/esm/processors/processSceneLogic.d.ts +4 -1
  69. package/dist/esm/processors/processSceneLogic.js +90 -15
  70. package/dist/esm/taro-template.json +68 -42
  71. package/dist/esm/toCodeTaro.d.ts +14 -1
  72. package/dist/esm/toCodeTaro.d.ts.map +1 -0
  73. package/dist/esm/toCodeTaro.js +1 -0
  74. package/dist/esm/utils/builder/buildResult.d.ts +1 -0
  75. package/dist/esm/utils/builder/buildResult.d.ts.map +1 -0
  76. package/dist/esm/utils/builder/buildResult.js +8 -1
  77. package/dist/esm/utils/common/ImportManager.d.ts.map +1 -0
  78. package/dist/esm/utils/common/helper.d.ts +10 -0
  79. package/dist/esm/utils/common/helper.js +29 -0
  80. package/dist/esm/utils/common/object.d.ts.map +1 -0
  81. package/dist/esm/utils/common/string.d.ts +10 -0
  82. package/dist/esm/utils/common/string.d.ts.map +1 -0
  83. package/dist/esm/utils/common/string.js +16 -0
  84. package/dist/esm/utils/config/content/converter.d.ts.map +1 -0
  85. package/dist/esm/utils/config/content/converter.js +1 -0
  86. package/dist/esm/utils/config/content/index.d.ts.map +1 -0
  87. package/dist/esm/utils/config/content/pageConfig.d.ts.map +1 -0
  88. package/dist/esm/utils/config/content/saveBase64Image.d.ts.map +1 -0
  89. package/dist/esm/utils/config/content/tabBarConfig.d.ts +19 -4
  90. package/dist/esm/utils/config/content/tabBarConfig.d.ts.map +1 -0
  91. package/dist/esm/utils/config/content/tabBarConfig.js +28 -4
  92. package/dist/esm/utils/config/content/types.d.ts +15 -10
  93. package/dist/esm/utils/config/content/types.d.ts.map +1 -0
  94. package/dist/esm/utils/config/content/validator.d.ts.map +1 -0
  95. package/dist/esm/utils/config/handlePageConfig.d.ts +6 -0
  96. package/dist/esm/utils/config/handlePageConfig.d.ts.map +1 -0
  97. package/dist/esm/utils/config/handlePageConfig.js +17 -2
  98. package/dist/esm/utils/context/buildContext.d.ts.map +1 -0
  99. package/dist/esm/utils/context/buildFrameMap.d.ts.map +1 -0
  100. package/dist/esm/utils/context/buildGlobalData.d.ts.map +1 -0
  101. package/dist/esm/utils/context/collectJSModules.d.ts.map +1 -0
  102. package/dist/esm/utils/context/createEventQueries.d.ts.map +1 -0
  103. package/dist/esm/utils/context/createProvider.d.ts.map +1 -0
  104. package/dist/esm/utils/index.d.ts.map +1 -0
  105. package/dist/esm/utils/logic/convertNamespace.d.ts.map +1 -0
  106. package/dist/esm/utils/logic/genJSModules.d.ts.map +1 -0
  107. package/dist/esm/utils/logic/handleProcess.js +66 -40
  108. package/dist/esm/utils/logic/processChildren.d.ts.map +1 -0
  109. package/dist/esm/utils/style/color.d.ts.map +1 -0
  110. package/dist/esm/utils/style/converter.js +11 -8
  111. package/dist/esm/utils/style/getComponentClassName.d.ts.map +1 -0
  112. package/dist/esm/utils/style/pxtransform.d.ts.map +1 -0
  113. package/dist/esm/utils/style/types.d.ts.map +1 -0
  114. package/dist/esm/utils/templates/component.d.ts.map +1 -0
  115. package/dist/esm/utils/templates/index.d.ts +1 -0
  116. package/dist/esm/utils/templates/index.js +20 -10
  117. package/dist/esm/utils/templates/renderManager.js +5 -2
  118. package/dist/esm/utils/templates/scene.d.ts +2 -1
  119. package/dist/esm/utils/templates/scene.js +7 -6
  120. package/package.json +1 -1
@@ -0,0 +1,68 @@
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/_Modal.ts
30
+ var Modal_exports = {};
31
+ __export(Modal_exports, {
32
+ default: () => Modal_default
33
+ });
34
+ module.exports = __toCommonJS(Modal_exports);
35
+ var import_taro = __toESM(require("@tarojs/taro"));
36
+ var Modal_default = (context) => {
37
+ var _a;
38
+ const data = context.data;
39
+ const inputs = context.inputs;
40
+ const outputs = context.outputs;
41
+ (_a = inputs.show) == null ? void 0 : _a.call(inputs, async (val) => {
42
+ var _a2, _b, _c;
43
+ try {
44
+ const cfg = typeof val === "string" ? { content: val } : val || {};
45
+ const modalConfig = {
46
+ title: cfg.title ?? data.title ?? "",
47
+ content: cfg.content ?? data.content ?? "",
48
+ showCancel: cfg.showCancel ?? data.showCancel ?? true,
49
+ cancelText: cfg.cancelText ?? data.cancelText ?? "取消",
50
+ cancelColor: cfg.cancelColor ?? data.cancelColor,
51
+ confirmText: cfg.confirmText ?? data.confirmText ?? "确认",
52
+ confirmColor: cfg.confirmColor ?? data.confirmColor
53
+ };
54
+ if (cfg.editable !== void 0)
55
+ modalConfig.editable = cfg.editable;
56
+ else if (data.editable !== void 0)
57
+ modalConfig.editable = data.editable;
58
+ const res = await import_taro.default.showModal(modalConfig);
59
+ if (res == null ? void 0 : res.confirm)
60
+ (_a2 = outputs.onConfirm) == null ? void 0 : _a2.call(outputs, res);
61
+ else
62
+ (_b = outputs.onCancel) == null ? void 0 : _b.call(outputs, res);
63
+ } catch (error) {
64
+ console.error("显示 Modal 失败:", error);
65
+ (_c = outputs.onCancel) == null ? void 0 : _c.call(outputs, error);
66
+ }
67
+ });
68
+ };
@@ -23,41 +23,66 @@ __export(TimerDelay_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(TimerDelay_exports);
25
25
  var TimerDelay_default = (context) => {
26
- var _a, _b;
26
+ var _a, _b, _c;
27
27
  const data = context.data;
28
28
  const inputs = context.inputs;
29
29
  const outputs = context.outputs;
30
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);
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();
36
58
  }
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;
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();
47
73
  }
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("没有正在执行的延迟任务");
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);
58
86
  }
59
- } catch (error) {
60
- console.error("取消延迟失败:", error);
61
- }
62
- });
87
+ });
63
88
  };
@@ -40,6 +40,7 @@ __export(comlib_exports, {
40
40
  mybricks_taro_getLocation: () => import_GetLocation.default,
41
41
  mybricks_taro_getStorage: () => import_GetStorage.default,
42
42
  mybricks_taro_getSystemInfo: () => import_GetSystemInfo.default,
43
+ mybricks_taro_modal: () => import_Modal.default,
43
44
  mybricks_taro_openCamera: () => import_OpenCamera.default,
44
45
  mybricks_taro_openPetalMap: () => import_OpenPetalMap.default,
45
46
  mybricks_taro_openUrl: () => import_OpenUrl.default,
@@ -69,6 +70,7 @@ var import_OpenUrl = __toESM(require("./_OpenUrl"));
69
70
  var import_Share = __toESM(require("./_Share"));
70
71
  var import_GetSystemInfo = __toESM(require("./_GetSystemInfo"));
71
72
  var import_AesEncode = __toESM(require("./_AesEncode"));
73
+ var import_Modal = __toESM(require("./_Modal"));
72
74
  var import_Format = __toESM(require("./_Format"));
73
75
  var import_ChooseFile = __toESM(require("./_ChooseFile"));
74
76
  var import_ChooseMedia = __toESM(require("./_ChooseMedia"));
@@ -94,6 +96,7 @@ var import_TimerThrottle = __toESM(require("./_TimerThrottle"));
94
96
  mybricks_taro_getLocation,
95
97
  mybricks_taro_getStorage,
96
98
  mybricks_taro_getSystemInfo,
99
+ mybricks_taro_modal,
97
100
  mybricks_taro_openCamera,
98
101
  mybricks_taro_openPetalMap,
99
102
  mybricks_taro_openUrl,
@@ -24,7 +24,6 @@ __export(log_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(log_exports);
26
26
  var log = (...args) => {
27
- console.log("[MyBricks]", ...args);
28
27
  };
29
28
  var logger = {
30
29
  info: log,
@@ -97,10 +97,11 @@ function useBindEvents(props, context) {
97
97
  return (0, import_react.useMemo)(() => {
98
98
  const _events = {};
99
99
  Object.keys(props).forEach((key) => {
100
- if (key.startsWith("on") && typeof props[key] === "function") {
100
+ if (typeof props[key] === "function") {
101
101
  const handler = props[key];
102
102
  const wrapped = (originalValue) => {
103
- const value = context ? {
103
+ var _a, _b;
104
+ const value = ((_b = (_a = context == null ? void 0 : context.parentSlot) == null ? void 0 : _a.params) == null ? void 0 : _b.itemWrap) ? {
104
105
  id: context.id,
105
106
  name: context.name,
106
107
  value: originalValue
@@ -37,6 +37,14 @@ module.exports = __toCommonJS(slots_exports);
37
37
  var import_react = __toESM(require("react"));
38
38
  var import_ComContext = __toESM(require("./ComContext"));
39
39
  var import_createReactiveInputHandler = require("../mybricks/createReactiveInputHandler");
40
+ function SlotParamsBridge(props) {
41
+ var _a, _b;
42
+ const parentSlot = (0, import_ComContext.useParentSlot)();
43
+ const mergedParams = ((_a = props.params) == null ? void 0 : _a.inputValues) === void 0 && ((_b = parentSlot == null ? void 0 : parentSlot.params) == null ? void 0 : _b.inputValues) ? { ...props.params || {}, inputValues: parentSlot.params.inputValues } : props.params;
44
+ const SlotComp = props.render;
45
+ const content = SlotComp ? /* @__PURE__ */ import_react.default.createElement(SlotComp, { ...mergedParams || {} }) : props.children ?? null;
46
+ return /* @__PURE__ */ import_react.default.createElement(import_ComContext.SlotProvider, { value: { ...props.state, params: mergedParams } }, content);
47
+ }
40
48
  function createChannelProxy(title) {
41
49
  const handlersMap = {};
42
50
  return new Proxy(
@@ -79,14 +87,12 @@ function useEnhancedSlots(rawSlots, id) {
79
87
  var _a, _b, _c, _d;
80
88
  const r = state._render;
81
89
  const rawScope = (params == null ? void 0 : params.key) ?? ((_a = params == null ? void 0 : params.inputValues) == null ? void 0 : _a.index) ?? ((_c = (_b = params == null ? void 0 : params.inputValues) == null ? void 0 : _b.itemData) == null ? void 0 : _c.id);
82
- const SlotComp = r;
83
- const content = r ? /* @__PURE__ */ import_react.default.createElement(SlotComp, { ...params || {} }) : null;
84
90
  if (rawScope === void 0 || rawScope === null) {
85
- return /* @__PURE__ */ import_react.default.createElement(import_ComContext.SlotProvider, { value: { ...state, params } }, content);
91
+ return /* @__PURE__ */ import_react.default.createElement(SlotParamsBridge, { state, params, render: r });
86
92
  }
87
93
  const scopeId = `${id}.${slotKey}::${String(rawScope)}`;
88
- const scopedComRefs = (_d = state._scopedComRefs)[scopeId] || (_d[scopeId] = { current: { $inputs: {} } });
89
- return /* @__PURE__ */ import_react.default.createElement(import_ComContext.SlotProvider, { value: { ...state, params } }, /* @__PURE__ */ import_react.default.createElement(ScopedComContextProvider, { comRefs: scopedComRefs, scopeId }, content));
94
+ const scopedComRefs = (_d = state._scopedComRefs)[scopeId] || (_d[scopeId] = { current: { $inputs: {}, $outputs: {} } });
95
+ return /* @__PURE__ */ import_react.default.createElement(import_ComContext.SlotProvider, { value: { ...state, params } }, /* @__PURE__ */ import_react.default.createElement(ScopedComContextProvider, { comRefs: scopedComRefs, scopeId }, /* @__PURE__ */ import_react.default.createElement(SlotParamsBridge, { state, params, render: r })));
90
96
  }
91
97
  });
92
98
  state._render = slotDef == null ? void 0 : slotDef.render;
@@ -25,8 +25,9 @@ module.exports = __toCommonJS(useContext_exports);
25
25
  var import_react = require("react");
26
26
  var import_hooks = require("./hooks");
27
27
  function useAppCreateContext() {
28
- const comRefs = (0, import_react.useRef)((0, import_hooks.deepProxy)({ $inputs: {} }));
29
- const outputs = (0, import_react.useRef)((0, import_hooks.deepProxy)({}));
28
+ const comRefs = (0, import_react.useRef)((0, import_hooks.deepProxy)({ $inputs: {}, $outputs: {} }));
29
+ const $vars = (0, import_react.useRef)({});
30
+ const $fxs = (0, import_react.useRef)({});
30
31
  const [popupState, setPopupState] = (0, import_react.useState)({
31
32
  visible: false,
32
33
  name: "",
@@ -54,7 +55,8 @@ function useAppCreateContext() {
54
55
  }).current;
55
56
  return (0, import_react.useMemo)(() => ({
56
57
  comRefs,
57
- outputs,
58
+ $vars,
59
+ $fxs,
58
60
  appContext,
59
61
  popupState,
60
62
  setPopupState
@@ -41,8 +41,8 @@ var import_ComContext = __toESM(require("./ComContext"));
41
41
  var import_slots = require("./slots");
42
42
  var import_taro = require("@tarojs/taro");
43
43
  var WithCom = (props) => {
44
- var _a;
45
- const { component: Component, id = "", data, className, style, inputValues, inputValuesMapping, ...rest } = props;
44
+ var _a, _b;
45
+ const { component: Component, id = "", data, className, style, ...rest } = props;
46
46
  const { comRefs, appContext } = (0, import_ComContext.useAppContext)();
47
47
  const env = appContext;
48
48
  const isPopup = Component.isPopup;
@@ -73,15 +73,14 @@ var WithCom = (props) => {
73
73
  }
74
74
  const inputProxy = (0, import_index.useBindInputs)(comRefs, id, handlers);
75
75
  const { slots: rawSlots, parentSlot: parentSlotProp, ...restProps } = rest;
76
- const { outputs: globalOutputs } = (0, import_ComContext.useAppContext)();
77
76
  const parentSlot = (0, import_slots.useResolvedParentSlot)(parentSlotProp);
78
77
  const eventProxy = (0, import_index.useBindEvents)(restProps, {
79
78
  id,
80
79
  name: props.name || id,
81
80
  parentSlot
82
81
  });
83
- if (globalOutputs && globalOutputs.current) {
84
- globalOutputs.current[id] = eventProxy;
82
+ if ((_a = comRefs == null ? void 0 : comRefs.current) == null ? void 0 : _a.$outputs) {
83
+ comRefs.current.$outputs[id] = eventProxy;
85
84
  }
86
85
  comRefs.current[id] = inputProxy;
87
86
  const enhancedSlots = (0, import_slots.useEnhancedSlots)(rawSlots, id);
@@ -99,7 +98,7 @@ var WithCom = (props) => {
99
98
  style
100
99
  }
101
100
  );
102
- if ((_a = parentSlot == null ? void 0 : parentSlot.params) == null ? void 0 : _a.itemWrap) {
101
+ if ((_b = parentSlot == null ? void 0 : parentSlot.params) == null ? void 0 : _b.itemWrap) {
103
102
  return parentSlot.params.itemWrap({
104
103
  id,
105
104
  name: props.name || id,
@@ -39,7 +39,7 @@ var import_commonDir = require("./utils/commonDir");
39
39
  var import_tabBarImages = require("./utils/tabBarImages");
40
40
  var import_appConfig = require("./utils/appConfig");
41
41
  var generateTaroProjectJson = (result) => {
42
- var _a;
42
+ var _a, _b;
43
43
  const { files = [], assets = {} } = result;
44
44
  const templateJsonPath = path.join(__dirname, "../taro-template.json");
45
45
  if (!fs.existsSync(templateJsonPath)) {
@@ -121,6 +121,23 @@ ${item.content || ""}`;
121
121
  (0, import_appConfig.updateAppConfig)(appConfigFile, normalItems, files);
122
122
  }
123
123
  (0, import_tabBarImages.handleTabBarImages)(tabbarDir, imageFiles);
124
+ const CUSTOM_TAB_BAR_CONFIG_PATH = "src/custom-tab-bar/mybricks/tabbar-config.ts";
125
+ const customTabBarItem = files.find((item) => item.type === "customTabBar");
126
+ if (customTabBarItem.content) {
127
+ const customTabBarDir = (0, import_fileNode.ensureDir)(srcDir, "src/custom-tab-bar");
128
+ const mybricksDir = (0, import_fileNode.ensureDir)(customTabBarDir, "src/custom-tab-bar/mybricks");
129
+ const tabbarConfigFileIndex = (_b = mybricksDir.children) == null ? void 0 : _b.findIndex(
130
+ (node) => node.path === CUSTOM_TAB_BAR_CONFIG_PATH
131
+ );
132
+ if (tabbarConfigFileIndex === -1) {
133
+ mybricksDir.children.push({
134
+ path: CUSTOM_TAB_BAR_CONFIG_PATH,
135
+ content: customTabBarItem.content
136
+ });
137
+ } else {
138
+ mybricksDir.children[tabbarConfigFileIndex].content = customTabBarItem.content;
139
+ }
140
+ }
124
141
  (0, import_commonDir.handleCommonDir)(commonDir, files);
125
142
  const popupFile = files.find((f) => f.type === "popup" && !f.meta);
126
143
  if (popupFile) {
@@ -39,6 +39,7 @@ var import_component = require("./utils/templates/component");
39
39
  var import_renderManager = require("./utils/templates/renderManager");
40
40
  var import_handleSlot = __toESM(require("./handleSlot"));
41
41
  var import_processComEvents = require("./processors/processComEvents");
42
+ var import_handleProcess = require("./utils/logic/handleProcess");
42
43
  var COM_PROTOCOL = {
43
44
  "mybricks.taro.formContainer": { useWrap: true },
44
45
  "mybricks.taro.formAdditionContainer": { useWrap: true }
@@ -93,10 +94,14 @@ var prepareComponent = (com, config) => {
93
94
  };
94
95
  };
95
96
  var prepareStyles = (com) => {
96
- var _a;
97
+ var _a, _b, _c;
97
98
  const { meta, props } = com;
98
- const resultStyle = (0, import_converter.convertComponentStyle)(props.style);
99
- const cssContent = (0, import_converter.convertStyleAryToCss)((_a = props.style) == null ? void 0 : _a.styleAry, meta.id);
99
+ const styleWithLayout = {
100
+ ...props.style || {},
101
+ layout: ((_a = props.data) == null ? void 0 : _a.layout) || ((_b = props.style) == null ? void 0 : _b.layout)
102
+ };
103
+ const resultStyle = (0, import_converter.convertComponentStyle)(styleWithLayout);
104
+ const cssContent = (0, import_converter.convertStyleAryToCss)((_c = props.style) == null ? void 0 : _c.styleAry, meta.id);
100
105
  return { cssContent, rootStyle: resultStyle.root || {} };
101
106
  };
102
107
  var processComSlots = (com, config, initialCss) => {
@@ -110,17 +115,20 @@ var processComSlots = (com, config, initialCss) => {
110
115
  const renderManager = config.renderManager || new import_renderManager.RenderManager();
111
116
  const slotEntries = Object.entries(slots);
112
117
  slotEntries.forEach(([slotId, slot], index) => {
113
- var _a, _b, _c;
118
+ var _a, _b, _c, _d;
114
119
  const children = slot.comAry || slot.children || [];
115
120
  if (children.length === 0) {
116
121
  return;
117
122
  }
123
+ const slotLayout = (_a = com.props.data) == null ? void 0 : _a.layout;
118
124
  const result = (0, import_handleSlot.default)(slot, {
119
125
  ...config,
120
126
  checkIsRoot: () => false,
121
127
  depth: 1,
122
128
  renderManager,
123
- slotKey: slotId
129
+ slotKey: slotId,
130
+ // 鸿蒙化:传递父容器的布局配置给插槽
131
+ layout: slotLayout
124
132
  });
125
133
  eventCode += result.js;
126
134
  if (result.cssContent) {
@@ -130,8 +138,8 @@ var processComSlots = (com, config, initialCss) => {
130
138
  const baseIndentSize = config.codeStyle.indent;
131
139
  const renderBodyIndent = (0, import_templates.indentation)(config.codeStyle.indent * 2);
132
140
  const formattedContent = (0, import_templates.formatSlotContent)(result.ui, baseIndentSize, renderBodyIndent);
133
- if (meta.def.namespace === "mybricks.taro.formContainer" && Array.isArray((_a = props.data) == null ? void 0 : _a.items) && result.childrenResults) {
134
- const items = (_b = props.data) == null ? void 0 : _b.items;
141
+ if (meta.def.namespace === "mybricks.taro.formContainer" && Array.isArray((_b = props.data) == null ? void 0 : _b.items) && result.childrenResults) {
142
+ const items = (_c = props.data) == null ? void 0 : _c.items;
135
143
  result.childrenResults.forEach((childRes) => {
136
144
  const itemConfig = items.find((it) => it.id === childRes.id);
137
145
  if (itemConfig == null ? void 0 : itemConfig.comName) {
@@ -139,7 +147,12 @@ var processComSlots = (com, config, initialCss) => {
139
147
  }
140
148
  });
141
149
  }
142
- const logicCode = buildSlotLogicCode(slotId, result.childrenResults, config);
150
+ const logicCode = buildSlotLogicCode({
151
+ parentComId: meta.id,
152
+ slotKey: slotId,
153
+ children: result.childrenResults,
154
+ config
155
+ });
143
156
  const description = `${meta.title || meta.id}的${slot.title || slotId}插槽`;
144
157
  renderManager.register(
145
158
  renderId,
@@ -147,7 +160,7 @@ var processComSlots = (com, config, initialCss) => {
147
160
  result.childrenResults,
148
161
  logicCode,
149
162
  slot.type,
150
- slot.wrap || slot.itemWrap || ((_c = COM_PROTOCOL[meta.def.namespace]) == null ? void 0 : _c.useWrap),
163
+ slot.wrap || slot.itemWrap || ((_d = COM_PROTOCOL[meta.def.namespace]) == null ? void 0 : _d.useWrap),
151
164
  description
152
165
  );
153
166
  if (result.childrenResults) {
@@ -163,40 +176,35 @@ var processComSlots = (com, config, initialCss) => {
163
176
  });
164
177
  return { slotsCode, accumulatedCssContent, eventCode, childrenResults: allChildrenResults };
165
178
  };
166
- var buildSlotLogicCode = (slotId, children, config) => {
167
- const scene = config.getCurrentScene();
179
+ var buildSlotLogicCode = (args) => {
180
+ var _a;
181
+ const { parentComId, slotKey, config } = args;
168
182
  const indent = (0, import_templates.indentation)(2);
169
183
  const indent2 = (0, import_templates.indentation)(4);
170
- const indent3 = (0, import_templates.indentation)(6);
171
- let bodyCode = "";
172
- children == null ? void 0 : children.forEach((child) => {
173
- if (child.type !== "com")
174
- return;
175
- const mapping = collectSlotInputMappingForCom({
176
- slotFrameId: slotId,
177
- scene,
178
- targetComId: child.id
179
- });
180
- Object.entries(mapping).forEach(([pinId, slotKey]) => {
181
- bodyCode += `${indent3}const val_${child.id}_${pinId} = params.inputValues['${slotKey}'];
182
- `;
183
- bodyCode += `${indent3}if (val_${child.id}_${pinId} !== undefined) {
184
- `;
185
- bodyCode += `${indent3}${indent}comRefs.current['${child.id}']?.['${pinId}']?.(val_${child.id}_${pinId});
186
- `;
187
- bodyCode += `${indent3}}
188
- `;
189
- });
190
- });
191
- if (!bodyCode) {
184
+ const effectEvent = (_a = config.getEffectEvent) == null ? void 0 : _a.call(config, { comId: parentComId, slotId: slotKey });
185
+ if (!effectEvent)
186
+ return "";
187
+ const paramsProxy = new Proxy(
188
+ {},
189
+ {
190
+ get: (_t, key) => `params?.inputValues?.['${String(key)}']`
191
+ }
192
+ );
193
+ let process = (0, import_handleProcess.handleProcess)(effectEvent, {
194
+ ...config,
195
+ target: "comRefs.current",
196
+ depth: 3,
197
+ addParentDependencyImport: config.addParentDependencyImport,
198
+ addConsumer: config.addConsumer,
199
+ getParams: () => paramsProxy
200
+ }).replace(/this\./g, "comRefs.current.").replace(/comRefs\.current\.([a-zA-Z0-9_]+)\.controller_/g, "comRefs.current.$1.").replace(/comRefs\.current\.slot_Index\./g, "comRefs.current.");
201
+ if (!process.trim())
192
202
  return "";
193
- }
194
203
  let code = `${indent}useEffect(() => {
195
204
  `;
196
- code += `${indent2}if (params?.inputValues) {
205
+ code += `${indent2}if (!params?.inputValues) return;
197
206
  `;
198
- code += bodyCode;
199
- code += `${indent2}}
207
+ code += `${process}
200
208
  `;
201
209
  code += `${indent}}, [params?.inputValues]);
202
210
  `;
@@ -222,7 +230,8 @@ var generateUiCode = (com, config, componentName, rootStyle, comEventCode, slots
222
230
  {
223
231
  codeStyle: config.codeStyle,
224
232
  depth: config.depth + 1,
225
- verbose: config.verbose
233
+ verbose: config.verbose,
234
+ checkIsRoot: config.checkIsRoot
226
235
  }
227
236
  );
228
237
  };
@@ -242,41 +251,6 @@ var handleJsCalculation = (com, config) => {
242
251
  }
243
252
  return { slots: [], scopeSlots: [], ui: "", js: "", cssContent: "", outputsConfig: void 0 };
244
253
  };
245
- function collectSlotInputMappingForCom(params) {
246
- const { slotFrameId, scene, targetComId } = params;
247
- const mapping = {};
248
- const cons = (scene == null ? void 0 : scene.cons) || {};
249
- const pinValueProxies = (scene == null ? void 0 : scene.pinValueProxies) || {};
250
- const coms = (scene == null ? void 0 : scene.coms) || {};
251
- const frameInputComIdToKey = {};
252
- Object.entries(pinValueProxies).forEach(([key, proxy]) => {
253
- var _a, _b;
254
- if ((proxy == null ? void 0 : proxy.type) === "frame" && proxy.frameId === slotFrameId && proxy.pinId) {
255
- const [comId] = String(key).split("-");
256
- if (comId && ((_b = (_a = coms[comId]) == null ? void 0 : _a.def) == null ? void 0 : _b.namespace) === "mybricks.core-comlib.frame-input") {
257
- frameInputComIdToKey[comId] = proxy.pinId;
258
- }
259
- }
260
- });
261
- if (Object.keys(frameInputComIdToKey).length === 0)
262
- return mapping;
263
- Object.entries(cons).forEach(([sourceKey, targets]) => {
264
- if (!Array.isArray(targets))
265
- return;
266
- const [sourceComId] = String(sourceKey).split("-");
267
- const slotInputKey = frameInputComIdToKey[sourceComId];
268
- if (slotInputKey) {
269
- targets.forEach((t) => {
270
- const targetId = typeof t === "string" ? t.split("-")[0] : t.comId;
271
- const targetPin = typeof t === "string" ? t.split("-")[1] : t.pinId;
272
- if (targetId === targetComId && targetPin) {
273
- mapping[targetPin] = slotInputKey;
274
- }
275
- });
276
- }
277
- });
278
- return mapping;
279
- }
280
254
  var handleCom_default = handleCom;
281
255
  // Annotate the CommonJS export names for ESM import in node:
282
256
  0 && (module.exports = {
@@ -60,9 +60,9 @@ var handleSlot = (ui, config) => {
60
60
  // 让插槽内部的组件知道当前处于哪个 slot(用于接收父容器 inputValues)
61
61
  currentSlotId: isRoot ? void 0 : config.slotKey || slotId
62
62
  });
63
- let effectCode = (0, import_processSceneLogic.processSceneLogic)(ui, config, addDependencyImport);
63
+ const { initCode, effectCode } = (0, import_processSceneLogic.processSceneLogic)(ui, config, addDependencyImport);
64
64
  let cssContent = ((0, import_utils.convertStyleAryToCss)((_b = props.style) == null ? void 0 : _b.styleAry, slotId) || "") + (childResults.cssContent ? "\n" + childResults.cssContent : "");
65
- const combinedJsCode = `${envDefineCode}${childResults.js}${(0, import_scene.wrapInEffect)(indent2, effectCode)}`;
65
+ const combinedJsCode = `${envDefineCode}${childResults.js}${initCode}${(0, import_scene.wrapInEffect)(indent2, effectCode)}`;
66
66
  const uiResult = generateSlotUi(ui, props, childResults.ui, config);
67
67
  if (isRoot) {
68
68
  const renderDefinitions = renderManager ? renderManager.toCode("") : "";
@@ -100,7 +100,8 @@ var setupImports = (addImport, config, isRoot) => {
100
100
  var generateSlotUi = (ui, props, childrenUi, config) => {
101
101
  const indent = (0, import_utils.indentation)(config.codeStyle.indent * config.depth);
102
102
  const mergedStyle = { width: "100%", height: "100%", ...ui.style || {}, ...props.style || {} };
103
- const styleCode = JSON.stringify((0, import_utils.convertRootStyle)({ ...mergedStyle, layout: ui.layout || mergedStyle.layout }));
103
+ const layout = config.layout || ui.layout || mergedStyle.layout;
104
+ const styleCode = JSON.stringify((0, import_utils.convertRootStyle)({ ...mergedStyle, layout }));
104
105
  const rootClassName = (0, import_utils.getRootComponentClassName)(config.getCurrentScene(), config.checkIsRoot());
105
106
  const classNameAttr = rootClassName ? ` className='${rootClassName}'` : "";
106
107
  return `${indent}<View${classNameAttr} style={${styleCode}}>
@@ -113,6 +114,7 @@ var finalizeRootComponent = (ui, config, importManager, combinedJsCode, renderDe
113
114
  const componentId = ((_b = ui.meta) == null ? void 0 : _b.id) || ui.id || ((_c = ui.meta) == null ? void 0 : _c.slotId) || "Index";
114
115
  const componentName = `I${String(componentId).replace(/[^a-zA-Z0-9]/g, "_")}`;
115
116
  const componentCode = (0, import_scene.genComponentTemplate)({
117
+ componentId,
116
118
  componentName,
117
119
  combinedJsCode,
118
120
  renderDefinitions,
@@ -67,7 +67,7 @@ var processComEvents = (com, config) => {
67
67
  depth: config.depth + 3,
68
68
  addParentDependencyImport: config.addParentDependencyImport,
69
69
  getParams: () => ({ [eventId]: paramName })
70
- }).replace(/this\./g, "comRefs.current.").replace(
70
+ }).replace(/this\.\$vars\./g, "$vars.current.").replace(/this\.\$fxs\./g, "$fxs.current.").replace(/this\./g, "comRefs.current.").replace(
71
71
  /comRefs\.current\.([a-zA-Z0-9_]+)\.controller_/g,
72
72
  "comRefs.current.$1."
73
73
  ).replace(/comRefs\.current\.slot_Index\./g, "comRefs.current.");
@@ -90,8 +90,7 @@ ${handlerIndent}}`;
90
90
  if (!outputsConfig[meta.id]) {
91
91
  outputsConfig[meta.id] = {};
92
92
  }
93
- const onEventName = eventId.startsWith("on") ? eventId : `on${eventId.charAt(0).toUpperCase()}${eventId.slice(1)}`;
94
- outputsConfig[meta.id][onEventName] = handlerCode;
93
+ outputsConfig[meta.id][eventId] = handlerCode;
95
94
  eventConfig[eventId] = { connected: true };
96
95
  });
97
96
  if (((_a = meta.def) == null ? void 0 : _a.namespace) === "mybricks.taro.popup") {
@@ -105,6 +105,29 @@ var processModule = (params) => {
105
105
  }
106
106
  abstractEventTypeDefMap[comId].eventIdMap[eventId] = schema;
107
107
  },
108
+ getCallTemplate: (params2) => {
109
+ var _a2, _b, _c, _d;
110
+ const { com, pinId, args } = params2;
111
+ const targetScene = getSceneById(com.sceneId || com.id);
112
+ if (targetScene || com.isScene) {
113
+ const sceneId = (targetScene == null ? void 0 : targetScene.id) || com.sceneId || com.id;
114
+ const isTargetPopup = (targetScene == null ? void 0 : targetScene.type) === "popup" || ((_a2 = targetScene == null ? void 0 : targetScene.deps) == null ? void 0 : _a2.some((dep) => dep.namespace === "mybricks.taro.popup"));
115
+ const routerName = isTargetPopup ? "popupRouter" : "pageRouter";
116
+ const isInput = (_b = targetScene == null ? void 0 : targetScene.inputs) == null ? void 0 : _b.some((pin) => pin.id === pinId);
117
+ const isOutput = (_c = targetScene == null ? void 0 : targetScene.outputs) == null ? void 0 : _c.some((pin) => pin.id === pinId);
118
+ if (isInput || isOutput) {
119
+ return {
120
+ code: `${routerName}.${pinId}("${((_d = config.getPageId) == null ? void 0 : _d.call(config, sceneId)) || sceneId}"${args ? `, ${args}` : ""})`,
121
+ import: {
122
+ packageName: config.getComponentPackageName(),
123
+ dependencyNames: [routerName],
124
+ importType: "named"
125
+ }
126
+ };
127
+ }
128
+ }
129
+ return void 0;
130
+ },
108
131
  getComponentController: ({ com }) => {
109
132
  return com.id;
110
133
  }
@@ -101,6 +101,29 @@ var processScene = (params) => {
101
101
  // 显式传入 renderManager
102
102
  isPopup,
103
103
  // 标记当前场景是否为弹窗
104
+ getCallTemplate: (params2) => {
105
+ var _a2, _b2, _c2, _d;
106
+ const { com, pinId, args } = params2;
107
+ const targetScene = getSceneById(com.sceneId || com.id);
108
+ if (targetScene || com.isScene) {
109
+ const sceneId = (targetScene == null ? void 0 : targetScene.id) || com.sceneId || com.id;
110
+ const isTargetPopup = (targetScene == null ? void 0 : targetScene.type) === "popup" || ((_a2 = targetScene == null ? void 0 : targetScene.deps) == null ? void 0 : _a2.some((dep) => dep.namespace === "mybricks.taro.popup"));
111
+ const routerName = isTargetPopup ? "popupRouter" : "pageRouter";
112
+ const isInput = (_b2 = targetScene == null ? void 0 : targetScene.inputs) == null ? void 0 : _b2.some((pin) => pin.id === pinId);
113
+ const isOutput = (_c2 = targetScene == null ? void 0 : targetScene.outputs) == null ? void 0 : _c2.some((pin) => pin.id === pinId);
114
+ if (isInput || isOutput) {
115
+ return {
116
+ code: `${routerName}.${pinId}("${((_d = config.getPageId) == null ? void 0 : _d.call(config, sceneId)) || sceneId}"${args ? `, ${args}` : ""})`,
117
+ import: {
118
+ packageName: config.getComponentPackageName(),
119
+ dependencyNames: [routerName],
120
+ importType: "named"
121
+ }
122
+ };
123
+ }
124
+ }
125
+ return void 0;
126
+ },
104
127
  getDslComNameById: (id) => dslComIdToNameMap[id],
105
128
  getCurrentScene: () => {
106
129
  const originalScene2 = getSceneById(scene.id);