@lvce-editor/find-widget-worker 1.3.0 → 1.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.
@@ -906,7 +906,7 @@ const isEqual$3 = (oldState, newState) => {
906
906
  };
907
907
 
908
908
  const isEqual$2 = (oldState, newState) => {
909
- return oldState.version === newState.version;
909
+ return oldState.focused === newState.focused;
910
910
  };
911
911
 
912
912
  const isEqual$1 = (oldState, newState) => {
@@ -922,9 +922,10 @@ const RenderEventListeners = 11;
922
922
  const RenderUid = 12;
923
923
  const RenderContent = 13;
924
924
  const RenderFocusContext = 14;
925
+ const RenderFocus = 15;
925
926
 
926
- const modules = [isEqual$3, isEqual$1, isEqual$4, isEqual, isEqual$2];
927
- const numbers = [RenderEventListeners, RenderContent, RenderBounds, RenderUid, RenderFocusContext];
927
+ const modules = [isEqual$3, isEqual$1, isEqual$4, isEqual, isEqual$2, isEqual$2];
928
+ const numbers = [RenderEventListeners, RenderContent, RenderBounds, RenderUid, RenderFocusContext, RenderFocus];
928
929
 
929
930
  const diff = (oldState, newState) => {
930
931
  const diffResult = [];
@@ -973,7 +974,10 @@ const focusIndex = (state, index) => {
973
974
  // newState,
974
975
  // }
975
976
  // const newWidgets = [...widgets.slice(0, childIndex), newWidget, ...widgets.slice(childIndex + 1)]
976
- return state;
977
+ return {
978
+ ...state,
979
+ matchIndex: index
980
+ };
977
981
  };
978
982
  const focusFirst = state => {
979
983
  return focusIndex(state, 0);
@@ -1095,11 +1099,14 @@ const getFindWidgetHeight = replaceExpanded => {
1095
1099
  };
1096
1100
 
1097
1101
  const toggleReplace = state => {
1098
- const newExpanded = !state.replaceExpanded;
1102
+ const {
1103
+ replaceExpanded
1104
+ } = state;
1105
+ const newExpanded = !replaceExpanded;
1099
1106
  const newHeight = getFindWidgetHeight(newExpanded);
1100
1107
  return {
1101
1108
  ...state,
1102
- replaceExpanded: !state.replaceExpanded,
1109
+ replaceExpanded: newExpanded,
1103
1110
  height: newHeight
1104
1111
  };
1105
1112
  };
@@ -1218,7 +1225,10 @@ const loadContent = async state => {
1218
1225
  x,
1219
1226
  y,
1220
1227
  width,
1221
- height
1228
+ height,
1229
+ lines,
1230
+ selections,
1231
+ focused: true
1222
1232
  };
1223
1233
  };
1224
1234
 
@@ -1265,45 +1275,41 @@ const i18nString = (key, placeholders = emptyObject) => {
1265
1275
  return key.replaceAll(RE_PLACEHOLDER, replacer);
1266
1276
  };
1267
1277
 
1268
- /**
1269
- * @enum {string}
1270
- */
1271
- const UiStrings = {
1272
- MatchOf: '{PH1} of {PH2}',
1273
- NoResults: 'No Results',
1274
- Close: 'Close',
1275
- PreviousMatch: 'Previous Match',
1276
- NextMatch: 'Next Match',
1277
- Find: 'Find',
1278
- Replace: 'Replace',
1279
- ReplaceAll: 'Replace All'
1280
- };
1278
+ const MatchOf = '{PH1} of {PH2}';
1279
+ const NoResults = 'No Results';
1280
+ const Close$2 = 'Close';
1281
+ const PreviousMatch = 'Previous Match';
1282
+ const NextMatch = 'Next Match';
1283
+ const Find$1 = 'Find';
1284
+ const Replace$2 = 'Replace';
1285
+ const ReplaceAll$2 = 'Replace All';
1286
+
1281
1287
  const noResults = () => {
1282
- return i18nString(UiStrings.NoResults);
1288
+ return i18nString(NoResults);
1283
1289
  };
1284
1290
  const matchOf = (matchIndex, matchCount) => {
1285
- return i18nString(UiStrings.MatchOf, {
1291
+ return i18nString(MatchOf, {
1286
1292
  PH1: matchIndex,
1287
1293
  PH2: matchCount
1288
1294
  });
1289
1295
  };
1290
1296
  const previousMatch = () => {
1291
- return i18nString(UiStrings.PreviousMatch);
1297
+ return i18nString(PreviousMatch);
1292
1298
  };
1293
1299
  const nextMatch = () => {
1294
- return i18nString(UiStrings.NextMatch);
1300
+ return i18nString(NextMatch);
1295
1301
  };
1296
1302
  const close = () => {
1297
- return i18nString(UiStrings.Close);
1303
+ return i18nString(Close$2);
1298
1304
  };
1299
1305
  const find = () => {
1300
- return i18nString(UiStrings.Find);
1306
+ return i18nString(Find$1);
1301
1307
  };
1302
1308
  const replace = () => {
1303
- return i18nString(UiStrings.Replace);
1309
+ return i18nString(Replace$2);
1304
1310
  };
1305
1311
  const replaceAll = () => {
1306
- return i18nString(UiStrings.ReplaceAll);
1312
+ return i18nString(ReplaceAll$2);
1307
1313
  };
1308
1314
 
1309
1315
  const ArrowDown = 'ArrowDown';
@@ -1637,6 +1643,13 @@ const renderEventListeners = state => {
1637
1643
  return [SetEventListeners, uid, eventListeners];
1638
1644
  };
1639
1645
 
1646
+ const renderFocus = (oldState, newState) => {
1647
+ const {
1648
+ uid
1649
+ } = newState;
1650
+ return [/* method */'Viewlet.focusSelector', uid, `[name="search-value"]`];
1651
+ };
1652
+
1640
1653
  const FocusFindWidget = 16;
1641
1654
 
1642
1655
  const renderFocusContext = (oldState, newState) => {
@@ -1663,6 +1676,8 @@ const getRenderer = diffType => {
1663
1676
  return renderUid;
1664
1677
  case RenderFocusContext:
1665
1678
  return renderFocusContext;
1679
+ case RenderFocus:
1680
+ return renderFocus;
1666
1681
  default:
1667
1682
  throw new Error('unknown renderer');
1668
1683
  }
@@ -1694,19 +1709,19 @@ const terminate = () => {
1694
1709
  const commandMap = {
1695
1710
  'FindWidget.create': create$1,
1696
1711
  'FindWidget.diff2': diff2,
1697
- 'FindWidget.focusFirst': focusFirst,
1698
- 'FindWidget.focusIndex': focusIndex,
1699
- 'FindWidget.focusLast': focusLast,
1700
- 'FindWidget.focusNext': focusNext,
1701
- 'FindWidget.focusPrevious': focusPrevious,
1712
+ 'FindWidget.focusFirst': wrapCommand(focusFirst),
1713
+ 'FindWidget.focusIndex': wrapCommand(focusIndex),
1714
+ 'FindWidget.focusLast': wrapCommand(focusLast),
1715
+ 'FindWidget.focusNext': wrapCommand(focusNext),
1716
+ 'FindWidget.focusPrevious': wrapCommand(focusPrevious),
1702
1717
  'FindWidget.getCommandIds': getCommandIds,
1703
- 'FindWidget.handleBlur': handleBlur,
1704
- 'FindWidget.handleClickClose': handleClickClose,
1705
- 'FindWidget.handleInput': handleInput,
1718
+ 'FindWidget.handleBlur': wrapCommand(handleBlur),
1719
+ 'FindWidget.handleClickClose': wrapCommand(handleClickClose),
1720
+ 'FindWidget.handleInput': wrapCommand(handleInput),
1706
1721
  'FindWidget.loadContent': wrapCommand(loadContent),
1707
1722
  'FindWidget.render2': render2,
1708
1723
  'FindWidget.terminate': terminate,
1709
- 'FindWidget.toggleReplace': toggleReplace
1724
+ 'FindWidget.toggleReplace': wrapCommand(toggleReplace)
1710
1725
  };
1711
1726
 
1712
1727
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/find-widget-worker",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "Web Worker for the find widget in Lvce Editor",
5
5
  "repository": {
6
6
  "type": "git",