refactor: remove useless files

This commit is contained in:
1ncounter 2024-07-03 11:16:40 +08:00
parent 450d08e500
commit 738f7af6de
392 changed files with 91 additions and 20603 deletions

6
.gitignore vendored
View File

@ -1,12 +1,6 @@
# project custom # project custom
build build
dist dist
packages/*/lib/
packages/*/es/
packages/*/dist/
packages/*/output/
packages/*/temp/
packages/demo/
package-lock.json package-lock.json
yarn.lock yarn.lock
pnpm-lock.yaml pnpm-lock.yaml

View File

@ -1,2 +0,0 @@
export * from './preference';
export * from './hotkey';

View File

@ -1,326 +0,0 @@
import { Command } from '../src/command';
describe('Command', () => {
let commandInstance;
let mockHandler;
beforeEach(() => {
commandInstance = new Command();
mockHandler = jest.fn();
});
describe('registerCommand', () => {
it('should register a command successfully', () => {
const command = {
name: 'testCommand',
handler: mockHandler,
};
commandInstance.registerCommand(command, { commandScope: 'testScope' });
const registeredCommand = commandInstance.listCommands().find(c => c.name === 'testScope:testCommand');
expect(registeredCommand).toBeDefined();
expect(registeredCommand.name).toBe('testScope:testCommand');
});
it('should throw an error if commandScope is not provided', () => {
const command = {
name: 'testCommand',
handler: mockHandler,
};
expect(() => {
commandInstance.registerCommand(command);
}).toThrow('plugin meta.commandScope is required.');
});
it('should throw an error if command is already registered', () => {
const command = {
name: 'testCommand',
handler: mockHandler,
};
commandInstance.registerCommand(command, { commandScope: 'testScope' });
expect(() => {
commandInstance.registerCommand(command, { commandScope: 'testScope' });
}).toThrow(`Command 'testCommand' is already registered.`);
});
});
afterEach(() => {
jest.clearAllMocks();
});
});
describe('unregisterCommand', () => {
let commandInstance;
let mockHandler;
beforeEach(() => {
commandInstance = new Command();
mockHandler = jest.fn();
// 先注册一个命令以便之后注销
const command = {
name: 'testCommand',
handler: mockHandler,
};
commandInstance.registerCommand(command, { commandScope: 'testScope' });
});
it('should unregister a command successfully', () => {
const commandName = 'testScope:testCommand';
expect(commandInstance.listCommands().find(c => c.name === commandName)).toBeDefined();
commandInstance.unregisterCommand(commandName);
expect(commandInstance.listCommands().find(c => c.name === commandName)).toBeUndefined();
});
it('should throw an error if the command is not registered', () => {
const nonExistingCommandName = 'testScope:nonExistingCommand';
expect(() => {
commandInstance.unregisterCommand(nonExistingCommandName);
}).toThrow(`Command '${nonExistingCommandName}' is not registered.`);
});
afterEach(() => {
jest.clearAllMocks();
});
});
describe('executeCommand', () => {
let commandInstance;
let mockHandler;
beforeEach(() => {
commandInstance = new Command();
mockHandler = jest.fn();
// 注册一个带参数校验的命令
const command = {
name: 'testCommand',
handler: mockHandler,
parameters: [
{ name: 'param1', propType: 'string' },
{ name: 'param2', propType: 'number' }
],
};
commandInstance.registerCommand(command, { commandScope: 'testScope' });
});
it('should execute a command successfully', () => {
const commandName = 'testScope:testCommand';
const args = { param1: 'test', param2: 42 };
commandInstance.executeCommand(commandName, args);
expect(mockHandler).toHaveBeenCalledWith(args);
});
it('should throw an error if the command is not registered', () => {
const nonExistingCommandName = 'testScope:nonExistingCommand';
expect(() => {
commandInstance.executeCommand(nonExistingCommandName, {});
}).toThrow(`Command '${nonExistingCommandName}' is not registered.`);
});
it('should throw an error if arguments are invalid', () => {
const commandName = 'testScope:testCommand';
const invalidArgs = { param1: 'test', param2: 'not-a-number' }; // param2 should be a number
expect(() => {
commandInstance.executeCommand(commandName, invalidArgs);
}).toThrow(`Command '${commandName}' arguments param2 is invalid.`);
});
it('should handle errors thrown by the command handler', () => {
const commandName = 'testScope:testCommand';
const args = { param1: 'test', param2: 42 };
const errorMessage = 'Command handler error';
mockHandler.mockImplementation(() => {
throw new Error(errorMessage);
});
expect(() => {
commandInstance.executeCommand(commandName, args);
}).toThrow(errorMessage);
});
afterEach(() => {
jest.clearAllMocks();
});
});
describe('batchExecuteCommand', () => {
let commandInstance;
let mockHandler;
let mockExecuteTransaction;
let mockPluginContext;
beforeEach(() => {
commandInstance = new Command();
mockHandler = jest.fn();
mockExecuteTransaction = jest.fn(callback => callback());
mockPluginContext = {
common: {
utils: {
executeTransaction: mockExecuteTransaction
}
}
};
// 注册几个命令
const command1 = {
name: 'testCommand1',
handler: mockHandler,
};
const command2 = {
name: 'testCommand2',
handler: mockHandler,
};
commandInstance.registerCommand(command1, { commandScope: 'testScope' });
commandInstance.registerCommand(command2, { commandScope: 'testScope' });
});
it('should execute a batch of commands', () => {
const commands = [
{ name: 'testScope:testCommand1', args: { param: 'value1' } },
{ name: 'testScope:testCommand2', args: { param: 'value2' } },
];
commandInstance.batchExecuteCommand(commands, mockPluginContext);
expect(mockExecuteTransaction).toHaveBeenCalledTimes(1);
expect(mockHandler).toHaveBeenCalledWith({ param: 'value1' });
expect(mockHandler).toHaveBeenCalledWith({ param: 'value2' });
});
it('should not execute anything if commands array is empty', () => {
commandInstance.batchExecuteCommand([], mockPluginContext);
expect(mockExecuteTransaction).not.toHaveBeenCalled();
expect(mockHandler).not.toHaveBeenCalled();
});
it('should handle errors thrown during command execution', () => {
const errorMessage = 'Command handler error';
mockHandler.mockImplementation(() => {
throw new Error(errorMessage);
});
const commands = [
{ name: 'testScope:testCommand1', args: { param: 'value1' } },
{ name: 'testScope:testCommand2', args: { param: 'value2' } },
];
expect(() => {
commandInstance.batchExecuteCommand(commands, mockPluginContext);
}).toThrow(errorMessage);
expect(mockExecuteTransaction).toHaveBeenCalledTimes(1); // Still called once
});
afterEach(() => {
jest.clearAllMocks();
});
});
describe('listCommands', () => {
let commandInstance;
let mockHandler;
beforeEach(() => {
commandInstance = new Command();
mockHandler = jest.fn();
});
it('should list all registered commands', () => {
// 注册几个命令
const command1 = {
name: 'testCommand1',
handler: mockHandler,
description: 'Test Command 1',
parameters: [{ name: 'param1', propType: 'string' }]
};
const command2 = {
name: 'testCommand2',
handler: mockHandler,
description: 'Test Command 2',
parameters: [{ name: 'param2', propType: 'number' }]
};
commandInstance.registerCommand(command1, { commandScope: 'testScope' });
commandInstance.registerCommand(command2, { commandScope: 'testScope' });
const listedCommands = commandInstance.listCommands();
expect(listedCommands.length).toBe(2);
expect(listedCommands).toEqual(expect.arrayContaining([
expect.objectContaining({
name: 'testScope:testCommand1',
description: 'Test Command 1',
parameters: [{ name: 'param1', propType: 'string' }]
}),
expect.objectContaining({
name: 'testScope:testCommand2',
description: 'Test Command 2',
parameters: [{ name: 'param2', propType: 'number' }]
})
]));
});
it('should return an empty array if no commands are registered', () => {
const listedCommands = commandInstance.listCommands();
expect(listedCommands).toEqual([]);
});
afterEach(() => {
jest.clearAllMocks();
});
});
describe('onCommandError', () => {
let commandInstance;
let mockHandler;
let mockErrorHandler1;
let mockErrorHandler2;
beforeEach(() => {
commandInstance = new Command();
mockHandler = jest.fn();
mockErrorHandler1 = jest.fn();
mockErrorHandler2 = jest.fn();
// 注册一个命令,该命令会抛出错误
const command = {
name: 'testCommand',
handler: () => {
throw new Error('Command execution failed');
},
};
commandInstance.registerCommand(command, { commandScope: 'testScope' });
});
it('should call all registered error handlers when a command throws an error', () => {
const commandName = 'testScope:testCommand';
commandInstance.onCommandError(mockErrorHandler1);
commandInstance.onCommandError(mockErrorHandler2);
expect(() => {
commandInstance.executeCommand(commandName, {});
}).not.toThrow();
// 确保所有错误处理函数都被调用,并且传递了正确的参数
expect(mockErrorHandler1).toHaveBeenCalledWith(commandName, expect.any(Error));
expect(mockErrorHandler2).toHaveBeenCalledWith(commandName, expect.any(Error));
});
it('should throw the error if no error handlers are registered', () => {
const commandName = 'testScope:testCommand';
expect(() => {
commandInstance.executeCommand(commandName, {});
}).toThrow('Command execution failed');
});
afterEach(() => {
jest.clearAllMocks();
});
});

View File

@ -1,10 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"declaration": true,
"outDir": "temp",
"stripInternal": true,
"paths": {}
}
}

View File

@ -1,7 +0,0 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": ["src", "__tests__", "src/configuration.ts"]
}

View File

@ -1,8 +0,0 @@
import { defineConfig } from 'vite';
import baseConfigFn from '../../vite.base.config'
export default defineConfig(async () => {
return baseConfigFn({
name: 'LowCodeEditorCore',
})
});

View File

@ -1,15 +1,14 @@
{ {
"name": "@alilc/lowcode-core", "name": "@ali/lowcode-engine-core",
"version": "2.0.0-beta.0", "description": "",
"description": "Core Api for Ali lowCode engine",
"license": "MIT",
"type": "module", "type": "module",
"main": "dist/low-code-editor-core.js", "main": "dist/engine-core.js",
"module": "dist/low-code-editor-core.js", "module": "dist/engine-core.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"exports": { "exports": {
".": { ".": {
"import": "./dist/low-code-editor-core.js", "import": "./dist/engine-core.js",
"require": "./dist/engine-core.cjs",
"types": "./dist/index.d.ts" "types": "./dist/index.d.ts"
}, },
"./dist/": { "./dist/": {
@ -17,10 +16,6 @@
"require": "./dist/" "require": "./dist/"
} }
}, },
"sideEffects": [
"*.css",
"*.less"
],
"files": [ "files": [
"dist", "dist",
"src", "src",
@ -29,22 +24,18 @@
"scripts": { "scripts": {
"build:target": "vite build", "build:target": "vite build",
"build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs", "build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs",
"test": "vitest", "test": "vitest"
"test:cov": ""
}, },
"license": "MIT",
"dependencies": { "dependencies": {
"@alilc/lowcode-shared": "workspace:*", "@alilc/lowcode-shared": "workspace:*",
"lodash-es": "^4.17.21" "lodash-es": "^4.17.21"
}, },
"devDependencies": { "devDependencies": {
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12"
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0"
}, },
"peerDependencies": { "peerDependencies": {
"@alilc/lowcode-shared": "workspace:*", "@alilc/lowcode-shared": "workspace:*"
"react": "^18.2.0",
"react-dom": "^18.2.0"
}, },
"publishConfig": { "publishConfig": {
"access": "public", "access": "public",
@ -52,7 +43,7 @@
}, },
"repository": { "repository": {
"type": "http", "type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/editor-core" "url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/engine-core"
}, },
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6", "gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6",
"bugs": "https://github.com/alibaba/lowcode-engine/issues", "bugs": "https://github.com/alibaba/lowcode-engine/issues",

View File

View File

@ -0,0 +1,9 @@
import { defineConfig } from 'vite';
import baseConfigFn from '../../vite.base.config';
export default defineConfig(async () => {
return baseConfigFn({
name: 'EngineCore',
defaultFormats: ['es', 'cjs'],
});
});

View File

@ -29,28 +29,17 @@
}, },
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@alifd/next": "^1.27.8", "@alilc/lowcode-shared": "workspace:*",
"@alilc/lowcode-designer": "workspace:*", "lodash-es": "^4.17.21",
"@alilc/lowcode-core": "workspace:*",
"@alilc/lowcode-workbench": "workspace:*",
"@alilc/lowcode-plugin-command": "workspace:*",
"@alilc/lowcode-plugin-designer": "workspace:*",
"@alilc/lowcode-plugin-outline-pane": "workspace:*",
"@alilc/lowcode-utils": "workspace:*",
"@alilc/lowcode-types": "workspace:*",
"classnames": "^2.5.1",
"prop-types": "^15.7.2",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0" "react-dom": "^18.2.0"
}, },
"devDependencies": { "devDependencies": {
"@alifd/theme-lowcode-dark": "^0.2.0", "@types/lodash-es": "^4.17.12",
"@alifd/theme-lowcode-light": "^0.2.0",
"@types/react": "^18.2.0", "@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0" "@types/react-dom": "^18.2.0"
}, },
"peerDependencies": { "peerDependencies": {
"@alifd/next": "^1.27.8",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0" "react-dom": "^18.2.0"
}, },

View File

@ -1,6 +1,3 @@
import { bootstrapModules, createInstance } from '@alilc/lowcode-core';
import { EngineMain } from './main';
export async function init( export async function init(
container?: HTMLElement, container?: HTMLElement,
options?: IPublicTypeEngineOptions, options?: IPublicTypeEngineOptions,
@ -11,7 +8,4 @@ export async function init(
container.id = 'engine'; container.id = 'engine';
document.body.appendChild(container); document.body.appendChild(container);
} }
bootstrapModules();
createInstance(EngineMain).startup(container);
} }

View File

@ -1,12 +1,11 @@
import { Provide } from '@alilc/lowcode-core'; import { InstantiationService } from '@alilc/lowcode-shared';
import { IWorkspaceMainService } from './workspace';
@Provide('EngineMain') export class MainEngineApplication {
export class EngineMain { instantiationService = new InstantiationService();
constructor(@IWorkspaceMainService private workspaceMainService: IWorkspaceMainService) {}
startup(container: HTMLElement): void { constructor() {
console.log('%c [ container ]-9', 'font-size:13px; background:pink; color:#bf2c9f;', container); this.instantiationService.bootstrapModules();
this.workspaceMainService.initialize();
} }
startup(container: HTMLElement): void {}
} }

View File

@ -0,0 +1,8 @@
import { createDecorator, Provide } from '@alilc/lowcode-shared';
export interface ICommandService {}
export const ICommandService = createDecorator<ICommandService>('commandService');
@Provide(ICommandService)
export class CommandService implements ICommandService {}

View File

@ -1,6 +1,6 @@
import { get as lodashGet, isPlainObject, cloneDeep } from 'lodash-es'; import { get as lodashGet, isPlainObject, cloneDeep } from 'lodash-es';
import { type PlainObject } from '@alilc/lowcode-shared/src/types'; import { type PlainObject } from '@alilc/lowcode-shared';
import { invariant } from '@alilc/lowcode-shared/src/utils'; import { invariant } from '@alilc/lowcode-shared';
export class Configuration<Config extends PlainObject, K extends keyof Config = keyof Config> { export class Configuration<Config extends PlainObject, K extends keyof Config = keyof Config> {
private config: Config; private config: Config;

View File

@ -0,0 +1,8 @@
import { createDecorator, Provide } from '@alilc/lowcode-shared';
export interface IConfigurationService {}
export const IConfigurationService = createDecorator<IConfigurationService>('configurationService');
@Provide(IConfigurationService)
export class ConfigurationService implements IConfigurationService {}

View File

@ -1,9 +0,0 @@
import { Provide } from '@alilc/lowcode-core';
import { IWorkspaceMainService } from './interface';
@Provide('WorkspaceMainService')
export class WorkspaceMainService implements IWorkspaceMainService {
initialize(): void {
console.log('initialize...');
}
}

View File

@ -1 +0,0 @@
export * from './interface';

View File

@ -1,7 +0,0 @@
import { createDecorator } from '@alilc/lowcode-core';
export interface IWorkspaceMainService {
initialize(): void;
}
export const IWorkspaceMainService = createDecorator<IWorkspaceMainService>('WorkspaceMainService');

View File

@ -1,25 +1,26 @@
import { defineConfig, mergeConfig } from 'vite'; import { defineConfig, mergeConfig } from 'vite';
import baseConfigFn from '../../vite.base.config' import baseConfigFn from '../../vite.base.config';
export default defineConfig(async () => { export default defineConfig(async () => {
const baseConfig = await baseConfigFn({ const baseConfig = await baseConfigFn({
name: 'AliLowCodeEngine', name: 'AliLowCodeEngine',
defaultFormats: ['es', 'cjs'], defaultFormats: ['es', 'cjs'],
}) });
return mergeConfig(baseConfig, defineConfig({ return mergeConfig(
build: { baseConfig,
rollupOptions: { defineConfig({
output: { build: {
// for UMD rollupOptions: {
globals: { output: {
react: 'React', // for UMD
'react-dom': 'ReactDOM', globals: {
'@alifd/next': 'Next' react: 'React',
'react-dom': 'ReactDOM',
},
}, },
}, },
}, },
} }),
})) );
}); });

View File

@ -36,30 +36,15 @@ const lowCodeComponentsCache = new Map<string, ReactComponent>();
export function getComponentByName( export function getComponentByName(
name: string, name: string,
{ packageManager, boostsManager }: RenderContext, { packageManager }: RenderContext,
componentOptions: ComponentOptions = {}, componentOptions: ComponentOptions = {},
): ReactComponent { ): ReactComponent {
const result = lowCodeComponentsCache.get(name) || packageManager.getComponent(name); const result = lowCodeComponentsCache.get(name) || packageManager.getComponent(name);
if (isLowCodeComponentPackage(result)) { if (isLowCodeComponentPackage(result)) {
const { schema, ...metadata } = result; const { schema, ...metadata } = result;
const { componentsMap, componentsTree, utils, i18n } = schema;
if (componentsMap.length > 0) { const lowCodeComponent = createComponent(schema, {
packageManager.resolveComponentMaps(componentsMap);
}
const boosts = boostsManager.toExpose();
utils?.forEach((util) => boosts.util.add(util));
if (i18n) {
Object.keys(i18n).forEach((locale) => {
boosts.intl.addTranslations(locale, i18n[locale]);
});
}
const lowCodeComponent = createComponent(componentsTree[0], {
...componentOptions, ...componentOptions,
displayName: name, displayName: name,
modelOptions: { modelOptions: {

View File

@ -3,7 +3,7 @@ export { createRenderer } from './main';
export { definePackageLoader } from './services/package'; export { definePackageLoader } from './services/package';
export { LifecyclePhase } from './services/lifeCycleService'; export { LifecyclePhase } from './services/lifeCycleService';
export { Widget } from './services/widget'; export { Widget } from './services/widget';
export * from './utils/node'; export * from '../../shared/src/utils/node';
export * from './utils/value'; export * from './utils/value';
/* --------------- types ---------------- */ /* --------------- types ---------------- */

View File

@ -6,7 +6,7 @@ import {
isJSFunction, isJSFunction,
} from '@alilc/lowcode-shared'; } from '@alilc/lowcode-shared';
import { type ICodeScope, CodeScope } from './codeScope'; import { type ICodeScope, CodeScope } from './codeScope';
import { isNode } from '../../utils/node'; import { isNode } from '../../../../shared/src/utils/node';
import { mapValue } from '../../utils/value'; import { mapValue } from '../../utils/value';
import { evaluate } from './evaluate'; import { evaluate } from './evaluate';

View File

@ -1,5 +1,5 @@
import { type PlainObject } from '@alilc/lowcode-shared'; import { type PlainObject } from '@alilc/lowcode-shared';
import { trustedGlobals } from '../../utils/globals-es2015'; import { trustedGlobals } from './globals-es2015';
/* /*
* variables who are impossible to be overwritten need to be escaped from proxy scope for performance reasons * variables who are impossible to be overwritten need to be escaped from proxy scope for performance reasons

View File

@ -1,12 +1,24 @@
import { Provide, createDecorator, EventEmitter, EventDisposable } from '@alilc/lowcode-shared'; import { Provide, createDecorator, EventEmitter, EventDisposable } from '@alilc/lowcode-shared';
/**
*
*/
export const enum LifecyclePhase { export const enum LifecyclePhase {
/**
*
*/
Starting = 1, Starting = 1,
/**
*
*/
OptionsResolved = 2, OptionsResolved = 2,
/**
*
*/
Ready = 3, Ready = 3,
/**
*
*/
Destroying = 4, Destroying = 4,
} }

View File

@ -3,5 +3,5 @@
"compilerOptions": { "compilerOptions": {
"outDir": "dist" "outDir": "dist"
}, },
"include": ["src"] "include": ["src", "../shared/src/utils/node.ts"]
} }

View File

@ -1,5 +1,5 @@
import { Package } from './specs/asset-spec'; import { Package } from './specs/asset-spec';
import { Project } from './specs/lowcode-spec'; import { ComponentTreeRoot } from './specs/lowcode-spec';
export interface ProCodeComponent extends Package { export interface ProCodeComponent extends Package {
package: string; package: string;
@ -11,5 +11,5 @@ export interface LowCodeComponent extends Package {
id: string; id: string;
type: 'lowCode'; type: 'lowCode';
componentName: string; componentName: string;
schema: Project; schema: ComponentTreeRoot;
} }

View File

@ -2,7 +2,7 @@
* https://lowcode-engine.cn/site/docs/specs/assets-spec * https://lowcode-engine.cn/site/docs/specs/assets-spec
* *
*/ */
import { Project } from './lowcode-spec'; import { ComponentTreeRoot } from './lowcode-spec';
export interface Package { export interface Package {
/** /**
@ -40,7 +40,7 @@ export interface Package {
/** /**
* schema * schema
*/ */
schema?: Project; schema?: ComponentTreeRoot;
/** /**
* id * id
*/ */

View File

@ -5,3 +5,4 @@ export * from './type-guards';
export * from './platform'; export * from './platform';
export * from './callback'; export * from './callback';
export * from './async'; export * from './async';
export * from './node';

View File

@ -3,7 +3,7 @@
* fork from: https://github.com/Rich-Harris/estree-walker * fork from: https://github.com/Rich-Harris/estree-walker
*/ */
import { type PlainObject, type Spec } from '@alilc/lowcode-shared'; import { type PlainObject, type Spec } from '../types';
type Node = Spec.JSNode; type Node = Spec.JSNode;

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +0,0 @@
{
"name": "@alilc/lowcode-types",
"version": "2.0.0-beta.0",
"description": "Types for Ali lowCode engine",
"type": "module",
"main": "dist/low-code-types.js",
"module": "dist/low-code-types.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"import": "./dist/low-code-types.js",
"module": "./dist/low-code-types.js",
"types": "./dist/index.d.ts"
},
"./package.json": "./package.json"
},
"files": [
"dist",
"src",
"package.json"
],
"scripts": {
"build:target": "vite build",
"build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs",
"test": "vitest"
},
"dependencies": {
"@alilc/lowcode-datasource-types": "^1.0.0",
"@alifd/next": "^1.27.8",
"react": "^18.2.0",
"strict-event-emitter-types": "^2.0.0"
},
"devDependencies": {
"@types/react": "^18.2.0"
},
"peerDependencies": {
"react": "^18.2.0",
"@alifd/next": "^1.27.8"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"repository": {
"type": "http",
"url": "https://github.com/alibaba/lowcode-engine/tree/main/packages/types"
},
"gitHead": "2669f179e6f899d395ce1942d0fe04f9c5ed48a6",
"bugs": "https://github.com/alibaba/lowcode-engine/issues",
"homepage": "https://github.com/alibaba/lowcode-engine/#readme"
}

View File

@ -1,21 +0,0 @@
import { IPublicTypeNodeSchema } from './shell';
export enum ActivityType {
ADDED = 'added',
DELETED = 'deleted',
MODIFIED = 'modified',
COMPOSITE = 'composite',
}
interface IActivityPayload {
schema: IPublicTypeNodeSchema;
location?: {
parent: {
nodeId: string;
index: number;
};
};
prop: any;
oldValue: any;
newValue: any;
}

View File

@ -1,52 +0,0 @@
export enum AssetLevel {
// 环境依赖库 比如 react, react-dom
Environment = 1,
// 基础类库,比如 lodash deep fusion antd
Library = 2,
// 主题
Theme = 3,
// 运行时
Runtime = 4,
// 业务组件
Components = 5,
// 应用 & 页面
App = 6,
}
export const AssetLevels = [
AssetLevel.Environment,
AssetLevel.Library,
AssetLevel.Theme,
AssetLevel.Runtime,
AssetLevel.Components,
AssetLevel.App,
];
export type URL = string;
export enum AssetType {
JSUrl = 'jsUrl',
CSSUrl = 'cssUrl',
CSSText = 'cssText',
JSText = 'jsText',
Bundle = 'bundle',
}
export interface AssetItem {
type: AssetType;
content?: string | null;
device?: string;
level?: AssetLevel;
id?: string;
scriptType?: 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;
}

View File

@ -1,14 +0,0 @@
export interface PackageJSON {
name: string;
version: string;
description?: string;
dependencies: Record<string, string>;
devDependencies: Record<string, string>;
scripts?: Record<string, string>;
engines?: Record<string, string>;
repository?: {
type: string;
url: string;
};
private?: boolean;
}

View File

@ -1,59 +0,0 @@
/**
*
*
* @export
* @interface ResultDir
*/
export interface ResultDir {
/**
* Root .
*
* @type {string}
* @memberof ResultDir
*/
name: string;
/**
*
*
* @type {ResultDir[]}
* @memberof ResultDir
*/
dirs: ResultDir[];
/**
*
*
* @type {ResultFile[]}
* @memberof ResultDir
*/
files: ResultFile[];
}
/**
*
*
* @export
* @interface ResultFile
*/
export interface ResultFile {
/**
*
*
* @type {string}
* @memberof ResultFile
*/
name: string;
/**
* .js .less
*
* @type {string}
* @memberof ResultFile
*/
ext: string;
/**
*
*
* @type {string}
* @memberof ResultFile
*/
content: string;
}

View File

@ -1,147 +0,0 @@
import { ReactNode, ComponentType } from 'react';
import { IPublicTypeNpmInfo, IPublicModelEditor } from './shell';
export interface EditorConfig {
skeleton?: SkeletonConfig;
theme?: ThemeConfig;
plugins?: PluginsConfig;
hooks?: HooksConfig;
shortCuts?: ShortCutsConfig;
utils?: UtilsConfig;
constants?: ConstantsConfig;
lifeCycles?: LifeCyclesConfig;
i18n?: I18nConfig;
}
export interface SkeletonConfig {
config: IPublicTypeNpmInfo;
props?: Record<string, unknown>;
handler?: (config: EditorConfig) => EditorConfig;
}
export interface FusionTheme {
package: string;
version: string;
}
export interface ThemeConfig {
fusion?: FusionTheme;
}
export interface PluginsConfig {
[key: string]: PluginConfig[];
}
export interface PluginConfig {
pluginKey: string;
type: string;
props: {
icon?: string;
title?: string;
width?: number;
height?: number;
visible?: boolean;
disabled?: boolean;
marked?: boolean;
align?: 'left' | 'right' | 'top' | 'bottom';
onClick?: () => void;
dialogProps?: Record<string, unknown>;
balloonProps?: Record<string, unknown>;
panelProps?: Record<string, unknown>;
linkProps?: Record<string, unknown>;
};
config?: IPublicTypeNpmInfo;
pluginProps?: Record<string, unknown>;
}
export type HooksConfig = HookConfig[];
export interface HookConfig {
message: string;
type: 'on' | 'once';
handler: (this: IPublicModelEditor, editor: IPublicModelEditor, ...args: any[]) => void;
}
export type ShortCutsConfig = ShortCutConfig[];
export interface ShortCutConfig {
keyboard: string;
handler: (editor: IPublicModelEditor, ev: Event, keymaster: any) => void;
}
export type UtilsConfig = UtilConfig[];
export interface UtilConfig {
name: string;
type: 'npm' | 'function';
content: IPublicTypeNpmInfo | ((...args: []) => any);
}
export type ConstantsConfig = Record<string, unknown>;
export interface LifeCyclesConfig {
init?: (editor: IPublicModelEditor) => any;
destroy?: (editor: IPublicModelEditor) => any;
}
export type LocaleType = 'zh-CN' | 'zh-TW' | 'en-US' | 'ja-JP';
export interface I18nMessages {
[key: string]: string;
}
export interface I18nConfig {
'zh-CN'?: I18nMessages;
'zh-TW'?: I18nMessages;
'en-US'?: I18nMessages;
'ja-JP'?: I18nMessages;
}
export type I18nFunction = (key: string, params: any) => string;
export interface Utils {
[key: string]: (...args: any[]) => any;
}
export interface PluginProps {
editor?: IPublicModelEditor;
config: PluginConfig;
[key: string]: any;
}
export type Plugin = ReactNode & {
open?: () => boolean | undefined | Promise<any>;
close?: () => boolean | undefined | Promise<any>;
};
export type HOCPlugin = ReactNode & {
open: () => Promise<any>;
close: () => Promise<any>;
};
export interface PluginSet {
[key: string]: HOCPlugin;
}
export type PluginClass = ComponentType<PluginProps> & {
init?: (editor: IPublicModelEditor) => void;
defaultProps?: {
locale?: LocaleType;
messages?: I18nMessages;
};
};
export interface PluginClassSet {
[key: string]: PluginClass;
}
export interface PluginStatus {
disabled?: boolean;
visible?: boolean;
marked?: boolean;
locked?: boolean;
}
export interface PluginStatusSet {
[key: string]: PluginStatus;
}

View File

@ -1,9 +0,0 @@
import * as Node from './node';
export interface EventConfig {
[Node.Prop.InnerChange]: (options: Node.Prop.ChangeOptions) => any;
[Node.Rerender]: (options: Node.RerenderOptions) => void;
[eventName: string]: any;
}
export { Node };

View File

@ -1,12 +0,0 @@
import * as Prop from './prop';
export { Prop };
export interface RerenderOptions {
time: number;
componentName?: string;
type?: string;
nodeCount?: number;
}
export const Rerender = 'node.edit.rerender.time';

View File

@ -1,10 +0,0 @@
export interface ChangeOptions {
key?: string | number;
prop?: any;
node: Node;
newValue: any;
oldValue: any;
}
/** Node Prop 变化事件 */
export const InnerChange = 'node.innerProp.change';

View File

@ -1,12 +0,0 @@
import * as GlobalEvent from './event';
export { GlobalEvent };
export * from '@alilc/lowcode-datasource-types';
export * from './editor';
export * from './activity';
export * from './code-intermediate';
export * from './code-result';
export * from './assets';
export * from './shell';
export * from './shell-model-factory';

View File

@ -1,9 +0,0 @@
import { IPublicModelNode, IPublicModelSettingField } from './shell';
export interface IShellModelFactory {
// TODO: 需要给 innerNode 提供一个 interface 并用在这里
createNode(node: any | null | undefined): IPublicModelNode | null;
// TODO: 需要给 InnerSettingField 提供一个 interface 并用在这里
createSettingField(prop: any): IPublicModelSettingField;
}

View File

@ -1,73 +0,0 @@
import { IPublicModelDragon, IPublicModelDropLocation, IPublicModelScrollTarget, IPublicModelScroller, IPublicModelActiveTracker, IPublicModelClipboard } from '../model';
import { IPublicTypeLocationData, IPublicTypeScrollable } from '../type';
/**
* canvas - API
* @since v1.1.0
*/
export interface IPublicApiCanvas {
/**
* Scroller
*
* a Scroller is a controller that gives a view (IPublicTypeScrollable) the ability scrolling
* to some cordination by api scrollTo.
*
* when a scroller is inited, will need to pass is a scrollable, which has a scrollTarget.
* and when scrollTo(options: { left?: number; top?: number }) is called, scroller will
* move scrollTarget`s top-left corner to (options.left, options.top) that passed in.
* @since v1.1.0
*/
createScroller(scrollable: IPublicTypeScrollable): IPublicModelScroller;
/**
* ScrollTarget Scroller createScroller
*
* this works with Scroller, refer to createScroller`s description
* @since v1.1.0
*/
createScrollTarget(shell: HTMLDivElement): IPublicModelScrollTarget;
/**
*
*
* create a drop location for document, drop location describes a location in document
* @since v1.1.0
*/
createLocation(locationData: IPublicTypeLocationData): IPublicModelDropLocation;
/**
*
*
* get dragon instance, you can use this to obtain draging related abilities and lifecycle hooks
* @since v1.1.0
*/
get dragon(): IPublicModelDragon | null;
/**
*
*
* get activeTracker instance, which is a singleton running in engine.
* it tracks document`s current focusing node/node[], and notify it`s subscribers that when
* focusing node/node[] changed.
* @since v1.1.0
*/
get activeTracker(): IPublicModelActiveTracker | null;
/**
* LiveEditing
*
* check if canvas is in liveEditing state
* @since v1.1.0
*/
get isInLiveEditing(): boolean;
/**
*
*
* get clipboard instance
*
* @since v1.1.0
*/
get clipboard(): IPublicModelClipboard;
}

View File

@ -1,34 +0,0 @@
import { IPublicTypeCommand, IPublicTypeCommandHandlerArgs, IPublicTypeListCommand } from '../type';
export interface IPublicApiCommand {
/**
*
*/
registerCommand(command: IPublicTypeCommand): void;
/**
*
*/
unregisterCommand(name: string): void;
/**
*
*/
executeCommand(name: string, args?: IPublicTypeCommandHandlerArgs): void;
/**
*
*/
batchExecuteCommand(commands: { name: string; args?: IPublicTypeCommandHandlerArgs }[]): void;
/**
*
*/
listCommands(): IPublicTypeListCommand[];
/**
*
*/
onCommandError(callback: (name: string, error: Error) => void): void;
}

View File

@ -1,96 +0,0 @@
import { Component, ReactNode } from 'react';
import { IPublicTypeNodeSchema, IPublicTypeTitleContent } from '../type';
import { IPublicEnumTransitionType } from '../enum';
export interface IPublicApiCommonUtils {
/**
* schema
* check if data is valid NodeSchema
*
* @param {*} data
* @returns {boolean}
*/
isNodeSchema(data: any): boolean;
/**
*
* check if e is a form event
* @param {(KeyboardEvent | MouseEvent)} e
* @returns {boolean}
*/
isFormEvent(e: KeyboardEvent | MouseEvent): boolean;
/**
* schema id
* get node schema from a larger schema with node id
* @param {IPublicTypeNodeSchema} schema
* @param {string} nodeId
* @returns {(IPublicTypeNodeSchema | undefined)}
*/
getNodeSchemaById(
schema: IPublicTypeNodeSchema,
nodeId: string,
): IPublicTypeNodeSchema | undefined;
// TODO: add comments
getConvertedExtraKey(key: string): string;
// TODO: add comments
getOriginalExtraKey(key: string): string;
/**
*
* excute something in a transaction for performence
*
* @param {() => void} fn
* @param {IPublicEnumTransitionType} type
* @since v1.0.16
*/
executeTransaction(fn: () => void, type: IPublicEnumTransitionType): void;
/**
* i18n
* i18n tools
*
* @param {(string | object)} instance
* @returns {{
* intlNode(id: string, params?: object): ReactNode;
* intl(id: string, params?: object): string;
* getLocale(): string;
* setLocale(locale: string): void;
* }}
* @since v1.0.17
*/
createIntl(instance: string | object): {
intlNode(id: string, params?: object): ReactNode;
intl(id: string, params?: object): string;
getLocale(): string;
setLocale(locale: string): void;
};
}
export interface IPublicApiCommonSkeletonCabin {
/**
* View
* get Workbench Component
*/
get Workbench(): Component;
}
export interface IPublicApiCommonEditorCabin {
/**
* Title
* @experimental unstable API, pay extra caution when trying to use this
*/
get Tip(): React.ComponentClass;
/**
* Tip
* @experimental unstable API, pay extra caution when trying to use this
*/
get Title(): React.ComponentClass<{
title: IPublicTypeTitleContent | undefined;
match?: boolean;
keywords?: string | null;
}>;
}

View File

@ -1,108 +0,0 @@
import React, { ReactElement, ComponentProps } from 'react';
import {
IPublicTypeContextMenuAction,
IPublicTypeHelpTipConfig,
IPublicTypeTipConfig,
IPublicTypeTitleContent,
} from '../type';
import {
Balloon,
Breadcrumb,
Button,
Card,
Checkbox,
DatePicker,
Dialog,
Dropdown,
Form,
Icon,
Input,
Loading,
Message,
Overlay,
Pagination,
Radio,
Search,
Select,
SplitButton,
Step,
Switch,
Tab,
Table,
Tree,
TreeSelect,
Upload,
Divider,
} from '@alifd/next';
type IconProps = ComponentProps<typeof Icon>;
export interface IPublicApiCommonUI {
Balloon: typeof Balloon;
Breadcrumb: typeof Breadcrumb;
Button: typeof Button;
Card: typeof Card;
Checkbox: typeof Checkbox;
DatePicker: typeof DatePicker;
Dialog: typeof Dialog;
Dropdown: typeof Dropdown;
Form: typeof Form;
Icon: typeof Icon;
Input: typeof Input;
Loading: typeof Loading;
Message: typeof Message;
Overlay: typeof Overlay;
Pagination: typeof Pagination;
Radio: typeof Radio;
Search: typeof Search;
Select: typeof Select;
SplitButton: typeof SplitButton;
Step: typeof Step;
Switch: typeof Switch;
Tab: typeof Tab;
Table: typeof Table;
Tree: typeof Tree;
TreeSelect: typeof TreeSelect;
Upload: typeof Upload;
Divider: typeof Divider;
/**
* Title
*/
get Tip(): React.ComponentClass<IPublicTypeTipConfig>;
/**
* HelpTip
*/
get HelpTip(): React.VFC<{
help: IPublicTypeHelpTipConfig;
/**
*
* @default 'top'
*/
direction: IPublicTypeTipConfig['direction'];
/**
*
* @default 'small'
*/
size: IconProps['size'];
}>;
/**
* Tip
*/
get Title(): React.ComponentClass<{
title: IPublicTypeTitleContent | undefined;
match?: boolean;
keywords?: string | null;
}>;
get ContextMenu(): ((props: {
menus: IPublicTypeContextMenuAction[];
children: React.ReactElement[] | React.ReactElement;
}) => ReactElement) & {
create(menus: IPublicTypeContextMenuAction[], event: MouseEvent | React.MouseEvent): void;
};
}

View File

@ -1,36 +0,0 @@
import { IPublicTypeDisposable } from '../type';
export interface IPublicApiEvent {
/**
*
* add monitor to a event
* @param event
* @param listener
*/
on(event: string, listener: (...args: any[]) => void): IPublicTypeDisposable;
/**
*
* add monitor to a event
* @param event
* @param listener
*/
prependListener(event: string, listener: (...args: any[]) => void): IPublicTypeDisposable;
/**
*
* cancel a monitor from a event
* @param event
* @param listener
*/
off(event: string, listener: (...args: any[]) => void): void;
/**
*
* emit a message for a event
* @param event
* @param args
* @returns
*/
emit(event: string, ...args: any[]): void;
}

View File

@ -1,31 +0,0 @@
import { IPublicTypeDisposable, IPublicTypeHotkeyCallback, IPublicTypeHotkeyCallbacks } from '../type';
export interface IPublicApiHotkey {
/**
*
*
* @experimental
* @since v1.1.0
*/
get callbacks(): IPublicTypeHotkeyCallbacks;
/**
*
* bind hotkey/hotkeys,
* @param combos ['command + s'] ['ctrl + shift + s']
* @param callback
* @param action
*/
bind(
combos: string[] | string,
callback: IPublicTypeHotkeyCallback,
action?: string,
): IPublicTypeDisposable;
/**
*
* @param window window
*/
mount(window: Window): IPublicTypeDisposable;
}

View File

@ -1,14 +0,0 @@
export * from './common';
export * from './event';
export * from './hotkey';
export * from './material';
export * from './project';
export * from './setters';
export * from './simulator-host';
export * from './skeleton';
export * from './plugins';
export * from './logger';
export * from './canvas';
export * from './workspace';
export * from './commonUI';
export * from './command';

View File

@ -1,33 +0,0 @@
export type LoggerLevel = 'debug' | 'log' | 'info' | 'warn' | 'error';
export interface ILoggerOptions {
level?: LoggerLevel;
bizName?: string;
}
export interface IPublicApiLogger {
/**
* debug info
*/
debug(...args: any | any[]): void;
/**
* normal info output
*/
info(...args: any | any[]): void;
/**
* warning info output
*/
warn(...args: any | any[]): void;
/**
* error info output
*/
error(...args: any | any[]): void;
/**
* log info output
*/
log(...args: any | any[]): void;
}

View File

@ -1,149 +0,0 @@
import { IPublicTypeAssetsJson, IPublicTypeMetadataTransducer, IPublicTypeComponentAction, IPublicTypeNpmInfo, IPublicTypeDisposable, IPublicTypeContextMenuAction, IPublicTypeContextMenuItem } from '../type';
import { IPublicModelComponentMeta } from '../model';
import { ComponentType } from 'react';
export interface IPublicApiMaterial {
/**
* map
* get map of components
*/
get componentsMap(): { [key: string]: IPublicTypeNpmInfo | ComponentType<any> | object } ;
/**
*
* set data for Assets
* @returns void
*/
setAssets(assets: IPublicTypeAssetsJson): Promise<void>;
/**
*
* get AssetsJson data
* @returns IPublicTypeAssetsJson
*/
getAssets(): IPublicTypeAssetsJson | undefined;
/**
*
* load Assets incrementally, and will merge this with exiting assets
* @param incrementalAssets
* @returns
*/
loadIncrementalAssets(incrementalAssets: IPublicTypeAssetsJson): void;
/**
*
* register transducer to process component meta, which will be
* excuted during component meta`s initialization
* @param transducer
* @param level
* @param id
*/
registerMetadataTransducer(
transducer: IPublicTypeMetadataTransducer,
level?: number,
id?: string | undefined
): void;
/**
*
* get all registered metadata transducers
* @returns {IPublicTypeMetadataTransducer[]}
*/
getRegisteredMetadataTransducers(): IPublicTypeMetadataTransducer[];
/**
*
* get component meta by component name
* @param componentName
* @returns
*/
getComponentMeta(componentName: string): IPublicModelComponentMeta | null;
/**
* test if the given object is a ComponentMeta instance or not
* @param obj
* @experiemental unstable API, pay extra caution when trying to use it
*/
isComponentMeta(obj: any): boolean;
/**
*
* get map of all component metas
*/
getComponentMetasMap(): Map<string, IPublicModelComponentMeta>;
/**
* action
*
* add an action button in canvas context menu area
* @param action
* @example
* ```ts
* import { plugins } from '@alilc/lowcode-engine';
* import { IPublicModelPluginContext } from '@alilc/lowcode-types';
*
* const removeCopyAction = (ctx: IPublicModelPluginContext) => {
* return {
* async init() {
* const { removeBuiltinComponentAction } = ctx.material;
* removeBuiltinComponentAction('copy');
* }
* }
* };
* removeCopyAction.pluginName = 'removeCopyAction';
* await plugins.register(removeCopyAction);
* ```
*/
addBuiltinComponentAction(action: IPublicTypeComponentAction): void;
/**
* action
* remove a builtin action button from canvas context menu area
* @param name
*/
removeBuiltinComponentAction(name: string): void;
/**
* action
* modify a builtin action button in canvas context menu area
* @param actionName
* @param handle
*/
modifyBuiltinComponentAction(
actionName: string,
handle: (action: IPublicTypeComponentAction) => void,
): void;
/**
* assets
* add callback for assets changed event
* @param fn
*/
onChangeAssets(fn: () => void): IPublicTypeDisposable;
/**
* componentMetasMap components
* @since v1.1.7
*/
refreshComponentMetasMap(): void;
/**
*
* @param action
*/
addContextMenuOption(action: IPublicTypeContextMenuAction): void;
/**
*
* @param name
*/
removeContextMenuOption(name: string): void;
/**
*
* @param actions
*/
adjustContextMenuLayout(fn: (actions: IPublicTypeContextMenuItem[]) => IPublicTypeContextMenuItem[]): void;
}

View File

@ -1,63 +0,0 @@
import { IPublicModelPluginInstance, IPublicTypePlugin } from '../model';
import { IPublicTypePluginPreferenceValueType } from '../type';
import { IPublicTypePluginRegisterOptions } from '../type/plugin-register-options';
export interface IPluginPreferenceMananger {
// eslint-disable-next-line max-len
getPreferenceValue: (
key: string,
defaultValue?: IPublicTypePluginPreferenceValueType,
) => IPublicTypePluginPreferenceValueType | undefined;
}
export type PluginOptionsType = string | number | boolean | object;
export interface IPublicApiPlugins {
/**
* plugin api export
*/
[key: string]: any;
register(
pluginModel: IPublicTypePlugin,
options?: Record<string, PluginOptionsType>,
registerOptions?: IPublicTypePluginRegisterOptions,
): Promise<void>;
/**
*
*
* use this to get preference config for this plugin when engine.init() called
*/
getPluginPreference(
pluginName: string,
): Record<string, IPublicTypePluginPreferenceValueType> | null | undefined;
/**
*
*
* get plugin instance by name
*/
get(pluginName: string): IPublicModelPluginInstance | null;
/**
*
*
* get all plugin instances
*/
getAll(): IPublicModelPluginInstance[];
/**
*
*
* check if plugin with certain name exists
*/
has(pluginName: string): boolean;
/**
*
*
* delete plugin instance by name
*/
delete(pluginName: string): void;
}

View File

@ -1,147 +0,0 @@
import { IPublicTypeProjectSchema, IPublicTypeDisposable, IPublicTypeRootSchema, IPublicTypePropsTransducer, IPublicTypeAppConfig } from '../type';
import { IPublicEnumTransformStage } from '../enum';
import { IPublicApiSimulatorHost } from './';
import { IPublicModelDocumentModel } from '../model';
export interface IBaseApiProject<
DocumentModel
> {
/**
* document
* get current document
*/
get currentDocument(): DocumentModel | null;
/**
* project documents
* get all documents of this project
* @returns
*/
get documents(): DocumentModel[];
/**
* host
* get simulator host
*/
get simulatorHost(): IPublicApiSimulatorHost | null;
/**
* document
* open a document
* @param doc
* @returns
*/
openDocument(doc?: string | IPublicTypeRootSchema | undefined): DocumentModel | null;
/**
* document
* create a document
* @param data
* @returns
*/
createDocument(data?: IPublicTypeRootSchema): DocumentModel | null;
/**
* document
* remove a document
* @param doc
*/
removeDocument(doc: DocumentModel): void;
/**
* fileName document
* get a document by filename
* @param fileName
* @returns
*/
getDocumentByFileName(fileName: string): DocumentModel | null;
/**
* id document
* get a document by id
* @param id
* @returns
*/
getDocumentById(id: string): DocumentModel | null;
/**
* project
* export project to schema
* @returns
*/
exportSchema(stage: IPublicEnumTransformStage): IPublicTypeProjectSchema;
/**
* project schema
* import schema to project
* @param schema project
*/
importSchema(schema?: IPublicTypeProjectSchema): void;
/**
* document
* get current document
* @returns
*/
getCurrentDocument(): DocumentModel | null;
/**
*
* add a transducer to process prop
* @param transducer
* @param stage
*/
addPropsTransducer(
transducer: IPublicTypePropsTransducer,
stage: IPublicEnumTransformStage,
): void;
/**
*
* set callback for event onDocumentRemoved
* @param fn
* @since v1.0.16
*/
onRemoveDocument(fn: (data: { id: string }) => void): IPublicTypeDisposable;
/**
* project document
* set callback for event onDocumentChanged
*/
onChangeDocument(fn: (doc: DocumentModel) => void): IPublicTypeDisposable;
/**
* project ready
* set callback for event onSimulatorHostReady
*/
onSimulatorHostReady(fn: (host: IPublicApiSimulatorHost) => void): IPublicTypeDisposable;
/**
* project ready
* set callback for event onSimulatorRendererReady
*/
onSimulatorRendererReady(fn: () => void): IPublicTypeDisposable;
/**
*
* https://github.com/alibaba/lowcode-engine/blob/main/specs/lowcode-spec.md#2434%E5%9B%BD%E9%99%85%E5%8C%96%E5%A4%9A%E8%AF%AD%E8%A8%80%E7%B1%BB%E5%9E%8Baa
*
* set I18n data for this project
* @param value object
* @since v1.0.17
*/
setI18n(value: object): void;
/**
*
*
* set config data for this project
* @param value object
* @since v1.1.4
*/
setConfig<T extends keyof IPublicTypeAppConfig>(key: T, value: IPublicTypeAppConfig[T]): void;
setConfig(value: IPublicTypeAppConfig): void;
}
export interface IPublicApiProject extends IBaseApiProject<IPublicModelDocumentModel> {}

View File

@ -1,32 +0,0 @@
import { IPublicTypeRegisteredSetter, IPublicTypeCustomView } from '../type';
export interface IPublicApiSetters {
/**
* setter
* get setter by type
* @param type
* @returns
*/
getSetter(type: string): IPublicTypeRegisteredSetter | null;
/**
* settersMap
* get map of all registered setters
* @returns
*/
getSettersMap(): Map<string, IPublicTypeRegisteredSetter & {
type: string;
}>;
/**
* setter
* register a setter
* @param typeOrMaps
* @param setter
* @returns
*/
registerSetter(
typeOrMaps: string | { [key: string]: IPublicTypeCustomView | IPublicTypeRegisteredSetter },
setter?: IPublicTypeCustomView | IPublicTypeRegisteredSetter | undefined
): void;
}

View File

@ -1,51 +0,0 @@
import { IPublicModelNode, IPublicModelSimulatorRender } from '../model';
export interface IPublicApiSimulatorHost {
/**
* contentWindow
* @experimental unstable api, pay extra caution when trying to use it
*/
get contentWindow(): Window | undefined;
/**
* contentDocument
* @experimental unstable api, pay extra caution when trying to use it
*/
get contentDocument(): Document | undefined;
/**
* @experimental unstable api, pay extra caution when trying to use it
*/
get renderer(): IPublicModelSimulatorRender | undefined;
/**
* locale
* set config for simulator host, eg. device locale and so on.
* @param key
* @param value
*/
set(key: string, value: any): void;
/**
* locale
* set config value by key
* @param key
* @returns
*/
get(key: string): any;
/**
*
* scroll to specific node
* @param node
* @since v1.1.0
*/
scrollToNode(node: IPublicModelNode): void;
/**
*
* make simulator render again
*/
rerender(): void;
}

View File

@ -1,177 +0,0 @@
import { IPublicModelSkeletonItem } from '../model';
import {
IPublicTypeConfigTransducer,
IPublicTypeDisposable,
IPublicTypeSkeletonConfig,
IPublicTypeWidgetConfigArea,
} from '../type';
export interface IPublicApiSkeleton {
/**
*
* add a new panel
* @param config
* @param extraConfig
* @returns
*/
add(
config: IPublicTypeSkeletonConfig,
extraConfig?: Record<string, any>,
): IPublicModelSkeletonItem | undefined;
/**
*
* remove a panel
* @param config
* @returns
*/
remove(config: IPublicTypeSkeletonConfig): number | undefined;
/**
*
* @param areaName IPublicTypeWidgetConfigArea
*/
getAreaItems(
areaName: IPublicTypeWidgetConfigArea,
): IPublicModelSkeletonItem[] | undefined;
/**
*
* @param name
* @since v1.1.10
*/
getPanel(name: string): IPublicModelSkeletonItem | undefined;
/**
* Panel
* show panel by name
* @param name
*/
showPanel(name: string): void;
/**
*
* hide panel by name
* @param name
*/
hidePanel(name: string): void;
/**
* Widget
* show widget by name
* @param name
*/
showWidget(name: string): void;
/**
* widget
* enable widget by name
* @param name
*/
enableWidget(name: string): void;
/**
* widget
* hide widget by name
* @param name
*/
hideWidget(name: string): void;
/**
* widget
* disable widgetand make it not responding any click event.
* @param name
*/
disableWidget(name: string): void;
/**
* Area
* show area
* @param areaName name of area
*/
showArea(areaName: string): void;
/**
* Area
* hide area
* @param areaName name of area
*/
hideArea(areaName: string): void;
/**
* Panel
* set callback for panel shown event
* @param listener
* @returns
*/
onShowPanel(
listener: (paneName?: string, panel?: IPublicModelSkeletonItem) => void,
): IPublicTypeDisposable;
/**
* Panel
* set callback for panel hidden event
* @param listener
* @returns
*/
onHidePanel(
listener: (paneName?: string, panel?: IPublicModelSkeletonItem) => void,
): IPublicTypeDisposable;
/**
* Widget Disable
* @param listener
*/
onDisableWidget(
listener: (paneName?: string, panel?: IPublicModelSkeletonItem) => void,
): IPublicTypeDisposable;
/**
* Widget Enable
* @param listener
*/
onEnableWidget(
listener: (paneName?: string, panel?: IPublicModelSkeletonItem) => void,
): IPublicTypeDisposable;
/**
* Widget
* set callback for widget shown event
* @param listener
* @returns
*/
onShowWidget(
listener: (paneName?: string, panel?: IPublicModelSkeletonItem) => void,
): IPublicTypeDisposable;
/**
* Widget
* set callback for widget hidden event
* @param listener
* @returns
*/
onHideWidget(
listener: (paneName?: string, panel?: IPublicModelSkeletonItem) => void,
): IPublicTypeDisposable;
/**
* transducer
* Registers a configuration transducer for a panel.
* @param {IPublicTypeConfigTransducer} transducer
* - IPublicTypeSkeletonConfig
* - The transducer function to be registered. This function takes a configuration object (of type IPublicTypeSkeletonConfig) as input and returns a modified configuration object.
*
* @param {number} level
* -
* - The priority level of the transducer. Transducers with higher priority levels are executed first.
*
* @param {string} [id]
* -
* - (Optional) A unique identifier for the transducer. Used for referencing or manipulating a specific transducer when needed.
*/
registerConfigTransducer(
transducer: IPublicTypeConfigTransducer,
level: number,
id?: string,
): void;
}

View File

@ -1,73 +0,0 @@
import { IPublicModelWindow } from '../model';
import {
IPublicApiPlugins,
IPublicApiSkeleton,
IPublicModelResource,
IPublicResourceList,
IPublicTypeDisposable,
IPublicTypeResourceType,
} from '..';
export interface IPublicApiWorkspace<
Plugins = IPublicApiPlugins,
Skeleton = IPublicApiSkeleton,
ModelWindow = IPublicModelWindow,
Resource = IPublicModelResource,
> {
/** 是否启用 workspace 模式 */
isActive: boolean;
/** 当前设计器窗口 */
window: ModelWindow | null;
plugins: Plugins;
skeleton: Skeleton;
/** 当前设计器的编辑窗口 */
windows: ModelWindow[];
/** 获取资源树列表 */
get resourceList(): IPublicModelResource[];
/** 设置资源树列表 */
setResourceList(resourceList: IPublicResourceList): void;
/** 资源树列表更新事件 */
onResourceListChange(fn: (resourceList: IPublicResourceList) => void): IPublicTypeDisposable;
/** 注册资源 */
registerResourceType(resourceTypeModel: IPublicTypeResourceType): void;
/** 打开视图窗口 */
openEditorWindow(resource: Resource, sleep?: boolean): Promise<void>;
/** 通过视图 id 打开窗口 */
openEditorWindowById(id: string): void;
/**
*
*/
removeEditorWindow(resource: Resource): void;
/** 通过视图 id 移除窗口 */
removeEditorWindowById(id: string): void;
/** 窗口新增/删除的事件 */
onChangeWindows(fn: () => void): IPublicTypeDisposable;
/** active 窗口变更事件 */
onChangeActiveWindow(fn: () => void): IPublicTypeDisposable;
/**
* active
* @since v1.1.7
*/
onChangeActiveEditorView(fn: () => void): IPublicTypeDisposable;
/**
* window renderer ready
* @since v1.1.7
*/
onWindowRendererReady(fn: () => void): IPublicTypeDisposable;
}

View File

@ -1,7 +0,0 @@
export enum IPublicEnumContextMenuType {
SEPARATOR = 'separator',
// 'menuItem'
MENU_ITEM = 'menuItem',
// 'nodeTree'
NODE_TREE = 'nodeTree',
}

View File

@ -1,4 +0,0 @@
export enum IPublicEnumDragObjectType {
Node = 'node',
NodeData = 'nodedata',
}

View File

@ -1,9 +0,0 @@
/**
*
* All public event names
* names should be like 'namespace.modelName.whatHappened'
*
*/
// eslint-disable-next-line no-shadow
export enum IPublicEnumEventNames {
}

View File

@ -1,7 +0,0 @@
export * from './event-names';
export * from './transition-type';
export * from './transform-stage';
export * from './drag-object-type';
export * from './prop-value-changed-type';
export * from './plugin-register-level';
export * from './context-menu';

View File

@ -1,6 +0,0 @@
export enum IPublicEnumPluginRegisterLevel {
Default = 'default',
Workspace = 'workspace',
Resource = 'resource',
EditorView = 'editorView',
}

View File

@ -1,10 +0,0 @@
export enum IPublicEnumPropValueChangedType {
/**
* normal set value
*/
SET_VALUE = 'SET_VALUE',
/**
* value changed caused by sub-prop value change
*/
SUB_VALUE_CHANGE = 'SUB_VALUE_CHANGE'
}

View File

@ -1,8 +0,0 @@
export enum IPublicEnumTransformStage {
Render = 'render',
Serilize = 'serilize',
Save = 'save',
Clone = 'clone',
Init = 'init',
Upgrade = 'upgrade',
}

View File

@ -1,4 +0,0 @@
export const enum IPublicEnumTransitionType {
/** 节点更新后重绘处理 */
REPAINT,
}

View File

@ -1,5 +0,0 @@
export * from './type';
export * from './api';
export * from './model';
export * from './enum';

View File

@ -1,14 +0,0 @@
import { IPublicTypeActiveTarget } from '../type';
import { IPublicModelNode } from './node';
export interface IPublicModelActiveTracker {
/**
* @since 1.1.7
*/
target: IPublicTypeActiveTarget | null;
onChange(fn: (target: IPublicTypeActiveTarget) => void): () => void;
track(node: IPublicModelNode): void;
}

View File

@ -1,25 +0,0 @@
export interface IPublicModelClipboard {
/**
*
* set data to clipboard
*
* @param {*} data
* @since v1.1.0
*/
setData(data: any): void;
/**
*
* set callback for clipboard provide paste data
*
* @param {KeyboardEvent} keyboardEvent
* @param {(data: any, clipboardEvent: ClipboardEvent) => void} cb
* @since v1.1.0
*/
waitPasteData(
keyboardEvent: KeyboardEvent,
cb: (data: any, clipboardEvent: ClipboardEvent) => void,
): void;
}

View File

@ -1,115 +0,0 @@
import { IPublicTypeNodeSchema, IPublicTypeNodeData, IPublicTypeIconType, IPublicTypeTransformedComponentMetadata, IPublicTypeI18nData, IPublicTypeNpmInfo, IPublicTypeAdvanced, IPublicTypeFieldConfig, IPublicTypeComponentAction } from '../type';
import { ReactElement } from 'react';
import { IPublicModelNode } from './node';
export interface IPublicModelComponentMeta<
Node = IPublicModelNode
> {
/**
*
* component name
*/
get componentName(): string;
/**
*
* is container node or not
*/
get isContainer(): boolean;
/**
*
*
*
*
*
* check if this is a mininal render unit.
* when a rerender is needed for a component:
* case 'it`s a mininal render unit': only render itself.
* case 'it`s not a mininal render unit': find a mininal render unit to render in
* its ancesters until root node is reached.
*/
get isMinimalRenderUnit(): boolean;
/**
*
* check if this is a modal component or not.
*/
get isModal(): boolean;
/**
*
* get configs for Settings Panel
*/
get configure(): IPublicTypeFieldConfig[];
/**
*
* title for this component
*/
get title(): string | IPublicTypeI18nData | ReactElement;
/**
*
* icon config for this component
*/
get icon(): IPublicTypeIconType;
/**
* npm
* npm informations
*/
get npm(): IPublicTypeNpmInfo;
/**
* Action
* available actions
*/
get availableActions(): IPublicTypeComponentAction[];
/**
*
* configure.advanced
* @since v1.1.0
*/
get advanced(): IPublicTypeAdvanced;
/**
* npm
* set method for npm inforamtion
* @param npm
*/
setNpm(npm: IPublicTypeNpmInfo): void;
/**
*
* get component metadata
*/
getMetadata(): IPublicTypeTransformedComponentMetadata;
/**
*
* check if the current node could be placed in parent node
* @param my
* @param parent
*/
checkNestingUp(my: Node | IPublicTypeNodeData, parent: any): boolean;
/**
*
* check if the target node(s) could be placed in current node
* @param my
* @param parent
*/
checkNestingDown(
my: Node | IPublicTypeNodeData,
target: IPublicTypeNodeSchema | Node | IPublicTypeNodeSchema[],
): boolean;
/**
*
* refresh metadata
*/
refreshMetadata(): void;
}

View File

@ -1,46 +0,0 @@
import { IPublicModelNode } from './';
import { IPublicTypeDisposable } from '../type';
export interface IPublicModelDetecting<Node = IPublicModelNode> {
/**
*
* check if current detecting is enabled
* @since v1.1.0
*/
get enable(): boolean;
/**
* hover
* get current hovering node
* @since v1.0.16
*/
get current(): Node | null;
/**
* hover
* capture node with nodeId
* @param id id
*/
capture(id: string): void;
/**
* hover
* release node with nodeId
* @param id id
*/
release(id: string): void;
/**
* hover
* clear all hover state
*/
leave(): void;
/**
* hover
* set callback which will be called when hovering object changed.
* @since v1.1.0
*/
onDetectingChange(fn: (node: Node | null) => void): IPublicTypeDisposable;
}

View File

@ -1,248 +0,0 @@
import {
IPublicTypeRootSchema,
IPublicTypeDragNodeDataObject,
IPublicTypeDragNodeObject,
IPublicTypePropChangeOptions,
IPublicTypeDisposable,
} from '../type';
import { IPublicEnumTransformStage } from '../enum';
import { IPublicApiProject } from '../api';
import {
IPublicModelDropLocation,
IPublicModelDetecting,
IPublicModelNode,
IPublicModelSelection,
IPublicModelHistory,
IPublicModelModalNodesManager,
} from './';
import { IPublicTypeNodeData, IPublicTypeNodeSchema, IPublicTypeOnChangeOptions } from '../type';
export interface IPublicModelDocumentModel<
Selection = IPublicModelSelection,
History = IPublicModelHistory,
Node = IPublicModelNode,
DropLocation = IPublicModelDropLocation,
ModalNodesManager = IPublicModelModalNodesManager,
Project = IPublicApiProject,
> {
/**
*
* instance of selection
*/
selection: Selection;
/**
* hover
* instance of detecting
*/
detecting: IPublicModelDetecting;
/**
*
* instance of history
*/
history: History;
/**
* id
*/
get id(): string;
set id(id);
/**
* project
* get project which this documentModel belongs to
* @returns
*/
get project(): Project;
/**
*
* root node of this documentModel
* @returns
*/
get root(): Node | null;
get focusNode(): Node | null;
set focusNode(node: Node | null);
/**
*
* @returns
*/
get nodesMap(): Map<string, Node>;
/**
*
* get instance of modalNodesManager
*/
get modalNodesManager(): ModalNodesManager | null;
/**
* nodeId Node
* get node by nodeId
* @param nodeId
* @returns
*/
getNodeById(nodeId: string): Node | null;
/**
* schema
* import schema data
* @param schema
*/
importSchema(schema: IPublicTypeRootSchema): void;
/**
* schema
* export schema
* @param stage
* @returns
*/
exportSchema(stage: IPublicEnumTransformStage): IPublicTypeRootSchema | undefined;
/**
*
* insert a node
*/
insertNode(
parent: Node,
thing: Node | IPublicTypeNodeData,
at?: number | null | undefined,
copy?: boolean | undefined,
): Node | null;
/**
*
* create a node
* @param data
* @returns
*/
createNode<T = Node, S = IPublicTypeNodeSchema>(data: S): T | null;
/**
* /id
* remove a node by node instance or nodeId
* @param idOrNode
*/
removeNode(idOrNode: string | Node): void;
/**
* componentsMap of documentModel
* @param extraComps
* @returns
*/
getComponentsMap(extraComps?: string[]): any;
/**
*
* check if dragOjbect can be put in this dragTarget
* @param dropTarget
* @param dragObject
* @returns boolean
* @since v1.0.16
*/
checkNesting(
dropTarget: Node,
dragObject: IPublicTypeDragNodeObject | IPublicTypeDragNodeDataObject,
): boolean;
/**
* document
* set callback for event on node is created for a document
*/
onAddNode(fn: (node: Node) => void): IPublicTypeDisposable;
/**
* document document
* set callback for event on node is mounted to canvas
*/
onMountNode(fn: (payload: { node: Node }) => void): IPublicTypeDisposable;
/**
* document
* set callback for event on node is removed
*/
onRemoveNode(fn: (node: Node) => void): IPublicTypeDisposable;
/**
* document hover
*
* set callback for event on detecting changed
*/
onChangeDetecting(fn: (node: Node) => void): IPublicTypeDisposable;
/**
* document
* set callback for event on selection changed
*/
onChangeSelection(fn: (ids: string[]) => void): IPublicTypeDisposable;
/**
* document
* set callback for event on visibility changed for certain node
* @param fn
*/
onChangeNodeVisible(fn: (node: Node, visible: boolean) => void): IPublicTypeDisposable;
/**
* document children
* @param fn
*/
onChangeNodeChildren(fn: (info: IPublicTypeOnChangeOptions<Node>) => void): IPublicTypeDisposable;
/**
* document
* @param fn
*/
onChangeNodeProp(fn: (info: IPublicTypePropChangeOptions<Node>) => void): IPublicTypeDisposable;
/**
* import schema event
* @param fn
* @since v1.0.15
*/
onImportSchema(fn: (schema: IPublicTypeRootSchema) => void): IPublicTypeDisposable;
/**
*
* check is node being detected
* @param node
* @since v1.1.0
*/
isDetectingNode(node: Node): boolean;
/**
* DropLocation
* get current drop location
* @since v1.1.0
*/
get dropLocation(): DropLocation | null;
/**
* DropLocation
* set current drop location
* @since v1.1.0
*/
set dropLocation(loc: DropLocation | null);
/**
*
* triggered focused node is set mannually from plugin
* @param fn
* @since v1.1.0
*/
onFocusNodeChanged(
fn: (doc: IPublicModelDocumentModel, focusNode: Node) => void,
): IPublicTypeDisposable;
/**
* DropLocation
* triggered when drop location changed
* @param fn
* @since v1.1.0
*/
onDropLocationChanged(fn: (doc: IPublicModelDocumentModel) => void): IPublicTypeDisposable;
}

View File

@ -1,11 +0,0 @@
import { IPublicEnumDragObjectType } from '../enum';
import { IPublicTypeNodeSchema } from '../type';
import { IPublicModelNode } from './node';
export class IPublicModelDragObject {
type: IPublicEnumDragObjectType.Node | IPublicEnumDragObjectType.NodeData;
data: IPublicTypeNodeSchema | IPublicTypeNodeSchema[] | null;
nodes: (IPublicModelNode | null)[] | null;
}

View File

@ -1,70 +0,0 @@
/* eslint-disable max-len */
import { IPublicTypeDisposable, IPublicTypeDragNodeDataObject, IPublicTypeDragObject } from '../type';
import { IPublicModelDragObject, IPublicModelLocateEvent, IPublicModelNode } from './';
export interface IPublicModelDragon<
Node = IPublicModelNode,
LocateEvent = IPublicModelLocateEvent
> {
/**
*
* is dragging or not
*/
get dragging(): boolean;
/**
* dragstart
* bind a callback function which will be called on dragging start
* @param func
* @returns
*/
onDragstart(func: (e: LocateEvent) => any): IPublicTypeDisposable;
/**
* drag
* bind a callback function which will be called on dragging
* @param func
* @returns
*/
onDrag(func: (e: LocateEvent) => any): IPublicTypeDisposable;
/**
* dragend
* bind a callback function which will be called on dragging end
* @param func
* @returns
*/
onDragend(func: (o: { dragObject: IPublicModelDragObject; copy?: boolean }) => any): IPublicTypeDisposable;
/**
* shell boost
* set a html element as shell to dragon as monitoring target, and
* set boost function which is used to transform a MouseEvent to type
* IPublicTypeDragNodeDataObject.
* @param shell
* @param boost
*/
from(shell: Element, boost: (e: MouseEvent) => IPublicTypeDragNodeDataObject | null): any;
/**
*
* boost your dragObject for dragging(flying)
*
* @param dragObject
* @param boostEvent
*/
boost(dragObject: IPublicTypeDragObject, boostEvent: MouseEvent | DragEvent, fromRglNode?: Node): void;
/**
*
* add sensor area
*/
addSensor(sensor: any): void;
/**
*
* remove sensor area
*/
removeSensor(sensor: any): void;
}

View File

@ -1,29 +0,0 @@
import { IPublicTypeLocationDetail } from '../type';
import { IPublicModelLocateEvent, IPublicModelNode } from './';
export interface IPublicModelDropLocation {
/**
*
* get target of dropLocation
*/
get target(): IPublicModelNode | null;
/**
*
* get detail of dropLocation
*/
get detail(): IPublicTypeLocationDetail;
/**
*
* get event of dropLocation
*/
get event(): IPublicModelLocateEvent;
/**
*
* get a clone object of current dropLocation
*/
clone(event: IPublicModelLocateEvent): IPublicModelDropLocation;
}

View File

@ -1,7 +0,0 @@
import { IPublicModelPluginContext } from './plugin-context';
export interface IPublicModelEditorView extends IPublicModelPluginContext {
viewName: string;
viewType: 'editor' | 'webview';
}

View File

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

View File

@ -1,66 +0,0 @@
import { IPublicTypeDisposable } from '../type';
import { IPublicModelPreference } from './';
export interface IPublicModelEngineConfig {
/**
* key
* check if config has certain key configed
* @param key
* @returns
*/
has(key: string): boolean;
/**
* key
* get value by key
* @param key
* @param defaultValue
* @returns
*/
get(key: string, defaultValue?: any): any;
/**
* key
* set value for certain key
* @param key
* @param value
*/
set(key: string, value: any): void;
/**
* set
* set multiple config key-values
* @param config
*/
setConfig(config: { [key: string]: any }): void;
/**
* key
* Promise fullfill
* wait until value of certain key is set, will only be
* triggered once.
* @param key
* @returns
*/
onceGot(key: string): Promise<any>;
/**
* key
* set callback for event of value set for some key
* this will be called each time the value is set
* @param key
* @param fn
* @returns
*/
onGot(key: string, fn: (data: any) => void): IPublicTypeDisposable;
/**
* Preference, Preference Panel
* get global user preference manager, which can be use to store
* user`s preference in user localstorage, such as a panel is pinned or not.
* @returns {IPublicModelPreference}
* @since v1.1.0
*/
getPreference(): IPublicModelPreference;
}

View File

@ -1,10 +0,0 @@
import { IPublicModelNode, IPublicTypeTitleContent } from '..';
export interface IPublicModelExclusiveGroup<
Node = IPublicModelNode,
> {
readonly id: string | undefined;
readonly title: IPublicTypeTitleContent | undefined;
get firstNode(): Node | null;
setVisible(node: Node): void;
}

View File

@ -1,62 +0,0 @@
import { IPublicTypeDisposable } from '../type';
export interface IPublicModelHistory {
/**
*
* go to a specific history
* @param cursor
*/
go(cursor: number): void;
/**
* 退
* go backward in history
*/
back(): void;
/**
*
* go forward in history
*/
forward(): void;
/**
*
* do save current change as a record in history
*/
savePoint(): void;
/**
*
* check if there is unsaved change for history
*/
isSavePoint(): boolean;
/**
* state退
* get flags in number which indicat current change state
*
* | 1 | 1 | 1 |
* | -------- | -------- | -------- |
* | modified | redoable | undoable |
* eg.
* 7 means : modified && redoable && undoable
* 5 means : modified && undoable
*/
getState(): number;
/**
* state
* monitor on stateChange event
* @param func
*/
onChangeState(func: () => any): IPublicTypeDisposable;
/**
*
* monitor on cursorChange event
* @param func
*/
onChangeCursor(func: () => any): IPublicTypeDisposable;
}

View File

@ -1,33 +0,0 @@
export * from './component-meta';
export * from './detecting';
export * from './document-model';
export * from './drag-object';
export * from './dragon';
export * from './drop-location';
export * from './history';
export * from './locate-event';
export * from './modal-nodes-manager';
export * from './node-children';
export * from './node';
export * from './prop';
export * from './props';
export * from './selection';
export * from './setting-top-entry';
export * from '../type/plugin';
export * from './window';
export * from './scroll-target';
export * from './scroller';
export * from './active-tracker';
export * from './exclusive-group';
export * from './plugin-context';
export * from './engine-config';
export * from './editor';
export * from './preference';
export * from './plugin-instance';
export * from './sensor';
export * from './resource';
export * from './clipboard';
export * from './setting-field';
export * from './editor-view';
export * from './skeleton-item';
export * from './simulator-render';

View File

@ -1,38 +0,0 @@
import { IPublicModelDocumentModel, IPublicModelDragObject } from './';
export interface IPublicModelLocateEvent {
get type(): string;
/**
*
*/
readonly globalX: number;
readonly globalY: number;
/**
*
*/
readonly originalEvent: MouseEvent | DragEvent;
/**
*
*/
target?: Element | null;
canvasX?: number;
canvasY?: number;
/**
* canvasX,canvasY,
*/
fixed?: true;
/**
*
*/
documentModel?: IPublicModelDocumentModel | null;
get dragObject(): IPublicModelDragObject | null;
}

View File

@ -1,42 +0,0 @@
import { IPublicModelNode } from './';
export interface IPublicModelModalNodesManager<Node = IPublicModelNode> {
/**
*
* set modal nodes, trigger internal events
*/
setNodes(): void;
/**
*
* get modal nodes
*/
getModalNodes(): Node[];
/**
*
* get current visible modal node
*/
getVisibleModalNode(): Node | null;
/**
*
* hide modal nodes
*/
hideModalNodes(): void;
/**
*
* set specfic model node as visible
* @param node Node
*/
setVisible(node: Node): void;
/**
*
* set specfic model node as invisible
* @param node Node
*/
setInvisible(node: Node): void;
}

View File

@ -1,177 +0,0 @@
import { IPublicTypeNodeSchema, IPublicTypeNodeData } from '../type';
import { IPublicEnumTransformStage } from '../enum';
import { IPublicModelNode } from './';
export interface IPublicModelNodeChildren<
Node = IPublicModelNode
> {
/**
* children
* get owner node of this nodeChildren
*/
get owner(): Node | null;
/**
* children
* get count of child nodes
*/
get size(): number;
/**
*
*
* @returns
*/
get isEmptyNode(): boolean;
/**
* judge if it is not empty
*/
get notEmptyNode(): boolean;
/**
*
*
* delete the node
* @param node
*/
delete(node: Node): boolean;
/**
*
*
* insert a node at specific position
* @param node
* @param at
* @returns
*/
insert(node: Node, at?: number | null): void;
/**
*
*
* get index of node in current children
* @param node
* @returns
*/
indexOf(node: Node): number;
/**
* splice
*
* provide the same function with {Array.prototype.splice}
* @param start
* @param deleteCount
* @param node
*/
splice(start: number, deleteCount: number, node?: Node): any;
/**
*
*
* get node with index
* @param index
* @returns
*/
get(index: number): Node | null;
/**
*
*
* check if node exists in current children
* @param node
* @returns
*/
has(node: Node): boolean;
/**
* forEach
*
* provide the same function with {Array.prototype.forEach}
* @param fn
*/
forEach(fn: (node: Node, index: number) => void): void;
/**
* reverse
*
* provide the same function with {Array.prototype.reverse}
*/
reverse(): Node[];
/**
* map
*
* provide the same function with {Array.prototype.map}
* @param fn
*/
map<T = any>(fn: (node: Node, index: number) => T): T[] | null;
/**
* every
* provide the same function with {Array.prototype.every}
* @param fn
*/
every(fn: (node: Node, index: number) => boolean): boolean;
/**
* some
* provide the same function with {Array.prototype.some}
* @param fn
*/
some(fn: (node: Node, index: number) => boolean): boolean;
/**
* filter
* provide the same function with {Array.prototype.filter}
* @param fn
*/
filter(fn: (node: Node, index: number) => boolean): any;
/**
* find
* provide the same function with {Array.prototype.find}
* @param fn
*/
find(fn: (node: Node, index: number) => boolean): Node | null | undefined;
/**
* reduce
*
* provide the same function with {Array.prototype.reduce}
* @param fn
*/
reduce(fn: (acc: any, cur: Node) => any, initialValue: any): void;
/**
* schema
*
* import schema
* @param data
*/
importSchema(data?: IPublicTypeNodeData | IPublicTypeNodeData[]): void;
/**
* schema
*
* export schema
* @param stage
*/
exportSchema(stage: IPublicEnumTransformStage): IPublicTypeNodeSchema;
/**
*
*
* excute remove/add/sort operations
* @param remover
* @param adder
* @param sorter
*/
mergeChildren(
remover: (node: Node, idx: number) => boolean,
adder: (children: Node[]) => IPublicTypeNodeData[] | null,
sorter: (firstNode: Node, secondNode: Node) => number
): any;
}

View File

@ -1,451 +0,0 @@
import { ReactElement } from 'react';
import { IPublicTypeNodeSchema, IPublicTypeIconType, IPublicTypeI18nData, IPublicTypeCompositeValue, IPublicTypePropsMap, IPublicTypePropsList } from '../type';
import { IPublicEnumTransformStage } from '../enum';
import { IPublicModelNodeChildren, IPublicModelComponentMeta, IPublicModelProp, IPublicModelProps, IPublicModelSettingTopEntry, IPublicModelDocumentModel, IPublicModelExclusiveGroup } from './';
export interface IBaseModelNode<
Document = IPublicModelDocumentModel,
Node = IPublicModelNode,
NodeChildren = IPublicModelNodeChildren,
ComponentMeta = IPublicModelComponentMeta,
SettingTopEntry = IPublicModelSettingTopEntry,
Props = IPublicModelProps,
Prop = IPublicModelProp,
ExclusiveGroup = IPublicModelExclusiveGroup
> {
/**
* id
* node id
*/
id: string;
/**
*
* title of node
*/
get title(): string | IPublicTypeI18nData | ReactElement;
/**
*
* check if node is a container type node
* @since v1.1.0
*/
get isContainerNode(): boolean;
/**
*
* check if node is root in the tree
* @since v1.1.0
*/
get isRootNode(): boolean;
/**
* children children
* check if current node is empty, which means no children or children is empty
* @since v1.1.0
*/
get isEmptyNode(): boolean;
/**
* Page
* check if node is Page
* @since v1.1.0
*/
get isPageNode(): boolean;
/**
* Component
* check if node is Component
* @since v1.1.0
*/
get isComponentNode(): boolean;
/**
*
* check if node is Modal
* @since v1.1.0
*/
get isModalNode(): boolean;
/**
*
* check if node is a Slot
* @since v1.1.0
*/
get isSlotNode(): boolean;
/**
* /
* check if node a parental node
* @since v1.1.0
*/
get isParentalNode(): boolean;
/**
*
* check if node is a leaf node in tree
* @since v1.1.0
*/
get isLeafNode(): boolean;
/**
*
* check if current node is locked
* @since v1.0.16
*/
get isLocked(): boolean;
/**
*
* @since v1.1.0
*/
set isRGLContainerNode(flag: boolean);
/**
*
* @returns Boolean
* @since v1.1.0
*/
get isRGLContainerNode();
/**
*
* index
*/
get index(): number | undefined;
/**
*
* get icon of this node
*/
get icon(): IPublicTypeIconType;
/**
* 0
* depth level of this node, value of root node is 0
*/
get zLevel(): number;
/**
* componentName
* componentName
*/
get componentName(): string;
/**
*
* get component meta of this node
*/
get componentMeta(): ComponentMeta | null;
/**
*
* get documentModel of this node
*/
get document(): Document | null;
/**
*
* get previous sibling of this node
*/
get prevSibling(): Node | null | undefined;
/**
*
* get next sibling of this node
*/
get nextSibling(): Node | null | undefined;
/**
*
* get parent of this node
*/
get parent(): Node | null;
/**
*
* get children of this node
*/
get children(): NodeChildren | null;
/**
*
* get slots of this node
*/
get slots(): Node[];
/**
*
* return coresponding prop when this node is a slot node
*/
get slotFor(): Prop | null | undefined;
/**
*
* get props
*/
get props(): Props | null;
/**
*
* get props data
*/
get propsData(): IPublicTypePropsMap | IPublicTypePropsList | null;
/**
* get conditionGroup
*/
get conditionGroup(): ExclusiveGroup | null;
/**
* - schema
* get schema of this node
* @since v1.1.0
*/
get schema(): IPublicTypeNodeSchema;
/**
* setting entry
* get setting entry of this node
* @since v1.1.0
*/
get settingEntry(): SettingTopEntry;
/**
*
* get rect information for this node
*/
getRect(): DOMRect | null;
/**
*
* check if current node has slots
*/
hasSlots(): boolean;
/**
*
* check if current node has condition value set
*/
hasCondition(): boolean;
/**
*
* check if loop is set for this node
*/
hasLoop(): boolean;
/**
* path
* get prop by path
* @param path a / a.b / a.0
* @param createIfNone true
*/
getProp(path: string | number, createIfNone?: boolean): Prop | null;
/**
* path
* get prop value by path
* @param path a / a.b / a.0
*/
getPropValue(path: string): any;
/**
* path
* props props
*
* get extra prop by path, an extra prop means a prop not exists in the `props`
* but as siblint of the `props`
* @param path a / a.b / a.0
* @param createIfNone
*/
getExtraProp(path: string, createIfNone?: boolean): Prop | null;
/**
* path
* props props
*
* get extra prop value by path, an extra prop means a prop not exists in the `props`
* but as siblint of the `props`
* @param path a / a.b / a.0
* @returns
*/
getExtraPropValue(path: string): any;
/**
* path
* set value for prop with path
* @param path a / a.b / a.0
* @param value
*/
setPropValue(path: string | number, value: IPublicTypeCompositeValue): void;
/**
* path
* set value for extra prop with path
* @param path a / a.b / a.0
* @param value
*/
setExtraPropValue(path: string, value: IPublicTypeCompositeValue): void;
/**
*
* import node schema
* @param data
*/
importSchema(data: IPublicTypeNodeSchema): void;
/**
*
* export schema from this node
* @param stage
* @param options
*/
exportSchema(stage: IPublicEnumTransformStage, options?: any): IPublicTypeNodeSchema;
/**
*
* insert a node befor current node
* @param node
* @param ref
* @param useMutator
*/
insertBefore(
node: Node,
ref?: Node | undefined,
useMutator?: boolean,
): void;
/**
*
* insert a node after this node
* @param node
* @param ref
* @param useMutator
*/
insertAfter(
node: Node,
ref?: Node | undefined,
useMutator?: boolean,
): void;
/**
*
* replace a child node with data provided
* @param node
* @param data
* @returns
*/
replaceChild(node: Node, data: any): Node | null;
/**
*
* replace current node with a new node schema
* @param schema
*/
replaceWith(schema: IPublicTypeNodeSchema): any;
/**
*
* select current node
*/
select(): void;
/**
*
* set hover value for current node
* @param flag
*/
hover(flag: boolean): void;
/**
*
* set lock value for current node
* @param flag
* @since v1.0.16
*/
lock(flag?: boolean): void;
/**
*
* remove current node
*/
remove(): void;
/**
*
* excute remove/add/sort operations on node`s children
*
* @since v1.1.0
*/
mergeChildren(
remover: (node: Node, idx: number) => boolean,
adder: (children: Node[]) => any,
sorter: (firstNode: Node, secondNode: Node) => number
): any;
/**
*
* check if current node contains another node as a child
* @param node
* @since v1.1.0
*/
contains(node: Node): boolean;
/**
* action
* check if current node can perform certain aciton with actionName
* @param actionName action
* @since v1.1.0
*/
canPerformAction(actionName: string): boolean;
/**
*
* check if current node is visible
* @since v1.1.0
*/
get visible(): boolean;
/**
*
* set visible value for current node
* @since v1.1.0
*/
set visible(value: boolean);
/**
* ConditionalVisible
* check if current node ConditionalVisible
* @since v1.1.0
*/
isConditionalVisible(): boolean | undefined;
/**
* ConditionalVisible true
* make this node as conditionalVisible === true
* @since v1.1.0
*/
setConditionalVisible(): void;
/**
* dom
*/
getDOMNode(): HTMLElement;
/**
*
*/
getRGL(): {
isContainerNode: boolean;
isEmptyNode: boolean;
isRGLContainerNode: boolean;
isRGLNode: boolean;
isRGL: boolean;
rglNode: Node | null;
};
}
export interface IPublicModelNode extends
IBaseModelNode<IPublicModelDocumentModel, IPublicModelNode> {}

View File

@ -1,124 +0,0 @@
import {
IPublicApiSkeleton,
IPublicApiHotkey,
IPublicApiSetters,
IPublicApiMaterial,
IPublicApiEvent,
IPublicApiProject,
IPublicApiCommon,
IPublicApiLogger,
IPublicApiCanvas,
IPluginPreferenceMananger,
IPublicApiPlugins,
IPublicApiWorkspace,
IPublicApiCommonUI,
IPublicApiCommand,
} from '../api';
import { IPublicEnumPluginRegisterLevel } from '../enum';
import { IPublicModelEngineConfig, IPublicModelWindow } from './';
export interface IPublicModelPluginContext {
/**
*
* by using this, init options can be accessed from inside plugin
*/
preference: IPluginPreferenceMananger;
/**
* skeleton API
* @tutorial https://lowcode-engine.cn/site/docs/api/skeleton
*/
get skeleton(): IPublicApiSkeleton;
/**
* hotkey API
* @tutorial https://lowcode-engine.cn/site/docs/api/hotkey
*/
get hotkey(): IPublicApiHotkey;
/**
* setter API
* @tutorial https://lowcode-engine.cn/site/docs/api/setters
*/
get setters(): IPublicApiSetters;
/**
* config API
* @tutorial https://lowcode-engine.cn/site/docs/api/config
*/
get config(): IPublicModelEngineConfig;
/**
* material API
* @tutorial https://lowcode-engine.cn/site/docs/api/material
*/
get material(): IPublicApiMaterial;
/**
* event API
* this event works globally, can be used between plugins and engine.
* @tutorial https://lowcode-engine.cn/site/docs/api/event
*/
get event(): IPublicApiEvent;
/**
* project API
* @tutorial https://lowcode-engine.cn/site/docs/api/project
*/
get project(): IPublicApiProject;
/**
* common API
* @tutorial https://lowcode-engine.cn/site/docs/api/common
*/
get common(): IPublicApiCommon;
/**
* plugins API
* @tutorial https://lowcode-engine.cn/site/docs/api/plugins
*/
get plugins(): IPublicApiPlugins;
/**
* logger API
* @tutorial https://lowcode-engine.cn/site/docs/api/logger
*/
get logger(): IPublicApiLogger;
/**
* this event works within current plugin, on an emit locally.
* @tutorial https://lowcode-engine.cn/site/docs/api/event
*/
get pluginEvent(): IPublicApiEvent;
/**
* canvas API
* @tutorial https://lowcode-engine.cn/site/docs/api/canvas
*/
get canvas(): IPublicApiCanvas;
/**
* workspace API
* @tutorial https://lowcode-engine.cn/site/docs/api/workspace
*/
get workspace(): IPublicApiWorkspace;
/**
* commonUI API
* @tutorial https://lowcode-engine.cn/site/docs/api/commonUI
*/
get commonUI(): IPublicApiCommonUI;
get command(): IPublicApiCommand;
/**
*
* @since v1.1.7
*/
get registerLevel(): IPublicEnumPluginRegisterLevel;
get isPluginRegisteredInWorkspace(): boolean;
get editorWindow(): IPublicModelWindow;
}

View File

@ -1,28 +0,0 @@
import { IPublicTypePluginMeta } from '../type/plugin-meta';
export interface IPublicModelPluginInstance {
/**
* disable
* current plugin instance is disabled or not
*/
disabled: boolean;
/**
*
* plugin name
*/
get pluginName(): string;
/**
*
* depenency info
*/
get dep(): string[];
/**
*
* meta info of this plugin
*/
get meta(): IPublicTypePluginMeta;
}

View File

@ -1,18 +0,0 @@
export interface IPublicModelPreference {
/**
* set value from local storage by module and key
*/
set(key: string, value: any, module?: string): void;
/**
* get value from local storage by module and key
*/
get(key: string, module: string): any;
/**
* check if local storage contain certain key
*/
contains(key: string, module: string): boolean;
}

View File

@ -1,72 +0,0 @@
import { IPublicEnumTransformStage } from '../enum';
import { IPublicTypeCompositeValue, IPublicTypeNodeData } from '../type';
import { IPublicModelNode } from './';
export interface IPublicModelProp<
Node = IPublicModelNode
> {
/**
* id
*/
get id(): string;
/**
* key
* get key of prop
*/
get key(): string | number | undefined;
/**
* prop
* get path of current prop
*/
get path(): string[];
/**
*
* get node instance, which this prop belongs to
*/
get node(): Node | null;
/**
* prop Slot slotNode
* return the slot node (only if the current prop represents a slot)
* @since v1.1.0
*/
get slotNode(): Node | undefined | null;
/**
* Prop , true
* check if it is a prop or not, and of course always return true
* @experimental
*/
get isProp(): boolean;
/**
*
* set value for this prop
* @param val
*/
setValue(val: IPublicTypeCompositeValue | IPublicTypeNodeData | IPublicTypeNodeData[]): void;
/**
*
* get value of this prop
*/
getValue(): any;
/**
*
* remove value of this prop
* @since v1.0.16
*/
remove(): void;
/**
*
* export schema
* @param stage
*/
exportSchema(stage: IPublicEnumTransformStage): IPublicTypeCompositeValue;
}

View File

@ -1,89 +0,0 @@
import { IPublicTypeCompositeValue } from '../type';
import { IPublicModelNode, IPublicModelProp } from './';
export interface IBaseModelProps<
Prop
> {
/**
* id
*/
get id(): string;
/**
* props
* return path of current props
*/
get path(): string[];
/**
* node
*/
get node(): IPublicModelNode | null;
/**
* path
* get prop by path
* @param path a / a.b / a.0
*/
getProp(path: string): Prop | null;
/**
* path
* get value of prop by path
* @param path a / a.b / a.0
*/
getPropValue(path: string): any;
/**
* path
* props props
* get extra prop by path
* @param path a / a.b / a.0
*/
getExtraProp(path: string): Prop | null;
/**
* path
* props props
* get value of extra prop by path
* @param path a / a.b / a.0
*/
getExtraPropValue(path: string): any;
/**
* path
* set value of prop by path
* @param path a / a.b / a.0
* @param value
*/
setPropValue(path: string, value: IPublicTypeCompositeValue): void;
/**
* path
* set value of extra prop by path
* @param path a / a.b / a.0
* @param value
*/
setExtraPropValue(path: string, value: IPublicTypeCompositeValue): void;
/**
* props prop
* check if the specified key is existing or not.
* @param key
* @since v1.1.0
*/
has(key: string): boolean;
/**
* prop
* add a key with given value
* @param value
* @param key
* @since v1.1.0
*/
add(value: IPublicTypeCompositeValue, key?: string | number | undefined): any;
}
export interface IPublicModelProps extends IBaseModelProps<IPublicModelProp> {}

View File

@ -1,31 +0,0 @@
import { ComponentType, ReactElement } from 'react';
export interface IBaseModelResource<
Resource
> {
get title(): string | undefined;
get id(): string | undefined;
get icon(): ReactElement | undefined | ComponentType;
get options(): Record<string, any>;
get name(): string | undefined;
get type(): string | undefined;
get category(): string | undefined;
get children(): Resource[];
get viewName(): string | undefined;
get description(): string | undefined;
get config(): {
[key: string]: any;
} | undefined;
}
export type IPublicModelResource = IBaseModelResource<IPublicModelResource>;

Some files were not shown because too many files have changed in this diff Show More