docs: 参照协议规范,完善所有 schema 和 asset 相关描述

This commit is contained in:
humphry.hy 2021-12-13 19:47:11 +08:00
parent 1a2f82154b
commit 820f8c046c
8 changed files with 327 additions and 47 deletions

View File

@ -1,6 +1,7 @@
import { NpmInfo } from './npm'; import { NpmInfo } from './npm';
import { PropConfig } from './prop-config'; import { PropConfig } from './prop-config';
import { Snippet, ComponentMetadata } from './metadata'; import { Snippet, ComponentMetadata } from './metadata';
import { I18nData } from './i18n';
/** /**
* external资源的信息 * external资源的信息
@ -27,7 +28,7 @@ export interface Package {
*/ */
library: string; library: string;
/** /**
* todo * @todo
*/ */
async?: boolean; async?: boolean;
/** /**
@ -77,11 +78,13 @@ export interface ComponentItem {
/** /**
* *
*/ */
group?: string; group?: string | I18nData;
/** /**
* *
*/ */
category?: string; category?: string | I18nData;
/** /**
* *
*/ */
@ -93,7 +96,7 @@ export interface ComponentItem {
*/ */
export interface ComponentDescription extends ComponentMetadata { export interface ComponentDescription extends ComponentMetadata {
/** /**
* todo * @todo
*/ */
keywords: string[]; keywords: string[];
} }

View File

@ -50,11 +50,20 @@ export interface FieldExtraProps {
* compatiable vision display * compatiable vision display
*/ */
display?: 'accordion' | 'inline' | 'block' | 'plain' | 'popup' | 'entry'; display?: 'accordion' | 'inline' | 'block' | 'plain' | 'popup' | 'entry';
// todo 这个 omit 是否合理? // @todo 这个 omit 是否合理?
/**
* @todo
*/
liveTextEditing?: Omit<LiveTextEditingConfig, 'propTarget'>; liveTextEditing?: Omit<LiveTextEditingConfig, 'propTarget'>;
} }
/**
*
*/
export interface FieldConfig extends FieldExtraProps { export interface FieldConfig extends FieldExtraProps {
/**
* @todo
*/
type?: 'field' | 'group'; type?: 'field' | 'group';
/** /**
* the name of this setting field, which used in quickEditor * the name of this setting field, which used in quickEditor
@ -78,11 +87,11 @@ export interface FieldConfig extends FieldExtraProps {
*/ */
extraProps?: FieldExtraProps; extraProps?: FieldExtraProps;
/** /**
* todo * @todo
*/ */
description?: TitleContent; description?: TitleContent;
/** /**
* todo * @todo
*/ */
isExtends?: boolean; isExtends?: boolean;
} }

View File

@ -9,7 +9,14 @@ import { NodeSchema, NodeData, ComponentSchema } from './schema';
import { SettingTarget } from './setting-target'; import { SettingTarget } from './setting-target';
import { I18nData } from './i18n'; import { I18nData } from './i18n';
/**
*
*/
export type NestingFilter = (testNode: any, currentNode: any) => boolean; export type NestingFilter = (testNode: any, currentNode: any) => boolean;
/**
*
* a a, FormField Form Column Table
*/
export interface NestingRule { export interface NestingRule {
/** /**
* *
@ -33,26 +40,64 @@ export interface NestingRule {
ancestorWhitelist?: string[] | string | RegExp | NestingFilter; ancestorWhitelist?: string[] | string | RegExp | NestingFilter;
} }
/**
*
*/
export interface ComponentConfigure { export interface ComponentConfigure {
/**
*
*/
isContainer?: boolean; isContainer?: boolean;
/**
*
*/
isModal?: boolean; isModal?: boolean;
/**
*
*/
isNullNode?: boolean; isNullNode?: boolean;
/**
*
*/
descriptor?: string; descriptor?: string;
/**
*
* a a, FormField Form Column Table
*/
nestingRule?: NestingRule; nestingRule?: NestingRule;
/**
*
*
*/
isMinimalRenderUnit?: boolean; isMinimalRenderUnit?: boolean;
/**
* cssSelector
*/
rootSelector?: string; rootSelector?: string;
/** /**
* copy, move, remove | * * `'copy'`, `'move'`, `'remove'`
*/ */
disableBehaviors?: string[] | string; disableBehaviors?: string[] | string;
/**
*
*/
actions?: ComponentAction[]; actions?: ComponentAction[];
} }
export interface Snippet { export interface Snippet {
/**
* title
*/
title?: string; title?: string;
/**
* snippet
*/
screenshot?: string; screenshot?: string;
/**
* @todo snippet
*/
label?: string; label?: string;
schema?: NodeSchema; schema?: NodeSchema;
} }
@ -70,26 +115,61 @@ export interface AutorunItem {
autorun: (target: SettingTarget) => any; autorun: (target: SettingTarget) => any;
} }
/**
*
*/
export interface Experimental { export interface Experimental {
/**
* @todo
*/
context?: { [contextInfoName: string]: any }; context?: { [contextInfoName: string]: any };
/**
* @todo
*/
snippets?: Snippet[]; snippets?: Snippet[];
/**
* @todo
*/
view?: ComponentType<any>; view?: ComponentType<any>;
/**
* @todo
*/
transducers?: any; transducers?: any;
/** /**
* @deprecated * @deprecated prop
*/ */
initials?: InitialItem[]; initials?: InitialItem[];
/**
* @todo
*/
filters?: FilterItem[]; filters?: FilterItem[];
/**
* @todo
*/
autoruns?: AutorunItem[]; autoruns?: AutorunItem[];
/**
* callbacks onNodeAddonResize
*/
callbacks?: Callbacks; callbacks?: Callbacks;
/**
* @todo
*/
initialChildren?: NodeData[] | ((target: SettingTarget) => NodeData[]); initialChildren?: NodeData[] | ((target: SettingTarget) => NodeData[]);
/**
* @todo
*/
isAbsoluteLayoutContainer?: boolean; isAbsoluteLayoutContainer?: boolean;
/**
* @todo
*/
hideSelectTools?: boolean; hideSelectTools?: boolean;
/** /**
* handle上必须有明确的标识以便事件路由判断 * handle上必须有明确的标识以便事件路由判断
* NWSE ReactElement * NWSE ReactElement
*/
/**
* resize
* - hover * - hover
* - mousedown * - mousedown
* - dragstart resizing hud * - dragstart resizing hud
@ -111,6 +191,10 @@ export interface Experimental {
* Live Text Editing children * Live Text Editing children
*/ */
liveTextEditing?: LiveTextEditingConfig[]; liveTextEditing?: LiveTextEditingConfig[];
/**
* @todo
*/
isTopFixed?: boolean; isTopFixed?: boolean;
} }
@ -120,11 +204,11 @@ export interface Experimental {
*/ */
export interface LiveTextEditingConfig { export interface LiveTextEditingConfig {
/** /**
* todo * @todo
*/ */
propTarget: string; propTarget: string;
/** /**
* todo * @todo
*/ */
selector?: string; selector?: string;
/** /**
@ -144,22 +228,58 @@ export type ConfigureSupportEvent = string | {
description?: string; description?: string;
}; };
export type ConfigureSupport = { /**
*
*/
export interface ConfigureSupport {
/**
*
*/
events?: ConfigureSupportEvent[]; events?: ConfigureSupportEvent[];
/**
* className
*/
className?: boolean; className?: boolean;
/**
*
*/
style?: boolean; style?: boolean;
/**
*
*/
lifecycles?: any[]; lifecycles?: any[];
// general?: boolean; // general?: boolean;
/**
*
*/
loop?: boolean; loop?: boolean;
/**
*
*/
condition?: boolean; condition?: boolean;
}; }
/**
*
*/
export interface Configure { export interface Configure {
/**
*
*/
props?: FieldConfig[]; props?: FieldConfig[];
/**
*
*/
component?: ComponentConfigure; component?: ComponentConfigure;
/**
*
*/
supports?: ConfigureSupport; supports?: ConfigureSupport;
} }
/**
*
*/
export interface ActionContentObject { export interface ActionContentObject {
/** /**
* *
@ -175,6 +295,9 @@ export interface ActionContentObject {
action?: (currentNode: any) => void; action?: (currentNode: any) => void;
} }
/**
* @todo
*/
export interface ComponentAction { export interface ComponentAction {
/** /**
* behaviorName * behaviorName
@ -203,7 +326,13 @@ export function isActionContentObject(obj: any): obj is ActionContentObject {
return obj && typeof obj === 'object'; return obj && typeof obj === 'object';
} }
/**
* meta
*/
export interface ComponentMetadata { export interface ComponentMetadata {
/**
*
*/
componentName: string; componentName: string;
/** /**
* unique id * unique id
@ -217,22 +346,67 @@ export interface ComponentMetadata {
* svg icon for component * svg icon for component
*/ */
icon?: IconType; icon?: IconType;
/**
*
*/
tags?: string[]; tags?: string[];
/**
*
*/
description?: string; description?: string;
/**
*
*/
docUrl?: string; docUrl?: string;
/**
*
*/
screenshot?: string; screenshot?: string;
/**
*
*/
devMode?: 'procode' | 'lowcode'; devMode?: 'procode' | 'lowcode';
/**
* npm
*/
npm?: NpmInfo; npm?: NpmInfo;
/**
*
*/
props?: PropConfig[]; props?: PropConfig[];
/**
*
*/
configure?: FieldConfig[] | Configure; configure?: FieldConfig[] | Configure;
/**
*
*/
experimental?: Experimental; experimental?: Experimental;
/**
* @todo
*/
schema?: ComponentSchema; schema?: ComponentSchema;
/**
*
*/
snippets?: Snippet[]; snippets?: Snippet[];
/**
*
*/
group?: string | I18nData; group?: string | I18nData;
/**
*
*/
category?: string | I18nData; category?: string | I18nData;
/**
*
*/
priority?: number; priority?: number;
} }
/**
* @todo
*/
export interface TransformedComponentMetadata extends ComponentMetadata { export interface TransformedComponentMetadata extends ComponentMetadata {
configure: Configure & { combined?: FieldConfig[] }; configure: Configure & { combined?: FieldConfig[] };
} }
@ -242,12 +416,10 @@ export interface TransformedComponentMetadata extends ComponentMetadata {
*/ */
/** /**
* hooks & events * callbacks onNodeAddonResize
*/ */
export interface Callbacks { export interface Callbacks {
/** // hooks
* hooks
*/
onMouseDownHook?: (e: MouseEvent, currentNode: any) => any; onMouseDownHook?: (e: MouseEvent, currentNode: any) => any;
onDblClickHook?: (e: MouseEvent, currentNode: any) => any; onDblClickHook?: (e: MouseEvent, currentNode: any) => any;
onClickHook?: (e: MouseEvent, currentNode: any) => any; onClickHook?: (e: MouseEvent, currentNode: any) => any;
@ -258,9 +430,7 @@ export interface Callbacks {
onHoverHook?: (currentNode: any) => boolean; onHoverHook?: (currentNode: any) => boolean;
onChildMoveHook?: (childNode: any, currentNode: any) => boolean; onChildMoveHook?: (childNode: any, currentNode: any) => boolean;
/** // events
* events
*/
onNodeRemove?: (removedNode: any, currentNode: any) => void; onNodeRemove?: (removedNode: any, currentNode: any) => void;
onNodeAdd?: (addedNode: any, currentNode: any) => void; onNodeAdd?: (addedNode: any, currentNode: any) => void;
onSubtreeModified?: (currentNode: any, options: any) => void; onSubtreeModified?: (currentNode: any, options: any) => void;

View File

@ -1,10 +1,34 @@
/**
* npm
*/
export interface NpmInfo { export interface NpmInfo {
/**
*
*/
componentName?: string; componentName?: string;
/**
*
*/
package: string; package: string;
/**
*
*/
version?: string; version?: string;
/**
*
*/
destructuring?: boolean; destructuring?: boolean;
/**
*
*/
exportName?: string; exportName?: string;
/**
*
*/
subName?: string; subName?: string;
/**
*
*/
main?: string; main?: string;
} }

View File

@ -38,10 +38,28 @@ export interface Exact {
isRequired?: boolean; isRequired?: boolean;
} }
/**
*
*/
export interface PropConfig { export interface PropConfig {
/**
*
*/
name: string; name: string;
/**
*
*/
propType: PropType; propType: PropType;
/**
*
*/
description?: string; description?: string;
/**
*
*/
defaultValue?: any; defaultValue?: any;
/**
* @todo
*/
setter?: any; setter?: any;
} }

View File

@ -12,6 +12,7 @@ import { UtilsMap } from './utils';
import { AppConfig } from './app-config'; import { AppConfig } from './app-config';
// 转换成一个 .jsx 文件内 React Class 类 render 函数返回的 jsx 代码 // 转换成一个 .jsx 文件内 React Class 类 render 函数返回的 jsx 代码
/** /**
* - * -
*/ */
@ -50,9 +51,7 @@ export interface NodeSchema {
*/ */
isLocked?: boolean; isLocked?: boolean;
/** // ------- future support -----
* ------- future support -----
*/
conditionGroup?: string; conditionGroup?: string;
title?: string; title?: string;
ignore?: boolean; ignore?: boolean;
@ -77,25 +76,53 @@ export function isDOMText(data: any): data is DOMText {
export type DOMText = string; export type DOMText = string;
/**
*
*/
export interface ContainerSchema extends NodeSchema { export interface ContainerSchema extends NodeSchema {
/** /**
* 'Block' | 'Page' | 'Component'; * 'Block' | 'Page' | 'Component';
*/ */
componentName: string; componentName: string;
/**
*
*/
fileName: string; fileName: string;
/**
* @todo
*/
meta?: Record<string, unknown>; meta?: Record<string, unknown>;
/**
*
*/
state?: { state?: {
[key: string]: CompositeValue; [key: string]: CompositeValue;
}; };
/**
*
*/
methods?: { methods?: {
[key: string]: JSExpression | JSFunction; [key: string]: JSExpression | JSFunction;
}; };
/**
*
*/
lifeCycles?: { lifeCycles?: {
[key: string]: JSExpression | JSFunction; [key: string]: JSExpression | JSFunction;
}; };
/**
*
*/
css?: string; css?: string;
/**
*
*/
dataSource?: DataSource; dataSource?: DataSource;
/**
*
*/
defaultProps?: CompositeObject; defaultProps?: CompositeObject;
// @todo propDefinitions
} }
/** /**
@ -122,25 +149,69 @@ export interface BlockSchema extends ContainerSchema {
componentName: 'Block'; componentName: 'Block';
} }
/**
* @todo
*/
export type RootSchema = PageSchema | ComponentSchema | BlockSchema; export type RootSchema = PageSchema | ComponentSchema | BlockSchema;
/**
* Slot schema
*/
export interface SlotSchema extends NodeSchema { export interface SlotSchema extends NodeSchema {
componentName: 'Slot'; componentName: 'Slot';
name?: string; name?: string;
params?: string[]; params?: string[];
} }
/**
*
*/
export interface ProjectSchema { export interface ProjectSchema {
/**
*
*/
version: string; version: string;
/**
*
*/
componentsMap: ComponentsMap; componentsMap: ComponentsMap;
/**
*
*
* 1,
*/
componentsTree: RootSchema[]; componentsTree: RootSchema[];
/**
*
*/
i18n?: I18nMap; i18n?: I18nMap;
/**
*
*/
utils?: UtilsMap; utils?: UtilsMap;
/**
* @todo
*/
constants?: JSONObject; constants?: JSONObject;
/**
*
*/
css?: string; css?: string;
/**
*
*/
dataSource?: DataSource; dataSource?: DataSource;
/**
*
*/
config?: AppConfig | Record<string, any>; config?: AppConfig | Record<string, any>;
/**
* @todo
*/
id?: string; id?: string;
/**
*
*/
meta?: Record<string, any>; meta?: Record<string, any>;
} }

View File

@ -77,7 +77,7 @@ export interface SettingTarget {
*/ */
setExtraPropValue: (propName: string, value: any) => void; setExtraPropValue: (propName: string, value: any) => void;
// todo 补充 node 定义 // @todo 补充 node 定义
/** /**
* node * node
*/ */

View File

@ -17,24 +17,12 @@ export interface JSExpression {
compiled?: string; compiled?: string;
} }
/**
*
*/
export interface JSFunction {
type: 'JSFunction';
/**
*
*/
value: string;
}
/** /**
* *
* @see https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#feHTW * @see https://yuque.antfin-inc.com/mo/spec/spec-low-code-building-schema#feHTW
*/ */
export interface JSFunction { export interface JSFunction {
type: 'JSFunction'; type: 'JSFunction';
/** /**
* *
*/ */
@ -42,27 +30,21 @@ export interface JSFunction {
/** 源码 */ /** 源码 */
compiled?: string; compiled?: string;
}
/**
*
*/
export interface JSFunction {
type: 'JSFunction';
/**
*
*/
value: string;
/** /**
* *
*/ */
mock?: any; mock?: any;
/** /**
* extTypeevents * extTypeevents
*/ */
[key: string]: any; [key: string]: any;
} }
/**
* Slot
*/
export interface JSSlot { export interface JSSlot {
type: 'JSSlot'; type: 'JSSlot';
title?: string; title?: string;
@ -74,6 +56,9 @@ export interface JSSlot {
name?: string; name?: string;
} }
/**
* @todo
*/
export interface JSBlock { export interface JSBlock {
type: 'JSBlock'; type: 'JSBlock';
value: NodeSchema; value: NodeSchema;