@lvce-editor/source-control-worker 2.12.0 → 2.14.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.
@@ -521,7 +521,7 @@ const create$4 = (method, params) => {
521
521
  };
522
522
  };
523
523
  const callbacks = Object.create(null);
524
- const set$4 = (id, fn) => {
524
+ const set$5 = (id, fn) => {
525
525
  callbacks[id] = fn;
526
526
  };
527
527
  const get$3 = id => {
@@ -540,7 +540,7 @@ const registerPromise = () => {
540
540
  resolve,
541
541
  promise
542
542
  } = Promise.withResolvers();
543
- set$4(id, resolve);
543
+ set$5(id, resolve);
544
544
  return {
545
545
  id,
546
546
  promise
@@ -1045,7 +1045,12 @@ const DeltaY = 'event.deltaY';
1045
1045
  const TargetName = 'event.target.name';
1046
1046
  const TargetValue = 'event.target.value';
1047
1047
 
1048
+ const Enter = 3;
1049
+
1048
1050
  const User = 1;
1051
+ const Script = 2;
1052
+
1053
+ const CtrlCmd = 1 << 11 >>> 0;
1049
1054
 
1050
1055
  const SourceControl$1 = 22;
1051
1056
 
@@ -1054,16 +1059,20 @@ const None = 0;
1054
1059
  const ExtensionHostWorker = 44;
1055
1060
  const RendererWorker = 1;
1056
1061
  const SourceControlWorker = 66;
1062
+ const IconThemeWorker = 7009;
1057
1063
 
1058
1064
  const SetCss = 'Viewlet.setCss';
1059
1065
  const SetDom2 = 'Viewlet.setDom2';
1066
+ const SetFocusContext = 'Viewlet.setFocusContext';
1060
1067
  const SetValueByName = 'Viewlet.setValueByName';
1061
1068
 
1062
1069
  const List = 1;
1063
1070
  const Tree = 2;
1064
1071
 
1072
+ const FocusSourceControlInput = 24;
1073
+
1065
1074
  const rpcs = Object.create(null);
1066
- const set$3 = (id, rpc) => {
1075
+ const set$4 = (id, rpc) => {
1067
1076
  rpcs[id] = rpc;
1068
1077
  };
1069
1078
  const get$2 = id => {
@@ -1085,7 +1094,7 @@ const create$1 = rpcId => {
1085
1094
  return rpc.invokeAndTransfer(method, ...params);
1086
1095
  },
1087
1096
  set(rpc) {
1088
- set$3(rpcId, rpc);
1097
+ set$4(rpcId, rpc);
1089
1098
  },
1090
1099
  async dispose() {
1091
1100
  const rpc = get$2(rpcId);
@@ -1096,12 +1105,12 @@ const create$1 = rpcId => {
1096
1105
 
1097
1106
  const {
1098
1107
  invoke: invoke$1,
1099
- set: set$2} = create$1(ExtensionHostWorker);
1108
+ set: set$3} = create$1(ExtensionHostWorker);
1100
1109
 
1101
1110
  const {
1102
1111
  invoke,
1103
1112
  invokeAndTransfer,
1104
- set: set$1} = create$1(RendererWorker);
1113
+ set: set$2} = create$1(RendererWorker);
1105
1114
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1106
1115
  number(uid);
1107
1116
  number(menuId);
@@ -1120,6 +1129,11 @@ const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
1120
1129
  const activateByEvent$1 = event => {
1121
1130
  return invoke('ExtensionHostManagement.activateByEvent', event);
1122
1131
  };
1132
+ const sendMessagePortToTextMeasurementWorker$1 = async port => {
1133
+ const command = 'TextMeasurement.handleMessagePort';
1134
+ // @ts-ignore
1135
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
1136
+ };
1123
1137
  const getPreference = async key => {
1124
1138
  return await invoke('Preferences.get', key);
1125
1139
  };
@@ -1127,6 +1141,9 @@ const openUri$1 = async (uri, focus, options) => {
1127
1141
  await invoke('Main.openUri', uri, focus, options);
1128
1142
  };
1129
1143
 
1144
+ const {
1145
+ set: set$1} = create$1(IconThemeWorker);
1146
+
1130
1147
  const toCommandId = key => {
1131
1148
  const dotIndex = key.indexOf('.');
1132
1149
  return key.slice(dotIndex + 1);
@@ -1269,20 +1286,27 @@ const create2 = (id, uri, x, y, width, height, workspacePath) => {
1269
1286
  history: [],
1270
1287
  viewMode: 1,
1271
1288
  iconDefinitions: [],
1272
- decorationIcons: []
1289
+ decorationIcons: [],
1290
+ focus: 0
1273
1291
  };
1274
1292
  set(id, state, state);
1275
1293
  };
1276
1294
 
1277
- const isEqual$2 = (oldState, newState) => {
1295
+ const isEqual$3 = (oldState, newState) => {
1278
1296
  return oldState.inputBoxHeight === newState.inputBoxHeight;
1279
1297
  };
1280
1298
 
1299
+ const isEqual$2 = (oldState, newState) => {
1300
+ return oldState.focus === newState.focus;
1301
+ };
1302
+
1281
1303
  const isEqual$1 = (oldState, newState) => {
1282
1304
  return oldState.allGroups === newState.allGroups && oldState.deltaY === newState.deltaY && oldState.items === newState.items && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.visibleItems === newState.visibleItems;
1283
1305
  };
1284
1306
 
1285
1307
  const RenderItems = 4;
1308
+ const RenderFocus = 6;
1309
+ const RenderFocusContext = 7;
1286
1310
  const RenderValue = 8;
1287
1311
  const RenderCss = 10;
1288
1312
 
@@ -1290,8 +1314,8 @@ const isEqual = (oldState, newState) => {
1290
1314
  return newState.inputSource === User || oldState.inputValue === newState.inputValue;
1291
1315
  };
1292
1316
 
1293
- const modules = [isEqual$1, isEqual, isEqual$2];
1294
- const numbers = [RenderItems, RenderValue, RenderCss];
1317
+ const modules = [isEqual$1, isEqual, isEqual$3, isEqual$2];
1318
+ const numbers = [RenderItems, RenderValue, RenderCss, RenderFocus];
1295
1319
 
1296
1320
  const diff = (oldState, newState) => {
1297
1321
  const diffResult = [];
@@ -1320,6 +1344,26 @@ const getInfo = uid => {
1320
1344
  return newState.allGroups;
1321
1345
  };
1322
1346
 
1347
+ const mergeClassNames = (...classNames) => {
1348
+ return classNames.filter(Boolean).join(' ');
1349
+ };
1350
+
1351
+ const text = data => {
1352
+ return {
1353
+ type: Text,
1354
+ text: data,
1355
+ childCount: 0
1356
+ };
1357
+ };
1358
+
1359
+ const getKeyBindings = () => {
1360
+ return [{
1361
+ key: CtrlCmd | Enter,
1362
+ command: 'Source Control.acceptInput',
1363
+ when: FocusSourceControlInput
1364
+ }];
1365
+ };
1366
+
1323
1367
  const emptyObject = {};
1324
1368
  const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1325
1369
  const i18nString = (key, placeholders = emptyObject) => {
@@ -1684,7 +1728,10 @@ const getGroups = async enabledProviderIds => {
1684
1728
 
1685
1729
  const getTextHeight = async (input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight) => {
1686
1730
  try {
1687
- const actualInput = '\n' + input;
1731
+ if (!input) {
1732
+ return lineHeight;
1733
+ }
1734
+ const actualInput = input;
1688
1735
  // TODO line height could also be like 1.5
1689
1736
  const lineHeightPx = `${lineHeight}px`;
1690
1737
  // @ts-ignore
@@ -2097,8 +2144,12 @@ const handleContextMenu = async (state, button, x, y) => {
2097
2144
  return state;
2098
2145
  };
2099
2146
 
2100
- const handleFocus = async state => {
2101
- return state;
2147
+ const handleInputFocus = async state => {
2148
+ return {
2149
+ ...state,
2150
+ focus: FocusSourceControlInput,
2151
+ inputSource: Script
2152
+ };
2102
2153
  };
2103
2154
 
2104
2155
  const handleInput = async (state, value, inputSource = User) => {
@@ -2119,6 +2170,11 @@ const handleInput = async (state, value, inputSource = User) => {
2119
2170
  };
2120
2171
  };
2121
2172
 
2173
+ const handleInputBlur = async state => {
2174
+ // TODO reset focus
2175
+ return state;
2176
+ };
2177
+
2122
2178
  const handleMessagePort = async port => {
2123
2179
  await PlainMessagePortRpc.create({
2124
2180
  commandMap: {},
@@ -2210,9 +2266,26 @@ const createExtensionHostRpc = async () => {
2210
2266
  }
2211
2267
  };
2212
2268
 
2269
+ const sendMessagePortToTextMeasurementWorker = async port => {
2270
+ await sendMessagePortToTextMeasurementWorker$1(port);
2271
+ };
2272
+
2273
+ const createTextMeasurementWorkerRpc = async () => {
2274
+ try {
2275
+ const rpc = await TransferMessagePortRpcParent.create({
2276
+ commandMap: {},
2277
+ send: sendMessagePortToTextMeasurementWorker
2278
+ });
2279
+ return rpc;
2280
+ } catch (error) {
2281
+ throw new VError(error, `Failed to create text measurement worker rpc`);
2282
+ }
2283
+ };
2284
+
2213
2285
  const initialize = async () => {
2214
- const extensionHostRpc = await createExtensionHostRpc();
2215
- set$2(extensionHostRpc);
2286
+ const [extensionHostRpc, textRpc] = await Promise.all([createExtensionHostRpc(), createTextMeasurementWorkerRpc()]);
2287
+ set$3(extensionHostRpc);
2288
+ set$1(textRpc);
2216
2289
  };
2217
2290
 
2218
2291
  const renderCss = (oldState, newState) => {
@@ -2227,16 +2300,12 @@ const renderCss = (oldState, newState) => {
2227
2300
  return [SetCss, id, css];
2228
2301
  };
2229
2302
 
2230
- const mergeClassNames = (...classNames) => {
2231
- return classNames.filter(Boolean).join(' ');
2232
- };
2233
-
2234
- const text = data => {
2235
- return {
2236
- type: Text,
2237
- text: data,
2238
- childCount: 0
2239
- };
2303
+ const renderFocusContext = (oldState, newState) => {
2304
+ const {
2305
+ id,
2306
+ focus
2307
+ } = newState;
2308
+ return [SetFocusContext, id, focus];
2240
2309
  };
2241
2310
 
2242
2311
  const Actions = 'Actions';
@@ -2564,6 +2633,8 @@ const getRenderer = diffType => {
2564
2633
  return renderValue;
2565
2634
  case RenderCss:
2566
2635
  return renderCss;
2636
+ case RenderFocusContext:
2637
+ return renderFocusContext;
2567
2638
  default:
2568
2639
  throw new Error('unknown renderer');
2569
2640
  }
@@ -2723,17 +2794,17 @@ const commandMap = {
2723
2794
  'SourceControl.create2': create2,
2724
2795
  'SourceControl.diff2': diff2,
2725
2796
  'SourceControl.getCommandIds': getCommandIds,
2726
- 'SourceControl.handleWorkspaceRefresh': wrapCommand(handleWorkspaceRefresh),
2727
- 'SourceControl.getMenuIds': getMenuIds,
2728
2797
  'SourceControl.getEnabledProviderIds': getEnabledProviderIds,
2729
2798
  'SourceControl.getFileDecorations': getFileDecorations,
2730
2799
  'SourceControl.getInfo': getInfo,
2800
+ 'SourceControl.getKeyBindings': getKeyBindings,
2731
2801
  'SourceControl.getMenuEntries2': wrapGetter(getMenuEntries2),
2802
+ 'SourceControl.getMenuIds': getMenuIds,
2732
2803
  'SourceControl.handleButtonClick': wrapCommand(handleButtonClick),
2733
2804
  'SourceControl.handleClickAt': wrapCommand(handleClickAt),
2734
2805
  'SourceControl.handleClickSourceControlButtons': wrapCommand(handleClickSourceControlButtons),
2735
2806
  'SourceControl.handleContextMenu': wrapCommand(handleContextMenu),
2736
- 'SourceControl.handleFocus': wrapCommand(handleFocus),
2807
+ 'SourceControl.handleFocus': wrapCommand(handleInputFocus),
2737
2808
  'SourceControl.handleInput': wrapCommand(handleInput),
2738
2809
  'SourceControl.handleMessagePort': handleMessagePort,
2739
2810
  'SourceControl.handleMouseOut': wrapCommand(handleMouseOut),
@@ -2741,6 +2812,7 @@ const commandMap = {
2741
2812
  'SourceControl.handleMouseOver': wrapCommand(handleMouseOver),
2742
2813
  'SourceControl.handleMouseOverAt': wrapCommand(handleMouseOverAt),
2743
2814
  'SourceControl.handleWheel': wrapCommand(handleWheel),
2815
+ 'SourceControl.handleWorkspaceRefresh': wrapCommand(handleWorkspaceRefresh),
2744
2816
  'SourceControl.loadContent': wrapCommand(loadContent),
2745
2817
  'SourceControl.refresh': wrapCommand(refresh),
2746
2818
  'SourceControl.render2': render2,
@@ -2753,7 +2825,8 @@ const commandMap = {
2753
2825
  'SourceControl.terminate': terminate,
2754
2826
  'SourceControl.updateIcons': wrapCommand(updateIcons),
2755
2827
  'SourceControl.viewAsList': wrapCommand(viewAsList),
2756
- 'SourceControl.viewAsTree': wrapCommand(viewAsTree)
2828
+ 'SourceControl.viewAsTree': wrapCommand(viewAsTree),
2829
+ 'SourceControl.handleInputBlur': wrapCommand(handleInputBlur)
2757
2830
  };
2758
2831
 
2759
2832
  const listen = async () => {
@@ -2761,7 +2834,7 @@ const listen = async () => {
2761
2834
  const rpc = await WebWorkerRpcClient.create({
2762
2835
  commandMap: commandMap
2763
2836
  });
2764
- set$1(rpc);
2837
+ set$2(rpc);
2765
2838
  };
2766
2839
 
2767
2840
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/source-control-worker",
3
- "version": "2.12.0",
3
+ "version": "2.14.0",
4
4
  "description": "Source Control Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"