@lvce-editor/settings-view 1.2.0 → 1.4.0
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/settingsViewWorkerMain.js +265 -107
- package/package.json +1 -1
|
@@ -914,6 +914,13 @@ const terminate = () => {
|
|
|
914
914
|
globalThis.close();
|
|
915
915
|
};
|
|
916
916
|
|
|
917
|
+
const clear = state => {
|
|
918
|
+
return {
|
|
919
|
+
...state,
|
|
920
|
+
searchValue: ''
|
|
921
|
+
};
|
|
922
|
+
};
|
|
923
|
+
|
|
917
924
|
const {
|
|
918
925
|
get: get$1,
|
|
919
926
|
set: set$1,
|
|
@@ -932,7 +939,10 @@ const create$1 = (id, uri, x, y, width, height) => {
|
|
|
932
939
|
x,
|
|
933
940
|
y,
|
|
934
941
|
width,
|
|
935
|
-
height
|
|
942
|
+
height,
|
|
943
|
+
tabs: [],
|
|
944
|
+
items: [],
|
|
945
|
+
searchValue: ''
|
|
936
946
|
};
|
|
937
947
|
set$1(id, state, state);
|
|
938
948
|
};
|
|
@@ -971,16 +981,115 @@ const diff2 = uid => {
|
|
|
971
981
|
return diffResult;
|
|
972
982
|
};
|
|
973
983
|
|
|
984
|
+
const getSelectedTabId = tabs => {
|
|
985
|
+
for (const tab of tabs) {
|
|
986
|
+
if (tab.selected) {
|
|
987
|
+
return tab.id;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
return '';
|
|
991
|
+
};
|
|
992
|
+
const getUpdatedTabs = (tabs, selectedTabId) => {
|
|
993
|
+
// Check if the clicked tab is already selected
|
|
994
|
+
const clickedTabId = getSelectedTabId(tabs);
|
|
995
|
+
if (clickedTabId === selectedTabId) {
|
|
996
|
+
return tabs;
|
|
997
|
+
}
|
|
998
|
+
return tabs.map(tab => ({
|
|
999
|
+
...tab,
|
|
1000
|
+
selected: tab.id === selectedTabId
|
|
1001
|
+
}));
|
|
1002
|
+
};
|
|
1003
|
+
|
|
1004
|
+
const handleClickTab = (state, name) => {
|
|
1005
|
+
if (!name) {
|
|
1006
|
+
return state;
|
|
1007
|
+
}
|
|
1008
|
+
return {
|
|
1009
|
+
...state,
|
|
1010
|
+
tabs: getUpdatedTabs(state.tabs, name)
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
|
+
|
|
1014
|
+
const handleInput = (state, value) => {
|
|
1015
|
+
return {
|
|
1016
|
+
...state,
|
|
1017
|
+
searchValue: value
|
|
1018
|
+
};
|
|
1019
|
+
};
|
|
1020
|
+
|
|
974
1021
|
const initialize = async () => {
|
|
975
1022
|
// TODO
|
|
976
1023
|
};
|
|
977
1024
|
|
|
1025
|
+
const String = 2;
|
|
1026
|
+
const Number$1 = 5;
|
|
1027
|
+
|
|
1028
|
+
const getSettingItems = async () => {
|
|
1029
|
+
return [{
|
|
1030
|
+
id: 'fontSize',
|
|
1031
|
+
heading: 'Font Size',
|
|
1032
|
+
description: 'The font size of the editor',
|
|
1033
|
+
type: Number$1,
|
|
1034
|
+
value: '15px'
|
|
1035
|
+
}, {
|
|
1036
|
+
id: 'fontFamily',
|
|
1037
|
+
heading: 'Font Family',
|
|
1038
|
+
description: 'The font family of the editor',
|
|
1039
|
+
type: String,
|
|
1040
|
+
value: 'Fira Code'
|
|
1041
|
+
}];
|
|
1042
|
+
};
|
|
1043
|
+
|
|
1044
|
+
const getTabs = () => {
|
|
1045
|
+
const tabs = [{
|
|
1046
|
+
id: 'text-editor',
|
|
1047
|
+
label: 'Text Editor',
|
|
1048
|
+
selected: true
|
|
1049
|
+
}, {
|
|
1050
|
+
id: 'workbench',
|
|
1051
|
+
label: 'Workbench',
|
|
1052
|
+
selected: false
|
|
1053
|
+
}, {
|
|
1054
|
+
id: 'window',
|
|
1055
|
+
label: 'Window',
|
|
1056
|
+
selected: false
|
|
1057
|
+
}, {
|
|
1058
|
+
id: 'features',
|
|
1059
|
+
label: 'Features',
|
|
1060
|
+
selected: false
|
|
1061
|
+
}, {
|
|
1062
|
+
id: 'applications',
|
|
1063
|
+
label: 'Applications',
|
|
1064
|
+
selected: false
|
|
1065
|
+
}, {
|
|
1066
|
+
id: 'security',
|
|
1067
|
+
label: 'Security',
|
|
1068
|
+
selected: false
|
|
1069
|
+
}, {
|
|
1070
|
+
id: 'extensions',
|
|
1071
|
+
label: 'Extensions',
|
|
1072
|
+
selected: false
|
|
1073
|
+
}];
|
|
1074
|
+
return tabs;
|
|
1075
|
+
};
|
|
1076
|
+
|
|
978
1077
|
const loadContent = async (state, savedState) => {
|
|
1078
|
+
const tabs = getTabs();
|
|
1079
|
+
const items = await getSettingItems();
|
|
979
1080
|
return {
|
|
980
|
-
...state
|
|
1081
|
+
...state,
|
|
1082
|
+
tabs,
|
|
1083
|
+
items
|
|
981
1084
|
};
|
|
982
1085
|
};
|
|
983
1086
|
|
|
1087
|
+
const Tab$1 = 'tab';
|
|
1088
|
+
const TabList = 'tablist';
|
|
1089
|
+
const AriaRoles = {
|
|
1090
|
+
__proto__: null,
|
|
1091
|
+
Tab: Tab$1,
|
|
1092
|
+
TabList};
|
|
984
1093
|
const Viewlet$1 = 'Viewlet';
|
|
985
1094
|
const ClassNames = {
|
|
986
1095
|
__proto__: null,
|
|
@@ -988,13 +1097,29 @@ const ClassNames = {
|
|
|
988
1097
|
const mergeClassNames = (...classNames) => {
|
|
989
1098
|
return classNames.filter(Boolean).join(' ');
|
|
990
1099
|
};
|
|
1100
|
+
const Button = 1;
|
|
991
1101
|
const Div = 4;
|
|
992
1102
|
const H1 = 5;
|
|
1103
|
+
const Input = 6;
|
|
993
1104
|
const Text = 12;
|
|
1105
|
+
const H2 = 22;
|
|
1106
|
+
const H3 = 23;
|
|
1107
|
+
const Aside = 28;
|
|
1108
|
+
const Li = 48;
|
|
1109
|
+
const P = 50;
|
|
1110
|
+
const Ul = 60;
|
|
994
1111
|
const VirtualDomElements = {
|
|
995
1112
|
__proto__: null,
|
|
1113
|
+
Aside,
|
|
1114
|
+
Button,
|
|
996
1115
|
Div,
|
|
997
|
-
H1
|
|
1116
|
+
H1,
|
|
1117
|
+
H2,
|
|
1118
|
+
H3,
|
|
1119
|
+
Input,
|
|
1120
|
+
Li,
|
|
1121
|
+
P,
|
|
1122
|
+
Ul};
|
|
998
1123
|
const text = data => {
|
|
999
1124
|
return {
|
|
1000
1125
|
type: Text,
|
|
@@ -1007,19 +1132,144 @@ const {
|
|
|
1007
1132
|
Viewlet} = ClassNames;
|
|
1008
1133
|
const Settings = 'Settings';
|
|
1009
1134
|
|
|
1010
|
-
const
|
|
1135
|
+
const SettingsSearch = 'SettingsSearch';
|
|
1136
|
+
const Clear = 'Clear';
|
|
1137
|
+
|
|
1138
|
+
const getSettingsInputDom = () => {
|
|
1139
|
+
const placeholder = 'Search Settings';
|
|
1011
1140
|
return [{
|
|
1012
1141
|
type: VirtualDomElements.Div,
|
|
1142
|
+
className: 'SettingsInputWrapper',
|
|
1143
|
+
childCount: 2
|
|
1144
|
+
}, {
|
|
1145
|
+
type: VirtualDomElements.Input,
|
|
1146
|
+
className: 'InputBox SettingsSearchInput',
|
|
1147
|
+
placeholder,
|
|
1148
|
+
childCount: 0,
|
|
1149
|
+
name: SettingsSearch // TODO add input event listener
|
|
1150
|
+
}, {
|
|
1151
|
+
type: VirtualDomElements.Button,
|
|
1152
|
+
className: 'Button InputButton',
|
|
1013
1153
|
childCount: 1,
|
|
1014
|
-
|
|
1154
|
+
ariaLabel: 'Clear',
|
|
1155
|
+
// TODO i18n string
|
|
1156
|
+
name: Clear // TODO add click event listener
|
|
1157
|
+
}, text('Clear') // TODO use icon
|
|
1158
|
+
];
|
|
1159
|
+
};
|
|
1160
|
+
|
|
1161
|
+
const getSettingsHeaderDom = () => {
|
|
1162
|
+
return [{
|
|
1163
|
+
type: VirtualDomElements.Div,
|
|
1164
|
+
className: 'SettingsHeader',
|
|
1165
|
+
childCount: 1
|
|
1166
|
+
}, ...getSettingsInputDom()];
|
|
1167
|
+
};
|
|
1168
|
+
|
|
1169
|
+
const getItemNumberVirtualDom = item => {
|
|
1170
|
+
const {
|
|
1171
|
+
heading,
|
|
1172
|
+
description
|
|
1173
|
+
} = item;
|
|
1174
|
+
return [{
|
|
1175
|
+
type: VirtualDomElements.Div,
|
|
1176
|
+
className: 'SettingsItem',
|
|
1177
|
+
childCount: 3
|
|
1178
|
+
}, {
|
|
1179
|
+
type: VirtualDomElements.H3,
|
|
1180
|
+
childCount: 1
|
|
1181
|
+
}, text(heading), {
|
|
1182
|
+
type: VirtualDomElements.P,
|
|
1183
|
+
childCount: 1
|
|
1184
|
+
}, text(description), {
|
|
1185
|
+
type: VirtualDomElements.Input,
|
|
1186
|
+
className: 'InputBox',
|
|
1187
|
+
inputType: 'number',
|
|
1188
|
+
placeholder: 'number value',
|
|
1189
|
+
childCount: 0
|
|
1190
|
+
}];
|
|
1191
|
+
};
|
|
1192
|
+
|
|
1193
|
+
const getSettingsItemsDom = items => {
|
|
1194
|
+
return [{
|
|
1195
|
+
type: VirtualDomElements.Div,
|
|
1196
|
+
className: 'SettingsItems',
|
|
1197
|
+
childCount: items.length
|
|
1198
|
+
}, ...items.flatMap(getItemNumberVirtualDom)];
|
|
1199
|
+
};
|
|
1200
|
+
|
|
1201
|
+
const getSettingsContentDom = items => {
|
|
1202
|
+
return [{
|
|
1203
|
+
type: VirtualDomElements.Div,
|
|
1204
|
+
className: 'SettingsContent',
|
|
1205
|
+
childCount: 2
|
|
1015
1206
|
}, {
|
|
1016
1207
|
type: VirtualDomElements.H1,
|
|
1017
1208
|
childCount: 1
|
|
1018
|
-
}, text('Settings
|
|
1209
|
+
}, text('Settings Content'), ...getSettingsItemsDom(items)];
|
|
1210
|
+
};
|
|
1211
|
+
|
|
1212
|
+
const HandleClickTab = 'handleClickTab';
|
|
1213
|
+
const HandleInput = 'handleInput';
|
|
1214
|
+
|
|
1215
|
+
// TODo use numeric ids
|
|
1216
|
+
|
|
1217
|
+
const getTabVirtualDom = tab => {
|
|
1218
|
+
const className = tab.selected ? mergeClassNames('Tab', 'TabSelected') : 'Tab';
|
|
1219
|
+
return [{
|
|
1220
|
+
type: VirtualDomElements.Li,
|
|
1221
|
+
className,
|
|
1222
|
+
childCount: 1,
|
|
1223
|
+
role: AriaRoles.Tab,
|
|
1224
|
+
name: tab.id
|
|
1225
|
+
}, text(tab.label)];
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
const getSettingsTabsDom = tabs => {
|
|
1229
|
+
return [{
|
|
1230
|
+
type: VirtualDomElements.Ul,
|
|
1231
|
+
className: 'SettingsTabs',
|
|
1232
|
+
role: AriaRoles.TabList,
|
|
1233
|
+
childCount: tabs.length,
|
|
1234
|
+
onClick: HandleClickTab
|
|
1235
|
+
}, ...tabs.flatMap(getTabVirtualDom)];
|
|
1236
|
+
};
|
|
1237
|
+
|
|
1238
|
+
const getSettingsSideBarDom = tabs => {
|
|
1239
|
+
const sideBarHeading = 'Settings SideBar';
|
|
1240
|
+
return [{
|
|
1241
|
+
type: VirtualDomElements.Aside,
|
|
1242
|
+
className: 'SettingsSideBar',
|
|
1243
|
+
childCount: 2
|
|
1244
|
+
}, {
|
|
1245
|
+
type: VirtualDomElements.H2,
|
|
1246
|
+
className: 'SettingsSideBarHeading',
|
|
1247
|
+
childCount: 1
|
|
1248
|
+
}, text(sideBarHeading), ...getSettingsTabsDom(tabs)];
|
|
1249
|
+
};
|
|
1250
|
+
|
|
1251
|
+
const getSettingsMainDom = (tabs, items) => {
|
|
1252
|
+
return [{
|
|
1253
|
+
type: VirtualDomElements.Div,
|
|
1254
|
+
className: 'SettingsMain',
|
|
1255
|
+
childCount: 2
|
|
1256
|
+
}, ...getSettingsSideBarDom(tabs), ...getSettingsContentDom(items)];
|
|
1257
|
+
};
|
|
1258
|
+
|
|
1259
|
+
const getSettingsDom = state => {
|
|
1260
|
+
const {
|
|
1261
|
+
tabs,
|
|
1262
|
+
items
|
|
1263
|
+
} = state;
|
|
1264
|
+
return [{
|
|
1265
|
+
type: VirtualDomElements.Div,
|
|
1266
|
+
childCount: 2,
|
|
1267
|
+
className: mergeClassNames(Viewlet, Settings)
|
|
1268
|
+
}, ...getSettingsHeaderDom(), ...getSettingsMainDom(tabs, items)];
|
|
1019
1269
|
};
|
|
1020
1270
|
|
|
1021
1271
|
const renderItems = (oldState, newState) => {
|
|
1022
|
-
const dom = getSettingsDom();
|
|
1272
|
+
const dom = getSettingsDom(newState);
|
|
1023
1273
|
return ['Viewlet.setDom2', newState.id, dom];
|
|
1024
1274
|
};
|
|
1025
1275
|
|
|
@@ -1055,108 +1305,13 @@ const renderActions = () => {
|
|
|
1055
1305
|
return [];
|
|
1056
1306
|
};
|
|
1057
1307
|
|
|
1058
|
-
const HandleClickCallStackItem = 'handleClickCallStackItem';
|
|
1059
|
-
const HandleClickWatchExpression = 'handleClickWatchExpression';
|
|
1060
|
-
const HandleClickWatchExpressionDelete = 'handleClickWatchExpressionDelete';
|
|
1061
|
-
const HandleClickCheckBox = 'handleClickCheckBox';
|
|
1062
|
-
const HandleClickContinue = 'handleClickContinue';
|
|
1063
|
-
const HandleClickDebugButton = 'handleClickDebugButton';
|
|
1064
|
-
const HandleClickPause = 'handleClickPause';
|
|
1065
|
-
const HandleClickScopeValue = 'handleClickScopeValue';
|
|
1066
|
-
const HandleClickSectionBreakPoints = 'handleClickSectionBreakPoints';
|
|
1067
|
-
const HandleClickSectionCallstack = 'handleClickSectionCallstack';
|
|
1068
|
-
const HandleClickSectionHeading = 'handleClickSectionHeading';
|
|
1069
|
-
const HandleClickSectionScope = 'handleClickSectionScope';
|
|
1070
|
-
const HandleClickSectionWatch = 'handleClickSectionWatch';
|
|
1071
|
-
const HandleClickStepInto = 'handleClickStepInto';
|
|
1072
|
-
const HandleClickStepOut = 'handleClickStepOut';
|
|
1073
|
-
const HandleClickStepOver = 'handleClickStepOver';
|
|
1074
|
-
const HandleDebugInput = 'handleDebugInput';
|
|
1075
|
-
const HandleClickSectionAction = 'handleClickSectionAction';
|
|
1076
|
-
const HandleInputFieldChange = 'handleInputFieldChange';
|
|
1077
|
-
const HandleInputBlur = 'handleInputBlur';
|
|
1078
|
-
const HandleSectionHeaderContextMenu = 'handleSectionHeaderContextMenu';
|
|
1079
|
-
const HandleWatchExpressionContextMenu = 'handleWatchExpressionContextMenu';
|
|
1080
|
-
|
|
1081
|
-
// TODo use numeric ids
|
|
1082
|
-
|
|
1083
1308
|
const renderEventListeners = () => {
|
|
1084
1309
|
return [{
|
|
1085
|
-
name:
|
|
1086
|
-
params: ['
|
|
1087
|
-
}, {
|
|
1088
|
-
name: HandleClickDebugButton,
|
|
1089
|
-
params: ['handleClickDebugButton', 'event.target.name']
|
|
1090
|
-
}, {
|
|
1091
|
-
name: HandleClickPause,
|
|
1092
|
-
params: ['handleClickPause']
|
|
1093
|
-
}, {
|
|
1094
|
-
name: HandleClickStepOver,
|
|
1095
|
-
params: ['handleClickStepOver']
|
|
1096
|
-
}, {
|
|
1097
|
-
name: HandleClickStepInto,
|
|
1098
|
-
params: ['handleClickStepInto']
|
|
1099
|
-
}, {
|
|
1100
|
-
name: HandleClickStepOut,
|
|
1101
|
-
params: ['handleClickStepOut']
|
|
1102
|
-
}, {
|
|
1103
|
-
name: HandleClickSectionWatch,
|
|
1104
|
-
params: ['HandleClickSectionWatch']
|
|
1105
|
-
}, {
|
|
1106
|
-
name: HandleClickSectionBreakPoints,
|
|
1107
|
-
params: ['handleClickSectionBreakpoints']
|
|
1108
|
-
}, {
|
|
1109
|
-
name: HandleClickSectionScope,
|
|
1110
|
-
params: ['handleClickSectionScope']
|
|
1111
|
-
}, {
|
|
1112
|
-
name: HandleClickSectionCallstack,
|
|
1113
|
-
params: ['handleClickSectionCallstack']
|
|
1114
|
-
}, {
|
|
1115
|
-
name: HandleClickSectionBreakPoints,
|
|
1116
|
-
params: ['handleClickSectionBreakPoints']
|
|
1117
|
-
}, {
|
|
1118
|
-
name: HandleDebugInput,
|
|
1119
|
-
params: ['handleDebugInput', 'event.target.value']
|
|
1120
|
-
}, {
|
|
1121
|
-
name: HandleClickSectionHeading,
|
|
1122
|
-
params: ['handleClickSectionHeading', 'event.target.dataset.name', 'event.button'],
|
|
1123
|
-
preventDefault: true
|
|
1124
|
-
}, {
|
|
1125
|
-
name: HandleClickCheckBox,
|
|
1126
|
-
params: ['handleClickCheckBox', 'event.target.name']
|
|
1127
|
-
}, {
|
|
1128
|
-
name: HandleClickDebugButton,
|
|
1129
|
-
params: ['handleClickDebugButton', 'event.target.name']
|
|
1130
|
-
}, {
|
|
1131
|
-
name: HandleClickCallStackItem,
|
|
1132
|
-
params: ['handleClickCallStackItem', 'event.target.dataset.index']
|
|
1133
|
-
}, {
|
|
1134
|
-
name: HandleClickWatchExpression,
|
|
1135
|
-
params: ['handleClickWatchExpression', 'event.target.dataset.index', 'event.defaultPrevented']
|
|
1136
|
-
}, {
|
|
1137
|
-
name: HandleClickWatchExpressionDelete,
|
|
1138
|
-
params: ['handleClickWatchExpressionDelete', 'event.target.dataset.index'],
|
|
1139
|
-
preventDefault: true
|
|
1140
|
-
}, {
|
|
1141
|
-
name: HandleClickScopeValue,
|
|
1142
|
-
params: ['handleClickScopeValue', 'event.target.dataset.index', 'event.button']
|
|
1143
|
-
}, {
|
|
1144
|
-
name: HandleInputFieldChange,
|
|
1145
|
-
params: ['handleInputFieldChange', 'event.target.name', 'event.target.value']
|
|
1146
|
-
}, {
|
|
1147
|
-
name: HandleClickSectionAction,
|
|
1148
|
-
params: ['handleClickSectionAction', 'event.target.name']
|
|
1149
|
-
}, {
|
|
1150
|
-
name: HandleInputBlur,
|
|
1151
|
-
params: ['handleInputBlur']
|
|
1152
|
-
}, {
|
|
1153
|
-
name: HandleSectionHeaderContextMenu,
|
|
1154
|
-
params: ['handleSectionHeaderContextMenu', 'event.clientX', 'event.clientY', 'event.target.dataset.name'],
|
|
1155
|
-
preventDefault: true
|
|
1310
|
+
name: HandleClickTab,
|
|
1311
|
+
params: ['handleClickTab', 'event.target.name']
|
|
1156
1312
|
}, {
|
|
1157
|
-
name:
|
|
1158
|
-
params: ['
|
|
1159
|
-
preventDefault: true
|
|
1313
|
+
name: HandleInput,
|
|
1314
|
+
params: ['handleInput', 'event.target.value']
|
|
1160
1315
|
}];
|
|
1161
1316
|
};
|
|
1162
1317
|
|
|
@@ -1217,7 +1372,10 @@ const commandMap = {
|
|
|
1217
1372
|
'Settings.renderEventListeners': renderEventListeners,
|
|
1218
1373
|
'Settings.restoreState': restoreState,
|
|
1219
1374
|
'Settings.saveState': saveState,
|
|
1220
|
-
'Settings.terminate': terminate
|
|
1375
|
+
'Settings.terminate': terminate,
|
|
1376
|
+
'Settings.handleClickTab': wrapCommand(handleClickTab),
|
|
1377
|
+
'Settings.clear': wrapCommand(clear),
|
|
1378
|
+
'Settings.handleInput': wrapCommand(handleInput)
|
|
1221
1379
|
};
|
|
1222
1380
|
|
|
1223
1381
|
const rpcs = Object.create(null);
|