Skip to content

Commit f92213d

Browse files
cmtlytwebfanzc
authored andcommitted
docs: 补充注释
1 parent 295dce5 commit f92213d

File tree

4 files changed

+49
-4
lines changed

4 files changed

+49
-4
lines changed

packages/core/src/plugins.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ export * from '@zelpis/builder/plugins'
1010
export * from '@zelpis/render/plugins'
1111

1212
export interface ZelpisPluginOption {
13+
/**
14+
* 构建插件配置
15+
*/
1316
build?: BuilderPluginOption
17+
/**
18+
* 渲染插件配置
19+
*/
1420
render?: RenderPluginOption
1521
}
1622

packages/render/src/boot.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
1+
import type { ReactNode } from 'react'
12
import type { Root } from 'react-dom/client'
2-
import type { App } from 'vue'
3+
import type { App, Component } from 'vue'
34
import { once } from '@zelpis/shared'
45

56
interface BaseBootOption {
7+
/**
8+
* 渲染类型, 当前只支持 csr
9+
*/
610
type?: 'csr' | 'ssr'
11+
/**
12+
* 框架, 当前只支持 react 和 vue
13+
*/
714
framework: 'react' | 'vue'
8-
Component: (props: any) => any
15+
/**
16+
* 渲染组件
17+
*/
18+
Component: any
19+
/**
20+
* 挂载函数
21+
*/
922
mount?: (app: any) => void
1023
}
1124

1225
interface ReactBootOption extends BaseBootOption {
1326
framework: 'react'
27+
Component: (props: any) => ReactNode
1428
mount?: (app: Root) => void
1529
}
1630

1731
interface VueBootOption extends BaseBootOption {
1832
framework: 'vue'
33+
Component: Component
1934
mount?: (app: App) => void
2035
}
2136

@@ -42,7 +57,7 @@ async function createComponent(
4257
): Promise<any> {
4358
if (framework === 'react') {
4459
const { createElement } = await import('react')
45-
return createElement(Component, props)
60+
return createElement(Component as ReactBootOption['Component'], props)
4661
}
4762
if (framework === 'vue') {
4863
if (option.type === 'csr') {

packages/render/src/plugins/render-plugin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const APP_BODY_START_PLACEHOLDER = STANDARD_PLACEHOLDERS.APP_BODY_START
1616
const APP_INJECT_SCRIPT_PLACEHOLDER = STANDARD_PLACEHOLDERS.APP_INJECT_SCRIPT
1717

1818
export interface RenderPluginOption {
19+
/**
20+
* 用于索引 entry 的相对路径
21+
*/
1922
baseDir?: string
2023
}
2124

packages/shared/src/html-config/types.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,46 @@ export interface HtmlConfig {
3232
* 入口配置
3333
*/
3434
export interface Entry {
35+
/**
36+
* url base path
37+
*/
3538
basePath: string
39+
/**
40+
* 入口文件路径
41+
*/
3642
entryPath: string
43+
/**
44+
* 当前入口文件对应的 DSL 文件夹路径
45+
*/
3746
dslPath?: string
47+
/**
48+
* 当前入口文件对应的 DSL 文件
49+
*/
3850
dslEntrys?: any[]
51+
/**
52+
* HTML 配置
53+
*/
3954
html?: HtmlConfig
4055
}
4156

4257
/**
4358
* 解析 HTML 选项
4459
*/
4560
export interface ResolveHtmlOptions {
46-
entry: Entry
61+
entry: Omit<Entry, 'dslEntrys'>
4762
defaultHtml?: HtmlConfig
4863
rootDir?: string
4964
ensurePlaceholders?: string[]
5065
}
5166

5267
export interface ZElpisConfig {
68+
/**
69+
* 入口配置
70+
*/
5371
entrys: Entry[]
72+
/**
73+
* 默认 HTML 配置
74+
*/
5475
defaultHtml?: HtmlConfig
5576
}
5677

0 commit comments

Comments
 (0)