@lvce-editor/source-control-worker 1.19.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.
@@ -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: '',
@@ -1606,20 +1612,35 @@ const create2 = (id, uri, x, y, width, height, workspacePath) => {
1606
1612
  workspacePath,
1607
1613
  x,
1608
1614
  y,
1609
- inputPlaceholder: ''
1615
+ inputPlaceholder: '',
1616
+ inputSource: 0,
1617
+ maxInputLines: 5,
1618
+ inputFontFamily: '"Fira Code"',
1619
+ inputFontSize: 15,
1620
+ inputFontWeight: 400,
1621
+ inputLetterSpacing: 0.5
1610
1622
  };
1611
1623
  set$1(id, state, state);
1612
1624
  };
1613
1625
 
1626
+ const isEqual$2 = (oldState, newState) => {
1627
+ return newState.inputBoxHeight === newState.inputBoxHeight;
1628
+ };
1629
+
1614
1630
  const RenderItems = 4;
1631
+ const RenderValue = 8;
1632
+ const RenderCss = 10;
1615
1633
 
1616
- const diffType = RenderItems;
1617
- const isEqual = (oldState, newState) => {
1634
+ const isEqual$1 = (oldState, newState) => {
1618
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;
1619
1636
  };
1620
1637
 
1621
- const modules = [isEqual];
1622
- 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];
1623
1644
 
1624
1645
  const diff = (oldState, newState) => {
1625
1646
  const diffResult = [];
@@ -2251,6 +2272,45 @@ const handleFocus = async state => {
2251
2272
  return state;
2252
2273
  };
2253
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
+
2254
2314
  const handleMouseOut = (state, index) => {
2255
2315
  const {
2256
2316
  items
@@ -2336,6 +2396,18 @@ const initialize = async () => {
2336
2396
  set(extensionHostRpc);
2337
2397
  };
2338
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
+
2339
2411
  const mergeClassNames = (...classNames) => {
2340
2412
  return classNames.filter(Boolean).join(' ');
2341
2413
  };
@@ -2377,15 +2449,15 @@ const StrikeThrough = 'StrikeThrough';
2377
2449
  const TreeItem = 'TreeItem';
2378
2450
  const Viewlet = 'Viewlet';
2379
2451
 
2380
- const HandleClickAt = 'handleClickAt';
2381
- const HandleContextMenu = 'handleContextMenu';
2382
- const HandleFocus = 'handleFocus';
2383
- const HandleInput = 'handleInput';
2384
- const HandleMouseOut = 'handleMouseOut';
2385
- const HandleMouseOutAt = 'handleMouseOutAt';
2386
- const HandleMouseOver = 'handleMouseOver';
2387
- const HandleMouseOverAt = 'handleMouseOverAt';
2388
- const HandleWheel = 'handleWheel';
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;
2389
2461
 
2390
2462
  const SourceControlInput = 'SourceControlInput';
2391
2463
 
@@ -2647,16 +2719,29 @@ const renderItems = (oldState, newState) => {
2647
2719
  const {
2648
2720
  visibleItems,
2649
2721
  splitButtonEnabled,
2650
- inputPlaceholder
2722
+ inputPlaceholder,
2723
+ id
2651
2724
  } = newState;
2652
2725
  const dom = getSourceControlVirtualDom(visibleItems, splitButtonEnabled, inputPlaceholder);
2653
- return [SetDom2, dom];
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];
2654
2735
  };
2655
2736
 
2656
2737
  const getRenderer = diffType => {
2657
2738
  switch (diffType) {
2658
2739
  case RenderItems:
2659
2740
  return renderItems;
2741
+ case RenderValue:
2742
+ return renderValue;
2743
+ case RenderCss:
2744
+ return renderCss;
2660
2745
  default:
2661
2746
  throw new Error('unknown renderer');
2662
2747
  }
@@ -2719,7 +2804,7 @@ const getActionsVirtualDom = actions => {
2719
2804
  }, ...actions.flatMap(getActionVirtualDom)];
2720
2805
  };
2721
2806
 
2722
- const renderActions = uid => {
2807
+ const renderActions = state => {
2723
2808
  const actions = [];
2724
2809
  const dom = getActionsVirtualDom(actions);
2725
2810
  return dom;
@@ -2799,11 +2884,13 @@ const commandMap = {
2799
2884
  'SourceControl.create2': create2,
2800
2885
  'SourceControl.diff2': diff2,
2801
2886
  'SourceControl.getCommandIds': getCommandIds,
2887
+ 'SourceControl.getInfo': getInfo,
2802
2888
  'SourceControl.handleButtonClick': wrapCommand(handleButtonClick),
2803
2889
  'SourceControl.handleClickAt': wrapCommand(handleClickAt),
2804
2890
  'SourceControl.handleClickSourceControlButtons': wrapCommand(handleClickSourceControlButtons),
2805
2891
  'SourceControl.handleContextMenu': wrapCommand(handleContextMenu),
2806
2892
  'SourceControl.handleFocus': wrapCommand(handleFocus),
2893
+ 'SourceControl.handleInput': wrapCommand(handleInput),
2807
2894
  'SourceControl.handleMouseOut': wrapCommand(handleMouseOut),
2808
2895
  'SourceControl.handleMouseOutAt': wrapCommand(handleMouseOutAt),
2809
2896
  'SourceControl.handleMouseOver': wrapCommand(handleMouseOver),
@@ -2812,14 +2899,14 @@ const commandMap = {
2812
2899
  'SourceControl.loadContent': wrapCommand(loadContent),
2813
2900
  'SourceControl.refresh': wrapCommand(refresh),
2814
2901
  'SourceControl.render2': render2,
2902
+ 'SourceControl.renderActions': wrapGetter(renderActions),
2815
2903
  'SourceControl.renderActions2': renderActions,
2816
2904
  'SourceControl.renderEventListeners': renderEventListeners,
2817
2905
  'SourceControl.saveState': saveState,
2818
2906
  'SourceControl.selectIndex': wrapCommand(selectIndex),
2819
2907
  'SourceControl.setDeltaY': wrapCommand(setDeltaY),
2820
2908
  'SourceControl.terminate': terminate,
2821
- 'SourceControl.updateIcons': wrapCommand(updateIcons),
2822
- 'SourceControl.getInfo': getInfo
2909
+ 'SourceControl.updateIcons': wrapCommand(updateIcons)
2823
2910
  };
2824
2911
 
2825
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.19.0",
3
+ "version": "1.20.0",
4
4
  "description": "Source Control Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"