forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjsx.ts
More file actions
29 lines (25 loc) · 955 Bytes
/
jsx.ts
File metadata and controls
29 lines (25 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { NodeSchema, CompositeValue } from '@alilc/lowcode-types';
import { HandlerSet, BaseGenerator, NodeGenerator } from './core';
export enum PIECE_TYPE {
BEFORE = 'NodeCodePieceBefore',
TAG = 'NodeCodePieceTag',
ATTR = 'NodeCodePieceAttr',
CHILDREN = 'NodeCodePieceChildren',
AFTER = 'NodeCodePieceAfter',
}
export interface CodePiece {
name?: string;
value: string;
type: PIECE_TYPE;
}
export interface AttrData { attrName: string; attrValue: CompositeValue }
// 对 JSX 出码的理解,目前定制点包含 【包装】【标签名】【属性】
export type AttrPlugin = BaseGenerator<AttrData, CodePiece[], NodeGeneratorConfig>;
export type NodePlugin = BaseGenerator<NodeSchema, CodePiece[], NodeGeneratorConfig>;
export interface NodeGeneratorConfig {
handlers?: HandlerSet<string>;
tagMapping?: (input: string) => string;
attrPlugins?: AttrPlugin[];
nodePlugins?: NodePlugin[];
self?: NodeGenerator<string>;
}