@lvce-editor/activity-bar-worker 7.1.0 → 7.2.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.
- package/dist/activityBarWorkerMain.js +93 -30
- package/package.json +1 -1
|
@@ -13,13 +13,13 @@ const create$a = () => {
|
|
|
13
13
|
},
|
|
14
14
|
diff(uid, modules, numbers) {
|
|
15
15
|
const {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
oldState,
|
|
17
|
+
scheduledState
|
|
18
18
|
} = states[uid];
|
|
19
19
|
const diffResult = [];
|
|
20
20
|
for (let i = 0; i < modules.length; i++) {
|
|
21
21
|
const fn = modules[i];
|
|
22
|
-
if (!fn(oldState,
|
|
22
|
+
if (!fn(oldState, scheduledState)) {
|
|
23
23
|
diffResult.push(numbers[i]);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -37,17 +37,16 @@ const create$a = () => {
|
|
|
37
37
|
return ids;
|
|
38
38
|
},
|
|
39
39
|
getKeys() {
|
|
40
|
-
return Object.keys(states).map(
|
|
41
|
-
return Number.parseFloat(key);
|
|
42
|
-
});
|
|
40
|
+
return Object.keys(states).map(Number);
|
|
43
41
|
},
|
|
44
42
|
registerCommands(commandMap) {
|
|
45
43
|
Object.assign(commandMapRef, commandMap);
|
|
46
44
|
},
|
|
47
|
-
set(uid, oldState, newState) {
|
|
45
|
+
set(uid, oldState, newState, scheduledState) {
|
|
48
46
|
states[uid] = {
|
|
49
47
|
newState,
|
|
50
|
-
oldState
|
|
48
|
+
oldState,
|
|
49
|
+
scheduledState: scheduledState ?? newState
|
|
51
50
|
};
|
|
52
51
|
},
|
|
53
52
|
wrapCommand(fn) {
|
|
@@ -67,7 +66,8 @@ const create$a = () => {
|
|
|
67
66
|
};
|
|
68
67
|
states[uid] = {
|
|
69
68
|
newState: latestNew,
|
|
70
|
-
oldState: latestOld.oldState
|
|
69
|
+
oldState: latestOld.oldState,
|
|
70
|
+
scheduledState: latestNew
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
73
|
return wrapped;
|
|
@@ -104,7 +104,8 @@ const create$a = () => {
|
|
|
104
104
|
};
|
|
105
105
|
states[uid] = {
|
|
106
106
|
newState: latestNew,
|
|
107
|
-
oldState: latestOld.oldState
|
|
107
|
+
oldState: latestOld.oldState,
|
|
108
|
+
scheduledState: latestNew
|
|
108
109
|
};
|
|
109
110
|
return {
|
|
110
111
|
error
|
|
@@ -159,8 +160,60 @@ const create$9 = (id, uri, x, y, width, height, args, parentUid, platform = 0) =
|
|
|
159
160
|
return state;
|
|
160
161
|
};
|
|
161
162
|
|
|
163
|
+
const hashString = value => {
|
|
164
|
+
let hash = 2_166_136_261;
|
|
165
|
+
for (const character of value) {
|
|
166
|
+
hash ^= character.codePointAt(0) || 0;
|
|
167
|
+
hash = Math.imul(hash, 16_777_619);
|
|
168
|
+
}
|
|
169
|
+
return (hash >>> 0).toString(36);
|
|
170
|
+
};
|
|
171
|
+
const isCustomIconUrl = icon => {
|
|
172
|
+
return icon.startsWith('http://') || icon.startsWith('https://') || icon.startsWith('file://') || icon.startsWith('/');
|
|
173
|
+
};
|
|
174
|
+
const getCustomIconClass = (id, iconUrl) => {
|
|
175
|
+
const hashInput = id + '\n' + iconUrl;
|
|
176
|
+
return `MaskIconCustomView${hashString(hashInput)}`;
|
|
177
|
+
};
|
|
178
|
+
const getIconClass = (item, builtinPrefix) => {
|
|
179
|
+
if (item.customIconClass) {
|
|
180
|
+
return item.customIconClass;
|
|
181
|
+
}
|
|
182
|
+
return `${builtinPrefix}${item.icon}`;
|
|
183
|
+
};
|
|
184
|
+
const escapeCssUrl = url => {
|
|
185
|
+
return url.replaceAll('\\', '\\\\').replaceAll('"', '\\"').replaceAll('\n', '\\a ').replaceAll('\r', '\\d ').replaceAll('\f', '\\c ');
|
|
186
|
+
};
|
|
187
|
+
const getCustomIconCss = items => {
|
|
188
|
+
const seen = new Set();
|
|
189
|
+
let css = '';
|
|
190
|
+
for (const item of items) {
|
|
191
|
+
const {
|
|
192
|
+
customIconClass,
|
|
193
|
+
customIconUrl
|
|
194
|
+
} = item;
|
|
195
|
+
if (!customIconClass || !customIconUrl || seen.has(customIconClass)) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
seen.add(customIconClass);
|
|
199
|
+
css += `.${customIconClass} {
|
|
200
|
+
mask-image: url("${escapeCssUrl(customIconUrl)}");
|
|
201
|
+
}
|
|
202
|
+
`;
|
|
203
|
+
}
|
|
204
|
+
return css;
|
|
205
|
+
};
|
|
206
|
+
const getCustomIconSignature = items => {
|
|
207
|
+
return items.map(item => {
|
|
208
|
+
if (!item.customIconClass || !item.customIconUrl) {
|
|
209
|
+
return '';
|
|
210
|
+
}
|
|
211
|
+
return `${item.customIconClass}\n${item.customIconUrl}`;
|
|
212
|
+
}).filter(Boolean).join('\n');
|
|
213
|
+
};
|
|
214
|
+
|
|
162
215
|
const isEqual$2 = (oldState, newState) => {
|
|
163
|
-
return oldState.itemHeight === newState.itemHeight;
|
|
216
|
+
return oldState.itemHeight === newState.itemHeight && getCustomIconSignature(oldState.filteredItems) === getCustomIconSignature(newState.filteredItems);
|
|
164
217
|
};
|
|
165
218
|
|
|
166
219
|
const isEqual$1 = (oldState, newState) => {
|
|
@@ -481,7 +534,7 @@ const getMenuEntriesActivityBar = state => {
|
|
|
481
534
|
} = state;
|
|
482
535
|
const topItems = activityBarItems.filter(item => !(item.flags & Button));
|
|
483
536
|
const bottomItems = activityBarItems.filter(item => item.flags & Button);
|
|
484
|
-
const entries =
|
|
537
|
+
const entries = topItems.map(toContextMenuItem$1);
|
|
485
538
|
if (bottomItems.length > 0) {
|
|
486
539
|
entries.push(menuEntrySeparator, ...bottomItems.map(toContextMenuItem$1));
|
|
487
540
|
}
|
|
@@ -628,7 +681,7 @@ class AssertionError extends Error {
|
|
|
628
681
|
const Object$1 = 1;
|
|
629
682
|
const Number$1 = 2;
|
|
630
683
|
const Array$1 = 3;
|
|
631
|
-
const String = 4;
|
|
684
|
+
const String$1 = 4;
|
|
632
685
|
const Boolean$1 = 5;
|
|
633
686
|
const Function = 6;
|
|
634
687
|
const Null = 7;
|
|
@@ -640,7 +693,7 @@ const getType = value => {
|
|
|
640
693
|
case 'function':
|
|
641
694
|
return Function;
|
|
642
695
|
case 'string':
|
|
643
|
-
return String;
|
|
696
|
+
return String$1;
|
|
644
697
|
case 'object':
|
|
645
698
|
if (value === null) {
|
|
646
699
|
return Null;
|
|
@@ -1754,7 +1807,7 @@ const updateItemsWithBadgeCount = async items => {
|
|
|
1754
1807
|
const badgeCounts = await invoke('Layout.getBadgeCounts');
|
|
1755
1808
|
const newItems = items.map(item => {
|
|
1756
1809
|
const badgeCount = badgeCounts[item.id] || 0;
|
|
1757
|
-
const badgeText = badgeCount ?
|
|
1810
|
+
const badgeText = badgeCount ? String(badgeCount) : '';
|
|
1758
1811
|
return {
|
|
1759
1812
|
...item,
|
|
1760
1813
|
badgeText
|
|
@@ -2029,13 +2082,24 @@ const Search = 'Search';
|
|
|
2029
2082
|
const SourceControl = 'Source Control';
|
|
2030
2083
|
|
|
2031
2084
|
const toActivityBarItem = view => {
|
|
2032
|
-
|
|
2085
|
+
const icon = view.icon || Extensions$1;
|
|
2086
|
+
const customIconUrl = isCustomIconUrl(icon) ? icon : undefined;
|
|
2087
|
+
const customIconClass = customIconUrl ? getCustomIconClass(view.id, customIconUrl) : undefined;
|
|
2088
|
+
const item = {
|
|
2033
2089
|
flags: Tab | Enabled,
|
|
2034
|
-
icon
|
|
2090
|
+
icon,
|
|
2035
2091
|
id: view.id,
|
|
2036
2092
|
keyShortcuts: '',
|
|
2037
2093
|
title: view.title || view.id
|
|
2038
2094
|
};
|
|
2095
|
+
if (customIconClass && customIconUrl) {
|
|
2096
|
+
return {
|
|
2097
|
+
...item,
|
|
2098
|
+
customIconClass,
|
|
2099
|
+
customIconUrl
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
return item;
|
|
2039
2103
|
};
|
|
2040
2104
|
const getActivityBarItems = (state, contributedViews = []) => {
|
|
2041
2105
|
const {
|
|
@@ -2345,19 +2409,20 @@ const loadContent = async state => {
|
|
|
2345
2409
|
};
|
|
2346
2410
|
};
|
|
2347
2411
|
|
|
2348
|
-
const getCss = itemHeight => {
|
|
2412
|
+
const getCss = (itemHeight, items = []) => {
|
|
2349
2413
|
return `:root {
|
|
2350
2414
|
--ActivityBarItemHeight: var(--${itemHeight}px);
|
|
2351
2415
|
}
|
|
2352
|
-
`;
|
|
2416
|
+
${getCustomIconCss(items)}`;
|
|
2353
2417
|
};
|
|
2354
2418
|
|
|
2355
2419
|
const renderCss = (oldState, newState) => {
|
|
2356
2420
|
const {
|
|
2421
|
+
filteredItems,
|
|
2357
2422
|
itemHeight,
|
|
2358
2423
|
uid
|
|
2359
2424
|
} = newState;
|
|
2360
|
-
const css = getCss(itemHeight);
|
|
2425
|
+
const css = getCss(itemHeight, filteredItems);
|
|
2361
2426
|
return [SetCss, uid, css];
|
|
2362
2427
|
};
|
|
2363
2428
|
|
|
@@ -2451,12 +2516,12 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
|
2451
2516
|
};
|
|
2452
2517
|
|
|
2453
2518
|
const compareNodes = (oldNode, newNode) => {
|
|
2454
|
-
const patches = [];
|
|
2455
2519
|
// Check if node type changed - return null to signal incompatible nodes
|
|
2456
2520
|
// (caller should handle this with a Replace operation)
|
|
2457
2521
|
if (oldNode.type !== newNode.type) {
|
|
2458
2522
|
return null;
|
|
2459
2523
|
}
|
|
2524
|
+
const patches = [];
|
|
2460
2525
|
// Handle reference nodes - special handling for uid changes
|
|
2461
2526
|
if (oldNode.type === Reference) {
|
|
2462
2527
|
if (oldNode.uid !== newNode.uid) {
|
|
@@ -2492,7 +2557,7 @@ const compareNodes = (oldNode, newNode) => {
|
|
|
2492
2557
|
}
|
|
2493
2558
|
// Check for removed attributes
|
|
2494
2559
|
for (const key of oldKeys) {
|
|
2495
|
-
if (!(key
|
|
2560
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
2496
2561
|
patches.push({
|
|
2497
2562
|
type: RemoveAttribute,
|
|
2498
2563
|
key
|
|
@@ -2707,7 +2772,6 @@ const getClassName = (isFocused, marginTop, isSelected) => {
|
|
|
2707
2772
|
const getActivityBarItemInProgressDom = item => {
|
|
2708
2773
|
const {
|
|
2709
2774
|
flags,
|
|
2710
|
-
icon,
|
|
2711
2775
|
title
|
|
2712
2776
|
} = item;
|
|
2713
2777
|
const isTab = flags & Tab;
|
|
@@ -2730,7 +2794,7 @@ const getActivityBarItemInProgressDom = item => {
|
|
|
2730
2794
|
type: Div
|
|
2731
2795
|
}, {
|
|
2732
2796
|
childCount: 0,
|
|
2733
|
-
className: mergeClassNames(Icon,
|
|
2797
|
+
className: mergeClassNames(Icon, getIconClass(item, 'MaskIcon')),
|
|
2734
2798
|
role: None$1,
|
|
2735
2799
|
type: Div
|
|
2736
2800
|
}, ...getBadgeVirtualDom()];
|
|
@@ -2740,7 +2804,6 @@ const getActivityBarItemWithBadgeDom = item => {
|
|
|
2740
2804
|
const {
|
|
2741
2805
|
badgeText,
|
|
2742
2806
|
flags,
|
|
2743
|
-
icon,
|
|
2744
2807
|
title
|
|
2745
2808
|
} = item;
|
|
2746
2809
|
if (!badgeText) {
|
|
@@ -2767,7 +2830,7 @@ const getActivityBarItemWithBadgeDom = item => {
|
|
|
2767
2830
|
type: Div
|
|
2768
2831
|
}, {
|
|
2769
2832
|
childCount: 0,
|
|
2770
|
-
className: mergeClassNames(Icon,
|
|
2833
|
+
className: mergeClassNames(Icon, getIconClass(item, 'MaskIcon')),
|
|
2771
2834
|
role: None$1,
|
|
2772
2835
|
type: Div
|
|
2773
2836
|
}, {
|
|
@@ -2777,10 +2840,10 @@ const getActivityBarItemWithBadgeDom = item => {
|
|
|
2777
2840
|
}, text(badgeText)];
|
|
2778
2841
|
};
|
|
2779
2842
|
|
|
2780
|
-
const getIconVirtualDom = (icon, type = Div) => {
|
|
2843
|
+
const getIconVirtualDom = (icon, type = Div, customIconClass = '') => {
|
|
2781
2844
|
return {
|
|
2782
2845
|
childCount: 0,
|
|
2783
|
-
className: `MaskIcon MaskIcon${icon}`,
|
|
2846
|
+
className: customIconClass ? `MaskIcon ${customIconClass}` : `MaskIcon MaskIcon${icon}`,
|
|
2784
2847
|
role: None$1,
|
|
2785
2848
|
type
|
|
2786
2849
|
};
|
|
@@ -2812,7 +2875,7 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
2812
2875
|
role,
|
|
2813
2876
|
title,
|
|
2814
2877
|
type: Div
|
|
2815
|
-
}, getIconVirtualDom(icon)];
|
|
2878
|
+
}, getIconVirtualDom(icon, Div, item.customIconClass)];
|
|
2816
2879
|
}
|
|
2817
2880
|
|
|
2818
2881
|
// TODO support progress on selected activity bar item
|
|
@@ -2827,7 +2890,7 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
2827
2890
|
ariaLabel: '',
|
|
2828
2891
|
ariaSelected,
|
|
2829
2892
|
childCount: 0,
|
|
2830
|
-
className: mergeClassNames(className,
|
|
2893
|
+
className: mergeClassNames(className, getIconClass(item, 'Icon')),
|
|
2831
2894
|
role,
|
|
2832
2895
|
title,
|
|
2833
2896
|
type: Div
|