File tree Expand file tree Collapse file tree 10 files changed +178
-3
lines changed
Expand file tree Collapse file tree 10 files changed +178
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ title : plugin-instance
3+ sidebar_position : 12
4+ ---
5+
6+ > ** @types ** [ IPublicModelPluginInstance] ( https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/plugin-instance.ts ) <br />
7+ > ** @since ** v1.1.0
8+
9+
10+ ## 基本介绍
11+
12+ 插件实例
13+
14+ ## 属性
15+
16+ ### pluginName
17+
18+ 插件名字
19+
20+ ``` typescript
21+ get name (): string ;
22+ ```
23+
24+ ### dep
25+
26+ 插件依赖
27+
28+ ``` typescript
29+ get dep (): string [];
30+ ```
31+
32+ ### disabled
33+
34+ 插件是否禁用
35+
36+ ``` typescript
37+ get disabled (): boolean
38+
39+ set disabled (disabled : boolean ): void ;
40+
41+ ```
42+
43+ ### meta
44+
45+ 插件 meta 信息
46+
47+ ``` typescript
48+ get meta (): IPublicTypePluginMeta
49+
50+ ```
51+
52+ - [ IPublicTypePluginMeta] ( https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/plugin-meta.ts )
53+
54+
Original file line number Diff line number Diff line change @@ -159,10 +159,51 @@ BuiltinPluginRegistry.meta = {
159159await plugins.register(BuiltinPluginRegistry, { key1: 'abc', key5: 'willNotPassToPlugin' });
160160` ` `
161161
162+ ### get
163+
164+ 获取指定插件
165+
166+ ` ` ` typescript
167+ function get(pluginName: string): IPublicModelPluginInstance;
168+
169+ ` ` `
170+
171+ 关联模型 [IPublicModelPluginInstance ](./model /plugin -instance )
172+
173+ ### getAll
174+
175+ 获取所有的插件实例
176+
177+ ` ` ` typescript
178+ function getAll(): IPublicModelPluginInstance[];
179+
180+ ` ` `
181+
182+ 关联模型 [IPublicModelPluginInstance ](./model /plugin -instance )
183+
184+ ### has
185+
186+ 判断是否有指定插件
187+
188+ ` ` ` typescript
189+ function has(pluginName: string): boolean;
190+
191+ ` ` `
192+
193+ ### delete
194+
195+ 删除指定插件
196+
197+ ` ` ` typescript
198+ function delete(pluginName: string): void;
199+
200+ ` ` `
201+
162202## 相关类型定义
163203
164204- [IPublicModelPluginContext ](https : // github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/plugin-context.ts)
165205- [IPublicTypePluginConfig ](https : // github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/type/plugin-config.ts)
206+ - [IPublicModelPluginInstance ](https : // github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/plugin-instance.ts)
166207
167208## 插件元数据工程转化示例
168209your -plugin /package .json
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ export interface ILowCodePluginRuntimeCore {
3131 destroy ( ) : void ;
3232 toProxy ( ) : any ;
3333 setDisabled ( flag : boolean ) : void ;
34+ meta : IPublicTypePluginMeta ;
3435}
3536
3637interface ILowCodePluginRuntimeExportsAccessor {
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export class LowCodePluginRuntime implements ILowCodePluginRuntime {
2020
2121 private pluginName : string ;
2222
23- private meta : IPublicTypePluginMeta ;
23+ meta : IPublicTypePluginMeta ;
2424
2525 /**
2626 * 标识插件状态,是否被 disabled
Original file line number Diff line number Diff line change @@ -4,10 +4,12 @@ import {
44import { globalContext } from '@alilc/lowcode-editor-core' ;
55import {
66 IPublicApiPlugins ,
7+ IPublicModelPluginInstance ,
78 IPublicTypePlugin ,
89 IPublicTypePluginRegisterOptions ,
910 IPublicTypePreferenceValueType ,
1011} from '@alilc/lowcode-types' ;
12+ import { PluginInstance } from '../model/plugin-instance' ;
1113import { pluginsSymbol } from '../symbols' ;
1214
1315const innerPluginsSymbol = Symbol ( 'plugin' ) ;
@@ -45,6 +47,27 @@ export class Plugins implements IPublicApiPlugins {
4547 return this [ pluginsSymbol ] . getPluginPreference ( pluginName ) ;
4648 }
4749
50+ get ( pluginName : string ) : IPublicModelPluginInstance | null {
51+ const instance = this [ pluginsSymbol ] . get ( pluginName ) ;
52+ if ( instance ) {
53+ return new PluginInstance ( instance ) ;
54+ }
55+
56+ return null ;
57+ }
58+
59+ getAll ( ) {
60+ return this [ pluginsSymbol ] . getAll ( ) ?. map ( d => new PluginInstance ( d ) ) ;
61+ }
62+
63+ has ( pluginName : string ) {
64+ return this [ pluginsSymbol ] . has ( pluginName ) ;
65+ }
66+
67+ delete ( pluginName : string ) {
68+ this [ pluginsSymbol ] . delete ( pluginName ) ;
69+ }
70+
4871 toProxy ( ) {
4972 return new Proxy ( this , {
5073 get ( target , prop , receiver ) {
Original file line number Diff line number Diff line change 1+ import { ILowCodePluginRuntime } from '@alilc/lowcode-designer' ;
2+ import { IPublicModelPluginInstance } from '@alilc/lowcode-types' ;
3+ import { pluginInstanceSymbol } from '../symbols' ;
4+
5+ export class PluginInstance implements IPublicModelPluginInstance {
6+ private readonly [ pluginInstanceSymbol ] : ILowCodePluginRuntime ;
7+
8+ constructor ( pluginInstance : ILowCodePluginRuntime ) {
9+ this [ pluginInstanceSymbol ] = pluginInstance ;
10+ }
11+
12+ get pluginName ( ) : string {
13+ return this [ pluginInstanceSymbol ] . name ;
14+ }
15+
16+ get dep ( ) : string [ ] {
17+ return this [ pluginInstanceSymbol ] . dep ;
18+ }
19+
20+ get disabled ( ) : boolean {
21+ return this [ pluginInstanceSymbol ] . disabled ;
22+ }
23+
24+ set disabled ( disabled : boolean ) {
25+ this [ pluginInstanceSymbol ] . setDisabled ( disabled ) ;
26+ }
27+
28+ get meta ( ) {
29+ return this [ pluginInstanceSymbol ] . meta ;
30+ }
31+ }
Original file line number Diff line number Diff line change @@ -28,4 +28,5 @@ export const designerCabinSymbol = Symbol('designerCabin');
2828export const hotkeySymbol = Symbol ( 'hotkey' ) ;
2929export const pluginsSymbol = Symbol ( 'plugins' ) ;
3030export const workspaceSymbol = Symbol ( 'workspace' ) ;
31- export const windowSymbol = Symbol ( 'window' ) ;
31+ export const windowSymbol = Symbol ( 'window' ) ;
32+ export const pluginInstanceSymbol = Symbol ( 'plugin-instance' ) ;
Original file line number Diff line number Diff line change 1- import { IPublicTypePlugin } from '../model' ;
1+ import { IPublicModelPluginInstance , IPublicTypePlugin } from '../model' ;
22import { IPublicTypePreferenceValueType } from '../type' ;
33import { IPublicTypePluginRegisterOptions } from '../type/plugin-register-options' ;
44
@@ -25,4 +25,16 @@ export interface IPublicApiPlugins {
2525 getPluginPreference (
2626 pluginName : string ,
2727 ) : Record < string , IPublicTypePreferenceValueType > | null | undefined ;
28+
29+ /** 获取指定插件 */
30+ get ( pluginName : string ) : IPublicModelPluginInstance | null ;
31+
32+ /** 获取所有的插件实例 */
33+ getAll ( ) : IPublicModelPluginInstance [ ] ;
34+
35+ /** 判断是否有指定插件 */
36+ has ( pluginName : string ) : boolean ;
37+
38+ /** 删除指定插件 */
39+ delete ( pluginName : string ) : void ;
2840}
Original file line number Diff line number Diff line change @@ -26,3 +26,4 @@ export * from './setting-target';
2626export * from './engine-config' ;
2727export * from './editor' ;
2828export * from './preference' ;
29+ export * from './plugin-instance' ;
Original file line number Diff line number Diff line change 1+ import { IPublicTypePluginMeta } from '../type/plugin-meta' ;
2+
3+ export interface IPublicModelPluginInstance {
4+ pluginName : string ;
5+
6+ dep : string [ ] ;
7+
8+ disabled : boolean ;
9+
10+ meta : IPublicTypePluginMeta ;
11+ }
You can’t perform that action at this time.
0 commit comments