Skip to content

Commit

Permalink
chore: setup playground
Browse files Browse the repository at this point in the history
  • Loading branch information
1ncounter committed Apr 11, 2024
1 parent 764e841 commit 8beefd3
Show file tree
Hide file tree
Showing 24 changed files with 199 additions and 38 deletions.
6 changes: 4 additions & 2 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import reactHooks from 'eslint-plugin-react-hooks';
import globals from 'globals';

export default tseslint.config({
files: ['packages/*/{src,__tests__}/**/*.{ts?(x),js?(x)}'],
files: ['packages/*/{src,__tests__}/**/*.{ts?(x),js?(x)}', 'scripts/*.js'],
ignores: ['**/*.test.ts'],
extends: [js.configs.recommended, ...tseslint.configs.recommended],
plugins: {
Expand All @@ -32,13 +32,15 @@ export default tseslint.config({
'@stylistic/max-len': ['error', { code: 100, tabWidth: 2, ignoreStrings: true, ignoreComments: true }],
'@stylistic/no-tabs': 'error',
'@stylistic/quotes': ['error', 'single'],
'@stylistic/quote-props': ['error', 'as-needed'],
'@stylistic/jsx-pascal-case': [2],
'@stylistic/jsx-indent': [2, 2, { checkAttributes: true, indentLogicalExpressions: true }],
'@stylistic/semi': ['error', 'always'],
'@stylistic/eol-last': ['error', 'always'],
'@stylistic/jsx-quotes': ['error', 'prefer-double'],

"@typescript-eslint/ban-ts-comment": ["error", { 'ts-expect-error': 'allow-with-description' }],
'@typescript-eslint/ban-ts-comment': ["error", { 'ts-expect-error': 'allow-with-description' }],
'@typescript-eslint/no-explicit-any': 'warn',

'react/jsx-no-undef': 'error',
'react/jsx-uses-vars': 'error',
Expand Down
9 changes: 6 additions & 3 deletions packages/designer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"require": "./dist/low-code-designer.cjs",
"types": "./dist/index.d.ts"
},
"./dist/": {
"import": "./dist/",
"require": "./dist/"
"./dist/style.css": {
"import": "./dist/style.css",
"require": "./dist/style.css"
}
},
"files": [
Expand Down Expand Up @@ -54,6 +54,9 @@
},
"peerDependencies": {
"@alifd/next": "^1.27.8",
"@alilc/lowcode-editor-core": "workspace:*",
"@alilc/lowcode-types": "workspace:*",
"@alilc/lowcode-utils": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/designer/src/document/document-view.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component } from 'react';
import classNames from 'classnames';
import { observer } from '@alilc/lowcode-editor-core';
import { DocumentModel, IDocumentModel } from './document-model';
import { IDocumentModel } from './document-model';
import { BuiltinSimulatorHostView } from '../builtin-simulator';

@observer
Expand Down
1 change: 0 additions & 1 deletion packages/designer/src/plugin/plugin-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export class LowCodePluginManager implements ILowCodePluginManager {
);
const config = newPluginModel(ctx, newOptions);
// compat the legacy way to declare pluginName
// @ts-ignore
pluginName = pluginName || config.name;
invariant(pluginName, 'pluginConfigCreator.pluginName required', config);

Expand Down
4 changes: 3 additions & 1 deletion packages/designer/src/plugin/plugin-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ export interface ILowCodePluginManagerCore {
pluginOptions?: any,
options?: IPublicTypePluginRegisterOptions,
): Promise<void>;
init(pluginPreference?: Map<string, Record<string, IPublicTypePreferenceValueType>>): Promise<void>;
init(
pluginPreference?: Map<string, Record<string, IPublicTypePreferenceValueType>>
): Promise<void>;
get(pluginName: string): ILowCodePluginRuntime | undefined;
getAll(): ILowCodePluginRuntime[];
has(pluginName: string): boolean;
Expand Down
4 changes: 3 additions & 1 deletion packages/designer/src/project/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@ export class Project implements IProject {
return doc.open();
}
if (typeof doc === 'string' || typeof doc === 'number') {
const got = this.documents.find((item) => item.fileName === String(doc) || String(item.id) === String(doc));
const got = this.documents.find(
(item) => item.fileName === String(doc) || String(item.id) === String(doc)
);
if (got) {
return got.open();
}
Expand Down
12 changes: 9 additions & 3 deletions packages/designer/src/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,19 @@ export interface ISimulatorHost<P = object> extends IPublicModelSensor<INode> {
*/
getComponentContext(node: INode): object | null;

getClosestNodeInstance(from: IPublicTypeComponentInstance, specId?: string): IPublicTypeNodeInstance | null;
getClosestNodeInstance(
from: IPublicTypeComponentInstance, specId?: string
): IPublicTypeNodeInstance | null;

computeRect(node: INode): DOMRect | null;

computeComponentInstanceRect(instance: IPublicTypeComponentInstance, selector?: string): DOMRect | null;
computeComponentInstanceRect(
instance: IPublicTypeComponentInstance, selector?: string
): DOMRect | null;

findDOMNodes(instance: IPublicTypeComponentInstance, selector?: string): Array<Element | Text> | null;
findDOMNodes(
instance: IPublicTypeComponentInstance, selector?: string
): Array<Element | Text> | null;

getDropContainer(e: ILocateEvent): DropContainer | null;

Expand Down
2 changes: 2 additions & 0 deletions packages/editor-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
},
"peerDependencies": {
"@alifd/next": "^1.27.8",
"@alilc/lowcode-types": "workspace:*",
"@alilc/lowcode-utils": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
4 changes: 4 additions & 0 deletions packages/editor-skeleton/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
},
"peerDependencies": {
"@alifd/next": "^1.27.8",
"@alilc/lowcode-designer": "workspace:*",
"@alilc/lowcode-editor-core": "workspace:*",
"@alilc/lowcode-types": "workspace:*",
"@alilc/lowcode-utils": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
7 changes: 4 additions & 3 deletions packages/editor-skeleton/src/layouts/top-area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { observer } from '@alilc/lowcode-editor-core';
import { Area } from '../area';

@observer
export default class TopArea extends Component<{ area: Area; itemClassName?: string; className?: string }> {
export default class TopArea extends Component<
{ area: Area; itemClassName?: string; className?: string }
> {
render() {
const { area, itemClassName, className } = this.props;
if (area.isEmpty()) {
Expand All @@ -13,8 +15,7 @@ export default class TopArea extends Component<{ area: Area; itemClassName?: str
return (
<div className={classNames(className, 'lc-top-area engine-actionpane', {
'lc-area-visible': area.visible,
})}
>
})}>
<Contents area={area} itemClassName={itemClassName} />
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion packages/editor-skeleton/src/layouts/workbench.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import Toolbar from './toolbar';
import MainArea from './main-area';
import BottomArea from './bottom-area';
import RightArea from './right-area';
import './workbench.less';
import { SkeletonContext } from '../context';
import { EditorConfig, PluginClassSet } from '@alilc/lowcode-types';

import './workbench.less';

@observer
export class Workbench extends Component<{
skeleton: ISkeleton;
Expand Down
9 changes: 6 additions & 3 deletions packages/engine/src/engine-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ import { CommandPlugin } from '@alilc/lowcode-plugin-command';
import { OutlinePlugin } from '@alilc/lowcode-plugin-outline-pane';
import { version } from '../package.json';

import '@alilc/lowcode-plugin-outline-pane/dist/style.css';
import '@alilc/lowcode-editor-skeleton/dist/style.css';
import '@alilc/lowcode-designer/dist/style.css';

export * from './modules/skeleton-types';
export * from './modules/designer-types';
Expand Down Expand Up @@ -115,10 +117,10 @@ globalContext.register(innerWorkspace, 'workspace');
const engineContext: Partial<ILowCodePluginContextPrivate> = {};

const innerSkeleton = new InnerSkeleton(editor);
editor.set('skeleton' as any, innerSkeleton);
editor.set('skeleton', innerSkeleton);

const designer = new Designer({ editor, shellModelFactory });
editor.set('designer' as any, designer);
editor.set('designer', designer);

const { project: innerProject } = designer;

Expand All @@ -137,7 +139,7 @@ const material = new Material(editor);
const commonUI = new CommonUI(editor);

editor.set('project', project);
editor.set('setters' as any, setters);
editor.set('setters', setters);
editor.set('material', material);
editor.set('innerHotkey', innerHotkey);

Expand Down Expand Up @@ -290,6 +292,7 @@ export async function init(
return;
}

await pluginPromise;
await plugins.init(pluginPreference as any);

if (!root) {
Expand Down
2 changes: 2 additions & 0 deletions packages/engine/src/inner-plugins/default-panel-registry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { IPublicModelPluginContext } from '@alilc/lowcode-types';
import { SettingsPrimaryPane } from '@alilc/lowcode-editor-skeleton';
import DesignerPlugin from '@alilc/lowcode-plugin-designer';

import '@alilc/lowcode-plugin-designer/dist/style.css';

// 注册默认的面板
export const defaultPanelRegistry = (editor: any) => {
const fun = (ctx: IPublicModelPluginContext) => {
Expand Down
14 changes: 7 additions & 7 deletions packages/engine/src/shell/api/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,9 @@ class EditorCabin implements IPublicApiCommonEditorCabin {
}

export class Common implements IPublicApiCommon {
private readonly __designerCabin: any;
private readonly __skeletonCabin: any;
private readonly __editorCabin: any;
private readonly __designerCabin: DesignerCabin;
private readonly __skeletonCabin: SkeletonCabin;
private readonly __editorCabin: EditorCabin;
private readonly __utils: Utils;

constructor(editor: Editor, skeleton: InnerSkeleton) {
Expand All @@ -438,7 +438,7 @@ export class Common implements IPublicApiCommon {
* this load of crap will be removed in some future versions, don`t use it.
* @deprecated
*/
get editorCabin(): any {
get editorCabin(): EditorCabin {
return this.__editorCabin;
}

Expand All @@ -447,11 +447,11 @@ export class Common implements IPublicApiCommon {
* this load of crap will be removed in some future versions, don`t use it.
* @deprecated use canvas api instead
*/
get designerCabin(): any {
get designerCabin(): DesignerCabin {
return this.__designerCabin;
}

get skeletonCabin(): any {
get skeletonCabin(): SkeletonCabin {
return this.__skeletonCabin;
}

Expand All @@ -460,7 +460,7 @@ export class Common implements IPublicApiCommon {
* this load of crap will be removed in some future versions, don`t use it.
* @deprecated use { TransformStage } from '@alilc/lowcode-types' instead
*/
get objects(): any {
get objects() {
return {
TransformStage: InnerTransitionStage,
};
Expand Down
5 changes: 3 additions & 2 deletions packages/engine/src/workspace/layouts/workbench.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@ export class Workbench extends Component<{
}

{
!workspace.windows.length && WorkspaceEmptyComponent ? <WorkspaceEmptyComponent /> : null
workspace.windows.length === 0 && WorkspaceEmptyComponent
? <WorkspaceEmptyComponent />
: null
}
</div>
</div>
<MainArea area={skeleton.mainArea} />
<BottomArea area={skeleton.bottomArea} />
</div>
{/* <RightArea area={skeleton.rightArea} /> */}
</div>
<TipContainer />
</SkeletonContext.Provider>
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-command/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"homepage": "https://github.com/alibaba/lowcode-engine#readme",
"license": "ISC",
"type": "module",
"private": true,
"main": "dist/low-code-plugin-command.cjs",
"module": "dist/low-code-plugin-command.js",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -39,6 +40,7 @@
"react-dom": "^18.2.0"
},
"peerDependencies": {
"@alilc/lowcode-utils": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
10 changes: 9 additions & 1 deletion packages/plugin-designer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@alilc/lowcode-plugin-designer",
"version": "2.0.0-beta.0",
"description": "alibaba lowcode editor designer plugin",
"private": true,
"type": "module",
"main": "dist/low-code-plugin-designer.cjs",
"module": "dist/low-code-plugin-designer.js",
Expand All @@ -11,6 +12,10 @@
"import": "./dist/low-code-plugin-designer.js",
"require": "./dist/low-code-plugin-designer.cjs",
"types": "./dist/index.d.ts"
},
"./dist/": {
"import": "./dist/",
"require": "./dist/"
}
},
"files": [
Expand Down Expand Up @@ -41,7 +46,10 @@
},
"peerDependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
"react-dom": "^18.2.0",
"@alilc/lowcode-designer": "workspace:*",
"@alilc/lowcode-editor-core": "workspace:*",
"@alilc/lowcode-utils": "workspace:*"
},
"publishConfig": {
"access": "public",
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-outline-pane/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@alilc/lowcode-plugin-outline-pane",
"version": "1.3.2",
"description": "Outline pane for Ali lowCode engine",
"private": true,
"type": "module",
"main": "dist/low-code-plugin-outline-pane.cjs",
"module": "dist/low-code-plugin-outline-pane.js",
Expand All @@ -11,6 +12,10 @@
"import": "./dist/low-code-plugin-outline-pane.js",
"require": "./dist/low-code-plugin-outline-pane.cjs",
"types": "./dist/index.d.ts"
},
"./dist/": {
"import": "./dist/",
"require": "./dist/"
}
},
"files": [
Expand Down Expand Up @@ -39,6 +44,8 @@
},
"peerDependencies": {
"@alifd/next": "^1.27.8",
"@alilc/lowcode-types": "workspace:*",
"@alilc/lowcode-utils": "workspace:*",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
Expand Down
11 changes: 10 additions & 1 deletion playground/engine/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { init, plugins } from '@alilc/lowcode-engine';
import * as engine from '@alilc/lowcode-engine';
import EditorInitPlugin from './plugins/plugin-editor-init';
import LogoSamplePlugin from './plugins/plugin-logo-sample';

import '@alilc/lowcode-engine/dist/style.css';
import './index.css';

(window as any).AliLowCodeEngine = engine;

async function run() {
const { plugins, init, project, skeleton, config } = engine;

await plugins.register(EditorInitPlugin, {
scenarioName: 'general',
displayName: '综合场景',
Expand All @@ -25,6 +30,7 @@ async function run() {
],
},
});
await plugins.register(LogoSamplePlugin);

await init(document.getElementById('app')!, {
locale: 'zh-CN',
Expand All @@ -38,7 +44,10 @@ async function run() {
'https://alifd.alicdn.com/npm/@alilc/[email protected]/dist/js/react-simulator-renderer.js'
],
enableContextMenu: true,
enableWorkspaceMode: false
});

console.log(project, skeleton, plugins, config)
}

run()
Loading

0 comments on commit 8beefd3

Please sign in to comment.