refactor: reorganize types

This commit is contained in:
JackLian 2023-01-05 16:54:11 +08:00 committed by 刘菊萍(絮黎)
parent b07d33e99a
commit c4bfeaa201
47 changed files with 300 additions and 342 deletions

View File

@ -41,5 +41,12 @@ module.exports = {
'@typescript-eslint/dot-notation': 0, // for lint performance
'@typescript-eslint/restrict-plus-operands': 0, // for lint performance
'no-unexpected-multiline': 1,
'no-multiple-empty-lines': ['error', { "max": 1 }],
'lines-around-comment': ['error', {
"beforeBlockComment": true,
"afterBlockComment": false,
"afterLineComment": false,
"allowBlockStart": true,
}],
}
};

View File

@ -5,7 +5,7 @@
import changeCase from 'change-case';
import {
IPublicTypeUtilItem,
NodeDataType,
IPublicTypeNodeDataType,
IPublicTypeNodeSchema,
IPublicTypeContainerSchema,
IPublicTypeProjectSchema,
@ -81,7 +81,7 @@ function processChildren(schema: IPublicTypeNodeSchema): void {
if (nodeProps.children) {
if (!schema.children) {
// eslint-disable-next-line no-param-reassign
schema.children = nodeProps.children as NodeDataType;
schema.children = nodeProps.children as IPublicTypeNodeDataType;
} else {
let _children: IPublicTypeNodeData[] = [];
@ -331,7 +331,7 @@ export class SchemaParser implements ISchemaParser {
};
}
getComponentNames(children: NodeDataType): string[] {
getComponentNames(children: IPublicTypeNodeDataType): string[] {
return handleSubNodes<string>(
children,
{

View File

@ -5,7 +5,7 @@ import {
IPublicTypeCompositeObject,
ResultDir,
ResultFile,
NodeDataType,
IPublicTypeNodeDataType,
IPublicTypeProjectSchema,
IPublicTypeJSExpression,
IPublicTypeJSFunction,
@ -65,7 +65,10 @@ export interface ICodeStruct extends IBaseCodeStruct {
/** 上下文数据,用来在插件之间共享一些数据 */
export interface IContextData extends IProjectBuilderOptions {
/** 是否使用了 Ref 的 API (this.$/this.$$) */
/**
* 使 Ref API (this.$/this.$$)
* */
useRefApi?: boolean;
/**
@ -108,6 +111,7 @@ export interface IModuleBuilder {
* @interface ICodeGenerator
*/
export interface ICodeGenerator {
/**
* Schema
*
@ -138,26 +142,27 @@ export interface IProjectPlugins {
}
export interface IProjectBuilderOptions {
/** 是否处于严格模式(默认: 否) */
/** 是否处于严格模式 (默认:否) */
inStrictMode?: boolean;
/**
* JSExpression
* true
* : 如果容忍异 try-catch
* try-catch
* catch CustomEvent
*/
tolerateEvalErrors?: boolean;
/**
*
* 默认:
*
*
* window.dispatchEvent(new CustomEvent('lowcode-eval-error', { error, expr }))
*
*
*
* :
*
* - error: 异常信息
* - expr: 求值的表达式
*/
@ -205,7 +210,7 @@ type CompositeTypeGenerator<I, T> =
| BaseGenerator<I, T, CompositeValueGeneratorOptions>
| Array<BaseGenerator<I, T, CompositeValueGeneratorOptions>>;
export type NodeGenerator<T> = (nodeItem: NodeDataType, scope: IScope) => T;
export type NodeGenerator<T> = (nodeItem: IPublicTypeNodeDataType, scope: IScope) => T;
// FIXME: 在新的实现中,添加了第一参数 this: CustomHandlerSet 作为上下文。究其本质
// scopeBindings?: IScopeBindings;

View File

@ -1,6 +1,6 @@
import _ from 'lodash';
import { pipe } from 'fp-ts/function';
import { IPublicTypeNodeSchema, isNodeSchema, NodeDataType, IPublicTypeCompositeValue } from '@alilc/lowcode-types';
import { IPublicTypeNodeSchema, isNodeSchema, IPublicTypeNodeDataType, IPublicTypeCompositeValue } from '@alilc/lowcode-types';
import {
IScope,
@ -365,7 +365,7 @@ export function generateReactExprInJS(
const handleChildren = (v: string[]) => v.join('');
export function createNodeGenerator(cfg: NodeGeneratorConfig = {}): NodeGenerator<string> {
const generateNode = (nodeItem: NodeDataType, scope: IScope): string => {
const generateNode = (nodeItem: IPublicTypeNodeDataType, scope: IScope): string => {
if (_.isArray(nodeItem)) {
const resList = nodeItem.map((n) => generateNode(n, scope));
return handleChildren(resList);
@ -390,7 +390,7 @@ export function createNodeGenerator(cfg: NodeGeneratorConfig = {}): NodeGenerato
return `{${valueStr}}`;
};
return (nodeItem: NodeDataType, scope: IScope) => unwrapJsExprQuoteInJsx(generateNode(nodeItem, scope));
return (nodeItem: IPublicTypeNodeDataType, scope: IScope) => unwrapJsExprQuoteInJsx(generateNode(nodeItem, scope));
}
const defaultReactGeneratorConfig: NodeGeneratorConfig = {

View File

@ -6,7 +6,6 @@ import { getClosestNode } from '@alilc/lowcode-utils';
import { intl } from '../../locale';
import { BuiltinSimulatorHost } from '../host';
export class BorderDetectingInstance extends PureComponent<{
title: IPublicTypeTitleContent;
rect: DOMRect | null;
@ -77,11 +76,9 @@ export class BorderDetecting extends Component<{ host: BuiltinSimulatorHost }> {
const { host } = this.props;
const { current } = this;
const canHoverHook = current?.componentMeta.getMetadata()?.configure.advanced?.callbacks?.onHoverHook;
const canHover = (canHoverHook && typeof canHoverHook === 'function') ? canHoverHook(current.internalToShellNode()) : true;
if (!canHover || !current || host.viewport.scrolling || host.liveEditing.editing) {
return null;
}

View File

@ -57,7 +57,7 @@ import {
IPublicEnumTransitionType,
IPublicEnumDragObjectType,
IPublicTypeDragNodeObject,
NodeInstance,
IPublicTypeNodeInstance,
IPublicTypeComponentInstance,
IPublicTypeLocationChildrenDetail,
IPublicTypeLocationDetailType,
@ -173,7 +173,6 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
readonly emitter: IEventBus = createModuleEventBus('BuiltinSimulatorHost');
readonly componentsConsumer: ResourceConsumer;
readonly injectionConsumer: ResourceConsumer;
@ -898,7 +897,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
/**
* @see ISimulator
*/
getComponentInstances(node: Node, context?: NodeInstance): IPublicTypeComponentInstance[] | null {
getComponentInstances(node: Node, context?: IPublicTypeNodeInstance): IPublicTypeComponentInstance[] | null {
const docId = node.document.id;
const instances = this.instancesMap[docId]?.get(node.id) || null;
@ -925,7 +924,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
getClosestNodeInstance(
from: IPublicTypeComponentInstance,
specId?: string,
): NodeInstance<IPublicTypeComponentInstance> | null {
): IPublicTypeNodeInstance<IPublicTypeComponentInstance> | null {
return this.renderer?.getClosestNodeInstance(from, specId) || null;
}
@ -1028,7 +1027,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
/**
* DOM simulator
*/
getNodeInstanceFromElement(target: Element | null): NodeInstance<IPublicTypeComponentInstance> | null {
getNodeInstanceFromElement(target: Element | null): IPublicTypeNodeInstance<IPublicTypeComponentInstance> | null {
if (!target) {
return null;
}
@ -1111,14 +1110,14 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
private _sensorAvailable = true;
/**
* @see ISensor
* @see IPublicModelSensor
*/
get sensorAvailable(): boolean {
return this._sensorAvailable;
}
/**
* @see ISensor
* @see IPublicModelSensor
*/
fixEvent(e: ILocateEvent): ILocateEvent {
if (e.fixed) {
@ -1149,7 +1148,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
}
/**
* @see ISensor
* @see IPublicModelSensor
*/
isEnter(e: ILocateEvent): boolean {
const rect = this.viewport.bounds;
@ -1164,7 +1163,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
private sensing = false;
/**
* @see ISensor
* @see IPublicModelSensor
*/
deactiveSensor() {
this.sensing = false;
@ -1174,7 +1173,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
// ========= drag location logic: helper for locate ==========
/**
* @see ISensor
* @see IPublicModelSensor
*/
locate(e: ILocateEvent): any {
const { dragObject } = e;
@ -1372,7 +1371,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
const document = this.project.currentDocument!;
const { currentRoot } = document;
let container: INode;
let nodeInstance: NodeInstance<IPublicTypeComponentInstance> | undefined;
let nodeInstance: IPublicTypeNodeInstance<IPublicTypeComponentInstance> | undefined;
if (target) {
const ref = this.getNodeInstanceFromElement(target);

View File

@ -214,7 +214,6 @@ function selectRange(doc: Document, range: Range) {
}
}
function queryPropElement(rootElement: HTMLElement, targetElement: HTMLElement, selector?: string) {
if (!selector) {
return null;

View File

@ -1,5 +1,5 @@
import { Component } from '../simulator';
import { IPublicTypeNodeSchema, IPublicTypeComponentInstance, NodeInstance } from '@alilc/lowcode-types';
import { IPublicTypeNodeSchema, IPublicTypeComponentInstance, IPublicTypeNodeInstance } from '@alilc/lowcode-types';
export interface BuiltinSimulatorRenderer {
readonly isSimulatorRenderer: true;
@ -8,7 +8,7 @@ export interface BuiltinSimulatorRenderer {
getClosestNodeInstance(
from: IPublicTypeComponentInstance,
nodeId?: string,
): NodeInstance<IPublicTypeComponentInstance> | null;
): IPublicTypeNodeInstance<IPublicTypeComponentInstance> | null;
findDOMNodes(instance: IPublicTypeComponentInstance): Array<Element | Text> | null;
getClientRects(element: Element | Text): DOMRect[];
setNativeSelection(enableFlag: boolean): void;

View File

@ -18,23 +18,8 @@ function getDataFromPasteEvent(event: ClipboardEvent) {
};
}
} catch (error) {
/*
const html = clipboardData.getData('text/html');
if (html !== '') {
// TODO: clear the html
return {
code: '<div dangerouslySetInnerHTML={ __html: html } />',
maps: {},
};
}
*/
// TODO: open the parser implement
return { };
/*
return {
code: clipboardData.getData('text/plain'),
maps: {},
}; */
}
}

View File

@ -13,10 +13,12 @@ import {
IShellModelFactory,
IPublicModelDragObject,
IPublicModelScrollable,
IDesigner,
IPublicModelScroller,
IPublicTypeLocationData,
IPublicEnumTransformStage,
IPublicModelDragon,
IPublicModelActiveTracker,
IPublicModelDropLocation,
} from '@alilc/lowcode-types';
import { megreAssets, IPublicTypeAssetsJson, isNodeSchema, isDragNodeObject, isDragNodeDataObject, isLocationChildrenDetail, Logger } from '@alilc/lowcode-utils';
import { Project } from '../project';
@ -57,6 +59,16 @@ export interface DesignerProps {
[key: string]: any;
}
export interface IDesigner {
get dragon(): IPublicModelDragon;
get activeTracker(): IPublicModelActiveTracker;
createScroller(scrollable: IPublicModelScrollable): IPublicModelScroller;
/**
* dragon
*/
createLocation(locationData: IPublicTypeLocationData): IPublicModelDropLocation;
}
export class Designer implements IDesigner {
dragon: Dragon;

View File

@ -8,7 +8,7 @@ import {
IPublicModelNode,
IPublicModelDragon,
IPublicModelLocateEvent,
ISensor,
IPublicModelSensor,
} from '@alilc/lowcode-types';
import { setNativeSelection, cursor } from '@alilc/lowcode-utils';
import { Node } from '../document';
@ -22,7 +22,7 @@ export interface ILocateEvent extends IPublicModelLocateEvent {
/**
*
*/
sensor?: ISensor;
sensor?: IPublicModelSensor;
}
@ -52,6 +52,7 @@ export function isLocateEvent(e: any): e is ILocateEvent {
}
const SHAKE_DISTANCE = 4;
/**
* mouse shake check
*/
@ -103,16 +104,16 @@ export interface IDragon extends IPublicModelDragon {
* Drag-on
*/
export class Dragon implements IDragon {
private sensors: ISensor[] = [];
private sensors: IPublicModelSensor[] = [];
key = Math.random();
/**
* current active sensor,
*/
@obx.ref private _activeSensor: ISensor | undefined;
@obx.ref private _activeSensor: IPublicModelSensor | undefined;
get activeSensor(): ISensor | undefined {
get activeSensor(): IPublicModelSensor | undefined {
return this._activeSensor;
}
@ -173,7 +174,7 @@ export class Dragon implements IDragon {
const forceCopyState =
isDragNodeObject(dragObject) && dragObject.nodes.some((node: Node | IPublicModelNode) => (typeof node.isSlot === 'function' ? node.isSlot() : node.isSlot));
const isBoostFromDragAPI = isDragEvent(boostEvent);
let lastSensor: ISensor | undefined;
let lastSensor: IPublicModelSensor | undefined;
this._dragging = false;
@ -462,7 +463,7 @@ export class Dragon implements IDragon {
/* istanbul ignore next */
const chooseSensor = (e: ILocateEvent) => {
// this.sensors will change on dragstart
const sensors: ISensor[] = this.sensors.concat(masterSensors as ISensor[]);
const sensors: IPublicModelSensor[] = this.sensors.concat(masterSensors as IPublicModelSensor[]);
let sensor =
e.sensor && e.sensor.isEnter(e)
? e.sensor

View File

@ -15,8 +15,7 @@ import {
IPublicApiProject,
IPublicModelDropLocation,
IPublicEnumTransformStage,
IPublicOnChangeOptions,
EDITOR_EVENT,
IPublicTypeOnChangeOptions,
} from '@alilc/lowcode-types';
import { Project } from '../project';
import { ISimulatorHost } from '../simulator';
@ -27,6 +26,7 @@ import { Selection } from './selection';
import { History } from './history';
import { ModalNodesManager } from './node';
import { uniqueId, isPlainObject, compatStage, isJSExpression, isDOMText, isNodeSchema, isDragNodeObject, isDragNodeDataObject } from '@alilc/lowcode-utils';
import { EDITOR_EVENT } from '../types';
export type GetDataType<T, NodeType> = T extends undefined
? NodeType extends {
@ -168,7 +168,7 @@ export class DocumentModel implements IDocumentModel {
};
}
onChangeNodeChildren(fn: (info: IPublicOnChangeOptions) => void): () => void {
onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions) => void): () => void {
this.designer.editor?.eventBus.on(EDITOR_EVENT.NODE_VISIBLE_CHANGE, fn);
return () => {
@ -338,7 +338,6 @@ export class DocumentModel implements IDocumentModel {
@obx.ref private _dropLocation: IDropLocation | null = null;
set dropLocation(loc: IPublicModelDropLocation | null) {
this._dropLocation = loc;
// pub event

View File

@ -6,17 +6,15 @@ import {
IPublicTypePropsList,
IPublicTypeNodeData,
IPublicTypeI18nData,
SlotSchema,
IPublicTypeSlotSchema,
IPublicTypePageSchema,
IPublicTypeComponentSchema,
NodeStatus,
IPublicTypeCompositeValue,
GlobalEvent,
IPublicTypeComponentAction,
IPublicModelNode,
IPublicModelExclusiveGroup,
IPublicEnumTransformStage,
EDITOR_EVENT,
} from '@alilc/lowcode-types';
import { compatStage, isDOMText, isJSExpression } from '@alilc/lowcode-utils';
import { SettingTopEntry } from '@alilc/lowcode-designer';
@ -28,8 +26,13 @@ import { ComponentMeta } from '../../component-meta';
import { ExclusiveGroup, isExclusiveGroup } from './exclusive-group';
import { includeSlot, removeSlot } from '../../utils/slot';
import { foreachReverse } from '../../utils/tree';
import { NodeRemoveOptions } from '../../types';
import { NodeRemoveOptions, EDITOR_EVENT } from '../../types';
export interface NodeStatus {
locking: boolean;
pseudo: boolean;
inPlaceEditing: boolean;
}
export interface INode extends IPublicModelNode {
@ -1235,14 +1238,13 @@ function ensureNode(node: any, document: DocumentModel): Node {
return nodeInstance;
}
export interface LeafNode extends Node {
readonly children: null;
}
export type IPublicTypePropChangeOptions = Omit<GlobalEvent.Node.Prop.ChangeOptions, 'node'>;
export type SlotNode = Node<SlotSchema>;
export type SlotNode = Node<IPublicTypeSlotSchema>;
export type PageNode = Node<IPublicTypePageSchema>;
export type ComponentNode = Node<IPublicTypeComponentSchema>;
export type RootNode = PageNode | ComponentNode;

View File

@ -1,5 +1,5 @@
import { untracked, computed, obx, engineConfig, action, makeObservable, mobx, runInAction } from '@alilc/lowcode-editor-core';
import { IPublicTypeCompositeValue, GlobalEvent, IPublicTypeJSSlot, SlotSchema, IPublicEnumTransformStage } from '@alilc/lowcode-types';
import { IPublicTypeCompositeValue, GlobalEvent, IPublicTypeJSSlot, IPublicTypeSlotSchema, IPublicEnumTransformStage } from '@alilc/lowcode-types';
import { uniqueId, isPlainObject, hasOwnProperty, compatStage, isJSExpression, isJSSlot } from '@alilc/lowcode-utils';
import { valueToSource } from './value-to-source';
import { Props } from './props';
@ -314,10 +314,10 @@ export class Prop implements IPropParent {
@action
setAsSlot(data: IPublicTypeJSSlot) {
this._type = 'slot';
let slotSchema: SlotSchema;
let slotSchema: IPublicTypeSlotSchema;
// 当 data.value 的结构为 { componentName: 'Slot' } 时,复用部分 slotSchema 数据
if ((isPlainObject(data.value) && data.value?.componentName === 'Slot')) {
const value = data.value as SlotSchema;
const value = data.value as IPublicTypeSlotSchema;
slotSchema = {
componentName: 'Slot',
title: value.title || value.props?.slotTitle,
@ -325,7 +325,7 @@ export class Prop implements IPropParent {
name: value.name || value.props?.slotName,
params: value.params || value.props?.slotParams,
children: data.value,
} as SlotSchema;
} as IPublicTypeSlotSchema;
} else {
slotSchema = {
componentName: 'Slot',

View File

@ -1,5 +1,5 @@
import { ComponentType } from 'react';
import { IPublicTypeComponentMetadata, IPublicTypeNodeSchema, IPublicModelScrollable, IPublicTypeComponentInstance, ISensor, NodeInstance } from '@alilc/lowcode-types';
import { IPublicTypeComponentMetadata, IPublicTypeNodeSchema, IPublicModelScrollable, IPublicTypeComponentInstance, IPublicModelSensor, IPublicTypeNodeInstance } from '@alilc/lowcode-types';
import { Point, ScrollTarget, ILocateEvent } from './designer';
import { BuiltinSimulatorRenderer } from './builtin-simulator/renderer';
import { Node, INode } from './document';
@ -11,6 +11,7 @@ export const AutoFit = '100%';
export interface IScrollable extends IPublicModelScrollable {
}
export interface IViewport extends IScrollable {
/**
*
*/
@ -32,22 +33,27 @@ export interface IViewport extends IScrollable {
*
*/
readonly bounds: DOMRect;
/**
*
*/
readonly contentBounds: DOMRect;
/**
*
*/
readonly scrollTarget?: ScrollTarget;
/**
*
*/
readonly scrolling: boolean;
/**
* X
*/
readonly scrollX: number;
/**
* Y
*/
@ -72,8 +78,9 @@ export interface DropContainer {
/**
*
*/
export interface ISimulatorHost<P = object> extends ISensor {
export interface ISimulatorHost<P = object> extends IPublicModelSensor {
readonly isSimulator: true;
/**
*
*/
@ -104,14 +111,17 @@ export interface ISimulatorHost<P = object> extends ISensor {
*
*/
setNativeSelection(enableFlag: boolean): void;
/**
*
*/
setDraggingState(state: boolean): void;
/**
*
*/
setCopyState(state: boolean): void;
/**
*
*/
@ -128,24 +138,28 @@ export interface ISimulatorHost<P = object> extends ISensor {
*
*/
generateComponentMetadata(componentName: string): IPublicTypeComponentMetadata;
/**
*
*/
getComponent(componentName: string): Component | any;
/**
*
*/
getComponentInstances(node: Node): IPublicTypeComponentInstance[] | null;
/**
* schema
*/
createComponent(schema: IPublicTypeNodeSchema): Component | null;
/**
*
*/
getComponentContext(node: Node): object | null;
getClosestNodeInstance(from: IPublicTypeComponentInstance, specId?: string): NodeInstance | null;
getClosestNodeInstance(from: IPublicTypeComponentInstance, specId?: string): IPublicTypeNodeInstance | null;
computeRect(node: Node): DOMRect | null;
@ -158,6 +172,7 @@ export interface ISimulatorHost<P = object> extends ISensor {
postEvent(evtName: string, evtData: any): void;
rerender(): void;
/**
*
*/

View File

@ -11,4 +11,10 @@ export const utils = {
getNodeSchemaById,
};
export enum EDITOR_EVENT {
NODE_CHILDREN_CHANGE = 'node.children.change',
NODE_VISIBLE_CHANGE = 'node.visible.change',
}
export type Utils = typeof utils;

View File

@ -7,8 +7,8 @@ import {
IPublicModelEditor,
EditorConfig,
PluginClassSet,
KeyType,
GetReturnType,
IPublicTypeEditorValueKey,
IPublicTypeEditorGetResult,
HookConfig,
IPublicTypeComponentDescription,
IPublicTypeRemoteComponentDescription,
@ -61,10 +61,11 @@ export class Editor extends (EventEmitter as any) implements IPublicModelEditor
this.setMaxListeners(200);
this.eventBus = new EventBus(this);
}
/**
* Ioc Container
*/
@obx.shallow private context = new Map<KeyType, any>();
@obx.shallow private context = new Map<IPublicTypeEditorValueKey, any>();
get locale() {
return globalLocale.getLocale();
@ -76,15 +77,15 @@ export class Editor extends (EventEmitter as any) implements IPublicModelEditor
get<T = undefined, KeyOrType = any>(
keyOrType: KeyOrType,
): GetReturnType<T, KeyOrType> | undefined {
): IPublicTypeEditorGetResult<T, KeyOrType> | undefined {
return this.context.get(keyOrType as any);
}
has(keyOrType: KeyType): boolean {
has(keyOrType: IPublicTypeEditorValueKey): boolean {
return this.context.has(keyOrType);
}
set(key: KeyType, data: any): void | Promise<void> {
set(key: IPublicTypeEditorValueKey, data: any): void | Promise<void> {
if (key === 'assets') {
return this.setAssets(data);
}
@ -172,7 +173,7 @@ export class Editor extends (EventEmitter as any) implements IPublicModelEditor
this.notifyGot('assets');
}
onceGot<T = undefined, KeyOrType extends KeyType = any>(keyOrType: KeyOrType): Promise<GetReturnType<T, KeyOrType>> {
onceGot<T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(keyOrType: KeyOrType): Promise<IPublicTypeEditorGetResult<T, KeyOrType>> {
const x = this.context.get(keyOrType);
if (x !== undefined) {
return Promise.resolve(x);
@ -182,9 +183,9 @@ export class Editor extends (EventEmitter as any) implements IPublicModelEditor
});
}
onGot<T = undefined, KeyOrType extends KeyType = any>(
onGot<T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(
keyOrType: KeyOrType,
fn: (data: GetReturnType<T, KeyOrType>) => void,
fn: (data: IPublicTypeEditorGetResult<T, KeyOrType>) => void,
): () => void {
const x = this.context.get(keyOrType);
if (x !== undefined) {
@ -198,7 +199,7 @@ export class Editor extends (EventEmitter as any) implements IPublicModelEditor
}
}
register(data: any, key?: KeyType): void {
register(data: any, key?: IPublicTypeEditorValueKey): void {
this.context.set(key || data, data);
this.notifyGot(key || data);
}
@ -273,7 +274,7 @@ export class Editor extends (EventEmitter as any) implements IPublicModelEditor
/* eslint-disable */
private waits = new Map<
KeyType,
IPublicTypeEditorValueKey,
Array<{
once?: boolean;
resolve: (data: any) => void;
@ -281,7 +282,7 @@ export class Editor extends (EventEmitter as any) implements IPublicModelEditor
>();
/* eslint-enable */
private notifyGot(key: KeyType) {
private notifyGot(key: IPublicTypeEditorValueKey) {
let waits = this.waits.get(key);
if (!waits) {
return;
@ -301,7 +302,7 @@ export class Editor extends (EventEmitter as any) implements IPublicModelEditor
}
}
private setWait(key: KeyType, resolve: (data: any) => void, once?: boolean) {
private setWait(key: IPublicTypeEditorValueKey, resolve: (data: any) => void, once?: boolean) {
const waits = this.waits.get(key);
if (waits) {
waits.push({ resolve, once });
@ -310,7 +311,7 @@ export class Editor extends (EventEmitter as any) implements IPublicModelEditor
}
}
private delWait(key: KeyType, fn: any) {
private delWait(key: IPublicTypeEditorValueKey, fn: any) {
const waits = this.waits.get(key);
if (!waits) {
return;

View File

@ -1,12 +1,20 @@
/* eslint-disable max-len */
import { obx, computed, makeObservable } from '@alilc/lowcode-editor-core';
import { Logger } from '@alilc/lowcode-utils';
import { IPublicTypeWidgetBaseConfig, IArea } from '@alilc/lowcode-types';
import { IPublicTypeWidgetBaseConfig } from '@alilc/lowcode-types';
import { WidgetContainer } from './widget/widget-container';
import { Skeleton } from './skeleton';
import { IWidget } from './widget/widget';
const logger = new Logger({ level: 'warn', bizName: 'skeleton:area' });
export interface IArea<C, T> {
isEmpty(): boolean;
add(config: T | C): T;
remove(config: T | string): number;
setVisible(flag: boolean): void;
hide(): void;
show(): void;
}
export class Area<C extends IPublicTypeWidgetBaseConfig = any, T extends IWidget = IWidget> implements IArea<C, T> {
@obx private _visible = true;

View File

@ -9,7 +9,7 @@ import {
import {
IPublicModelDragObject,
IPublicModelScrollable,
ISensor,
IPublicModelSensor,
IPublicTypeLocationChildrenDetail,
IPublicTypeLocationDetailType,
IPublicModelNode,
@ -24,7 +24,7 @@ import { IndentTrack } from '../helper/indent-track';
import DwellTimer from '../helper/dwell-timer';
import { ITreeBoard, TreeMaster } from './tree-master';
export class PaneController implements ISensor, ITreeBoard, IPublicModelScrollable {
export class PaneController implements IPublicModelSensor, ITreeBoard, IPublicModelScrollable {
private pluginContext: IPublicModelPluginContext;
private treeMaster?: TreeMaster;
@ -50,12 +50,12 @@ export class PaneController implements ISensor, ITreeBoard, IPublicModelScrollab
setup();
}
/** -------------------- ISensor begin -------------------- */
/** -------------------- IPublicModelSensor begin -------------------- */
private indentTrack = new IndentTrack();
/**
* @see ISensor
* @see IPublicModelSensor
*/
fixEvent(e: IPublicModelLocateEvent): IPublicModelLocateEvent {
if (e.fixed) {
@ -77,7 +77,7 @@ export class PaneController implements ISensor, ITreeBoard, IPublicModelScrollab
}
/**
* @see ISensor
* @see IPublicModelSensor
*/
locate(e: IPublicModelLocateEvent): IPublicModelDropLocation | undefined | null {
this.sensing = true;
@ -213,7 +213,7 @@ export class PaneController implements ISensor, ITreeBoard, IPublicModelScrollab
}
/**
* @see ISensor
* @see IPublicModelSensor
*/
isEnter(e: IPublicModelLocateEvent): boolean {
if (!this._shell) {
@ -224,7 +224,7 @@ export class PaneController implements ISensor, ITreeBoard, IPublicModelScrollab
}
/**
* @see ISensor
* @see IPublicModelSensor
*/
deactiveSensor() {
this.sensing = false;
@ -234,15 +234,15 @@ export class PaneController implements ISensor, ITreeBoard, IPublicModelScrollab
}
private _sensorAvailable = false;
/**
* @see ISensor
* @see IPublicModelSensor
*/
get sensorAvailable() {
return this._sensorAvailable;
}
/** -------------------- ISensor end -------------------- */
/** -------------------- IPublicModelSensor end -------------------- */
/** -------------------- ITreeBoard begin -------------------- */
@ -564,7 +564,6 @@ export class PaneController implements ISensor, ITreeBoard, IPublicModelScrollab
return this._scrollTarget;
}
private scroller?: IPublicModelScroller;
purge() {
@ -573,7 +572,6 @@ export class PaneController implements ISensor, ITreeBoard, IPublicModelScrollab
this.treeMaster?.removeBoard(this);
}
private _shell: HTMLDivElement | null = null;
mount(shell: HTMLDivElement | null) {

View File

@ -1,5 +1,5 @@
import { BuiltinSimulatorRenderer, Component, DocumentModel, Node } from '@alilc/lowcode-designer';
import { IPublicTypeComponentSchema, IPublicTypeNodeSchema, IPublicTypeNpmInfo, IPublicEnumTransformStage, NodeInstance } from '@alilc/lowcode-types';
import { IPublicTypeComponentSchema, IPublicTypeNodeSchema, IPublicTypeNpmInfo, IPublicEnumTransformStage, IPublicTypeNodeInstance } from '@alilc/lowcode-types';
import { Asset, compatibleLegaoSchema, cursor, isElement, isESModule, isPlainObject, isReactComponent, setNativeSelection } from '@alilc/lowcode-utils';
import LowCodeRenderer from '@alilc/lowcode-rax-renderer';
import { computed, observable as obx, makeObservable, configure } from 'mobx';
@ -94,7 +94,7 @@ function isValidDesignModeRaxComponentInstance(
raxComponentInst: any,
): raxComponentInst is {
props: {
_leaf: Exclude<NodeInstance<any>['node'], null | undefined>;
_leaf: Exclude<IPublicTypeNodeInstance<any>['node'], null | undefined>;
};
} {
const leaf = raxComponentInst?.props?._leaf;
@ -370,6 +370,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
@computed get componentsMap(): any {
return this._componentsMap;
}
/**
*
*/
@ -396,7 +397,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
}
}
getNodeInstance(dom: HTMLElement): NodeInstance<any> | null {
getNodeInstance(dom: HTMLElement): IPublicTypeNodeInstance<any> | null {
const INTERNAL = '_internal';
let instance: any = dom;
if (!isElement(instance)) {
@ -429,7 +430,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
return null;
}
getClosestNodeInstance(from: any, nodeId?: string): NodeInstance<any> | null {
getClosestNodeInstance(from: any, nodeId?: string): IPublicTypeNodeInstance<any> | null {
const el: any = from;
if (el) {
// if (isElement(el)) {
@ -510,7 +511,6 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
doc.getElementsByTagName('head')[0].appendChild(s);
}
const renderer = this;
const { componentsMap: components } = renderer;

View File

@ -17,7 +17,7 @@ import {
AssetLoader,
getProjectUtils,
} from '@alilc/lowcode-utils';
import { IPublicTypeComponentSchema, IPublicEnumTransformStage, IPublicTypeNodeSchema, NodeInstance } from '@alilc/lowcode-types';
import { IPublicTypeComponentSchema, IPublicEnumTransformStage, IPublicTypeNodeSchema, IPublicTypeNodeInstance } from '@alilc/lowcode-types';
// just use types
import { BuiltinSimulatorRenderer, Component, DocumentModel, Node } from '@alilc/lowcode-designer';
import LowCodeRenderer from '@alilc/lowcode-react-renderer';
@ -368,6 +368,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
*
*/
autoRepaintNode = true;
/**
*
*/
@ -399,7 +400,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
}
}
getClosestNodeInstance(from: ReactInstance, nodeId?: string): NodeInstance<ReactInstance> | null {
getClosestNodeInstance(from: ReactInstance, nodeId?: string): IPublicTypeNodeInstance<ReactInstance> | null {
return getClosestNodeInstance(from, nodeId);
}
@ -557,7 +558,7 @@ const SYMBOL_VDID = Symbol('_LCDocId');
function getClosestNodeInstance(
from: ReactInstance,
specId?: string,
): NodeInstance<ReactInstance> | null {
): IPublicTypeNodeInstance<ReactInstance> | null {
let el: any = from;
if (el) {
if (isElement(el)) {
@ -587,7 +588,7 @@ function getClosestNodeInstance(
return null;
}
function getNodeInstance(fiberNode: any, specId?: string): NodeInstance<ReactInstance> | null {
function getNodeInstance(fiberNode: any, specId?: string): IPublicTypeNodeInstance<ReactInstance> | null {
const instance = fiberNode?.stateNode;
if (instance && SYMBOL_VNID in instance) {
const nodeId = instance[SYMBOL_VNID];

View File

@ -4,7 +4,6 @@ import {
IPublicModelScrollTarget,
IPublicModelScrollable,
IPublicModelScroller,
IDesigner,
IPublicTypeLocationData,
IPublicModelEditor,
IPublicModelDragon,
@ -12,13 +11,13 @@ import {
} from '@alilc/lowcode-types';
import {
ScrollTarget as InnerScrollTarget,
IDesigner,
} from '@alilc/lowcode-designer';
import { editorSymbol, designerSymbol, nodeSymbol } from '../symbols';
import { Dragon } from '../model';
import { DropLocation } from '../model/drop-location';
import { ActiveTracker } from '../model/active-tracker';
export class Canvas implements IPublicApiCanvas {
private readonly [editorSymbol]: IPublicModelEditor;

View File

@ -25,7 +25,6 @@ import {
IPublicTypeLocationDetailType as InnerLocationDetailType,
IPublicApiCommonEditorCabin,
IPublicModelDragon,
IDesigner,
} from '@alilc/lowcode-types';
import {
SettingField as InnerSettingField,
@ -35,6 +34,7 @@ import {
ScrollTarget as InnerScrollTarget,
getConvertedExtraKey as innerGetConvertedExtraKey,
getOriginalExtraKey as innerGetOriginalExtraKey,
IDesigner,
} from '@alilc/lowcode-designer';
import {
Skeleton as InnerSkeleton,
@ -63,6 +63,7 @@ import { ReactNode, Component } from 'react';
class DesignerCabin implements IPublicApiCommonDesignerCabin {
private readonly [editorSymbol]: Editor;
/**
* @deprecated
*/
@ -240,6 +241,7 @@ class EditorCabin implements IPublicApiCommonEditorCabin {
constructor(editor: Editor) {
this[editorSymbol] = editor;
}
/**
* Title
* @experimental unstable API, pay extra caution when trying to use this
@ -335,7 +337,6 @@ class EditorCabin implements IPublicApiCommonEditorCabin {
}
}
export class Common implements IPublicApiCommon {
private readonly __designerCabin: any;
private readonly __skeletonCabin: any;

View File

@ -3,14 +3,13 @@ import {
DocumentModel as InnerDocumentModel,
Node as InnerNode,
isDragNodeObject,
IOnChangeOptions as InnerOnChangeOptions,
} from '@alilc/lowcode-designer';
import {
IPublicEnumTransformStage,
IPublicTypeRootSchema,
GlobalEvent,
IPublicModelDocumentModel,
IPublicOnChangeOptions,
IPublicTypeOnChangeOptions,
IPublicModelDragObject,
IPublicTypeDragNodeObject,
IPublicTypeDragNodeDataObject,
@ -45,6 +44,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
selection: IPublicModelSelection;
detecting: IPublicModelDetecting;
history: IPublicModelHistory;
/**
* @deprecated use canvas API instead
*/
@ -141,6 +141,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
set dropLocation(loc: IPublicModelDropLocation | null) {
this[documentSymbol].dropLocation = loc;
}
/**
* nodeId Node
* get node instance by nodeId
@ -297,8 +298,8 @@ export class DocumentModel implements IPublicModelDocumentModel {
* document children
* @param fn
*/
onChangeNodeChildren(fn: (info: IPublicOnChangeOptions) => void): void {
this[documentSymbol].onChangeNodeChildren((info?: IPublicOnChangeOptions) => {
onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions) => void): void {
this[documentSymbol].onChangeNodeChildren((info?: IPublicTypeOnChangeOptions) => {
if (!info) {
return;
}

View File

@ -7,7 +7,7 @@ export enum ActivityType {
'COMPOSITE' = 'composite',
}
export interface IActivityPayload {
interface IActivityPayload {
schema: IPublicTypeNodeSchema;
location?: {
parent: {
@ -20,6 +20,10 @@ export interface IActivityPayload {
newValue: any;
}
/**
* TODO: not sure if this is used anywhere
* @deprecated
*/
export type ActivityData = {
type: ActivityType;
payload: IActivityPayload;

View File

@ -1,12 +1,3 @@
export interface AssetItem {
type: AssetType;
content?: string | null;
device?: string;
level?: AssetLevel;
id?: string;
}
export enum AssetLevel {
// 环境依赖库 比如 react, react-dom
Environment = 1,
@ -41,12 +32,20 @@ export enum AssetType {
Bundle = 'bundle',
}
export interface AssetItem {
type: AssetType;
content?: string | null;
device?: string;
level?: AssetLevel;
id?: string;
}
export type AssetList = Array<Asset | undefined | null>;
export type Asset = AssetList | AssetBundle | AssetItem | URL;
export interface AssetBundle {
type: AssetType.Bundle;
level?: AssetLevel;
assets?: Asset | AssetList | null;
}
export type Asset = AssetList | AssetBundle | AssetItem | URL;
export type AssetList = Array<Asset | undefined | null>;

View File

@ -1,25 +0,0 @@
import { IPublicModelNode, IPublicModelDragon, IPublicModelDropLocation, IPublicModelScroller, IPublicModelScrollable, IPublicTypeComponentInstance, IPublicTypeLocationData, IPublicModelActiveTracker } from './shell';
export interface IPublicOnChangeOptions {
type: string;
node: IPublicModelNode;
}
export interface NodeInstance<T = IPublicTypeComponentInstance> {
docId: string;
nodeId: string;
instance: T;
node?: Node | null;
}
export interface IDesigner {
get dragon(): IPublicModelDragon;
get activeTracker(): IPublicModelActiveTracker;
createScroller(scrollable: IPublicModelScrollable): IPublicModelScroller;
/**
* dragon
*/
createLocation(locationData: IPublicTypeLocationData): IPublicModelDropLocation;
}

View File

@ -1,82 +0,0 @@
import { NodeInstance } from './designer';
import {
IPublicModelDocumentModel,
IPublicModelLocateEvent,
IPublicModelDropLocation,
IPublicTypeComponentInstance,
} from './shell';
import { IPublicTypeDragObject } from './shell/type/drag-object';
export interface LocateEvent {
readonly type: 'LocateEvent';
/**
*
*/
readonly globalX: number;
readonly globalY: number;
/**
*
*/
readonly originalEvent: MouseEvent | DragEvent;
/**
*
*/
readonly dragObject: IPublicTypeDragObject;
/**
*
*/
sensor?: ISensor;
// ======= 以下是 激活的 sensor 将填充的值 ========
/**
*
*/
target?: Element | null;
/**
*
*/
canvasX?: number;
canvasY?: number;
/**
*
*/
documentModel?: IPublicModelDocumentModel;
/**
* canvasX,canvasY,
*/
fixed?: true;
}
/**
*
*/
export interface ISensor {
/**
* false
*/
readonly sensorAvailable: boolean;
/**
*
*/
fixEvent(e: IPublicModelLocateEvent): IPublicModelLocateEvent;
/**
*
*/
locate(e: IPublicModelLocateEvent): IPublicModelDropLocation | undefined | null;
/**
*
*/
isEnter(e: IPublicModelLocateEvent): boolean;
/**
*
*/
deactiveSensor(): void;
/**
*
*/
getNodeInstanceFromElement?: (e: Element | null) => NodeInstance<IPublicTypeComponentInstance> | null;
}

View File

@ -1,8 +0,0 @@
export interface IArea<C, T> {
isEmpty(): boolean;
add(config: T | C): T;
remove(config: T | string): number;
setVisible(flag: boolean): void;
hide(): void;
show(): void;
}

View File

@ -1,34 +1,6 @@
import { ReactNode, ComponentType } from 'react';
import { IPublicTypeNpmInfo, IPublicModelEditor } from './shell';
export type KeyType = (new (...args: any[]) => any) | symbol | string;
export type ClassType = new (...args: any[]) => any;
export interface GetOptions {
forceNew?: boolean;
sourceCls?: ClassType;
}
export type GetReturnType<T, ClsType> = T extends undefined
? ClsType extends {
prototype: infer R;
}
? R
: any
: T;
/**
* duck-typed power-di
*
* @see https://www.npmjs.com/package/power-di
*/
export interface PowerDIRegisterOptions {
/** default: true */
singleton?: boolean;
/** if data a class, auto new a instance.
* if data a function, auto run(lazy).
* default: true */
autoNew?: boolean;
}
export interface EditorConfig {
skeleton?: SkeletonConfig;
theme?: ThemeConfig;
@ -172,10 +144,4 @@ export interface PluginStatus {
export interface PluginStatusSet {
[key: string]: PluginStatus;
}
export enum EDITOR_EVENT {
NODE_CHILDREN_CHANGE = 'node.children.change',
NODE_VISIBLE_CHANGE = 'node.visible.change',
}

View File

@ -1,29 +1,10 @@
export * from '@alilc/lowcode-datasource-types';
export * from './editor';
export * from './shell/type/field-extra-props';
export * from './shell/type/i18n-map';
export * from './shell/type/icon-config';
export * from './shell/type/metadata';
export * from './shell/type/npm';
export * from './shell/type/prop-types';
export * from './schema';
export * from './activity';
export * from './shell/type/tip-config';
export * from './shell/type/title-content';
export * from './utils';
export * from './shell/type/value-type';
export * from './shell/type/setter-config';
export * from './shell/model/setting-target';
export * from './node';
export * from './shell/enum/transform-stage';
export * from './code-intermediate';
export * from './code-result';
export * from './assets';
export * as GlobalEvent from './event';
export * from './shell/type/props-transducer';
export * from './editor-skeleton';
export * from './designer';
export * from './dragon';
export * from './shell';
export * from './shell-model-factory';
// TODO: remove this in future versions

View File

@ -1,10 +0,0 @@
export interface NodeStatus {
locking: boolean;
pseudo: boolean;
inPlaceEditing: boolean;
}
export interface LeafNode extends Node {
readonly children: null;
}

View File

@ -1,19 +0,0 @@
import { IPublicTypeNodeSchema } from './shell/type/node-schema';
import { IPublicTypeNodeData } from './shell/type/node-data';
export type NodeDataType = IPublicTypeNodeData | IPublicTypeNodeData[];
/**
* Slot schema
*/
export interface SlotSchema extends IPublicTypeNodeSchema {
componentName: 'Slot';
name?: string;
title?: string;
params?: string[];
props?: {
slotTitle?: string;
slotName?: string;
slotParams?: string[];
};
children?: IPublicTypeNodeSchema[];
}

View File

@ -2,7 +2,7 @@ import { IPublicTypeRootSchema, IPublicTypeDragNodeDataObject, IPublicTypeDragNo
import { IPublicEnumTransformStage } from '../enum';
import { IPublicApiProject } from '../api';
import { IPublicModelDropLocation, IPublicModelDetecting, IPublicModelNode, IPublicModelSelection, IPublicModelHistory, IPublicModelModalNodesManager } from './';
import { IPublicOnChangeOptions } from '@alilc/lowcode-types';
import { IPublicTypeOnChangeOptions } from '@alilc/lowcode-types';
export interface IPublicModelDocumentModel {
@ -168,12 +168,11 @@ export interface IPublicModelDocumentModel {
*/
onChangeNodeVisible(fn: (node: IPublicModelNode, visible: boolean) => void): void;
/**
* document children
* @param fn
*/
onChangeNodeChildren(fn: (info: IPublicOnChangeOptions) => void): void;
onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions) => void): void;
/**
* document
@ -210,7 +209,6 @@ export interface IPublicModelDocumentModel {
*/
set dropLocation(loc: IPublicModelDropLocation | null);
/**
*
* triggered focused node is set mannually from plugin

View File

@ -3,27 +3,26 @@ import { EventEmitter } from 'events';
import StrictEventEmitter from 'strict-event-emitter-types';
import * as GlobalEvent from '../../event';
import { IPublicApiEvent } from '../api';
import { GetOptions, GetReturnType, KeyType, PowerDIRegisterOptions } from '../../editor';
import { IPublicTypeEditorValueKey, IPublicTypeEditorGetOptions, IPublicTypeEditorGetResult, IPublicTypeEditorRegisterOptions } from '../type';
export interface IPublicModelEditor extends StrictEventEmitter<EventEmitter, GlobalEvent.EventConfig> {
get: <T = undefined, KeyOrType = any>(
keyOrType: KeyOrType,
opt?: GetOptions
) => GetReturnType<T, KeyOrType> | undefined;
opt?: IPublicTypeEditorGetOptions
) => IPublicTypeEditorGetResult<T, KeyOrType> | undefined;
has: (keyOrType: KeyType) => boolean;
has: (keyOrType: IPublicTypeEditorValueKey) => boolean;
set: (key: KeyType, data: any) => void | Promise<void>;
set: (key: IPublicTypeEditorValueKey, data: any) => void | Promise<void>;
onceGot: <T = undefined, KeyOrType extends KeyType = any>(keyOrType: KeyOrType) => Promise<GetReturnType<T, KeyOrType>>;
onceGot: <T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(keyOrType: KeyOrType) => Promise<IPublicTypeEditorGetResult<T, KeyOrType>>;
onGot: <T = undefined, KeyOrType extends KeyType = any>(
onGot: <T = undefined, KeyOrType extends IPublicTypeEditorValueKey = any>(
keyOrType: KeyOrType,
fn: (data: GetReturnType<T, KeyOrType>) => void
fn: (data: IPublicTypeEditorGetResult<T, KeyOrType>) => void
) => () => void;
register: (data: any, key?: KeyType, options?: PowerDIRegisterOptions) => void;
register: (data: any, key?: IPublicTypeEditorValueKey, options?: IPublicTypeEditorRegisterOptions) => void;
get eventBus(): IPublicApiEvent;
}

View File

@ -26,4 +26,5 @@ export * from './setting-target';
export * from './engine-config';
export * from './editor';
export * from './preference';
export * from './plugin-instance';
export * from './plugin-instance';
export * from './sensor';

View File

@ -0,0 +1,42 @@
import { IPublicTypeNodeInstance } from '../type/node-instance';
import {
IPublicModelLocateEvent,
IPublicModelDropLocation,
IPublicTypeComponentInstance,
} from '..';
/**
*
*/
export interface IPublicModelSensor {
/**
* false
*/
readonly sensorAvailable: boolean;
/**
*
*/
fixEvent(e: IPublicModelLocateEvent): IPublicModelLocateEvent;
/**
*
*/
locate(e: IPublicModelLocateEvent): IPublicModelDropLocation | undefined | null;
/**
*
*/
isEnter(e: IPublicModelLocateEvent): boolean;
/**
*
*/
deactiveSensor(): void;
/**
*
*/
getNodeInstanceFromElement?: (e: Element | null) => IPublicTypeNodeInstance<IPublicTypeComponentInstance> | null;
}

View File

@ -0,0 +1,5 @@
export interface IPublicTypeEditorGetOptions {
forceNew?: boolean;
sourceCls?: new (...args: any[]) => any;
}

View File

@ -0,0 +1,4 @@
export type IPublicTypeEditorGetResult<T, ClsType> = T extends undefined ? ClsType extends {
prototype: infer R;
} ? R : any : T;

View File

@ -0,0 +1,19 @@
/**
* duck-typed power-di
*
* @see https://www.npmjs.com/package/power-di
*/
export interface IPublicTypeEditorRegisterOptions {
/**
* default: true
*/
singleton?: boolean;
/**
* if data a class, auto new a instance.
* if data a function, auto run(lazy).
* default: true
*/
autoNew?: boolean;
}

View File

@ -0,0 +1,2 @@
export type IPublicTypeEditorValueKey = (new (...args: any[]) => any) | symbol | string;

View File

@ -1,6 +1,6 @@
// this folder contains all interfaces/types working as type definition
// - some exists as type TypeName
// - some althought exists as interfaces , but there won`t be a class implements them.
// - some althought exists as interfaces , but there won`t be any class implements them.
// all of above cases will with prefix IPublicType, eg. IPublicTypeSomeName
export * from './location';
export * from './active-target';
@ -74,4 +74,12 @@ export * from './widget-config-area';
export * from './hotkey-callback';
export * from './plugin-register-options';
export * from './resource-options';
export * from './engine-options';
export * from './engine-options';
export * from './on-change-options';
export * from './slot-schema';
export * from './node-data-type';
export * from './node-instance';
export * from './editor-value-key';
export * from './editor-get-options';
export * from './editor-get-result';
export * from './editor-register-options';

View File

@ -0,0 +1,3 @@
import { IPublicTypeNodeData } from './node-data';
export type IPublicTypeNodeDataType = IPublicTypeNodeData | IPublicTypeNodeData[];

View File

@ -0,0 +1,8 @@
import { IPublicTypeComponentInstance, IPublicModelNode } from '..';
export interface IPublicTypeNodeInstance<T = IPublicTypeComponentInstance> {
docId: string;
nodeId: string;
instance: T;
node?: IPublicModelNode | null;
}

View File

@ -0,0 +1,6 @@
import { IPublicModelNode } from '..';
export interface IPublicTypeOnChangeOptions {
type: string;
node: IPublicModelNode;
}

View File

@ -0,0 +1,17 @@
import { IPublicTypeNodeSchema } from './node-schema';
/**
* Slot schema
*/
export interface IPublicTypeSlotSchema extends IPublicTypeNodeSchema {
componentName: 'Slot';
name?: string;
title?: string;
params?: string[];
props?: {
slotTitle?: string;
slotName?: string;
slotParams?: string[];
};
children?: IPublicTypeNodeSchema[];
}

View File

@ -119,6 +119,10 @@ function getNodeSchemaFromPropsById(props: any, nodeId: string): IPublicTypeNode
}
}
/**
* TODO: not sure if this is used anywhere
* @deprecated
*/
export function applyActivities(pivotSchema: IPublicTypeRootSchema, activities: any, options?: any): IPublicTypeRootSchema {
let schema = { ...pivotSchema };
if (!Array.isArray(activities)) {