@mybricks/to-code-taro 1.2.7 → 1.2.8
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.
- package/package.json +1 -1
- package/dist/cjs/abstractEventTypeDef.d.ts +0 -11
- package/dist/cjs/abstractEventTypeDef.js +0 -93
- package/dist/cjs/generate/compressImages.d.ts +0 -16
- package/dist/cjs/generate/compressImages.js +0 -76
- package/dist/cjs/generate/generateTaroProjectJson.d.ts +0 -13
- package/dist/cjs/generate/generateTaroProjectJson.js +0 -225
- package/dist/cjs/generate/generateTaroTempalteJson.d.ts +0 -15
- package/dist/cjs/generate/generateTaroTempalteJson.js +0 -103
- package/dist/cjs/generate/utils/appConfig.d.ts +0 -21
- package/dist/cjs/generate/utils/appConfig.js +0 -57
- package/dist/cjs/generate/utils/commonDir.d.ts +0 -21
- package/dist/cjs/generate/utils/commonDir.js +0 -63
- package/dist/cjs/generate/utils/customTabBar.d.ts +0 -11
- package/dist/cjs/generate/utils/customTabBar.js +0 -73
- package/dist/cjs/generate/utils/fileNode.d.ts +0 -21
- package/dist/cjs/generate/utils/fileNode.js +0 -67
- package/dist/cjs/generate/utils/index.d.ts +0 -7
- package/dist/cjs/generate/utils/index.js +0 -29
- package/dist/cjs/generate/utils/pageImages.d.ts +0 -14
- package/dist/cjs/generate/utils/pageImages.js +0 -36
- package/dist/cjs/generate/utils/tabBarImages.d.ts +0 -14
- package/dist/cjs/generate/utils/tabBarImages.js +0 -36
- package/dist/cjs/handleCom.d.ts +0 -8
- package/dist/cjs/handleCom.js +0 -280
- package/dist/cjs/handleDom.d.ts +0 -21
- package/dist/cjs/handleDom.js +0 -52
- package/dist/cjs/handleExtension.d.ts +0 -10
- package/dist/cjs/handleExtension.js +0 -300
- package/dist/cjs/handleGlobal.d.ts +0 -11
- package/dist/cjs/handleGlobal.js +0 -191
- package/dist/cjs/handleModule.d.ts +0 -15
- package/dist/cjs/handleModule.js +0 -104
- package/dist/cjs/handleSlot.d.ts +0 -29
- package/dist/cjs/handleSlot.js +0 -153
- package/dist/cjs/index.d.ts +0 -4
- package/dist/cjs/index.js +0 -48
- package/dist/cjs/processors/processComEvents.d.ts +0 -9
- package/dist/cjs/processors/processComEvents.js +0 -163
- package/dist/cjs/processors/processModule.d.ts +0 -31
- package/dist/cjs/processors/processModule.js +0 -159
- package/dist/cjs/processors/processScene.d.ts +0 -32
- package/dist/cjs/processors/processScene.js +0 -198
- package/dist/cjs/processors/processSceneLogic.d.ts +0 -7
- package/dist/cjs/processors/processSceneLogic.js +0 -230
- package/dist/cjs/shims-taro.d.ts +0 -20
- package/dist/cjs/taro-template.json +0 -154
- package/dist/cjs/toCodeTaro.d.ts +0 -168
- package/dist/cjs/toCodeTaro.js +0 -326
- package/dist/cjs/utils/builder/buildResult.d.ts +0 -24
- package/dist/cjs/utils/builder/buildResult.js +0 -163
- package/dist/cjs/utils/common/ImportManager.d.ts +0 -26
- package/dist/cjs/utils/common/ImportManager.js +0 -123
- package/dist/cjs/utils/common/helper.d.ts +0 -12
- package/dist/cjs/utils/common/helper.js +0 -52
- package/dist/cjs/utils/common/object.d.ts +0 -5
- package/dist/cjs/utils/common/object.js +0 -58
- package/dist/cjs/utils/common/string.d.ts +0 -18
- package/dist/cjs/utils/common/string.js +0 -59
- package/dist/cjs/utils/config/content/converter.d.ts +0 -17
- package/dist/cjs/utils/config/content/converter.js +0 -84
- package/dist/cjs/utils/config/content/index.d.ts +0 -10
- package/dist/cjs/utils/config/content/index.js +0 -33
- package/dist/cjs/utils/config/content/pageConfig.d.ts +0 -10
- package/dist/cjs/utils/config/content/pageConfig.js +0 -80
- package/dist/cjs/utils/config/content/saveBase64Image.d.ts +0 -24
- package/dist/cjs/utils/config/content/saveBase64Image.js +0 -113
- package/dist/cjs/utils/config/content/tabBarConfig.d.ts +0 -28
- package/dist/cjs/utils/config/content/tabBarConfig.js +0 -74
- package/dist/cjs/utils/config/content/types.d.ts +0 -73
- package/dist/cjs/utils/config/content/types.js +0 -17
- package/dist/cjs/utils/config/content/validator.d.ts +0 -13
- package/dist/cjs/utils/config/content/validator.js +0 -67
- package/dist/cjs/utils/config/handlePageConfig.d.ts +0 -31
- package/dist/cjs/utils/config/handlePageConfig.js +0 -88
- package/dist/cjs/utils/context/buildContext.d.ts +0 -31
- package/dist/cjs/utils/context/buildContext.js +0 -76
- package/dist/cjs/utils/context/buildFrameMap.d.ts +0 -16
- package/dist/cjs/utils/context/buildFrameMap.js +0 -106
- package/dist/cjs/utils/context/buildGlobalData.d.ts +0 -13
- package/dist/cjs/utils/context/buildGlobalData.js +0 -58
- package/dist/cjs/utils/context/collectJSModules.d.ts +0 -41
- package/dist/cjs/utils/context/collectJSModules.js +0 -93
- package/dist/cjs/utils/context/createEventQueries.d.ts +0 -45
- package/dist/cjs/utils/context/createEventQueries.js +0 -99
- package/dist/cjs/utils/context/createProvider.d.ts +0 -21
- package/dist/cjs/utils/context/createProvider.js +0 -49
- package/dist/cjs/utils/index.d.ts +0 -10
- package/dist/cjs/utils/index.js +0 -60
- package/dist/cjs/utils/logic/convertNamespace.d.ts +0 -11
- package/dist/cjs/utils/logic/convertNamespace.js +0 -43
- package/dist/cjs/utils/logic/genJSModules.d.ts +0 -16
- package/dist/cjs/utils/logic/genJSModules.js +0 -114
- package/dist/cjs/utils/logic/handleProcess.d.ts +0 -9
- package/dist/cjs/utils/logic/handleProcess.js +0 -462
- package/dist/cjs/utils/logic/processChildren.d.ts +0 -26
- package/dist/cjs/utils/logic/processChildren.js +0 -121
- package/dist/cjs/utils/style/color.d.ts +0 -4
- package/dist/cjs/utils/style/color.js +0 -45
- package/dist/cjs/utils/style/converter.d.ts +0 -7
- package/dist/cjs/utils/style/converter.js +0 -175
- package/dist/cjs/utils/style/getComponentClassName.d.ts +0 -16
- package/dist/cjs/utils/style/getComponentClassName.js +0 -47
- package/dist/cjs/utils/style/pxtransform.d.ts +0 -4
- package/dist/cjs/utils/style/pxtransform.js +0 -62
- package/dist/cjs/utils/style/types.d.ts +0 -23
- package/dist/cjs/utils/style/types.js +0 -17
- package/dist/cjs/utils/templates/component.d.ts +0 -19
- package/dist/cjs/utils/templates/component.js +0 -86
- package/dist/cjs/utils/templates/index.d.ts +0 -32
- package/dist/cjs/utils/templates/index.js +0 -116
- package/dist/cjs/utils/templates/renderManager.d.ts +0 -18
- package/dist/cjs/utils/templates/renderManager.js +0 -152
- package/dist/cjs/utils/templates/scene.d.ts +0 -23
- package/dist/cjs/utils/templates/scene.js +0 -113
- package/dist/esm/abstractEventTypeDef.d.ts +0 -11
- package/dist/esm/abstractEventTypeDef.js +0 -63
- package/dist/esm/generate/compressImages.d.ts +0 -16
- package/dist/esm/generate/compressImages.js +0 -108
- package/dist/esm/generate/generateTaroProjectJson.d.ts +0 -13
- package/dist/esm/generate/generateTaroProjectJson.js +0 -228
- package/dist/esm/generate/generateTaroTempalteJson.d.ts +0 -15
- package/dist/esm/generate/generateTaroTempalteJson.js +0 -94
- package/dist/esm/generate/utils/appConfig.d.ts +0 -21
- package/dist/esm/generate/utils/appConfig.js +0 -49
- package/dist/esm/generate/utils/commonDir.d.ts +0 -21
- package/dist/esm/generate/utils/commonDir.js +0 -53
- package/dist/esm/generate/utils/customTabBar.d.ts +0 -11
- package/dist/esm/generate/utils/customTabBar.js +0 -52
- package/dist/esm/generate/utils/fileNode.d.ts +0 -21
- package/dist/esm/generate/utils/fileNode.js +0 -62
- package/dist/esm/generate/utils/index.d.ts +0 -7
- package/dist/esm/generate/utils/index.js +0 -8
- package/dist/esm/generate/utils/pageImages.d.ts +0 -14
- package/dist/esm/generate/utils/pageImages.js +0 -15
- package/dist/esm/generate/utils/tabBarImages.d.ts +0 -14
- package/dist/esm/generate/utils/tabBarImages.js +0 -15
- package/dist/esm/handleCom.d.ts +0 -8
- package/dist/esm/handleCom.js +0 -350
- package/dist/esm/handleDom.d.ts +0 -21
- package/dist/esm/handleDom.js +0 -26
- package/dist/esm/handleExtension.d.ts +0 -10
- package/dist/esm/handleExtension.js +0 -243
- package/dist/esm/handleGlobal.d.ts +0 -11
- package/dist/esm/handleGlobal.js +0 -157
- package/dist/esm/handleModule.d.ts +0 -15
- package/dist/esm/handleModule.js +0 -73
- package/dist/esm/handleSlot.d.ts +0 -29
- package/dist/esm/handleSlot.js +0 -215
- package/dist/esm/index.d.ts +0 -4
- package/dist/esm/index.js +0 -4
- package/dist/esm/processors/processComEvents.d.ts +0 -9
- package/dist/esm/processors/processComEvents.js +0 -170
- package/dist/esm/processors/processModule.d.ts +0 -31
- package/dist/esm/processors/processModule.js +0 -177
- package/dist/esm/processors/processScene.d.ts +0 -32
- package/dist/esm/processors/processScene.js +0 -234
- package/dist/esm/processors/processSceneLogic.d.ts +0 -7
- package/dist/esm/processors/processSceneLogic.js +0 -247
- package/dist/esm/shims-taro.d.ts +0 -20
- package/dist/esm/taro-template.json +0 -154
- package/dist/esm/toCodeTaro.d.ts +0 -168
- package/dist/esm/toCodeTaro.js +0 -367
- package/dist/esm/utils/builder/buildResult.d.ts +0 -24
- package/dist/esm/utils/builder/buildResult.js +0 -119
- package/dist/esm/utils/common/ImportManager.d.ts +0 -26
- package/dist/esm/utils/common/ImportManager.js +0 -131
- package/dist/esm/utils/common/helper.d.ts +0 -12
- package/dist/esm/utils/common/helper.js +0 -33
- package/dist/esm/utils/common/object.d.ts +0 -5
- package/dist/esm/utils/common/object.js +0 -32
- package/dist/esm/utils/common/string.d.ts +0 -18
- package/dist/esm/utils/common/string.js +0 -37
- package/dist/esm/utils/config/content/converter.d.ts +0 -17
- package/dist/esm/utils/config/content/converter.js +0 -106
- package/dist/esm/utils/config/content/index.d.ts +0 -10
- package/dist/esm/utils/config/content/index.js +0 -11
- package/dist/esm/utils/config/content/pageConfig.d.ts +0 -10
- package/dist/esm/utils/config/content/pageConfig.js +0 -43
- package/dist/esm/utils/config/content/saveBase64Image.d.ts +0 -24
- package/dist/esm/utils/config/content/saveBase64Image.js +0 -127
- package/dist/esm/utils/config/content/tabBarConfig.d.ts +0 -28
- package/dist/esm/utils/config/content/tabBarConfig.js +0 -89
- package/dist/esm/utils/config/content/types.d.ts +0 -73
- package/dist/esm/utils/config/content/types.js +0 -1
- package/dist/esm/utils/config/content/validator.d.ts +0 -13
- package/dist/esm/utils/config/content/validator.js +0 -64
- package/dist/esm/utils/config/handlePageConfig.d.ts +0 -31
- package/dist/esm/utils/config/handlePageConfig.js +0 -89
- package/dist/esm/utils/context/buildContext.d.ts +0 -31
- package/dist/esm/utils/context/buildContext.js +0 -65
- package/dist/esm/utils/context/buildFrameMap.d.ts +0 -16
- package/dist/esm/utils/context/buildFrameMap.js +0 -131
- package/dist/esm/utils/context/buildGlobalData.d.ts +0 -13
- package/dist/esm/utils/context/buildGlobalData.js +0 -44
- package/dist/esm/utils/context/collectJSModules.d.ts +0 -41
- package/dist/esm/utils/context/collectJSModules.js +0 -87
- package/dist/esm/utils/context/createEventQueries.d.ts +0 -45
- package/dist/esm/utils/context/createEventQueries.js +0 -99
- package/dist/esm/utils/context/createProvider.d.ts +0 -21
- package/dist/esm/utils/context/createProvider.js +0 -33
- package/dist/esm/utils/index.d.ts +0 -10
- package/dist/esm/utils/index.js +0 -12
- package/dist/esm/utils/logic/convertNamespace.d.ts +0 -11
- package/dist/esm/utils/logic/convertNamespace.js +0 -27
- package/dist/esm/utils/logic/genJSModules.d.ts +0 -16
- package/dist/esm/utils/logic/genJSModules.js +0 -33
- package/dist/esm/utils/logic/handleProcess.d.ts +0 -9
- package/dist/esm/utils/logic/handleProcess.js +0 -520
- package/dist/esm/utils/logic/processChildren.d.ts +0 -26
- package/dist/esm/utils/logic/processChildren.js +0 -101
- package/dist/esm/utils/style/color.d.ts +0 -4
- package/dist/esm/utils/style/color.js +0 -17
- package/dist/esm/utils/style/converter.d.ts +0 -7
- package/dist/esm/utils/style/converter.js +0 -175
- package/dist/esm/utils/style/getComponentClassName.d.ts +0 -16
- package/dist/esm/utils/style/getComponentClassName.js +0 -37
- package/dist/esm/utils/style/pxtransform.d.ts +0 -4
- package/dist/esm/utils/style/pxtransform.js +0 -54
- package/dist/esm/utils/style/types.d.ts +0 -23
- package/dist/esm/utils/style/types.js +0 -1
- package/dist/esm/utils/templates/component.d.ts +0 -19
- package/dist/esm/utils/templates/component.js +0 -55
- package/dist/esm/utils/templates/index.d.ts +0 -32
- package/dist/esm/utils/templates/index.js +0 -97
- package/dist/esm/utils/templates/renderManager.d.ts +0 -18
- package/dist/esm/utils/templates/renderManager.js +0 -145
- package/dist/esm/utils/templates/scene.d.ts +0 -23
- package/dist/esm/utils/templates/scene.js +0 -66
package/dist/cjs/handleModule.js
DELETED
|
@@ -1,104 +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/handleModule.ts
|
|
20
|
-
var handleModule_exports = {};
|
|
21
|
-
__export(handleModule_exports, {
|
|
22
|
-
default: () => handleModule_default
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(handleModule_exports);
|
|
25
|
-
var import_utils = require("./utils");
|
|
26
|
-
var import_handleProcess = require("./utils/logic/handleProcess");
|
|
27
|
-
var handleModule = (module2, config) => {
|
|
28
|
-
var _a;
|
|
29
|
-
const { events, moduleId, props } = module2;
|
|
30
|
-
const name = `C${String(moduleId).replace(/[^a-zA-Z0-9]/g, "_").toUpperCase()}`;
|
|
31
|
-
let comEventCode = "";
|
|
32
|
-
const indent = (0, import_utils.indentation)(config.codeStyle.indent * (config.depth + 1));
|
|
33
|
-
Object.entries(events).forEach(([eventId, { diagramId }]) => {
|
|
34
|
-
if (!diagramId) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const event = config.getEventByDiagramId(diagramId);
|
|
38
|
-
if (!event) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const defaultValue = "value";
|
|
42
|
-
let process = (0, import_handleProcess.handleProcess)(event, {
|
|
43
|
-
...config,
|
|
44
|
-
depth: config.depth + 2,
|
|
45
|
-
addParentDependencyImport: config.addParentDependencyImport,
|
|
46
|
-
getParams: () => {
|
|
47
|
-
return {
|
|
48
|
-
[eventId]: defaultValue
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
if (process.includes("pageParams")) {
|
|
53
|
-
config.addParentDependencyImport({
|
|
54
|
-
packageName: config.getComponentPackageName(),
|
|
55
|
-
dependencyNames: ["page", "SUBJECT_VALUE"],
|
|
56
|
-
importType: "named"
|
|
57
|
-
});
|
|
58
|
-
process = (0, import_utils.indentation)(config.codeStyle.indent * (config.depth + 2)) + `const pageParams: any = page.getParams("${config.getCurrentScene().id}")[SUBJECT_VALUE];
|
|
59
|
-
` + process;
|
|
60
|
-
}
|
|
61
|
-
comEventCode += `${indent}${eventId}: (${defaultValue}: any) => {
|
|
62
|
-
` + process + `
|
|
63
|
-
${indent}},
|
|
64
|
-
`;
|
|
65
|
-
});
|
|
66
|
-
config.addParentDependencyImport({
|
|
67
|
-
packageName: "@/components/Index",
|
|
68
|
-
dependencyNames: [name],
|
|
69
|
-
importType: "named"
|
|
70
|
-
});
|
|
71
|
-
const configs = module2.meta.model.data.configs;
|
|
72
|
-
const currentProvider = config.getCurrentProvider();
|
|
73
|
-
currentProvider.coms.add(module2.meta.id);
|
|
74
|
-
currentProvider.controllers.add(module2.meta.id);
|
|
75
|
-
const resultStyle = (0, import_utils.convertComponentStyle)(module2.props.style);
|
|
76
|
-
const cssContent = (0, import_utils.convertStyleAryToCss)((_a = props.style) == null ? void 0 : _a.styleAry, module2.meta.id);
|
|
77
|
-
const componentController = module2.meta.id;
|
|
78
|
-
const initialIndent = config.codeStyle.indent * config.depth;
|
|
79
|
-
const indentView = (0, import_utils.indentation)(initialIndent);
|
|
80
|
-
const indent2 = (0, import_utils.indentation)(initialIndent + config.codeStyle.indent);
|
|
81
|
-
const indent3 = (0, import_utils.indentation)(initialIndent + config.codeStyle.indent * 2);
|
|
82
|
-
const moduleCode = `${indent2}<${name}` + (config.verbose ? `
|
|
83
|
-
${indent3}title="${module2.meta.title}"` : "") + (configs ? `
|
|
84
|
-
${indent3}data={${(0, import_utils.genObjectCode)(configs, {
|
|
85
|
-
initialIndent: initialIndent + config.codeStyle.indent * 2,
|
|
86
|
-
indentSize: config.codeStyle.indent
|
|
87
|
-
})}}` : "") + `
|
|
88
|
-
${indent3}parentComRefs={comRefs}
|
|
89
|
-
${indent3}moduleId="${componentController}"` + (comEventCode ? `
|
|
90
|
-
${indent3}onEvents={{${comEventCode.replace(/\n/g, "\n" + indent3)}}}` : "") + `
|
|
91
|
-
${indent2}/>`;
|
|
92
|
-
const ui = `${indentView}<View id="${module2.meta.id}" className="${module2.meta.id}" style={${JSON.stringify(resultStyle.root)}}>
|
|
93
|
-
${moduleCode}
|
|
94
|
-
${indentView}</View>`;
|
|
95
|
-
return {
|
|
96
|
-
ui,
|
|
97
|
-
cssContent
|
|
98
|
-
};
|
|
99
|
-
return {
|
|
100
|
-
ui,
|
|
101
|
-
cssContent
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
var handleModule_default = handleModule;
|
package/dist/cjs/handleSlot.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ImportManager } from "./utils";
|
|
2
|
-
import { RenderManager } from "./utils/templates/renderManager";
|
|
3
|
-
import type { UI, BaseConfig } from "./toCodeTaro";
|
|
4
|
-
interface HandleSlotConfig extends BaseConfig {
|
|
5
|
-
addParentDependencyImport?: (typeof ImportManager)["prototype"]["addImport"];
|
|
6
|
-
addComId?: (comId: string) => void;
|
|
7
|
-
addConsumer?: (provider: ReturnType<BaseConfig["getCurrentProvider"]>) => void;
|
|
8
|
-
checkIsRoot: () => boolean;
|
|
9
|
-
renderManager?: RenderManager;
|
|
10
|
-
addJSModule?: (module: any) => void;
|
|
11
|
-
isPopup?: boolean;
|
|
12
|
-
isModule?: boolean;
|
|
13
|
-
hasPopups?: boolean;
|
|
14
|
-
/** handleCom 处理 slots 时的 slot key(如 item/content),用于识别 scope 入参 */
|
|
15
|
-
slotKey?: string;
|
|
16
|
-
/** 父组件 id(用于给插槽根容器打标 className) */
|
|
17
|
-
parentComId?: string;
|
|
18
|
-
}
|
|
19
|
-
declare const handleSlot: (ui: UI, config: HandleSlotConfig) => {
|
|
20
|
-
js: string;
|
|
21
|
-
combinedJsCode: string;
|
|
22
|
-
ui: string;
|
|
23
|
-
cssContent: string;
|
|
24
|
-
slots: any[];
|
|
25
|
-
scopeSlots: any[];
|
|
26
|
-
directChildren: any[];
|
|
27
|
-
childrenResults: any[];
|
|
28
|
-
};
|
|
29
|
-
export default handleSlot;
|
package/dist/cjs/handleSlot.js
DELETED
|
@@ -1,153 +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/handleSlot.ts
|
|
20
|
-
var handleSlot_exports = {};
|
|
21
|
-
__export(handleSlot_exports, {
|
|
22
|
-
default: () => handleSlot_default
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(handleSlot_exports);
|
|
25
|
-
var import_utils = require("./utils");
|
|
26
|
-
var import_scene = require("./utils/templates/scene");
|
|
27
|
-
var import_renderManager = require("./utils/templates/renderManager");
|
|
28
|
-
var import_processChildren = require("./utils/logic/processChildren");
|
|
29
|
-
var import_processSceneLogic = require("./processors/processSceneLogic");
|
|
30
|
-
var handleSlot = (ui, config) => {
|
|
31
|
-
var _a, _b;
|
|
32
|
-
const importManager = new import_utils.ImportManager(config);
|
|
33
|
-
const { props = {} } = ui;
|
|
34
|
-
const children = (0, import_processChildren.normalizeChildren)(ui);
|
|
35
|
-
const isRoot = config.checkIsRoot();
|
|
36
|
-
const slotId = ((_a = ui.meta) == null ? void 0 : _a.id) || ui.id;
|
|
37
|
-
const addDependencyImport = config.addParentDependencyImport || importManager.addImport.bind(importManager);
|
|
38
|
-
setupImports(addDependencyImport, config, isRoot);
|
|
39
|
-
if (!isRoot) {
|
|
40
|
-
const utilsPkg = config.getUtilsPackageName({ isRoot, isPopup: config.isPopup });
|
|
41
|
-
addDependencyImport({
|
|
42
|
-
packageName: utilsPkg,
|
|
43
|
-
dependencyNames: ["useAppContext"],
|
|
44
|
-
importType: "named"
|
|
45
|
-
});
|
|
46
|
-
addDependencyImport({
|
|
47
|
-
packageName: "react",
|
|
48
|
-
dependencyNames: ["useEffect"],
|
|
49
|
-
importType: "named"
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const indent2 = (0, import_utils.indentation)(config.codeStyle.indent);
|
|
53
|
-
const envDefineCode = isRoot ? (0, import_scene.genRootDefineCode)(indent2, config.getUtilsPackageName(), false, config.isModule) : (0, import_scene.genSlotDefineCode)(indent2);
|
|
54
|
-
const renderManager = isRoot ? new import_renderManager.RenderManager() : config.renderManager || new import_renderManager.RenderManager();
|
|
55
|
-
const childResults = (0, import_processChildren.processChildren)(children, {
|
|
56
|
-
...config,
|
|
57
|
-
depth: config.depth + 1,
|
|
58
|
-
addParentDependencyImport: addDependencyImport,
|
|
59
|
-
renderManager,
|
|
60
|
-
// 让插槽内部的组件知道当前处于哪个 slot(用于接收父容器 inputValues)
|
|
61
|
-
currentSlotId: isRoot ? void 0 : config.slotKey || slotId
|
|
62
|
-
});
|
|
63
|
-
const { initCode, effectCode } = (0, import_processSceneLogic.processSceneLogic)(ui, config, addDependencyImport);
|
|
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}${initCode}${(0, import_scene.wrapInEffect)(indent2, effectCode)}`;
|
|
66
|
-
const uiResult = generateSlotUi(ui, props, childResults.ui, childResults.childrenResults, config);
|
|
67
|
-
if (isRoot) {
|
|
68
|
-
const renderDefinitions = renderManager ? renderManager.toCode("") : "";
|
|
69
|
-
finalizeRootComponent(ui, config, importManager, combinedJsCode, renderDefinitions, uiResult, cssContent);
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
js: childResults.js,
|
|
73
|
-
combinedJsCode,
|
|
74
|
-
ui: uiResult,
|
|
75
|
-
cssContent,
|
|
76
|
-
slots: [],
|
|
77
|
-
scopeSlots: [],
|
|
78
|
-
directChildren: childResults.directChildren,
|
|
79
|
-
childrenResults: childResults.childrenResults
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
var setupImports = (addImport, config, isRoot) => {
|
|
83
|
-
const importParams = { isPopup: config.isPopup };
|
|
84
|
-
const utilsPkg = config.getUtilsPackageName(importParams);
|
|
85
|
-
const comPkg = config.getComponentPackageName(importParams);
|
|
86
|
-
addImport({
|
|
87
|
-
packageName: "react",
|
|
88
|
-
dependencyNames: ["useRef", "useEffect", "useState", "createContext", "useContext"],
|
|
89
|
-
importType: "named"
|
|
90
|
-
});
|
|
91
|
-
addImport({ packageName: "@tarojs/components", dependencyNames: ["View"], importType: "named" });
|
|
92
|
-
const dependencyNames = ["WithCom", "WithWrapper"];
|
|
93
|
-
if (isRoot && config.hasPopups) {
|
|
94
|
-
dependencyNames.push("PopupRenderer");
|
|
95
|
-
}
|
|
96
|
-
addImport({ packageName: utilsPkg, dependencyNames, importType: "named" });
|
|
97
|
-
addImport({ packageName: comPkg, dependencyNames: ["useAppContext"], importType: "named" });
|
|
98
|
-
if (isRoot) {
|
|
99
|
-
if (!config.isModule) {
|
|
100
|
-
addImport({ packageName: "@/common/pageLife", dependencyNames: ["usePageLife"], importType: "named" });
|
|
101
|
-
}
|
|
102
|
-
if (config.hasPopups) {
|
|
103
|
-
addImport({ packageName: "@/common/popup", dependencyNames: ["POPUP_MAP", "POPUP_IDS"], importType: "named" });
|
|
104
|
-
}
|
|
105
|
-
addImport({ packageName: "./index.less", dependencyNames: [], importType: "module" });
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
var generateSlotUi = (ui, props, childrenUi, childrenResults, config) => {
|
|
109
|
-
const indent = (0, import_utils.indentation)(config.codeStyle.indent * config.depth);
|
|
110
|
-
const slotStyle = ui.style || {};
|
|
111
|
-
const propsStyle = props.style || {};
|
|
112
|
-
const mergedStyle = { width: "100%", height: "100%", ...slotStyle, ...propsStyle };
|
|
113
|
-
const layout = ui.layout || mergedStyle.layout;
|
|
114
|
-
const smart = isSmartLayout(layout);
|
|
115
|
-
const layoutAdjustment = smart ? { position: "relative" } : hasFixedChildren(childrenResults) ? { transform: "translateX(0)" } : {};
|
|
116
|
-
const styleCode = JSON.stringify((0, import_utils.convertRootStyle)({ ...mergedStyle, layout, ...layoutAdjustment }));
|
|
117
|
-
const rootClassName = (0, import_utils.getRootComponentClassName)(config.getCurrentScene(), config.checkIsRoot());
|
|
118
|
-
const parentComId = config == null ? void 0 : config.parentComId;
|
|
119
|
-
const slotMarkClass = parentComId ? `mybricks_slot slot-${parentComId}` : "";
|
|
120
|
-
const classNameStr = [rootClassName, slotMarkClass].filter(Boolean).join(" ");
|
|
121
|
-
const classNameAttr = classNameStr ? ` className='${classNameStr}'` : "";
|
|
122
|
-
const styleAttr = slotMarkClass ? `style={{...params.style || {}, ...${styleCode}}}` : `style={${styleCode}}`;
|
|
123
|
-
return `${indent}<View${classNameAttr} ${styleAttr}>
|
|
124
|
-
${childrenUi}
|
|
125
|
-
${indent}</View>`;
|
|
126
|
-
};
|
|
127
|
-
var finalizeRootComponent = (ui, config, importManager, combinedJsCode, renderDefinitions, uiResult, cssContent) => {
|
|
128
|
-
var _a, _b, _c;
|
|
129
|
-
const fileName = ((_a = config.getFileName) == null ? void 0 : _a.call(config, ui.meta.slotId)) || ui.meta.title || "index";
|
|
130
|
-
const componentId = ((_b = ui.meta) == null ? void 0 : _b.id) || ui.id || ((_c = ui.meta) == null ? void 0 : _c.slotId) || "Index";
|
|
131
|
-
const prefix = config.isModule ? "C" : "P";
|
|
132
|
-
const componentName = `${prefix}${String(componentId).replace(/[^a-zA-Z0-9]/g, "_").toUpperCase()}`;
|
|
133
|
-
const componentCode = (0, import_scene.genComponentTemplate)({
|
|
134
|
-
componentId,
|
|
135
|
-
componentName,
|
|
136
|
-
combinedJsCode,
|
|
137
|
-
renderDefinitions,
|
|
138
|
-
uiResult,
|
|
139
|
-
isPopup: config.isPopup,
|
|
140
|
-
hasPopups: config.hasPopups
|
|
141
|
-
});
|
|
142
|
-
config.add({ importManager, content: componentCode, cssContent, name: fileName });
|
|
143
|
-
};
|
|
144
|
-
var hasFixedChildren = (childrenResults) => {
|
|
145
|
-
return childrenResults.some((item) => {
|
|
146
|
-
var _a;
|
|
147
|
-
return ((_a = item == null ? void 0 : item.rootStyle) == null ? void 0 : _a.position) === "fixed";
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
var isSmartLayout = (layout) => {
|
|
151
|
-
return layout === "smart" || (layout == null ? void 0 : layout.position) === "smart";
|
|
152
|
-
};
|
|
153
|
-
var handleSlot_default = handleSlot;
|
package/dist/cjs/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { default as toCodeTaro } from './toCodeTaro';
|
|
2
|
-
export { default as generateTaroProjectJson } from './generate/generateTaroProjectJson';
|
|
3
|
-
export { default as generateTaroTempalteJson } from './generate/generateTaroTempalteJson';
|
|
4
|
-
export { compressImages, type ImageCompressionOptions } from './generate/compressImages';
|
package/dist/cjs/index.js
DELETED
|
@@ -1,48 +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/index.ts
|
|
30
|
-
var src_exports = {};
|
|
31
|
-
__export(src_exports, {
|
|
32
|
-
compressImages: () => import_compressImages.compressImages,
|
|
33
|
-
generateTaroProjectJson: () => import_generateTaroProjectJson.default,
|
|
34
|
-
generateTaroTempalteJson: () => import_generateTaroTempalteJson.default,
|
|
35
|
-
toCodeTaro: () => import_toCodeTaro.default
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(src_exports);
|
|
38
|
-
var import_toCodeTaro = __toESM(require("./toCodeTaro"));
|
|
39
|
-
var import_generateTaroProjectJson = __toESM(require("./generate/generateTaroProjectJson"));
|
|
40
|
-
var import_generateTaroTempalteJson = __toESM(require("./generate/generateTaroTempalteJson"));
|
|
41
|
-
var import_compressImages = require("./generate/compressImages");
|
|
42
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
-
0 && (module.exports = {
|
|
44
|
-
compressImages,
|
|
45
|
-
generateTaroProjectJson,
|
|
46
|
-
generateTaroTempalteJson,
|
|
47
|
-
toCodeTaro
|
|
48
|
-
});
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { HandleComConfig, Com } from "../handleCom";
|
|
2
|
-
/**
|
|
3
|
-
* 处理组件事件
|
|
4
|
-
*/
|
|
5
|
-
export declare const processComEvents: (com: Com, config: HandleComConfig) => {
|
|
6
|
-
comEventCode: string;
|
|
7
|
-
outputsConfig: Record<string, any>;
|
|
8
|
-
eventConfig: Record<string, any>;
|
|
9
|
-
};
|
|
@@ -1,163 +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/processors/processComEvents.ts
|
|
20
|
-
var processComEvents_exports = {};
|
|
21
|
-
__export(processComEvents_exports, {
|
|
22
|
-
processComEvents: () => processComEvents
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(processComEvents_exports);
|
|
25
|
-
var import_utils = require("../utils");
|
|
26
|
-
var import_handleProcess = require("../utils/logic/handleProcess");
|
|
27
|
-
var processComEvents = (com, config) => {
|
|
28
|
-
var _a, _b, _c;
|
|
29
|
-
const { meta, events } = com;
|
|
30
|
-
let comEventCode = "";
|
|
31
|
-
const outputsConfig = {};
|
|
32
|
-
const eventConfig = {};
|
|
33
|
-
const outputEvents = events || {};
|
|
34
|
-
Object.entries(outputEvents).forEach(([eventId, eventInfo]) => {
|
|
35
|
-
var _a2, _b2;
|
|
36
|
-
const { type, isAbstract, diagramId, schema, active } = eventInfo;
|
|
37
|
-
if (active === false)
|
|
38
|
-
return;
|
|
39
|
-
if (isAbstract) {
|
|
40
|
-
config.setAbstractEventTypeDefMap({
|
|
41
|
-
comId: com.meta.id,
|
|
42
|
-
eventId,
|
|
43
|
-
typeDef: config.getTypeDef(),
|
|
44
|
-
schema
|
|
45
|
-
});
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (type === "fx") {
|
|
49
|
-
processFxEvent(eventId, com, config, (code) => {
|
|
50
|
-
comEventCode += code;
|
|
51
|
-
});
|
|
52
|
-
eventConfig[eventId] = { connected: true };
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (type !== "defined")
|
|
56
|
-
return;
|
|
57
|
-
const resolvedDiagramId = diagramId || ((_a2 = eventInfo == null ? void 0 : eventInfo.options) == null ? void 0 : _a2.diagramId) || ((_b2 = eventInfo == null ? void 0 : eventInfo.options) == null ? void 0 : _b2.id);
|
|
58
|
-
if (!resolvedDiagramId)
|
|
59
|
-
return;
|
|
60
|
-
const event = config.getEventByDiagramId(resolvedDiagramId);
|
|
61
|
-
if (!event)
|
|
62
|
-
return;
|
|
63
|
-
const paramName = "value";
|
|
64
|
-
let process = (0, import_handleProcess.handleProcess)(event, {
|
|
65
|
-
...config,
|
|
66
|
-
target: "comRefs.current",
|
|
67
|
-
depth: config.depth + 3,
|
|
68
|
-
addParentDependencyImport: config.addParentDependencyImport,
|
|
69
|
-
getParams: () => ({ [eventId]: paramName })
|
|
70
|
-
}).replace(/this\.\$vars\./g, "$vars.current.").replace(/this\.\$fxs\./g, "$fxs.current.").replace(/this\./g, "comRefs.current.").replace(
|
|
71
|
-
/comRefs\.current\.([a-zA-Z0-9_]+)\.controller_/g,
|
|
72
|
-
"comRefs.current.$1."
|
|
73
|
-
).replace(/comRefs\.current\.slot_Index\./g, "comRefs.current.");
|
|
74
|
-
if (process.includes("pageParams")) {
|
|
75
|
-
const importParams = { isPopup: config.isPopup };
|
|
76
|
-
const controllerName = config.isPopup ? "popupRouter" : "pageRouter";
|
|
77
|
-
config.addParentDependencyImport({
|
|
78
|
-
packageName: config.getComponentPackageName(importParams),
|
|
79
|
-
dependencyNames: [controllerName, "SUBJECT_VALUE"],
|
|
80
|
-
importType: "named"
|
|
81
|
-
});
|
|
82
|
-
const indent = (0, import_utils.indentation)(config.codeStyle.indent * (config.depth + 3));
|
|
83
|
-
process = `${indent}const pageParams: any = ${controllerName}.getParams("${config.getCurrentScene().id}")[SUBJECT_VALUE];
|
|
84
|
-
${process}`;
|
|
85
|
-
}
|
|
86
|
-
const handlerIndent = (0, import_utils.indentation)(config.codeStyle.indent * (config.depth + 2));
|
|
87
|
-
const handlerCode = `(${paramName}: any) => {
|
|
88
|
-
${process}
|
|
89
|
-
${handlerIndent}}`;
|
|
90
|
-
if (!outputsConfig[meta.id]) {
|
|
91
|
-
outputsConfig[meta.id] = {};
|
|
92
|
-
}
|
|
93
|
-
outputsConfig[meta.id][eventId] = handlerCode;
|
|
94
|
-
eventConfig[eventId] = { connected: true };
|
|
95
|
-
});
|
|
96
|
-
if (((_a = meta.def) == null ? void 0 : _a.namespace) === "mybricks.taro.popup") {
|
|
97
|
-
if (!outputsConfig[meta.id]) {
|
|
98
|
-
outputsConfig[meta.id] = {};
|
|
99
|
-
}
|
|
100
|
-
const importParams = { isPopup: config.isPopup };
|
|
101
|
-
const sceneCom = (_b = config.getCurrentScene().coms) == null ? void 0 : _b[meta.id];
|
|
102
|
-
const popupData = ((_c = sceneCom == null ? void 0 : sceneCom.model) == null ? void 0 : _c.data) || {};
|
|
103
|
-
const isTrue = (v) => v === true || v === "true";
|
|
104
|
-
if (!eventConfig["onClose"] && isTrue(popupData.visibleClose)) {
|
|
105
|
-
config.addParentDependencyImport({
|
|
106
|
-
packageName: config.getComponentPackageName(importParams),
|
|
107
|
-
dependencyNames: ["popupRouter"],
|
|
108
|
-
importType: "named"
|
|
109
|
-
});
|
|
110
|
-
const handlerIndent = (0, import_utils.indentation)(config.codeStyle.indent * (config.depth + 2));
|
|
111
|
-
const processIndent = (0, import_utils.indentation)(config.codeStyle.indent * (config.depth + 3));
|
|
112
|
-
outputsConfig[meta.id]["onClose"] = `() => {
|
|
113
|
-
${processIndent}popupRouter.close("${config.getCurrentScene().id}");
|
|
114
|
-
${handlerIndent}}`;
|
|
115
|
-
eventConfig["onClose"] = { connected: true };
|
|
116
|
-
}
|
|
117
|
-
if (!eventConfig["onClickOverlay"] && isTrue(popupData.maskClose)) {
|
|
118
|
-
config.addParentDependencyImport({
|
|
119
|
-
packageName: config.getComponentPackageName(importParams),
|
|
120
|
-
dependencyNames: ["popupRouter"],
|
|
121
|
-
importType: "named"
|
|
122
|
-
});
|
|
123
|
-
const handlerIndent = (0, import_utils.indentation)(config.codeStyle.indent * (config.depth + 2));
|
|
124
|
-
const processIndent = (0, import_utils.indentation)(config.codeStyle.indent * (config.depth + 3));
|
|
125
|
-
outputsConfig[meta.id]["onClickOverlay"] = `() => {
|
|
126
|
-
${processIndent}popupRouter.close("${config.getCurrentScene().id}");
|
|
127
|
-
${handlerIndent}}`;
|
|
128
|
-
eventConfig["onClickOverlay"] = { connected: true };
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
return { comEventCode, outputsConfig, eventConfig };
|
|
132
|
-
};
|
|
133
|
-
var processFxEvent = (eventId, com, config, addCode) => {
|
|
134
|
-
const fxsMap = config.getFxsMap();
|
|
135
|
-
const currentProvider = config.getCurrentProvider();
|
|
136
|
-
const scene = config.getCurrentScene();
|
|
137
|
-
const pinProxy = scene.pinProxies[`${com.props.id}-${eventId}`];
|
|
138
|
-
if (!pinProxy)
|
|
139
|
-
return;
|
|
140
|
-
const fxProvider = fxsMap[pinProxy.frameId];
|
|
141
|
-
if (!fxProvider)
|
|
142
|
-
return;
|
|
143
|
-
const isGlobal = fxProvider.name === "global";
|
|
144
|
-
if (fxProvider.name !== currentProvider.name) {
|
|
145
|
-
if (isGlobal) {
|
|
146
|
-
config.addParentDependencyImport({
|
|
147
|
-
packageName: config.getComponentPackageName(),
|
|
148
|
-
dependencyNames: ["globalFxs"],
|
|
149
|
-
importType: "named"
|
|
150
|
-
});
|
|
151
|
-
} else {
|
|
152
|
-
config.addConsumer(fxProvider);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
const indent = (0, import_utils.indentation)(config.codeStyle.indent * (config.depth + 2));
|
|
156
|
-
const code = `${indent}${eventId}: ${isGlobal ? "globalFxs" : `comRefs.current.${fxProvider.name}_Fxs`}.${pinProxy.frameId},
|
|
157
|
-
`;
|
|
158
|
-
addCode(code);
|
|
159
|
-
};
|
|
160
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
161
|
-
0 && (module.exports = {
|
|
162
|
-
processComEvents
|
|
163
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 处理模块(Module)
|
|
3
|
-
* 参考鸿蒙实现,将模块处理逻辑独立出来
|
|
4
|
-
*/
|
|
5
|
-
import type { ToTaroCodeConfig, GeneratedFile } from "../toCodeTaro";
|
|
6
|
-
import toCode from "@mybricks/to-code-react/dist/cjs/toCode";
|
|
7
|
-
import { type Provider } from "../utils/context/createProvider";
|
|
8
|
-
import type { JSModulesMap } from "../utils/context/collectJSModules";
|
|
9
|
-
type ToCodeResult = ReturnType<typeof toCode>;
|
|
10
|
-
type Module = ToCodeResult["modules"][0];
|
|
11
|
-
interface ProcessModuleParams {
|
|
12
|
-
module: Module;
|
|
13
|
-
config: ToTaroCodeConfig;
|
|
14
|
-
globalVarTypeDef: Record<string, any>;
|
|
15
|
-
defaultFxsMap: Record<string, Provider>;
|
|
16
|
-
abstractEventTypeDefMap: Record<string, any>;
|
|
17
|
-
jsModulesMap: JSModulesMap;
|
|
18
|
-
getExtensionEventById: (id: string) => any;
|
|
19
|
-
getSceneById: (id: string) => any;
|
|
20
|
-
getFrameById?: (id: string) => any;
|
|
21
|
-
addResult: (result: GeneratedFile) => void;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* 处理单个模块
|
|
25
|
-
*/
|
|
26
|
-
export declare const processModule: (params: ProcessModuleParams) => void;
|
|
27
|
-
/**
|
|
28
|
-
* 处理所有模块
|
|
29
|
-
*/
|
|
30
|
-
export declare const processModules: (modules: Module[], params: Omit<ProcessModuleParams, "module">) => void;
|
|
31
|
-
export {};
|