@lvce-editor/find-widget-worker 2.3.0 → 2.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.
@@ -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.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;
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
@@ -1498,7 +1507,7 @@ const refresh$1 = (state, value, inputSource) => {
1498
1507
  };
1499
1508
  };
1500
1509
 
1501
- const refresh = (state, value = state.value, inputSource = User) => {
1510
+ const refresh = (state, value = state.value, inputSource = User$1) => {
1502
1511
  return refresh$1(state, value, inputSource);
1503
1512
  };
1504
1513
 
@@ -1510,7 +1519,7 @@ const toggleMatchCase = state => {
1510
1519
  ...state,
1511
1520
  matchCase: !matchCase
1512
1521
  };
1513
- return refresh(newState, newState.value, User);
1522
+ return refresh(newState, newState.value, User$1);
1514
1523
  };
1515
1524
 
1516
1525
  const toggleMatchWholeWord = state => {
@@ -1521,7 +1530,7 @@ const toggleMatchWholeWord = state => {
1521
1530
  ...state,
1522
1531
  matchWholeWord: !matchWholeWord
1523
1532
  };
1524
- return refresh(newState, newState.value, User);
1533
+ return refresh(newState, newState.value, User$1);
1525
1534
  };
1526
1535
 
1527
1536
  const togglePreserveCase = state => {
@@ -1543,7 +1552,7 @@ const toggleUseRegularExpression = state => {
1543
1552
  ...state,
1544
1553
  useRegularExpression: !useRegularExpression
1545
1554
  };
1546
- return refresh(newState, newState.value, User);
1555
+ return refresh(newState, newState.value, User$1);
1547
1556
  };
1548
1557
 
1549
1558
  const Close$2 = 'Close';
@@ -1655,15 +1664,6 @@ const handleClickButton = async (state, name) => {
1655
1664
  return fn(state);
1656
1665
  };
1657
1666
 
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
1667
  const handleClickClose = state => {
1668
1668
  return close$1(state);
1669
1669
  };
@@ -1675,7 +1675,7 @@ const handleFindWidgetFocus = (state, focusKey) => {
1675
1675
  return {
1676
1676
  ...state,
1677
1677
  focus: focusKey,
1678
- focusSource: User$1
1678
+ focusSource: User
1679
1679
  };
1680
1680
  };
1681
1681
 
@@ -1751,7 +1751,7 @@ const focusElement = (state, whenExpression) => {
1751
1751
  return {
1752
1752
  ...state,
1753
1753
  focus: whenExpression,
1754
- focusSource: Script
1754
+ focusSource: Script$1
1755
1755
  };
1756
1756
  };
1757
1757
 
@@ -1925,11 +1925,11 @@ const getKeyBindings = () => {
1925
1925
  }];
1926
1926
  };
1927
1927
 
1928
- const handleInput = (state, value, inputSource = User) => {
1928
+ const handleInput = (state, value, inputSource = User$1) => {
1929
1929
  return refresh(state, value, inputSource);
1930
1930
  };
1931
1931
 
1932
- const handleReplaceInput = (state, value, inputSource = User) => {
1932
+ const handleReplaceInput = (state, value, inputSource = User$1) => {
1933
1933
  return {
1934
1934
  ...state,
1935
1935
  replacement: value,
@@ -2049,7 +2049,7 @@ const loadContent = async (state, savedState) => {
2049
2049
  focus: FocusSearchInput,
2050
2050
  focused: true,
2051
2051
  height,
2052
- inputSource: Script,
2052
+ inputSource: Script$1,
2053
2053
  lines,
2054
2054
  matchCount,
2055
2055
  matches,
@@ -2692,8 +2692,8 @@ const render2 = (uid, diffResult) => {
2692
2692
  const {
2693
2693
  oldState,
2694
2694
  newState
2695
- } = get$1(uid);
2696
- set$3(uid, newState, newState);
2695
+ } = get(uid);
2696
+ set(uid, newState, newState);
2697
2697
  const commands = applyRender(oldState, newState, diffResult);
2698
2698
  return commands;
2699
2699
  };
@@ -2724,9 +2724,10 @@ const saveState = state => {
2724
2724
  };
2725
2725
 
2726
2726
  const commandMap = {
2727
- 'FindWidget.create': create$1,
2727
+ 'FindWidget.create': create,
2728
2728
  'FindWidget.diff2': diff2,
2729
- 'FindWidget.dispose': dispose$1,
2729
+ 'FindWidget.close': wrapCommand(close$1),
2730
+ 'FindWidget.dispose': dispose,
2730
2731
  'FindWidget.focusCloseButton': wrapCommand(focusCloseButton),
2731
2732
  'FindWidget.focusElement': wrapCommand(focusElement),
2732
2733
  'FindWidget.focusFirst': wrapCommand(focusFirst),
@@ -2760,7 +2761,8 @@ const commandMap = {
2760
2761
  'FindWidget.toggleMatchCase': wrapCommand(toggleMatchCase),
2761
2762
  'FindWidget.toggleReplace': wrapCommand(toggleReplace$1),
2762
2763
  'FindWidget.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
2763
- 'FindWidget.togglePreserveCase': wrapCommand(togglePreserveCase)
2764
+ 'FindWidget.togglePreserveCase': wrapCommand(togglePreserveCase),
2765
+ 'FindWidget.toggleMatchWholeWord': wrapCommand(toggleMatchWholeWord)
2764
2766
  };
2765
2767
 
2766
2768
  const listen = async () => {
@@ -2768,7 +2770,7 @@ const listen = async () => {
2768
2770
  const rpc = await WebWorkerRpcClient.create({
2769
2771
  commandMap: commandMap
2770
2772
  });
2771
- set(rpc);
2773
+ set$1(rpc);
2772
2774
  };
2773
2775
 
2774
2776
  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.4.0",
4
4
  "description": "Web Worker for the find widget in Lvce Editor",
5
5
  "repository": {
6
6
  "type": "git",