@mybricks/to-code-taro 1.2.3 → 1.2.5

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.
@@ -194,6 +194,17 @@ ${item.content || ""}`;
194
194
  (0, import_pageImages.handlePageImages)(assetsDir, pageImages);
195
195
  (0, import_customTabBar.updateCustomTabBar)(srcDir, files);
196
196
  (0, import_commonDir.handleCommonDir)(commonDir, files);
197
+ const globalItem = files.find((item) => item.type === "global");
198
+ if ((globalItem == null ? void 0 : globalItem.jsModules) && globalItem.jsModules.length > 0) {
199
+ commonDir.children.push({
200
+ path: "src/common/index.jsModules.ts",
201
+ content: (0, import_genJSModules.genScopedJSModules)(
202
+ globalItem.jsModules,
203
+ "@mybricks/taro-core",
204
+ "@/common/jsModulesRuntime"
205
+ )
206
+ });
207
+ }
197
208
  const apiItem = files.find((item) => item.type === "connector-api");
198
209
  if (apiItem) {
199
210
  commonDir.children = commonDir.children || [];
@@ -25,6 +25,7 @@ module.exports = __toCommonJS(handleGlobal_exports);
25
25
  var import_utils = require("./utils");
26
26
  var import_handleProcess = require("./utils/logic/handleProcess");
27
27
  var import_string = require("./utils/common/string");
28
+ var import_collectJSModules = require("./utils/context/collectJSModules");
28
29
  var handleGlobal = (params, config) => {
29
30
  const { tojson, globalFxs, globalVars } = params;
30
31
  const globalImportManager = new import_utils.ImportManager(config);
@@ -121,8 +122,9 @@ ${indent2}})`;
121
122
  }
122
123
  return `value${index}: any`;
123
124
  }).join(", ");
125
+ const fxParams = values ? `${values}, appContext: any` : `appContext: any`;
124
126
  globalFxsInitCode += `${indent}/** ${event.title} */
125
- ${indent}${event.frameId}: any = createFx((${values}) => {
127
+ ${indent}${event.frameId}: any = createFx((${fxParams}) => {
126
128
  ${res}
127
129
  ${indent}})
128
130
  `;
@@ -161,6 +163,15 @@ export const globalFxs = new GlobalFxs()`;
161
163
  importType: "named"
162
164
  });
163
165
  }
166
+ const globalJsModules = [];
167
+ (tojson.global.fxFrames || []).forEach((fxFrame) => {
168
+ Object.entries(fxFrame.coms || {}).forEach(([comId, comInfo]) => {
169
+ const jsModule = (0, import_collectJSModules.extractJSModuleFromCom)(comId, comInfo);
170
+ if (jsModule && !globalJsModules.some((m) => m.id === comId)) {
171
+ globalJsModules.push(jsModule);
172
+ }
173
+ });
174
+ });
164
175
  return [
165
176
  {
166
177
  type: "rootConfig",
@@ -172,7 +183,8 @@ export const globalFxs = new GlobalFxs()`;
172
183
  type: "global",
173
184
  content: varCode + "\n\n" + fxCode,
174
185
  importManager: globalImportManager,
175
- name: "global"
186
+ name: "global",
187
+ jsModules: globalJsModules
176
188
  }
177
189
  ];
178
190
  };
@@ -25,7 +25,7 @@ module.exports = __toCommonJS(handleModule_exports);
25
25
  var import_utils = require("./utils");
26
26
  var import_handleProcess = require("./utils/logic/handleProcess");
27
27
  var handleModule = (module2, config) => {
28
- var _a, _b;
28
+ var _a;
29
29
  const { events, moduleId, props } = module2;
30
30
  const name = `C${String(moduleId).replace(/[^a-zA-Z0-9]/g, "_").toUpperCase()}`;
31
31
  let comEventCode = "";
@@ -74,10 +74,7 @@ ${indent}},
74
74
  currentProvider.controllers.add(module2.meta.id);
75
75
  const resultStyle = (0, import_utils.convertComponentStyle)(module2.props.style);
76
76
  const cssContent = (0, import_utils.convertStyleAryToCss)((_a = props.style) == null ? void 0 : _a.styleAry, module2.meta.id);
77
- const componentController = ((_b = config.getComponentController) == null ? void 0 : _b.call(config, {
78
- com: module2.meta,
79
- scene: config.getCurrentScene()
80
- })) || `controller_${module2.meta.id}`;
77
+ const componentController = module2.meta.id;
81
78
  const initialIndent = config.codeStyle.indent * config.depth;
82
79
  const indentView = (0, import_utils.indentation)(initialIndent);
83
80
  const indent2 = (0, import_utils.indentation)(initialIndent + config.codeStyle.indent);
@@ -88,7 +85,8 @@ ${indent3}data={${(0, import_utils.genObjectCode)(configs, {
88
85
  initialIndent: initialIndent + config.codeStyle.indent * 2,
89
86
  indentSize: config.codeStyle.indent
90
87
  })}}` : "") + `
91
- ${indent3}controller={comRefs.current.${componentController}}` + (comEventCode ? `
88
+ ${indent3}parentComRefs={comRefs}
89
+ ${indent3}moduleId="${componentController}"` + (comEventCode ? `
92
90
  ${indent3}onEvents={{${comEventCode.replace(/\n/g, "\n" + indent3)}}}` : "") + `
93
91
  ${indent2}/>`;
94
92
  const ui = `${indentView}<View id="${module2.meta.id}" className="${module2.meta.id}" style={${JSON.stringify(resultStyle.root)}}>
@@ -70,10 +70,12 @@ var processModule = (params) => {
70
70
  return { ...scene, ...originalScene, event };
71
71
  },
72
72
  add: (value) => {
73
+ const jsModules = Array.from(jsModulesMap.values());
73
74
  addResult({
74
75
  ...value,
75
76
  type: scene.type,
76
- meta: scene
77
+ meta: scene,
78
+ jsModules
77
79
  });
78
80
  },
79
81
  addJSModule: (module2) => {
@@ -107,18 +109,26 @@ var processModule = (params) => {
107
109
  abstractEventTypeDefMap[comId].eventIdMap[eventId] = schema;
108
110
  },
109
111
  getCallTemplate: (params2) => {
110
- var _a2, _b, _c, _d;
112
+ var _a2, _b, _c, _d, _e;
111
113
  const { com, pinId, args } = params2;
112
114
  const targetScene = getSceneById(com.sceneId || com.id);
113
115
  if (targetScene || com.isScene) {
114
116
  const sceneId = (targetScene == null ? void 0 : targetScene.id) || com.sceneId || com.id;
115
- 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"));
117
+ if (sceneId === scene.id) {
118
+ const isOutput2 = (_a2 = targetScene == null ? void 0 : targetScene.outputs) == null ? void 0 : _a2.some((pin) => pin.id === pinId);
119
+ if (isOutput2) {
120
+ return {
121
+ code: `moduleOutputs?.${pinId}?.(${args || ""})`
122
+ };
123
+ }
124
+ }
125
+ const isTargetPopup = (targetScene == null ? void 0 : targetScene.type) === "popup" || ((_b = targetScene == null ? void 0 : targetScene.deps) == null ? void 0 : _b.some((dep) => dep.namespace === "mybricks.taro.popup"));
116
126
  const routerName = isTargetPopup ? "popupRouter" : "pageRouter";
117
- const isInput = (_b = targetScene == null ? void 0 : targetScene.inputs) == null ? void 0 : _b.some((pin) => pin.id === pinId);
118
- const isOutput = (_c = targetScene == null ? void 0 : targetScene.outputs) == null ? void 0 : _c.some((pin) => pin.id === pinId);
127
+ const isInput = (_c = targetScene == null ? void 0 : targetScene.inputs) == null ? void 0 : _c.some((pin) => pin.id === pinId);
128
+ const isOutput = (_d = targetScene == null ? void 0 : targetScene.outputs) == null ? void 0 : _d.some((pin) => pin.id === pinId);
119
129
  if (isInput || isOutput) {
120
130
  return {
121
- code: `${routerName}.${pinId}("${((_d = config.getPageId) == null ? void 0 : _d.call(config, sceneId)) || sceneId}"${args ? `, ${args}` : ""})`,
131
+ code: `${routerName}.${pinId}("${((_e = config.getPageId) == null ? void 0 : _e.call(config, sceneId)) || sceneId}"${args ? `, ${args}` : ""})`,
122
132
  import: {
123
133
  packageName: config.getComponentPackageName(),
124
134
  dependencyNames: [routerName],
@@ -77,7 +77,7 @@
77
77
  },
78
78
  {
79
79
  "path": "src/app.less",
80
- "content": "/* 隐藏 React Refresh 的全屏错误遮罩 */\n#react-refresh-overlay, \niframe[id=\"react-refresh-overlay\"] {\n display: none !important;\n}\n\n.mybricks_taro_systemPage {\n height: 100vh !important;\n}\n\n.mybricks_com{\n flex-shrink: 0;\n min-height: 0; /* 防止子元素撑开父元素 */\n}\n.mybricks_slot{\n width: 100%;\n height: 100%;\n position: relative;\n transform: translateX(0)\n}\n\nview {\n box-sizing: border-box;\n}\n"
80
+ "content": "/* 隐藏 React Refresh 的全屏错误遮罩 */\n#react-refresh-overlay,\niframe[id=\"react-refresh-overlay\"] {\n display: none !important;\n}\n\n/* 系统页面 */\n.mybricks_taro_systemPage {\n height: 100vh !important;\n}\n\n.mybricks_com {\n flex-shrink: 0;\n min-height: 0;\n /* 防止子元素撑开父元素 */\n}\n\n.mybricks_slot {\n width: 100%;\n height: 100%;\n position: relative;\n transform: translateX(0)\n}\n\nview {\n box-sizing: border-box;\n}"
81
81
  },
82
82
  {
83
83
  "path": "src/app.ts",
@@ -137,7 +137,7 @@
137
137
  },
138
138
  {
139
139
  "path": "package.json",
140
- "content": "{\n \"name\": \"checkCom\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"\",\n \"templateInfo\": {\n \"name\": \"default\",\n \"typescript\": true,\n \"css\": \"Less\",\n \"framework\": \"React\"\n },\n \"scripts\": {\n \"prepare\": \"husky\",\n \"new\": \"taro new\",\n \"build:weapp\": \"taro build --type weapp\",\n \"build:swan\": \"taro build --type swan\",\n \"build:alipay\": \"taro build --type alipay\",\n \"build:tt\": \"taro build --type tt\",\n \"build:h5\": \"taro build --type h5\",\n \"build:rn\": \"taro build --type rn\",\n \"build:qq\": \"taro build --type qq\",\n \"build:jd\": \"taro build --type jd\",\n \"build:harmony-hybrid\": \"taro build --type harmony-hybrid\",\n \"dev:weapp\": \"npm run build:weapp -- --watch\",\n \"dev:swan\": \"npm run build:swan -- --watch\",\n \"dev:alipay\": \"npm run build:alipay -- --watch\",\n \"dev:tt\": \"npm run build:tt -- --watch\",\n \"dev:h5\": \"npm run build:h5 -- --watch\",\n \"dev:rn\": \"npm run build:rn -- --watch\",\n \"dev:qq\": \"npm run build:qq -- --watch\",\n \"dev:jd\": \"npm run build:jd -- --watch\",\n \"dev:harmony-hybrid\": \"npm run build:harmony-hybrid -- --watch\"\n },\n \"browserslist\": {\n \"development\": [\n \"defaults and fully supports es6-module\",\n \"maintained node versions\"\n ],\n \"production\": [\n \"last 3 versions\",\n \"Android >= 4.1\",\n \"ios >= 8\"\n ]\n },\n \"author\": \"\",\n \"dependencies\": {\n \"@babel/runtime\": \"^7.24.4\",\n \"@tarojs/components\": \"4.1.9\",\n \"@tarojs/helper\": \"4.1.9\",\n \"@tarojs/plugin-platform-weapp\": \"4.1.9\",\n \"@tarojs/plugin-platform-alipay\": \"4.1.9\",\n \"@tarojs/plugin-platform-tt\": \"4.1.9\",\n \"@tarojs/plugin-platform-swan\": \"4.1.9\",\n \"@tarojs/plugin-platform-jd\": \"4.1.9\",\n \"@tarojs/plugin-platform-qq\": \"4.1.9\",\n \"@tarojs/plugin-platform-h5\": \"4.1.9\",\n \"@tarojs/plugin-platform-harmony-hybrid\": \"4.1.9\",\n \"@tarojs/runtime\": \"4.1.9\",\n \"@tarojs/shared\": \"4.1.9\",\n \"@tarojs/taro\": \"4.1.9\",\n \"@tarojs/plugin-framework-react\": \"4.1.9\",\n \"@tarojs/react\": \"4.1.9\",\n \"react-dom\": \"^18.0.0\",\n \"react\": \"^18.0.0\",\n \"brickd-mobile\": \"^0.0.53\",\n \"@taroify/icons\": \"^0.9.0\",\n \"@types/crypto-js\": \"^4.2.2\",\n \"dayjs\": \"^1.11.19\",\n \"crypto-js\": \"^4.2.0\",\n \"@antv/f2\": \"3.8.12\",\n \"qrcode-generator\": \"^2.0.4\",\n \"lodash\": \"^4.17.21\",\n \"@mybricks/taro-core\": \"^0.1.2\",\n \"@mybricks/taro-components\": \"^0.1.2\"\n },\n \"devDependencies\": {\n \"@tarojs/plugin-generator\": \"4.1.9\",\n \"@commitlint/cli\": \"^19.8.1\",\n \"@commitlint/config-conventional\": \"^19.8.1\",\n \"lint-staged\": \"^16.1.2\",\n \"husky\": \"^9.1.7\",\n \"stylelint-config-standard\": \"^38.0.0\",\n \"@babel/core\": \"^7.24.4\",\n \"@tarojs/cli\": \"4.1.9\",\n \"@babel/plugin-transform-class-properties\": \"7.25.9\",\n \"@types/webpack-env\": \"^1.13.6\",\n \"@types/react\": \"^18.0.0\",\n \"webpack\": \"5.91.0\",\n \"@tarojs/taro-loader\": \"4.1.9\",\n \"@tarojs/webpack5-runner\": \"4.1.9\",\n \"less\": \"^4.2.0\",\n \"babel-preset-taro\": \"4.1.9\",\n \"eslint-config-taro\": \"4.1.9\",\n \"eslint\": \"^8.57.0\",\n \"@pmmmwh/react-refresh-webpack-plugin\": \"^0.5.5\",\n \"react-refresh\": \"^0.14.0\",\n \"@babel/preset-react\": \"^7.24.1\",\n \"eslint-plugin-react\": \"^7.34.1\",\n \"eslint-plugin-react-hooks\": \"^4.4.0\",\n \"stylelint\": \"^16.4.0\",\n \"typescript\": \"^5.4.5\",\n \"tsconfig-paths-webpack-plugin\": \"^4.1.0\",\n \"postcss\": \"^8.5.6\",\n \"@types/node\": \"^18\",\n \"@types/minimatch\": \"^5\"\n }\n}\n"
140
+ "content": "{\n \"name\": \"checkCom\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"\",\n \"templateInfo\": {\n \"name\": \"default\",\n \"typescript\": true,\n \"css\": \"Less\",\n \"framework\": \"React\"\n },\n \"scripts\": {\n \"prepare\": \"husky\",\n \"new\": \"taro new\",\n \"build:weapp\": \"taro build --type weapp\",\n \"build:swan\": \"taro build --type swan\",\n \"build:alipay\": \"taro build --type alipay\",\n \"build:tt\": \"taro build --type tt\",\n \"build:h5\": \"taro build --type h5\",\n \"build:rn\": \"taro build --type rn\",\n \"build:qq\": \"taro build --type qq\",\n \"build:jd\": \"taro build --type jd\",\n \"build:harmony-hybrid\": \"taro build --type harmony-hybrid\",\n \"dev:weapp\": \"npm run build:weapp -- --watch\",\n \"dev:swan\": \"npm run build:swan -- --watch\",\n \"dev:alipay\": \"npm run build:alipay -- --watch\",\n \"dev:tt\": \"npm run build:tt -- --watch\",\n \"dev:h5\": \"npm run build:h5 -- --watch\",\n \"dev:rn\": \"npm run build:rn -- --watch\",\n \"dev:qq\": \"npm run build:qq -- --watch\",\n \"dev:jd\": \"npm run build:jd -- --watch\",\n \"dev:harmony-hybrid\": \"npm run build:harmony-hybrid -- --watch\"\n },\n \"browserslist\": {\n \"development\": [\n \"defaults and fully supports es6-module\",\n \"maintained node versions\"\n ],\n \"production\": [\n \"last 3 versions\",\n \"Android >= 4.1\",\n \"ios >= 8\"\n ]\n },\n \"author\": \"\",\n \"dependencies\": {\n \"@babel/runtime\": \"^7.24.4\",\n \"@tarojs/components\": \"4.1.9\",\n \"@tarojs/helper\": \"4.1.9\",\n \"@tarojs/plugin-platform-weapp\": \"4.1.9\",\n \"@tarojs/plugin-platform-alipay\": \"4.1.9\",\n \"@tarojs/plugin-platform-tt\": \"4.1.9\",\n \"@tarojs/plugin-platform-swan\": \"4.1.9\",\n \"@tarojs/plugin-platform-jd\": \"4.1.9\",\n \"@tarojs/plugin-platform-qq\": \"4.1.9\",\n \"@tarojs/plugin-platform-h5\": \"4.1.9\",\n \"@tarojs/plugin-platform-harmony-hybrid\": \"4.1.9\",\n \"@tarojs/runtime\": \"4.1.9\",\n \"@tarojs/shared\": \"4.1.9\",\n \"@tarojs/taro\": \"4.1.9\",\n \"@tarojs/plugin-framework-react\": \"4.1.9\",\n \"@tarojs/react\": \"4.1.9\",\n \"react-dom\": \"^18.0.0\",\n \"react\": \"^18.0.0\",\n \"brickd-mobile\": \"^0.0.53\",\n \"@taroify/icons\": \"^0.9.0\",\n \"@types/crypto-js\": \"^4.2.2\",\n \"dayjs\": \"^1.11.19\",\n \"crypto-js\": \"^4.2.0\",\n \"@antv/f2\": \"3.8.12\",\n \"qrcode-generator\": \"^2.0.4\",\n \"lodash\": \"^4.17.21\",\n \"@mybricks/taro-core\": \"^0.1.3\",\n \"@mybricks/taro-components\": \"^0.1.2\"\n },\n \"devDependencies\": {\n \"@tarojs/plugin-generator\": \"4.1.9\",\n \"@commitlint/cli\": \"^19.8.1\",\n \"@commitlint/config-conventional\": \"^19.8.1\",\n \"lint-staged\": \"^16.1.2\",\n \"husky\": \"^9.1.7\",\n \"stylelint-config-standard\": \"^38.0.0\",\n \"@babel/core\": \"^7.24.4\",\n \"@tarojs/cli\": \"4.1.9\",\n \"@babel/plugin-transform-class-properties\": \"7.25.9\",\n \"@types/webpack-env\": \"^1.13.6\",\n \"@types/react\": \"^18.0.0\",\n \"webpack\": \"5.91.0\",\n \"@tarojs/taro-loader\": \"4.1.9\",\n \"@tarojs/webpack5-runner\": \"4.1.9\",\n \"less\": \"^4.2.0\",\n \"babel-preset-taro\": \"4.1.9\",\n \"eslint-config-taro\": \"4.1.9\",\n \"eslint\": \"^8.57.0\",\n \"@pmmmwh/react-refresh-webpack-plugin\": \"^0.5.5\",\n \"react-refresh\": \"^0.14.0\",\n \"@babel/preset-react\": \"^7.24.1\",\n \"eslint-plugin-react\": \"^7.34.1\",\n \"eslint-plugin-react-hooks\": \"^4.4.0\",\n \"stylelint\": \"^16.4.0\",\n \"typescript\": \"^5.4.5\",\n \"tsconfig-paths-webpack-plugin\": \"^4.1.0\",\n \"postcss\": \"^8.5.6\",\n \"@types/node\": \"^18\",\n \"@types/minimatch\": \"^5\"\n }\n}\n"
141
141
  },
142
142
  {
143
143
  "path": "project.config.json",
@@ -176,7 +176,7 @@ ${indent}${nextCode}globalVars.${varKey}.${props.id}(${nextValue}${xpathArg})`;
176
176
  config
177
177
  );
178
178
  code += `${indent}/** ${props.title} 变量 ${props.meta.title} */
179
- ${indent}${nextCode}this.$vars.${varKey}.${props.id}(${nextValue}${xpathArg})`;
179
+ ${indent}${nextCode}$vars.current.${varKey}.${props.id}(${nextValue}${xpathArg})`;
180
180
  }
181
181
  } else if (category === "fx") {
182
182
  if (props.meta.global) {
@@ -186,14 +186,14 @@ ${indent}${nextCode}this.$vars.${varKey}.${props.id}(${nextValue}${xpathArg})`;
186
186
  importType: "named"
187
187
  });
188
188
  code += `${indent}/** 调用全局Fx ${props.meta.title} */
189
- ${indent}${nextCode}globalFxs.${props.meta.ioProxy.id}(${nextValue})`;
189
+ ${indent}${nextCode}globalFxs.${props.meta.ioProxy.id}(${nextValue}${nextValue ? ", " : ""}appContext)`;
190
190
  } else {
191
191
  const currentProvider = getCurrentProvider(
192
192
  { isSameScope, props },
193
193
  config
194
194
  );
195
195
  code += `${indent}/** 调用Fx ${props.meta.title} */
196
- ${indent}${nextCode}this.$fxs.${props.meta.ioProxy.id}(${nextValue})`;
196
+ ${indent}${nextCode}$fxs.current.${props.meta.ioProxy.id}(${nextValue})`;
197
197
  }
198
198
  }
199
199
  } else {
@@ -225,7 +225,7 @@ ${indent}${nextCode}this.${props.meta.id}.${props.id}(${nextValue})`;
225
225
  `;
226
226
  } else {
227
227
  const next = outputs.map((output) => {
228
- return getNextValueWithParam(output, config, event);
228
+ return getNextValueWithParam(output, config, event, outputToInputPinMap);
229
229
  }).join(", ");
230
230
  return pre + `${indent2}${id}: ${next},
231
231
  `;
@@ -343,8 +343,8 @@ var getNextValue = (props, config, event, outputToInputPinMap) => {
343
343
  });
344
344
  return nextValue.join(", ");
345
345
  };
346
- var getNextValueWithParam = (param, config, event) => {
347
- var _a, _b, _c, _d, _e;
346
+ var getNextValueWithParam = (param, config, event, outputToInputPinMap) => {
347
+ var _a, _b, _c, _d, _e, _f, _g;
348
348
  if (param.type === "params") {
349
349
  const params = config.getParams();
350
350
  return params[param.id];
@@ -354,15 +354,17 @@ var getNextValueWithParam = (param, config, event) => {
354
354
  }
355
355
  const componentNameWithId = getComponentNameWithId(param, config, event);
356
356
  if ((_e = (_d = (_c = param.meta) == null ? void 0 : _c.def) == null ? void 0 : _d.namespace) == null ? void 0 : _e.includes(".var")) {
357
- const connectId2 = param.connectId;
358
- if (connectId2) {
359
- return `${componentNameWithId}_${connectId2}_result`;
357
+ const key2 = `${(_f = param.meta) == null ? void 0 : _f.id}_${param.id}`;
358
+ const fullVarName2 = outputToInputPinMap == null ? void 0 : outputToInputPinMap.get(key2);
359
+ if (fullVarName2) {
360
+ return fullVarName2;
360
361
  }
361
362
  return `${componentNameWithId}_result`;
362
363
  }
363
- const connectId = param.connectId;
364
- if (connectId) {
365
- return `${componentNameWithId}_${connectId}_result.${param.id}`;
364
+ const key = `${(_g = param.meta) == null ? void 0 : _g.id}_${param.id}`;
365
+ const fullVarName = outputToInputPinMap == null ? void 0 : outputToInputPinMap.get(key);
366
+ if (fullVarName) {
367
+ return `${fullVarName}.${param.id}`;
366
368
  }
367
369
  return `${componentNameWithId}_result.${param.id}`;
368
370
  };
@@ -99,6 +99,15 @@ var convertRootStyle = (style) => {
99
99
  handleLayoutProp(value, rootStyle);
100
100
  return;
101
101
  }
102
+ if (key === "widthAuto" && value === true) {
103
+ rootStyle["width"] = "auto";
104
+ } else if (key === "heightAuto" && value === true) {
105
+ rootStyle["height"] = "auto";
106
+ } else if (key === "widthFull" && value === true) {
107
+ rootStyle["width"] = "100%";
108
+ } else if (key === "heightFull" && value === true) {
109
+ rootStyle["height"] = "100%";
110
+ }
102
111
  const camelKey = key.includes("-") ? (0, import_string.kebabToCamel)(key) : key;
103
112
  rootStyle[camelKey] = transformStyleValue(camelKey, value);
104
113
  });
@@ -56,7 +56,7 @@ var RenderManager = class {
56
56
  }
57
57
  code += `${indent}function ${renderFunctionName}(params: any) {
58
58
  `;
59
- code += `${indent}${indent2}const { comRefs, $vars, $fxs, appContext } = useAppContext();
59
+ code += `${indent}${indent2}const { comRefs, $vars, $fxs, appContext, moduleOutputs } = useAppContext();
60
60
  `;
61
61
  if (logicCode == null ? void 0 : logicCode.includes("$outputs")) {
62
62
  code += `${indent}${indent2}const $outputs = comRefs.current.$outputs;
@@ -31,7 +31,8 @@ var genReactiveDataManager = (indent, utilsPackageName) => {
31
31
  return ``;
32
32
  };
33
33
  var genRootDefineCode = (indent, utilsPackageName, hasJsModules = false, isModule = false) => {
34
- let code = `${indent}const {comRefs, $vars, $fxs, appContext} = useAppContext();
34
+ let code = isModule ? `${indent}const {comRefs, $vars, $fxs, appContext, moduleOutputs} = useAppContext();
35
+ ` : `${indent}const {comRefs, $vars, $fxs, appContext} = useAppContext();
35
36
  `;
36
37
  if (!isModule) {
37
38
  code += `${indent}usePageLife();
@@ -44,7 +45,7 @@ var genRootDefineCode = (indent, utilsPackageName, hasJsModules = false, isModul
44
45
  return code;
45
46
  };
46
47
  var genSlotDefineCode = (indent) => {
47
- return `${indent}const {comRefs, $vars, $fxs, appContext} = useAppContext();
48
+ return `${indent}const { comRefs, $vars, $fxs, appContext, moduleOutputs } = useAppContext();
48
49
  `;
49
50
  };
50
51
  var genControllerInitCode = (indent, providerName) => {
@@ -190,6 +190,17 @@ var generateTaroProjectJson = function generateTaroProjectJson(result) {
190
190
  // 处理 common 目录下的文件
191
191
  handleCommonDir(commonDir, files);
192
192
 
193
+ // 生成全局 jsModules(如果全局 Fx 中有 JS 计算组件)
194
+ var globalItem = files.find(function (item) {
195
+ return item.type === 'global';
196
+ });
197
+ if (globalItem !== null && globalItem !== void 0 && globalItem.jsModules && globalItem.jsModules.length > 0) {
198
+ commonDir.children.push({
199
+ path: 'src/common/index.jsModules.ts',
200
+ content: genScopedJSModules(globalItem.jsModules, "@mybricks/taro-core", "@/common/jsModulesRuntime")
201
+ });
202
+ }
203
+
193
204
  // 处理 common 目录下的 api.ts
194
205
  var apiItem = files.find(function (item) {
195
206
  return item.type === 'connector-api';
@@ -9,6 +9,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
9
9
  import { ImportManager, indentation } from "./utils";
10
10
  import { handleProcess } from "./utils/logic/handleProcess";
11
11
  import { getSafeVarName } from "./utils/common/string";
12
+ import { extractJSModuleFromCom } from "./utils/context/collectJSModules";
12
13
  var handleGlobal = function handleGlobal(params, config) {
13
14
  var tojson = params.tojson,
14
15
  globalFxs = params.globalFxs,
@@ -98,7 +99,8 @@ var handleGlobal = function handleGlobal(params, config) {
98
99
  }
99
100
  return "value".concat(index, ": any");
100
101
  }).join(", ");
101
- globalFxsInitCode += "".concat(indent, "/** ").concat(event.title, " */") + "\n".concat(indent).concat(event.frameId, ": any = createFx((").concat(values, ") => {") + "\n".concat(res) + "\n".concat(indent, "})\n");
102
+ var fxParams = values ? "".concat(values, ", appContext: any") : "appContext: any";
103
+ globalFxsInitCode += "".concat(indent, "/** ").concat(event.title, " */") + "\n".concat(indent).concat(event.frameId, ": any = createFx((").concat(fxParams, ") => {") + "\n".concat(res) + "\n".concat(indent, "})\n");
102
104
  });
103
105
  var varCode = "/** 全局变量 */" + "\nclass GlobalVars {" + "\n".concat(globalVarsInitCode) + "\n".concat(indent, "init() {") + "".concat(globalVarsRegisterChangeCode) + "\n".concat(indent, "}") + "\n}" + "\n\nexport const globalVars = new GlobalVars()";
104
106
  var fxCode = "/** 全局Fx */" + "\nclass GlobalFxs {" + "\n".concat(globalFxsInitCode) + "}" + "\n\nexport const globalFxs = new GlobalFxs()";
@@ -123,6 +125,22 @@ var handleGlobal = function handleGlobal(params, config) {
123
125
  importType: "named"
124
126
  });
125
127
  }
128
+
129
+ // 收集全局 JS 计算组件(从 fxFrames 的 coms 中提取)
130
+ var globalJsModules = [];
131
+ (tojson.global.fxFrames || []).forEach(function (fxFrame) {
132
+ Object.entries(fxFrame.coms || {}).forEach(function (_ref4) {
133
+ var _ref5 = _slicedToArray(_ref4, 2),
134
+ comId = _ref5[0],
135
+ comInfo = _ref5[1];
136
+ var jsModule = extractJSModuleFromCom(comId, comInfo);
137
+ if (jsModule && !globalJsModules.some(function (m) {
138
+ return m.id === comId;
139
+ })) {
140
+ globalJsModules.push(jsModule);
141
+ }
142
+ });
143
+ });
126
144
  return [{
127
145
  type: "rootConfig",
128
146
  content: JSON.stringify(tojson.rootConfig, null, 2),
@@ -132,7 +150,8 @@ var handleGlobal = function handleGlobal(params, config) {
132
150
  type: "global",
133
151
  content: varCode + "\n\n" + fxCode,
134
152
  importManager: globalImportManager,
135
- name: "global"
153
+ name: "global",
154
+ jsModules: globalJsModules
136
155
  }];
137
156
  };
138
157
  export default handleGlobal;
@@ -4,7 +4,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
4
  import { indentation, genObjectCode, convertComponentStyle, convertStyleAryToCss } from "./utils";
5
5
  import { handleProcess } from "./utils/logic/handleProcess";
6
6
  var handleModule = function handleModule(module, config) {
7
- var _props$style, _config$getComponentC;
7
+ var _props$style;
8
8
  var events = module.events,
9
9
  moduleId = module.moduleId,
10
10
  props = module.props;
@@ -51,10 +51,7 @@ var handleModule = function handleModule(module, config) {
51
51
  currentProvider.controllers.add(module.meta.id);
52
52
  var resultStyle = convertComponentStyle(module.props.style);
53
53
  var cssContent = convertStyleAryToCss((_props$style = props.style) === null || _props$style === void 0 ? void 0 : _props$style.styleAry, module.meta.id);
54
- var componentController = ((_config$getComponentC = config.getComponentController) === null || _config$getComponentC === void 0 ? void 0 : _config$getComponentC.call(config, {
55
- com: module.meta,
56
- scene: config.getCurrentScene()
57
- })) || "controller_".concat(module.meta.id);
54
+ var componentController = module.meta.id;
58
55
  var initialIndent = config.codeStyle.indent * config.depth;
59
56
  var indentView = indentation(initialIndent);
60
57
  var indent2 = indentation(initialIndent + config.codeStyle.indent);
@@ -62,7 +59,7 @@ var handleModule = function handleModule(module, config) {
62
59
  var moduleCode = "".concat(indent2, "<").concat(name) + (config.verbose ? "\n".concat(indent3, "title=\"").concat(module.meta.title, "\"") : "") + (configs ? "\n".concat(indent3, "data={").concat(genObjectCode(configs, {
63
60
  initialIndent: initialIndent + config.codeStyle.indent * 2,
64
61
  indentSize: config.codeStyle.indent
65
- }), "}") : "") + "\n".concat(indent3, "controller={comRefs.current.").concat(componentController, "}") + (comEventCode ? "\n".concat(indent3, "onEvents={{").concat(comEventCode.replace(/\n/g, "\n" + indent3), "}}") : "") + "\n".concat(indent2, "/>");
62
+ }), "}") : "") + "\n".concat(indent3, "parentComRefs={comRefs}") + "\n".concat(indent3, "moduleId=\"").concat(componentController, "\"") + (comEventCode ? "\n".concat(indent3, "onEvents={{").concat(comEventCode.replace(/\n/g, "\n" + indent3), "}}") : "") + "\n".concat(indent2, "/>");
66
63
  var ui = "".concat(indentView, "<View id=\"").concat(module.meta.id, "\" className=\"").concat(module.meta.id, "\" style={").concat(JSON.stringify(resultStyle.root), "}>\n").concat(moduleCode, "\n").concat(indentView, "</View>");
67
64
  return {
68
65
  ui: ui,
@@ -58,9 +58,11 @@ export var processModule = function processModule(params) {
58
58
  });
59
59
  },
60
60
  add: function add(value) {
61
+ var jsModules = Array.from(jsModulesMap.values());
61
62
  addResult(_objectSpread(_objectSpread({}, value), {}, {
62
63
  type: scene.type,
63
- meta: scene
64
+ meta: scene,
65
+ jsModules: jsModules
64
66
  }));
65
67
  },
66
68
  addJSModule: function addJSModule(module) {
@@ -115,8 +117,21 @@ export var processModule = function processModule(params) {
115
117
  // 优先通过 sceneId 查找,如果找不到再通过 id 查找
116
118
  var targetScene = getSceneById(com.sceneId || com.id);
117
119
  if (targetScene || com.isScene) {
118
- var _targetScene$deps, _targetScene$inputs, _targetScene$outputs;
120
+ var _targetScene$deps, _targetScene$inputs, _targetScene$outputs2;
119
121
  var sceneId = (targetScene === null || targetScene === void 0 ? void 0 : targetScene.id) || com.sceneId || com.id;
122
+
123
+ // 当前模块自身的 output → 通过 moduleOutputs 回调
124
+ if (sceneId === scene.id) {
125
+ var _targetScene$outputs;
126
+ var _isOutput = targetScene === null || targetScene === void 0 || (_targetScene$outputs = targetScene.outputs) === null || _targetScene$outputs === void 0 ? void 0 : _targetScene$outputs.some(function (pin) {
127
+ return pin.id === pinId;
128
+ });
129
+ if (_isOutput) {
130
+ return {
131
+ code: "moduleOutputs?.".concat(pinId, "?.(").concat(args || '', ")")
132
+ };
133
+ }
134
+ }
120
135
  var isTargetPopup = (targetScene === null || targetScene === void 0 ? void 0 : targetScene.type) === 'popup' || (targetScene === null || targetScene === void 0 || (_targetScene$deps = targetScene.deps) === null || _targetScene$deps === void 0 ? void 0 : _targetScene$deps.some(function (dep) {
121
136
  return dep.namespace === 'mybricks.taro.popup';
122
137
  }));
@@ -126,7 +141,7 @@ export var processModule = function processModule(params) {
126
141
  var isInput = targetScene === null || targetScene === void 0 || (_targetScene$inputs = targetScene.inputs) === null || _targetScene$inputs === void 0 ? void 0 : _targetScene$inputs.some(function (pin) {
127
142
  return pin.id === pinId;
128
143
  });
129
- var isOutput = targetScene === null || targetScene === void 0 || (_targetScene$outputs = targetScene.outputs) === null || _targetScene$outputs === void 0 ? void 0 : _targetScene$outputs.some(function (pin) {
144
+ var isOutput = targetScene === null || targetScene === void 0 || (_targetScene$outputs2 = targetScene.outputs) === null || _targetScene$outputs2 === void 0 ? void 0 : _targetScene$outputs2.some(function (pin) {
130
145
  return pin.id === pinId;
131
146
  });
132
147
  if (isInput || isOutput) {
@@ -77,7 +77,7 @@
77
77
  },
78
78
  {
79
79
  "path": "src/app.less",
80
- "content": "/* 隐藏 React Refresh 的全屏错误遮罩 */\n#react-refresh-overlay, \niframe[id=\"react-refresh-overlay\"] {\n display: none !important;\n}\n\n.mybricks_taro_systemPage {\n height: 100vh !important;\n}\n\n.mybricks_com{\n flex-shrink: 0;\n min-height: 0; /* 防止子元素撑开父元素 */\n}\n.mybricks_slot{\n width: 100%;\n height: 100%;\n position: relative;\n transform: translateX(0)\n}\n\nview {\n box-sizing: border-box;\n}\n"
80
+ "content": "/* 隐藏 React Refresh 的全屏错误遮罩 */\n#react-refresh-overlay,\niframe[id=\"react-refresh-overlay\"] {\n display: none !important;\n}\n\n/* 系统页面 */\n.mybricks_taro_systemPage {\n height: 100vh !important;\n}\n\n.mybricks_com {\n flex-shrink: 0;\n min-height: 0;\n /* 防止子元素撑开父元素 */\n}\n\n.mybricks_slot {\n width: 100%;\n height: 100%;\n position: relative;\n transform: translateX(0)\n}\n\nview {\n box-sizing: border-box;\n}"
81
81
  },
82
82
  {
83
83
  "path": "src/app.ts",
@@ -137,7 +137,7 @@
137
137
  },
138
138
  {
139
139
  "path": "package.json",
140
- "content": "{\n \"name\": \"checkCom\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"\",\n \"templateInfo\": {\n \"name\": \"default\",\n \"typescript\": true,\n \"css\": \"Less\",\n \"framework\": \"React\"\n },\n \"scripts\": {\n \"prepare\": \"husky\",\n \"new\": \"taro new\",\n \"build:weapp\": \"taro build --type weapp\",\n \"build:swan\": \"taro build --type swan\",\n \"build:alipay\": \"taro build --type alipay\",\n \"build:tt\": \"taro build --type tt\",\n \"build:h5\": \"taro build --type h5\",\n \"build:rn\": \"taro build --type rn\",\n \"build:qq\": \"taro build --type qq\",\n \"build:jd\": \"taro build --type jd\",\n \"build:harmony-hybrid\": \"taro build --type harmony-hybrid\",\n \"dev:weapp\": \"npm run build:weapp -- --watch\",\n \"dev:swan\": \"npm run build:swan -- --watch\",\n \"dev:alipay\": \"npm run build:alipay -- --watch\",\n \"dev:tt\": \"npm run build:tt -- --watch\",\n \"dev:h5\": \"npm run build:h5 -- --watch\",\n \"dev:rn\": \"npm run build:rn -- --watch\",\n \"dev:qq\": \"npm run build:qq -- --watch\",\n \"dev:jd\": \"npm run build:jd -- --watch\",\n \"dev:harmony-hybrid\": \"npm run build:harmony-hybrid -- --watch\"\n },\n \"browserslist\": {\n \"development\": [\n \"defaults and fully supports es6-module\",\n \"maintained node versions\"\n ],\n \"production\": [\n \"last 3 versions\",\n \"Android >= 4.1\",\n \"ios >= 8\"\n ]\n },\n \"author\": \"\",\n \"dependencies\": {\n \"@babel/runtime\": \"^7.24.4\",\n \"@tarojs/components\": \"4.1.9\",\n \"@tarojs/helper\": \"4.1.9\",\n \"@tarojs/plugin-platform-weapp\": \"4.1.9\",\n \"@tarojs/plugin-platform-alipay\": \"4.1.9\",\n \"@tarojs/plugin-platform-tt\": \"4.1.9\",\n \"@tarojs/plugin-platform-swan\": \"4.1.9\",\n \"@tarojs/plugin-platform-jd\": \"4.1.9\",\n \"@tarojs/plugin-platform-qq\": \"4.1.9\",\n \"@tarojs/plugin-platform-h5\": \"4.1.9\",\n \"@tarojs/plugin-platform-harmony-hybrid\": \"4.1.9\",\n \"@tarojs/runtime\": \"4.1.9\",\n \"@tarojs/shared\": \"4.1.9\",\n \"@tarojs/taro\": \"4.1.9\",\n \"@tarojs/plugin-framework-react\": \"4.1.9\",\n \"@tarojs/react\": \"4.1.9\",\n \"react-dom\": \"^18.0.0\",\n \"react\": \"^18.0.0\",\n \"brickd-mobile\": \"^0.0.53\",\n \"@taroify/icons\": \"^0.9.0\",\n \"@types/crypto-js\": \"^4.2.2\",\n \"dayjs\": \"^1.11.19\",\n \"crypto-js\": \"^4.2.0\",\n \"@antv/f2\": \"3.8.12\",\n \"qrcode-generator\": \"^2.0.4\",\n \"lodash\": \"^4.17.21\",\n \"@mybricks/taro-core\": \"^0.1.2\",\n \"@mybricks/taro-components\": \"^0.1.2\"\n },\n \"devDependencies\": {\n \"@tarojs/plugin-generator\": \"4.1.9\",\n \"@commitlint/cli\": \"^19.8.1\",\n \"@commitlint/config-conventional\": \"^19.8.1\",\n \"lint-staged\": \"^16.1.2\",\n \"husky\": \"^9.1.7\",\n \"stylelint-config-standard\": \"^38.0.0\",\n \"@babel/core\": \"^7.24.4\",\n \"@tarojs/cli\": \"4.1.9\",\n \"@babel/plugin-transform-class-properties\": \"7.25.9\",\n \"@types/webpack-env\": \"^1.13.6\",\n \"@types/react\": \"^18.0.0\",\n \"webpack\": \"5.91.0\",\n \"@tarojs/taro-loader\": \"4.1.9\",\n \"@tarojs/webpack5-runner\": \"4.1.9\",\n \"less\": \"^4.2.0\",\n \"babel-preset-taro\": \"4.1.9\",\n \"eslint-config-taro\": \"4.1.9\",\n \"eslint\": \"^8.57.0\",\n \"@pmmmwh/react-refresh-webpack-plugin\": \"^0.5.5\",\n \"react-refresh\": \"^0.14.0\",\n \"@babel/preset-react\": \"^7.24.1\",\n \"eslint-plugin-react\": \"^7.34.1\",\n \"eslint-plugin-react-hooks\": \"^4.4.0\",\n \"stylelint\": \"^16.4.0\",\n \"typescript\": \"^5.4.5\",\n \"tsconfig-paths-webpack-plugin\": \"^4.1.0\",\n \"postcss\": \"^8.5.6\",\n \"@types/node\": \"^18\",\n \"@types/minimatch\": \"^5\"\n }\n}\n"
140
+ "content": "{\n \"name\": \"checkCom\",\n \"version\": \"1.0.0\",\n \"private\": true,\n \"description\": \"\",\n \"templateInfo\": {\n \"name\": \"default\",\n \"typescript\": true,\n \"css\": \"Less\",\n \"framework\": \"React\"\n },\n \"scripts\": {\n \"prepare\": \"husky\",\n \"new\": \"taro new\",\n \"build:weapp\": \"taro build --type weapp\",\n \"build:swan\": \"taro build --type swan\",\n \"build:alipay\": \"taro build --type alipay\",\n \"build:tt\": \"taro build --type tt\",\n \"build:h5\": \"taro build --type h5\",\n \"build:rn\": \"taro build --type rn\",\n \"build:qq\": \"taro build --type qq\",\n \"build:jd\": \"taro build --type jd\",\n \"build:harmony-hybrid\": \"taro build --type harmony-hybrid\",\n \"dev:weapp\": \"npm run build:weapp -- --watch\",\n \"dev:swan\": \"npm run build:swan -- --watch\",\n \"dev:alipay\": \"npm run build:alipay -- --watch\",\n \"dev:tt\": \"npm run build:tt -- --watch\",\n \"dev:h5\": \"npm run build:h5 -- --watch\",\n \"dev:rn\": \"npm run build:rn -- --watch\",\n \"dev:qq\": \"npm run build:qq -- --watch\",\n \"dev:jd\": \"npm run build:jd -- --watch\",\n \"dev:harmony-hybrid\": \"npm run build:harmony-hybrid -- --watch\"\n },\n \"browserslist\": {\n \"development\": [\n \"defaults and fully supports es6-module\",\n \"maintained node versions\"\n ],\n \"production\": [\n \"last 3 versions\",\n \"Android >= 4.1\",\n \"ios >= 8\"\n ]\n },\n \"author\": \"\",\n \"dependencies\": {\n \"@babel/runtime\": \"^7.24.4\",\n \"@tarojs/components\": \"4.1.9\",\n \"@tarojs/helper\": \"4.1.9\",\n \"@tarojs/plugin-platform-weapp\": \"4.1.9\",\n \"@tarojs/plugin-platform-alipay\": \"4.1.9\",\n \"@tarojs/plugin-platform-tt\": \"4.1.9\",\n \"@tarojs/plugin-platform-swan\": \"4.1.9\",\n \"@tarojs/plugin-platform-jd\": \"4.1.9\",\n \"@tarojs/plugin-platform-qq\": \"4.1.9\",\n \"@tarojs/plugin-platform-h5\": \"4.1.9\",\n \"@tarojs/plugin-platform-harmony-hybrid\": \"4.1.9\",\n \"@tarojs/runtime\": \"4.1.9\",\n \"@tarojs/shared\": \"4.1.9\",\n \"@tarojs/taro\": \"4.1.9\",\n \"@tarojs/plugin-framework-react\": \"4.1.9\",\n \"@tarojs/react\": \"4.1.9\",\n \"react-dom\": \"^18.0.0\",\n \"react\": \"^18.0.0\",\n \"brickd-mobile\": \"^0.0.53\",\n \"@taroify/icons\": \"^0.9.0\",\n \"@types/crypto-js\": \"^4.2.2\",\n \"dayjs\": \"^1.11.19\",\n \"crypto-js\": \"^4.2.0\",\n \"@antv/f2\": \"3.8.12\",\n \"qrcode-generator\": \"^2.0.4\",\n \"lodash\": \"^4.17.21\",\n \"@mybricks/taro-core\": \"^0.1.3\",\n \"@mybricks/taro-components\": \"^0.1.2\"\n },\n \"devDependencies\": {\n \"@tarojs/plugin-generator\": \"4.1.9\",\n \"@commitlint/cli\": \"^19.8.1\",\n \"@commitlint/config-conventional\": \"^19.8.1\",\n \"lint-staged\": \"^16.1.2\",\n \"husky\": \"^9.1.7\",\n \"stylelint-config-standard\": \"^38.0.0\",\n \"@babel/core\": \"^7.24.4\",\n \"@tarojs/cli\": \"4.1.9\",\n \"@babel/plugin-transform-class-properties\": \"7.25.9\",\n \"@types/webpack-env\": \"^1.13.6\",\n \"@types/react\": \"^18.0.0\",\n \"webpack\": \"5.91.0\",\n \"@tarojs/taro-loader\": \"4.1.9\",\n \"@tarojs/webpack5-runner\": \"4.1.9\",\n \"less\": \"^4.2.0\",\n \"babel-preset-taro\": \"4.1.9\",\n \"eslint-config-taro\": \"4.1.9\",\n \"eslint\": \"^8.57.0\",\n \"@pmmmwh/react-refresh-webpack-plugin\": \"^0.5.5\",\n \"react-refresh\": \"^0.14.0\",\n \"@babel/preset-react\": \"^7.24.1\",\n \"eslint-plugin-react\": \"^7.34.1\",\n \"eslint-plugin-react-hooks\": \"^4.4.0\",\n \"stylelint\": \"^16.4.0\",\n \"typescript\": \"^5.4.5\",\n \"tsconfig-paths-webpack-plugin\": \"^4.1.0\",\n \"postcss\": \"^8.5.6\",\n \"@types/node\": \"^18\",\n \"@types/minimatch\": \"^5\"\n }\n}\n"
141
141
  },
142
142
  {
143
143
  "path": "project.config.json",
@@ -187,7 +187,7 @@ export var handleProcess = function handleProcess(event, config) {
187
187
  isSameScope: isSameScope,
188
188
  props: props
189
189
  }, config);
190
- code += "".concat(indent, "/** ").concat(props.title, " \u53D8\u91CF ").concat(props.meta.title, " */") + "\n".concat(indent).concat(nextCode, "this.$vars.").concat(varKey, ".").concat(props.id, "(").concat(nextValue).concat(xpathArg, ")");
190
+ code += "".concat(indent, "/** ").concat(props.title, " \u53D8\u91CF ").concat(props.meta.title, " */") + "\n".concat(indent).concat(nextCode, "$vars.current.").concat(varKey, ".").concat(props.id, "(").concat(nextValue).concat(xpathArg, ")");
191
191
  }
192
192
  } else if (category === "fx") {
193
193
  if (props.meta.global) {
@@ -196,13 +196,13 @@ export var handleProcess = function handleProcess(event, config) {
196
196
  dependencyNames: ["globalFxs"],
197
197
  importType: "named"
198
198
  });
199
- code += "".concat(indent, "/** \u8C03\u7528\u5168\u5C40Fx ").concat(props.meta.title, " */") + "\n".concat(indent).concat(nextCode, "globalFxs.").concat(props.meta.ioProxy.id, "(").concat(nextValue, ")");
199
+ code += "".concat(indent, "/** \u8C03\u7528\u5168\u5C40Fx ").concat(props.meta.title, " */") + "\n".concat(indent).concat(nextCode, "globalFxs.").concat(props.meta.ioProxy.id, "(").concat(nextValue).concat(nextValue ? ', ' : '', "appContext)");
200
200
  } else {
201
201
  var _currentProvider = getCurrentProvider({
202
202
  isSameScope: isSameScope,
203
203
  props: props
204
204
  }, config);
205
- code += "".concat(indent, "/** \u8C03\u7528Fx ").concat(props.meta.title, " */") + "\n".concat(indent).concat(nextCode, "this.$fxs.").concat(props.meta.ioProxy.id, "(").concat(nextValue, ")");
205
+ code += "".concat(indent, "/** \u8C03\u7528Fx ").concat(props.meta.title, " */") + "\n".concat(indent).concat(nextCode, "$fxs.current.").concat(props.meta.ioProxy.id, "(").concat(nextValue, ")");
206
206
  }
207
207
  }
208
208
  } else {
@@ -235,7 +235,7 @@ export var handleProcess = function handleProcess(event, config) {
235
235
  return pre + "".concat(indent2).concat(id, ": undefined,\n");
236
236
  } else {
237
237
  var next = outputs.map(function (output) {
238
- return getNextValueWithParam(output, config, event);
238
+ return getNextValueWithParam(output, config, event, outputToInputPinMap);
239
239
  }).join(", ");
240
240
  return pre + "".concat(indent2).concat(id, ": ").concat(next, ",\n");
241
241
  }
@@ -382,8 +382,8 @@ var getNextValue = function getNextValue(props, config, event, outputToInputPinM
382
382
  });
383
383
  return nextValue.join(", ");
384
384
  };
385
- var getNextValueWithParam = function getNextValueWithParam(param, config, event) {
386
- var _param$meta5, _param$meta6;
385
+ var getNextValueWithParam = function getNextValueWithParam(param, config, event, outputToInputPinMap) {
386
+ var _param$meta5, _param$meta6, _param$meta8;
387
387
  if (param.type === "params") {
388
388
  var params = config.getParams();
389
389
  return params[param.id];
@@ -396,16 +396,20 @@ var getNextValueWithParam = function getNextValueWithParam(param, config, event)
396
396
  var componentNameWithId = getComponentNameWithId(param, config, event);
397
397
  // 变量组件直接返回 Subject
398
398
  if ((_param$meta6 = param.meta) !== null && _param$meta6 !== void 0 && (_param$meta6 = _param$meta6.def) !== null && _param$meta6 !== void 0 && (_param$meta6 = _param$meta6.namespace) !== null && _param$meta6 !== void 0 && _param$meta6.includes(".var")) {
399
- var _connectId = param.connectId;
400
- if (_connectId) {
401
- return "".concat(componentNameWithId, "_").concat(_connectId, "_result");
399
+ var _param$meta7;
400
+ var _key2 = "".concat((_param$meta7 = param.meta) === null || _param$meta7 === void 0 ? void 0 : _param$meta7.id, "_").concat(param.id);
401
+ var _fullVarName2 = outputToInputPinMap === null || outputToInputPinMap === void 0 ? void 0 : outputToInputPinMap.get(_key2);
402
+ if (_fullVarName2) {
403
+ return _fullVarName2;
402
404
  }
403
405
  return "".concat(componentNameWithId, "_result");
404
406
  }
405
- // 使用 connectId(连接ID)来引用对应的 result 变量
406
- var connectId = param.connectId;
407
- if (connectId) {
408
- return "".concat(componentNameWithId, "_").concat(connectId, "_result.").concat(param.id);
407
+
408
+ // outputToInputPinMap 中查找完整变量名(已包含去重后缀)
409
+ var key = "".concat((_param$meta8 = param.meta) === null || _param$meta8 === void 0 ? void 0 : _param$meta8.id, "_").concat(param.id);
410
+ var fullVarName = outputToInputPinMap === null || outputToInputPinMap === void 0 ? void 0 : outputToInputPinMap.get(key);
411
+ if (fullVarName) {
412
+ return "".concat(fullVarName, ".").concat(param.id);
409
413
  }
410
414
  return "".concat(componentNameWithId, "_result.").concat(param.id);
411
415
  };
@@ -95,6 +95,17 @@ export var convertRootStyle = function convertRootStyle(style) {
95
95
  handleLayoutProp(value, rootStyle);
96
96
  return;
97
97
  }
98
+
99
+ // widthAuto、heightAuto、widthFull、heightFull
100
+ if (key === "widthAuto" && value === true) {
101
+ rootStyle["width"] = "auto";
102
+ } else if (key === "heightAuto" && value === true) {
103
+ rootStyle["height"] = "auto";
104
+ } else if (key === "widthFull" && value === true) {
105
+ rootStyle["width"] = "100%";
106
+ } else if (key === "heightFull" && value === true) {
107
+ rootStyle["height"] = "100%";
108
+ }
98
109
  var camelKey = key.includes("-") ? kebabToCamel(key) : key;
99
110
  rootStyle[camelKey] = transformStyleValue(camelKey, value);
100
111
  });
@@ -55,7 +55,7 @@ export var RenderManager = /*#__PURE__*/function () {
55
55
  code += "".concat(indent, "/** ").concat(description, " */\n");
56
56
  }
57
57
  code += "".concat(indent, "function ").concat(renderFunctionName, "(params: any) {\n");
58
- code += "".concat(indent).concat(indent2, "const { comRefs, $vars, $fxs, appContext } = useAppContext();\n");
58
+ code += "".concat(indent).concat(indent2, "const { comRefs, $vars, $fxs, appContext, moduleOutputs } = useAppContext();\n");
59
59
  if (logicCode !== null && logicCode !== void 0 && logicCode.includes('$outputs')) {
60
60
  code += "".concat(indent).concat(indent2, "const $outputs = comRefs.current.$outputs;\n");
61
61
  }
@@ -8,7 +8,7 @@ export var genRootDefineCode = function genRootDefineCode(indent, utilsPackageNa
8
8
  var hasJsModules = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
9
9
  var isModule = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
10
10
  // 使用 useAppContext 获取 comRefs / $vars / $fxs / appContext
11
- var code = "".concat(indent, "const {comRefs, $vars, $fxs, appContext} = useAppContext();\n");
11
+ var code = isModule ? "".concat(indent, "const {comRefs, $vars, $fxs, appContext, moduleOutputs} = useAppContext();\n") : "".concat(indent, "const {comRefs, $vars, $fxs, appContext} = useAppContext();\n");
12
12
  if (!isModule) {
13
13
  code += "".concat(indent, "usePageLife();\n");
14
14
  }
@@ -21,8 +21,7 @@ export var genRootDefineCode = function genRootDefineCode(indent, utilsPackageNa
21
21
 
22
22
  /** 生成普通插槽定义代码 */
23
23
  export var genSlotDefineCode = function genSlotDefineCode(indent) {
24
- // 插槽内部也使用 useAppContext,获取 comRefs / $vars / $fxs / appContext
25
- return "".concat(indent, "const {comRefs, $vars, $fxs, appContext} = useAppContext();\n");
24
+ return "".concat(indent, "const { comRefs, $vars, $fxs, appContext, moduleOutputs } = useAppContext();\n");
26
25
  };
27
26
 
28
27
  /** 生成控制器初始化代码 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mybricks/to-code-taro",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "description": "To code for Taro",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",