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

Function init

packages/engine/src/engine-core.ts:218–272  ·  view source on GitHub ↗
(
  container?: HTMLElement,
  options?: IPublicTypeEngineOptions,
  pluginPreference?: PluginPreference,
  )

Source from the content-addressed store, hash-verified

216const pluginPromise = registryInnerPlugin(designer, editor, plugins);
217
218export async function init(
219 container?: HTMLElement,
220 options?: IPublicTypeEngineOptions,
221 pluginPreference?: PluginPreference,
222 ) {
223 await destroy();
224 let engineOptions = null;
225 if (isPlainObject(container)) {
226 engineOptions = container;
227 engineContainer = document.createElement('div');
228 engineContainer.id = 'engine';
229 document.body.appendChild(engineContainer);
230 } else {
231 engineOptions = options;
232 engineContainer = container;
233 if (!container) {
234 engineContainer = document.createElement('div');
235 engineContainer.id = 'engine';
236 document.body.appendChild(engineContainer);
237 }
238 }
239 engineConfig.setEngineOptions(engineOptions as any);
240
241 const { Workbench } = common.skeletonCabin;
242 if (options && options.enableWorkspaceMode) {
243 const disposeFun = await pluginPromise;
244 disposeFun && disposeFun();
245 render(
246 createElement(WorkSpaceWorkbench, {
247 workspace: innerWorkspace,
248 // skeleton: workspace.skeleton,
249 className: 'engine-main',
250 topAreaItemClassName: 'engine-actionitem',
251 }),
252 engineContainer,
253 );
254 innerWorkspace.enableAutoOpenFirstWindow = engineConfig.get('enableAutoOpenFirstWindow', true);
255 innerWorkspace.setActive(true);
256 innerWorkspace.initWindow();
257 innerHotkey.activate(false);
258 await innerWorkspace.plugins.init(pluginPreference);
259 return;
260 }
261
262 await plugins.init(pluginPreference as any);
263
264 render(
265 createElement(Workbench, {
266 skeleton: innerSkeleton,
267 className: 'engine-main',
268 topAreaItemClassName: 'engine-actionitem',
269 }),
270 engineContainer,
271 );
272}
273
274export async function destroy() {
275 // remove all documents

Callers

nothing calls this directly

Calls 9

destroyFunction · 0.70
setEngineOptionsMethod · 0.65
getMethod · 0.65
setActiveMethod · 0.65
initWindowMethod · 0.65
activateMethod · 0.65
initMethod · 0.65
isPlainObjectFunction · 0.50
createElementMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…