@mybricks/to-code-taro 1.2.6 → 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/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ToTaroCodeConfig } from "./toCodeTaro";
|
|
2
|
-
type AbstractEventTypeDefMap = Record<string, {
|
|
3
|
-
eventIds: Set<string>;
|
|
4
|
-
typeDef: {
|
|
5
|
-
var: Record<string, any>;
|
|
6
|
-
input: Record<string, any>;
|
|
7
|
-
output: Record<string, any>;
|
|
8
|
-
};
|
|
9
|
-
}>;
|
|
10
|
-
declare const abstractEventTypeDef: (abstractEventTypeDefMap: AbstractEventTypeDefMap, config: ToTaroCodeConfig) => string;
|
|
11
|
-
export default abstractEventTypeDef;
|
|
@@ -1,93 +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/abstractEventTypeDef.ts
|
|
20
|
-
var abstractEventTypeDef_exports = {};
|
|
21
|
-
__export(abstractEventTypeDef_exports, {
|
|
22
|
-
default: () => abstractEventTypeDef_default
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(abstractEventTypeDef_exports);
|
|
25
|
-
var import_utils = require("./utils");
|
|
26
|
-
var abstractEventTypeDef = (abstractEventTypeDefMap, config) => {
|
|
27
|
-
const indent = (0, import_utils.indentation)(config.codeStyle.indent);
|
|
28
|
-
const interfaceCode = [];
|
|
29
|
-
const comEvent = [];
|
|
30
|
-
Object.entries(abstractEventTypeDefMap).forEach(
|
|
31
|
-
([comId, { typeDef, eventIdMap }]) => {
|
|
32
|
-
const { vars, inputs, outputs } = typeDef;
|
|
33
|
-
const statementCode = [];
|
|
34
|
-
const getCode = [];
|
|
35
|
-
const eventCode = [];
|
|
36
|
-
const eventCtxTypeName = `I${comId}_comEventCtx`;
|
|
37
|
-
const comEventTypeName = `I${comId}_comEvent`;
|
|
38
|
-
Object.entries(vars).forEach(([, { title, schema }]) => {
|
|
39
|
-
const typeName = `I${comId}_var_${title}`;
|
|
40
|
-
statementCode.push(`type ${typeName} = any;`);
|
|
41
|
-
getCode.push(
|
|
42
|
-
`${indent}getVar<T = ${typeName}>(value: "${title}"): GetVarResult<T>`
|
|
43
|
-
);
|
|
44
|
-
});
|
|
45
|
-
Object.entries(inputs).forEach(([, { title, schema }]) => {
|
|
46
|
-
const typeName = `I${comId}_input_${title}`;
|
|
47
|
-
statementCode.push(`type ${typeName} = any;`);
|
|
48
|
-
getCode.push(
|
|
49
|
-
`${indent}getInput<T = ${typeName}>(value: "${title}"): GetInputResult<T>`
|
|
50
|
-
);
|
|
51
|
-
});
|
|
52
|
-
Object.entries(outputs).forEach(([, { title, schema }]) => {
|
|
53
|
-
const typeName = `I${comId}_output_${title}`;
|
|
54
|
-
statementCode.push(`type ${typeName} = any;`);
|
|
55
|
-
getCode.push(
|
|
56
|
-
`${indent}getOutput<T = ${typeName}>(value: "${title}"): GetOutputResult<T>`
|
|
57
|
-
);
|
|
58
|
-
});
|
|
59
|
-
Object.entries(eventIdMap).forEach(([eventId, schema]) => {
|
|
60
|
-
const typeName = `I${comId}_${eventId}_value`;
|
|
61
|
-
statementCode.push(`type ${typeName} = any;`);
|
|
62
|
-
eventCode.push(
|
|
63
|
-
`${indent}${eventId}?: (value: ${typeName}, ctx: ${eventCtxTypeName}) => void`
|
|
64
|
-
);
|
|
65
|
-
});
|
|
66
|
-
interfaceCode.push(
|
|
67
|
-
statementCode.join("\n") + `
|
|
68
|
-
interface ${eventCtxTypeName} {
|
|
69
|
-
${getCode.join("\n")}
|
|
70
|
-
}
|
|
71
|
-
interface ${comEventTypeName} {
|
|
72
|
-
${eventCode.join("\n")}
|
|
73
|
-
}`
|
|
74
|
-
);
|
|
75
|
-
comEvent.push(`${indent}${comId}?: ${comEventTypeName}`);
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
return `interface GetVarResult<T> {
|
|
79
|
-
getValue: () => T
|
|
80
|
-
setValue: (value: T) => void
|
|
81
|
-
}
|
|
82
|
-
interface GetOutputResult<T> {
|
|
83
|
-
setValue: (value: T) => void
|
|
84
|
-
}
|
|
85
|
-
interface GetInputResult<T> {
|
|
86
|
-
getValue: () => T
|
|
87
|
-
}` + (interfaceCode ? `
|
|
88
|
-
${interfaceCode.join("\n")}` : "") + `
|
|
89
|
-
interface ComEvent {
|
|
90
|
-
${comEvent.join("\n")}
|
|
91
|
-
}`;
|
|
92
|
-
};
|
|
93
|
-
var abstractEventTypeDef_default = abstractEventTypeDef;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 图片压缩工具
|
|
3
|
-
* 使用 sharp(可选依赖)对生成的图片进行压缩
|
|
4
|
-
*/
|
|
5
|
-
import type { GenerationResult } from "../toCodeTaro";
|
|
6
|
-
export interface ImageCompressionOptions {
|
|
7
|
-
/** sharp .png() 参数,如 { compressionLevel: 9, palette: true, effort: 10 } */
|
|
8
|
-
png?: Record<string, any>;
|
|
9
|
-
/** sharp .jpeg() 参数,如 { quality: 80 } */
|
|
10
|
-
jpeg?: Record<string, any>;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* 压缩 GenerationResult 中的所有图片
|
|
14
|
-
* 需要安装 sharp(optionalDependency),未安装时原样返回
|
|
15
|
-
*/
|
|
16
|
-
export declare function compressImages(result: GenerationResult, options: ImageCompressionOptions): Promise<GenerationResult>;
|
|
@@ -1,76 +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/generate/compressImages.ts
|
|
20
|
-
var compressImages_exports = {};
|
|
21
|
-
__export(compressImages_exports, {
|
|
22
|
-
compressImages: () => compressImages
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(compressImages_exports);
|
|
25
|
-
var sharpModule;
|
|
26
|
-
function getSharp() {
|
|
27
|
-
if (sharpModule !== void 0)
|
|
28
|
-
return sharpModule;
|
|
29
|
-
try {
|
|
30
|
-
sharpModule = require("sharp");
|
|
31
|
-
} catch {
|
|
32
|
-
sharpModule = null;
|
|
33
|
-
}
|
|
34
|
-
return sharpModule;
|
|
35
|
-
}
|
|
36
|
-
async function compressImages(result, options) {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
const sharp = getSharp();
|
|
39
|
-
if (!sharp) {
|
|
40
|
-
console.warn(
|
|
41
|
-
"[to-code-taro] sharp 未安装,跳过图片压缩。可通过 pnpm add sharp 安装。"
|
|
42
|
-
);
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
const allImages = [
|
|
46
|
-
...((_a = result.assets) == null ? void 0 : _a.pageImages) || [],
|
|
47
|
-
...((_b = result.assets) == null ? void 0 : _b.tabBarImages) || []
|
|
48
|
-
];
|
|
49
|
-
if (allImages.length === 0)
|
|
50
|
-
return result;
|
|
51
|
-
await Promise.all(
|
|
52
|
-
allImages.map(async (img) => {
|
|
53
|
-
var _a2;
|
|
54
|
-
const ext = (_a2 = img.filePath.split(".").pop()) == null ? void 0 : _a2.toLowerCase();
|
|
55
|
-
const original = img.fileContent;
|
|
56
|
-
try {
|
|
57
|
-
let compressed;
|
|
58
|
-
if (ext === "png" && options.png) {
|
|
59
|
-
compressed = await sharp(original).png(options.png).toBuffer();
|
|
60
|
-
} else if ((ext === "jpg" || ext === "jpeg") && options.jpeg) {
|
|
61
|
-
compressed = await sharp(original).jpeg(options.jpeg).toBuffer();
|
|
62
|
-
}
|
|
63
|
-
if (compressed) {
|
|
64
|
-
img.fileContent = compressed;
|
|
65
|
-
}
|
|
66
|
-
} catch (e) {
|
|
67
|
-
console.warn(`[to-code-taro] 压缩图片失败 ${img.filePath}:`, e);
|
|
68
|
-
}
|
|
69
|
-
})
|
|
70
|
-
);
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
-
0 && (module.exports = {
|
|
75
|
-
compressImages
|
|
76
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { GenerationResult } from "../toCodeTaro";
|
|
2
|
-
interface FileNode {
|
|
3
|
-
path: string;
|
|
4
|
-
content: string | null;
|
|
5
|
-
children?: FileNode[];
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* 根据数组生成文件结构 JSON 对象
|
|
9
|
-
* @param result 包含 files 和 assets 的生成结果对象
|
|
10
|
-
* @returns 返回文件结构的 JSON 对象数组
|
|
11
|
-
*/
|
|
12
|
-
declare const generateTaroProjectJson: (result: GenerationResult) => FileNode[];
|
|
13
|
-
export default generateTaroProjectJson;
|
|
@@ -1,225 +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/generate/generateTaroProjectJson.ts
|
|
30
|
-
var generateTaroProjectJson_exports = {};
|
|
31
|
-
__export(generateTaroProjectJson_exports, {
|
|
32
|
-
default: () => generateTaroProjectJson_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(generateTaroProjectJson_exports);
|
|
35
|
-
var fs = __toESM(require("fs"));
|
|
36
|
-
var path = __toESM(require("path"));
|
|
37
|
-
var import_fileNode = require("./utils/fileNode");
|
|
38
|
-
var import_commonDir = require("./utils/commonDir");
|
|
39
|
-
var import_tabBarImages = require("./utils/tabBarImages");
|
|
40
|
-
var import_pageImages = require("./utils/pageImages");
|
|
41
|
-
var import_appConfig = require("./utils/appConfig");
|
|
42
|
-
var import_customTabBar = require("./utils/customTabBar");
|
|
43
|
-
var import_genJSModules = require("../utils/logic/genJSModules");
|
|
44
|
-
var generateTaroProjectJson = (result) => {
|
|
45
|
-
var _a;
|
|
46
|
-
const { files = [], assets = {} } = result;
|
|
47
|
-
const templateJsonPath = path.join(__dirname, "../taro-template.json");
|
|
48
|
-
if (!fs.existsSync(templateJsonPath)) {
|
|
49
|
-
throw new Error(`模板文件不存在: ${templateJsonPath}`);
|
|
50
|
-
}
|
|
51
|
-
const templateJson = JSON.parse(
|
|
52
|
-
fs.readFileSync(templateJsonPath, "utf-8")
|
|
53
|
-
);
|
|
54
|
-
const srcDir = templateJson.find((node) => node.path === "src");
|
|
55
|
-
srcDir.children = srcDir.children || [];
|
|
56
|
-
const pagesDir = (0, import_fileNode.findDir)(templateJson, "src/pages");
|
|
57
|
-
if (!pagesDir) {
|
|
58
|
-
throw new Error("未找到 pages 目录");
|
|
59
|
-
}
|
|
60
|
-
pagesDir.children = pagesDir.children || [];
|
|
61
|
-
const commonDir = (0, import_fileNode.ensureDir)(srcDir, "src/common");
|
|
62
|
-
const assetsDir = (0, import_fileNode.ensureDir)(srcDir, "src/assets");
|
|
63
|
-
const tabbarDir = (0, import_fileNode.ensureDir)(assetsDir, "src/assets/tabbar");
|
|
64
|
-
const imageFiles = assets.tabBarImages || [];
|
|
65
|
-
const pageImages = assets.pageImages || [];
|
|
66
|
-
const normalItems = files.filter((item) => item.type === "normal");
|
|
67
|
-
const generatedPages = normalItems.map((item) => {
|
|
68
|
-
var _a2;
|
|
69
|
-
const pageName = item.meta.id;
|
|
70
|
-
const importCode = ((_a2 = item.importManager) == null ? void 0 : _a2.toCode()) || "";
|
|
71
|
-
const fileContent = item.content || "";
|
|
72
|
-
const fullContent = importCode ? `${importCode}
|
|
73
|
-
${fileContent}` : fileContent;
|
|
74
|
-
const configContent = item.pageConfigContent || `export default definePageConfig({
|
|
75
|
-
navigationBarTitleText: '页面'
|
|
76
|
-
})`;
|
|
77
|
-
const pageChildren = [
|
|
78
|
-
{
|
|
79
|
-
path: `src/pages/${pageName}/index.config.ts`,
|
|
80
|
-
content: configContent
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
path: `src/pages/${pageName}/index.less`,
|
|
84
|
-
content: item.cssContent || ""
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
path: `src/pages/${pageName}/index.tsx`,
|
|
88
|
-
content: fullContent
|
|
89
|
-
}
|
|
90
|
-
];
|
|
91
|
-
if (item.jsModules && item.jsModules.length > 0) {
|
|
92
|
-
pageChildren.push({
|
|
93
|
-
path: `src/pages/${pageName}/index.jsModules.ts`,
|
|
94
|
-
content: (0, import_genJSModules.genScopedJSModules)(
|
|
95
|
-
item.jsModules,
|
|
96
|
-
"@mybricks/taro-core",
|
|
97
|
-
"@/common/jsModulesRuntime"
|
|
98
|
-
)
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
path: `src/pages/${pageName}`,
|
|
103
|
-
content: null,
|
|
104
|
-
children: pageChildren
|
|
105
|
-
};
|
|
106
|
-
});
|
|
107
|
-
pagesDir.children.push(...generatedPages);
|
|
108
|
-
const popupComponentsDir = (0, import_fileNode.ensureDir)(srcDir, "src/popupComponents");
|
|
109
|
-
const popupScenes = files.filter((item) => item.type === "popup" && item.meta);
|
|
110
|
-
popupScenes.forEach((item) => {
|
|
111
|
-
var _a2;
|
|
112
|
-
const popupId = item.meta.id;
|
|
113
|
-
const importCode = ((_a2 = item.importManager) == null ? void 0 : _a2.toCode()) || "";
|
|
114
|
-
const fullContent = `${importCode}
|
|
115
|
-
${item.content || ""}`;
|
|
116
|
-
const popupChildren = [
|
|
117
|
-
{
|
|
118
|
-
path: `src/popupComponents/${popupId}/index.tsx`,
|
|
119
|
-
content: fullContent
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
path: `src/popupComponents/${popupId}/index.less`,
|
|
123
|
-
content: item.cssContent || ""
|
|
124
|
-
}
|
|
125
|
-
];
|
|
126
|
-
if (item.jsModules && item.jsModules.length > 0) {
|
|
127
|
-
popupChildren.push({
|
|
128
|
-
path: `src/popupComponents/${popupId}/index.jsModules.ts`,
|
|
129
|
-
content: (0, import_genJSModules.genScopedJSModules)(
|
|
130
|
-
item.jsModules,
|
|
131
|
-
"@mybricks/taro-core",
|
|
132
|
-
"@/common/jsModulesRuntime"
|
|
133
|
-
)
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
popupComponentsDir.children.push({
|
|
137
|
-
path: `src/popupComponents/${popupId}`,
|
|
138
|
-
content: null,
|
|
139
|
-
children: popupChildren
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
const componentsDir = (0, import_fileNode.ensureDir)(srcDir, "src/components");
|
|
143
|
-
const moduleScenes = files.filter((item) => item.type === "module" && item.meta);
|
|
144
|
-
const moduleExports = [];
|
|
145
|
-
moduleScenes.forEach((item) => {
|
|
146
|
-
var _a2;
|
|
147
|
-
const moduleId = item.meta.id;
|
|
148
|
-
const exportName = `C${String(moduleId).replace(/[^a-zA-Z0-9]/g, "_").toUpperCase()}`;
|
|
149
|
-
const importCode = ((_a2 = item.importManager) == null ? void 0 : _a2.toCode()) || "";
|
|
150
|
-
const fullContent = `${importCode}
|
|
151
|
-
${item.content || ""}`;
|
|
152
|
-
const moduleChildren = [
|
|
153
|
-
{
|
|
154
|
-
path: `src/components/${moduleId}/index.tsx`,
|
|
155
|
-
content: fullContent
|
|
156
|
-
},
|
|
157
|
-
{
|
|
158
|
-
path: `src/components/${moduleId}/index.less`,
|
|
159
|
-
content: item.cssContent || ""
|
|
160
|
-
}
|
|
161
|
-
];
|
|
162
|
-
if (item.jsModules && item.jsModules.length > 0) {
|
|
163
|
-
moduleChildren.push({
|
|
164
|
-
path: `src/components/${moduleId}/index.jsModules.ts`,
|
|
165
|
-
content: (0, import_genJSModules.genScopedJSModules)(
|
|
166
|
-
item.jsModules,
|
|
167
|
-
"@mybricks/taro-core",
|
|
168
|
-
"@/common/jsModulesRuntime"
|
|
169
|
-
)
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
componentsDir.children.push({
|
|
173
|
-
path: `src/components/${moduleId}`,
|
|
174
|
-
content: null,
|
|
175
|
-
children: moduleChildren
|
|
176
|
-
});
|
|
177
|
-
moduleExports.push(
|
|
178
|
-
`export { default as ${exportName} } from "./${moduleId}/index";`
|
|
179
|
-
);
|
|
180
|
-
});
|
|
181
|
-
if (moduleExports.length > 0) {
|
|
182
|
-
componentsDir.children.push({
|
|
183
|
-
path: "src/components/Index.ts",
|
|
184
|
-
content: moduleExports.join("\n") + "\n"
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
const appConfigFile = (_a = srcDir.children) == null ? void 0 : _a.find(
|
|
188
|
-
(node) => node.path === "src/app.config.ts"
|
|
189
|
-
);
|
|
190
|
-
if (appConfigFile) {
|
|
191
|
-
(0, import_appConfig.updateAppConfig)(appConfigFile, normalItems, files);
|
|
192
|
-
}
|
|
193
|
-
(0, import_tabBarImages.handleTabBarImages)(tabbarDir, imageFiles);
|
|
194
|
-
(0, import_pageImages.handlePageImages)(assetsDir, pageImages);
|
|
195
|
-
(0, import_customTabBar.updateCustomTabBar)(srcDir, files);
|
|
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
|
-
}
|
|
208
|
-
const apiItem = files.find((item) => item.type === "connector-api");
|
|
209
|
-
if (apiItem) {
|
|
210
|
-
commonDir.children = commonDir.children || [];
|
|
211
|
-
commonDir.children.push({
|
|
212
|
-
path: "src/common/api.ts",
|
|
213
|
-
content: apiItem.content
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
const popupFile = files.find((f) => f.type === "popup" && !f.meta);
|
|
217
|
-
if (popupFile) {
|
|
218
|
-
commonDir.children.push({
|
|
219
|
-
path: `src/common/${popupFile.name}.ts`,
|
|
220
|
-
content: popupFile.content
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
return templateJson;
|
|
224
|
-
};
|
|
225
|
-
var generateTaroProjectJson_default = generateTaroProjectJson;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
interface FileNode {
|
|
2
|
-
path: string;
|
|
3
|
-
content: string | null;
|
|
4
|
-
children?: FileNode[];
|
|
5
|
-
}
|
|
6
|
-
interface TemplateJson {
|
|
7
|
-
rootDir: string;
|
|
8
|
-
files: FileNode[];
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* 递归遍历目录并生成文件树结构
|
|
12
|
-
* @param templateDir 模板目录路径,默认为当前文件所在目录下的 template 目录
|
|
13
|
-
*/
|
|
14
|
-
declare const generateTaroTemplateJson: (templateDir?: string) => TemplateJson;
|
|
15
|
-
export default generateTaroTemplateJson;
|
|
@@ -1,103 +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/generate/generateTaroTempalteJson.ts
|
|
30
|
-
var generateTaroTempalteJson_exports = {};
|
|
31
|
-
__export(generateTaroTempalteJson_exports, {
|
|
32
|
-
default: () => generateTaroTempalteJson_default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(generateTaroTempalteJson_exports);
|
|
35
|
-
var fs = __toESM(require("fs"));
|
|
36
|
-
var path = __toESM(require("path"));
|
|
37
|
-
var _templateDir = path.join(__dirname, "../_template");
|
|
38
|
-
var generateTaroTemplateJson = (templateDir = _templateDir) => {
|
|
39
|
-
const rootDir = path.basename(templateDir);
|
|
40
|
-
const files = [];
|
|
41
|
-
const ignoreList = [
|
|
42
|
-
"node_modules",
|
|
43
|
-
"dist",
|
|
44
|
-
".git",
|
|
45
|
-
".husky",
|
|
46
|
-
".swc",
|
|
47
|
-
"yarn.lock",
|
|
48
|
-
"package-lock.json"
|
|
49
|
-
];
|
|
50
|
-
const readDirectory = (dirPath, relativePath = "") => {
|
|
51
|
-
const items = [];
|
|
52
|
-
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
53
|
-
entries.sort((a, b) => {
|
|
54
|
-
if (a.isDirectory() && !b.isDirectory())
|
|
55
|
-
return -1;
|
|
56
|
-
if (!a.isDirectory() && b.isDirectory())
|
|
57
|
-
return 1;
|
|
58
|
-
return a.name.localeCompare(b.name);
|
|
59
|
-
});
|
|
60
|
-
for (const entry of entries) {
|
|
61
|
-
if (ignoreList.includes(entry.name)) {
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
const fullPath = path.join(dirPath, entry.name);
|
|
65
|
-
const itemRelativePath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
|
|
66
|
-
if (entry.isDirectory()) {
|
|
67
|
-
const children = readDirectory(fullPath, itemRelativePath);
|
|
68
|
-
items.push({
|
|
69
|
-
path: itemRelativePath,
|
|
70
|
-
content: null,
|
|
71
|
-
children: children.length > 0 ? children : void 0
|
|
72
|
-
});
|
|
73
|
-
} else {
|
|
74
|
-
try {
|
|
75
|
-
const content = fs.readFileSync(fullPath, "utf-8");
|
|
76
|
-
items.push({
|
|
77
|
-
path: itemRelativePath,
|
|
78
|
-
content,
|
|
79
|
-
children: void 0
|
|
80
|
-
});
|
|
81
|
-
} catch (error) {
|
|
82
|
-
items.push({
|
|
83
|
-
path: itemRelativePath,
|
|
84
|
-
content: "",
|
|
85
|
-
children: void 0
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return items;
|
|
91
|
-
};
|
|
92
|
-
files.push(...readDirectory(templateDir));
|
|
93
|
-
const jsonFilePath = path.join(__dirname, "../taro-template.json");
|
|
94
|
-
if (fs.existsSync(jsonFilePath)) {
|
|
95
|
-
fs.unlinkSync(jsonFilePath);
|
|
96
|
-
}
|
|
97
|
-
fs.writeFileSync(jsonFilePath, JSON.stringify(files, null, 2));
|
|
98
|
-
return {
|
|
99
|
-
rootDir,
|
|
100
|
-
files
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
var generateTaroTempalteJson_default = generateTaroTemplateJson;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* app.config.ts 更新工具
|
|
3
|
-
*/
|
|
4
|
-
interface FileNode {
|
|
5
|
-
path: string;
|
|
6
|
-
content: string | null;
|
|
7
|
-
children?: FileNode[];
|
|
8
|
-
}
|
|
9
|
-
interface GenerateItem {
|
|
10
|
-
type: string;
|
|
11
|
-
meta?: {
|
|
12
|
-
id: string;
|
|
13
|
-
coms?: Record<string, any>;
|
|
14
|
-
};
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 更新 app.config.ts
|
|
19
|
-
*/
|
|
20
|
-
export declare function updateAppConfig(appConfigFile: FileNode, normalItems: GenerateItem[], items: GenerateItem[]): void;
|
|
21
|
-
export {};
|
|
@@ -1,57 +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/generate/utils/appConfig.ts
|
|
20
|
-
var appConfig_exports = {};
|
|
21
|
-
__export(appConfig_exports, {
|
|
22
|
-
updateAppConfig: () => updateAppConfig
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(appConfig_exports);
|
|
25
|
-
var import_fileNode = require("./fileNode");
|
|
26
|
-
function updateAppConfig(appConfigFile, normalItems, items) {
|
|
27
|
-
var _a;
|
|
28
|
-
if (!appConfigFile.content) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const content = (0, import_fileNode.parseLooseObject)(((_a = appConfigFile.content.match(/defineAppConfig\(([\s\S]*?)\)/)) == null ? void 0 : _a[1]) || "{}");
|
|
32
|
-
const newPagePaths = normalItems.map((item) => `pages/${item.meta.id}/index`);
|
|
33
|
-
content.pages = newPagePaths;
|
|
34
|
-
let entryPagePath = "";
|
|
35
|
-
normalItems.forEach((item) => {
|
|
36
|
-
var _a2, _b;
|
|
37
|
-
(_b = Object.values((_a2 = item.meta) == null ? void 0 : _a2.coms)) == null ? void 0 : _b.forEach((com) => {
|
|
38
|
-
var _a3, _b2;
|
|
39
|
-
if ((com == null ? void 0 : com.asRoot) && ((_b2 = (_a3 = com == null ? void 0 : com.model) == null ? void 0 : _a3.data) == null ? void 0 : _b2.isEntryPagePath)) {
|
|
40
|
-
entryPagePath = `pages/${item.meta.id}/index`;
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
if (entryPagePath) {
|
|
45
|
-
content.entryPagePath = entryPagePath;
|
|
46
|
-
}
|
|
47
|
-
const tabBarConfigItem = items.find((item) => item.type === "tabBarConfig");
|
|
48
|
-
if (tabBarConfigItem == null ? void 0 : tabBarConfigItem.content) {
|
|
49
|
-
const tabBar = (0, import_fileNode.parseLooseObject)(`{${tabBarConfigItem.content}}`);
|
|
50
|
-
Object.assign(content, tabBar);
|
|
51
|
-
}
|
|
52
|
-
appConfigFile.content = `export default defineAppConfig(${JSON.stringify(content, null, 2)})`;
|
|
53
|
-
}
|
|
54
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
-
0 && (module.exports = {
|
|
56
|
-
updateAppConfig
|
|
57
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common 目录处理工具
|
|
3
|
-
*/
|
|
4
|
-
interface FileNode {
|
|
5
|
-
path: string;
|
|
6
|
-
content: string | null;
|
|
7
|
-
children?: FileNode[];
|
|
8
|
-
}
|
|
9
|
-
interface GenerateItem {
|
|
10
|
-
type: string;
|
|
11
|
-
content?: string;
|
|
12
|
-
importManager?: {
|
|
13
|
-
toCode: () => string;
|
|
14
|
-
};
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* 处理 common 目录下的文件
|
|
19
|
-
*/
|
|
20
|
-
export declare function handleCommonDir(commonDir: FileNode, items: GenerateItem[]): void;
|
|
21
|
-
export {};
|