@lvce-editor/settings-view 1.13.0 → 1.14.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 +172 -50
- package/package.json +1 -1
|
@@ -991,19 +991,24 @@ const create$1 = (id, uri, x, y, width, height) => {
|
|
|
991
991
|
scrollOffset: 0,
|
|
992
992
|
filteredItemsCount: 0,
|
|
993
993
|
history: [],
|
|
994
|
+
historyIndex: -1,
|
|
994
995
|
modifiedSettings: {}
|
|
995
996
|
};
|
|
996
997
|
set$1(id, state, state);
|
|
997
998
|
};
|
|
998
999
|
|
|
999
|
-
const isEqual$
|
|
1000
|
+
const isEqual$4 = (oldState, newState) => {
|
|
1000
1001
|
return oldState.focus === newState.focus;
|
|
1001
1002
|
};
|
|
1002
1003
|
|
|
1003
|
-
const isEqual$
|
|
1004
|
+
const isEqual$3 = (oldState, newState) => {
|
|
1004
1005
|
return oldState.filteredItems === newState.filteredItems;
|
|
1005
1006
|
};
|
|
1006
1007
|
|
|
1008
|
+
const isEqual$2 = (oldState, newState) => {
|
|
1009
|
+
return newState.inputSource === User || oldState.scrollOffset === newState.scrollOffset;
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1007
1012
|
const isEqual$1 = (oldState, newState) => {
|
|
1008
1013
|
return oldState.filteredItems === newState.filteredItems;
|
|
1009
1014
|
};
|
|
@@ -1012,13 +1017,14 @@ const RenderItems = 1;
|
|
|
1012
1017
|
const RenderFocus = 2;
|
|
1013
1018
|
const RenderValue = 3;
|
|
1014
1019
|
const RenderSettingValues = 10;
|
|
1020
|
+
const RenderScrollOffset = 11;
|
|
1015
1021
|
|
|
1016
1022
|
const isEqual = (oldState, newState) => {
|
|
1017
1023
|
return newState.inputSource === User || oldState.searchValue === newState.searchValue;
|
|
1018
1024
|
};
|
|
1019
1025
|
|
|
1020
|
-
const modules = [isEqual$
|
|
1021
|
-
const numbers = [RenderFocus, RenderItems, RenderValue, RenderSettingValues];
|
|
1026
|
+
const modules = [isEqual$4, isEqual$3, isEqual, isEqual$1, isEqual$2];
|
|
1027
|
+
const numbers = [RenderFocus, RenderItems, RenderValue, RenderSettingValues, RenderScrollOffset];
|
|
1022
1028
|
|
|
1023
1029
|
const diff = (oldState, newState) => {
|
|
1024
1030
|
const diffResult = [];
|
|
@@ -1080,69 +1086,102 @@ const handleClickTab = (state, name) => {
|
|
|
1080
1086
|
};
|
|
1081
1087
|
};
|
|
1082
1088
|
|
|
1089
|
+
const addToHistory = (history, value) => {
|
|
1090
|
+
let newHistory = history;
|
|
1091
|
+
let newHistoryIndex = -1;
|
|
1092
|
+
if (value && value.trim() && !history.includes(value)) {
|
|
1093
|
+
newHistory = [...history, value];
|
|
1094
|
+
newHistoryIndex = newHistory.length - 1;
|
|
1095
|
+
} else if (value && value.trim()) {
|
|
1096
|
+
// If value already exists in history, find its index
|
|
1097
|
+
newHistoryIndex = history.indexOf(value);
|
|
1098
|
+
}
|
|
1099
|
+
return {
|
|
1100
|
+
newHistory,
|
|
1101
|
+
newHistoryIndex
|
|
1102
|
+
};
|
|
1103
|
+
};
|
|
1104
|
+
|
|
1083
1105
|
const handleInput = (state, value, inputSource = User) => {
|
|
1084
1106
|
const {
|
|
1085
1107
|
items,
|
|
1086
1108
|
tabs,
|
|
1087
|
-
preferences
|
|
1109
|
+
preferences,
|
|
1110
|
+
history
|
|
1088
1111
|
} = state;
|
|
1089
1112
|
const filteredItems = getFilteredItems(items, tabs, value, preferences);
|
|
1113
|
+
const {
|
|
1114
|
+
newHistory,
|
|
1115
|
+
newHistoryIndex
|
|
1116
|
+
} = addToHistory(history, value);
|
|
1090
1117
|
return {
|
|
1091
1118
|
...state,
|
|
1092
1119
|
searchValue: value,
|
|
1093
1120
|
filteredItems,
|
|
1121
|
+
history: newHistory,
|
|
1122
|
+
historyIndex: newHistoryIndex,
|
|
1094
1123
|
inputSource
|
|
1095
1124
|
};
|
|
1096
1125
|
};
|
|
1097
1126
|
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
searchValue
|
|
1104
|
-
} = state;
|
|
1105
|
-
const newModifiedSettings = {
|
|
1106
|
-
...modifiedSettings,
|
|
1107
|
-
[name]: true
|
|
1127
|
+
const handleScroll = (state, scrollTop, inputSource = User) => {
|
|
1128
|
+
return {
|
|
1129
|
+
...state,
|
|
1130
|
+
scrollOffset: scrollTop,
|
|
1131
|
+
inputSource
|
|
1108
1132
|
};
|
|
1109
|
-
|
|
1133
|
+
};
|
|
1134
|
+
|
|
1135
|
+
const getNewFilteredItems = (oldModifiedSetings, newModifiedSettings, items, tabs, searchValue, oldFilteredItems) => {
|
|
1136
|
+
if (oldModifiedSetings === newModifiedSettings) {
|
|
1137
|
+
return oldFilteredItems;
|
|
1138
|
+
}
|
|
1139
|
+
return getFilteredItems(items, tabs, searchValue, newModifiedSettings);
|
|
1140
|
+
};
|
|
1110
1141
|
|
|
1111
|
-
|
|
1142
|
+
const getNewModifiedSettings = (modifiedSettings, name) => {
|
|
1143
|
+
if (name in modifiedSettings) {
|
|
1144
|
+
return modifiedSettings;
|
|
1145
|
+
}
|
|
1112
1146
|
return {
|
|
1113
|
-
...
|
|
1114
|
-
|
|
1115
|
-
filteredItems
|
|
1147
|
+
...modifiedSettings,
|
|
1148
|
+
[name]: true
|
|
1116
1149
|
};
|
|
1117
1150
|
};
|
|
1118
1151
|
|
|
1119
|
-
const
|
|
1120
|
-
// TODO update value
|
|
1152
|
+
const handleSettingUpdate = (state, name, value, inputSource) => {
|
|
1121
1153
|
const {
|
|
1122
1154
|
modifiedSettings,
|
|
1123
1155
|
items,
|
|
1124
1156
|
tabs,
|
|
1125
|
-
searchValue
|
|
1157
|
+
searchValue,
|
|
1158
|
+
preferences,
|
|
1159
|
+
filteredItems
|
|
1126
1160
|
} = state;
|
|
1127
|
-
const newModifiedSettings =
|
|
1128
|
-
|
|
1129
|
-
|
|
1161
|
+
const newModifiedSettings = getNewModifiedSettings(modifiedSettings, name);
|
|
1162
|
+
const newPreferences = {
|
|
1163
|
+
...preferences,
|
|
1164
|
+
[name]: value
|
|
1130
1165
|
};
|
|
1131
|
-
|
|
1132
|
-
// TODO don't need to update items if it was already modified
|
|
1133
|
-
const filteredItems = getFilteredItems(items, tabs, searchValue, newModifiedSettings);
|
|
1166
|
+
const newFilteredItems = getNewFilteredItems(modifiedSettings, newModifiedSettings, items, tabs, searchValue, filteredItems);
|
|
1134
1167
|
return {
|
|
1135
1168
|
...state,
|
|
1136
1169
|
inputSource,
|
|
1137
|
-
filteredItems
|
|
1170
|
+
filteredItems: newFilteredItems,
|
|
1171
|
+
preferences: newPreferences
|
|
1138
1172
|
};
|
|
1139
1173
|
};
|
|
1140
1174
|
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1175
|
+
const handleSettingChecked = (state, name, value, source = User) => {
|
|
1176
|
+
return handleSettingUpdate(state, name, value, source);
|
|
1177
|
+
};
|
|
1178
|
+
|
|
1179
|
+
const handleSettingInput = (state, name, value, inputSource = User) => {
|
|
1180
|
+
return handleSettingUpdate(state, name, value, inputSource);
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
const handleSettingSelect = (state, name, value, source = User) => {
|
|
1184
|
+
return handleSettingUpdate(state, name, value, source);
|
|
1146
1185
|
};
|
|
1147
1186
|
|
|
1148
1187
|
const initialize = async () => {
|
|
@@ -3231,6 +3270,12 @@ const getSavedTabId = savedState => {
|
|
|
3231
3270
|
}
|
|
3232
3271
|
return '';
|
|
3233
3272
|
};
|
|
3273
|
+
const getSavedScrollOffset = savedState => {
|
|
3274
|
+
if (savedState && typeof savedState === 'object' && 'scrollOffset' in savedState && typeof savedState.scrollOffset === 'number') {
|
|
3275
|
+
return savedState.scrollOffset;
|
|
3276
|
+
}
|
|
3277
|
+
return 0;
|
|
3278
|
+
};
|
|
3234
3279
|
const restoreState = savedState => {
|
|
3235
3280
|
if (!savedState) {
|
|
3236
3281
|
return {
|
|
@@ -3238,7 +3283,8 @@ const restoreState = savedState => {
|
|
|
3238
3283
|
minLineY: 0,
|
|
3239
3284
|
deltaY: 0,
|
|
3240
3285
|
tabId: '',
|
|
3241
|
-
searchValue: ''
|
|
3286
|
+
searchValue: '',
|
|
3287
|
+
scrollOffset: 0
|
|
3242
3288
|
};
|
|
3243
3289
|
}
|
|
3244
3290
|
const root = getSavedWorkspacePath(savedState);
|
|
@@ -3246,12 +3292,14 @@ const restoreState = savedState => {
|
|
|
3246
3292
|
const deltaY = getSavedDeltaY(savedState);
|
|
3247
3293
|
const tabId = getSavedTabId(savedState);
|
|
3248
3294
|
const searchValue = getSavedSearchValue(savedState);
|
|
3295
|
+
const scrollOffset = getSavedScrollOffset(savedState);
|
|
3249
3296
|
return {
|
|
3250
3297
|
root,
|
|
3251
3298
|
minLineY,
|
|
3252
3299
|
deltaY,
|
|
3253
3300
|
tabId,
|
|
3254
|
-
searchValue
|
|
3301
|
+
searchValue,
|
|
3302
|
+
scrollOffset
|
|
3255
3303
|
};
|
|
3256
3304
|
};
|
|
3257
3305
|
|
|
@@ -3265,7 +3313,8 @@ const getModifiedSettings = preferences => {
|
|
|
3265
3313
|
const loadContent = async (state, savedState) => {
|
|
3266
3314
|
const {
|
|
3267
3315
|
searchValue,
|
|
3268
|
-
tabId
|
|
3316
|
+
tabId,
|
|
3317
|
+
scrollOffset
|
|
3269
3318
|
} = restoreState(savedState);
|
|
3270
3319
|
const tabs = getTabs();
|
|
3271
3320
|
const newTabs = getUpdatedTabs(tabs, tabId);
|
|
@@ -3280,6 +3329,7 @@ const loadContent = async (state, savedState) => {
|
|
|
3280
3329
|
items,
|
|
3281
3330
|
modifiedSettings,
|
|
3282
3331
|
preferences,
|
|
3332
|
+
scrollOffset,
|
|
3283
3333
|
searchValue,
|
|
3284
3334
|
tabs: newTabs
|
|
3285
3335
|
};
|
|
@@ -3378,6 +3428,7 @@ const HandleClickTab = 'handleClickTab';
|
|
|
3378
3428
|
const HandleInput = 'handleInput';
|
|
3379
3429
|
const HandleSettingInput = 'handleSettingInput';
|
|
3380
3430
|
const HandleSettingChecked = 'handleSettingChecked';
|
|
3431
|
+
const HandleScroll = 'handleScroll';
|
|
3381
3432
|
const HandleSettingSelect = 'handleSettingSelect';
|
|
3382
3433
|
|
|
3383
3434
|
const getButtonClassName = hasSearchValue => {
|
|
@@ -3449,7 +3500,7 @@ const getItemCheckBoxVirtualDom = item => {
|
|
|
3449
3500
|
className: SettingsItem,
|
|
3450
3501
|
childCount: 3,
|
|
3451
3502
|
role: 'group',
|
|
3452
|
-
|
|
3503
|
+
'data-modified': isModified
|
|
3453
3504
|
}, {
|
|
3454
3505
|
type: VirtualDomElements.H3,
|
|
3455
3506
|
childCount: 1
|
|
@@ -3492,14 +3543,17 @@ const getItemNumberVirtualDom = item => {
|
|
|
3492
3543
|
const {
|
|
3493
3544
|
heading,
|
|
3494
3545
|
description,
|
|
3495
|
-
id
|
|
3546
|
+
id,
|
|
3547
|
+
modified
|
|
3496
3548
|
} = item;
|
|
3497
3549
|
const domId = getInputId(id);
|
|
3550
|
+
const isModified = modified || false;
|
|
3498
3551
|
return [{
|
|
3499
3552
|
type: VirtualDomElements.Div,
|
|
3500
3553
|
className: SettingsItem,
|
|
3501
3554
|
childCount: 3,
|
|
3502
|
-
role: 'group'
|
|
3555
|
+
role: 'group',
|
|
3556
|
+
'data-modified': isModified
|
|
3503
3557
|
}, ...getItemHeadingDom(heading), ...getItemLabelDom(domId, description), {
|
|
3504
3558
|
type: VirtualDomElements.Input,
|
|
3505
3559
|
className: InputBox,
|
|
@@ -3628,7 +3682,8 @@ const getSettingsContentDom = (items, tabs, searchValue) => {
|
|
|
3628
3682
|
return [{
|
|
3629
3683
|
type: VirtualDomElements.Div,
|
|
3630
3684
|
className: SettingsContent,
|
|
3631
|
-
childCount: 2
|
|
3685
|
+
childCount: 2,
|
|
3686
|
+
onScroll: HandleScroll
|
|
3632
3687
|
}, {
|
|
3633
3688
|
type: VirtualDomElements.H1,
|
|
3634
3689
|
className: SettingsContentHeading,
|
|
@@ -3699,6 +3754,16 @@ const renderItems = (oldState, newState) => {
|
|
|
3699
3754
|
return ['Viewlet.setDom2', newState.id, dom];
|
|
3700
3755
|
};
|
|
3701
3756
|
|
|
3757
|
+
const renderScrollOffset = (oldState, newState) => {
|
|
3758
|
+
const {
|
|
3759
|
+
id,
|
|
3760
|
+
scrollOffset
|
|
3761
|
+
} = newState;
|
|
3762
|
+
const selector = '.SettingsContent';
|
|
3763
|
+
const property = 'scrollTop';
|
|
3764
|
+
return ['Viewlet.setProperty', id, selector, property, scrollOffset];
|
|
3765
|
+
};
|
|
3766
|
+
|
|
3702
3767
|
const renderSettingValues = (oldState, newState) => {
|
|
3703
3768
|
const {
|
|
3704
3769
|
filteredItems,
|
|
@@ -3729,6 +3794,8 @@ const getRenderer = diffType => {
|
|
|
3729
3794
|
return renderValue;
|
|
3730
3795
|
case RenderSettingValues:
|
|
3731
3796
|
return renderSettingValues;
|
|
3797
|
+
case RenderScrollOffset:
|
|
3798
|
+
return renderScrollOffset;
|
|
3732
3799
|
default:
|
|
3733
3800
|
throw new Error('unknown renderer');
|
|
3734
3801
|
}
|
|
@@ -3773,6 +3840,10 @@ const renderEventListeners = () => {
|
|
|
3773
3840
|
}, {
|
|
3774
3841
|
name: HandleSettingChecked,
|
|
3775
3842
|
params: ['handleSettingChecked', 'event.target.name', 'event.target.value']
|
|
3843
|
+
}, {
|
|
3844
|
+
name: HandleScroll,
|
|
3845
|
+
params: ['handleScroll', 'event.target.scrollTop'],
|
|
3846
|
+
passive: true
|
|
3776
3847
|
}, {
|
|
3777
3848
|
name: HandleSettingSelect,
|
|
3778
3849
|
params: ['handleSettingSelect', 'event.target.name', 'event.target.value']
|
|
@@ -3782,7 +3853,8 @@ const renderEventListeners = () => {
|
|
|
3782
3853
|
const saveState = state => {
|
|
3783
3854
|
const {
|
|
3784
3855
|
tabs,
|
|
3785
|
-
searchValue
|
|
3856
|
+
searchValue,
|
|
3857
|
+
scrollOffset
|
|
3786
3858
|
} = state;
|
|
3787
3859
|
const selectedTab = getSelectedTabId(tabs);
|
|
3788
3860
|
return {
|
|
@@ -3792,15 +3864,69 @@ const saveState = state => {
|
|
|
3792
3864
|
maxLineY: 0,
|
|
3793
3865
|
deltaY: 0,
|
|
3794
3866
|
searchValue,
|
|
3795
|
-
selectedTab
|
|
3867
|
+
selectedTab,
|
|
3868
|
+
scrollOffset
|
|
3869
|
+
};
|
|
3870
|
+
};
|
|
3871
|
+
|
|
3872
|
+
const useNextSearchValue = state => {
|
|
3873
|
+
const {
|
|
3874
|
+
history,
|
|
3875
|
+
historyIndex,
|
|
3876
|
+
items,
|
|
3877
|
+
tabs,
|
|
3878
|
+
preferences
|
|
3879
|
+
} = state;
|
|
3880
|
+
if (history.length === 0 || historyIndex >= history.length - 1) {
|
|
3881
|
+
return state;
|
|
3882
|
+
}
|
|
3883
|
+
const newHistoryIndex = historyIndex + 1;
|
|
3884
|
+
const newSearchValue = history[newHistoryIndex];
|
|
3885
|
+
const filteredItems = getFilteredItems(items, tabs, newSearchValue, preferences);
|
|
3886
|
+
return {
|
|
3887
|
+
...state,
|
|
3888
|
+
searchValue: newSearchValue,
|
|
3889
|
+
historyIndex: newHistoryIndex,
|
|
3890
|
+
filteredItems,
|
|
3891
|
+
inputSource: Script
|
|
3892
|
+
};
|
|
3893
|
+
};
|
|
3894
|
+
|
|
3895
|
+
const usePreviousSearchValue = state => {
|
|
3896
|
+
const {
|
|
3897
|
+
history,
|
|
3898
|
+
historyIndex,
|
|
3899
|
+
items,
|
|
3900
|
+
tabs,
|
|
3901
|
+
preferences
|
|
3902
|
+
} = state;
|
|
3903
|
+
if (history.length === 0 || historyIndex <= 0) {
|
|
3904
|
+
return state;
|
|
3905
|
+
}
|
|
3906
|
+
const newHistoryIndex = historyIndex - 1;
|
|
3907
|
+
const newSearchValue = history[newHistoryIndex];
|
|
3908
|
+
const filteredItems = getFilteredItems(items, tabs, newSearchValue, preferences);
|
|
3909
|
+
return {
|
|
3910
|
+
...state,
|
|
3911
|
+
searchValue: newSearchValue,
|
|
3912
|
+
historyIndex: newHistoryIndex,
|
|
3913
|
+
filteredItems,
|
|
3914
|
+
inputSource: Script
|
|
3796
3915
|
};
|
|
3797
3916
|
};
|
|
3798
3917
|
|
|
3799
3918
|
const commandMap = {
|
|
3800
3919
|
'Initialize.initialize': initialize,
|
|
3920
|
+
'Settings.clear': wrapCommand(clear$1),
|
|
3801
3921
|
'Settings.create': create$1,
|
|
3802
3922
|
'Settings.diff2': diff2,
|
|
3803
3923
|
'Settings.getCommandIds': getCommandIds,
|
|
3924
|
+
'Settings.handleClickTab': wrapCommand(handleClickTab),
|
|
3925
|
+
'Settings.handleInput': wrapCommand(handleInput),
|
|
3926
|
+
'Settings.handleScroll': wrapCommand(handleScroll),
|
|
3927
|
+
'Settings.handleSettingChecked': wrapCommand(handleSettingChecked),
|
|
3928
|
+
'Settings.handleSettingInput': wrapCommand(handleSettingInput),
|
|
3929
|
+
'Settings.handleSettingSelect': wrapCommand(handleSettingSelect),
|
|
3804
3930
|
'Settings.loadContent': wrapCommand(loadContent),
|
|
3805
3931
|
'Settings.render2': render2,
|
|
3806
3932
|
'Settings.renderActions': renderActions,
|
|
@@ -3808,12 +3934,8 @@ const commandMap = {
|
|
|
3808
3934
|
'Settings.restoreState': restoreState,
|
|
3809
3935
|
'Settings.saveState': wrapGetter(saveState),
|
|
3810
3936
|
'Settings.terminate': terminate,
|
|
3811
|
-
'Settings.
|
|
3812
|
-
'Settings.
|
|
3813
|
-
'Settings.handleInput': wrapCommand(handleInput),
|
|
3814
|
-
'Settings.handleSettingInput': wrapCommand(handleSettingInput),
|
|
3815
|
-
'Settings.handleSettingChecked': wrapCommand(handleSettingChecked),
|
|
3816
|
-
'Settings.handleSettingSelect': wrapCommand(handleSettingSelect)
|
|
3937
|
+
'Settings.useNextSearchValue': wrapCommand(useNextSearchValue),
|
|
3938
|
+
'Settings.usePreviousSearchValue': wrapCommand(usePreviousSearchValue)
|
|
3817
3939
|
};
|
|
3818
3940
|
|
|
3819
3941
|
const rpcs = Object.create(null);
|