From c59eee0ccaca81ac94f4edf71e47b1aee34bbe6f Mon Sep 17 00:00:00 2001 From: "lihao.ylh" Date: Wed, 5 Jan 2022 15:11:25 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=A2=9E=E5=8A=A0=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + packages/shell/src/component-meta.ts | 39 ++++++++-- packages/shell/src/detecting.ts | 11 +++ packages/shell/src/document-model.ts | 2 +- packages/shell/src/event.ts | 20 ++++++ packages/shell/src/history.ts | 31 ++++++++ packages/shell/src/hotkey.ts | 7 ++ packages/shell/src/material.ts | 49 +++++++++++++ packages/shell/src/node-children.ts | 91 +++++++++++++++++++++++- packages/shell/src/node.ts | 67 ++++++++++++++++- packages/shell/src/project.ts | 3 + packages/shell/src/prop.ts | 31 +++++++- packages/shell/src/props.ts | 6 ++ packages/shell/src/selection.ts | 31 ++++++++ packages/shell/src/setters.ts | 15 ++++ packages/shell/src/setting-prop-entry.ts | 29 ++++++++ packages/shell/src/setting-top-entry.ts | 13 ++++ packages/shell/src/simulator-host.ts | 16 +++++ packages/shell/src/skeleton.ts | 11 +++ 19 files changed, 461 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 380a057ce..a3fa53259 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "lint": "eslint --ext .ts,.tsx,.js,.jsx ./ --quiet", "lint:fix": "eslint --ext .ts,.tsx,.js,.jsx ./ --quiet --fix", "pub": "tnpm run watchdog:build && lerna publish patch --force-publish --exact --no-changelog", + "pub:premajor": "tnpm run watchdog:build && lerna publish premajor --force-publish --exact --dist-tag beta --preid beta --no-changelog", "pub:prepatch": "tnpm run watchdog:build && lerna publish prepatch --force-publish --exact --dist-tag beta --preid beta --no-changelog", "pub:prerelease": "tnpm run watchdog:build && lerna publish prerelease --force-publish --exact --dist-tag beta --preid beta --no-changelog", "setup": "./scripts/setup.sh", diff --git a/packages/shell/src/component-meta.ts b/packages/shell/src/component-meta.ts index 0e7cd79e2..80e1271c4 100644 --- a/packages/shell/src/component-meta.ts +++ b/packages/shell/src/component-meta.ts @@ -29,46 +29,77 @@ export default class ComponentMeta { return new ComponentMeta(componentMeta); } + /** + * 组件名 + */ get componentName(): string { return this[componentMetaSymbol].componentName; } + /** + * 是否是「容器型」组件 + */ get isContainer(): boolean { return this[componentMetaSymbol].isContainer; } + /** + * 是否是最小渲染单元。 + * 当组件需要重新渲染时: + * 若为最小渲染单元,则只渲染当前组件, + * 若不为最小渲染单元,则寻找到上层最近的最小渲染单元进行重新渲染,直至根节点。 + */ get isMinimalRenderUnit(): boolean { return this[componentMetaSymbol].isMinimalRenderUnit; } + /** + * 是否为「模态框」组件 + */ get isModal(): boolean { return this[componentMetaSymbol].isModal; } + /** + * 元数据配置 + */ get configure() { return this[componentMetaSymbol].configure; } + /** + * 标题 + */ get title() { return this[componentMetaSymbol].title; } + /** + * 图标 + */ get icon() { return this[componentMetaSymbol].icon; } + /** + * 组件 npm 信息 + */ get npm() { return this[componentMetaSymbol].npm; } - get acceptable(): boolean { - return this[componentMetaSymbol].acceptable; - } - + /** + * 设置 npm 信息 + * @param npm + */ setNpm(npm: any) { this[componentMetaSymbol].setNpm(npm); } + /** + * 获取元数据 + * @returns + */ getMetadata() { return this[componentMetaSymbol].getMetadata(); } diff --git a/packages/shell/src/detecting.ts b/packages/shell/src/detecting.ts index bbcfc7e7b..5dab5ee42 100644 --- a/packages/shell/src/detecting.ts +++ b/packages/shell/src/detecting.ts @@ -13,14 +13,25 @@ export default class Detecting { this[detectingSymbol] = document.designer.detecting; } + /** + * hover 指定节点 + * @param id 节点 id + */ capture(id: string) { this[detectingSymbol].capture(this[documentSymbol].getNode(id)); } + /** + * hover 离开指定节点 + * @param id 节点 id + */ release(id: string) { this[detectingSymbol].release(this[documentSymbol].getNode(id)); } + /** + * 清空 hover 态 + */ leave() { this[detectingSymbol].leave(this[documentSymbol]); } diff --git a/packages/shell/src/document-model.ts b/packages/shell/src/document-model.ts index fba2f3e81..12d36eb81 100644 --- a/packages/shell/src/document-model.ts +++ b/packages/shell/src/document-model.ts @@ -101,7 +101,7 @@ export default class DocumentModel { * @param stage * @returns */ - exportSchema(stage?: TransformStage) { + exportSchema(stage: TransformStage = TransformStage.Render) { return this[documentSymbol].export(stage); } diff --git a/packages/shell/src/event.ts b/packages/shell/src/event.ts index 1956b5768..897185346 100644 --- a/packages/shell/src/event.ts +++ b/packages/shell/src/event.ts @@ -25,10 +25,30 @@ export default class Event { } } + /** + * 监听事件 + * @param event 事件名称 + * @param listener 事件回调 + */ on(event: string, listener: (...args: unknown[]) => void) { this[editorSymbol].on(event, listener); } + /** + * 取消监听事件 + * @param event 事件名称 + * @param listener 事件回调 + */ + off(event: string, listener: (...args: unknown[]) => void) { + this[editorSymbol].off(event, listener); + } + + /** + * 触发事件 + * @param event 事件名称 + * @param args 事件参数 + * @returns + */ emit(event: string, ...args: unknown[]) { if (!this.options.prefix) { logger.warn('Event#emit has been forbidden while prefix is not specified'); diff --git a/packages/shell/src/history.ts b/packages/shell/src/history.ts index cbf51d419..39c674185 100644 --- a/packages/shell/src/history.ts +++ b/packages/shell/src/history.ts @@ -10,34 +10,65 @@ export default class History { this[historySymbol] = this[documentSymbol].getHistory(); } + /** + * 历史记录跳转到指定位置 + * @param cursor + */ go(cursor: number) { this[historySymbol].go(cursor); } + /** + * 历史记录后退 + */ back() { this[historySymbol].back(); } + /** + * 历史记录前进 + */ forward() { this[historySymbol].forward(); } + /** + * 保存当前状态 + */ savePoint() { this[historySymbol].savePoint(); } + /** + * 当前是否是「保存点」,即是否有状态变更但未保存 + * @returns + */ isSavePoint() { return this[historySymbol].isSavePoint(); } + /** + * 获取 state,判断当前是否为「可回退」、「可前进」的状态 + * @returns + */ getState() { return this[historySymbol].getState(); } + /** + * 监听 state 变更事件 + * @param func + * @returns + */ onChangeState(func: () => any) { return this[historySymbol].onStateChange(func); } + /** + * 监听历史记录游标位置变更事件 + * @param func + * @returns + */ onChangeCursor(func: () => any) { return this[historySymbol].onCursor(func); } diff --git a/packages/shell/src/hotkey.ts b/packages/shell/src/hotkey.ts index 82fbae44a..eeb14f785 100644 --- a/packages/shell/src/hotkey.ts +++ b/packages/shell/src/hotkey.ts @@ -2,6 +2,13 @@ import { hotkey, HotkeyCallback } from '@ali/lowcode-editor-core'; import { Disposable } from '@ali/lowcode-types'; export default class Hotkey { + /** + * 绑定快捷键 + * @param combos 快捷键,格式如:['command + s'] 、['ctrl + shift + s'] 等 + * @param callback 回调函数 + * @param action + * @returns + */ bind(combos: string[] | string, callback: HotkeyCallback, action?: string): Disposable { hotkey.bind(combos, callback, action); return () => { diff --git a/packages/shell/src/material.ts b/packages/shell/src/material.ts index 639a712eb..a62e69633 100644 --- a/packages/shell/src/material.ts +++ b/packages/shell/src/material.ts @@ -22,22 +22,45 @@ export default class Material { this[designerSymbol] = editor.get('designer')!; } + /** + * 获取组件 map 结构 + */ get componentsMap() { return this[designerSymbol].componentsMap; } + /** + * 设置「资产包」结构 + * @param assets + * @returns + */ setAssets(assets: AssetsJson) { return this[editorSymbol].setAssets(assets); } + /** + * 获取「资产包」结构 + * @returns + */ getAssets() { return this[editorSymbol].get('assets'); } + /** + * 加载增量的「资产包」结构,该增量包会与原有的合并 + * @param incrementalAssets + * @returns + */ loadIncrementalAssets(incrementalAssets: AssetsJson) { return this[designerSymbol].loadIncrementalAssets(incrementalAssets); } + /** + * 注册物料元数据管道函数 + * @param transducer + * @param level + * @param id + */ registerMetadataTransducer( transducer: MetadataTransducer, level?: number, @@ -46,14 +69,27 @@ export default class Material { registerMetadataTransducer(transducer, level, id); } + /** + * 获取所有物料元数据管道函数 + * @returns + */ getRegisteredMetadataTransducers() { return getRegisteredMetadataTransducers(); } + /** + * 获取指定名称的物料元数据 + * @param componentName + * @returns + */ getComponentMeta(componentName: string) { return ComponentMeta.create(this[designerSymbol].getComponentMeta(componentName)); } + /** + * 获取所有已注册的物料元数据 + * @returns + */ getComponentMetasMap() { const map = new Map(); const originalMap = this[designerSymbol].getComponentMetasMap(); @@ -63,14 +99,27 @@ export default class Material { return map; } + /** + * 在设计器辅助层增加一个扩展 action + * @param action + */ addBuiltinComponentAction(action: ComponentAction) { addBuiltinComponentAction(action); } + /** + * 移除设计器辅助层的指定 action + * @param name + */ removeBuiltinComponentAction(name: string) { removeBuiltinComponentAction(name); } + /** + * 修改已有的设计器辅助层的指定 action + * @param actionName + * @param handle + */ modifyBuiltinComponentAction(actionName: string, handle: (action: ComponentAction) => void) { modifyBuiltinComponentAction(actionName, handle); } diff --git a/packages/shell/src/node-children.ts b/packages/shell/src/node-children.ts index 68c1aba03..9bc867ae4 100644 --- a/packages/shell/src/node-children.ts +++ b/packages/shell/src/node-children.ts @@ -15,66 +15,128 @@ export default class NodeChildren { return new NodeChildren(nodeChldren); } + /** + * 返回当前 children 实例所属的节点实例 + */ get owner(): Node | null { return Node.create(this[nodeChildrenSymbol].owner); } + /** + * children 内的节点实例数 + */ get size() { return this[nodeChildrenSymbol].size; } + /** + * 是否为空 + * @returns + */ isEmpty() { return this[nodeChildrenSymbol].isEmpty(); } + /** + * 删除指定节点 + * @param node + * @returns + */ delete(node: Node) { return this[nodeChildrenSymbol].delete(node[nodeSymbol]); } - insert(node: Node, at?: number | null | undefined, useMutator?: boolean) { - return this[nodeChildrenSymbol].insert(node[nodeSymbol], at, useMutator); + /** + * 插入一个节点 + * @param node 待插入节点 + * @param at 插入下标 + * @returns + */ + insert(node: Node, at?: number | null) { + return this[nodeChildrenSymbol].insert(node[nodeSymbol], at, true); } + /** + * 返回指定节点的下标 + * @param node + * @returns + */ indexOf(node: Node) { return this[nodeChildrenSymbol].indexOf(node[nodeSymbol]); } + /** + * 类似数组 splice 操作 + * @param start + * @param deleteCount + * @param node + */ splice(start: number, deleteCount: number, node?: Node) { this[nodeChildrenSymbol].splice(start, deleteCount, node?.[nodeSymbol]); } + /** + * 返回指定下标的节点 + * @param index + * @returns + */ get(index: number) { return this[nodeChildrenSymbol].get(index); } + /** + * 是否包含指定节点 + * @param node + * @returns + */ has(node: Node) { return this[nodeChildrenSymbol].has(node[nodeSymbol]); } + /** + * 类似数组的 forEach + * @param fn + */ forEach(fn: (node: Node, index: number) => void) { this[nodeChildrenSymbol].forEach((item: InnerNode, index: number) => { fn(Node.create(item)!, index); }); } + /** + * 类似数组的 map + * @param fn + */ map(fn: (node: Node, index: number) => T[]) { return this[nodeChildrenSymbol].map((item: InnerNode, index: number) => { return fn(Node.create(item)!, index); }); } + /** + * 类似数组的 every + * @param fn + */ every(fn: (node: Node, index: number) => boolean) { return this[nodeChildrenSymbol].every((item: InnerNode, index: number) => { return fn(Node.create(item)!, index); }); } + /** + * 类似数组的 some + * @param fn + */ some(fn: (node: Node, index: number) => boolean) { return this[nodeChildrenSymbol].some((item: InnerNode, index: number) => { return fn(Node.create(item)!, index); }); } + /** + * 类似数组的 filter + * @param fn + */ filter(fn: (node: Node, index: number) => boolean) { return this[nodeChildrenSymbol] .filter((item: InnerNode, index: number) => { @@ -83,6 +145,10 @@ export default class NodeChildren { .map((item: InnerNode) => Node.create(item)!); } + /** + * 类似数组的 find + * @param fn + */ find(fn: (node: Node, index: number) => boolean) { return Node.create( this[nodeChildrenSymbol].find((item: InnerNode, index: number) => { @@ -91,20 +157,39 @@ export default class NodeChildren { ); } + /** + * 类似数组的 reduce + * @param fn + */ reduce(fn: (acc: any, cur: Node) => any, initialValue: any) { return this[nodeChildrenSymbol].reduce((acc: any, cur: InnerNode) => { return fn(acc, Node.create(cur)!); }, initialValue); } + /** + * 导入 schema + * @param data + */ importSchema(data?: NodeData | NodeData[]) { this[nodeChildrenSymbol].import(data); } - exportSchema(stage?: TransformStage) { + /** + * 导出 schema + * @param stage + * @returns + */ + exportSchema(stage: TransformStage = TransformStage.Render) { return this[nodeChildrenSymbol].export(stage); } + /** + * 执行新增、删除、排序等操作 + * @param remover + * @param adder + * @param sorter + */ mergeChildren( remover: (node: Node, idx: number) => boolean, adder: (children: Node[]) => any, diff --git a/packages/shell/src/node.ts b/packages/shell/src/node.ts index 267004db8..de7358390 100644 --- a/packages/shell/src/node.ts +++ b/packages/shell/src/node.ts @@ -26,63 +26,99 @@ export default class Node { } /** - * 返回节点 id + * 节点 id */ get id() { return this[nodeSymbol].id; } + /** + * 节点标题 + */ get title() { return this[nodeSymbol].title; } + /** + * 是否为「容器型」节点 + */ get isContainer() { return this[nodeSymbol].isContainer(); } + /** + * 是否为根节点 + */ get isRoot() { return this[nodeSymbol].isRoot(); } + /** + * 是否为 Page 节点 + */ get isPage() { return this[nodeSymbol].isPage(); } + /** + * 是否为 Component 节点 + */ get isComponent() { return this[nodeSymbol].isComponent(); } + /** + * 是否为插槽节点 + */ get isSlot() { return this[nodeSymbol].isSlot(); } + /** + * 是否为父类/分支节点 + */ get isParental() { return this[nodeSymbol].isParental(); } + /** + * 是否为叶子节点 + */ get isLeaf() { return this[nodeSymbol].isLeaf(); } + /** + * 下标 + */ get index() { return this[nodeSymbol].index; } + /** + * 图标 + */ get icon() { return this[nodeSymbol].icon; } + /** + * 节点所在树的层级深度,根节点深度为 0 + */ get zLevel() { return this[nodeSymbol].zLevel; } /** - * 返回节点 componentName + * 节点 componentName */ get componentName() { return this[nodeSymbol].componentName; } + /** + * 节点的物料元数据 + */ get componentMeta() { return ComponentMeta.create(this[nodeSymbol].componentMeta); } @@ -127,14 +163,23 @@ export default class Node { return NodeChildren.create(this[nodeSymbol].children); } + /** + * 节点上挂载的插槽节点们 + */ get slots(): Node[] { return this[nodeSymbol].slots.map((node: InnerNode) => Node.create(node)!); } + /** + * 当前节点为插槽节点时,返回节点对应的属性实例 + */ get slotFor() { return Prop.create(this[nodeSymbol].slotFor); } + /** + * 返回节点的属性集 + */ get props() { return Props.create(this[nodeSymbol].props); } @@ -153,18 +198,34 @@ export default class Node { return this[nodeSymbol].getDOMNode(); } + /** + * 返回节点的尺寸、位置信息 + * @returns + */ getRect() { return this[nodeSymbol].getRect(); } + /** + * 是否有挂载插槽节点 + * @returns + */ hasSlots() { return this[nodeSymbol].hasSlots(); } + /** + * 是否设定了渲染条件 + * @returns + */ hasCondition() { return this[nodeSymbol].hasCondition(); } + /** + * 是否设定了循环数据 + * @returns + */ hasLoop() { return this[nodeSymbol].hasLoop(); } @@ -248,7 +309,7 @@ export default class Node { * @param options * @returns */ - exportSchema(stage?: TransformStage, options?: any) { + exportSchema(stage: TransformStage = TransformStage.Render, options?: any) { return this[nodeSymbol].export(stage, options); } diff --git a/packages/shell/src/project.ts b/packages/shell/src/project.ts index dd72bfb6d..b0fb0214b 100644 --- a/packages/shell/src/project.ts +++ b/packages/shell/src/project.ts @@ -30,6 +30,9 @@ export default class Project { return this[projectSymbol].documents.map((doc) => DocumentModel.create(doc)!); } + /** + * 获取模拟器的 host + */ get simulatorHost() { return SimulatorHost.create(this[projectSymbol].simulator as any || this[simulatorHostSymbol]); } diff --git a/packages/shell/src/prop.ts b/packages/shell/src/prop.ts index d929fc953..8338fe4fe 100644 --- a/packages/shell/src/prop.ts +++ b/packages/shell/src/prop.ts @@ -15,27 +15,56 @@ export default class Prop { return new Prop(prop); } + /** + * id + */ get id() { return this[propSymbol].id; } + /** + * key 值 + */ get key() { return this[propSymbol].key; } + /** + * 返回当前 prop 的路径 + */ + get path() { + return this[propSymbol].path; + } + + /** + * 返回所属的节点实例 + */ get node(): Node | null { return Node.create(this[propSymbol].getNode()); } + /** + * 设置值 + * @param val + */ setValue(val: CompositeValue) { this[propSymbol].setValue(val); } + /** + * 获取值 + * @returns + */ getValue() { return this[propSymbol].getValue(); } - exportSchema(stage: TransformStage) { + /** + * 导出值 + * @param stage + * @returns + */ + exportSchema(stage: TransformStage = TransformStage.Render) { return this[propSymbol].export(stage); } } \ No newline at end of file diff --git a/packages/shell/src/props.ts b/packages/shell/src/props.ts index 0392fd84c..eae58ba61 100644 --- a/packages/shell/src/props.ts +++ b/packages/shell/src/props.ts @@ -16,10 +16,16 @@ export default class Props { return new Props(props); } + /** + * id + */ get id() { return this[propsSymbol].id; } + /** + * 返回当前 props 的路径 + */ get path() { return this[propsSymbol].path; } diff --git a/packages/shell/src/selection.ts b/packages/shell/src/selection.ts index a9fa8c767..4b3f1ee15 100644 --- a/packages/shell/src/selection.ts +++ b/packages/shell/src/selection.ts @@ -15,34 +15,65 @@ export default class Selection { this[selectionSymbol] = document.selection; } + /** + * 返回选中的节点 id + */ get selected() { return this[selectionSymbol].selected; } + /** + * 选中指定节点(覆盖方式) + * @param id + */ select(id: string) { this[selectionSymbol].select(id); } + /** + * 批量选中指定节点们 + * @param ids + */ selectAll(ids: string[]) { this[selectionSymbol].selectAll(ids); } + /** + * 移除选中的指定节点 + * @param id + */ remove(id: string) { this[selectionSymbol].remove(id); } + /** + * 清除所有选中节点 + */ clear() { this[selectionSymbol].clear(); } + /** + * 判断是否选中了指定节点 + * @param id + * @returns + */ has(id: string) { return this[selectionSymbol].has(id); } + /** + * 选中指定节点(增量方式) + * @param id + */ add(id: string) { this[selectionSymbol].add(id); } + /** + * 获取选中的节点实例 + * @returns + */ getNodes() { return this[selectionSymbol].getNodes().map((node: InnerNode) => Node.create(node)); } diff --git a/packages/shell/src/setters.ts b/packages/shell/src/setters.ts index febab29b3..ca6484d69 100644 --- a/packages/shell/src/setters.ts +++ b/packages/shell/src/setters.ts @@ -2,14 +2,29 @@ import { getSetter, registerSetter, getSettersMap, RegisteredSetter } from '@ali import { CustomView } from '@ali/lowcode-types'; export default class Setters { + /** + * 获取指定 setter + * @param type + * @returns + */ getSetter(type: string) { return getSetter(type); } + /** + * 获取已注册的所有 settersMap + * @returns + */ getSettersMap() { return getSettersMap(); } + /** + * 注册一个 setter + * @param typeOrMaps + * @param setter + * @returns + */ registerSetter( typeOrMaps: string | { [key: string]: CustomView | RegisteredSetter }, setter?: CustomView | RegisteredSetter | undefined, diff --git a/packages/shell/src/setting-prop-entry.ts b/packages/shell/src/setting-prop-entry.ts index 66b8519b9..71ea2cb0d 100644 --- a/packages/shell/src/setting-prop-entry.ts +++ b/packages/shell/src/setting-prop-entry.ts @@ -26,30 +26,59 @@ export default class SettingPropEntry { return this.node; } + /** + * 设置值 + * @param val + */ setValue(val: CompositeValue) { this[settingPropEntrySymbol].setValue(val); } + /** + * 获取值 + * @returns + */ getValue() { return this[settingPropEntrySymbol].getValue(); } + /** + * 获取设置属性集 + * @returns + */ getProps() { return SettingTopEntry.create(this[settingPropEntrySymbol].getProps() as SettingEntry) as any; } + /** + * 是否绑定了变量 + * @returns + */ isUseVariable() { return this[settingPropEntrySymbol].isUseVariable(); } + /** + * 设置绑定变量 + * @param flag + */ setUseVariable(flag: boolean) { this[settingPropEntrySymbol].setUseVariable(flag); } + /** + * 创建一个设置 field 实例 + * @param config + * @returns + */ createField(config: FieldConfig) { return SettingPropEntry.create(this[settingPropEntrySymbol].createField(config)); } + /** + * 获取值,当为变量时,返回 mock + * @returns + */ getMockOrValue() { return this[settingPropEntrySymbol].getMockOrValue(); } diff --git a/packages/shell/src/setting-top-entry.ts b/packages/shell/src/setting-top-entry.ts index 1d3f57a14..8c8ef20c2 100644 --- a/packages/shell/src/setting-top-entry.ts +++ b/packages/shell/src/setting-top-entry.ts @@ -13,6 +13,9 @@ export default class SettingTopEntry { return new SettingTopEntry(prop); } + /** + * 返回所属的节点实例 + */ get node(): Node | null { return Node.create(this[settingTopEntrySymbol].getNode()); } @@ -24,10 +27,20 @@ export default class SettingTopEntry { return this.node; } + /** + * 获取指定 propName 的值 + * @param propName + * @returns + */ getPropValue(propName: string | number) { return this[settingTopEntrySymbol].getPropValue(propName); } + /** + * 设置指定 propName 的值 + * @param propName + * @param value + */ setPropValue(propName: string | number, value: any) { this[settingTopEntrySymbol].setPropValue(propName, value); } diff --git a/packages/shell/src/simulator-host.ts b/packages/shell/src/simulator-host.ts index 6af489c70..625714ba2 100644 --- a/packages/shell/src/simulator-host.ts +++ b/packages/shell/src/simulator-host.ts @@ -15,18 +15,34 @@ export default class SimulatorHost { return new SimulatorHost(host); } + /** + * 获取 contentWindow + */ get contentWindow() { return this[simulatorHostSymbol].contentWindow; } + /** + * 获取 contentDocument + */ get contentDocument() { return this[simulatorHostSymbol].contentDocument; } + /** + * 设置 host 配置值 + * @param key + * @param value + */ set(key: string, value: any) { this[simulatorHostSymbol].set(key, value); } + /** + * 获取 host 配置值 + * @param key + * @returns + */ get(key: string) { return this[simulatorHostSymbol].get(key); } diff --git a/packages/shell/src/skeleton.ts b/packages/shell/src/skeleton.ts index b17a10e41..0ff5a6c75 100644 --- a/packages/shell/src/skeleton.ts +++ b/packages/shell/src/skeleton.ts @@ -12,10 +12,21 @@ export default class Skeleton { this[skeletonSymbol] = skeleton; } + /** + * 增加一个面板实例 + * @param config + * @param extraConfig + * @returns + */ add(config: IWidgetBaseConfig, extraConfig?: Record) { return this[skeletonSymbol].add(config, extraConfig); } + /** + * 移除一个面板实例 + * @param config + * @returns + */ remove(config: IWidgetBaseConfig) { const { area, name } = config; const skeleton = this[skeletonSymbol];