diff --git a/packages/vue-generator/src/generator/generateApp.js b/packages/vue-generator/src/generator/generateApp.js index b602a1c9e..066181e46 100644 --- a/packages/vue-generator/src/generator/generateApp.js +++ b/packages/vue-generator/src/generator/generateApp.js @@ -15,8 +15,8 @@ import CodeGenerator from './codeGenerator' /** * 整体应用出码 - * @param {tinyEngineDslVue.IConfig} config - * @returns {tinyEngineDslVue.codeGenInstance} + * @param {import('@opentiny/tiny-engine-dsl-vue').IConfig} config + * @returns {import('@opentiny/tiny-engine-dsl-vue').codeGenInstance} */ export function generateApp(config = {}) { diff --git a/packages/vue-generator/src/index.d.ts b/packages/vue-generator/src/index.d.ts index 618b83bca..167700811 100644 --- a/packages/vue-generator/src/index.d.ts +++ b/packages/vue-generator/src/index.d.ts @@ -1,5 +1,8 @@ -declare namespace tinyEngineDslVue { - type defaultPlugins = +declare module '@opentiny/tiny-engine-dsl-vue' { + export function generateCode(param: { pageInfo: any; componentsMap?: Array; blocksData?: Array }): { + [key: string]: any + } + export type defaultPlugins = | 'template' | 'block' | 'page' @@ -12,9 +15,9 @@ declare namespace tinyEngineDslVue { | 'formatCode' | 'parseSchema' - type IPluginFun = (schema: IAppSchema, context: IContext) => void + export type IPluginFun = (schema: IAppSchema, context: IContext) => void - interface IConfig { + export interface IConfig { customPlugins?: { [key in defaultPlugins]?: IPluginFun } & { @@ -26,7 +29,7 @@ declare namespace tinyEngineDslVue { customContext?: Record } - interface IContext { + export interface IContext { config: Record genResult: Array genLogs: Array @@ -35,24 +38,24 @@ declare namespace tinyEngineDslVue { export function generateApp(config?: IConfig): codeGenInstance - interface codeGenInstance { - generate(IAppSchema): ICodeGenResult + export interface codeGenInstance { + generate(schema: IAppSchema): ICodeGenResult } - interface ICodeGenResult { + export interface ICodeGenResult { errors: Array genResult: Array genLogs: Array } - interface IFile { + export interface IFile { fileType: string fileName: string path: string fileContent: string } - interface IAppSchema { + export interface IAppSchema { i18n: { en_US: Record zh_CN: Record @@ -66,37 +69,37 @@ declare namespace tinyEngineDslVue { meta: IMetaInfo } - interface IUtilsItem { + export interface IUtilsItem { name: string type: 'npm' | 'function' content: object } - interface IDataSource { + export interface IDataSource { list: Array<{ id: number; name: string; data: object }> dataHandler?: IFuncType errorHandler?: IFuncType willFetch?: IFuncType } - interface IFuncType { + export interface IFuncType { type: 'JSFunction' value: string } - interface IExpressionType { + export interface IExpressionType { type: 'JSExpression' value: string } - interface IGlobalStateItem { + export interface IGlobalStateItem { id: string state: Record actions: Record getters: Record } - interface IPageSchema { + export interface IPageSchema { componentName: 'Page' | 'Block' css: string fileName: string @@ -120,7 +123,7 @@ declare namespace tinyEngineDslVue { } } - interface IFolderItem { + export interface IFolderItem { componentName: 'Folder' depth: number folderName: string @@ -129,14 +132,14 @@ declare namespace tinyEngineDslVue { router: string } - interface ISchemaChildrenItem { + export interface ISchemaChildrenItem { children: Array componentName: string id: string props: Record } - interface IComponentMapItem { + export interface IComponentMapItem { componentName: string destructuring: boolean exportName?: string @@ -144,7 +147,7 @@ declare namespace tinyEngineDslVue { version: string } - interface IMetaInfo { + export interface IMetaInfo { name: string description: string } diff --git a/packages/vue-generator/src/plugins/formatCodePlugin.js b/packages/vue-generator/src/plugins/formatCodePlugin.js index 5662c41bf..b55d2f500 100644 --- a/packages/vue-generator/src/plugins/formatCodePlugin.js +++ b/packages/vue-generator/src/plugins/formatCodePlugin.js @@ -29,7 +29,7 @@ function formatCode(options = {}) { description: 'transform block schema to code', /** * 格式化出码 - * @param {tinyEngineDslVue.IAppSchema} schema + * @param {import('@opentiny/tiny-engine-dsl-vue').IAppSchema} schema * @returns */ run(schema, context) { diff --git a/packages/vue-generator/src/plugins/genBlockPlugin.js b/packages/vue-generator/src/plugins/genBlockPlugin.js index f2b834fba..879847017 100644 --- a/packages/vue-generator/src/plugins/genBlockPlugin.js +++ b/packages/vue-generator/src/plugins/genBlockPlugin.js @@ -15,7 +15,7 @@ function genBlockPlugin(options = {}) { description: 'transform block schema to code', /** * 将区块 schema 转换成高代码 - * @param {tinyEngineDslVue.IAppSchema} schema + * @param {import('@opentiny/tiny-engine-dsl-vue').IAppSchema} schema * @returns */ run(schema) { diff --git a/packages/vue-generator/src/plugins/genDataSourcePlugin.js b/packages/vue-generator/src/plugins/genDataSourcePlugin.js index 0b8b0c74d..3c17badfe 100644 --- a/packages/vue-generator/src/plugins/genDataSourcePlugin.js +++ b/packages/vue-generator/src/plugins/genDataSourcePlugin.js @@ -15,7 +15,7 @@ function genDataSourcePlugin(options = {}) { description: 'transform schema to dataSource plugin', /** * 转换 dataSource - * @param {tinyEngineDslVue.IAppSchema} schema + * @param {import('@opentiny/tiny-engine-dsl-vue').IAppSchema} schema * @returns */ run(schema) { diff --git a/packages/vue-generator/src/plugins/genDependenciesPlugin.js b/packages/vue-generator/src/plugins/genDependenciesPlugin.js index da84f3b7b..5bdb77a8b 100644 --- a/packages/vue-generator/src/plugins/genDependenciesPlugin.js +++ b/packages/vue-generator/src/plugins/genDependenciesPlugin.js @@ -63,7 +63,7 @@ function genDependenciesPlugin(options = {}) { description: 'transform dependencies to package.json', /** * 分析依赖,写入 package.json - * @param {tinyEngineDslVue.IAppSchema} schema + * @param {import('@opentiny/tiny-engine-dsl-vue').IAppSchema} schema * @returns */ run(schema) { diff --git a/packages/vue-generator/src/plugins/genGlobalState.js b/packages/vue-generator/src/plugins/genGlobalState.js index 324f698a7..3e680a0c8 100644 --- a/packages/vue-generator/src/plugins/genGlobalState.js +++ b/packages/vue-generator/src/plugins/genGlobalState.js @@ -25,7 +25,7 @@ function genDependenciesPlugin(options = {}) { description: 'transform schema to globalState', /** * 转换 globalState - * @param {tinyEngineDslVue.IAppSchema} schema + * @param {import('@opentiny/tiny-engine-dsl-vue').IAppSchema} schema * @returns */ run(schema) { diff --git a/packages/vue-generator/src/plugins/genI18nPlugin.js b/packages/vue-generator/src/plugins/genI18nPlugin.js index be5fd00fd..290adece7 100644 --- a/packages/vue-generator/src/plugins/genI18nPlugin.js +++ b/packages/vue-generator/src/plugins/genI18nPlugin.js @@ -17,7 +17,7 @@ function genI18nPlugin(options = {}) { description: 'transform i18n schema to i18n code plugin', /** * 将国际化 schema 转换成 i18n 高代码 - * @param {tinyEngineDslVue.IAppSchema} schema + * @param {import('@opentiny/tiny-engine-dsl-vue').IAppSchema} schema * @returns */ run(schema) { diff --git a/packages/vue-generator/src/plugins/genPagePlugin.js b/packages/vue-generator/src/plugins/genPagePlugin.js index 9f6fb4306..68b9c7115 100644 --- a/packages/vue-generator/src/plugins/genPagePlugin.js +++ b/packages/vue-generator/src/plugins/genPagePlugin.js @@ -15,7 +15,7 @@ function genPagePlugin(options = {}) { description: 'transform page schema to code', /** * 将页面 schema 转换成高代码 - * @param {tinyEngineDslVue.IAppSchema} schema + * @param {import('@opentiny/tiny-engine-dsl-vue').IAppSchema} schema * @returns */ run(schema) { diff --git a/packages/vue-generator/src/plugins/genRouterPlugin.js b/packages/vue-generator/src/plugins/genRouterPlugin.js index 1a92510f4..bccc98eae 100644 --- a/packages/vue-generator/src/plugins/genRouterPlugin.js +++ b/packages/vue-generator/src/plugins/genRouterPlugin.js @@ -36,7 +36,7 @@ function genRouterPlugin(options = {}) { description: 'transform router schema to router code plugin', /** * 根据页面生成路由配置 - * @param {tinyEngineDslVue.IAppSchema} schema + * @param {import('@opentiny/tiny-engine-dsl-vue').IAppSchema} schema * @returns */ run(schema) { diff --git a/packages/vue-generator/src/plugins/genUtilsPlugin.js b/packages/vue-generator/src/plugins/genUtilsPlugin.js index ba89c5265..2c7a1cdab 100644 --- a/packages/vue-generator/src/plugins/genUtilsPlugin.js +++ b/packages/vue-generator/src/plugins/genUtilsPlugin.js @@ -42,7 +42,7 @@ function genUtilsPlugin(options = {}) { description: 'transform utils schema to utils code', /** * 生成 utils 源码 - * @param {tinyEngineDslVue.IAppSchema} schema + * @param {import('@opentiny/tiny-engine-dsl-vue').IAppSchema} schema * @returns */ run(schema) { diff --git a/packages/vue-generator/src/plugins/parseSchemaPlugin.js b/packages/vue-generator/src/plugins/parseSchemaPlugin.js index 5e62f520b..1510c9c23 100644 --- a/packages/vue-generator/src/plugins/parseSchemaPlugin.js +++ b/packages/vue-generator/src/plugins/parseSchemaPlugin.js @@ -7,7 +7,7 @@ function parseSchema() { /** * 解析schema,预处理 schema - * @param {tinyEngineDslVue.IAppSchema} schema + * @param {import('@opentiny/tiny-engine-dsl-vue').IAppSchema} schema * @returns */ run(schema) {