@lvce-editor/source-control-worker 1.19.0 → 1.21.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,36 @@ 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: 'system-ui, Ubuntu, "Droid Sans", sans-serif',
1619
+ inputFontSize: 13,
1620
+ inputFontWeight: 400,
1621
+ inputLetterSpacing: 0,
1622
+ inputLineHeight: 14.95
1610
1623
  };
1611
1624
  set$1(id, state, state);
1612
1625
  };
1613
1626
 
1627
+ const isEqual$2 = (oldState, newState) => {
1628
+ return oldState.inputBoxHeight === newState.inputBoxHeight;
1629
+ };
1630
+
1614
1631
  const RenderItems = 4;
1632
+ const RenderValue = 8;
1633
+ const RenderCss = 10;
1615
1634
 
1616
- const diffType = RenderItems;
1617
- const isEqual = (oldState, newState) => {
1635
+ const isEqual$1 = (oldState, newState) => {
1618
1636
  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
1637
  };
1620
1638
 
1621
- const modules = [isEqual];
1622
- const numbers = [diffType];
1639
+ const isEqual = (oldState, newState) => {
1640
+ return newState.inputSource === User || oldState.inputValue === newState.inputValue;
1641
+ };
1642
+
1643
+ const modules = [isEqual$1, isEqual, isEqual$2];
1644
+ const numbers = [RenderItems, RenderValue, RenderCss];
1623
1645
 
1624
1646
  const diff = (oldState, newState) => {
1625
1647
  const diffResult = [];
@@ -2251,6 +2273,45 @@ const handleFocus = async state => {
2251
2273
  return state;
2252
2274
  };
2253
2275
 
2276
+ const getTextHeight = async (input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight) => {
2277
+ try {
2278
+ // TODO line height could also be like 1.5
2279
+ const lineHeightPx = `${lineHeight}px`;
2280
+ // @ts-ignore
2281
+ const height = await invoke$2(`MeasureTextHeight.measureTextBlockHeight`, input, fontFamily, fontSize, lineHeightPx, width);
2282
+ return height;
2283
+ } catch {
2284
+ // fallback
2285
+ const lines = input.split('\n');
2286
+ const lineCount = lines.length;
2287
+ const inputHeight = lineCount * lineHeight;
2288
+ return inputHeight;
2289
+ }
2290
+ };
2291
+
2292
+ const getInputHeight = async (input, width, fontFamily, fontWeight, fontSize, letterSpacing, lineHeight) => {
2293
+ const height = await getTextHeight(input, width, fontFamily, fontSize, fontWeight, letterSpacing, lineHeight);
2294
+ return height;
2295
+ };
2296
+
2297
+ const handleInput = async (state, value, inputSource = User) => {
2298
+ const {
2299
+ width,
2300
+ inputFontFamily,
2301
+ inputFontSize,
2302
+ inputFontWeight,
2303
+ inputLetterSpacing,
2304
+ inputLineHeight
2305
+ } = state;
2306
+ const inputBoxHeight = await getInputHeight(value, width, inputFontFamily, inputFontWeight, inputFontSize, inputLetterSpacing, inputLineHeight);
2307
+ return {
2308
+ ...state,
2309
+ inputValue: value,
2310
+ inputSource,
2311
+ inputBoxHeight
2312
+ };
2313
+ };
2314
+
2254
2315
  const handleMouseOut = (state, index) => {
2255
2316
  const {
2256
2317
  items
@@ -2336,6 +2397,18 @@ const initialize = async () => {
2336
2397
  set(extensionHostRpc);
2337
2398
  };
2338
2399
 
2400
+ const renderCss = (oldState, newState) => {
2401
+ const {
2402
+ id,
2403
+ inputBoxHeight
2404
+ } = newState;
2405
+ const css = `:root {
2406
+ --SourceControlInputHeight: ${inputBoxHeight}px;
2407
+ }
2408
+ `;
2409
+ return [SetCss, id, css];
2410
+ };
2411
+
2339
2412
  const mergeClassNames = (...classNames) => {
2340
2413
  return classNames.filter(Boolean).join(' ');
2341
2414
  };
@@ -2377,15 +2450,15 @@ const StrikeThrough = 'StrikeThrough';
2377
2450
  const TreeItem = 'TreeItem';
2378
2451
  const Viewlet = 'Viewlet';
2379
2452
 
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';
2453
+ const HandleClickAt = 1;
2454
+ const HandleContextMenu = 2;
2455
+ const HandleFocus = 3;
2456
+ const HandleInput = 4;
2457
+ const HandleMouseOut = 5;
2458
+ const HandleMouseOutAt = 6;
2459
+ const HandleMouseOver = 7;
2460
+ const HandleMouseOverAt = 8;
2461
+ const HandleWheel = 9;
2389
2462
 
2390
2463
  const SourceControlInput = 'SourceControlInput';
2391
2464
 
@@ -2647,16 +2720,29 @@ const renderItems = (oldState, newState) => {
2647
2720
  const {
2648
2721
  visibleItems,
2649
2722
  splitButtonEnabled,
2650
- inputPlaceholder
2723
+ inputPlaceholder,
2724
+ id
2651
2725
  } = newState;
2652
2726
  const dom = getSourceControlVirtualDom(visibleItems, splitButtonEnabled, inputPlaceholder);
2653
- return [SetDom2, dom];
2727
+ return [SetDom2, id, dom];
2728
+ };
2729
+
2730
+ const renderValue = (oldState, newState) => {
2731
+ const {
2732
+ id,
2733
+ inputValue
2734
+ } = newState;
2735
+ return [SetValueByName, id, SourceControlInput, inputValue];
2654
2736
  };
2655
2737
 
2656
2738
  const getRenderer = diffType => {
2657
2739
  switch (diffType) {
2658
2740
  case RenderItems:
2659
2741
  return renderItems;
2742
+ case RenderValue:
2743
+ return renderValue;
2744
+ case RenderCss:
2745
+ return renderCss;
2660
2746
  default:
2661
2747
  throw new Error('unknown renderer');
2662
2748
  }
@@ -2719,7 +2805,7 @@ const getActionsVirtualDom = actions => {
2719
2805
  }, ...actions.flatMap(getActionVirtualDom)];
2720
2806
  };
2721
2807
 
2722
- const renderActions = uid => {
2808
+ const renderActions = state => {
2723
2809
  const actions = [];
2724
2810
  const dom = getActionsVirtualDom(actions);
2725
2811
  return dom;
@@ -2799,11 +2885,13 @@ const commandMap = {
2799
2885
  'SourceControl.create2': create2,
2800
2886
  'SourceControl.diff2': diff2,
2801
2887
  'SourceControl.getCommandIds': getCommandIds,
2888
+ 'SourceControl.getInfo': getInfo,
2802
2889
  'SourceControl.handleButtonClick': wrapCommand(handleButtonClick),
2803
2890
  'SourceControl.handleClickAt': wrapCommand(handleClickAt),
2804
2891
  'SourceControl.handleClickSourceControlButtons': wrapCommand(handleClickSourceControlButtons),
2805
2892
  'SourceControl.handleContextMenu': wrapCommand(handleContextMenu),
2806
2893
  'SourceControl.handleFocus': wrapCommand(handleFocus),
2894
+ 'SourceControl.handleInput': wrapCommand(handleInput),
2807
2895
  'SourceControl.handleMouseOut': wrapCommand(handleMouseOut),
2808
2896
  'SourceControl.handleMouseOutAt': wrapCommand(handleMouseOutAt),
2809
2897
  'SourceControl.handleMouseOver': wrapCommand(handleMouseOver),
@@ -2812,14 +2900,14 @@ const commandMap = {
2812
2900
  'SourceControl.loadContent': wrapCommand(loadContent),
2813
2901
  'SourceControl.refresh': wrapCommand(refresh),
2814
2902
  'SourceControl.render2': render2,
2903
+ 'SourceControl.renderActions': wrapGetter(renderActions),
2815
2904
  'SourceControl.renderActions2': renderActions,
2816
2905
  'SourceControl.renderEventListeners': renderEventListeners,
2817
2906
  'SourceControl.saveState': saveState,
2818
2907
  'SourceControl.selectIndex': wrapCommand(selectIndex),
2819
2908
  'SourceControl.setDeltaY': wrapCommand(setDeltaY),
2820
2909
  'SourceControl.terminate': terminate,
2821
- 'SourceControl.updateIcons': wrapCommand(updateIcons),
2822
- 'SourceControl.getInfo': getInfo
2910
+ 'SourceControl.updateIcons': wrapCommand(updateIcons)
2823
2911
  };
2824
2912
 
2825
2913
  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.21.0",
4
4
  "description": "Source Control Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"