@gant-lowcode/plugin-code-generator 1.0.10 → 2.0.1
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/LICENSE +21 -0
- package/{dist → es}/components/code-gen-action/index.d.ts +2 -1
- package/es/components/code-gen-action/index.js +330 -0
- package/es/components/code-gen-action/index.less +20 -0
- package/es/components/code-gen-preview/fixPreviewCode.js +100 -0
- package/{dist → es}/components/code-gen-preview/index.d.ts +3 -2
- package/es/components/code-gen-preview/index.js +5 -0
- package/es/components/code-gen-preview/index.less +16 -0
- package/{dist → es}/components/code-gen-result/index.d.ts +2 -2
- package/es/components/code-gen-result/index.js +207 -0
- package/es/components/code-gen-result/index.less +20 -0
- package/{dist → es}/components/codesandbox-preview/index.d.ts +2 -1
- package/es/components/codesandbox-preview/index.js +192 -0
- package/es/components/codesandbox-preview/index.less +18 -0
- package/{dist → es}/components/file-tree/index.d.ts +3 -2
- package/es/components/file-tree/index.js +162 -0
- package/es/components/file-tree/index.less +54 -0
- package/{dist → es}/components/file-type-icon/index.d.ts +2 -2
- package/es/components/file-type-icon/index.js +12 -0
- package/es/components/file-type-icon/index.less +77 -0
- package/{dist → es}/components/sources-view/index.d.ts +2 -1
- package/es/components/sources-view/index.js +128 -0
- package/es/components/sources-view/index.less +12 -0
- package/{dist → es}/index.d.ts +3 -4
- package/es/index.js +67 -0
- package/es/style.js +9 -0
- package/{dist → es}/types/index.d.ts +3 -3
- package/es/types/index.js +1 -0
- package/lib/components/code-gen-action/index.d.ts +7 -0
- package/lib/components/code-gen-action/index.js +336 -0
- package/lib/components/code-gen-action/index.less +20 -0
- package/lib/components/code-gen-preview/fixPreviewCode.d.ts +2 -0
- package/lib/components/code-gen-preview/fixPreviewCode.js +105 -0
- package/lib/components/code-gen-preview/index.d.ts +9 -0
- package/lib/components/code-gen-preview/index.js +9 -0
- package/lib/components/code-gen-preview/index.less +16 -0
- package/lib/components/code-gen-result/index.d.ts +14 -0
- package/lib/components/code-gen-result/index.js +215 -0
- package/lib/components/code-gen-result/index.less +20 -0
- package/lib/components/codesandbox-preview/index.d.ts +4 -0
- package/lib/components/codesandbox-preview/index.js +199 -0
- package/lib/components/codesandbox-preview/index.less +18 -0
- package/lib/components/file-tree/index.d.ts +21 -0
- package/lib/components/file-tree/index.js +170 -0
- package/lib/components/file-tree/index.less +54 -0
- package/lib/components/file-type-icon/index.d.ts +6 -0
- package/lib/components/file-type-icon/index.js +17 -0
- package/lib/components/file-type-icon/index.less +77 -0
- package/lib/components/sources-view/index.d.ts +8 -0
- package/lib/components/sources-view/index.js +135 -0
- package/lib/components/sources-view/index.less +12 -0
- package/lib/index.d.ts +27 -0
- package/lib/index.js +74 -0
- package/lib/style.js +9 -0
- package/lib/types/index.d.ts +17 -0
- package/lib/types/index.js +3 -0
- package/package.json +27 -19
- package/dist/components/code-gen-action/index.css +0 -18
- package/dist/components/code-gen-action/index.js +0 -203
- package/dist/components/code-gen-preview/fixPreviewCode.js +0 -119
- package/dist/components/code-gen-preview/index.css +0 -18
- package/dist/components/code-gen-preview/index.js +0 -9
- package/dist/components/code-gen-result/index.css +0 -18
- package/dist/components/code-gen-result/index.js +0 -147
- package/dist/components/codesandbox-preview/index.css +0 -17
- package/dist/components/codesandbox-preview/index.js +0 -147
- package/dist/components/file-tree/index.css +0 -55
- package/dist/components/file-tree/index.js +0 -138
- package/dist/components/file-type-icon/index.css +0 -73
- package/dist/components/file-type-icon/index.js +0 -10
- package/dist/components/sources-view/index.css +0 -11
- package/dist/components/sources-view/index.js +0 -128
- package/dist/index.js +0 -50
- package/dist/types/index.js +0 -1
- /package/{dist → es}/components/code-gen-preview/fixPreviewCode.d.ts +0 -0
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
.code-file-tree {
|
|
2
|
-
white-space: nowrap;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
.code-file-tree .tree-node {
|
|
6
|
-
-webkit-user-select: none;
|
|
7
|
-
user-select: none;
|
|
8
|
-
justify-content: center;
|
|
9
|
-
align-items: center;
|
|
10
|
-
display: flex;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.code-file-tree .tree-node:hover, .code-file-tree .tree-node.tree-node-selected {
|
|
14
|
-
cursor: pointer;
|
|
15
|
-
background-color: #cfd0d1;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.code-file-tree .tree-item {
|
|
19
|
-
justify-content: left;
|
|
20
|
-
align-items: center;
|
|
21
|
-
display: flex;
|
|
22
|
-
position: absolute;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.code-file-tree .tree-item > i {
|
|
26
|
-
margin-right: 8px;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.code-file-tree .tree-item .label-name {
|
|
30
|
-
text-overflow: ellipsis;
|
|
31
|
-
flex: 1;
|
|
32
|
-
min-width: 0;
|
|
33
|
-
overflow: hidden;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.code-file-tree .tree-folder:after {
|
|
37
|
-
content: "";
|
|
38
|
-
opacity: .7;
|
|
39
|
-
border-top: 6px solid #000000b3;
|
|
40
|
-
border-left: 6px solid #0000;
|
|
41
|
-
border-right: 6px solid #0000;
|
|
42
|
-
width: 0;
|
|
43
|
-
height: 0;
|
|
44
|
-
margin-left: 20px;
|
|
45
|
-
transition: transform .3s;
|
|
46
|
-
display: block;
|
|
47
|
-
position: absolute;
|
|
48
|
-
left: -36px;
|
|
49
|
-
transform: translate(0);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.code-file-tree .tree-item-expanded:after {
|
|
53
|
-
transform: rotate(-90deg);
|
|
54
|
-
}
|
|
55
|
-
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react_window__ from "react-window";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react_virtualized_auto_sizer__ from "react-virtualized-auto-sizer";
|
|
5
|
-
import * as __WEBPACK_EXTERNAL_MODULE_classnames__ from "classnames";
|
|
6
|
-
import * as __WEBPACK_EXTERNAL_MODULE_memoize_one__ from "memoize-one";
|
|
7
|
-
import * as __WEBPACK_EXTERNAL_MODULE_string_natural_compare__ from "string-natural-compare";
|
|
8
|
-
import * as __WEBPACK_EXTERNAL_MODULE__file_type_icon_index_js__ from "../file-type-icon/index.js";
|
|
9
|
-
import "./index.css";
|
|
10
|
-
const FILE_TYPES_ICON_MAP = {
|
|
11
|
-
js: "js",
|
|
12
|
-
jsx: "jsx",
|
|
13
|
-
ts: "ts",
|
|
14
|
-
tsx: "ts",
|
|
15
|
-
json: "json",
|
|
16
|
-
scss: "scss",
|
|
17
|
-
css: "css",
|
|
18
|
-
less: "less",
|
|
19
|
-
tsconfig: "tsconfig",
|
|
20
|
-
html: "html"
|
|
21
|
-
};
|
|
22
|
-
function getFileIcon(file) {
|
|
23
|
-
const type = FILE_TYPES_ICON_MAP[(file || "").split(".").pop() || ""] || "text";
|
|
24
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__file_type_icon_index_js__.FileTypeIcon, {
|
|
25
|
-
type: type
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
const Row = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react__.memo)(({ data, index, style })=>{
|
|
29
|
-
const { flattenedData, onOpen, onSelect, selectedKeys } = data;
|
|
30
|
-
const node = flattenedData[index];
|
|
31
|
-
const left = 20 * node.depth;
|
|
32
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
|
|
33
|
-
className: (0, __WEBPACK_EXTERNAL_MODULE_classnames__["default"])("tree-node", {
|
|
34
|
-
"tree-node-selected": selectedKeys?.includes(node.id)
|
|
35
|
-
}),
|
|
36
|
-
style: style,
|
|
37
|
-
onClick: ()=>onOpen(node),
|
|
38
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
|
|
39
|
-
className: (0, __WEBPACK_EXTERNAL_MODULE_classnames__["default"])("tree-item", {
|
|
40
|
-
"tree-folder": node.folder,
|
|
41
|
-
"tree-item-expanded": node.expanded,
|
|
42
|
-
"tree-item-open": !node.expanded
|
|
43
|
-
}),
|
|
44
|
-
onClick: (e)=>onSelect(e, node),
|
|
45
|
-
style: {
|
|
46
|
-
left: `${left}px`,
|
|
47
|
-
width: `calc(100% - ${left}px)`
|
|
48
|
-
},
|
|
49
|
-
children: [
|
|
50
|
-
!node.folder && getFileIcon(node.label),
|
|
51
|
-
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("span", {
|
|
52
|
-
className: "label-name",
|
|
53
|
-
children: node.label
|
|
54
|
-
})
|
|
55
|
-
]
|
|
56
|
-
})
|
|
57
|
-
});
|
|
58
|
-
}, __WEBPACK_EXTERNAL_MODULE_react_window__.areEqual);
|
|
59
|
-
const getItemData = (0, __WEBPACK_EXTERNAL_MODULE_memoize_one__["default"])((onOpen, onSelect, flattenedData, selectedKeys)=>({
|
|
60
|
-
onOpen,
|
|
61
|
-
onSelect,
|
|
62
|
-
flattenedData,
|
|
63
|
-
selectedKeys
|
|
64
|
-
}));
|
|
65
|
-
const FileTree = (props)=>{
|
|
66
|
-
const { modules, selectedKeys = [] } = props;
|
|
67
|
-
const [openedNodeIds, setOpenedNodeIds] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)([]);
|
|
68
|
-
const onOpen = (node)=>{
|
|
69
|
-
if (!node.folder) return;
|
|
70
|
-
node.expanded ? setOpenedNodeIds(openedNodeIds.filter((id)=>id !== node.id)) : setOpenedNodeIds([
|
|
71
|
-
...openedNodeIds,
|
|
72
|
-
node.id
|
|
73
|
-
]);
|
|
74
|
-
};
|
|
75
|
-
const onSelect = (e, node)=>{
|
|
76
|
-
//e.stopPropagation();
|
|
77
|
-
if (node.folder) return;
|
|
78
|
-
props.onSelect?.(node.id);
|
|
79
|
-
};
|
|
80
|
-
const flattenedData = createFlattenTree(modules, openedNodeIds);
|
|
81
|
-
const itemData = getItemData(onOpen, onSelect, flattenedData, selectedKeys);
|
|
82
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_virtualized_auto_sizer__["default"], {
|
|
83
|
-
children: ({ height, width })=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_window__.FixedSizeList, {
|
|
84
|
-
className: "code-file-tree",
|
|
85
|
-
height: height,
|
|
86
|
-
itemCount: flattenedData.length,
|
|
87
|
-
itemSize: 22,
|
|
88
|
-
width: width,
|
|
89
|
-
itemKey: (index)=>flattenedData[index].id,
|
|
90
|
-
itemData: itemData,
|
|
91
|
-
children: Row
|
|
92
|
-
})
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
function createFlattenTree(data, expandedKeys) {
|
|
96
|
-
const flatTree = [];
|
|
97
|
-
const filePaths = Object.keys(data);
|
|
98
|
-
// console.log(JSON.parse(JSON.stringify(filePaths)))
|
|
99
|
-
// filePaths.sort((a, b) => {
|
|
100
|
-
// // 检查字符串a是否包含斜杠
|
|
101
|
-
// const hasSlashA = a.substring(1).lastIndexOf('/');
|
|
102
|
-
// // 检查字符串b是否包含斜杠
|
|
103
|
-
// const hasSlashB = b.substring(1).lastIndexOf('/');
|
|
104
|
-
// console.log('---a', hasSlashA)
|
|
105
|
-
// console.log('---b', hasSlashB)
|
|
106
|
-
// // 如果a包含斜杠,而b不包含,则a应该排在b之后
|
|
107
|
-
// if (hasSlashA > -1 && hasSlashB > -1) {
|
|
108
|
-
// return hasSlashB - hasSlashA;
|
|
109
|
-
// }
|
|
110
|
-
// return naturalCompare(a, b, {
|
|
111
|
-
// caseInsensitive: true,
|
|
112
|
-
// }); // 包含斜杠的字符串按字典顺序排序
|
|
113
|
-
// });
|
|
114
|
-
// console.log(filePaths)
|
|
115
|
-
filePaths.forEach((key)=>{
|
|
116
|
-
const parts = key.split("/");
|
|
117
|
-
const fileNames = [];
|
|
118
|
-
for(let i = 1; i <= parts.length; i++){
|
|
119
|
-
const path = parts.slice(0, i).join("/");
|
|
120
|
-
let expanded = expandedKeys.includes(path);
|
|
121
|
-
if (path && !flatTree.some((node)=>node.id === path)) fileNames.push({
|
|
122
|
-
id: path,
|
|
123
|
-
label: parts[i - 1] || "/",
|
|
124
|
-
folder: i < parts.length,
|
|
125
|
-
depth: i - 1,
|
|
126
|
-
expanded: expanded
|
|
127
|
-
});
|
|
128
|
-
if (expanded) break;
|
|
129
|
-
}
|
|
130
|
-
// console.log('--fileNames', fileNames);
|
|
131
|
-
fileNames.sort((a, b)=>(0, __WEBPACK_EXTERNAL_MODULE_string_natural_compare__["default"])(a.id, b.id, {
|
|
132
|
-
caseInsensitive: true
|
|
133
|
-
}));
|
|
134
|
-
flatTree.push(...fileNames);
|
|
135
|
-
});
|
|
136
|
-
return flatTree;
|
|
137
|
-
}
|
|
138
|
-
export { FileTree, createFlattenTree };
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
@font-face {
|
|
2
|
-
font-family: file-types-iconfont;
|
|
3
|
-
src: url("//at.alicdn.com/t/c/font_4778352_c4wg236tblh.woff2?t=1734587113843") format("woff2"), url("//at.alicdn.com/t/c/font_4778352_c4wg236tblh.woff?t=1734587113843") format("woff"), url("//at.alicdn.com/t/c/font_4778352_c4wg236tblh.ttf?t=1734587113843") format("truetype");
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.file-types-iconfont {
|
|
7
|
-
-webkit-font-smoothing: antialiased;
|
|
8
|
-
-moz-osx-font-smoothing: grayscale;
|
|
9
|
-
font-size: 14px;
|
|
10
|
-
font-style: normal;
|
|
11
|
-
font-family: file-types-iconfont !important;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.file-types-icon-css:before {
|
|
15
|
-
content: "";
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.file-types-icon-editorconfig:before {
|
|
19
|
-
content: "";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.file-types-icon-eslintignore:before {
|
|
23
|
-
content: "";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.file-types-icon-gitignore:before {
|
|
27
|
-
content: "";
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.file-types-icon-git:before {
|
|
31
|
-
content: "";
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.file-types-icon-html:before {
|
|
35
|
-
content: "";
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.file-types-icon-tsconfig:before {
|
|
39
|
-
content: "";
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.file-types-icon-less:before {
|
|
43
|
-
content: "";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.file-types-icon-scss:before {
|
|
47
|
-
content: "";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.file-types-icon-json:before {
|
|
51
|
-
content: "";
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.file-types-icon-text:before {
|
|
55
|
-
content: "";
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.file-types-icon-js:before {
|
|
59
|
-
content: "";
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.file-types-icon-jsx:before {
|
|
63
|
-
content: "";
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.file-types-icon-ts:before {
|
|
67
|
-
content: "";
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.file-types-icon-tsx:before {
|
|
71
|
-
content: "";
|
|
72
|
-
}
|
|
73
|
-
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
|
|
2
|
-
import "./index.css";
|
|
3
|
-
import "react";
|
|
4
|
-
function FileTypeIcon({ type, ...props }) {
|
|
5
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("i", {
|
|
6
|
-
...props,
|
|
7
|
-
className: `file-types-iconfont file-types-icon-${type} ${props.className || ''}`
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
export { FileTypeIcon };
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
3
|
-
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
|
|
4
|
-
import * as __WEBPACK_EXTERNAL_MODULE__gant_lowcode_lowcode_plugin_base_monaco_editor__ from "@gant-lowcode/lowcode-plugin-base-monaco-editor";
|
|
5
|
-
import "@gant-lowcode/lowcode-plugin-base-monaco-editor/lib/style.js";
|
|
6
|
-
import * as __WEBPACK_EXTERNAL_MODULE__file_tree_index_js__ from "../file-tree/index.js";
|
|
7
|
-
import "./index.css";
|
|
8
|
-
const DEBOUNCE_UPDATE_INTERVAL_IN_MS = 500;
|
|
9
|
-
function SourcesView({ code, onCodeChange }) {
|
|
10
|
-
const editorContainerRef = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
|
|
11
|
-
const [state, setState] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(()=>{
|
|
12
|
-
const allFiles = Object.values(code.modules);
|
|
13
|
-
const currentFile = [
|
|
14
|
-
allFiles.find((x)=>/pages.+(js|ts)x?$/.test(x.fpath)),
|
|
15
|
-
allFiles.find((m)=>m.entry)
|
|
16
|
-
].filter(Boolean)[0];
|
|
17
|
-
return {
|
|
18
|
-
currentFile,
|
|
19
|
-
selectedKeys: [
|
|
20
|
-
currentFile?.fpath
|
|
21
|
-
]
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
const [height, setHeight] = (0, __WEBPACK_EXTERNAL_MODULE_react__.useState)(0);
|
|
25
|
-
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
26
|
-
const observer = new ResizeObserver(()=>{
|
|
27
|
-
if (editorContainerRef.current) {
|
|
28
|
-
const { height } = editorContainerRef.current.getBoundingClientRect();
|
|
29
|
-
setHeight(height - 2);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
if (editorContainerRef.current) observer.observe(editorContainerRef.current);
|
|
33
|
-
return ()=>{
|
|
34
|
-
if (editorContainerRef.current) observer.unobserve(editorContainerRef.current);
|
|
35
|
-
};
|
|
36
|
-
}, []);
|
|
37
|
-
const ref = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)({
|
|
38
|
-
debounceTimer: null
|
|
39
|
-
});
|
|
40
|
-
const onSelect = (key)=>{
|
|
41
|
-
setState((prev)=>{
|
|
42
|
-
if (ref.current.debounceTimer) ref.current.debounceTimer = null;
|
|
43
|
-
return {
|
|
44
|
-
...prev,
|
|
45
|
-
currentFile: code.modules[key] || prev.currentFile
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE_antd__.Splitter, {
|
|
50
|
-
className: "sources-panes",
|
|
51
|
-
children: [
|
|
52
|
-
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Splitter.Panel, {
|
|
53
|
-
defaultSize: 300,
|
|
54
|
-
min: 300,
|
|
55
|
-
max: "70%",
|
|
56
|
-
className: "file-tree-pane",
|
|
57
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__file_tree_index_js__.FileTree, {
|
|
58
|
-
modules: code.modules,
|
|
59
|
-
onSelect: onSelect,
|
|
60
|
-
selectedKeys: state.currentFile?.fpath ? [
|
|
61
|
-
state.currentFile?.fpath
|
|
62
|
-
] : void 0
|
|
63
|
-
})
|
|
64
|
-
}),
|
|
65
|
-
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Splitter.Panel, {
|
|
66
|
-
className: "source-code-pane",
|
|
67
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
|
|
68
|
-
ref: editorContainerRef,
|
|
69
|
-
style: {
|
|
70
|
-
height: "100%"
|
|
71
|
-
},
|
|
72
|
-
children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__gant_lowcode_lowcode_plugin_base_monaco_editor__["default"], {
|
|
73
|
-
height: height,
|
|
74
|
-
language: getFileLanguage(state.currentFile?.fpath),
|
|
75
|
-
saveViewState: true,
|
|
76
|
-
defaultValue: state.currentFile?.code,
|
|
77
|
-
path: state.currentFile?.fpath,
|
|
78
|
-
onChange: (value)=>{
|
|
79
|
-
console.debug("[monaco editor] onChange: %o (currentFile: %o)", {
|
|
80
|
-
value
|
|
81
|
-
}, state.currentFile);
|
|
82
|
-
const currentFile = state.currentFile;
|
|
83
|
-
if (currentFile) {
|
|
84
|
-
if (ref.current.debounceTimer) clearTimeout(ref.current.debounceTimer);
|
|
85
|
-
ref.current.debounceTimer = setTimeout(()=>{
|
|
86
|
-
ref.current.debounceTimer = null;
|
|
87
|
-
onCodeChange({
|
|
88
|
-
...code,
|
|
89
|
-
modules: {
|
|
90
|
-
...code.modules,
|
|
91
|
-
[currentFile.fpath]: {
|
|
92
|
-
...currentFile,
|
|
93
|
-
code: value || ""
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}, DEBOUNCE_UPDATE_INTERVAL_IN_MS);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
})
|
|
101
|
-
})
|
|
102
|
-
})
|
|
103
|
-
]
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
function getFileLanguage(file) {
|
|
107
|
-
switch((file || "").split(".").pop()){
|
|
108
|
-
case "ts":
|
|
109
|
-
case "tsx":
|
|
110
|
-
return "typescript";
|
|
111
|
-
case "js":
|
|
112
|
-
case "jsx":
|
|
113
|
-
return "javascript";
|
|
114
|
-
case "css":
|
|
115
|
-
return "css";
|
|
116
|
-
case "scss":
|
|
117
|
-
return "scss";
|
|
118
|
-
case "less":
|
|
119
|
-
return "less";
|
|
120
|
-
case "json":
|
|
121
|
-
return "json";
|
|
122
|
-
case "md":
|
|
123
|
-
return "markdown";
|
|
124
|
-
default:
|
|
125
|
-
return "text";
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
export { SourcesView };
|
package/dist/index.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as __WEBPACK_EXTERNAL_MODULE__gant_lowcode_code_generator_standalone_loader__ from "@gant-lowcode/code-generator/standalone-loader";
|
|
2
|
-
import * as __WEBPACK_EXTERNAL_MODULE__components_code_gen_action_index_js__ from "./components/code-gen-action/index.js";
|
|
3
|
-
const src_rslib_entry_plugin = (ctx, options)=>({
|
|
4
|
-
// 插件对外暴露的数据和方法
|
|
5
|
-
exports () {
|
|
6
|
-
return {
|
|
7
|
-
generateCode: __WEBPACK_EXTERNAL_MODULE__gant_lowcode_code_generator_standalone_loader__.generateCode
|
|
8
|
-
};
|
|
9
|
-
},
|
|
10
|
-
// 插件的初始化函数,在引擎初始化之后会立刻调用
|
|
11
|
-
async init () {
|
|
12
|
-
try {
|
|
13
|
-
if (!options?.disableCodeGenActionBtn) ctx.skeleton.add({
|
|
14
|
-
type: "Custom",
|
|
15
|
-
name: "code-generator",
|
|
16
|
-
area: "topArea",
|
|
17
|
-
props: {
|
|
18
|
-
align: "right",
|
|
19
|
-
width: 100
|
|
20
|
-
},
|
|
21
|
-
content: __WEBPACK_EXTERNAL_MODULE__components_code_gen_action_index_js__.CodeGenActionBtn,
|
|
22
|
-
contentProps: {
|
|
23
|
-
ctx
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
// 提前初始化下,这样后面用的时候更快
|
|
27
|
-
__WEBPACK_EXTERNAL_MODULE__gant_lowcode_code_generator_standalone_loader__.init();
|
|
28
|
-
} catch (e) {
|
|
29
|
-
console.error("[plugin-code-geneator] failed to init: ", e);
|
|
30
|
-
throw e;
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
destroy () {}
|
|
34
|
-
});
|
|
35
|
-
src_rslib_entry_plugin.pluginName = "codeGenerator";
|
|
36
|
-
src_rslib_entry_plugin.meta = {
|
|
37
|
-
dependencies: [],
|
|
38
|
-
preferenceDeclaration: {
|
|
39
|
-
title: "codeGenerator 的参数定义",
|
|
40
|
-
properties: [
|
|
41
|
-
{
|
|
42
|
-
key: "disableCodeGenActionBtn",
|
|
43
|
-
type: "boolean",
|
|
44
|
-
description: "是否要禁用出码的动作按钮"
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
/* ESM default export */ const src_rslib_entry_ = src_rslib_entry_plugin;
|
|
50
|
-
export { src_rslib_entry_ as default };
|
package/dist/types/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// CONCATENATED MODULE: ./src/types/index.ts?__rslib_entry__
|
|
File without changes
|