basic rebuild implementation

This commit is contained in:
Yanzhen Yu
2026-04-01 12:00:00 +08:00
parent 97c4b4f6e1
commit a71fb73aaf
4 changed files with 193 additions and 137 deletions

55
src/types.ts Normal file
View File

@@ -0,0 +1,55 @@
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;
};
export type elementNode = {
type: NodeType.Element;
tagName: string;
attributes: attributes;
childNodes: serializedNodeWithId[];
};
export type textNode = {
type: NodeType.Text;
textContent: string;
};
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 };