70 lines
1.1 KiB
TypeScript
70 lines
1.1 KiB
TypeScript
export enum NodeType {
|
|
Document,
|
|
DocumentType,
|
|
Element,
|
|
Text,
|
|
CDATA,
|
|
Comment,
|
|
}
|
|
|
|
export type documentNode = {
|
|
type: NodeType.Document;
|
|
childNodes: serializedNodeWithId[];
|
|
};
|
|
|
|
export type documentTypeNode = {
|
|
type: NodeType.DocumentType;
|
|
name: string;
|
|
publicId: string;
|
|
systemId: string;
|
|
};
|
|
|
|
export type attributes = {
|
|
[key: string]: string | boolean;
|
|
};
|
|
export type elementNode = {
|
|
type: NodeType.Element;
|
|
tagName: string;
|
|
attributes: attributes;
|
|
childNodes: serializedNodeWithId[];
|
|
isSVG?: true;
|
|
};
|
|
|
|
export type textNode = {
|
|
type: NodeType.Text;
|
|
textContent: string;
|
|
isStyle?: true;
|
|
};
|
|
|
|
export type cdataNode = {
|
|
type: NodeType.CDATA;
|
|
textContent: '';
|
|
};
|
|
|
|
export type commentNode = {
|
|
type: NodeType.Comment;
|
|
textContent: string;
|
|
};
|
|
|
|
export type serializedNode =
|
|
| documentNode
|
|
| documentTypeNode
|
|
| elementNode
|
|
| textNode
|
|
| cdataNode
|
|
| commentNode;
|
|
|
|
export type serializedNodeWithId = serializedNode & { id: number };
|
|
|
|
export type tagMap = {
|
|
[key: string]: string;
|
|
};
|
|
|
|
export interface INode extends Node {
|
|
__sn: serializedNodeWithId;
|
|
}
|
|
|
|
export type idNodeMap = {
|
|
[key: number]: INode;
|
|
};
|