@blocklet/pages-kit-core 0.5.30 → 0.5.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1 @@
1
- export * from './types';
2
- export * from './core';
3
- export * from './dataset';
1
+ export * from './template-model';
@@ -0,0 +1,124 @@
1
+ export declare const DEFAULT_CHILDREN_PROPERTIES: string[];
2
+ export declare const PAGES_KIT_CHILDREN_PROPERTIES: ((node: Node) => any)[];
3
+ type WalkStrategy = 'pre' | 'post' | 'breadth';
4
+ export type ChildrenResolver = string | ((node: Node, locale?: string) => any[]);
5
+ interface TemplateModelConfig {
6
+ childrenProperties?: ChildrenResolver[];
7
+ locale?: string;
8
+ }
9
+ interface NodeModel {
10
+ [key: string]: any;
11
+ }
12
+ interface WalkOptions {
13
+ strategy?: WalkStrategy;
14
+ }
15
+ interface WalkFunction<T = any> {
16
+ (node: Node): boolean | void | T;
17
+ }
18
+ /**
19
+ * 表示树中的一个节点
20
+ */
21
+ export declare class Node {
22
+ parent?: Node;
23
+ children: Node[];
24
+ config: TemplateModelConfig;
25
+ model: NodeModel;
26
+ constructor(config: TemplateModelConfig, model: NodeModel);
27
+ isRoot(): boolean;
28
+ hasChildren(): boolean;
29
+ getPath(): Node[];
30
+ walk(options: WalkOptions, fn?: WalkFunction, ctx?: any): void;
31
+ walk(fn: WalkFunction, ctx?: any): void;
32
+ all(options: WalkOptions, fn?: WalkFunction, ctx?: any): Node[];
33
+ all(fn?: WalkFunction, ctx?: any): Node[];
34
+ first(options: WalkOptions, fn?: WalkFunction, ctx?: any): Node | undefined;
35
+ first(fn?: WalkFunction, ctx?: any): Node | undefined;
36
+ /**
37
+ * 在所有子节点源中查找节点
38
+ */
39
+ findAll(predicate: WalkFunction): Node[];
40
+ private parseArgs;
41
+ /**
42
+ * 获取节点在父节点中的索引
43
+ */
44
+ getIndex(): number;
45
+ /**
46
+ * 获取节点完整的JSON路径表示
47
+ * 返回一个能直接访问JSON对象的路径数组
48
+ */
49
+ getJsonPath(): string[];
50
+ /**
51
+ * 获取节点导出数据
52
+ */
53
+ getExportData(): NodeModel;
54
+ /**
55
+ * 获取深拷贝
56
+ */
57
+ private _cloneObject;
58
+ }
59
+ /**
60
+ * 树模型类,用于将普通对象转换为树结构
61
+ */
62
+ export declare class TemplateModel {
63
+ private config;
64
+ private componentsById;
65
+ private rootComponentIds;
66
+ originalModel: NodeModel | null;
67
+ parseModel: NodeModel | null;
68
+ root: Node | null;
69
+ constructor(config?: TemplateModelConfig);
70
+ /**
71
+ * 添加子节点解析器
72
+ */
73
+ addChildrenResolver(resolver: ChildrenResolver): void;
74
+ /**
75
+ * 新增: 构建扁平索引
76
+ */
77
+ private _buildFlatIndex;
78
+ parse(model: NodeModel, { isClone, }?: {
79
+ isClone?: boolean;
80
+ }): Node;
81
+ /**
82
+ * 新增: 根据ID快速获取组件节点
83
+ */
84
+ getComponentById(id: string): Node | null;
85
+ /**
86
+ * 新增: 获取组件所有父节点
87
+ */
88
+ getComponentAncestors(id: string): Node[];
89
+ /**
90
+ * 新增: 获取组件的子组件
91
+ */
92
+ getChildComponents(id: string): Node[];
93
+ /**
94
+ * 新增: 获取组件的兄弟组件
95
+ */
96
+ getSiblingComponents(id: string): Node[];
97
+ findAll(tree: Node, predicate: WalkFunction): Node[];
98
+ /**
99
+ * 新增: 获取所有根组件
100
+ */
101
+ getRootComponents(): Node[];
102
+ /**
103
+ * 新增: 检查组件是否存在
104
+ */
105
+ hasComponent(id: string): boolean;
106
+ /**
107
+ * 获取组件的完整JSON路径表示
108
+ * 返回一个能直接访问JSON对象的路径数组
109
+ */
110
+ getComponentJsonPath(id: string): string[];
111
+ /**
112
+ * 获取根节点
113
+ */
114
+ getRoot(): Node | null;
115
+ /**
116
+ * 获取根节点导出数据
117
+ */
118
+ getRootExportData(): NodeModel | null;
119
+ /**
120
+ * 获取深拷贝
121
+ */
122
+ private _cloneObject;
123
+ }
124
+ export default TemplateModel;