Skip to content

Commit e53f72f

Browse files
committed
feat: 修复构建问题
1 parent 3b2ffd1 commit e53f72f

12 files changed

Lines changed: 184 additions & 75 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
module.exports = {
2+
'env': {
3+
'browser': true,
4+
'es2021': true
5+
},
6+
'extends': [
7+
'eslint:recommended',
8+
'plugin:react/recommended',
9+
'plugin:@typescript-eslint/recommended',
10+
"react-app",
11+
],
12+
'parser': '@typescript-eslint/parser',
13+
'parserOptions': {
14+
'ecmaFeatures': {
15+
'jsx': true
16+
},
17+
'ecmaVersion': 'latest',
18+
'sourceType': 'module'
19+
},
20+
'plugins': [
21+
'@typescript-eslint'
22+
],
23+
'rules': {
24+
'indent': [
25+
'error',
26+
2
27+
],
28+
'linebreak-style': [
29+
'error',
30+
'unix'
31+
],
32+
'quotes': [
33+
'error',
34+
'single'
35+
],
36+
'semi': [
37+
'error',
38+
'always'
39+
],
40+
"@typescript-eslint/ban-ts-comment": 0
41+
}
42+
};

packages/plugin-multiple-editor/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@
9898
"postcss-normalize": "^10.0.1",
9999
"postcss-preset-env": "^7.0.1",
100100
"prompts": "^2.4.2",
101-
"react": "^17.0.2",
101+
"react": "*",
102102
"react-app-polyfill": "^3.0.0",
103103
"react-dev-utils": "^12.0.0",
104-
"react-dom": "^17.0.2",
104+
"react-dom": "*",
105105
"react-refresh": "^0.11.0",
106106
"resolve": "^1.20.0",
107107
"resolve-url-loader": "^4.0.0",

packages/plugin-multiple-editor/src/Controller.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { Project, Event } from '@alilc/lowcode-shell';
2-
import { ProjectSchema } from '@alilc/lowcode-types';
3-
import { skeleton } from '@alilc/lowcode-engine';
2+
import { skeleton, common } from '@alilc/lowcode-engine';
43
import {
54
beautifyCSS,
65
compatGetSourceCodeMap,
@@ -11,7 +10,6 @@ import {
1110
treeToMap,
1211
} from './utils';
1312
import { FunctionEventParams, Monaco, ObjectType } from './types';
14-
import { common } from '@alilc/lowcode-engine';
1513
import type { editor } from 'monaco-editor';
1614
import {
1715
addFunction,
@@ -29,7 +27,7 @@ export * from './EditorHook';
2927

3028
export interface EditorControllerState {
3129
declarationsMap: Record<string, string>;
32-
extraLibs: { path: string; content: string }[];
30+
extraLibs: Array<{ path: string; content: string }>;
3331
}
3432

3533
export type HookHandleFn<T = any> = (fn: T) => () => void;
@@ -51,7 +49,7 @@ export class EditorController extends EditorHook {
5149

5250
defaultFiles: ObjectType<string>;
5351

54-
public monaco?: Monaco;
52+
monaco?: Monaco;
5553

5654
private codeTemp?: CodeTemp;
5755

@@ -61,20 +59,20 @@ export class EditorController extends EditorHook {
6159

6260
private state: EditorControllerState;
6361

64-
public codeEditor?: editor.IStandaloneCodeEditor;
62+
codeEditor?: editor.IStandaloneCodeEditor;
6563

6664
private codeEditorCtx?: EditorContextType;
6765

68-
public service!: Service;
66+
service!: Service;
6967

70-
public onImportSchema: HookHandleFn<
71-
(schema: ProjectSchema) => void | Promise<void>
72-
> = this.hookFactory(HookKeys.onImport);
68+
onImportSchema: HookHandleFn<(schema: any) => void | Promise<void>> =
69+
this.hookFactory(HookKeys.onImport);
7370

74-
public onSourceCodeChange: HookHandleFn<(code: any) => void> =
75-
this.hookFactory(HookKeys.onSourceCodeChange);
71+
onSourceCodeChange: HookHandleFn<(code: any) => void> = this.hookFactory(
72+
HookKeys.onSourceCodeChange
73+
);
7674

77-
public onEditCodeChange: HookHandleFn<
75+
onEditCodeChange: HookHandleFn<
7876
(code: { content: string; file: string }) => void
7977
> = this.hookFactory(HookKeys.onEditCodeChange);
8078

@@ -124,7 +122,7 @@ export class EditorController extends EditorHook {
124122
this.applyLibs();
125123
}
126124

127-
addComponentDeclarations(list: [string, string][] = []) {
125+
addComponentDeclarations(list: Array<[string, string]> = []) {
128126
for (const [key, dec] of list) {
129127
this.state.declarationsMap[key] = dec;
130128
}
@@ -133,7 +131,7 @@ export class EditorController extends EditorHook {
133131
}
134132

135133
private publishExtraLib() {
136-
const libs: { path: string; content: string }[] = [];
134+
const libs: Array<{ path: string; content: string }> = [];
137135
this.extraLibMap.forEach((content, path) => libs.push({ content, path }));
138136
this.state.extraLibs = libs;
139137
this.publish();
@@ -156,7 +154,7 @@ export class EditorController extends EditorHook {
156154
const { getMonaco } = await import(
157155
'@alilc/lowcode-plugin-base-monaco-editor'
158156
);
159-
this.monaco = await getMonaco(undefined);
157+
this.monaco = await getMonaco(undefined) as any;
160158
}
161159
const decStr = Object.keys(this.state.declarationsMap).reduce(
162160
(v, k) => `${v}\n${k}: ${this.state.declarationsMap[k]};\n`,
@@ -175,7 +173,7 @@ export class EditorController extends EditorHook {
175173
});
176174
}
177175

178-
getSchema(pure?: boolean): ProjectSchema {
176+
getSchema(pure?: boolean): any {
179177
const schema = this.project.exportSchema(
180178
common.designerCabin.TransformStage.Save
181179
);
@@ -192,7 +190,7 @@ export class EditorController extends EditorHook {
192190
return schema;
193191
}
194192

195-
importSchema(schema: ProjectSchema) {
193+
importSchema(schema: any) {
196194
this.project.importSchema(schema);
197195
this.initCodeTempBySchema(schema);
198196
this.triggerHook(HookKeys.onImport, schema);
@@ -219,7 +217,7 @@ export class EditorController extends EditorHook {
219217
};
220218
}
221219

222-
public initCodeTempBySchema(schema: ProjectSchema) {
220+
initCodeTempBySchema(schema: any) {
223221
const componentSchema = schema.componentsTree[0] || {};
224222
const { css, methods, state, lifeCycles } = componentSchema;
225223
const codeMap = (componentSchema as any)._sourceCodeMap;
@@ -343,7 +341,7 @@ export class EditorController extends EditorHook {
343341
return true;
344342
}
345343

346-
public resetSaveStatus() {
344+
resetSaveStatus() {
347345
this.codeEditorCtx?.updateState({ modifiedKeys: [] });
348346
}
349347

packages/plugin-multiple-editor/src/dev-config/sample-plugins/delete-hidden-transducer/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { ILowCodePluginContext, project } from '@alilc/lowcode-engine';
2-
import { CompositeObject, TransformStage } from '@alilc/lowcode-types';
1+
import { project } from '@alilc/lowcode-engine';
2+
import { IPublicEnumTransformStage } from '@alilc/lowcode-types';
33

4-
export const deleteHiddenTransducer = (ctx: ILowCodePluginContext) => {
4+
export const deleteHiddenTransducer = (ctx: any) => {
55
return {
66
name: 'deleteHiddenTransducer',
77
async init() {
8-
project.addPropsTransducer((props: CompositeObject): CompositeObject => {
8+
project.addPropsTransducer((props: any): any => {
99
delete props.hidden;
1010
return props;
11-
}, TransformStage.Save);
11+
}, IPublicEnumTransformStage.Save);
1212
},
1313
};
1414
}

packages/plugin-multiple-editor/src/dev-config/sample-plugins/set-ref-prop/index.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import {
2-
TransformedComponentMetadata,
3-
FieldConfig,
4-
} from '@alilc/lowcode-types';
51
import { v4 as uuidv4 } from 'uuid';
62
import { material } from '@alilc/lowcode-engine';
73

8-
function addonCombine(metadata: TransformedComponentMetadata) {
4+
function addonCombine(metadata: any) {
95
const { componentName, configure = {} } = metadata;
106

117
const isRoot: boolean =
@@ -15,9 +11,9 @@ function addonCombine(metadata: TransformedComponentMetadata) {
1511
return metadata;
1612
}
1713

18-
let advancedGroup: FieldConfig | undefined;
14+
let advancedGroup: any | undefined;
1915

20-
const refItem: FieldConfig = {
16+
const refItem: any = {
2117
title: {
2218
label: 'refId',
2319
tip: '用于获取组件实例,调用物料内部方法',
@@ -57,7 +53,7 @@ function addonCombine(metadata: TransformedComponentMetadata) {
5753
advancedGroup.items = [refItem];
5854
}
5955

60-
const advanceItems: FieldConfig[] = advancedGroup.items || [];
56+
const advanceItems: any[] = advancedGroup.items || [];
6157

6258
if (
6359
!advanceItems ||

packages/plugin-multiple-editor/src/dev-config/universal/plugin.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import {
3-
ILowCodePluginContext,
43
plugins,
54
skeleton,
65
project,
@@ -41,7 +40,7 @@ export default async function registerPlugins() {
4140
SchemaPlugin.pluginName = 'SchemaPlugin';
4241
await plugins.register(SchemaPlugin);
4342

44-
const editorInit = (ctx: ILowCodePluginContext) => {
43+
const editorInit = (ctx: any) => {
4544
return {
4645
name: 'editor-init',
4746
async init() {
@@ -66,7 +65,7 @@ export default async function registerPlugins() {
6665
editorInit.pluginName = 'editorInit';
6766
await plugins.register(editorInit);
6867

69-
const builtinPluginRegistry = (ctx: ILowCodePluginContext) => {
68+
const builtinPluginRegistry = (ctx: any) => {
7069
return {
7170
name: 'builtin-plugin-registry',
7271
async init() {
@@ -110,7 +109,7 @@ export default async function registerPlugins() {
110109
await plugins.register(builtinPluginRegistry);
111110

112111
// 设置内置 setter 和事件绑定、插件绑定面板
113-
const setterRegistry = (ctx: ILowCodePluginContext) => {
112+
const setterRegistry = (ctx: any) => {
114113
const { setterMap, pluginMap } = AliLowCodeEngineExt;
115114
return {
116115
name: 'ext-setters-registry',
@@ -145,7 +144,7 @@ export default async function registerPlugins() {
145144
// 注册中英文切换
146145
await plugins.register(ZhEnPlugin);
147146

148-
const loadAssetsSample = (ctx: ILowCodePluginContext) => {
147+
const loadAssetsSample = (ctx: any) => {
149148
return {
150149
name: 'loadAssetsSample',
151150
async init() {
@@ -170,7 +169,7 @@ export default async function registerPlugins() {
170169
await plugins.register(loadAssetsSample);
171170

172171
// 注册保存面板
173-
const saveSample = (ctx: ILowCodePluginContext) => {
172+
const saveSample = (ctx: any) => {
174173
return {
175174
name: 'saveSample',
176175
async init() {
@@ -204,7 +203,7 @@ export default async function registerPlugins() {
204203
saveSample.pluginName = 'saveSample';
205204
await plugins.register(saveSample);
206205

207-
const previewSample = (ctx: ILowCodePluginContext) => {
206+
const previewSample = (ctx: any) => {
208207
return {
209208
name: 'previewSample',
210209
async init() {
@@ -228,7 +227,7 @@ export default async function registerPlugins() {
228227
previewSample.pluginName = 'previewSample';
229228
await plugins.register(previewSample);
230229

231-
const customSetter = (ctx: ILowCodePluginContext) => {
230+
const customSetter = (ctx: any) => {
232231
return {
233232
name: '___registerCustomSetter___',
234233
async init() {

packages/plugin-multiple-editor/src/dev-config/universal/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { material, project } from '@alilc/lowcode-engine';
22
import { filterPackages } from '@alilc/lowcode-plugin-inject';
33
import { Message, Dialog } from '@alifd/next';
4-
import { TransformStage } from '@alilc/lowcode-types';
4+
import { IPublicEnumTransformStage } from '@alilc/lowcode-types';
55

66
export const loadIncrementalAssets = () => {
77
material?.onChangeAssets(() => {
@@ -252,7 +252,7 @@ const setProjectSchemaToLocalStorage = (scenarioName: string) => {
252252
}
253253
window.localStorage.setItem(
254254
getLSName(scenarioName),
255-
JSON.stringify(project.exportSchema(TransformStage.Save))
255+
JSON.stringify(project.exportSchema(IPublicEnumTransformStage.Save))
256256
);
257257
};
258258

packages/plugin-multiple-editor/src/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
import { project, editor } from '@alilc/lowcode-engine';
2-
import type {
3-
ILowCodePluginConfig,
4-
ILowCodePluginContext,
5-
} from '@alilc/lowcode-engine';
62
import { controller as baseController } from '@alilc/lowcode-plugin-base-monaco-editor/es/controller';
73
import { EditorProvider } from './Context';
84
import MultipleFileEditor from './MultipleFileEditor';
@@ -26,7 +22,7 @@ const pluginCodeEditor = (
2622
defaultFiles?: Record<string, string>;
2723
} = {}
2824
) => {
29-
const plugin = (ctx: ILowCodePluginContext): ILowCodePluginConfig => {
25+
const plugin = (ctx: any): any => {
3026
return {
3127
exports: () => ({}),
3228
init() {

packages/plugin-multiple-editor/src/types/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { JSExpression } from '@alilc/lowcode-types';
2-
31
export type Monaco = typeof import('monaco-editor/esm/vs/editor/editor.api');
42
export type ObjectType<T = any> = Record<string, T>;
53

6-
export interface IState extends JSExpression {
4+
export interface IState {
75
originCode?: string;
86
}
97

packages/plugin-multiple-editor/src/utils/code.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
import {
2-
isJSExpression,
3-
ProjectSchema,
4-
RootSchema,
5-
JSFunction,
6-
JSExpression,
7-
} from '@alilc/lowcode-types';
81
// @ts-ignore
92
import prettier from 'prettier/esm/standalone.mjs';
103
import parserBabel from 'prettier/parser-babel';
@@ -30,7 +23,7 @@ const prettierCssConfig = {
3023
printWidth: 120, // 超过120个字符强制换行
3124
};
3225

33-
export const initCode = (componentSchema: RootSchema | undefined) => {
26+
export const initCode = (componentSchema: any | undefined) => {
3427
return (
3528
(componentSchema as any)?.originCode ||
3629
`export default class LowcodeComponent extends Component {
@@ -79,6 +72,6 @@ export const beautifyCSS = (input: string, options: any): string => {
7972
};
8073

8174
// schema转换为CSS代码
82-
export const schema2CssCode = (schema: ProjectSchema, prettierOptions: any) => {
75+
export const schema2CssCode = (schema: any, prettierOptions: any) => {
8376
return beautifyCSS(schema.componentsTree[0]?.css || '', prettierOptions);
8477
};

0 commit comments

Comments
 (0)