@lvce-editor/find-widget-worker 3.7.5 → 3.9.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/findWidgetWorkerMain.js +154 -36
- package/package.json +1 -1
|
@@ -891,11 +891,11 @@ const SetValueByName = 'Viewlet.setValueByName';
|
|
|
891
891
|
|
|
892
892
|
const FocusFindWidget$1 = 16;
|
|
893
893
|
const FocusFindWidgetCloseButton$1 = 48;
|
|
894
|
-
const FocusFindWidgetNextMatchButton = 49;
|
|
895
|
-
const FocusFindWidgetPreviousMatchButton = 50;
|
|
894
|
+
const FocusFindWidgetNextMatchButton$1 = 49;
|
|
895
|
+
const FocusFindWidgetPreviousMatchButton$1 = 50;
|
|
896
896
|
const FocusFindWidgetReplace$1 = 43;
|
|
897
897
|
const FocusFindWidgetReplaceAllButton$1 = 47;
|
|
898
|
-
const FocusFindWidgetReplaceButton = 46;
|
|
898
|
+
const FocusFindWidgetReplaceButton$1 = 46;
|
|
899
899
|
const FocusIgnoreFiles = 1012;
|
|
900
900
|
const FocusSearchExcludeInput = 1008;
|
|
901
901
|
const FocusSearchIncludeInput = 1007;
|
|
@@ -1058,28 +1058,87 @@ const terminate = () => {
|
|
|
1058
1058
|
|
|
1059
1059
|
const close$1 = async state => {
|
|
1060
1060
|
const {
|
|
1061
|
-
editorUid
|
|
1061
|
+
editorUid,
|
|
1062
|
+
instanceId
|
|
1062
1063
|
} = state;
|
|
1063
|
-
|
|
1064
|
-
|
|
1064
|
+
if (instanceId) {
|
|
1065
|
+
// @ts-ignore
|
|
1066
|
+
await invoke('Editor.requestFindWidgetClose', {
|
|
1067
|
+
editorUid,
|
|
1068
|
+
instanceId
|
|
1069
|
+
});
|
|
1070
|
+
} else {
|
|
1071
|
+
// @ts-ignore
|
|
1072
|
+
await invoke('Editor.closeFind2', editorUid);
|
|
1073
|
+
}
|
|
1065
1074
|
return state;
|
|
1066
1075
|
};
|
|
1067
1076
|
|
|
1077
|
+
const registry = create$1();
|
|
1078
|
+
const instanceUids = new Map();
|
|
1068
1079
|
const {
|
|
1069
|
-
dispose: dispose$1,
|
|
1070
1080
|
get,
|
|
1071
1081
|
getCommandIds,
|
|
1072
1082
|
registerCommands,
|
|
1073
1083
|
set,
|
|
1074
1084
|
wrapCommand,
|
|
1075
1085
|
wrapGetter
|
|
1076
|
-
} =
|
|
1086
|
+
} = registry;
|
|
1087
|
+
const registerInstance = (instanceId, uid) => {
|
|
1088
|
+
const previousUid = instanceUids.get(instanceId);
|
|
1089
|
+
if (previousUid !== undefined && previousUid !== uid) {
|
|
1090
|
+
registry.dispose(previousUid);
|
|
1091
|
+
}
|
|
1092
|
+
instanceUids.set(instanceId, uid);
|
|
1093
|
+
};
|
|
1094
|
+
const resolveUid = instanceId => {
|
|
1095
|
+
return instanceUids.get(instanceId);
|
|
1096
|
+
};
|
|
1097
|
+
const dispose$1 = uid => {
|
|
1098
|
+
const state = registry.get(uid)?.newState;
|
|
1099
|
+
if (state?.instanceId) {
|
|
1100
|
+
instanceUids.delete(state.instanceId);
|
|
1101
|
+
}
|
|
1102
|
+
registry.dispose(uid);
|
|
1103
|
+
};
|
|
1104
|
+
const disposeInstance$1 = instanceId => {
|
|
1105
|
+
const uid = instanceUids.get(instanceId);
|
|
1106
|
+
if (uid === undefined) {
|
|
1107
|
+
return;
|
|
1108
|
+
}
|
|
1109
|
+
instanceUids.delete(instanceId);
|
|
1110
|
+
registry.dispose(uid);
|
|
1111
|
+
};
|
|
1112
|
+
const wrapInstanceCommand = fn => {
|
|
1113
|
+
return async (instanceId, ...args) => {
|
|
1114
|
+
const uid = instanceUids.get(instanceId);
|
|
1115
|
+
if (uid === undefined) {
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
const states = registry.get(uid);
|
|
1119
|
+
if (!states) {
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
const newerState = await fn(states.newState, ...args);
|
|
1123
|
+
if (states.oldState === newerState || states.newState === newerState) {
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
if (instanceUids.get(instanceId) !== uid) {
|
|
1127
|
+
return;
|
|
1128
|
+
}
|
|
1129
|
+
const latest = registry.get(uid);
|
|
1130
|
+
if (!latest) {
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
registry.set(uid, latest.oldState, newerState);
|
|
1134
|
+
};
|
|
1135
|
+
};
|
|
1077
1136
|
|
|
1078
1137
|
const User = 1;
|
|
1079
1138
|
const Script = 2;
|
|
1080
1139
|
const Unknown = 0;
|
|
1081
1140
|
|
|
1082
|
-
const
|
|
1141
|
+
const createState = (uid, x, y, width, height, parentUid, instanceId) => {
|
|
1083
1142
|
const state = {
|
|
1084
1143
|
ariaAnnouncement: '',
|
|
1085
1144
|
editorHeight: height,
|
|
@@ -1100,6 +1159,9 @@ const create = (uid, x, y, width, height, parentUid) => {
|
|
|
1100
1159
|
inputPaddingBottom: 4,
|
|
1101
1160
|
inputPaddingTop: 4,
|
|
1102
1161
|
inputSource: 0,
|
|
1162
|
+
...(instanceId && {
|
|
1163
|
+
instanceId
|
|
1164
|
+
}),
|
|
1103
1165
|
lines: [],
|
|
1104
1166
|
matchCase: false,
|
|
1105
1167
|
matchCount: 0,
|
|
@@ -1122,8 +1184,17 @@ const create = (uid, x, y, width, height, parentUid) => {
|
|
|
1122
1184
|
y: 0
|
|
1123
1185
|
};
|
|
1124
1186
|
set(uid, state, state);
|
|
1187
|
+
if (instanceId) {
|
|
1188
|
+
registerInstance(instanceId, uid);
|
|
1189
|
+
}
|
|
1125
1190
|
return state;
|
|
1126
1191
|
};
|
|
1192
|
+
const create = (uid, x, y, width, height, parentUid) => {
|
|
1193
|
+
return createState(uid, x, y, width, height, parentUid);
|
|
1194
|
+
};
|
|
1195
|
+
const createInstance = (instanceId, uid, x, y, width, height, parentUid) => {
|
|
1196
|
+
return createState(uid, x, y, width, height, parentUid, instanceId);
|
|
1197
|
+
};
|
|
1127
1198
|
|
|
1128
1199
|
const isEqual$8 = (oldState, newState) => {
|
|
1129
1200
|
return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
|
|
@@ -1193,15 +1264,28 @@ const diff2 = uid => {
|
|
|
1193
1264
|
const diffResult = diff(oldState, newState);
|
|
1194
1265
|
return diffResult;
|
|
1195
1266
|
};
|
|
1267
|
+
const diffInstance = instanceId => {
|
|
1268
|
+
const uid = resolveUid(instanceId);
|
|
1269
|
+
if (uid === undefined) {
|
|
1270
|
+
return [];
|
|
1271
|
+
}
|
|
1272
|
+
return diff2(uid);
|
|
1273
|
+
};
|
|
1196
1274
|
|
|
1197
1275
|
const dispose = uid => {
|
|
1198
1276
|
return dispose$1(uid);
|
|
1199
1277
|
};
|
|
1278
|
+
const disposeInstance = instanceId => {
|
|
1279
|
+
return disposeInstance$1(instanceId);
|
|
1280
|
+
};
|
|
1200
1281
|
|
|
1201
1282
|
const FindWidget$1 = 16;
|
|
1202
1283
|
const FocusFindWidgetCloseButton = 48;
|
|
1284
|
+
const FocusFindWidgetNextMatchButton = 49;
|
|
1285
|
+
const FocusFindWidgetPreviousMatchButton = 50;
|
|
1203
1286
|
const FocusFindWidgetReplace = 43;
|
|
1204
1287
|
const FocusFindWidgetReplaceAllButton = 47;
|
|
1288
|
+
const FocusFindWidgetReplaceButton = 46;
|
|
1205
1289
|
const FocusFindWidgetToggleReplace = 42;
|
|
1206
1290
|
|
|
1207
1291
|
const setFindWidgetFocus = (state, focusKey) => {
|
|
@@ -1282,6 +1366,14 @@ const focusPrevious = state => {
|
|
|
1282
1366
|
return focusIndex(state, matchIndex - 1);
|
|
1283
1367
|
};
|
|
1284
1368
|
|
|
1369
|
+
const focusNextMatchButton = state => {
|
|
1370
|
+
return setFindWidgetFocus(state, FocusFindWidgetNextMatchButton);
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
const focusPreviousMatchButton = state => {
|
|
1374
|
+
return setFindWidgetFocus(state, FocusFindWidgetPreviousMatchButton);
|
|
1375
|
+
};
|
|
1376
|
+
|
|
1285
1377
|
const focusReplace = state => {
|
|
1286
1378
|
return setFindWidgetFocus(state, FocusFindWidgetReplace);
|
|
1287
1379
|
};
|
|
@@ -1290,6 +1382,14 @@ const focusReplaceAllButton = state => {
|
|
|
1290
1382
|
return setFindWidgetFocus(state, FocusFindWidgetReplaceAllButton);
|
|
1291
1383
|
};
|
|
1292
1384
|
|
|
1385
|
+
const focusReplaceButton = state => {
|
|
1386
|
+
return setFindWidgetFocus(state, FocusFindWidgetReplaceButton);
|
|
1387
|
+
};
|
|
1388
|
+
|
|
1389
|
+
const focusToggleReplaceButton = state => {
|
|
1390
|
+
return setFindWidgetFocus(state, FocusFindWidgetToggleReplace);
|
|
1391
|
+
};
|
|
1392
|
+
|
|
1293
1393
|
const handleBlur = async state => {
|
|
1294
1394
|
return {
|
|
1295
1395
|
...state,
|
|
@@ -2009,19 +2109,19 @@ const getKeyBindings = () => {
|
|
|
2009
2109
|
}, {
|
|
2010
2110
|
command: 'FindWidget.focusNextMatchButton',
|
|
2011
2111
|
key: Tab,
|
|
2012
|
-
when: FocusFindWidgetPreviousMatchButton
|
|
2112
|
+
when: FocusFindWidgetPreviousMatchButton$1
|
|
2013
2113
|
}, {
|
|
2014
2114
|
command: 'FindWidget.focusReplace',
|
|
2015
2115
|
key: Shift | Tab,
|
|
2016
|
-
when: FocusFindWidgetPreviousMatchButton
|
|
2116
|
+
when: FocusFindWidgetPreviousMatchButton$1
|
|
2017
2117
|
}, {
|
|
2018
2118
|
command: 'FindWidget.focusPreviousMatchButton',
|
|
2019
2119
|
key: Shift | Tab,
|
|
2020
|
-
when: FocusFindWidgetNextMatchButton
|
|
2120
|
+
when: FocusFindWidgetNextMatchButton$1
|
|
2021
2121
|
}, {
|
|
2022
2122
|
command: 'FindWidget.focusCloseButton',
|
|
2023
2123
|
key: Tab,
|
|
2024
|
-
when: FocusFindWidgetNextMatchButton
|
|
2124
|
+
when: FocusFindWidgetNextMatchButton$1
|
|
2025
2125
|
}, {
|
|
2026
2126
|
command: 'FindWidget.focusNextMatchButton',
|
|
2027
2127
|
key: Shift | Tab,
|
|
@@ -2037,11 +2137,11 @@ const getKeyBindings = () => {
|
|
|
2037
2137
|
}, {
|
|
2038
2138
|
command: 'FindWidget.focusReplaceAllButton',
|
|
2039
2139
|
key: Tab,
|
|
2040
|
-
when: FocusFindWidgetReplaceButton
|
|
2140
|
+
when: FocusFindWidgetReplaceButton$1
|
|
2041
2141
|
}, {
|
|
2042
2142
|
command: 'FindWidget.focusCloseButton',
|
|
2043
2143
|
key: Shift | Tab,
|
|
2044
|
-
when: FocusFindWidgetReplaceButton
|
|
2144
|
+
when: FocusFindWidgetReplaceButton$1
|
|
2045
2145
|
}, {
|
|
2046
2146
|
command: 'FindWidget.focusReplaceButton',
|
|
2047
2147
|
key: Shift | Tab,
|
|
@@ -2417,7 +2517,7 @@ const ViewletFindWidget = 'ViewletFindWidget';
|
|
|
2417
2517
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
2418
2518
|
return {
|
|
2419
2519
|
childCount: 0,
|
|
2420
|
-
className:
|
|
2520
|
+
className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
|
|
2421
2521
|
role: None,
|
|
2422
2522
|
type
|
|
2423
2523
|
};
|
|
@@ -2431,10 +2531,7 @@ const getIconButtonVirtualDom = iconButton => {
|
|
|
2431
2531
|
name,
|
|
2432
2532
|
onClick
|
|
2433
2533
|
} = iconButton;
|
|
2434
|
-
|
|
2435
|
-
if (disabled) {
|
|
2436
|
-
className += ' ' + IconButtonDisabled;
|
|
2437
|
-
}
|
|
2534
|
+
const className = mergeClassNames(IconButton, disabled ? IconButtonDisabled : '');
|
|
2438
2535
|
return [{
|
|
2439
2536
|
ariaLabel: label,
|
|
2440
2537
|
childCount: 1,
|
|
@@ -2467,6 +2564,8 @@ const getMatchCountVirtualDom = (matchCountText, matchCount, hasValue, hasError
|
|
|
2467
2564
|
}, text(matchCountText)];
|
|
2468
2565
|
};
|
|
2469
2566
|
|
|
2567
|
+
const Focusable = 0;
|
|
2568
|
+
|
|
2470
2569
|
const checkedClassName = mergeClassNames(SearchFieldButton, SearchFieldButtonChecked);
|
|
2471
2570
|
const unCheckedClassName = SearchFieldButton;
|
|
2472
2571
|
const getSearchFieldButtonVirtualDom = button => {
|
|
@@ -2484,7 +2583,7 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
2484
2583
|
name,
|
|
2485
2584
|
onClick,
|
|
2486
2585
|
role: CheckBox,
|
|
2487
|
-
tabIndex:
|
|
2586
|
+
tabIndex: Focusable,
|
|
2488
2587
|
title,
|
|
2489
2588
|
type: Button
|
|
2490
2589
|
}, {
|
|
@@ -2531,6 +2630,11 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
2531
2630
|
return dom;
|
|
2532
2631
|
};
|
|
2533
2632
|
|
|
2633
|
+
const findWidgetFindNode = {
|
|
2634
|
+
childCount: 2,
|
|
2635
|
+
className: FindWidgetFind,
|
|
2636
|
+
type: Div
|
|
2637
|
+
};
|
|
2534
2638
|
const getExtraClassName = (hasError, inputFocused) => {
|
|
2535
2639
|
if (hasError) {
|
|
2536
2640
|
return SearchFieldError;
|
|
@@ -2542,11 +2646,7 @@ const getExtraClassName = (hasError, inputFocused) => {
|
|
|
2542
2646
|
};
|
|
2543
2647
|
const getFindWidgetFindVirtualDom = (matchCountText, buttons, fieldButtons, matchCount, hasValue, hasError, inputFocused) => {
|
|
2544
2648
|
const extraClassName = getExtraClassName(hasError, inputFocused);
|
|
2545
|
-
return [{
|
|
2546
|
-
childCount: 2,
|
|
2547
|
-
className: FindWidgetFind,
|
|
2548
|
-
type: Div
|
|
2549
|
-
}, ...getSearchFieldVirtualDom(SearchValue, find(), HandleInput, fieldButtons, [], HandleFocus, extraClassName, inputFocused, hasError ? 'FindWidgetInputError' : '', hasError ? 'true' : ''), {
|
|
2649
|
+
return [findWidgetFindNode, ...getSearchFieldVirtualDom(SearchValue, find(), HandleInput, fieldButtons, [], HandleFocus, extraClassName, inputFocused, hasError ? 'FindWidgetInputError' : '', hasError ? 'true' : ''), {
|
|
2550
2650
|
childCount: 1 + buttons.length,
|
|
2551
2651
|
className: 'FindWidgetActions',
|
|
2552
2652
|
type: Div
|
|
@@ -2565,17 +2665,19 @@ const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons, replace
|
|
|
2565
2665
|
}, ...getSearchFieldVirtualDom(ReplaceValue, replace(), HandleReplaceInput, [], [], HandleReplaceFocus, extraClassName, replaceInputFocused), ...replaceButtons.flatMap(getIconButtonVirtualDom)];
|
|
2566
2666
|
};
|
|
2567
2667
|
|
|
2668
|
+
const resizerNode = {
|
|
2669
|
+
childCount: 1,
|
|
2670
|
+
className: Resizer,
|
|
2671
|
+
onPointerDown: HandleResizerPointerDown,
|
|
2672
|
+
type: Div
|
|
2673
|
+
};
|
|
2674
|
+
const resizerHighlightNode = {
|
|
2675
|
+
childCount: 0,
|
|
2676
|
+
className: ResizerHighlight,
|
|
2677
|
+
type: Div
|
|
2678
|
+
};
|
|
2568
2679
|
const getResizerVirtualDom = () => {
|
|
2569
|
-
return [
|
|
2570
|
-
childCount: 1,
|
|
2571
|
-
className: Resizer,
|
|
2572
|
-
onPointerDown: HandleResizerPointerDown,
|
|
2573
|
-
type: Div
|
|
2574
|
-
}, {
|
|
2575
|
-
childCount: 0,
|
|
2576
|
-
className: ResizerHighlight,
|
|
2577
|
-
type: Div
|
|
2578
|
-
}];
|
|
2680
|
+
return [resizerNode, resizerHighlightNode];
|
|
2579
2681
|
};
|
|
2580
2682
|
|
|
2581
2683
|
const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
|
|
@@ -2846,6 +2948,13 @@ const render2 = (uid, diffResult) => {
|
|
|
2846
2948
|
const commands = applyRender(oldState, newState, diffResult);
|
|
2847
2949
|
return commands;
|
|
2848
2950
|
};
|
|
2951
|
+
const renderInstance = (instanceId, diffResult) => {
|
|
2952
|
+
const uid = resolveUid(instanceId);
|
|
2953
|
+
if (uid === undefined) {
|
|
2954
|
+
return [];
|
|
2955
|
+
}
|
|
2956
|
+
return render2(uid, diffResult);
|
|
2957
|
+
};
|
|
2849
2958
|
|
|
2850
2959
|
const resize = async (state, dimensions) => {
|
|
2851
2960
|
return state;
|
|
@@ -2875,8 +2984,11 @@ const saveState = state => {
|
|
|
2875
2984
|
const commandMap = {
|
|
2876
2985
|
'FindWidget.close': wrapCommand(close$1),
|
|
2877
2986
|
'FindWidget.create': create,
|
|
2987
|
+
'FindWidget.createInstance': createInstance,
|
|
2878
2988
|
'FindWidget.diff2': diff2,
|
|
2989
|
+
'FindWidget.diffInstance': diffInstance,
|
|
2879
2990
|
'FindWidget.dispose': dispose,
|
|
2991
|
+
'FindWidget.disposeInstance': disposeInstance,
|
|
2880
2992
|
'FindWidget.focusCloseButton': wrapCommand(focusCloseButton),
|
|
2881
2993
|
'FindWidget.focusElement': wrapCommand(focusElement),
|
|
2882
2994
|
'FindWidget.focusFind': wrapCommand(focusFind),
|
|
@@ -2885,10 +2997,14 @@ const commandMap = {
|
|
|
2885
2997
|
'FindWidget.focusLast': wrapCommand(focusLast),
|
|
2886
2998
|
'FindWidget.focusNext': wrapCommand(focusNext),
|
|
2887
2999
|
'FindWidget.focusNextElement': wrapCommand(focusNextElement),
|
|
3000
|
+
'FindWidget.focusNextMatchButton': wrapCommand(focusNextMatchButton),
|
|
2888
3001
|
'FindWidget.focusPrevious': wrapCommand(focusPrevious),
|
|
2889
3002
|
'FindWidget.focusPreviousElement': wrapCommand(focusPreviousElement),
|
|
3003
|
+
'FindWidget.focusPreviousMatchButton': wrapCommand(focusPreviousMatchButton),
|
|
2890
3004
|
'FindWidget.focusReplace': wrapCommand(focusReplace),
|
|
2891
3005
|
'FindWidget.focusReplaceAllButton': wrapCommand(focusReplaceAllButton),
|
|
3006
|
+
'FindWidget.focusReplaceButton': wrapCommand(focusReplaceButton),
|
|
3007
|
+
'FindWidget.focusToggleReplace': wrapCommand(focusToggleReplaceButton),
|
|
2892
3008
|
'FindWidget.getCommandIds': getCommandIds,
|
|
2893
3009
|
'FindWidget.getKeyBindings': getKeyBindings,
|
|
2894
3010
|
'FindWidget.handleBlur': wrapCommand(handleBlur),
|
|
@@ -2903,8 +3019,10 @@ const commandMap = {
|
|
|
2903
3019
|
'FindWidget.handleResizerPointerUp': wrapCommand(handleResizerPointerUp),
|
|
2904
3020
|
'FindWidget.handleToggleReplaceFocus': wrapCommand(handleToggleReplaceFocus),
|
|
2905
3021
|
'FindWidget.loadContent': wrapCommand(loadContent),
|
|
3022
|
+
'FindWidget.loadContentInstance': wrapInstanceCommand(loadContent),
|
|
2906
3023
|
'FindWidget.preventDefaultBrowserFind': wrapCommand(preventDefaultBrowserFind),
|
|
2907
3024
|
'FindWidget.render2': render2,
|
|
3025
|
+
'FindWidget.renderInstance': renderInstance,
|
|
2908
3026
|
'FindWidget.replace': wrapCommand(replace$1),
|
|
2909
3027
|
'FindWidget.replaceAll': wrapCommand(replaceAll$1),
|
|
2910
3028
|
'FindWidget.resize': wrapCommand(resize),
|