@lvce-editor/find-widget-worker 2.3.0 → 2.5.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.
@@ -940,93 +940,6 @@ const terminate = () => {
940
940
  globalThis.close();
941
941
  };
942
942
 
943
- const {
944
- get: get$1,
945
- set: set$3,
946
- wrapCommand,
947
- dispose: dispose$2,
948
- getCommandIds,
949
- registerCommands,
950
- wrapGetter
951
- } = create$2();
952
-
953
- const User$1 = 1;
954
- const Script$1 = 2;
955
- const Unknown = 0;
956
-
957
- const create$1 = (uid, x, y, width, height, parentUid) => {
958
- const state = {
959
- uid,
960
- value: '',
961
- ariaAnnouncement: '',
962
- matches: new Uint32Array(),
963
- matchIndex: -1,
964
- matchCount: 0,
965
- replaceExpanded: false,
966
- useRegularExpression: false,
967
- matchCase: false,
968
- matchWholeWord: false,
969
- replacement: '',
970
- editorUid: parentUid,
971
- x: 0,
972
- y: 0,
973
- width: 0,
974
- height: 0,
975
- focused: false,
976
- focusSource: Unknown,
977
- focus: 0,
978
- version: 0,
979
- lines: [],
980
- selections: [],
981
- editorX: x,
982
- editorY: y,
983
- editorWidth: width,
984
- editorHeight: height,
985
- inputSource: 0,
986
- preserveCase: false,
987
- resizerPointerDown: false,
988
- minWidth: 400,
989
- history: [],
990
- inputErrorMessage: '',
991
- searchInputHeight: 15,
992
- inputLineHeight: 15,
993
- inputPaddingTop: 4,
994
- inputPaddingBottom: 4,
995
- inputBorderWidth: 1,
996
- inputGap: 3
997
- };
998
- set$3(uid, state, state);
999
- return state;
1000
- };
1001
-
1002
- const isEqual$8 = (oldState, newState) => {
1003
- return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
1004
- };
1005
-
1006
- const isEqual$7 = (oldState, newState) => {
1007
- return newState.width === newState.width && oldState.height === newState.height && oldState.x === newState.x && oldState.searchInputHeight === newState.searchInputHeight;
1008
- };
1009
-
1010
- const isEqual$6 = (oldState, newState) => {
1011
- return oldState.version === newState.version;
1012
- };
1013
-
1014
- const isEqual$5 = (oldState, newState) => {
1015
- return oldState.focused === newState.focused && oldState.focus === newState.focus;
1016
- };
1017
-
1018
- const isEqual$4 = (oldState, newState) => {
1019
- return oldState.focused === newState.focused;
1020
- };
1021
-
1022
- const isEqual$3 = (oldState, newState) => {
1023
- return oldState.version === newState.version && oldState.replaceExpanded === newState.replaceExpanded && oldState.matchCount === newState.matchCount && oldState.matchIndex === newState.matchIndex && oldState.matchCase === newState.matchCase && oldState.matchWholeWord === newState.matchWholeWord && oldState.useRegularExpression === newState.useRegularExpression && oldState.preserveCase === newState.preserveCase;
1024
- };
1025
-
1026
- const isEqual$2 = (oldState, newState) => {
1027
- return oldState.version === newState.version;
1028
- };
1029
-
1030
943
  const CheckBox = 'checkbox';
1031
944
  const Group = 'group';
1032
945
  const None = 'none';
@@ -1045,8 +958,8 @@ const Enter = 3;
1045
958
  const KeyF = 34;
1046
959
  const F4 = 60;
1047
960
 
1048
- const User = 1;
1049
- const Script = 2;
961
+ const User$1 = 1;
962
+ const Script$1 = 2;
1050
963
 
1051
964
  const CtrlCmd = 1 << 11 >>> 0;
1052
965
  const Shift = 1 << 10 >>> 0;
@@ -1080,97 +993,33 @@ const FocusSearchWholeWord = 34;
1080
993
  const FocusToggleDetails = 1010;
1081
994
  const FocusToggleReplace = 1020;
1082
995
 
1083
- const isEqual$1 = (oldState, newState) => {
1084
- return newState.inputSource === User || oldState.replacement === newState.replacement;
1085
- };
1086
-
1087
- const RenderBounds = 8;
1088
- const RenderCss = 10;
1089
- const RenderEventListeners = 11;
1090
- const RenderUid = 12;
1091
- const RenderContent = 13;
1092
- const RenderFocusContext = 14;
1093
- const RenderFocus = 15;
1094
- const RenderValue = 16;
1095
- const RenderReplaceValue = 17;
1096
-
1097
- const isEqual = (oldState, newState) => {
1098
- return newState.inputSource === User || oldState.value === newState.value;
1099
- };
1100
-
1101
- const modules = [isEqual$6, isEqual$3, isEqual$8, isEqual$2, isEqual$4, isEqual$5, isEqual, isEqual$1, isEqual$7];
1102
- const numbers = [RenderEventListeners, RenderContent, RenderBounds, RenderUid, RenderFocusContext, RenderFocus, RenderValue, RenderReplaceValue, RenderCss];
1103
-
1104
- const diff = (oldState, newState) => {
1105
- const diffResult = [];
1106
- for (let i = 0; i < modules.length; i++) {
1107
- const fn = modules[i];
1108
- if (!fn(oldState, newState)) {
1109
- diffResult.push(numbers[i]);
1110
- }
1111
- }
1112
- return diffResult;
1113
- };
1114
-
1115
- const diff2 = uid => {
1116
- const {
1117
- oldState,
1118
- newState
1119
- } = get$1(uid);
1120
- const diffResult = diff(oldState, newState);
1121
- return diffResult;
1122
- };
1123
-
1124
- const dispose$1 = uid => {
1125
- return dispose$2(uid);
1126
- };
1127
-
1128
- const FocusFindWidgetCloseButton = 48;
1129
- const FocusFindWidgetReplace = 43;
1130
- const FocusFindWidgetReplaceAllButton = 47;
1131
-
1132
- const setFindWidgetFocus = (state, focusKey) => {
1133
- if (state.focus === focusKey) {
1134
- return state;
1135
- }
1136
- return {
1137
- ...state,
1138
- focus: focusKey,
1139
- focusSource: Script$1
1140
- };
1141
- };
1142
-
1143
- const focusCloseButton = state => {
1144
- return setFindWidgetFocus(state, FocusFindWidgetCloseButton);
1145
- };
1146
-
1147
996
  const rpcs = Object.create(null);
1148
- const set$2 = (id, rpc) => {
997
+ const set$3 = (id, rpc) => {
1149
998
  rpcs[id] = rpc;
1150
999
  };
1151
- const get = id => {
1000
+ const get$1 = id => {
1152
1001
  return rpcs[id];
1153
1002
  };
1154
1003
 
1155
- const create = rpcId => {
1004
+ const create$1 = rpcId => {
1156
1005
  return {
1157
1006
  // @ts-ignore
1158
1007
  invoke(method, ...params) {
1159
- const rpc = get(rpcId);
1008
+ const rpc = get$1(rpcId);
1160
1009
  // @ts-ignore
1161
1010
  return rpc.invoke(method, ...params);
1162
1011
  },
1163
1012
  // @ts-ignore
1164
1013
  invokeAndTransfer(method, ...params) {
1165
- const rpc = get(rpcId);
1014
+ const rpc = get$1(rpcId);
1166
1015
  // @ts-ignore
1167
1016
  return rpc.invokeAndTransfer(method, ...params);
1168
1017
  },
1169
1018
  set(rpc) {
1170
- set$2(rpcId, rpc);
1019
+ set$3(rpcId, rpc);
1171
1020
  },
1172
1021
  async dispose() {
1173
- const rpc = get(rpcId);
1022
+ const rpc = get$1(rpcId);
1174
1023
  await rpc.dispose();
1175
1024
  }
1176
1025
  };
@@ -1179,9 +1028,9 @@ const create = rpcId => {
1179
1028
  const {
1180
1029
  invoke: invoke$1,
1181
1030
  invokeAndTransfer,
1182
- set: set$1,
1183
- dispose
1184
- } = create(EditorWorker$1);
1031
+ set: set$2,
1032
+ dispose: dispose$2
1033
+ } = create$1(EditorWorker$1);
1185
1034
  const sendMessagePortToExtensionHostWorker = async port => {
1186
1035
  const command = 'HandleMessagePort.handleMessagePort2';
1187
1036
  await invokeAndTransfer(
@@ -1251,7 +1100,7 @@ const registerMockRpc = commandMap => {
1251
1100
  const mockRpc = createMockRpc({
1252
1101
  commandMap
1253
1102
  });
1254
- set$1(mockRpc);
1103
+ set$2(mockRpc);
1255
1104
  return mockRpc;
1256
1105
  };
1257
1106
 
@@ -1261,7 +1110,7 @@ const EditorWorker = {
1261
1110
  applyEdit,
1262
1111
  applyWorkspaceEdit,
1263
1112
  closeWidget,
1264
- dispose,
1113
+ dispose: dispose$2,
1265
1114
  getLanguageId,
1266
1115
  getLines: getLines$1,
1267
1116
  getOffsetAtCursor,
@@ -1276,13 +1125,173 @@ const EditorWorker = {
1276
1125
  invokeAndTransfer,
1277
1126
  registerMockRpc,
1278
1127
  sendMessagePortToExtensionHostWorker,
1279
- set: set$1,
1128
+ set: set$2,
1280
1129
  updateDebugInfo
1281
1130
  };
1282
1131
 
1283
1132
  const {
1284
1133
  invoke,
1285
- set} = EditorWorker;
1134
+ set: set$1} = EditorWorker;
1135
+
1136
+ const close$1 = async state => {
1137
+ const {
1138
+ editorUid
1139
+ } = state;
1140
+ // @ts-ignore
1141
+ await invoke('Editor.closeFind2', editorUid);
1142
+ return state;
1143
+ };
1144
+
1145
+ const {
1146
+ get,
1147
+ set,
1148
+ wrapCommand,
1149
+ dispose: dispose$1,
1150
+ getCommandIds,
1151
+ registerCommands,
1152
+ wrapGetter
1153
+ } = create$2();
1154
+
1155
+ const User = 1;
1156
+ const Script = 2;
1157
+ const Unknown = 0;
1158
+
1159
+ const create = (uid, x, y, width, height, parentUid) => {
1160
+ const state = {
1161
+ uid,
1162
+ value: '',
1163
+ ariaAnnouncement: '',
1164
+ matches: new Uint32Array(),
1165
+ matchIndex: -1,
1166
+ matchCount: 0,
1167
+ replaceExpanded: false,
1168
+ useRegularExpression: false,
1169
+ matchCase: false,
1170
+ matchWholeWord: false,
1171
+ replacement: '',
1172
+ editorUid: parentUid,
1173
+ x: 0,
1174
+ y: 0,
1175
+ width: 0,
1176
+ height: 0,
1177
+ focused: false,
1178
+ focusSource: Unknown,
1179
+ focus: 0,
1180
+ version: 0,
1181
+ lines: [],
1182
+ selections: [],
1183
+ editorX: x,
1184
+ editorY: y,
1185
+ editorWidth: width,
1186
+ editorHeight: height,
1187
+ inputSource: 0,
1188
+ preserveCase: false,
1189
+ resizerPointerDown: false,
1190
+ minWidth: 400,
1191
+ history: [],
1192
+ inputErrorMessage: '',
1193
+ searchInputHeight: 15,
1194
+ inputLineHeight: 15,
1195
+ inputPaddingTop: 4,
1196
+ inputPaddingBottom: 4,
1197
+ inputBorderWidth: 1,
1198
+ inputGap: 3
1199
+ };
1200
+ set(uid, state, state);
1201
+ return state;
1202
+ };
1203
+
1204
+ const isEqual$8 = (oldState, newState) => {
1205
+ return oldState.x === newState.x && oldState.y === newState.y && oldState.width === newState.width && oldState.height === newState.height;
1206
+ };
1207
+
1208
+ const isEqual$7 = (oldState, newState) => {
1209
+ return newState.width === newState.width && oldState.height === newState.height && oldState.x === newState.x && oldState.searchInputHeight === newState.searchInputHeight;
1210
+ };
1211
+
1212
+ const isEqual$6 = (oldState, newState) => {
1213
+ return oldState.version === newState.version;
1214
+ };
1215
+
1216
+ const isEqual$5 = (oldState, newState) => {
1217
+ return oldState.focused === newState.focused && oldState.focus === newState.focus;
1218
+ };
1219
+
1220
+ const isEqual$4 = (oldState, newState) => {
1221
+ return oldState.focused === newState.focused;
1222
+ };
1223
+
1224
+ const isEqual$3 = (oldState, newState) => {
1225
+ return oldState.inputErrorMessage === newState.inputErrorMessage && oldState.matchCase === newState.matchCase && oldState.matchCount === newState.matchCount && oldState.matchIndex === newState.matchIndex && oldState.matchWholeWord === newState.matchWholeWord && oldState.preserveCase === newState.preserveCase && oldState.replaceExpanded === newState.replaceExpanded && oldState.useRegularExpression === newState.useRegularExpression && oldState.version === newState.version;
1226
+ };
1227
+
1228
+ const isEqual$2 = (oldState, newState) => {
1229
+ return oldState.version === newState.version;
1230
+ };
1231
+
1232
+ const isEqual$1 = (oldState, newState) => {
1233
+ return newState.inputSource === User$1 || oldState.replacement === newState.replacement;
1234
+ };
1235
+
1236
+ const RenderBounds = 8;
1237
+ const RenderCss = 10;
1238
+ const RenderEventListeners = 11;
1239
+ const RenderUid = 12;
1240
+ const RenderContent = 13;
1241
+ const RenderFocusContext = 14;
1242
+ const RenderFocus = 15;
1243
+ const RenderValue = 16;
1244
+ const RenderReplaceValue = 17;
1245
+
1246
+ const isEqual = (oldState, newState) => {
1247
+ return newState.inputSource === User$1 || oldState.value === newState.value;
1248
+ };
1249
+
1250
+ const modules = [isEqual$6, isEqual$3, isEqual$8, isEqual$2, isEqual$4, isEqual$5, isEqual, isEqual$1, isEqual$7];
1251
+ const numbers = [RenderEventListeners, RenderContent, RenderBounds, RenderUid, RenderFocusContext, RenderFocus, RenderValue, RenderReplaceValue, RenderCss];
1252
+
1253
+ const diff = (oldState, newState) => {
1254
+ const diffResult = [];
1255
+ for (let i = 0; i < modules.length; i++) {
1256
+ const fn = modules[i];
1257
+ if (!fn(oldState, newState)) {
1258
+ diffResult.push(numbers[i]);
1259
+ }
1260
+ }
1261
+ return diffResult;
1262
+ };
1263
+
1264
+ const diff2 = uid => {
1265
+ const {
1266
+ oldState,
1267
+ newState
1268
+ } = get(uid);
1269
+ const diffResult = diff(oldState, newState);
1270
+ return diffResult;
1271
+ };
1272
+
1273
+ const dispose = uid => {
1274
+ return dispose$1(uid);
1275
+ };
1276
+
1277
+ const FocusFindWidgetCloseButton = 48;
1278
+ const FocusFindWidgetReplace = 43;
1279
+ const FocusFindWidgetReplaceAllButton = 47;
1280
+
1281
+ const setFindWidgetFocus = (state, focusKey) => {
1282
+ if (state.focus === focusKey) {
1283
+ return state;
1284
+ }
1285
+ return {
1286
+ ...state,
1287
+ focus: focusKey,
1288
+ focusSource: Script
1289
+ };
1290
+ };
1291
+
1292
+ const focusCloseButton = state => {
1293
+ return setFindWidgetFocus(state, FocusFindWidgetCloseButton);
1294
+ };
1286
1295
 
1287
1296
  const setSelections = async (editorUid, selections) => {
1288
1297
  // @ts-ignore
@@ -1413,8 +1422,15 @@ const findMatches = (lines, searchString, options) => {
1413
1422
  };
1414
1423
  }
1415
1424
  const {
1416
- regex
1425
+ regex,
1426
+ error
1417
1427
  } = buildRegex(searchString, options);
1428
+ if (error) {
1429
+ return {
1430
+ matches: new Uint32Array([]),
1431
+ error
1432
+ };
1433
+ }
1418
1434
  const matches = findRegexMatches(lines, regex);
1419
1435
  return {
1420
1436
  matches,
@@ -1498,7 +1514,7 @@ const refresh$1 = (state, value, inputSource) => {
1498
1514
  };
1499
1515
  };
1500
1516
 
1501
- const refresh = (state, value = state.value, inputSource = User) => {
1517
+ const refresh = (state, value = state.value, inputSource = User$1) => {
1502
1518
  return refresh$1(state, value, inputSource);
1503
1519
  };
1504
1520
 
@@ -1510,7 +1526,7 @@ const toggleMatchCase = state => {
1510
1526
  ...state,
1511
1527
  matchCase: !matchCase
1512
1528
  };
1513
- return refresh(newState, newState.value, User);
1529
+ return refresh(newState, newState.value, User$1);
1514
1530
  };
1515
1531
 
1516
1532
  const toggleMatchWholeWord = state => {
@@ -1521,7 +1537,7 @@ const toggleMatchWholeWord = state => {
1521
1537
  ...state,
1522
1538
  matchWholeWord: !matchWholeWord
1523
1539
  };
1524
- return refresh(newState, newState.value, User);
1540
+ return refresh(newState, newState.value, User$1);
1525
1541
  };
1526
1542
 
1527
1543
  const togglePreserveCase = state => {
@@ -1543,7 +1559,7 @@ const toggleUseRegularExpression = state => {
1543
1559
  ...state,
1544
1560
  useRegularExpression: !useRegularExpression
1545
1561
  };
1546
- return refresh(newState, newState.value, User);
1562
+ return refresh(newState, newState.value, User$1);
1547
1563
  };
1548
1564
 
1549
1565
  const Close$2 = 'Close';
@@ -1564,7 +1580,46 @@ const applyEdits = async (editorId, edits) => {
1564
1580
  await invoke('Editor.applyDocumentEdits', editorId, edits);
1565
1581
  };
1566
1582
 
1567
- const getEdits = (matches, value, replacement, startIndex, replaceAll, lines) => {
1583
+ /**
1584
+ * Preserves the case pattern of the original text when replacing.
1585
+ * Supports uppercase, lowercase, PascalCase, and camelCase patterns.
1586
+ */
1587
+ const preserveCase$1 = (originalText, replacementText) => {
1588
+ if (originalText.length === 0 || replacementText.length === 0) {
1589
+ return replacementText;
1590
+ }
1591
+
1592
+ // Check if original text is all uppercase
1593
+ if (originalText === originalText.toUpperCase()) {
1594
+ return replacementText.toUpperCase();
1595
+ }
1596
+
1597
+ // Check if original text is all lowercase
1598
+ if (originalText === originalText.toLowerCase()) {
1599
+ return replacementText.toLowerCase();
1600
+ }
1601
+
1602
+ // Check if original text is PascalCase (first letter uppercase, rest lowercase or mixed)
1603
+ if (originalText[0] === originalText[0].toUpperCase()) {
1604
+ // Check if it's pure PascalCase (first uppercase, rest lowercase)
1605
+ const restOfText = originalText.slice(1);
1606
+ if (restOfText === restOfText.toLowerCase()) {
1607
+ return replacementText[0].toUpperCase() + replacementText.slice(1).toLowerCase();
1608
+ }
1609
+ // Mixed case - preserve the pattern as much as possible
1610
+ return replacementText[0].toUpperCase() + replacementText.slice(1).toLowerCase();
1611
+ }
1612
+
1613
+ // Check if original text is camelCase (first letter lowercase, rest mixed)
1614
+ if (originalText[0] === originalText[0].toLowerCase()) {
1615
+ return replacementText[0].toLowerCase() + replacementText.slice(1).toLowerCase();
1616
+ }
1617
+
1618
+ // Default fallback - return replacement as-is
1619
+ return replacementText;
1620
+ };
1621
+
1622
+ const getEdits = (matches, value, replacement, startIndex, replaceAll, lines, preserveCaseOption = false) => {
1568
1623
  if (value.length === 0 || matches.length === 0) {
1569
1624
  return [];
1570
1625
  }
@@ -1577,6 +1632,12 @@ const getEdits = (matches, value, replacement, startIndex, replaceAll, lines) =>
1577
1632
  const startColumnIndex = matches[i * 2 + 1];
1578
1633
  const endColumnIndex = startColumnIndex + value.length;
1579
1634
 
1635
+ // Get the original text that was matched
1636
+ const originalText = lines[rowIndex].slice(startColumnIndex, endColumnIndex);
1637
+
1638
+ // Apply case preservation if enabled
1639
+ const finalReplacement = preserveCaseOption ? preserveCase$1(originalText, replacement) : replacement;
1640
+
1580
1641
  // Convert row/column positions to character offsets
1581
1642
  let startOffset = 0;
1582
1643
  for (let row = 0; row < rowIndex; row++) {
@@ -1591,7 +1652,7 @@ const getEdits = (matches, value, replacement, startIndex, replaceAll, lines) =>
1591
1652
  edits.push({
1592
1653
  startOffset,
1593
1654
  endOffset,
1594
- inserted: replacement,
1655
+ inserted: finalReplacement,
1595
1656
  origin: 'find-widget.replace'
1596
1657
  });
1597
1658
  }
@@ -1605,9 +1666,10 @@ const replace$1 = async state => {
1605
1666
  replacement,
1606
1667
  matchIndex,
1607
1668
  editorUid,
1608
- lines
1669
+ lines,
1670
+ preserveCase
1609
1671
  } = state;
1610
- const edits = getEdits(matches, value, replacement, matchIndex, false, lines);
1672
+ const edits = getEdits(matches, value, replacement, matchIndex, false, lines, preserveCase);
1611
1673
  await applyEdits(editorUid, edits);
1612
1674
  // TODO ask editor worker to apply edit
1613
1675
  // TODO ask editor worker for new lines?
@@ -1622,9 +1684,10 @@ const replaceAll$1 = state => {
1622
1684
  value,
1623
1685
  replacement,
1624
1686
  editorUid,
1625
- lines
1687
+ lines,
1688
+ preserveCase
1626
1689
  } = state;
1627
- const edits = getEdits(matches, value, replacement, 0, true, lines);
1690
+ const edits = getEdits(matches, value, replacement, 0, true, lines, preserveCase);
1628
1691
  void applyEdits(editorUid, edits);
1629
1692
  return {
1630
1693
  ...state
@@ -1655,15 +1718,6 @@ const handleClickButton = async (state, name) => {
1655
1718
  return fn(state);
1656
1719
  };
1657
1720
 
1658
- const close$1 = async state => {
1659
- const {
1660
- editorUid
1661
- } = state;
1662
- // @ts-ignore
1663
- await invoke('Editor.closeFind2', editorUid);
1664
- return state;
1665
- };
1666
-
1667
1721
  const handleClickClose = state => {
1668
1722
  return close$1(state);
1669
1723
  };
@@ -1675,7 +1729,7 @@ const handleFindWidgetFocus = (state, focusKey) => {
1675
1729
  return {
1676
1730
  ...state,
1677
1731
  focus: focusKey,
1678
- focusSource: User$1
1732
+ focusSource: User
1679
1733
  };
1680
1734
  };
1681
1735
 
@@ -1751,7 +1805,7 @@ const focusElement = (state, whenExpression) => {
1751
1805
  return {
1752
1806
  ...state,
1753
1807
  focus: whenExpression,
1754
- focusSource: Script
1808
+ focusSource: Script$1
1755
1809
  };
1756
1810
  };
1757
1811
 
@@ -1925,11 +1979,11 @@ const getKeyBindings = () => {
1925
1979
  }];
1926
1980
  };
1927
1981
 
1928
- const handleInput = (state, value, inputSource = User) => {
1982
+ const handleInput = (state, value, inputSource = User$1) => {
1929
1983
  return refresh(state, value, inputSource);
1930
1984
  };
1931
1985
 
1932
- const handleReplaceInput = (state, value, inputSource = User) => {
1986
+ const handleReplaceInput = (state, value, inputSource = User$1) => {
1933
1987
  return {
1934
1988
  ...state,
1935
1989
  replacement: value,
@@ -2049,7 +2103,7 @@ const loadContent = async (state, savedState) => {
2049
2103
  focus: FocusSearchInput,
2050
2104
  focused: true,
2051
2105
  height,
2052
- inputSource: Script,
2106
+ inputSource: Script$1,
2053
2107
  lines,
2054
2108
  matchCount,
2055
2109
  matches,
@@ -2270,6 +2324,7 @@ const text = data => {
2270
2324
  };
2271
2325
  };
2272
2326
 
2327
+ const FindWidget = 'FindWidget';
2273
2328
  const FindWidgetFind = 'FindWidgetFind';
2274
2329
  const FindWidgetMatchCount = 'FindWidgetMatchCount';
2275
2330
  const FindWidgetMatchCountEmpty = 'FindWidgetMatchCountEmpty';
@@ -2278,21 +2333,21 @@ const FindWidgetRight = 'FindWidgetRight';
2278
2333
  const IconButton = 'IconButton';
2279
2334
  const IconButtonDisabled = 'IconButtonDisabled';
2280
2335
  const MaskIcon = 'MaskIcon';
2336
+ const MaskIconChevronDown = 'MaskIconChevronDown';
2337
+ const MaskIconChevronRight = 'MaskIconChevronRight';
2281
2338
  const MultilineInputBox = 'MultilineInputBox';
2339
+ const Resizer = 'Resizer';
2340
+ const ResizerHighlight = 'ResizerHighlight';
2282
2341
  const SearchField = 'SearchField';
2283
2342
  const SearchFieldButton = 'SearchFieldButton';
2284
2343
  const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
2285
2344
  const SearchFieldButtons = 'SearchFieldButtons';
2345
+ const SearchFieldError = 'SearchFieldError';
2346
+ const SearchToggleButton = 'SearchToggleButton';
2347
+ const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
2286
2348
  const Viewlet = 'Viewlet';
2287
2349
  const ViewletFind = 'ViewletFind';
2288
- const FindWidget = 'FindWidget';
2289
2350
  const ViewletFindWidget = 'ViewletFindWidget';
2290
- const Resizer = 'Resizer';
2291
- const ResizerHighlight = 'ResizerHighlight';
2292
- const SearchToggleButton = 'SearchToggleButton';
2293
- const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
2294
- const MaskIconChevronDown = 'MaskIconChevronDown';
2295
- const MaskIconChevronRight = 'MaskIconChevronRight';
2296
2351
 
2297
2352
  const getIconVirtualDom = (icon, type = Div) => {
2298
2353
  return {
@@ -2370,15 +2425,15 @@ const getSearchFieldButtonVirtualDom = button => {
2370
2425
  }];
2371
2426
  };
2372
2427
 
2373
- const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, outsideButtons, onFocus = '', extraClassName = '') => {
2428
+ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, outsideButtons, onFocus, extraClassName) => {
2374
2429
  const dom = [{
2375
2430
  type: Div,
2376
- className: SearchField,
2431
+ className: mergeClassNames(SearchField, extraClassName),
2377
2432
  role: None,
2378
2433
  childCount: 2
2379
2434
  }, {
2380
2435
  type: TextArea,
2381
- className: mergeClassNames(MultilineInputBox, extraClassName),
2436
+ className: MultilineInputBox,
2382
2437
  spellcheck: false,
2383
2438
  autocapitalize: 'off',
2384
2439
  autocorrect: 'off',
@@ -2399,7 +2454,7 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
2399
2454
  };
2400
2455
 
2401
2456
  const getFindWidgetFindVirtualDom = (matchCountText, buttons, fieldButtons, matchCount, hasValue, hasError) => {
2402
- const extraClassName = hasError ? `InputValidationError` : '';
2457
+ const extraClassName = hasError ? SearchFieldError : '';
2403
2458
  return [{
2404
2459
  type: Div,
2405
2460
  className: FindWidgetFind,
@@ -2419,7 +2474,7 @@ const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons, replace
2419
2474
  type: Div,
2420
2475
  className: FindWidgetReplace,
2421
2476
  childCount: 1 + replaceButtons.length
2422
- }, ...getSearchFieldVirtualDom(ReplaceValue, replace(), HandleReplaceInput, [], [], HandleReplaceFocus), ...replaceButtons.flatMap(getIconButtonVirtualDom)];
2477
+ }, ...getSearchFieldVirtualDom(ReplaceValue, replace(), HandleReplaceInput, [], [], HandleReplaceFocus, ''), ...replaceButtons.flatMap(getIconButtonVirtualDom)];
2423
2478
  };
2424
2479
 
2425
2480
  const getResizerVirtualDom = () => {
@@ -2692,8 +2747,8 @@ const render2 = (uid, diffResult) => {
2692
2747
  const {
2693
2748
  oldState,
2694
2749
  newState
2695
- } = get$1(uid);
2696
- set$3(uid, newState, newState);
2750
+ } = get(uid);
2751
+ set(uid, newState, newState);
2697
2752
  const commands = applyRender(oldState, newState, diffResult);
2698
2753
  return commands;
2699
2754
  };
@@ -2724,9 +2779,10 @@ const saveState = state => {
2724
2779
  };
2725
2780
 
2726
2781
  const commandMap = {
2727
- 'FindWidget.create': create$1,
2782
+ 'FindWidget.create': create,
2728
2783
  'FindWidget.diff2': diff2,
2729
- 'FindWidget.dispose': dispose$1,
2784
+ 'FindWidget.close': wrapCommand(close$1),
2785
+ 'FindWidget.dispose': dispose,
2730
2786
  'FindWidget.focusCloseButton': wrapCommand(focusCloseButton),
2731
2787
  'FindWidget.focusElement': wrapCommand(focusElement),
2732
2788
  'FindWidget.focusFirst': wrapCommand(focusFirst),
@@ -2760,7 +2816,8 @@ const commandMap = {
2760
2816
  'FindWidget.toggleMatchCase': wrapCommand(toggleMatchCase),
2761
2817
  'FindWidget.toggleReplace': wrapCommand(toggleReplace$1),
2762
2818
  'FindWidget.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
2763
- 'FindWidget.togglePreserveCase': wrapCommand(togglePreserveCase)
2819
+ 'FindWidget.togglePreserveCase': wrapCommand(togglePreserveCase),
2820
+ 'FindWidget.toggleMatchWholeWord': wrapCommand(toggleMatchWholeWord)
2764
2821
  };
2765
2822
 
2766
2823
  const listen = async () => {
@@ -2768,7 +2825,7 @@ const listen = async () => {
2768
2825
  const rpc = await WebWorkerRpcClient.create({
2769
2826
  commandMap: commandMap
2770
2827
  });
2771
- set(rpc);
2828
+ set$1(rpc);
2772
2829
  };
2773
2830
 
2774
2831
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/find-widget-worker",
3
- "version": "2.3.0",
3
+ "version": "2.5.0",
4
4
  "description": "Web Worker for the find widget in Lvce Editor",
5
5
  "repository": {
6
6
  "type": "git",