@tmagic/editor 1.5.16 → 1.5.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tmagic-editor.js +112 -50
- package/dist/tmagic-editor.umd.cjs +110 -48
- package/package.json +7 -7
- package/src/fields/Code.vue +4 -18
- package/src/fields/CodeLink.vue +2 -10
- package/src/fields/CodeSelect.vue +2 -11
- package/src/fields/CodeSelectCol.vue +2 -1
- package/src/fields/CondOpSelect.vue +1 -2
- package/src/fields/DataSourceFieldSelect/Index.vue +1 -2
- package/src/fields/DataSourceFields.vue +4 -10
- package/src/fields/DataSourceInput.vue +4 -13
- package/src/fields/DataSourceMethodSelect.vue +2 -1
- package/src/fields/DataSourceMethods.vue +4 -11
- package/src/fields/DataSourceMocks.vue +4 -11
- package/src/fields/DataSourceSelect.vue +9 -2
- package/src/fields/DisplayConds.vue +4 -12
- package/src/fields/EventSelect.vue +3 -1
- package/src/fields/KeyValue.vue +4 -14
- package/src/fields/PageFragmentSelect.vue +1 -2
- package/src/fields/UISelect.vue +2 -2
- package/src/initService.ts +18 -20
- package/src/services/dep.ts +54 -4
- package/src/type.ts +2 -103
- package/src/utils/data-source/formConfigs/base.ts +4 -5
- package/src/utils/data-source/formConfigs/http.ts +3 -3
- package/src/utils/dep/worker.ts +63 -0
- package/src/utils/index.ts +1 -1
- package/types/index.d.ts +238 -896
- /package/src/utils/{idle-task.ts → dep/idle-task.ts} +0 -0
package/src/type.ts
CHANGED
|
@@ -21,27 +21,8 @@ import type EventEmitter from 'events';
|
|
|
21
21
|
import Sortable, { type Options, type SortableEvent } from 'sortablejs';
|
|
22
22
|
import type { PascalCasedProperties } from 'type-fest';
|
|
23
23
|
|
|
24
|
-
import type {
|
|
25
|
-
|
|
26
|
-
CodeBlockDSL,
|
|
27
|
-
DataSourceFieldType,
|
|
28
|
-
DataSourceSchema,
|
|
29
|
-
Id,
|
|
30
|
-
MApp,
|
|
31
|
-
MContainer,
|
|
32
|
-
MNode,
|
|
33
|
-
MPage,
|
|
34
|
-
MPageFragment,
|
|
35
|
-
} from '@tmagic/core';
|
|
36
|
-
import type {
|
|
37
|
-
ChildConfig,
|
|
38
|
-
FilterFunction,
|
|
39
|
-
FormConfig,
|
|
40
|
-
FormItem,
|
|
41
|
-
FormState,
|
|
42
|
-
Input,
|
|
43
|
-
TableColumnConfig,
|
|
44
|
-
} from '@tmagic/form';
|
|
24
|
+
import type { CodeBlockContent, CodeBlockDSL, Id, MApp, MContainer, MNode, MPage, MPageFragment } from '@tmagic/core';
|
|
25
|
+
import type { FormConfig, TableColumnConfig } from '@tmagic/form';
|
|
45
26
|
import type StageCore from '@tmagic/stage';
|
|
46
27
|
import type {
|
|
47
28
|
ContainerHighlightType,
|
|
@@ -562,25 +543,6 @@ export interface HistoryState {
|
|
|
562
543
|
canUndo: boolean;
|
|
563
544
|
}
|
|
564
545
|
|
|
565
|
-
export interface EventSelectConfig {
|
|
566
|
-
name: string;
|
|
567
|
-
type: 'event-select';
|
|
568
|
-
src: 'datasource' | 'component';
|
|
569
|
-
labelWidth?: string;
|
|
570
|
-
/** 事件名称表单配置 */
|
|
571
|
-
eventNameConfig?: FormItem;
|
|
572
|
-
/** 动作类型配置 */
|
|
573
|
-
actionTypeConfig?: FormItem;
|
|
574
|
-
/** 联动组件配置 */
|
|
575
|
-
targetCompConfig?: FormItem;
|
|
576
|
-
/** 联动组件动作配置 */
|
|
577
|
-
compActionConfig?: FormItem;
|
|
578
|
-
/** 联动代码配置 */
|
|
579
|
-
codeActionConfig?: FormItem;
|
|
580
|
-
/** 联动数据源配置 */
|
|
581
|
-
dataSourceActionConfig?: FormItem;
|
|
582
|
-
}
|
|
583
|
-
|
|
584
546
|
export enum KeyBindingCommand {
|
|
585
547
|
/** 复制 */
|
|
586
548
|
COPY_NODE = 'tmagic-system-copy-node',
|
|
@@ -636,69 +598,6 @@ export interface KeyBindingCacheItem {
|
|
|
636
598
|
bound: boolean;
|
|
637
599
|
}
|
|
638
600
|
|
|
639
|
-
export interface CodeSelectColConfig extends FormItem {
|
|
640
|
-
type: 'code-select-col';
|
|
641
|
-
/** 是否可以编辑代码块,disable表示的是是否可以选择代码块 */
|
|
642
|
-
notEditable?: boolean | FilterFunction;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
export interface PageFragmentSelectConfig extends FormItem {
|
|
646
|
-
type: 'page-fragment-select';
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
export interface DataSourceSelect extends FormItem, Input {
|
|
650
|
-
type: 'data-source-select';
|
|
651
|
-
/** 数据源类型: base、http... */
|
|
652
|
-
dataSourceType?: string;
|
|
653
|
-
/** 是否要编译成数据源的data。
|
|
654
|
-
* id: 不编译,就是要数据源id;
|
|
655
|
-
* value: 要编译(数据源data)
|
|
656
|
-
* */
|
|
657
|
-
value?: 'id' | 'value';
|
|
658
|
-
/** 是否可以编辑数据源,disable表示的是是否可以选择数据源 */
|
|
659
|
-
notEditable?: boolean | FilterFunction;
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
export interface DataSourceMethodSelectConfig extends FormItem {
|
|
663
|
-
type: 'data-source-method-select';
|
|
664
|
-
/** 是否可以编辑数据源,disable表示的是是否可以选择数据源 */
|
|
665
|
-
notEditable?: boolean | FilterFunction;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
export interface DataSourceFieldSelectConfig extends FormItem {
|
|
669
|
-
type: 'data-source-field-select';
|
|
670
|
-
/**
|
|
671
|
-
* 是否要编译成数据源的data。
|
|
672
|
-
* key: 不编译,就是要数据源id和field name;
|
|
673
|
-
* value: 要编译(数据源data[`${filed}`])
|
|
674
|
-
* */
|
|
675
|
-
value?: 'key' | 'value';
|
|
676
|
-
/** 是否严格的遵守父子节点不互相关联 */
|
|
677
|
-
checkStrictly?:
|
|
678
|
-
| boolean
|
|
679
|
-
| ((
|
|
680
|
-
mForm: FormState | undefined,
|
|
681
|
-
data: {
|
|
682
|
-
model: Record<any, any>;
|
|
683
|
-
values: Record<any, any>;
|
|
684
|
-
parent?: Record<any, any>;
|
|
685
|
-
formValue: Record<any, any>;
|
|
686
|
-
prop: string;
|
|
687
|
-
config: DataSourceFieldSelectConfig;
|
|
688
|
-
dataSource?: DataSourceSchema;
|
|
689
|
-
},
|
|
690
|
-
) => boolean);
|
|
691
|
-
dataSourceFieldType?: DataSourceFieldType[];
|
|
692
|
-
fieldConfig?: ChildConfig;
|
|
693
|
-
/** 是否可以编辑数据源,disable表示的是是否可以选择数据源 */
|
|
694
|
-
notEditable?: boolean | FilterFunction;
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
export interface CondOpSelectConfig extends FormItem {
|
|
698
|
-
type: 'cond-op';
|
|
699
|
-
parentFields?: string[];
|
|
700
|
-
}
|
|
701
|
-
|
|
702
601
|
/** 可新增的数据源类型选项 */
|
|
703
602
|
export interface DatasourceTypeOption {
|
|
704
603
|
/** 数据源类型 */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { defineFormConfig } from '@tmagic/form';
|
|
2
2
|
|
|
3
|
-
export default
|
|
4
|
-
|
|
3
|
+
export default () =>
|
|
4
|
+
defineFormConfig([
|
|
5
5
|
{
|
|
6
6
|
name: 'id',
|
|
7
7
|
type: 'hidden',
|
|
@@ -26,5 +26,4 @@ export default function (): FormConfig {
|
|
|
26
26
|
name: 'description',
|
|
27
27
|
text: '描述',
|
|
28
28
|
},
|
|
29
|
-
];
|
|
30
|
-
}
|
|
29
|
+
]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineFormConfig } from '@tmagic/form';
|
|
2
2
|
|
|
3
|
-
export default [
|
|
3
|
+
export default defineFormConfig([
|
|
4
4
|
{
|
|
5
5
|
name: 'autoFetch',
|
|
6
6
|
text: '自动请求',
|
|
@@ -59,4 +59,4 @@ export default [
|
|
|
59
59
|
},
|
|
60
60
|
],
|
|
61
61
|
},
|
|
62
|
-
]
|
|
62
|
+
]);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCodeBlockTarget,
|
|
3
|
+
createDataSourceCondTarget,
|
|
4
|
+
createDataSourceMethodTarget,
|
|
5
|
+
createDataSourceTarget,
|
|
6
|
+
type DepData,
|
|
7
|
+
DepTargetType,
|
|
8
|
+
type Id,
|
|
9
|
+
type MApp,
|
|
10
|
+
traverseTarget,
|
|
11
|
+
Watcher,
|
|
12
|
+
} from '@tmagic/core';
|
|
13
|
+
|
|
14
|
+
import { error } from '../logger';
|
|
15
|
+
|
|
16
|
+
onmessage = (e) => {
|
|
17
|
+
const watcher = new Watcher({ initialTargets: {} });
|
|
18
|
+
|
|
19
|
+
const { dsl } = e.data;
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
// eslint-disable-next-line no-eval
|
|
23
|
+
const mApp: MApp = eval(`(${dsl})`);
|
|
24
|
+
|
|
25
|
+
if (!mApp) {
|
|
26
|
+
postMessage({});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (mApp.codeBlocks) {
|
|
30
|
+
for (const [id, code] of Object.entries(mApp.codeBlocks)) {
|
|
31
|
+
watcher.addTarget(createCodeBlockTarget(id, code));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (mApp.dataSources) {
|
|
36
|
+
for (const ds of mApp.dataSources) {
|
|
37
|
+
watcher.addTarget(createDataSourceTarget(ds, {}));
|
|
38
|
+
watcher.addTarget(createDataSourceMethodTarget(ds, {}));
|
|
39
|
+
watcher.addTarget(createDataSourceCondTarget(ds, {}));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
watcher.collectByCallback(mApp.items, undefined, ({ node, target }) => {
|
|
44
|
+
watcher.collectItem(node, target, { pageId: node.id }, true);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const data: Record<string, Record<Id, DepData>> = {
|
|
48
|
+
[DepTargetType.DATA_SOURCE]: {},
|
|
49
|
+
[DepTargetType.DATA_SOURCE_METHOD]: {},
|
|
50
|
+
[DepTargetType.DATA_SOURCE_COND]: {},
|
|
51
|
+
[DepTargetType.CODE_BLOCK]: {},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
traverseTarget(watcher.getTargetsList(), (target) => {
|
|
55
|
+
data[target.type][target.id] = target.deps;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
postMessage(data);
|
|
59
|
+
} catch (e: any) {
|
|
60
|
+
error(e);
|
|
61
|
+
postMessage({});
|
|
62
|
+
}
|
|
63
|
+
};
|
package/src/utils/index.ts
CHANGED
|
@@ -22,7 +22,7 @@ export * from './logger';
|
|
|
22
22
|
export * from './editor';
|
|
23
23
|
export * from './operator';
|
|
24
24
|
export * from './data-source';
|
|
25
|
-
export * from './idle-task';
|
|
25
|
+
export * from './dep/idle-task';
|
|
26
26
|
export * from './scroll-viewer';
|
|
27
27
|
export * from './tree';
|
|
28
28
|
export * from './undo-redo';
|