Skip to content

Commit

Permalink
fix: change namespace 2 export module (#837)
Browse files Browse the repository at this point in the history
* fix: change namespace 2 export module

* fix: add missing type params
  • Loading branch information
chilingling authored and kevinmoch committed Dec 4, 2024
1 parent 273cd37 commit 8bfa0a4
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 32 deletions.
4 changes: 2 additions & 2 deletions packages/vue-generator/src/generator/generateApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}) {
Expand Down
43 changes: 23 additions & 20 deletions packages/vue-generator/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
declare namespace tinyEngineDslVue {
type defaultPlugins =
declare module '@opentiny/tiny-engine-dsl-vue' {
export function generateCode(param: { pageInfo: any; componentsMap?: Array<any>; blocksData?: Array<any> }): {
[key: string]: any
}
export type defaultPlugins =
| 'template'
| 'block'
| 'page'
Expand All @@ -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
} & {
Expand All @@ -26,7 +29,7 @@ declare namespace tinyEngineDslVue {
customContext?: Record<string, any>
}

interface IContext {
export interface IContext {
config: Record<string, any>
genResult: Array<IFile>
genLogs: Array<any>
Expand All @@ -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<any>
genResult: Array<IFile>
genLogs: Array<any>
}

interface IFile {
export interface IFile {
fileType: string
fileName: string
path: string
fileContent: string
}

interface IAppSchema {
export interface IAppSchema {
i18n: {
en_US: Record<string, any>
zh_CN: Record<string, any>
Expand All @@ -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<string, any>
actions: Record<string, IFuncType>
getters: Record<string, IFuncType>
}

interface IPageSchema {
export interface IPageSchema {
componentName: 'Page' | 'Block'
css: string
fileName: string
Expand All @@ -120,7 +123,7 @@ declare namespace tinyEngineDslVue {
}
}

interface IFolderItem {
export interface IFolderItem {
componentName: 'Folder'
depth: number
folderName: string
Expand All @@ -129,22 +132,22 @@ declare namespace tinyEngineDslVue {
router: string
}

interface ISchemaChildrenItem {
export interface ISchemaChildrenItem {
children: Array<ISchemaChildrenItem>
componentName: string
id: string
props: Record<string, any>
}

interface IComponentMapItem {
export interface IComponentMapItem {
componentName: string
destructuring: boolean
exportName?: string
package?: string
version: string
}

interface IMetaInfo {
export interface IMetaInfo {
name: string
description: string
}
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-generator/src/plugins/formatCodePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-generator/src/plugins/genBlockPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-generator/src/plugins/genDataSourcePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-generator/src/plugins/genGlobalState.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-generator/src/plugins/genI18nPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-generator/src/plugins/genPagePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-generator/src/plugins/genRouterPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-generator/src/plugins/genUtilsPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vue-generator/src/plugins/parseSchemaPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function parseSchema() {

/**
* 解析schema,预处理 schema
* @param {tinyEngineDslVue.IAppSchema} schema
* @param {import('@opentiny/tiny-engine-dsl-vue').IAppSchema} schema
* @returns
*/
run(schema) {
Expand Down

0 comments on commit 8bfa0a4

Please sign in to comment.