jamis
Version:
一种支持通过JSON配置方式生成页面的组件库
34 lines (33 loc) • 1.24 kB
TypeScript
import type { Schema } from 'jamis-core';
import type { IPlayNode } from './types';
export type Node = IPlayNode;
export type { Schema };
/**
* 从schema对象中加载出nodeMap.
* 采用迭代方式, 为每个节点生成唯一的nanoid.
* @returns 返回nodeMap和rootNode
*/
export declare const loadSchema: (schema: Schema) => [Map<string, Node>, Node];
/**
* 添加子节点.
* 复用加载逻辑, 将新节点及其子孙添加到 nodeMap.
*/
export declare const addChild: (nodeMap: Map<string, Node>, parentId: string, slot: string, newItemSchema: Schema) => Node;
/**
* 更新节点值.
* 逻辑简化: 先删除所有旧的子节点, 再根据 newValue 添加新的子节点.
*/
export declare const updateNode: (nodeMap: Map<string, Node>, id: string, newValue: Schema) => Node | null;
/**
* 删除节点及其所有子孙.
* 逻辑极其简单, 无需再关心兄弟节点.
*/
export declare const deleteNode: (nodeMap: Map<string, Node>, id: string) => void;
/**
* 导出最新的schema对象树.
*/
export declare const pipeOut: (nodeMap: Map<string, Node>, id: string) => Schema;
/**
* 序列化为JS文件字符串.
*/
export declare const toString: (nodeMap: Map<string, Node>, id: string) => string;