Compare commits

...

8 Commits

Author SHA1 Message Date
JackLian
904a687573 chore(release): publish 1.1.4-beta.2 2023-03-20 08:31:11 +08:00
liujuping
b7b0366de5 feat: lowCode components support project schema 2023-03-20 08:26:26 +08:00
Qi
7eae3562a0 fix: fiberkey compatibility 2023-03-20 08:26:26 +08:00
BARM
d2b6bc7565 update pluginWidget.md
Dock的使用需要在props里面定义icon属性和onClick事件
2023-03-20 08:26:26 +08:00
JackLian
1e95f1d0d0 chore(release): publish 1.1.4-beta.1 2023-03-16 11:23:10 +08:00
JackLian
e6f1a34c2b chore(docs): publish docs 1.0.21 2023-03-16 11:20:33 +08:00
liujuping
43d618dbc6 refactor: rename internalToShell to internalToShellField 2023-03-16 11:20:33 +08:00
JackLian
f295278bfb chore(release): publish 1.1.4-beta.0 2023-03-16 09:32:17 +08:00
35 changed files with 210 additions and 149 deletions

View File

@ -172,19 +172,16 @@ skeleton.add({
area: 'leftArea',
type: 'Dock',
name: 'opener',
content: Opener, // Widget 组件实例
contentProps: { // Widget 插件 props
xxx: '1',
},
props: {
icon: Icon, // Icon 组件实例
align: 'bottom',
},
onClick: function () {
// 打开外部链接
window.open('https://lowcode-engine.cn');
// 显示 widget
skeleton.showWidget('xxx');
},
onClick: function () {
// 打开外部链接
window.open('https://lowcode-engine.cn');
// 显示 widget
skeleton.showWidget('xxx');
}
}
});
```

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-engine-docs",
"version": "1.0.20",
"version": "1.0.21",
"description": "低代码引擎版本化文档",
"license": "MIT",
"files": [

View File

@ -1,6 +1,6 @@
{
"lerna": "4.0.0",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-designer",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "Designer for Ali LowCode Engine",
"main": "lib/index.js",
"module": "es/index.js",
@ -15,9 +15,9 @@
},
"license": "MIT",
"dependencies": {
"@alilc/lowcode-editor-core": "1.1.3",
"@alilc/lowcode-types": "1.1.3",
"@alilc/lowcode-utils": "1.1.3",
"@alilc/lowcode-editor-core": "1.1.4-beta.2",
"@alilc/lowcode-types": "1.1.4-beta.2",
"@alilc/lowcode-utils": "1.1.4-beta.2",
"classnames": "^2.2.6",
"react": "^16",
"react-dom": "^16.7.0",

View File

@ -1,12 +1,12 @@
import { Component } from '../simulator';
import { IPublicTypeNodeSchema, IPublicTypeComponentInstance, IPublicTypeNodeInstance, Asset } from '@alilc/lowcode-types';
import { IPublicTypeComponentInstance, IPublicTypeNodeInstance, Asset, IPublicTypeComponentSchema, IPublicTypeProjectSchema, IPublicTypeLowCodeComponent } from '@alilc/lowcode-types';
export interface BuiltinSimulatorRenderer {
readonly isSimulatorRenderer: true;
autoRepaintNode?: boolean;
components: Record<string, Component>;
rerender: () => void;
createComponent(schema: IPublicTypeNodeSchema): Component | null;
createComponent(schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema>): Component | null;
getComponent(componentName: string): Component;
getClosestNodeInstance(
from: IPublicTypeComponentInstance,

View File

@ -73,7 +73,7 @@ INode
onEffect(action: () => void): IPublicTypeDisposable;
internalToShell(): IPublicModelSettingField;
internalToShellField(): IPublicModelSettingField;
}
export class SettingField extends SettingPropEntry implements ISettingField {
@ -143,7 +143,7 @@ export class SettingField extends SettingPropEntry implements ISettingField {
}
if (isDynamicSetter(this._setter)) {
return untracked(() => {
const shellThis = this.internalToShell();
const shellThis = this.internalToShellField();
return (this._setter as IPublicTypeDynamicSetter)?.call(shellThis, shellThis!);
});
}
@ -296,7 +296,7 @@ export class SettingField extends SettingPropEntry implements ISettingField {
}
internalToShell() {
internalToShellField() {
return this.designer!.shellModelFactory.createSettingField(this);
}
}

View File

@ -35,7 +35,7 @@ export interface ISettingPropEntry extends ISettingEntry {
setValue(val: any, isHotValue?: boolean, force?: boolean, extraOptions?: IPublicTypeSetValueOptions): void;
internalToShell(): IPublicModelSettingField;
internalToShellField(): IPublicModelSettingField;
}
export class SettingPropEntry implements ISettingPropEntry {
@ -157,7 +157,7 @@ export class SettingPropEntry implements ISettingPropEntry {
if (this.type !== 'field') {
const { getValue } = this.extraProps;
return getValue
? getValue(this.internalToShell()!, undefined) === undefined
? getValue(this.internalToShellField()!, undefined) === undefined
? 0
: 1
: 0;
@ -196,7 +196,7 @@ export class SettingPropEntry implements ISettingPropEntry {
}
const { getValue } = this.extraProps;
try {
return getValue ? getValue(this.internalToShell()!, val) : val;
return getValue ? getValue(this.internalToShellField()!, val) : val;
} catch (e) {
console.warn(e);
return val;
@ -215,7 +215,7 @@ export class SettingPropEntry implements ISettingPropEntry {
const { setValue } = this.extraProps;
if (setValue && !extraOptions?.disableMutator) {
try {
setValue(this.internalToShell()!, val);
setValue(this.internalToShellField()!, val);
} catch (e) {
/* istanbul ignore next */
console.warn(e);
@ -238,7 +238,7 @@ export class SettingPropEntry implements ISettingPropEntry {
const { setValue } = this.extraProps;
if (setValue) {
try {
setValue(this.internalToShell()!, undefined);
setValue(this.internalToShellField()!, undefined);
} catch (e) {
/* istanbul ignore next */
console.warn(e);
@ -394,7 +394,7 @@ export class SettingPropEntry implements ISettingPropEntry {
return v;
}
internalToShell(): IPublicModelSettingField {
internalToShellField(): IPublicModelSettingField {
return this.designer!.shellModelFactory.createSettingField(this);;
}
}

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-editor-core",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "Core Api for Ali lowCode engine",
"license": "MIT",
"main": "lib/index.js",
@ -14,8 +14,8 @@
},
"dependencies": {
"@alifd/next": "^1.19.16",
"@alilc/lowcode-types": "1.1.3",
"@alilc/lowcode-utils": "1.1.3",
"@alilc/lowcode-types": "1.1.4-beta.2",
"@alilc/lowcode-utils": "1.1.4-beta.2",
"classnames": "^2.2.6",
"debug": "^4.1.1",
"intl-messageformat": "^9.3.1",

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-editor-skeleton",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "alibaba lowcode editor skeleton",
"main": "lib/index.js",
"module": "es/index.js",
@ -18,10 +18,10 @@
],
"dependencies": {
"@alifd/next": "^1.20.12",
"@alilc/lowcode-designer": "1.1.3",
"@alilc/lowcode-editor-core": "1.1.3",
"@alilc/lowcode-types": "1.1.3",
"@alilc/lowcode-utils": "1.1.3",
"@alilc/lowcode-designer": "1.1.4-beta.2",
"@alilc/lowcode-editor-core": "1.1.4-beta.2",
"@alilc/lowcode-types": "1.1.4-beta.2",
"@alilc/lowcode-utils": "1.1.4-beta.2",
"classnames": "^2.2.6",
"react": "^16.8.1",
"react-dom": "^16.8.1"

View File

@ -80,7 +80,7 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
const { extraProps } = this.field;
const { condition } = extraProps;
try {
return typeof condition === 'function' ? condition(this.field.internalToShell()) !== false : true;
return typeof condition === 'function' ? condition(this.field.internalToShellField()) !== false : true;
} catch (error) {
console.error('exception when condition (hidden) is excuted', error);
}
@ -123,7 +123,7 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
if (setter.props) {
setterProps = setter.props;
if (typeof setterProps === 'function') {
setterProps = setterProps(this.field.internalToShell());
setterProps = setterProps(this.field.internalToShellField());
}
}
if (setter.initialValue != null) {
@ -190,7 +190,7 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
}
// 当前 field 没有 value 值时,将 initialValue 写入 field
// 之所以用 initialValue而不是 defaultValue 是为了保持跟 props.onInitial 的逻辑一致
const _initialValue = typeof initialValue === 'function' ? initialValue(this.field.internalToShell()) : initialValue;
const _initialValue = typeof initialValue === 'function' ? initialValue(this.field.internalToShellField()) : initialValue;
this.field.setValue(_initialValue);
}
@ -238,9 +238,9 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
forceInline: extraProps.forceInline,
key: field.id,
// === injection
prop: field.internalToShell(), // for compatible vision
prop: field.internalToShellField(), // for compatible vision
selected: field.top?.getNode()?.internalToShellNode(),
field: field.internalToShell(),
field: field.internalToShellField(),
// === IO
value, // reaction point
initialValue,
@ -257,7 +257,7 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
if (initialValue == null) {
return;
}
const value = typeof initialValue === 'function' ? initialValue(field.internalToShell()) : initialValue;
const value = typeof initialValue === 'function' ? initialValue(field.internalToShellField()) : initialValue;
this.setState({
// eslint-disable-next-line react/no-unused-state
value,
@ -316,7 +316,7 @@ class SettingGroupView extends Component<SettingGroupViewProps> {
const { field } = this.props;
const { extraProps } = field;
const { condition, display } = extraProps;
const visible = field.isSingle && typeof condition === 'function' ? condition(field.internalToShell()) !== false : true;
const visible = field.isSingle && typeof condition === 'function' ? condition(field.internalToShellField()) !== false : true;
if (!visible) {
return null;

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-engine",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "An enterprise-class low-code technology stack with scale-out design / 一套面向扩展设计的企业级低代码技术体系",
"main": "lib/engine-core.js",
"module": "es/engine-core.js",
@ -19,15 +19,15 @@
"license": "MIT",
"dependencies": {
"@alifd/next": "^1.19.12",
"@alilc/lowcode-designer": "1.1.3",
"@alilc/lowcode-editor-core": "1.1.3",
"@alilc/lowcode-editor-skeleton": "1.1.3",
"@alilc/lowcode-designer": "1.1.4-beta.2",
"@alilc/lowcode-editor-core": "1.1.4-beta.2",
"@alilc/lowcode-editor-skeleton": "1.1.4-beta.2",
"@alilc/lowcode-engine-ext": "^1.0.0",
"@alilc/lowcode-plugin-designer": "1.1.3",
"@alilc/lowcode-plugin-outline-pane": "1.1.3",
"@alilc/lowcode-shell": "1.1.3",
"@alilc/lowcode-utils": "1.1.3",
"@alilc/lowcode-workspace": "1.1.3",
"@alilc/lowcode-plugin-designer": "1.1.4-beta.2",
"@alilc/lowcode-plugin-outline-pane": "1.1.4-beta.2",
"@alilc/lowcode-shell": "1.1.4-beta.2",
"@alilc/lowcode-utils": "1.1.4-beta.2",
"@alilc/lowcode-workspace": "1.1.4-beta.2",
"react": "^16.8.1",
"react-dom": "^16.8.1"
},

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-ignitor",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "点火器bootstrap lce project",
"main": "lib/index.js",
"private": true,

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-plugin-designer",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "alibaba lowcode editor designer plugin",
"files": [
"es",
@ -18,9 +18,9 @@
],
"author": "xiayang.xy",
"dependencies": {
"@alilc/lowcode-designer": "1.1.3",
"@alilc/lowcode-editor-core": "1.1.3",
"@alilc/lowcode-utils": "1.1.3",
"@alilc/lowcode-designer": "1.1.4-beta.2",
"@alilc/lowcode-editor-core": "1.1.4-beta.2",
"@alilc/lowcode-utils": "1.1.4-beta.2",
"react": "^16.8.1",
"react-dom": "^16.8.1"
},

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-plugin-outline-pane",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "Outline pane for Ali lowCode engine",
"files": [
"es",
@ -13,10 +13,10 @@
},
"dependencies": {
"@alifd/next": "^1.19.16",
"@alilc/lowcode-designer": "1.1.3",
"@alilc/lowcode-editor-core": "1.1.3",
"@alilc/lowcode-types": "1.1.3",
"@alilc/lowcode-utils": "1.1.3",
"@alilc/lowcode-designer": "1.1.4-beta.2",
"@alilc/lowcode-editor-core": "1.1.4-beta.2",
"@alilc/lowcode-types": "1.1.4-beta.2",
"@alilc/lowcode-utils": "1.1.4-beta.2",
"classnames": "^2.2.6",
"react": "^16",
"react-dom": "^16.7.0",

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-rax-renderer",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "Rax renderer for Ali lowCode engine",
"main": "lib/index.js",
"module": "es/index.js",
@ -30,8 +30,8 @@
"build": "build-scripts build"
},
"dependencies": {
"@alilc/lowcode-renderer-core": "1.1.3",
"@alilc/lowcode-utils": "1.1.3",
"@alilc/lowcode-renderer-core": "1.1.4-beta.2",
"@alilc/lowcode-utils": "1.1.4-beta.2",
"rax-find-dom-node": "^1.0.1"
},
"devDependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-rax-simulator-renderer",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "rax simulator renderer for alibaba lowcode designer",
"main": "lib/index.js",
"module": "es/index.js",
@ -13,10 +13,10 @@
"build:umd": "build-scripts build --config build.umd.json"
},
"dependencies": {
"@alilc/lowcode-designer": "1.1.3",
"@alilc/lowcode-rax-renderer": "1.1.3",
"@alilc/lowcode-types": "1.1.3",
"@alilc/lowcode-utils": "1.1.3",
"@alilc/lowcode-designer": "1.1.4-beta.2",
"@alilc/lowcode-rax-renderer": "1.1.4-beta.2",
"@alilc/lowcode-types": "1.1.4-beta.2",
"@alilc/lowcode-utils": "1.1.4-beta.2",
"classnames": "^2.2.6",
"driver-universal": "^3.1.3",
"history": "^5.0.0",

View File

@ -1,6 +1,6 @@
import { BuiltinSimulatorRenderer, Component, DocumentModel, Node } from '@alilc/lowcode-designer';
import { IPublicTypeComponentSchema, IPublicTypeNodeSchema, IPublicTypeNpmInfo, IPublicEnumTransformStage, IPublicTypeNodeInstance } from '@alilc/lowcode-types';
import { Asset, compatibleLegaoSchema, cursor, isElement, isESModule, isPlainObject, isReactComponent, setNativeSelection } from '@alilc/lowcode-utils';
import { BuiltinSimulatorRenderer, Component, IBaseNode, IDocumentModel } from '@alilc/lowcode-designer';
import { IPublicTypeComponentSchema, IPublicTypeNodeSchema, IPublicTypeNpmInfo, IPublicEnumTransformStage, IPublicTypeNodeInstance, IPublicTypeProjectSchema } from '@alilc/lowcode-types';
import { Asset, compatibleLegaoSchema, cursor, isElement, isESModule, isLowcodeProjectSchema, isComponentSchema, isPlainObject, isReactComponent, setNativeSelection } from '@alilc/lowcode-utils';
import LowCodeRenderer from '@alilc/lowcode-rax-renderer';
import { computed, observable as obx, makeObservable, configure } from 'mobx';
import DriverUniversal from 'driver-universal';
@ -47,15 +47,23 @@ const builtinComponents = {
function buildComponents(
libraryMap: LibraryMap,
componentsMap: { [componentName: string]: IPublicTypeNpmInfo | ComponentType<any> | IPublicTypeComponentSchema },
createComponent: (schema: IPublicTypeComponentSchema) => Component | null,
createComponent: (schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema>) => Component | null,
) {
const components: any = {
...builtinComponents,
};
Object.keys(componentsMap).forEach((componentName) => {
let component = componentsMap[componentName];
if (component && (component as IPublicTypeComponentSchema).componentName === 'Component') {
components[componentName] = createComponent(component as IPublicTypeComponentSchema);
if (component && (isLowcodeProjectSchema(component) || isComponentSchema(component))) {
if (isComponentSchema(component)) {
components[componentName] = createComponent({
version: '',
componentsMap: [],
componentsTree: [component],
});
} else {
components[componentName] = createComponent(component);
}
} else if (isReactComponent(component)) {
components[componentName] = component;
} else {
@ -110,7 +118,7 @@ export class DocumentInstance {
return this.document.export(IPublicEnumTransformStage.Render);
}
constructor(readonly container: SimulatorRendererContainer, readonly document: DocumentModel) {
constructor(readonly container: SimulatorRendererContainer, readonly document: IDocumentModel) {
makeObservable(this);
}
@ -221,7 +229,7 @@ export class DocumentInstance {
return this.instancesMap.get(id) || null;
}
getNode(id: string): Node<IPublicTypeNodeSchema> | null {
getNode(id: string): IBaseNode<IPublicTypeNodeSchema> | null {
return this.document.getNode(id);
}
}
@ -256,6 +264,8 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
// sync designMode
this._designMode = host.designMode;
this._locale = host.locale;
// sync requestHandlersMap
this._requestHandlersMap = host.requestHandlersMap;
@ -343,11 +353,11 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
// TODO: remove this.createComponent
this._components = buildComponents(this._libraryMap, this._componentsMap, this.createComponent.bind(this));
}
@obx.ref private _components: any = {};
@computed get components(): object {
@obx.ref private _components: Record<string, React.FC | React.ComponentClass> | null = {};
@computed get components(): Record<string, React.FC | React.ComponentClass> {
// 根据 device 选择不同组件,进行响应式
// 更好的做法是,根据 device 选择加载不同的组件资源,甚至是 simulatorUrl
return this._components;
return this._components || {};
}
// context from: utils、constants、history、location、match
@obx.ref private _appContext = {};
@ -362,6 +372,10 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
@computed get device() {
return this._device;
}
@obx.ref private _locale: string | undefined = undefined;
@computed get locale() {
return this._locale;
}
@obx.ref private _requestHandlersMap = null;
@computed get requestHandlersMap(): any {
return this._requestHandlersMap;
@ -378,12 +392,15 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
return loader.load(asset);
}
async loadAsyncLibrary(asyncLibraryMap: Record<string, any>) {
}
getComponent(componentName: string) {
const paths = componentName.split('.');
const subs: string[] = [];
while (true) {
const component = this._components[componentName];
const component = this._components?.[componentName];
if (component) {
return getSubComponent(component, subs);
}
@ -416,7 +433,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
// if (instance && SYMBOL_VNID in instance) {
// const docId = (instance.props as any).schema.docId;
return {
docId: instance.props._leaf.document.id,
docId: instance.props._leaf.document?.id || '',
nodeId: instance.props._leaf.getId(),
instance,
node: instance.props._leaf,
@ -497,17 +514,26 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
this.currentDocumentInstance?.refresh();
}
createComponent(schema: IPublicTypeNodeSchema): Component | null {
const _schema: any = {
...compatibleLegaoSchema(schema),
stopAutoRepaintNode() {
}
enableAutoRepaintNode() {
}
createComponent(schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema>): Component | null {
const _schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema> = {
...schema,
componentsTree: schema.componentsTree.map(compatibleLegaoSchema),
};
if (schema.componentName === 'Component' && (schema as IPublicTypeComponentSchema).css) {
const componentsTreeSchema = _schema.componentsTree[0];
if (componentsTreeSchema.componentName === 'Component' && componentsTreeSchema.css) {
const doc = window.document;
const s = doc.createElement('style');
s.setAttribute('type', 'text/css');
s.setAttribute('id', `Component-${schema.id || ''}`);
s.appendChild(doc.createTextNode((schema as IPublicTypeComponentSchema).css || ''));
s.setAttribute('id', `Component-${componentsTreeSchema.id || ''}`);
s.appendChild(doc.createTextNode(componentsTreeSchema.css || ''));
doc.getElementsByTagName('head')[0].appendChild(s);
}
@ -520,9 +546,11 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
// @ts-ignore
return createElement(LowCodeRenderer, {
...extraProps,
schema: _schema,
schema: componentsTreeSchema,
components,
designMode: '',
locale: renderer.locale,
messages: _schema.i18n || {},
device: renderer.device,
appHelper: renderer.context,
rendererName: 'LowCodeRenderer',

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-react-renderer",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "react renderer for ali lowcode engine",
"main": "lib/index.js",
"module": "es/index.js",
@ -22,7 +22,7 @@
],
"dependencies": {
"@alifd/next": "^1.21.16",
"@alilc/lowcode-renderer-core": "1.1.3"
"@alilc/lowcode-renderer-core": "1.1.4-beta.2"
},
"devDependencies": {
"@alib/build-scripts": "^0.1.18",

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-react-simulator-renderer",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "react simulator renderer for alibaba lowcode designer",
"main": "lib/index.js",
"module": "es/index.js",
@ -17,10 +17,10 @@
"test:cov": "build-scripts test --config build.test.json --jest-coverage"
},
"dependencies": {
"@alilc/lowcode-designer": "1.1.3",
"@alilc/lowcode-react-renderer": "1.1.3",
"@alilc/lowcode-types": "1.1.3",
"@alilc/lowcode-utils": "1.1.3",
"@alilc/lowcode-designer": "1.1.4-beta.2",
"@alilc/lowcode-react-renderer": "1.1.4-beta.2",
"@alilc/lowcode-types": "1.1.4-beta.2",
"@alilc/lowcode-utils": "1.1.4-beta.2",
"classnames": "^2.2.6",
"mobx": "^6.3.0",
"mobx-react": "^7.2.0",

View File

@ -4,7 +4,7 @@ import { host } from './host';
import SimulatorRendererView from './renderer-view';
import { computed, observable as obx, untracked, makeObservable, configure } from 'mobx';
import { getClientRects } from './utils/get-client-rects';
import { reactFindDOMNodes, FIBER_KEY } from './utils/react-find-dom-nodes';
import { reactFindDOMNodes, getReactInternalFiber } from './utils/react-find-dom-nodes';
import {
Asset,
isElement,
@ -17,9 +17,9 @@ import {
AssetLoader,
getProjectUtils,
} from '@alilc/lowcode-utils';
import { IPublicTypeComponentSchema, IPublicEnumTransformStage, IPublicTypeNodeSchema, IPublicTypeNodeInstance } from '@alilc/lowcode-types';
import { IPublicTypeComponentSchema, IPublicEnumTransformStage, IPublicTypeNodeInstance, IPublicTypeProjectSchema } from '@alilc/lowcode-types';
// just use types
import { BuiltinSimulatorRenderer, Component, DocumentModel, Node } from '@alilc/lowcode-designer';
import { BuiltinSimulatorRenderer, Component, IDocumentModel, INode } from '@alilc/lowcode-designer';
import LowCodeRenderer from '@alilc/lowcode-react-renderer';
import { createMemoryHistory, MemoryHistory } from 'history';
import Slot from './builtin-components/slot';
@ -94,7 +94,7 @@ export class DocumentInstance {
return this.document.id;
}
constructor(readonly container: SimulatorRendererContainer, readonly document: DocumentModel) {
constructor(readonly container: SimulatorRendererContainer, readonly document: IDocumentModel) {
makeObservable(this);
}
@ -173,7 +173,7 @@ export class DocumentInstance {
mountContext() {
}
getNode(id: string): Node | null {
getNode(id: string): INode | null {
return this.document.getNode(id);
}
@ -207,12 +207,12 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
private _libraryMap: { [key: string]: string } = {};
private _components: any = {};
private _components: Record<string, React.FC | React.ComponentClass> | null = {};
get components(): object {
get components(): Record<string, React.FC | React.ComponentClass> {
// 根据 device 选择不同组件,进行响应式
// 更好的做法是,根据 device 选择加载不同的组件资源,甚至是 simulatorUrl
return this._components;
return this._components || {};
}
// context from: utils、constants、history、location、match
@obx.ref private _appContext: any = {};
@ -388,7 +388,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
const subs: string[] = [];
while (true) {
const component = this._components[componentName];
const component = this._components?.[componentName];
if (component) {
return getSubComponent(component, subs);
}
@ -430,17 +430,20 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
cursor.release();
}
createComponent(schema: IPublicTypeNodeSchema): Component | null {
const _schema: any = {
...compatibleLegaoSchema(schema),
createComponent(schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema>): Component | null {
const _schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema> = {
...schema,
componentsTree: schema.componentsTree.map(compatibleLegaoSchema),
};
if (schema.componentName === 'Component' && (schema as IPublicTypeComponentSchema).css) {
const componentsTreeSchema = _schema.componentsTree[0];
if (componentsTreeSchema.componentName === 'Component' && componentsTreeSchema.css) {
const doc = window.document;
const s = doc.createElement('style');
s.setAttribute('type', 'text/css');
s.setAttribute('id', `Component-${schema.id || ''}`);
s.appendChild(doc.createTextNode((schema as IPublicTypeComponentSchema).css || ''));
s.setAttribute('id', `Component-${componentsTreeSchema.id || ''}`);
s.appendChild(doc.createTextNode(componentsTreeSchema.css || ''));
doc.getElementsByTagName('head')[0].appendChild(s);
}
@ -452,9 +455,11 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
return createElement(LowCodeRenderer, {
...extraProps, // 防止覆盖下面内置属性
// 使用 _schema 为了使低代码组件在页面设计中使用变量,同 react 组件使用效果一致
schema: _schema,
schema: componentsTreeSchema,
components: renderer.components,
designMode: '',
locale: renderer.locale,
messages: _schema.i18n || {},
device: renderer.device,
appHelper: renderer.context,
rendererName: 'LowCodeRenderer',
@ -565,7 +570,7 @@ function getClosestNodeInstance(
if (isElement(el)) {
el = cacheReactKey(el);
} else {
return getNodeInstance(el[FIBER_KEY], specId);
return getNodeInstance(getReactInternalFiber(el), specId);
}
}
while (el) {

View File

@ -3,7 +3,9 @@ import { findDOMNode } from 'react-dom';
import { isElement } from '@alilc/lowcode-utils';
import { isDOMNode } from './is-dom-node';
export const FIBER_KEY = '_reactInternalFiber';
export const getReactInternalFiber = (el: any) => {
return el._reactInternals || el._reactInternalFiber;
};
function elementsFromFiber(fiber: any, elements: Array<Element | Text>) {
if (fiber) {
@ -28,7 +30,7 @@ export function reactFindDOMNodes(elem: ReactInstance | null): Array<Element | T
return [elem];
}
const elements: Array<Element | Text> = [];
const fiberNode = (elem as any)[FIBER_KEY];
const fiberNode = getReactInternalFiber(elem);
elementsFromFiber(fiberNode?.child, elements);
if (elements.length > 0) return elements;
try {

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-renderer-core",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "renderer core",
"license": "MIT",
"main": "lib/index.js",
@ -16,8 +16,8 @@
},
"dependencies": {
"@alilc/lowcode-datasource-engine": "^1.0.0",
"@alilc/lowcode-types": "1.1.3",
"@alilc/lowcode-utils": "1.1.3",
"@alilc/lowcode-types": "1.1.4-beta.2",
"@alilc/lowcode-utils": "1.1.4-beta.2",
"classnames": "^2.2.6",
"debug": "^4.1.1",
"fetch-jsonp": "^1.1.3",
@ -32,7 +32,7 @@
"devDependencies": {
"@alib/build-scripts": "^0.1.18",
"@alifd/next": "^1.26.0",
"@alilc/lowcode-designer": "1.1.3",
"@alilc/lowcode-designer": "1.1.4-beta.2",
"@babel/plugin-transform-typescript": "^7.16.8",
"@testing-library/react": "^11.2.2",
"@types/classnames": "^2.2.11",

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-shell",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "Shell Layer for AliLowCodeEngine",
"main": "lib/index.js",
"module": "es/index.js",
@ -15,12 +15,12 @@
},
"license": "MIT",
"dependencies": {
"@alilc/lowcode-designer": "1.1.3",
"@alilc/lowcode-editor-core": "1.1.3",
"@alilc/lowcode-editor-skeleton": "1.1.3",
"@alilc/lowcode-types": "1.1.3",
"@alilc/lowcode-utils": "1.1.3",
"@alilc/lowcode-workspace": "1.1.3",
"@alilc/lowcode-designer": "1.1.4-beta.2",
"@alilc/lowcode-editor-core": "1.1.4-beta.2",
"@alilc/lowcode-editor-skeleton": "1.1.4-beta.2",
"@alilc/lowcode-types": "1.1.4-beta.2",
"@alilc/lowcode-utils": "1.1.4-beta.2",
"@alilc/lowcode-workspace": "1.1.4-beta.2",
"classnames": "^2.2.6",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",

View File

@ -143,7 +143,7 @@ export class SettingField implements IPublicModelSettingField {
if (isCustomView(item)) {
return item;
}
return item.internalToShell();
return item.internalToShellField();
});
}

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-types",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "Types for Ali lowCode engine",
"files": [
"es",

View File

@ -1,5 +1,5 @@
import { EitherOr } from '../../utils';
import { IPublicTypeComponentSchema } from './';
import { IPublicTypeComponentSchema, IPublicTypeProjectSchema } from './';
/**
* external
@ -51,5 +51,5 @@ export type IPublicTypePackage = EitherOr<{
/**
* schema
*/
schema?: IPublicTypeComponentSchema;
schema?: IPublicTypeProjectSchema<IPublicTypeComponentSchema>;
}, 'package', 'id'>;

View File

@ -19,7 +19,7 @@ export type IPublicTypeUtilsMap = IPublicTypeUtilItem[];
*
*/
export interface IPublicTypeProjectSchema {
export interface IPublicTypeProjectSchema<T = IPublicTypeRootSchema> {
id?: string;
/**
*
@ -34,7 +34,7 @@ export interface IPublicTypeProjectSchema {
*
* 1
*/
componentsTree: IPublicTypeRootSchema[];
componentsTree: T[];
/**
*
*/

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-utils",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "Utils for Ali lowCode engine",
"files": [
"lib",
@ -14,7 +14,7 @@
},
"dependencies": {
"@alifd/next": "^1.19.16",
"@alilc/lowcode-types": "1.1.3",
"@alilc/lowcode-types": "1.1.4-beta.2",
"lodash": "^4.17.21",
"mobx": "^6.3.0",
"react": "^16"

View File

@ -1,8 +1,10 @@
import { ComponentType, forwardRef, createElement, FunctionComponent } from 'react';
import { IPublicTypeNpmInfo, IPublicTypeComponentSchema } from '@alilc/lowcode-types';
import { IPublicTypeNpmInfo, IPublicTypeComponentSchema, IPublicTypeProjectSchema } from '@alilc/lowcode-types';
import { isESModule } from './is-es-module';
import { isReactComponent, acceptsRef, wrapReactClass } from './is-react';
import { isObject } from './is-object';
import { isLowcodeProjectSchema } from './check-types';
import { isComponentSchema } from './check-types/is-component-schema';
type Component = ComponentType<any> | object;
interface LibraryMap {
@ -95,12 +97,20 @@ function isMixinComponent(components: any) {
export function buildComponents(libraryMap: LibraryMap,
componentsMap: { [componentName: string]: IPublicTypeNpmInfo | ComponentType<any> | IPublicTypeComponentSchema },
createComponent: (schema: IPublicTypeComponentSchema) => Component | null) {
createComponent: (schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema>) => Component | null) {
const components: any = {};
Object.keys(componentsMap).forEach((componentName) => {
let component = componentsMap[componentName];
if (component && (component as IPublicTypeComponentSchema).componentName === 'Component') {
components[componentName] = createComponent(component as IPublicTypeComponentSchema);
if (component && (isLowcodeProjectSchema(component) || isComponentSchema(component))) {
if (isComponentSchema(component)) {
components[componentName] = createComponent({
version: '',
componentsMap: [],
componentsTree: [component],
});
} else {
components[componentName] = createComponent(component);
}
} else if (isReactComponent(component)) {
if (!acceptsRef(component)) {
component = wrapReactClass(component as FunctionComponent);

View File

@ -20,4 +20,7 @@ export * from './is-drag-any-object';
export * from './is-location-children-detail';
export * from './is-node';
export * from './is-location-data';
export * from './is-setting-field';
export * from './is-setting-field';
export * from './is-lowcode-component-type';
export * from './is-lowcode-project-schema';
export * from './is-component-schema';

View File

@ -0,0 +1,8 @@
import { IPublicTypeComponentSchema } from "@alilc/lowcode-types";
export function isComponentSchema(schema: any): schema is IPublicTypeComponentSchema {
if (typeof schema === 'object') {
return schema.componentName === 'Component';
}
return false
}

View File

@ -1,7 +1,7 @@
import { isProCodeComponentType } from './is-procode-component-type';
import { IPublicTypeComponentMap } from '@alilc/lowcode-types';
import { IPublicTypeComponentMap, IPublicTypeLowCodeComponent } from '@alilc/lowcode-types';
export function isLowCodeComponentType(desc: IPublicTypeComponentMap): boolean {
export function isLowCodeComponentType(desc: IPublicTypeComponentMap): desc is IPublicTypeLowCodeComponent {
return !isProCodeComponentType(desc);
}

View File

@ -0,0 +1,6 @@
import { IPublicTypeComponentSchema, IPublicTypeProjectSchema } from "@alilc/lowcode-types";
import { isComponentSchema } from "./is-component-schema";
export function isLowcodeProjectSchema(data: any): data is IPublicTypeProjectSchema<IPublicTypeComponentSchema> {
return data && data.componentsTree && data.componentsTree.length && isComponentSchema(data.componentsTree[0]);
}

View File

@ -1,3 +1,5 @@
export function isProjectSchema(data: any): boolean {
import { IPublicTypeProjectSchema } from "@alilc/lowcode-types";
export function isProjectSchema(data: any): data is IPublicTypeProjectSchema {
return data && data.componentsTree;
}

View File

@ -1,6 +1,6 @@
{
"name": "@alilc/lowcode-workspace",
"version": "1.1.3",
"version": "1.1.4-beta.2",
"description": "Shell Layer for AliLowCodeEngine",
"main": "lib/index.js",
"module": "es/index.js",
@ -15,11 +15,11 @@
},
"license": "MIT",
"dependencies": {
"@alilc/lowcode-designer": "1.1.3",
"@alilc/lowcode-editor-core": "1.1.3",
"@alilc/lowcode-editor-skeleton": "1.1.3",
"@alilc/lowcode-types": "1.1.3",
"@alilc/lowcode-utils": "1.1.3",
"@alilc/lowcode-designer": "1.1.4-beta.2",
"@alilc/lowcode-editor-core": "1.1.4-beta.2",
"@alilc/lowcode-editor-skeleton": "1.1.4-beta.2",
"@alilc/lowcode-types": "1.1.4-beta.2",
"@alilc/lowcode-utils": "1.1.4-beta.2",
"classnames": "^2.2.6",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",