MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / constructor

Method constructor

packages/designer/src/document/node/node.ts:371–405  ·  view source on GitHub ↗
(readonly document: IDocumentModel, nodeSchema: Schema)

Source from the content-addressed store, hash-verified

369 };
370
371 constructor(readonly document: IDocumentModel, nodeSchema: Schema) {
372 makeObservable(this);
373 const { componentName, id, children, props, ...extras } = nodeSchema;
374 this.id = document.nextId(id);
375 this.componentName = componentName;
376 if (this.componentName === 'Leaf') {
377 this.props = new Props(this, {
378 children: isDOMText(children) || isJSExpression(children) ? children : '',
379 });
380 } else {
381 this.props = new Props(this, props, extras);
382 this._children = new NodeChildren(this as INode, this.initialChildren(children));
383 this._children.internalInitParent();
384 this.props.merge(
385 this.upgradeProps(this.initProps(props || {})),
386 this.upgradeProps(extras),
387 );
388 this.setupAutoruns();
389 }
390
391 this.initBuiltinProps();
392
393 this.isInited = true;
394 this.emitter = createModuleEventBus('Node');
395 const { editor } = this.document.designer;
396 this.onVisibleChange((visible: boolean) => {
397 editor?.eventBus.emit(EDITOR_EVENT.NODE_VISIBLE_CHANGE, this, visible);
398 });
399 this.onChildrenChange((info?: { type: string; node: INode }) => {
400 editor?.eventBus.emit(EDITOR_EVENT.NODE_CHILDREN_CHANGE, {
401 type: info?.type,
402 node: this,
403 });
404 });
405 }
406
407 /**
408 * 节点初始化期间就把内置的一些 prop 初始化好,避免后续不断构造实例导致 reaction 执行多次

Callers

nothing calls this directly

Calls 14

initialChildrenMethod · 0.95
upgradePropsMethod · 0.95
initPropsMethod · 0.95
setupAutorunsMethod · 0.95
initBuiltinPropsMethod · 0.95
onVisibleChangeMethod · 0.95
onChildrenChangeMethod · 0.95
createModuleEventBusFunction · 0.85
nextIdMethod · 0.65
internalInitParentMethod · 0.65
mergeMethod · 0.65
emitMethod · 0.65

Tested by

no test coverage detected