MCPcopy
hub / github.com/alibaba/lowcode-engine / Context

Class Context

packages/workspace/src/context/view-context.ts:17–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16
17export class Context extends BasicContext implements IViewContext {
18 viewName = 'editor-view';
19
20 instance: IPublicEditorViewConfig;
21
22 viewType: 'editor' | 'webview';
23
24 @obx _activate = false;
25
26 @obx isInit: boolean = false;
27
28 init = flow(function* (this: Context) {
29 if (this.viewType === 'webview') {
30 const url = yield this.instance?.url?.();
31 yield this.plugins.register(getWebviewPlugin(url, this.viewName));
32 } else {
33 yield this.registerInnerPlugins();
34 }
35 yield this.instance?.init?.();
36 yield this.innerPlugins.init();
37 this.isInit = true;
38 });
39
40 constructor(public workspace: IWorkspace, public editorWindow: IEditorWindow, public editorView: IPublicTypeEditorView, options: Object | undefined) {
41 super(workspace, editorView.viewName, IPublicEnumPluginRegisterLevel.EditorView, editorWindow);
42 this.viewType = editorView.viewType || 'editor';
43 this.viewName = editorView.viewName;
44 this.instance = editorView(this.innerPlugins._getLowCodePluginContext({
45 pluginName: 'any',
46 }), options);
47 makeObservable(this);
48 }
49
50 @computed get active() {
51 return this._activate;
52 }
53
54 onSimulatorRendererReady = (): Promise<void> => {
55 return new Promise((resolve) => {
56 this.project.onSimulatorRendererReady(() => {
57 resolve();
58 });
59 });
60 };
61
62 setActivate = (_activate: boolean) => {
63 this._activate = _activate;
64 this.innerHotkey.activate(this._activate);
65 };
66
67 async save() {
68 return await this.instance?.save?.();
69 }
70}

Callers

nothing calls this directly

Calls 6

getWebviewPluginFunction · 0.90
urlMethod · 0.65
registerMethod · 0.65
initMethod · 0.65
activateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…