@coding-script/script-engine 0.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 +201 -0
- package/README.md +23 -0
- package/dist/autocomplete/completion-source.d.ts +11 -0
- package/dist/autocomplete/completion-source.js +267 -0
- package/dist/autocomplete/index.d.ts +2 -0
- package/dist/autocomplete/index.js +2 -0
- package/dist/autocomplete/resolve.d.ts +15 -0
- package/dist/autocomplete/resolve.js +29 -0
- package/dist/components/data-types-section.d.ts +10 -0
- package/dist/components/data-types-section.js +25 -0
- package/dist/components/drag-handle.d.ts +10 -0
- package/dist/components/drag-handle.js +39 -0
- package/dist/components/expand-sidebar-button.d.ts +8 -0
- package/dist/components/expand-sidebar-button.js +27 -0
- package/dist/components/field-row.d.ts +8 -0
- package/dist/components/field-row.js +46 -0
- package/dist/components/function-row.d.ts +8 -0
- package/dist/components/function-row.js +47 -0
- package/dist/components/index.d.ts +28 -0
- package/dist/components/index.js +14 -0
- package/dist/components/main-function-section.d.ts +8 -0
- package/dist/components/main-function-section.js +40 -0
- package/dist/components/panel-header.d.ts +7 -0
- package/dist/components/panel-header.js +33 -0
- package/dist/components/section-header.d.ts +7 -0
- package/dist/components/section-header.js +12 -0
- package/dist/components/theme-colors.d.ts +46 -0
- package/dist/components/theme-colors.js +47 -0
- package/dist/components/toolbar-button.d.ts +11 -0
- package/dist/components/toolbar-button.js +26 -0
- package/dist/components/toolbar.d.ts +8 -0
- package/dist/components/toolbar.js +85 -0
- package/dist/components/type-section.d.ts +10 -0
- package/dist/components/type-section.js +58 -0
- package/dist/components/variable-row.d.ts +9 -0
- package/dist/components/variable-row.js +38 -0
- package/dist/components/variables-section.d.ts +9 -0
- package/dist/components/variables-section.js +23 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/script-code.d.ts +3 -0
- package/dist/script-code.js +307 -0
- package/dist/type-panel/index.d.ts +2 -0
- package/dist/type-panel/index.js +1 -0
- package/dist/type-panel/type-panel.d.ts +12 -0
- package/dist/type-panel/type-panel.js +129 -0
- package/dist/types/index.d.ts +77 -0
- package/dist/types/index.js +0 -0
- package/package.json +48 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import react, { useState } from "react";
|
|
2
|
+
const ExpandSidebarButton = ({ borderColor, expandBtnColor, expandBtnBg, onClick })=>{
|
|
3
|
+
const [hovered, setHovered] = useState(false);
|
|
4
|
+
return /*#__PURE__*/ react.createElement("button", {
|
|
5
|
+
onClick: onClick,
|
|
6
|
+
onMouseEnter: ()=>setHovered(true),
|
|
7
|
+
onMouseLeave: ()=>setHovered(false),
|
|
8
|
+
style: {
|
|
9
|
+
position: 'absolute',
|
|
10
|
+
top: 4,
|
|
11
|
+
right: 4,
|
|
12
|
+
zIndex: 10,
|
|
13
|
+
background: hovered ? expandBtnBg : 'transparent',
|
|
14
|
+
border: `1px solid ${borderColor}`,
|
|
15
|
+
color: expandBtnColor,
|
|
16
|
+
cursor: 'pointer',
|
|
17
|
+
fontSize: 12,
|
|
18
|
+
padding: '3px 6px',
|
|
19
|
+
borderRadius: 3,
|
|
20
|
+
lineHeight: 1,
|
|
21
|
+
opacity: hovered ? 1 : 0.6,
|
|
22
|
+
transition: 'opacity 0.2s, background 0.2s'
|
|
23
|
+
},
|
|
24
|
+
title: "展开属性面板"
|
|
25
|
+
}, "属性面板 ◀");
|
|
26
|
+
};
|
|
27
|
+
export { ExpandSidebarButton };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ScriptFieldInfo } from '../types';
|
|
3
|
+
import type { ThemeColors } from './theme-colors';
|
|
4
|
+
export interface FieldRowProps {
|
|
5
|
+
field: ScriptFieldInfo;
|
|
6
|
+
colors: ThemeColors;
|
|
7
|
+
}
|
|
8
|
+
export declare const FieldRow: React.FC<FieldRowProps>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import react, { useState } from "react";
|
|
2
|
+
const FieldRow = ({ field, colors })=>{
|
|
3
|
+
const [hovered, setHovered] = useState(false);
|
|
4
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
5
|
+
style: {
|
|
6
|
+
padding: '4px 12px 4px 28px',
|
|
7
|
+
cursor: 'default',
|
|
8
|
+
backgroundColor: hovered ? colors.hover : 'transparent'
|
|
9
|
+
},
|
|
10
|
+
onMouseEnter: ()=>setHovered(true),
|
|
11
|
+
onMouseLeave: ()=>setHovered(false),
|
|
12
|
+
title: field.description ? `${field.name}: ${field.dataType} — ${field.description}` : `${field.name}: ${field.dataType}`
|
|
13
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
14
|
+
style: {
|
|
15
|
+
display: 'flex',
|
|
16
|
+
alignItems: 'center',
|
|
17
|
+
gap: 6,
|
|
18
|
+
fontSize: 12
|
|
19
|
+
}
|
|
20
|
+
}, /*#__PURE__*/ react.createElement("span", {
|
|
21
|
+
style: {
|
|
22
|
+
color: colors.fieldColor,
|
|
23
|
+
fontSize: 10,
|
|
24
|
+
flexShrink: 0
|
|
25
|
+
}
|
|
26
|
+
}, "◇"), /*#__PURE__*/ react.createElement("span", {
|
|
27
|
+
style: {
|
|
28
|
+
color: colors.text,
|
|
29
|
+
fontWeight: 500
|
|
30
|
+
}
|
|
31
|
+
}, field.name), /*#__PURE__*/ react.createElement("span", {
|
|
32
|
+
style: {
|
|
33
|
+
color: colors.typeColor,
|
|
34
|
+
fontSize: 11,
|
|
35
|
+
marginLeft: 'auto'
|
|
36
|
+
}
|
|
37
|
+
}, field.dataType)), field.description && /*#__PURE__*/ react.createElement("div", {
|
|
38
|
+
style: {
|
|
39
|
+
fontSize: 11,
|
|
40
|
+
color: colors.textSecondary,
|
|
41
|
+
marginTop: 2,
|
|
42
|
+
paddingLeft: 16
|
|
43
|
+
}
|
|
44
|
+
}, field.description));
|
|
45
|
+
};
|
|
46
|
+
export { FieldRow };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ScriptFunctionInfo } from '../types';
|
|
3
|
+
import type { ThemeColors } from './theme-colors';
|
|
4
|
+
export interface FunctionRowProps {
|
|
5
|
+
func: ScriptFunctionInfo;
|
|
6
|
+
colors: ThemeColors;
|
|
7
|
+
}
|
|
8
|
+
export declare const FunctionRow: React.FC<FunctionRowProps>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import react, { useState } from "react";
|
|
2
|
+
const FunctionRow = ({ func, colors })=>{
|
|
3
|
+
const [hovered, setHovered] = useState(false);
|
|
4
|
+
const params = func.parameters.map((p)=>`${p.name}: ${p.dataType}`).join(', ');
|
|
5
|
+
const sig = `${func.name}(${params})`;
|
|
6
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
7
|
+
style: {
|
|
8
|
+
padding: '4px 12px 4px 28px',
|
|
9
|
+
cursor: 'default',
|
|
10
|
+
backgroundColor: hovered ? colors.hover : 'transparent'
|
|
11
|
+
},
|
|
12
|
+
onMouseEnter: ()=>setHovered(true),
|
|
13
|
+
onMouseLeave: ()=>setHovered(false),
|
|
14
|
+
title: func.description ? `${sig} — ${func.description}` : sig
|
|
15
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
16
|
+
style: {
|
|
17
|
+
display: 'flex',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
gap: 6,
|
|
20
|
+
fontSize: 12
|
|
21
|
+
}
|
|
22
|
+
}, /*#__PURE__*/ react.createElement("span", {
|
|
23
|
+
style: {
|
|
24
|
+
color: colors.methodColor,
|
|
25
|
+
fontSize: 11,
|
|
26
|
+
flexShrink: 0
|
|
27
|
+
}
|
|
28
|
+
}, "ƒ"), /*#__PURE__*/ react.createElement("span", {
|
|
29
|
+
style: {
|
|
30
|
+
color: colors.text,
|
|
31
|
+
fontWeight: 500
|
|
32
|
+
}
|
|
33
|
+
}, func.name), /*#__PURE__*/ react.createElement("span", {
|
|
34
|
+
style: {
|
|
35
|
+
color: colors.textSecondary,
|
|
36
|
+
fontSize: 11
|
|
37
|
+
}
|
|
38
|
+
}, "(", params, ")")), func.description && /*#__PURE__*/ react.createElement("div", {
|
|
39
|
+
style: {
|
|
40
|
+
fontSize: 11,
|
|
41
|
+
color: colors.textSecondary,
|
|
42
|
+
marginTop: 2,
|
|
43
|
+
paddingLeft: 16
|
|
44
|
+
}
|
|
45
|
+
}, func.description));
|
|
46
|
+
};
|
|
47
|
+
export { FunctionRow };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export { themes, SCROLL_CLASS, ensureScrollbarStyle } from './theme-colors';
|
|
2
|
+
export type { ThemeColors } from './theme-colors';
|
|
3
|
+
export { ToolbarButton } from './toolbar-button';
|
|
4
|
+
export type { ToolbarButtonProps } from './toolbar-button';
|
|
5
|
+
export { Toolbar } from './toolbar';
|
|
6
|
+
export type { ToolbarProps } from './toolbar';
|
|
7
|
+
export { ExpandSidebarButton } from './expand-sidebar-button';
|
|
8
|
+
export type { ExpandSidebarButtonProps } from './expand-sidebar-button';
|
|
9
|
+
export { DragHandle } from './drag-handle';
|
|
10
|
+
export type { DragHandleProps } from './drag-handle';
|
|
11
|
+
export { PanelHeader } from './panel-header';
|
|
12
|
+
export type { PanelHeaderProps } from './panel-header';
|
|
13
|
+
export { SectionHeader } from './section-header';
|
|
14
|
+
export type { SectionHeaderProps } from './section-header';
|
|
15
|
+
export { VariableRow } from './variable-row';
|
|
16
|
+
export type { VariableRowProps } from './variable-row';
|
|
17
|
+
export { FieldRow } from './field-row';
|
|
18
|
+
export type { FieldRowProps } from './field-row';
|
|
19
|
+
export { FunctionRow } from './function-row';
|
|
20
|
+
export type { FunctionRowProps } from './function-row';
|
|
21
|
+
export { TypeSection } from './type-section';
|
|
22
|
+
export type { TypeSectionProps } from './type-section';
|
|
23
|
+
export { MainFunctionSection } from './main-function-section';
|
|
24
|
+
export type { MainFunctionSectionProps } from './main-function-section';
|
|
25
|
+
export { VariablesSection } from './variables-section';
|
|
26
|
+
export type { VariablesSectionProps } from './variables-section';
|
|
27
|
+
export { DataTypesSection } from './data-types-section';
|
|
28
|
+
export type { DataTypesSectionProps } from './data-types-section';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { SCROLL_CLASS, ensureScrollbarStyle, themes } from "./theme-colors.js";
|
|
2
|
+
export { ToolbarButton } from "./toolbar-button.js";
|
|
3
|
+
export { Toolbar } from "./toolbar.js";
|
|
4
|
+
export { ExpandSidebarButton } from "./expand-sidebar-button.js";
|
|
5
|
+
export { DragHandle } from "./drag-handle.js";
|
|
6
|
+
export { PanelHeader } from "./panel-header.js";
|
|
7
|
+
export { SectionHeader } from "./section-header.js";
|
|
8
|
+
export { VariableRow } from "./variable-row.js";
|
|
9
|
+
export { FieldRow } from "./field-row.js";
|
|
10
|
+
export { FunctionRow } from "./function-row.js";
|
|
11
|
+
export { TypeSection } from "./type-section.js";
|
|
12
|
+
export { MainFunctionSection } from "./main-function-section.js";
|
|
13
|
+
export { VariablesSection } from "./variables-section.js";
|
|
14
|
+
export { DataTypesSection } from "./data-types-section.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ScriptMetadata } from '../types';
|
|
3
|
+
import type { ThemeColors } from './theme-colors';
|
|
4
|
+
export interface MainFunctionSectionProps {
|
|
5
|
+
metadata: ScriptMetadata;
|
|
6
|
+
colors: ThemeColors;
|
|
7
|
+
}
|
|
8
|
+
export declare const MainFunctionSection: React.FC<MainFunctionSectionProps>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { SectionHeader } from "./section-header.js";
|
|
3
|
+
const MainFunctionSection = ({ metadata, colors })=>/*#__PURE__*/ react.createElement("div", null, /*#__PURE__*/ react.createElement(SectionHeader, {
|
|
4
|
+
colors: colors,
|
|
5
|
+
label: "主函数"
|
|
6
|
+
}), /*#__PURE__*/ react.createElement("div", {
|
|
7
|
+
style: {
|
|
8
|
+
padding: '4px 12px 4px 20px'
|
|
9
|
+
}
|
|
10
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
11
|
+
style: {
|
|
12
|
+
display: 'flex',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
gap: 6,
|
|
15
|
+
fontSize: 12
|
|
16
|
+
}
|
|
17
|
+
}, /*#__PURE__*/ react.createElement("span", {
|
|
18
|
+
style: {
|
|
19
|
+
color: colors.methodColor,
|
|
20
|
+
fontSize: 11,
|
|
21
|
+
flexShrink: 0
|
|
22
|
+
}
|
|
23
|
+
}, "ƒ"), /*#__PURE__*/ react.createElement("span", {
|
|
24
|
+
style: {
|
|
25
|
+
color: colors.text,
|
|
26
|
+
fontWeight: 500
|
|
27
|
+
}
|
|
28
|
+
}, metadata.mainMethod), /*#__PURE__*/ react.createElement("span", {
|
|
29
|
+
style: {
|
|
30
|
+
color: colors.textSecondary,
|
|
31
|
+
fontSize: 11
|
|
32
|
+
}
|
|
33
|
+
}, "(", metadata.requests.map((r)=>`${r.name}: ${r.dataType}`).join(', '), ")"), metadata.returnType && /*#__PURE__*/ react.createElement("span", {
|
|
34
|
+
style: {
|
|
35
|
+
color: colors.typeColor,
|
|
36
|
+
fontSize: 11,
|
|
37
|
+
marginLeft: 'auto'
|
|
38
|
+
}
|
|
39
|
+
}, "→ ", metadata.returnType))));
|
|
40
|
+
export { MainFunctionSection };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import react, { useState } from "react";
|
|
2
|
+
const PanelHeader = ({ colors, onCollapse })=>{
|
|
3
|
+
const [collapseHovered, setCollapseHovered] = useState(false);
|
|
4
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
5
|
+
style: {
|
|
6
|
+
padding: '8px 12px',
|
|
7
|
+
display: 'flex',
|
|
8
|
+
justifyContent: 'space-between',
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
borderBottom: `1px solid ${colors.border}`,
|
|
11
|
+
backgroundColor: colors.headerBg,
|
|
12
|
+
fontWeight: 600,
|
|
13
|
+
fontSize: 13,
|
|
14
|
+
flexShrink: 0
|
|
15
|
+
}
|
|
16
|
+
}, /*#__PURE__*/ react.createElement("span", null, "\uD83D\uDCCB 属性面板"), /*#__PURE__*/ react.createElement("button", {
|
|
17
|
+
onClick: onCollapse,
|
|
18
|
+
onMouseEnter: ()=>setCollapseHovered(true),
|
|
19
|
+
onMouseLeave: ()=>setCollapseHovered(false),
|
|
20
|
+
style: {
|
|
21
|
+
background: collapseHovered ? colors.hover : 'none',
|
|
22
|
+
border: 'none',
|
|
23
|
+
color: colors.textSecondary,
|
|
24
|
+
cursor: 'pointer',
|
|
25
|
+
fontSize: 14,
|
|
26
|
+
padding: '2px 6px',
|
|
27
|
+
borderRadius: 3,
|
|
28
|
+
lineHeight: 1
|
|
29
|
+
},
|
|
30
|
+
title: "收起属性面板"
|
|
31
|
+
}, "▶"));
|
|
32
|
+
};
|
|
33
|
+
export { PanelHeader };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
const SectionHeader = ({ colors, label })=>/*#__PURE__*/ react.createElement("div", {
|
|
3
|
+
style: {
|
|
4
|
+
padding: '6px 12px 4px',
|
|
5
|
+
fontSize: 11,
|
|
6
|
+
textTransform: 'uppercase',
|
|
7
|
+
letterSpacing: 0.5,
|
|
8
|
+
color: colors.textSecondary,
|
|
9
|
+
fontWeight: 600
|
|
10
|
+
}
|
|
11
|
+
}, label);
|
|
12
|
+
export { SectionHeader };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare const themes: {
|
|
2
|
+
readonly dark: {
|
|
3
|
+
readonly bg: "#21252b";
|
|
4
|
+
readonly text: "#abb2bf";
|
|
5
|
+
readonly textSecondary: "#7f848e";
|
|
6
|
+
readonly border: "#434343";
|
|
7
|
+
readonly hover: "#2c313a";
|
|
8
|
+
readonly accent: "#61afef";
|
|
9
|
+
readonly headerBg: "#282c34";
|
|
10
|
+
readonly variableBg: "#2c313a";
|
|
11
|
+
readonly fieldColor: "#61afef";
|
|
12
|
+
readonly methodColor: "#c678dd";
|
|
13
|
+
readonly typeColor: "#e5c07b";
|
|
14
|
+
readonly scrollThumb: "#4b5263";
|
|
15
|
+
};
|
|
16
|
+
readonly light: {
|
|
17
|
+
readonly bg: "#ffffff";
|
|
18
|
+
readonly text: "#333333";
|
|
19
|
+
readonly textSecondary: "#888888";
|
|
20
|
+
readonly border: "#d9d9d9";
|
|
21
|
+
readonly hover: "#f0f0f0";
|
|
22
|
+
readonly accent: "#1677ff";
|
|
23
|
+
readonly headerBg: "#fafafa";
|
|
24
|
+
readonly variableBg: "#f5f5f5";
|
|
25
|
+
readonly fieldColor: "#1677ff";
|
|
26
|
+
readonly methodColor: "#722ed1";
|
|
27
|
+
readonly typeColor: "#d48806";
|
|
28
|
+
readonly scrollThumb: "#c1c1c1";
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export interface ThemeColors {
|
|
32
|
+
bg: string;
|
|
33
|
+
text: string;
|
|
34
|
+
textSecondary: string;
|
|
35
|
+
border: string;
|
|
36
|
+
hover: string;
|
|
37
|
+
accent: string;
|
|
38
|
+
headerBg: string;
|
|
39
|
+
variableBg: string;
|
|
40
|
+
fieldColor: string;
|
|
41
|
+
methodColor: string;
|
|
42
|
+
typeColor: string;
|
|
43
|
+
scrollThumb: string;
|
|
44
|
+
}
|
|
45
|
+
export declare const SCROLL_CLASS = "se-type-panel-scroll";
|
|
46
|
+
export declare function ensureScrollbarStyle(): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const themes = {
|
|
2
|
+
dark: {
|
|
3
|
+
bg: '#21252b',
|
|
4
|
+
text: '#abb2bf',
|
|
5
|
+
textSecondary: '#7f848e',
|
|
6
|
+
border: '#434343',
|
|
7
|
+
hover: '#2c313a',
|
|
8
|
+
accent: '#61afef',
|
|
9
|
+
headerBg: '#282c34',
|
|
10
|
+
variableBg: '#2c313a',
|
|
11
|
+
fieldColor: '#61afef',
|
|
12
|
+
methodColor: '#c678dd',
|
|
13
|
+
typeColor: '#e5c07b',
|
|
14
|
+
scrollThumb: '#4b5263'
|
|
15
|
+
},
|
|
16
|
+
light: {
|
|
17
|
+
bg: '#ffffff',
|
|
18
|
+
text: '#333333',
|
|
19
|
+
textSecondary: '#888888',
|
|
20
|
+
border: '#d9d9d9',
|
|
21
|
+
hover: '#f0f0f0',
|
|
22
|
+
accent: '#1677ff',
|
|
23
|
+
headerBg: '#fafafa',
|
|
24
|
+
variableBg: '#f5f5f5',
|
|
25
|
+
fieldColor: '#1677ff',
|
|
26
|
+
methodColor: '#722ed1',
|
|
27
|
+
typeColor: '#d48806',
|
|
28
|
+
scrollThumb: '#c1c1c1'
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const SCROLL_CLASS = 'se-type-panel-scroll';
|
|
32
|
+
const STYLE_ID = "script-engine-type-panel-style";
|
|
33
|
+
function ensureScrollbarStyle() {
|
|
34
|
+
if ("u" < typeof document) return;
|
|
35
|
+
if (document.getElementById(STYLE_ID)) return;
|
|
36
|
+
const style = document.createElement('style');
|
|
37
|
+
style.id = STYLE_ID;
|
|
38
|
+
style.textContent = `
|
|
39
|
+
.${SCROLL_CLASS}::-webkit-scrollbar { width: 6px; }
|
|
40
|
+
.${SCROLL_CLASS}::-webkit-scrollbar-thumb { background: #4b5263; border-radius: 3px; }
|
|
41
|
+
.${SCROLL_CLASS}::-webkit-scrollbar-track { background: transparent; }
|
|
42
|
+
body.se-panel-resizing { cursor: col-resize !important; user-select: none !important; }
|
|
43
|
+
body.se-panel-resizing * { cursor: col-resize !important; user-select: none !important; }
|
|
44
|
+
`;
|
|
45
|
+
document.head.appendChild(style);
|
|
46
|
+
}
|
|
47
|
+
export { SCROLL_CLASS, ensureScrollbarStyle, themes };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ToolbarButtonProps {
|
|
3
|
+
label: React.ReactNode;
|
|
4
|
+
title: string;
|
|
5
|
+
bg: string;
|
|
6
|
+
hoverBg: string;
|
|
7
|
+
color: string;
|
|
8
|
+
border: string;
|
|
9
|
+
onClick: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const ToolbarButton: React.FC<ToolbarButtonProps>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import react, { useState } from "react";
|
|
2
|
+
const ToolbarButton = ({ label, title, bg, hoverBg, color, border, onClick })=>{
|
|
3
|
+
const [hovered, setHovered] = useState(false);
|
|
4
|
+
return /*#__PURE__*/ react.createElement("button", {
|
|
5
|
+
onClick: onClick,
|
|
6
|
+
onMouseEnter: ()=>setHovered(true),
|
|
7
|
+
onMouseLeave: ()=>setHovered(false),
|
|
8
|
+
style: {
|
|
9
|
+
display: 'inline-flex',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
gap: 4,
|
|
12
|
+
background: hovered ? hoverBg : bg,
|
|
13
|
+
border: `1px solid ${border}`,
|
|
14
|
+
color,
|
|
15
|
+
cursor: 'pointer',
|
|
16
|
+
fontSize: 12,
|
|
17
|
+
padding: '4px 10px',
|
|
18
|
+
borderRadius: 4,
|
|
19
|
+
lineHeight: 1.4,
|
|
20
|
+
whiteSpace: 'nowrap',
|
|
21
|
+
transition: 'background 0.15s'
|
|
22
|
+
},
|
|
23
|
+
title: title
|
|
24
|
+
}, label);
|
|
25
|
+
};
|
|
26
|
+
export { ToolbarButton };
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
import { ToolbarButton } from "./toolbar-button.js";
|
|
3
|
+
const HammerIcon = ({ color })=>/*#__PURE__*/ react.createElement("svg", {
|
|
4
|
+
width: "14",
|
|
5
|
+
height: "14",
|
|
6
|
+
viewBox: "0 0 24 24",
|
|
7
|
+
fill: "none",
|
|
8
|
+
style: {
|
|
9
|
+
flexShrink: 0
|
|
10
|
+
}
|
|
11
|
+
}, /*#__PURE__*/ react.createElement("rect", {
|
|
12
|
+
x: "3",
|
|
13
|
+
y: "6",
|
|
14
|
+
width: "12",
|
|
15
|
+
height: "5",
|
|
16
|
+
rx: "1",
|
|
17
|
+
fill: color,
|
|
18
|
+
transform: "rotate(-25 9 8.5)"
|
|
19
|
+
}), /*#__PURE__*/ react.createElement("rect", {
|
|
20
|
+
x: "11",
|
|
21
|
+
y: "9",
|
|
22
|
+
width: "2.5",
|
|
23
|
+
height: "11",
|
|
24
|
+
rx: "1",
|
|
25
|
+
fill: color,
|
|
26
|
+
opacity: 0.8,
|
|
27
|
+
transform: "rotate(-25 12.25 14.5)"
|
|
28
|
+
}));
|
|
29
|
+
const Toolbar = ({ title, theme, onThemeChange, onCompile })=>{
|
|
30
|
+
const isDark = 'dark' === theme;
|
|
31
|
+
const borderColor = isDark ? '#434343' : '#d9d9d9';
|
|
32
|
+
const toolbarBg = isDark ? '#282c34' : '#fafafa';
|
|
33
|
+
const toolbarText = isDark ? '#abb2bf' : '#333';
|
|
34
|
+
const btnBg = isDark ? '#2c313a' : '#f0f0f0';
|
|
35
|
+
const btnHoverBg = isDark ? '#3e4451' : '#e0e0e0';
|
|
36
|
+
const handleThemeToggle = ()=>{
|
|
37
|
+
const next = isDark ? 'light' : 'dark';
|
|
38
|
+
onThemeChange?.(next);
|
|
39
|
+
};
|
|
40
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
41
|
+
style: {
|
|
42
|
+
display: 'flex',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
gap: 8,
|
|
45
|
+
padding: '6px 12px',
|
|
46
|
+
backgroundColor: toolbarBg,
|
|
47
|
+
borderBottom: `1px solid ${borderColor}`,
|
|
48
|
+
borderRadius: '6px 6px 0 0',
|
|
49
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
|
|
50
|
+
fontSize: 13
|
|
51
|
+
}
|
|
52
|
+
}, title && /*#__PURE__*/ react.createElement("span", {
|
|
53
|
+
style: {
|
|
54
|
+
color: toolbarText,
|
|
55
|
+
fontWeight: 600,
|
|
56
|
+
marginRight: 'auto',
|
|
57
|
+
whiteSpace: 'nowrap',
|
|
58
|
+
overflow: 'hidden',
|
|
59
|
+
textOverflow: 'ellipsis'
|
|
60
|
+
}
|
|
61
|
+
}, title), !title && /*#__PURE__*/ react.createElement("span", {
|
|
62
|
+
style: {
|
|
63
|
+
marginRight: 'auto'
|
|
64
|
+
}
|
|
65
|
+
}), /*#__PURE__*/ react.createElement(ToolbarButton, {
|
|
66
|
+
label: isDark ? '🌞 浅色模式' : '🌙 深色模式',
|
|
67
|
+
title: isDark ? '切换到浅色主题' : '切换到深色主题',
|
|
68
|
+
bg: btnBg,
|
|
69
|
+
hoverBg: btnHoverBg,
|
|
70
|
+
color: toolbarText,
|
|
71
|
+
border: borderColor,
|
|
72
|
+
onClick: handleThemeToggle
|
|
73
|
+
}), onCompile && /*#__PURE__*/ react.createElement(ToolbarButton, {
|
|
74
|
+
label: /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(HammerIcon, {
|
|
75
|
+
color: isDark ? '#98c379' : '#389e0d'
|
|
76
|
+
}), "编译验证"),
|
|
77
|
+
title: "编译并验证脚本",
|
|
78
|
+
bg: isDark ? '#2d5a27' : '#e6f4e5',
|
|
79
|
+
hoverBg: isDark ? '#3a7033' : '#d4ecd3',
|
|
80
|
+
color: isDark ? '#98c379' : '#389e0d',
|
|
81
|
+
border: isDark ? '#2d5a27' : '#b7eb8f',
|
|
82
|
+
onClick: onCompile
|
|
83
|
+
}));
|
|
84
|
+
};
|
|
85
|
+
export { Toolbar };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ScriptTypeInfo } from '../types';
|
|
3
|
+
import type { ThemeColors } from './theme-colors';
|
|
4
|
+
export interface TypeSectionProps {
|
|
5
|
+
typeInfo: ScriptTypeInfo;
|
|
6
|
+
expanded: boolean;
|
|
7
|
+
onToggle: () => void;
|
|
8
|
+
colors: ThemeColors;
|
|
9
|
+
}
|
|
10
|
+
export declare const TypeSection: React.FC<TypeSectionProps>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import react, { useState } from "react";
|
|
2
|
+
import { FieldRow } from "./field-row.js";
|
|
3
|
+
import { FunctionRow } from "./function-row.js";
|
|
4
|
+
const TypeSection = ({ typeInfo, expanded, onToggle, colors })=>{
|
|
5
|
+
const [hovered, setHovered] = useState(false);
|
|
6
|
+
const hasMembers = typeInfo.fields.length > 0 || typeInfo.functions.length > 0;
|
|
7
|
+
return /*#__PURE__*/ react.createElement("div", null, /*#__PURE__*/ react.createElement("div", {
|
|
8
|
+
style: {
|
|
9
|
+
padding: '5px 12px',
|
|
10
|
+
cursor: hasMembers ? 'pointer' : 'default',
|
|
11
|
+
userSelect: 'none',
|
|
12
|
+
backgroundColor: hovered ? colors.hover : 'transparent'
|
|
13
|
+
},
|
|
14
|
+
onClick: hasMembers ? onToggle : void 0,
|
|
15
|
+
onMouseEnter: ()=>setHovered(true),
|
|
16
|
+
onMouseLeave: ()=>setHovered(false),
|
|
17
|
+
title: typeInfo.description || typeInfo.dataType
|
|
18
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
19
|
+
style: {
|
|
20
|
+
display: 'flex',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
gap: 6,
|
|
23
|
+
fontSize: 13
|
|
24
|
+
}
|
|
25
|
+
}, /*#__PURE__*/ react.createElement("span", {
|
|
26
|
+
style: {
|
|
27
|
+
fontSize: 10,
|
|
28
|
+
width: 12,
|
|
29
|
+
textAlign: 'center',
|
|
30
|
+
flexShrink: 0
|
|
31
|
+
}
|
|
32
|
+
}, hasMembers ? expanded ? '▼' : '▶' : ''), /*#__PURE__*/ react.createElement("span", {
|
|
33
|
+
style: {
|
|
34
|
+
color: colors.typeColor,
|
|
35
|
+
fontWeight: 600
|
|
36
|
+
}
|
|
37
|
+
}, typeInfo.dataType)), typeInfo.description && /*#__PURE__*/ react.createElement("div", {
|
|
38
|
+
style: {
|
|
39
|
+
fontSize: 11,
|
|
40
|
+
color: colors.textSecondary,
|
|
41
|
+
marginTop: 2,
|
|
42
|
+
paddingLeft: 18
|
|
43
|
+
}
|
|
44
|
+
}, typeInfo.description)), expanded && /*#__PURE__*/ react.createElement("div", null, [
|
|
45
|
+
...typeInfo.fields
|
|
46
|
+
].sort((a, b)=>a.name.localeCompare(b.name)).map((field)=>/*#__PURE__*/ react.createElement(FieldRow, {
|
|
47
|
+
key: field.name,
|
|
48
|
+
field: field,
|
|
49
|
+
colors: colors
|
|
50
|
+
})), [
|
|
51
|
+
...typeInfo.functions
|
|
52
|
+
].sort((a, b)=>a.name.localeCompare(b.name)).map((func)=>/*#__PURE__*/ react.createElement(FunctionRow, {
|
|
53
|
+
key: func.name,
|
|
54
|
+
func: func,
|
|
55
|
+
colors: colors
|
|
56
|
+
}))));
|
|
57
|
+
};
|
|
58
|
+
export { TypeSection };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ThemeColors } from './theme-colors';
|
|
3
|
+
export interface VariableRowProps {
|
|
4
|
+
name: string;
|
|
5
|
+
dataType: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
colors: ThemeColors;
|
|
8
|
+
}
|
|
9
|
+
export declare const VariableRow: React.FC<VariableRowProps>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import react from "react";
|
|
2
|
+
const VariableRow = ({ name, dataType, description, colors })=>/*#__PURE__*/ react.createElement("div", {
|
|
3
|
+
style: {
|
|
4
|
+
padding: '4px 12px 4px 20px'
|
|
5
|
+
},
|
|
6
|
+
title: `${name}: ${dataType}${description ? ` — ${description}` : ''}`
|
|
7
|
+
}, /*#__PURE__*/ react.createElement("div", {
|
|
8
|
+
style: {
|
|
9
|
+
display: 'flex',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
gap: 6,
|
|
12
|
+
fontSize: 12
|
|
13
|
+
}
|
|
14
|
+
}, /*#__PURE__*/ react.createElement("span", {
|
|
15
|
+
style: {
|
|
16
|
+
color: colors.accent,
|
|
17
|
+
fontSize: 10
|
|
18
|
+
}
|
|
19
|
+
}, "◆"), /*#__PURE__*/ react.createElement("span", {
|
|
20
|
+
style: {
|
|
21
|
+
color: colors.text,
|
|
22
|
+
fontWeight: 500
|
|
23
|
+
}
|
|
24
|
+
}, name), /*#__PURE__*/ react.createElement("span", {
|
|
25
|
+
style: {
|
|
26
|
+
color: colors.typeColor,
|
|
27
|
+
marginLeft: 'auto',
|
|
28
|
+
fontSize: 11
|
|
29
|
+
}
|
|
30
|
+
}, dataType)), description && /*#__PURE__*/ react.createElement("div", {
|
|
31
|
+
style: {
|
|
32
|
+
fontSize: 11,
|
|
33
|
+
color: colors.textSecondary,
|
|
34
|
+
marginTop: 2,
|
|
35
|
+
paddingLeft: 16
|
|
36
|
+
}
|
|
37
|
+
}, description));
|
|
38
|
+
export { VariableRow };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ScriptBindInfo, ScriptRequestInfo } from '../types';
|
|
3
|
+
import type { ThemeColors } from './theme-colors';
|
|
4
|
+
export interface VariablesSectionProps {
|
|
5
|
+
sortedBinds: ScriptBindInfo[];
|
|
6
|
+
sortedRequests: ScriptRequestInfo[];
|
|
7
|
+
colors: ThemeColors;
|
|
8
|
+
}
|
|
9
|
+
export declare const VariablesSection: React.FC<VariablesSectionProps>;
|