@lvce-editor/source-control-worker 3.6.0 → 3.6.1

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.
@@ -1981,6 +1981,7 @@ const loadContent = async (state, savedState) => {
1981
1981
  inputPlaceholder,
1982
1982
  inputValue,
1983
1983
  items: displayItems,
1984
+ loading: false,
1984
1985
  maxLineY,
1985
1986
  root,
1986
1987
  scrollBarHeight,
@@ -2059,6 +2060,7 @@ const createDefaultState = () => ({
2059
2060
  isVisible: true,
2060
2061
  itemHeight: 20,
2061
2062
  items: [],
2063
+ loading: false,
2062
2064
  maxInputLines: 5,
2063
2065
  maxLineY: 0,
2064
2066
  merge: [],
@@ -2098,26 +2100,31 @@ const create2 = (id, _uri, x, y, width, height, workspacePath, platform, assetDi
2098
2100
  assetDir,
2099
2101
  height,
2100
2102
  id,
2101
- initial: true,
2103
+ initial: false,
2104
+ loading: true,
2102
2105
  platform,
2103
2106
  width,
2104
2107
  workspacePath,
2105
2108
  x,
2106
2109
  y
2107
2110
  };
2108
- set(id, state, state);
2111
+ set(id, {
2112
+ ...state,
2113
+ initial: true,
2114
+ loading: false
2115
+ }, state);
2109
2116
  };
2110
2117
 
2111
- const isEqual$3 = (oldState, newState) => {
2118
+ const isEqual$4 = (oldState, newState) => {
2112
2119
  return oldState.inputBoxHeight === newState.inputBoxHeight;
2113
2120
  };
2114
2121
 
2115
- const isEqual$2 = (oldState, newState) => {
2122
+ const isEqual$3 = (oldState, newState) => {
2116
2123
  return oldState.focus === newState.focus;
2117
2124
  };
2118
2125
 
2119
- const isEqual$1 = (oldState, newState) => {
2120
- return oldState.allGroups === newState.allGroups && oldState.deltaY === newState.deltaY && oldState.items === newState.items && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.sourceControlButtons === newState.sourceControlButtons && oldState.visibleItems === newState.visibleItems;
2126
+ const isEqual$2 = (oldState, newState) => {
2127
+ return oldState.allGroups === newState.allGroups && oldState.deltaY === newState.deltaY && oldState.items === newState.items && oldState.loading === newState.loading && oldState.maxLineY === newState.maxLineY && oldState.minLineY === newState.minLineY && oldState.sourceControlButtons === newState.sourceControlButtons && oldState.visibleItems === newState.visibleItems;
2121
2128
  };
2122
2129
 
2123
2130
  const RenderItems = 4;
@@ -2126,11 +2133,11 @@ const RenderValue = 8;
2126
2133
  const RenderCss = 10;
2127
2134
  const RenderIncremental = 11;
2128
2135
 
2129
- const isEqual = (oldState, newState) => {
2136
+ const isEqual$1 = (oldState, newState) => {
2130
2137
  return newState.inputSource === User || oldState.inputValue === newState.inputValue;
2131
2138
  };
2132
2139
 
2133
- const modules = [isEqual$1, isEqual, isEqual$3, isEqual$2];
2140
+ const modules = [isEqual$2, isEqual$1, isEqual$4, isEqual$3];
2134
2141
  const numbers = [RenderIncremental, RenderValue, RenderCss, RenderFocusContext];
2135
2142
 
2136
2143
  const diff = (oldState, newState) => {
@@ -2941,8 +2948,32 @@ const handleWheel = async (state, deltaMode, deltaY) => {
2941
2948
  return setDeltaY(state, state.deltaY + deltaY);
2942
2949
  };
2943
2950
 
2951
+ const isEqual = (oldProviderIds, newProviderIds) => {
2952
+ if (oldProviderIds.length !== newProviderIds.length) {
2953
+ return false;
2954
+ }
2955
+ for (let index = 0; index < oldProviderIds.length; index++) {
2956
+ if (oldProviderIds[index] !== newProviderIds[index]) {
2957
+ return false;
2958
+ }
2959
+ }
2960
+ return true;
2961
+ };
2944
2962
  const handleWorkspaceRefresh = async state => {
2945
- return refresh(state);
2963
+ const {
2964
+ assetDir,
2965
+ enabledProviderIds,
2966
+ platform,
2967
+ workspacePath
2968
+ } = state;
2969
+ const scheme = getProtocol(workspacePath);
2970
+ const newProviderIds = await getEnabledProviderIds(scheme, workspacePath, assetDir, platform);
2971
+ if (isEqual(enabledProviderIds, newProviderIds)) {
2972
+ return refresh(state);
2973
+ }
2974
+ return loadContent(state, {
2975
+ inputValue: state.inputValue
2976
+ });
2946
2977
  };
2947
2978
 
2948
2979
  const sendMessagePortToExtensionHostWorker = async port => {
@@ -3060,6 +3091,8 @@ const InputBox = 'InputBox';
3060
3091
  const Label = 'Label';
3061
3092
  const LabelDetail = 'LabelDetail';
3062
3093
  const Message = 'Message';
3094
+ const Progress = 'Progress';
3095
+ const ProgressContainer = 'ProgressContainer';
3063
3096
  const SourceControl = 'SourceControl';
3064
3097
  const SourceControlButton = 'SourceControlButton';
3065
3098
  const SourceControlHeader = 'SourceControlHeader';
@@ -3083,6 +3116,18 @@ const HandleWheel = 9;
3083
3116
  const HandleClickAction = 10;
3084
3117
  const HandleClickSourceControlButton = 11;
3085
3118
 
3119
+ const getProgressVirtualDom = () => {
3120
+ return [{
3121
+ childCount: 1,
3122
+ className: ProgressContainer,
3123
+ type: Div
3124
+ }, {
3125
+ childCount: 0,
3126
+ className: Progress,
3127
+ type: Div
3128
+ }];
3129
+ };
3130
+
3086
3131
  const getIconVirtualDom = (icon, type = Div) => {
3087
3132
  return {
3088
3133
  childCount: 0,
@@ -3340,7 +3385,7 @@ const getSourceControlListVirtualDom = items => {
3340
3385
  };
3341
3386
 
3342
3387
  const className = mergeClassNames(Viewlet, SourceControl);
3343
- const getSourceControlVirtualDom = (items, buttons, disabled, placeholder, inputMessage, message) => {
3388
+ const getSourceControlVirtualDom = (items, buttons, disabled, placeholder, inputMessage, message, loading) => {
3344
3389
  const content = message ? [{
3345
3390
  childCount: 1,
3346
3391
  className: Message,
@@ -3348,8 +3393,10 @@ const getSourceControlVirtualDom = (items, buttons, disabled, placeholder, input
3348
3393
  paddingRight: '20px',
3349
3394
  type: Div
3350
3395
  }, text(message)] : [...getSourceControlHeaderVirtualDom(placeholder, inputMessage), ...buttons.flatMap(button => getSourceControlButtonVirtualDom(button, disabled)), ...getSourceControlListVirtualDom(items)];
3396
+ const progressDom = loading ? getProgressVirtualDom() : [];
3351
3397
  const dom = [{
3352
- childCount: message ? 1 : 2 + buttons.length,
3398
+ ariaBusy: loading,
3399
+ childCount: (message ? 1 : 2 + buttons.length) + (loading ? 1 : 0),
3353
3400
  className: className,
3354
3401
  onContextMenu: HandleContextMenu,
3355
3402
  onMouseOver: HandleMouseOver,
@@ -3357,7 +3404,7 @@ const getSourceControlVirtualDom = (items, buttons, disabled, placeholder, input
3357
3404
  onWheel: HandleWheel,
3358
3405
  tabIndex: 0,
3359
3406
  type: Div
3360
- }, ...content];
3407
+ }, ...progressDom, ...content];
3361
3408
  return dom;
3362
3409
  };
3363
3410
 
@@ -3369,14 +3416,15 @@ const renderItems = (oldState, newState) => {
3369
3416
  inputMessage,
3370
3417
  inputPlaceholder,
3371
3418
  items,
3419
+ loading,
3372
3420
  sourceControlButtons,
3373
3421
  visibleItems
3374
3422
  } = newState;
3375
3423
  if (initial) {
3376
3424
  return [SetDom2, id, []];
3377
3425
  }
3378
- const unavailableMessage = enabledProviderIds.length === 0 ? noSourceControlProvider() : '';
3379
- const dom = getSourceControlVirtualDom(visibleItems, sourceControlButtons, items.length === 0, inputPlaceholder, inputMessage, unavailableMessage);
3426
+ const unavailableMessage = !loading && enabledProviderIds.length === 0 ? noSourceControlProvider() : '';
3427
+ const dom = getSourceControlVirtualDom(visibleItems, sourceControlButtons, items.length === 0, inputPlaceholder, inputMessage, unavailableMessage, loading);
3380
3428
  return [SetDom2, id, dom];
3381
3429
  };
3382
3430
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/source-control-worker",
3
- "version": "3.6.0",
3
+ "version": "3.6.1",
4
4
  "description": "Source Control Worker",
5
5
  "keywords": [
6
6
  "Lvce Editor"