@lvce-editor/running-extensions-view 1.11.0 → 1.12.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.
|
@@ -1362,6 +1362,9 @@ const {
|
|
|
1362
1362
|
invoke: invoke$2,
|
|
1363
1363
|
set: set$4
|
|
1364
1364
|
} = create$2(ExtensionManagementWorker);
|
|
1365
|
+
const disable2 = (id, platform) => {
|
|
1366
|
+
return invoke$2(`Extensions.disable2`, id, platform);
|
|
1367
|
+
};
|
|
1365
1368
|
|
|
1366
1369
|
const {
|
|
1367
1370
|
invoke: invoke$1,
|
|
@@ -1416,9 +1419,10 @@ const copyId$1 = async (state, index) => {
|
|
|
1416
1419
|
extensions
|
|
1417
1420
|
} = state;
|
|
1418
1421
|
const extension = extensions[index];
|
|
1419
|
-
if (extension) {
|
|
1420
|
-
|
|
1422
|
+
if (!extension) {
|
|
1423
|
+
return state;
|
|
1421
1424
|
}
|
|
1425
|
+
await writeText(extension.id);
|
|
1422
1426
|
return state;
|
|
1423
1427
|
};
|
|
1424
1428
|
|
|
@@ -1681,6 +1685,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1681
1685
|
assetDir,
|
|
1682
1686
|
extensions: [],
|
|
1683
1687
|
focusedIndex: -1,
|
|
1688
|
+
focusOutline: false,
|
|
1684
1689
|
height,
|
|
1685
1690
|
itemHeight: 72,
|
|
1686
1691
|
loaded: false,
|
|
@@ -1695,7 +1700,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1695
1700
|
};
|
|
1696
1701
|
|
|
1697
1702
|
const isDomEqual = (oldState, newState) => {
|
|
1698
|
-
return oldState.extensions === newState.extensions && oldState.focusedIndex === newState.focusedIndex && oldState.loaded === newState.loaded && oldState.selectedIndex === newState.selectedIndex;
|
|
1703
|
+
return oldState.extensions === newState.extensions && oldState.focusedIndex === newState.focusedIndex && oldState.focusOutline === newState.focusOutline && oldState.loaded === newState.loaded && oldState.selectedIndex === newState.selectedIndex;
|
|
1699
1704
|
};
|
|
1700
1705
|
const isCssEqual = (oldState, newState) => {
|
|
1701
1706
|
return oldState.width === newState.width && oldState.height === newState.height;
|
|
@@ -1715,7 +1720,7 @@ const disable$1 = async (state, index) => {
|
|
|
1715
1720
|
} = state;
|
|
1716
1721
|
const extension = extensions[index];
|
|
1717
1722
|
if (extension) {
|
|
1718
|
-
await
|
|
1723
|
+
await disable2(extension.id, platform);
|
|
1719
1724
|
}
|
|
1720
1725
|
return state;
|
|
1721
1726
|
};
|
|
@@ -1880,15 +1885,27 @@ const getMenuEntryIds = () => {
|
|
|
1880
1885
|
return [RunningExtensions$1];
|
|
1881
1886
|
};
|
|
1882
1887
|
|
|
1888
|
+
const handleBlur = state => {
|
|
1889
|
+
return {
|
|
1890
|
+
...state,
|
|
1891
|
+
focusOutline: false
|
|
1892
|
+
};
|
|
1893
|
+
};
|
|
1894
|
+
|
|
1895
|
+
const getIndex = (eventY, y, itemHeight) => {
|
|
1896
|
+
const index = Math.floor((eventY - y) / itemHeight);
|
|
1897
|
+
return index;
|
|
1898
|
+
};
|
|
1883
1899
|
const handleClickAt = (state, eventY) => {
|
|
1884
1900
|
const {
|
|
1885
1901
|
extensions,
|
|
1886
1902
|
itemHeight,
|
|
1887
1903
|
y
|
|
1888
1904
|
} = state;
|
|
1889
|
-
const index =
|
|
1905
|
+
const index = getIndex(eventY, y, itemHeight);
|
|
1890
1906
|
return {
|
|
1891
1907
|
...state,
|
|
1908
|
+
focusOutline: false,
|
|
1892
1909
|
selectedIndex: extensions[index] ? index : -1
|
|
1893
1910
|
};
|
|
1894
1911
|
};
|
|
@@ -1908,7 +1925,8 @@ const handleContextMenu = async (state, index, x = 0, y = 0) => {
|
|
|
1908
1925
|
}
|
|
1909
1926
|
const newState = {
|
|
1910
1927
|
...state,
|
|
1911
|
-
focusedIndex
|
|
1928
|
+
focusedIndex,
|
|
1929
|
+
focusOutline: true
|
|
1912
1930
|
};
|
|
1913
1931
|
set(uid, state, newState);
|
|
1914
1932
|
await show(uid, RunningExtensions$1, x, y, {
|
|
@@ -1944,6 +1962,7 @@ const renderCss = (oldState, newState) => {
|
|
|
1944
1962
|
uid,
|
|
1945
1963
|
width
|
|
1946
1964
|
} = newState;
|
|
1965
|
+
// TODO this is not needed
|
|
1947
1966
|
const css = getCss(width, height);
|
|
1948
1967
|
return [SetCss, uid, css];
|
|
1949
1968
|
};
|
|
@@ -1988,6 +2007,7 @@ const RunningExtensionVersion = 'RunningExtensionVersion';
|
|
|
1988
2007
|
|
|
1989
2008
|
const HandleContextMenu = 3;
|
|
1990
2009
|
const HandleClick = 4;
|
|
2010
|
+
const HandleBlur = 5;
|
|
1991
2011
|
|
|
1992
2012
|
const getIconVirtualDom = (extension, index) => {
|
|
1993
2013
|
if (extension.icon) {
|
|
@@ -2032,10 +2052,7 @@ const getRemoteAuthorityVirtualDom = (remoteAuthority, index) => {
|
|
|
2032
2052
|
type: Div
|
|
2033
2053
|
}, text(ssh(host))];
|
|
2034
2054
|
};
|
|
2035
|
-
const
|
|
2036
|
-
const displayName = extension.name || extension.id;
|
|
2037
|
-
const activationReasonDom = getActivationReasonVirtualDom(extension.activationEvent, index);
|
|
2038
|
-
const remoteAuthorityDom = getRemoteAuthorityVirtualDom(extension.remoteAuthority, index);
|
|
2055
|
+
const getClassName = (focused, selected) => {
|
|
2039
2056
|
let className = RunningExtension;
|
|
2040
2057
|
if (focused) {
|
|
2041
2058
|
className = mergeClassNames(className, FocusOutline);
|
|
@@ -2043,6 +2060,13 @@ const getExtensionVirtualDom = (extension, index, focused = false, selected = fa
|
|
|
2043
2060
|
if (selected) {
|
|
2044
2061
|
className = mergeClassNames(className, ExtensionActive);
|
|
2045
2062
|
}
|
|
2063
|
+
return className;
|
|
2064
|
+
};
|
|
2065
|
+
const getExtensionVirtualDom = (extension, index, focused = false, selected = false) => {
|
|
2066
|
+
const displayName = extension.name || extension.id;
|
|
2067
|
+
const activationReasonDom = getActivationReasonVirtualDom(extension.activationEvent, index);
|
|
2068
|
+
const remoteAuthorityDom = getRemoteAuthorityVirtualDom(extension.remoteAuthority, index);
|
|
2069
|
+
const className = getClassName(focused, selected);
|
|
2046
2070
|
return [{
|
|
2047
2071
|
childCount: 3,
|
|
2048
2072
|
className,
|
|
@@ -2087,40 +2111,50 @@ const getExtensionVirtualDom = (extension, index, focused = false, selected = fa
|
|
|
2087
2111
|
}, text(activationTime(Math.round(extension.activationTime))), ...activationReasonDom];
|
|
2088
2112
|
};
|
|
2089
2113
|
|
|
2114
|
+
const Focusable = 0;
|
|
2115
|
+
|
|
2090
2116
|
const emptyNode = {
|
|
2091
2117
|
childCount: 1,
|
|
2092
2118
|
className: RunningExtensionsEmpty,
|
|
2093
2119
|
type: Div
|
|
2094
2120
|
};
|
|
2095
|
-
const
|
|
2121
|
+
const getMessage = loaded => {
|
|
2096
2122
|
const message = loaded ? noRunningExtensions() : loadingRunningExtensions();
|
|
2123
|
+
return message;
|
|
2124
|
+
};
|
|
2125
|
+
const getRunningExtensionsEmptyDom = loaded => {
|
|
2126
|
+
const message = getMessage(loaded);
|
|
2097
2127
|
return [{
|
|
2098
2128
|
childCount: 1,
|
|
2099
2129
|
className: mergeClassNames(RunningExtensions, Grow),
|
|
2130
|
+
onBlur: HandleBlur,
|
|
2100
2131
|
onClick: HandleClick,
|
|
2101
2132
|
onContextMenu: HandleContextMenu,
|
|
2102
2133
|
role: List,
|
|
2134
|
+
tabIndex: Focusable,
|
|
2103
2135
|
type: Div
|
|
2104
2136
|
}, emptyNode, text(message)];
|
|
2105
2137
|
};
|
|
2106
2138
|
|
|
2107
|
-
const getRunningExtensionsVirtualDom = (extensions, loaded, focusedIndex = -1, selectedIndex = -1) => {
|
|
2139
|
+
const getRunningExtensionsVirtualDom = (extensions, loaded, focusedIndex = -1, selectedIndex = -1, focusOutline = false) => {
|
|
2108
2140
|
if (extensions.length === 0) {
|
|
2109
2141
|
return getRunningExtensionsEmptyDom(loaded);
|
|
2110
2142
|
}
|
|
2111
|
-
const children = extensions.flatMap((extension, index) => getExtensionVirtualDom(extension, index, index === focusedIndex, index === selectedIndex));
|
|
2112
2143
|
return [{
|
|
2113
2144
|
childCount: extensions.length,
|
|
2114
2145
|
className: mergeClassNames(RunningExtensions, Grow),
|
|
2146
|
+
onBlur: HandleBlur,
|
|
2115
2147
|
onClick: HandleClick,
|
|
2116
2148
|
onContextMenu: HandleContextMenu,
|
|
2117
2149
|
role: List,
|
|
2150
|
+
tabIndex: Focusable,
|
|
2118
2151
|
type: Div
|
|
2119
|
-
}, ...
|
|
2152
|
+
}, ...extensions.flatMap((extension, index) => getExtensionVirtualDom(extension, index, focusOutline && index === focusedIndex, index === selectedIndex))];
|
|
2120
2153
|
};
|
|
2121
2154
|
|
|
2122
2155
|
const renderDom = (oldState, newState) => {
|
|
2123
|
-
|
|
2156
|
+
// TODO incremental rendering
|
|
2157
|
+
return [SetDom2, newState.uid, getRunningExtensionsVirtualDom(newState.extensions, newState.loaded, newState.focusedIndex, newState.selectedIndex, newState.focusOutline)];
|
|
2124
2158
|
};
|
|
2125
2159
|
|
|
2126
2160
|
const getRenderer = diffType => {
|
|
@@ -2151,12 +2185,15 @@ const renderEventListeners = () => {
|
|
|
2151
2185
|
name: HandleClick,
|
|
2152
2186
|
params: ['handleClickAt', ClientY],
|
|
2153
2187
|
preventDefault: true
|
|
2188
|
+
}, {
|
|
2189
|
+
name: HandleBlur,
|
|
2190
|
+
params: ['handleBlur']
|
|
2154
2191
|
}];
|
|
2155
2192
|
};
|
|
2156
2193
|
|
|
2157
2194
|
const gitSuffixRegex = /\.git$/;
|
|
2158
2195
|
const getIssuesUrl = repository => {
|
|
2159
|
-
if (typeof repository !== 'string') {
|
|
2196
|
+
if (typeof repository !== 'string' || !URL.canParse(repository)) {
|
|
2160
2197
|
return '';
|
|
2161
2198
|
}
|
|
2162
2199
|
let url;
|
|
@@ -2216,13 +2253,16 @@ const startProfile = async state => {
|
|
|
2216
2253
|
return state;
|
|
2217
2254
|
};
|
|
2218
2255
|
|
|
2256
|
+
const canTakeHeapSnapshot = (platform, extension) => {
|
|
2257
|
+
return !(!extension || platform !== Electron || !extension.isolated);
|
|
2258
|
+
};
|
|
2219
2259
|
const takeHeapSnapshot = async (state, index) => {
|
|
2220
2260
|
const {
|
|
2221
2261
|
extensions,
|
|
2222
2262
|
platform
|
|
2223
2263
|
} = state;
|
|
2224
2264
|
const extension = extensions[index];
|
|
2225
|
-
if (!
|
|
2265
|
+
if (!canTakeHeapSnapshot(platform, extension)) {
|
|
2226
2266
|
return state;
|
|
2227
2267
|
}
|
|
2228
2268
|
const windowId = await getWindowId();
|
|
@@ -2248,6 +2288,7 @@ const commandMap = {
|
|
|
2248
2288
|
'RunningExtensions.getCommandIds': getCommandIds,
|
|
2249
2289
|
'RunningExtensions.getMenuEntries': wrapGetter(getMenuEntries),
|
|
2250
2290
|
'RunningExtensions.getMenuEntryIds': getMenuEntryIds,
|
|
2291
|
+
'RunningExtensions.handleBlur': wrapCommand(handleBlur),
|
|
2251
2292
|
'RunningExtensions.handleClickAt': wrapCommand(handleClickAt),
|
|
2252
2293
|
'RunningExtensions.handleContextMenu': wrapCommand(handleContextMenu),
|
|
2253
2294
|
'RunningExtensions.loadContent': wrapCommand(loadContent),
|