mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-04-18 03:18:06 +00:00
refactor: remove useless files
This commit is contained in:
parent
450d08e500
commit
738f7af6de
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,12 +1,6 @@
|
||||
# project custom
|
||||
build
|
||||
dist
|
||||
packages/*/lib/
|
||||
packages/*/es/
|
||||
packages/*/dist/
|
||||
packages/*/output/
|
||||
packages/*/temp/
|
||||
packages/demo/
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
pnpm-lock.yaml
|
||||
|
||||
@ -1,2 +0,0 @@
|
||||
export * from './preference';
|
||||
export * from './hotkey';
|
||||
@ -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();
|
||||
});
|
||||
});
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"emitDeclarationOnly": true,
|
||||
"declaration": true,
|
||||
"outDir": "temp",
|
||||
"stripInternal": true,
|
||||
"paths": {}
|
||||
}
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["src", "__tests__", "src/configuration.ts"]
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import baseConfigFn from '../../vite.base.config'
|
||||
|
||||
export default defineConfig(async () => {
|
||||
return baseConfigFn({
|
||||
name: 'LowCodeEditorCore',
|
||||
})
|
||||
});
|
||||
@ -1,15 +1,14 @@
|
||||
{
|
||||
"name": "@alilc/lowcode-core",
|
||||
"version": "2.0.0-beta.0",
|
||||
"description": "Core Api for Ali lowCode engine",
|
||||
"license": "MIT",
|
||||
"name": "@ali/lowcode-engine-core",
|
||||
"description": "",
|
||||
"type": "module",
|
||||
"main": "dist/low-code-editor-core.js",
|
||||
"module": "dist/low-code-editor-core.js",
|
||||
"main": "dist/engine-core.js",
|
||||
"module": "dist/engine-core.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/low-code-editor-core.js",
|
||||
"import": "./dist/engine-core.js",
|
||||
"require": "./dist/engine-core.cjs",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"./dist/": {
|
||||
@ -17,10 +16,6 @@
|
||||
"require": "./dist/"
|
||||
}
|
||||
},
|
||||
"sideEffects": [
|
||||
"*.css",
|
||||
"*.less"
|
||||
],
|
||||
"files": [
|
||||
"dist",
|
||||
"src",
|
||||
@ -29,22 +24,18 @@
|
||||
"scripts": {
|
||||
"build:target": "vite build",
|
||||
"build:dts": "tsc -p tsconfig.declaration.json && node ../../scripts/rollup-dts.mjs",
|
||||
"test": "vitest",
|
||||
"test:cov": ""
|
||||
"test": "vitest"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@alilc/lowcode-shared": "workspace:*",
|
||||
"lodash-es": "^4.17.21"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/react": "^18.2.0",
|
||||
"@types/react-dom": "^18.2.0"
|
||||
"@types/lodash-es": "^4.17.12"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@alilc/lowcode-shared": "workspace:*",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
"@alilc/lowcode-shared": "workspace:*"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public",
|
||||
@ -52,7 +43,7 @@
|
||||
},
|
||||
"repository": {
|
||||
"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",
|
||||
"bugs": "https://github.com/alibaba/lowcode-engine/issues",
|
||||
0
packages/engine-core/src/index.ts
Normal file
0
packages/engine-core/src/index.ts
Normal file
9
packages/engine-core/vite.config.ts
Normal file
9
packages/engine-core/vite.config.ts
Normal 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'],
|
||||
});
|
||||
});
|
||||
@ -29,28 +29,17 @@
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@alifd/next": "^1.27.8",
|
||||
"@alilc/lowcode-designer": "workspace:*",
|
||||
"@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",
|
||||
"@alilc/lowcode-shared": "workspace:*",
|
||||
"lodash-es": "^4.17.21",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@alifd/theme-lowcode-dark": "^0.2.0",
|
||||
"@alifd/theme-lowcode-light": "^0.2.0",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/react": "^18.2.0",
|
||||
"@types/react-dom": "^18.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@alifd/next": "^1.27.8",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
},
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
import { bootstrapModules, createInstance } from '@alilc/lowcode-core';
|
||||
import { EngineMain } from './main';
|
||||
|
||||
export async function init(
|
||||
container?: HTMLElement,
|
||||
options?: IPublicTypeEngineOptions,
|
||||
@ -11,7 +8,4 @@ export async function init(
|
||||
container.id = 'engine';
|
||||
document.body.appendChild(container);
|
||||
}
|
||||
|
||||
bootstrapModules();
|
||||
createInstance(EngineMain).startup(container);
|
||||
}
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
import { Provide } from '@alilc/lowcode-core';
|
||||
import { IWorkspaceMainService } from './workspace';
|
||||
import { InstantiationService } from '@alilc/lowcode-shared';
|
||||
|
||||
@Provide('EngineMain')
|
||||
export class EngineMain {
|
||||
constructor(@IWorkspaceMainService private workspaceMainService: IWorkspaceMainService) {}
|
||||
export class MainEngineApplication {
|
||||
instantiationService = new InstantiationService();
|
||||
|
||||
startup(container: HTMLElement): void {
|
||||
console.log('%c [ container ]-9', 'font-size:13px; background:pink; color:#bf2c9f;', container);
|
||||
this.workspaceMainService.initialize();
|
||||
constructor() {
|
||||
this.instantiationService.bootstrapModules();
|
||||
}
|
||||
|
||||
startup(container: HTMLElement): void {}
|
||||
}
|
||||
|
||||
8
packages/engine/src/services/command/commandService.ts
Normal file
8
packages/engine/src/services/command/commandService.ts
Normal 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 {}
|
||||
@ -1,6 +1,6 @@
|
||||
import { get as lodashGet, isPlainObject, cloneDeep } from 'lodash-es';
|
||||
import { type PlainObject } from '@alilc/lowcode-shared/src/types';
|
||||
import { invariant } from '@alilc/lowcode-shared/src/utils';
|
||||
import { type PlainObject } from '@alilc/lowcode-shared';
|
||||
import { invariant } from '@alilc/lowcode-shared';
|
||||
|
||||
export class Configuration<Config extends PlainObject, K extends keyof Config = keyof Config> {
|
||||
private config: Config;
|
||||
@ -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 {}
|
||||
@ -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...');
|
||||
}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
export * from './interface';
|
||||
@ -1,7 +0,0 @@
|
||||
import { createDecorator } from '@alilc/lowcode-core';
|
||||
|
||||
export interface IWorkspaceMainService {
|
||||
initialize(): void;
|
||||
}
|
||||
|
||||
export const IWorkspaceMainService = createDecorator<IWorkspaceMainService>('WorkspaceMainService');
|
||||
@ -1,13 +1,15 @@
|
||||
import { defineConfig, mergeConfig } from 'vite';
|
||||
import baseConfigFn from '../../vite.base.config'
|
||||
import baseConfigFn from '../../vite.base.config';
|
||||
|
||||
export default defineConfig(async () => {
|
||||
const baseConfig = await baseConfigFn({
|
||||
name: 'AliLowCodeEngine',
|
||||
defaultFormats: ['es', 'cjs'],
|
||||
})
|
||||
});
|
||||
|
||||
return mergeConfig(baseConfig, defineConfig({
|
||||
return mergeConfig(
|
||||
baseConfig,
|
||||
defineConfig({
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: {
|
||||
@ -15,11 +17,10 @@ export default defineConfig(async () => {
|
||||
globals: {
|
||||
react: 'React',
|
||||
'react-dom': 'ReactDOM',
|
||||
'@alifd/next': 'Next'
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}))
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@ -36,30 +36,15 @@ const lowCodeComponentsCache = new Map<string, ReactComponent>();
|
||||
|
||||
export function getComponentByName(
|
||||
name: string,
|
||||
{ packageManager, boostsManager }: RenderContext,
|
||||
{ packageManager }: RenderContext,
|
||||
componentOptions: ComponentOptions = {},
|
||||
): ReactComponent {
|
||||
const result = lowCodeComponentsCache.get(name) || packageManager.getComponent(name);
|
||||
|
||||
if (isLowCodeComponentPackage(result)) {
|
||||
const { schema, ...metadata } = result;
|
||||
const { componentsMap, componentsTree, utils, i18n } = schema;
|
||||
|
||||
if (componentsMap.length > 0) {
|
||||
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], {
|
||||
const lowCodeComponent = createComponent(schema, {
|
||||
...componentOptions,
|
||||
displayName: name,
|
||||
modelOptions: {
|
||||
|
||||
@ -3,7 +3,7 @@ export { createRenderer } from './main';
|
||||
export { definePackageLoader } from './services/package';
|
||||
export { LifecyclePhase } from './services/lifeCycleService';
|
||||
export { Widget } from './services/widget';
|
||||
export * from './utils/node';
|
||||
export * from '../../shared/src/utils/node';
|
||||
export * from './utils/value';
|
||||
|
||||
/* --------------- types ---------------- */
|
||||
|
||||
@ -6,7 +6,7 @@ import {
|
||||
isJSFunction,
|
||||
} from '@alilc/lowcode-shared';
|
||||
import { type ICodeScope, CodeScope } from './codeScope';
|
||||
import { isNode } from '../../utils/node';
|
||||
import { isNode } from '../../../../shared/src/utils/node';
|
||||
import { mapValue } from '../../utils/value';
|
||||
import { evaluate } from './evaluate';
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
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
|
||||
|
||||
@ -1,12 +1,24 @@
|
||||
import { Provide, createDecorator, EventEmitter, EventDisposable } from '@alilc/lowcode-shared';
|
||||
|
||||
/**
|
||||
* 生命周期阶段
|
||||
*/
|
||||
export const enum LifecyclePhase {
|
||||
/**
|
||||
* 开始
|
||||
*/
|
||||
Starting = 1,
|
||||
|
||||
/**
|
||||
* 配置解析完成
|
||||
*/
|
||||
OptionsResolved = 2,
|
||||
|
||||
/**
|
||||
* 已就绪
|
||||
*/
|
||||
Ready = 3,
|
||||
|
||||
/**
|
||||
* 销毁中
|
||||
*/
|
||||
Destroying = 4,
|
||||
}
|
||||
|
||||
|
||||
@ -3,5 +3,5 @@
|
||||
"compilerOptions": {
|
||||
"outDir": "dist"
|
||||
},
|
||||
"include": ["src"]
|
||||
"include": ["src", "../shared/src/utils/node.ts"]
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { Package } from './specs/asset-spec';
|
||||
import { Project } from './specs/lowcode-spec';
|
||||
import { ComponentTreeRoot } from './specs/lowcode-spec';
|
||||
|
||||
export interface ProCodeComponent extends Package {
|
||||
package: string;
|
||||
@ -11,5 +11,5 @@ export interface LowCodeComponent extends Package {
|
||||
id: string;
|
||||
type: 'lowCode';
|
||||
componentName: string;
|
||||
schema: Project;
|
||||
schema: ComponentTreeRoot;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* https://lowcode-engine.cn/site/docs/specs/assets-spec
|
||||
* 低代码引擎资产包协议规范
|
||||
*/
|
||||
import { Project } from './lowcode-spec';
|
||||
import { ComponentTreeRoot } from './lowcode-spec';
|
||||
|
||||
export interface Package {
|
||||
/**
|
||||
@ -40,7 +40,7 @@ export interface Package {
|
||||
/**
|
||||
* 低代码组件的 schema 内容
|
||||
*/
|
||||
schema?: Project;
|
||||
schema?: ComponentTreeRoot;
|
||||
/**
|
||||
* 当前资源所依赖的其他资源包的 id 列表
|
||||
*/
|
||||
|
||||
@ -5,3 +5,4 @@ export * from './type-guards';
|
||||
export * from './platform';
|
||||
export * from './callback';
|
||||
export * from './async';
|
||||
export * from './node';
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* 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;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -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"
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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 };
|
||||
@ -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';
|
||||
@ -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';
|
||||
@ -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';
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}>;
|
||||
}
|
||||
@ -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;
|
||||
};
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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';
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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> {}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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 widget,and 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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
export enum IPublicEnumContextMenuType {
|
||||
SEPARATOR = 'separator',
|
||||
// 'menuItem'
|
||||
MENU_ITEM = 'menuItem',
|
||||
// 'nodeTree'
|
||||
NODE_TREE = 'nodeTree',
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
export enum IPublicEnumDragObjectType {
|
||||
Node = 'node',
|
||||
NodeData = 'nodedata',
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
/**
|
||||
* 所有公开可用的事件名定义
|
||||
* All public event names
|
||||
* names should be like 'namespace.modelName.whatHappened'
|
||||
*
|
||||
*/
|
||||
// eslint-disable-next-line no-shadow
|
||||
export enum IPublicEnumEventNames {
|
||||
}
|
||||
@ -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';
|
||||
@ -1,6 +0,0 @@
|
||||
export enum IPublicEnumPluginRegisterLevel {
|
||||
Default = 'default',
|
||||
Workspace = 'workspace',
|
||||
Resource = 'resource',
|
||||
EditorView = 'editorView',
|
||||
}
|
||||
@ -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'
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
export enum IPublicEnumTransformStage {
|
||||
Render = 'render',
|
||||
Serilize = 'serilize',
|
||||
Save = 'save',
|
||||
Clone = 'clone',
|
||||
Init = 'init',
|
||||
Upgrade = 'upgrade',
|
||||
}
|
||||
@ -1,4 +0,0 @@
|
||||
export const enum IPublicEnumTransitionType {
|
||||
/** 节点更新后重绘处理 */
|
||||
REPAINT,
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
export * from './type';
|
||||
export * from './api';
|
||||
export * from './model';
|
||||
export * from './enum';
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -1,7 +0,0 @@
|
||||
import { IPublicModelPluginContext } from './plugin-context';
|
||||
|
||||
export interface IPublicModelEditorView extends IPublicModelPluginContext {
|
||||
viewName: string;
|
||||
|
||||
viewType: 'editor' | 'webview';
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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';
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
|
||||
}
|
||||
@ -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> {}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
@ -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> {}
|
||||
@ -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
Loading…
x
Reference in New Issue
Block a user