@lvce-editor/find-widget-worker 3.8.0 → 3.10.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.
@@ -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
- // @ts-ignore
1064
- await invoke('Editor.closeFind2', editorUid);
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
- } = create$1();
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 create = (uid, x, y, width, height, parentUid) => {
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,
@@ -2848,6 +2948,13 @@ const render2 = (uid, diffResult) => {
2848
2948
  const commands = applyRender(oldState, newState, diffResult);
2849
2949
  return commands;
2850
2950
  };
2951
+ const renderInstance = (instanceId, diffResult) => {
2952
+ const uid = resolveUid(instanceId);
2953
+ if (uid === undefined) {
2954
+ return [];
2955
+ }
2956
+ return render2(uid, diffResult);
2957
+ };
2851
2958
 
2852
2959
  const resize = async (state, dimensions) => {
2853
2960
  return state;
@@ -2877,8 +2984,11 @@ const saveState = state => {
2877
2984
  const commandMap = {
2878
2985
  'FindWidget.close': wrapCommand(close$1),
2879
2986
  'FindWidget.create': create,
2987
+ 'FindWidget.createInstance': createInstance,
2880
2988
  'FindWidget.diff2': diff2,
2989
+ 'FindWidget.diffInstance': diffInstance,
2881
2990
  'FindWidget.dispose': dispose,
2991
+ 'FindWidget.disposeInstance': disposeInstance,
2882
2992
  'FindWidget.focusCloseButton': wrapCommand(focusCloseButton),
2883
2993
  'FindWidget.focusElement': wrapCommand(focusElement),
2884
2994
  'FindWidget.focusFind': wrapCommand(focusFind),
@@ -2887,10 +2997,14 @@ const commandMap = {
2887
2997
  'FindWidget.focusLast': wrapCommand(focusLast),
2888
2998
  'FindWidget.focusNext': wrapCommand(focusNext),
2889
2999
  'FindWidget.focusNextElement': wrapCommand(focusNextElement),
3000
+ 'FindWidget.focusNextMatchButton': wrapCommand(focusNextMatchButton),
2890
3001
  'FindWidget.focusPrevious': wrapCommand(focusPrevious),
2891
3002
  'FindWidget.focusPreviousElement': wrapCommand(focusPreviousElement),
3003
+ 'FindWidget.focusPreviousMatchButton': wrapCommand(focusPreviousMatchButton),
2892
3004
  'FindWidget.focusReplace': wrapCommand(focusReplace),
2893
3005
  'FindWidget.focusReplaceAllButton': wrapCommand(focusReplaceAllButton),
3006
+ 'FindWidget.focusReplaceButton': wrapCommand(focusReplaceButton),
3007
+ 'FindWidget.focusToggleReplace': wrapCommand(focusToggleReplaceButton),
2894
3008
  'FindWidget.getCommandIds': getCommandIds,
2895
3009
  'FindWidget.getKeyBindings': getKeyBindings,
2896
3010
  'FindWidget.handleBlur': wrapCommand(handleBlur),
@@ -2905,8 +3019,10 @@ const commandMap = {
2905
3019
  'FindWidget.handleResizerPointerUp': wrapCommand(handleResizerPointerUp),
2906
3020
  'FindWidget.handleToggleReplaceFocus': wrapCommand(handleToggleReplaceFocus),
2907
3021
  'FindWidget.loadContent': wrapCommand(loadContent),
3022
+ 'FindWidget.loadContentInstance': wrapInstanceCommand(loadContent),
2908
3023
  'FindWidget.preventDefaultBrowserFind': wrapCommand(preventDefaultBrowserFind),
2909
3024
  'FindWidget.render2': render2,
3025
+ 'FindWidget.renderInstance': renderInstance,
2910
3026
  'FindWidget.replace': wrapCommand(replace$1),
2911
3027
  'FindWidget.replaceAll': wrapCommand(replaceAll$1),
2912
3028
  'FindWidget.resize': wrapCommand(resize),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/find-widget-worker",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "description": "Web Worker for the find widget in Lvce Editor",
5
5
  "repository": {
6
6
  "type": "git",