@lvce-editor/source-control-worker 1.18.0 → 1.20.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.
@@ -1040,10 +1040,10 @@ const TreeItem$1 = 'treeitem';
1040
1040
 
1041
1041
  const Button$2 = 1;
1042
1042
  const Div = 4;
1043
- const Input = 6;
1044
1043
  const Span = 8;
1045
1044
  const Text = 12;
1046
1045
  const Img = 17;
1046
+ const TextArea = 62;
1047
1047
 
1048
1048
  const TargetValue = 'event.target.value';
1049
1049
  const ClientX = 'event.clientX';
@@ -1053,12 +1053,16 @@ const DeltaMode = 'event.deltaMode';
1053
1053
  const DeltaY = 'event.deltaY';
1054
1054
  const TargetName = 'event.target.name';
1055
1055
 
1056
+ const User = 1;
1057
+
1056
1058
  const DebugWorker = 55;
1057
1059
  const ExtensionHostWorker = 44;
1058
1060
  const RendererWorker$1 = 1;
1059
1061
  const SourceControlWorker = 66;
1060
1062
 
1063
+ const SetCss = 'Viewlet.setCss';
1061
1064
  const SetDom2 = 'Viewlet.setDom2';
1065
+ const SetValueByName = 'Viewlet.setValueByName';
1062
1066
 
1063
1067
  const rpcs = Object.create(null);
1064
1068
  const set$4 = (id, rpc) => {
@@ -1568,7 +1572,8 @@ const {
1568
1572
  set: set$1,
1569
1573
  wrapCommand,
1570
1574
  getCommandIds,
1571
- registerCommands
1575
+ registerCommands,
1576
+ wrapGetter
1572
1577
  } = create();
1573
1578
 
1574
1579
  const create2 = (id, uri, x, y, width, height, workspacePath) => {
@@ -1593,6 +1598,7 @@ const create2 = (id, uri, x, y, width, height, workspacePath) => {
1593
1598
  maxLineY: 0,
1594
1599
  merge: [],
1595
1600
  minimumSliderSize: 20,
1601
+ inputBoxHeight: 30,
1596
1602
  minLineY: 0,
1597
1603
  providerId: '',
1598
1604
  root: '',
@@ -1605,20 +1611,36 @@ const create2 = (id, uri, x, y, width, height, workspacePath) => {
1605
1611
  workingTree: [],
1606
1612
  workspacePath,
1607
1613
  x,
1608
- y
1614
+ y,
1615
+ inputPlaceholder: '',
1616
+ inputSource: 0,
1617
+ maxInputLines: 5,
1618
+ inputFontFamily: '"Fira Code"',
1619
+ inputFontSize: 15,
1620
+ inputFontWeight: 400,
1621
+ inputLetterSpacing: 0.5
1609
1622
  };
1610
1623
  set$1(id, state, state);
1611
1624
  };
1612
1625
 
1626
+ const isEqual$2 = (oldState, newState) => {
1627
+ return newState.inputBoxHeight === newState.inputBoxHeight;
1628
+ };
1629
+
1613
1630
  const RenderItems = 4;
1631
+ const RenderValue = 8;
1632
+ const RenderCss = 10;
1614
1633
 
1615
- const diffType = RenderItems;
1616
- const isEqual = (oldState, newState) => {
1634
+ const isEqual$1 = (oldState, newState) => {
1617
1635
  return oldState.allGroups === newState.allGroups && oldState.visibleItems === newState.visibleItems && oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY;
1618
1636
  };
1619
1637
 
1620
- const modules = [isEqual];
1621
- const numbers = [diffType];
1638
+ const isEqual = (oldState, newState) => {
1639
+ return newState.inputSource === User || oldState.inputValue === newState.inputValue;
1640
+ };
1641
+
1642
+ const modules = [isEqual$1, isEqual, isEqual$2];
1643
+ const numbers = [RenderItems, RenderValue, RenderCss];
1622
1644
 
1623
1645
  const diff = (oldState, newState) => {
1624
1646
  const diffResult = [];
@@ -1968,6 +1990,28 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1968
1990
  return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
1969
1991
  };
1970
1992
 
1993
+ const emptyObject = {};
1994
+ const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
1995
+ const i18nString = (key, placeholders = emptyObject) => {
1996
+ if (placeholders === emptyObject) {
1997
+ return key;
1998
+ }
1999
+ const replacer = (match, rest) => {
2000
+ return placeholders[rest];
2001
+ };
2002
+ return key.replaceAll(RE_PLACEHOLDER, replacer);
2003
+ };
2004
+
2005
+ const MessageEnterToCommitOnMaster = `Message (Enter) to commit on 'master'`;
2006
+ const SourceControlInput$1 = 'Source Control Input';
2007
+
2008
+ const messageEnterToCommitOnMaster = () => {
2009
+ return i18nString(MessageEnterToCommitOnMaster);
2010
+ };
2011
+ const sourceControlInput = () => {
2012
+ return i18nString(SourceControlInput$1);
2013
+ };
2014
+
1971
2015
  const loadContent = async state => {
1972
2016
  const {
1973
2017
  itemHeight,
@@ -1997,20 +2041,22 @@ const loadContent = async state => {
1997
2041
  const newFileIconCache = await getFileIcons(displayItems, fileIconCache);
1998
2042
  const visibleItems = getVisibleSourceControlItems(displayItems, minLineY, maxLineY, actionsCache, newFileIconCache);
1999
2043
  const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
2044
+ const inputPlaceholder = messageEnterToCommitOnMaster();
2000
2045
  return {
2001
2046
  ...state,
2047
+ actionsCache,
2002
2048
  allGroups,
2049
+ enabledProviderIds,
2050
+ fileIconCache: newFileIconCache,
2051
+ finalDeltaY,
2003
2052
  gitRoot,
2053
+ inputPlaceholder,
2004
2054
  items: displayItems,
2005
- visibleItems,
2006
- enabledProviderIds,
2007
- root,
2008
- splitButtonEnabled,
2009
2055
  maxLineY,
2056
+ root,
2010
2057
  scrollBarHeight,
2011
- finalDeltaY,
2012
- fileIconCache: newFileIconCache,
2013
- actionsCache
2058
+ splitButtonEnabled,
2059
+ visibleItems
2014
2060
  };
2015
2061
  };
2016
2062
 
@@ -2226,6 +2272,45 @@ const handleFocus = async state => {
2226
2272
  return state;
2227
2273
  };
2228
2274
 
2275
+ const getTextHeight = async (input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight) => {
2276
+ try {
2277
+ // TODO line height could also be like 1.5
2278
+ const lineHeightPx = `${lineHeight}px`;
2279
+ // @ts-ignore
2280
+ const height = await invoke$2(`MeasureTextHeight.measureTextBlockHeight`, input, fontFamily, fontSize, lineHeightPx, width);
2281
+ return height;
2282
+ } catch {
2283
+ // fallback
2284
+ const lines = input.split('\n');
2285
+ const lineCount = lines.length;
2286
+ const inputHeight = lineCount * lineHeight;
2287
+ return inputHeight;
2288
+ }
2289
+ };
2290
+
2291
+ const getInputHeight = async (input, width, fontFamily, fontWeight, fontSize, letterSpacing, lineHeight) => {
2292
+ const height = await getTextHeight(input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight);
2293
+ return height;
2294
+ };
2295
+
2296
+ const handleInput = async (state, value, inputSource = User) => {
2297
+ const {
2298
+ width,
2299
+ inputFontFamily,
2300
+ inputFontSize,
2301
+ inputFontWeight,
2302
+ inputLetterSpacing
2303
+ } = state;
2304
+ const lineHeight = 30;
2305
+ const inputBoxHeight = await getInputHeight(value, width, inputFontFamily, inputFontWeight, inputFontSize, inputLetterSpacing, lineHeight);
2306
+ return {
2307
+ ...state,
2308
+ inputValue: value,
2309
+ inputSource,
2310
+ inputBoxHeight
2311
+ };
2312
+ };
2313
+
2229
2314
  const handleMouseOut = (state, index) => {
2230
2315
  const {
2231
2316
  items
@@ -2311,6 +2396,18 @@ const initialize = async () => {
2311
2396
  set(extensionHostRpc);
2312
2397
  };
2313
2398
 
2399
+ const renderCss = (oldState, newState) => {
2400
+ const {
2401
+ id,
2402
+ inputBoxHeight
2403
+ } = newState;
2404
+ const css = `:root {
2405
+ --SourceControlInputHeight: ${inputBoxHeight}px;
2406
+ }
2407
+ `;
2408
+ return [SetCss, id, css];
2409
+ };
2410
+
2314
2411
  const mergeClassNames = (...classNames) => {
2315
2412
  return classNames.filter(Boolean).join(' ');
2316
2413
  };
@@ -2352,60 +2449,42 @@ const StrikeThrough = 'StrikeThrough';
2352
2449
  const TreeItem = 'TreeItem';
2353
2450
  const Viewlet = 'Viewlet';
2354
2451
 
2355
- const HandleClickAt = 'handleClickAt';
2356
- const HandleContextMenu = 'handleContextMenu';
2357
- const HandleFocus = 'handleFocus';
2358
- const HandleInput = 'handleInput';
2359
- const HandleMouseOut = 'handleMouseOut';
2360
- const HandleMouseOutAt = 'handleMouseOutAt';
2361
- const HandleMouseOver = 'handleMouseOver';
2362
- const HandleMouseOverAt = 'handleMouseOverAt';
2363
- const HandleWheel = 'handleWheel';
2364
-
2365
- const SourceControlInput$1 = 'SourceControlInput';
2366
-
2367
- const emptyObject = {};
2368
- const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
2369
- const i18nString = (key, placeholders = emptyObject) => {
2370
- if (placeholders === emptyObject) {
2371
- return key;
2372
- }
2373
- const replacer = (match, rest) => {
2374
- return placeholders[rest];
2375
- };
2376
- return key.replaceAll(RE_PLACEHOLDER, replacer);
2377
- };
2452
+ const HandleClickAt = 1;
2453
+ const HandleContextMenu = 2;
2454
+ const HandleFocus = 3;
2455
+ const HandleInput = 4;
2456
+ const HandleMouseOut = 5;
2457
+ const HandleMouseOutAt = 6;
2458
+ const HandleMouseOver = 7;
2459
+ const HandleMouseOverAt = 8;
2460
+ const HandleWheel = 9;
2378
2461
 
2379
- const MessageEnterToCommitOnMaster = `Message (Enter) to commit on 'master'`;
2380
- const SourceControlInput = 'Source Control Input';
2462
+ const SourceControlInput = 'SourceControlInput';
2381
2463
 
2382
- const messageEnterToCommitOnMaster = () => {
2383
- return i18nString(MessageEnterToCommitOnMaster);
2384
- };
2385
- const sourceControlInput = () => {
2386
- return i18nString(SourceControlInput);
2387
- };
2388
-
2389
- const getSourceControlHeaderVirtualDom = () => {
2464
+ const getSourceControlInputDom = inputPlaceholder => {
2390
2465
  return [{
2391
- type: Div,
2392
- className: SourceControlHeader,
2393
- childCount: 1
2394
- }, {
2395
- type: Input,
2396
- className: InputBox,
2466
+ type: TextArea,
2467
+ className: mergeClassNames(InputBox, 'MultilineInputBox'),
2397
2468
  ariaLabel: sourceControlInput(),
2398
2469
  autocapitalize: 'off',
2399
2470
  autocorrect: 'off',
2400
2471
  childCount: 0,
2401
- name: SourceControlInput$1,
2472
+ name: SourceControlInput,
2402
2473
  onFocus: HandleFocus,
2403
2474
  onInput: HandleInput,
2404
- placeholder: messageEnterToCommitOnMaster(),
2475
+ placeholder: inputPlaceholder,
2405
2476
  spellcheck: false
2406
2477
  }];
2407
2478
  };
2408
2479
 
2480
+ const getSourceControlHeaderVirtualDom = inputPlaceholder => {
2481
+ return [{
2482
+ type: Div,
2483
+ className: SourceControlHeader,
2484
+ childCount: 1
2485
+ }, ...getSourceControlInputDom(inputPlaceholder)];
2486
+ };
2487
+
2409
2488
  const getBadgeVirtualDom = (className, count) => {
2410
2489
  return [{
2411
2490
  type: Div,
@@ -2621,7 +2700,7 @@ const getSplitButtonVirtualDom = (hasItems, splitButtonEnabled, buttonText) => {
2621
2700
  }];
2622
2701
  };
2623
2702
 
2624
- const getSourceControlVirtualDom = (items, splitButtonEnabled) => {
2703
+ const getSourceControlVirtualDom = (items, splitButtonEnabled, inputPlaceholder) => {
2625
2704
  const hasItems = items.length > 0;
2626
2705
  const dom = [{
2627
2706
  type: Div,
@@ -2632,20 +2711,37 @@ const getSourceControlVirtualDom = (items, splitButtonEnabled) => {
2632
2711
  onMouseOut: HandleMouseOut,
2633
2712
  onWheel: HandleWheel,
2634
2713
  childCount: splitButtonEnabled ? 3 : 2
2635
- }, ...getSourceControlHeaderVirtualDom(), ...getSplitButtonVirtualDom(hasItems, splitButtonEnabled, 'Commit'), ...getSourceControlListVirtualDom(items)];
2714
+ }, ...getSourceControlHeaderVirtualDom(inputPlaceholder), ...getSplitButtonVirtualDom(hasItems, splitButtonEnabled, 'Commit'), ...getSourceControlListVirtualDom(items)];
2636
2715
  return dom;
2637
2716
  };
2638
2717
 
2639
2718
  const renderItems = (oldState, newState) => {
2640
- const visible = newState.visibleItems;
2641
- const dom = getSourceControlVirtualDom(visible, newState.splitButtonEnabled);
2642
- return [SetDom2, dom];
2719
+ const {
2720
+ visibleItems,
2721
+ splitButtonEnabled,
2722
+ inputPlaceholder,
2723
+ id
2724
+ } = newState;
2725
+ const dom = getSourceControlVirtualDom(visibleItems, splitButtonEnabled, inputPlaceholder);
2726
+ return [SetDom2, id, dom];
2727
+ };
2728
+
2729
+ const renderValue = (oldState, newState) => {
2730
+ const {
2731
+ id,
2732
+ inputValue
2733
+ } = newState;
2734
+ return [SetValueByName, id, SourceControlInput, inputValue];
2643
2735
  };
2644
2736
 
2645
2737
  const getRenderer = diffType => {
2646
2738
  switch (diffType) {
2647
2739
  case RenderItems:
2648
2740
  return renderItems;
2741
+ case RenderValue:
2742
+ return renderValue;
2743
+ case RenderCss:
2744
+ return renderCss;
2649
2745
  default:
2650
2746
  throw new Error('unknown renderer');
2651
2747
  }
@@ -2708,7 +2804,7 @@ const getActionsVirtualDom = actions => {
2708
2804
  }, ...actions.flatMap(getActionVirtualDom)];
2709
2805
  };
2710
2806
 
2711
- const renderActions = uid => {
2807
+ const renderActions = state => {
2712
2808
  const actions = [];
2713
2809
  const dom = getActionsVirtualDom(actions);
2714
2810
  return dom;
@@ -2788,11 +2884,13 @@ const commandMap = {
2788
2884
  'SourceControl.create2': create2,
2789
2885
  'SourceControl.diff2': diff2,
2790
2886
  'SourceControl.getCommandIds': getCommandIds,
2887
+ 'SourceControl.getInfo': getInfo,
2791
2888
  'SourceControl.handleButtonClick': wrapCommand(handleButtonClick),
2792
2889
  'SourceControl.handleClickAt': wrapCommand(handleClickAt),
2793
2890
  'SourceControl.handleClickSourceControlButtons': wrapCommand(handleClickSourceControlButtons),
2794
2891
  'SourceControl.handleContextMenu': wrapCommand(handleContextMenu),
2795
2892
  'SourceControl.handleFocus': wrapCommand(handleFocus),
2893
+ 'SourceControl.handleInput': wrapCommand(handleInput),
2796
2894
  'SourceControl.handleMouseOut': wrapCommand(handleMouseOut),
2797
2895
  'SourceControl.handleMouseOutAt': wrapCommand(handleMouseOutAt),
2798
2896
  'SourceControl.handleMouseOver': wrapCommand(handleMouseOver),
@@ -2801,14 +2899,14 @@ const commandMap = {
2801
2899
  'SourceControl.loadContent': wrapCommand(loadContent),
2802
2900
  'SourceControl.refresh': wrapCommand(refresh),
2803
2901
  'SourceControl.render2': render2,
2902
+ 'SourceControl.renderActions': wrapGetter(renderActions),
2804
2903
  'SourceControl.renderActions2': renderActions,
2805
2904
  'SourceControl.renderEventListeners': renderEventListeners,
2806
2905
  'SourceControl.saveState': saveState,
2807
2906
  'SourceControl.selectIndex': wrapCommand(selectIndex),
2808
2907
  'SourceControl.setDeltaY': wrapCommand(setDeltaY),
2809
2908
  'SourceControl.terminate': terminate,
2810
- 'SourceControl.updateIcons': wrapCommand(updateIcons),
2811
- 'SourceControl.getInfo': getInfo
2909
+ 'SourceControl.updateIcons': wrapCommand(updateIcons)
2812
2910
  };
2813
2911
 
2814
2912
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/source-control-worker",
3
- "version": "1.18.0",
3
+ "version": "1.20.0",
4
4
  "description": "Source Control Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"