@lvce-editor/running-extensions-view 1.11.0 → 1.13.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/runningExtensionsViewMain.js +358 -34
- package/package.json +1 -1
|
@@ -1349,6 +1349,7 @@ const SharedProcess = 1492;
|
|
|
1349
1349
|
|
|
1350
1350
|
const SetCss = 'Viewlet.setCss';
|
|
1351
1351
|
const SetDom2 = 'Viewlet.setDom2';
|
|
1352
|
+
const SetPatches = 'Viewlet.setPatches';
|
|
1352
1353
|
|
|
1353
1354
|
const {
|
|
1354
1355
|
invoke: invoke$3,
|
|
@@ -1362,6 +1363,9 @@ const {
|
|
|
1362
1363
|
invoke: invoke$2,
|
|
1363
1364
|
set: set$4
|
|
1364
1365
|
} = create$2(ExtensionManagementWorker);
|
|
1366
|
+
const disable2 = (id, platform) => {
|
|
1367
|
+
return invoke$2(`Extensions.disable2`, id, platform);
|
|
1368
|
+
};
|
|
1365
1369
|
|
|
1366
1370
|
const {
|
|
1367
1371
|
invoke: invoke$1,
|
|
@@ -1416,9 +1420,10 @@ const copyId$1 = async (state, index) => {
|
|
|
1416
1420
|
extensions
|
|
1417
1421
|
} = state;
|
|
1418
1422
|
const extension = extensions[index];
|
|
1419
|
-
if (extension) {
|
|
1420
|
-
|
|
1423
|
+
if (!extension) {
|
|
1424
|
+
return state;
|
|
1421
1425
|
}
|
|
1426
|
+
await writeText(extension.id);
|
|
1422
1427
|
return state;
|
|
1423
1428
|
};
|
|
1424
1429
|
|
|
@@ -1681,6 +1686,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1681
1686
|
assetDir,
|
|
1682
1687
|
extensions: [],
|
|
1683
1688
|
focusedIndex: -1,
|
|
1689
|
+
focusOutline: false,
|
|
1684
1690
|
height,
|
|
1685
1691
|
itemHeight: 72,
|
|
1686
1692
|
loaded: false,
|
|
@@ -1695,7 +1701,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
|
1695
1701
|
};
|
|
1696
1702
|
|
|
1697
1703
|
const isDomEqual = (oldState, newState) => {
|
|
1698
|
-
return oldState.extensions === newState.extensions && oldState.focusedIndex === newState.focusedIndex && oldState.loaded === newState.loaded && oldState.selectedIndex === newState.selectedIndex;
|
|
1704
|
+
return oldState.extensions === newState.extensions && oldState.focusedIndex === newState.focusedIndex && oldState.focusOutline === newState.focusOutline && oldState.loaded === newState.loaded && oldState.selectedIndex === newState.selectedIndex;
|
|
1699
1705
|
};
|
|
1700
1706
|
const isCssEqual = (oldState, newState) => {
|
|
1701
1707
|
return oldState.width === newState.width && oldState.height === newState.height;
|
|
@@ -1703,9 +1709,14 @@ const isCssEqual = (oldState, newState) => {
|
|
|
1703
1709
|
|
|
1704
1710
|
const RenderDom = 1;
|
|
1705
1711
|
const RenderCss = 2;
|
|
1712
|
+
const RenderIncremental = 3;
|
|
1706
1713
|
|
|
1707
1714
|
const diff2 = uid => {
|
|
1708
|
-
|
|
1715
|
+
const {
|
|
1716
|
+
oldState
|
|
1717
|
+
} = get(uid);
|
|
1718
|
+
const domDiffType = oldState.loaded ? RenderIncremental : RenderDom;
|
|
1719
|
+
return diff(uid, [isDomEqual, isCssEqual], [domDiffType, RenderCss]);
|
|
1709
1720
|
};
|
|
1710
1721
|
|
|
1711
1722
|
const disable$1 = async (state, index) => {
|
|
@@ -1715,7 +1726,7 @@ const disable$1 = async (state, index) => {
|
|
|
1715
1726
|
} = state;
|
|
1716
1727
|
const extension = extensions[index];
|
|
1717
1728
|
if (extension) {
|
|
1718
|
-
await
|
|
1729
|
+
await disable2(extension.id, platform);
|
|
1719
1730
|
}
|
|
1720
1731
|
return state;
|
|
1721
1732
|
};
|
|
@@ -1880,16 +1891,22 @@ const getMenuEntryIds = () => {
|
|
|
1880
1891
|
return [RunningExtensions$1];
|
|
1881
1892
|
};
|
|
1882
1893
|
|
|
1883
|
-
const
|
|
1894
|
+
const handleBlur = state => {
|
|
1895
|
+
return {
|
|
1896
|
+
...state,
|
|
1897
|
+
focusOutline: false
|
|
1898
|
+
};
|
|
1899
|
+
};
|
|
1900
|
+
|
|
1901
|
+
const handleClickAt = (state, index) => {
|
|
1884
1902
|
const {
|
|
1885
|
-
extensions
|
|
1886
|
-
itemHeight,
|
|
1887
|
-
y
|
|
1903
|
+
extensions
|
|
1888
1904
|
} = state;
|
|
1889
|
-
const
|
|
1905
|
+
const selectedIndex = Number(index);
|
|
1890
1906
|
return {
|
|
1891
1907
|
...state,
|
|
1892
|
-
|
|
1908
|
+
focusOutline: false,
|
|
1909
|
+
selectedIndex: extensions[selectedIndex] ? selectedIndex : -1
|
|
1893
1910
|
};
|
|
1894
1911
|
};
|
|
1895
1912
|
|
|
@@ -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
|
};
|
|
@@ -1962,6 +1981,264 @@ const text = data => {
|
|
|
1962
1981
|
|
|
1963
1982
|
new Set(Object.values(VirtualDomElements));
|
|
1964
1983
|
|
|
1984
|
+
const SetText = 1;
|
|
1985
|
+
const Replace = 2;
|
|
1986
|
+
const SetAttribute = 3;
|
|
1987
|
+
const RemoveAttribute = 4;
|
|
1988
|
+
const Add = 6;
|
|
1989
|
+
const NavigateChild = 7;
|
|
1990
|
+
const NavigateParent = 8;
|
|
1991
|
+
const RemoveChild = 9;
|
|
1992
|
+
const NavigateSibling = 10;
|
|
1993
|
+
const SetReferenceNodeUid = 11;
|
|
1994
|
+
|
|
1995
|
+
const isKey = key => {
|
|
1996
|
+
return key !== 'type' && key !== 'childCount';
|
|
1997
|
+
};
|
|
1998
|
+
|
|
1999
|
+
const getKeys = node => {
|
|
2000
|
+
const keys = Object.keys(node).filter(isKey);
|
|
2001
|
+
return keys;
|
|
2002
|
+
};
|
|
2003
|
+
|
|
2004
|
+
const arrayToTree = nodes => {
|
|
2005
|
+
const result = [];
|
|
2006
|
+
let i = 0;
|
|
2007
|
+
while (i < nodes.length) {
|
|
2008
|
+
const node = nodes[i];
|
|
2009
|
+
const {
|
|
2010
|
+
children,
|
|
2011
|
+
nodesConsumed
|
|
2012
|
+
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
2013
|
+
result.push({
|
|
2014
|
+
node,
|
|
2015
|
+
children
|
|
2016
|
+
});
|
|
2017
|
+
i += 1 + nodesConsumed;
|
|
2018
|
+
}
|
|
2019
|
+
return result;
|
|
2020
|
+
};
|
|
2021
|
+
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
2022
|
+
if (childCount === 0) {
|
|
2023
|
+
return {
|
|
2024
|
+
children: [],
|
|
2025
|
+
nodesConsumed: 0
|
|
2026
|
+
};
|
|
2027
|
+
}
|
|
2028
|
+
const children = [];
|
|
2029
|
+
let i = startIndex;
|
|
2030
|
+
let remaining = childCount;
|
|
2031
|
+
let totalConsumed = 0;
|
|
2032
|
+
while (remaining > 0 && i < nodes.length) {
|
|
2033
|
+
const node = nodes[i];
|
|
2034
|
+
const nodeChildCount = node.childCount || 0;
|
|
2035
|
+
const {
|
|
2036
|
+
children: nodeChildren,
|
|
2037
|
+
nodesConsumed
|
|
2038
|
+
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
2039
|
+
children.push({
|
|
2040
|
+
node,
|
|
2041
|
+
children: nodeChildren
|
|
2042
|
+
});
|
|
2043
|
+
const nodeSize = 1 + nodesConsumed;
|
|
2044
|
+
i += nodeSize;
|
|
2045
|
+
totalConsumed += nodeSize;
|
|
2046
|
+
remaining--;
|
|
2047
|
+
}
|
|
2048
|
+
return {
|
|
2049
|
+
children,
|
|
2050
|
+
nodesConsumed: totalConsumed
|
|
2051
|
+
};
|
|
2052
|
+
};
|
|
2053
|
+
|
|
2054
|
+
const compareNodes = (oldNode, newNode) => {
|
|
2055
|
+
// Check if node type changed - return null to signal incompatible nodes
|
|
2056
|
+
// (caller should handle this with a Replace operation)
|
|
2057
|
+
if (oldNode.type !== newNode.type) {
|
|
2058
|
+
return null;
|
|
2059
|
+
}
|
|
2060
|
+
const patches = [];
|
|
2061
|
+
// Handle reference nodes - special handling for uid changes
|
|
2062
|
+
if (oldNode.type === Reference) {
|
|
2063
|
+
if (oldNode.uid !== newNode.uid) {
|
|
2064
|
+
patches.push({
|
|
2065
|
+
type: SetReferenceNodeUid,
|
|
2066
|
+
uid: newNode.uid
|
|
2067
|
+
});
|
|
2068
|
+
}
|
|
2069
|
+
return patches;
|
|
2070
|
+
}
|
|
2071
|
+
// Handle text nodes
|
|
2072
|
+
if (oldNode.type === Text && newNode.type === Text) {
|
|
2073
|
+
if (oldNode.text !== newNode.text) {
|
|
2074
|
+
patches.push({
|
|
2075
|
+
type: SetText,
|
|
2076
|
+
value: newNode.text
|
|
2077
|
+
});
|
|
2078
|
+
}
|
|
2079
|
+
return patches;
|
|
2080
|
+
}
|
|
2081
|
+
// Compare attributes
|
|
2082
|
+
const oldKeys = getKeys(oldNode);
|
|
2083
|
+
const newKeys = getKeys(newNode);
|
|
2084
|
+
// Check for attribute changes
|
|
2085
|
+
for (const key of newKeys) {
|
|
2086
|
+
if (oldNode[key] !== newNode[key]) {
|
|
2087
|
+
patches.push({
|
|
2088
|
+
type: SetAttribute,
|
|
2089
|
+
key,
|
|
2090
|
+
value: newNode[key]
|
|
2091
|
+
});
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2094
|
+
// Check for removed attributes
|
|
2095
|
+
for (const key of oldKeys) {
|
|
2096
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
2097
|
+
patches.push({
|
|
2098
|
+
type: RemoveAttribute,
|
|
2099
|
+
key
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
}
|
|
2103
|
+
return patches;
|
|
2104
|
+
};
|
|
2105
|
+
|
|
2106
|
+
const treeToArray = node => {
|
|
2107
|
+
const result = [node.node];
|
|
2108
|
+
for (const child of node.children) {
|
|
2109
|
+
result.push(...treeToArray(child));
|
|
2110
|
+
}
|
|
2111
|
+
return result;
|
|
2112
|
+
};
|
|
2113
|
+
|
|
2114
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
2115
|
+
if (currentChildIndex === -1) {
|
|
2116
|
+
patches.push({
|
|
2117
|
+
type: NavigateChild,
|
|
2118
|
+
index
|
|
2119
|
+
});
|
|
2120
|
+
return index;
|
|
2121
|
+
}
|
|
2122
|
+
if (currentChildIndex !== index) {
|
|
2123
|
+
patches.push({
|
|
2124
|
+
type: NavigateSibling,
|
|
2125
|
+
index
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
return index;
|
|
2129
|
+
};
|
|
2130
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
2131
|
+
if (currentChildIndex >= 0) {
|
|
2132
|
+
patches.push({
|
|
2133
|
+
type: NavigateParent
|
|
2134
|
+
});
|
|
2135
|
+
}
|
|
2136
|
+
return -1;
|
|
2137
|
+
};
|
|
2138
|
+
const addTree = (newNode, patches) => {
|
|
2139
|
+
patches.push({
|
|
2140
|
+
type: Add,
|
|
2141
|
+
nodes: treeToArray(newNode)
|
|
2142
|
+
});
|
|
2143
|
+
};
|
|
2144
|
+
const replaceTree = (newNode, patches) => {
|
|
2145
|
+
patches.push({
|
|
2146
|
+
type: Replace,
|
|
2147
|
+
nodes: treeToArray(newNode)
|
|
2148
|
+
});
|
|
2149
|
+
};
|
|
2150
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
2151
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2152
|
+
if (nodePatches === null) {
|
|
2153
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
2154
|
+
replaceTree(newNode, patches);
|
|
2155
|
+
return nextChildIndex;
|
|
2156
|
+
}
|
|
2157
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
2158
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
2159
|
+
return currentChildIndex;
|
|
2160
|
+
}
|
|
2161
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
2162
|
+
if (nodePatches.length > 0) {
|
|
2163
|
+
patches.push(...nodePatches);
|
|
2164
|
+
}
|
|
2165
|
+
if (hasChildrenToCompare) {
|
|
2166
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2167
|
+
}
|
|
2168
|
+
return nextChildIndex;
|
|
2169
|
+
};
|
|
2170
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
2171
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
2172
|
+
if (nodePatches === null) {
|
|
2173
|
+
replaceTree(newNode, patches);
|
|
2174
|
+
return;
|
|
2175
|
+
}
|
|
2176
|
+
if (nodePatches.length > 0) {
|
|
2177
|
+
patches.push(...nodePatches);
|
|
2178
|
+
}
|
|
2179
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
2180
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
2181
|
+
}
|
|
2182
|
+
};
|
|
2183
|
+
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
2184
|
+
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
2185
|
+
let currentChildIndex = -1;
|
|
2186
|
+
const indicesToRemove = [];
|
|
2187
|
+
for (let i = 0; i < maxLength; i++) {
|
|
2188
|
+
const oldNode = oldChildren[i];
|
|
2189
|
+
const newNode = newChildren[i];
|
|
2190
|
+
if (!oldNode && !newNode) {
|
|
2191
|
+
continue;
|
|
2192
|
+
}
|
|
2193
|
+
if (!oldNode) {
|
|
2194
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
2195
|
+
addTree(newNode, patches);
|
|
2196
|
+
continue;
|
|
2197
|
+
}
|
|
2198
|
+
if (!newNode) {
|
|
2199
|
+
indicesToRemove.push(i);
|
|
2200
|
+
continue;
|
|
2201
|
+
}
|
|
2202
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
2203
|
+
}
|
|
2204
|
+
navigateToParent(patches, currentChildIndex);
|
|
2205
|
+
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
2206
|
+
patches.push({
|
|
2207
|
+
type: RemoveChild,
|
|
2208
|
+
index: indicesToRemove[j]
|
|
2209
|
+
});
|
|
2210
|
+
}
|
|
2211
|
+
};
|
|
2212
|
+
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
2213
|
+
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
2214
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
2217
|
+
diffChildren(oldTree, newTree, patches);
|
|
2218
|
+
};
|
|
2219
|
+
|
|
2220
|
+
const removeTrailingNavigationPatches = patches => {
|
|
2221
|
+
while (patches.length > 0) {
|
|
2222
|
+
const patch = patches.at(-1);
|
|
2223
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
2224
|
+
break;
|
|
2225
|
+
}
|
|
2226
|
+
patches.pop();
|
|
2227
|
+
}
|
|
2228
|
+
return patches;
|
|
2229
|
+
};
|
|
2230
|
+
|
|
2231
|
+
const diffTree = (oldNodes, newNodes) => {
|
|
2232
|
+
// Step 1: Convert flat arrays to tree structures
|
|
2233
|
+
const oldTree = arrayToTree(oldNodes);
|
|
2234
|
+
const newTree = arrayToTree(newNodes);
|
|
2235
|
+
// Step 3: Compare the trees
|
|
2236
|
+
const patches = [];
|
|
2237
|
+
diffTrees(oldTree, newTree, patches, []);
|
|
2238
|
+
// Remove trailing navigation patches since they serve no purpose
|
|
2239
|
+
return removeTrailingNavigationPatches(patches);
|
|
2240
|
+
};
|
|
2241
|
+
|
|
1965
2242
|
const List = 'list';
|
|
1966
2243
|
const ListItem = 'listitem';
|
|
1967
2244
|
const None = 'none';
|
|
@@ -1988,6 +2265,7 @@ const RunningExtensionVersion = 'RunningExtensionVersion';
|
|
|
1988
2265
|
|
|
1989
2266
|
const HandleContextMenu = 3;
|
|
1990
2267
|
const HandleClick = 4;
|
|
2268
|
+
const HandleBlur = 5;
|
|
1991
2269
|
|
|
1992
2270
|
const getIconVirtualDom = (extension, index) => {
|
|
1993
2271
|
if (extension.icon) {
|
|
@@ -2032,10 +2310,7 @@ const getRemoteAuthorityVirtualDom = (remoteAuthority, index) => {
|
|
|
2032
2310
|
type: Div
|
|
2033
2311
|
}, text(ssh(host))];
|
|
2034
2312
|
};
|
|
2035
|
-
const
|
|
2036
|
-
const displayName = extension.name || extension.id;
|
|
2037
|
-
const activationReasonDom = getActivationReasonVirtualDom(extension.activationEvent, index);
|
|
2038
|
-
const remoteAuthorityDom = getRemoteAuthorityVirtualDom(extension.remoteAuthority, index);
|
|
2313
|
+
const getClassName = (focused, selected) => {
|
|
2039
2314
|
let className = RunningExtension;
|
|
2040
2315
|
if (focused) {
|
|
2041
2316
|
className = mergeClassNames(className, FocusOutline);
|
|
@@ -2043,6 +2318,13 @@ const getExtensionVirtualDom = (extension, index, focused = false, selected = fa
|
|
|
2043
2318
|
if (selected) {
|
|
2044
2319
|
className = mergeClassNames(className, ExtensionActive);
|
|
2045
2320
|
}
|
|
2321
|
+
return className;
|
|
2322
|
+
};
|
|
2323
|
+
const getExtensionVirtualDom = (extension, index, focused = false, selected = false) => {
|
|
2324
|
+
const displayName = extension.name || extension.id;
|
|
2325
|
+
const activationReasonDom = getActivationReasonVirtualDom(extension.activationEvent, index);
|
|
2326
|
+
const remoteAuthorityDom = getRemoteAuthorityVirtualDom(extension.remoteAuthority, index);
|
|
2327
|
+
const className = getClassName(focused, selected);
|
|
2046
2328
|
return [{
|
|
2047
2329
|
childCount: 3,
|
|
2048
2330
|
className,
|
|
@@ -2087,40 +2369,56 @@ const getExtensionVirtualDom = (extension, index, focused = false, selected = fa
|
|
|
2087
2369
|
}, text(activationTime(Math.round(extension.activationTime))), ...activationReasonDom];
|
|
2088
2370
|
};
|
|
2089
2371
|
|
|
2372
|
+
const Focusable = 0;
|
|
2373
|
+
|
|
2090
2374
|
const emptyNode = {
|
|
2091
2375
|
childCount: 1,
|
|
2092
2376
|
className: RunningExtensionsEmpty,
|
|
2093
2377
|
type: Div
|
|
2094
2378
|
};
|
|
2095
|
-
const
|
|
2379
|
+
const getMessage = loaded => {
|
|
2096
2380
|
const message = loaded ? noRunningExtensions() : loadingRunningExtensions();
|
|
2381
|
+
return message;
|
|
2382
|
+
};
|
|
2383
|
+
const getRunningExtensionsEmptyDom = loaded => {
|
|
2384
|
+
const message = getMessage(loaded);
|
|
2097
2385
|
return [{
|
|
2098
2386
|
childCount: 1,
|
|
2099
2387
|
className: mergeClassNames(RunningExtensions, Grow),
|
|
2388
|
+
onBlur: HandleBlur,
|
|
2100
2389
|
onClick: HandleClick,
|
|
2101
2390
|
onContextMenu: HandleContextMenu,
|
|
2102
2391
|
role: List,
|
|
2392
|
+
tabIndex: Focusable,
|
|
2103
2393
|
type: Div
|
|
2104
2394
|
}, emptyNode, text(message)];
|
|
2105
2395
|
};
|
|
2106
2396
|
|
|
2107
|
-
const getRunningExtensionsVirtualDom = (extensions, loaded, focusedIndex = -1, selectedIndex = -1) => {
|
|
2397
|
+
const getRunningExtensionsVirtualDom = (extensions, loaded, focusedIndex = -1, selectedIndex = -1, focusOutline = false) => {
|
|
2108
2398
|
if (extensions.length === 0) {
|
|
2109
2399
|
return getRunningExtensionsEmptyDom(loaded);
|
|
2110
2400
|
}
|
|
2111
|
-
const children = extensions.flatMap((extension, index) => getExtensionVirtualDom(extension, index, index === focusedIndex, index === selectedIndex));
|
|
2112
2401
|
return [{
|
|
2113
2402
|
childCount: extensions.length,
|
|
2114
2403
|
className: mergeClassNames(RunningExtensions, Grow),
|
|
2404
|
+
onBlur: HandleBlur,
|
|
2115
2405
|
onClick: HandleClick,
|
|
2116
2406
|
onContextMenu: HandleContextMenu,
|
|
2117
2407
|
role: List,
|
|
2408
|
+
tabIndex: Focusable,
|
|
2118
2409
|
type: Div
|
|
2119
|
-
}, ...
|
|
2410
|
+
}, ...extensions.flatMap((extension, index) => getExtensionVirtualDom(extension, index, focusOutline && index === focusedIndex, index === selectedIndex))];
|
|
2120
2411
|
};
|
|
2121
2412
|
|
|
2122
2413
|
const renderDom = (oldState, newState) => {
|
|
2123
|
-
return [SetDom2, newState.uid, getRunningExtensionsVirtualDom(newState.extensions, newState.loaded, newState.focusedIndex, newState.selectedIndex)];
|
|
2414
|
+
return [SetDom2, newState.uid, getRunningExtensionsVirtualDom(newState.extensions, newState.loaded, newState.focusedIndex, newState.selectedIndex, newState.focusOutline)];
|
|
2415
|
+
};
|
|
2416
|
+
|
|
2417
|
+
const renderIncremental = (oldState, newState) => {
|
|
2418
|
+
const oldDom = getRunningExtensionsVirtualDom(oldState.extensions, oldState.loaded, oldState.focusedIndex, oldState.selectedIndex, oldState.focusOutline);
|
|
2419
|
+
const newDom = getRunningExtensionsVirtualDom(newState.extensions, newState.loaded, newState.focusedIndex, newState.selectedIndex, newState.focusOutline);
|
|
2420
|
+
const patches = diffTree(oldDom, newDom);
|
|
2421
|
+
return [SetPatches, newState.uid, patches];
|
|
2124
2422
|
};
|
|
2125
2423
|
|
|
2126
2424
|
const getRenderer = diffType => {
|
|
@@ -2129,6 +2427,8 @@ const getRenderer = diffType => {
|
|
|
2129
2427
|
return renderCss;
|
|
2130
2428
|
case RenderDom:
|
|
2131
2429
|
return renderDom;
|
|
2430
|
+
case RenderIncremental:
|
|
2431
|
+
return renderIncremental;
|
|
2132
2432
|
default:
|
|
2133
2433
|
throw new Error(`Unknown diff type ${diffType}`);
|
|
2134
2434
|
}
|
|
@@ -2149,14 +2449,17 @@ const renderEventListeners = () => {
|
|
|
2149
2449
|
preventDefault: true
|
|
2150
2450
|
}, {
|
|
2151
2451
|
name: HandleClick,
|
|
2152
|
-
params: ['handleClickAt',
|
|
2452
|
+
params: ['handleClickAt', 'event.target.dataset.index'],
|
|
2153
2453
|
preventDefault: true
|
|
2454
|
+
}, {
|
|
2455
|
+
name: HandleBlur,
|
|
2456
|
+
params: ['handleBlur']
|
|
2154
2457
|
}];
|
|
2155
2458
|
};
|
|
2156
2459
|
|
|
2157
2460
|
const gitSuffixRegex = /\.git$/;
|
|
2158
2461
|
const getIssuesUrl = repository => {
|
|
2159
|
-
if (typeof repository !== 'string') {
|
|
2462
|
+
if (typeof repository !== 'string' || !URL.canParse(repository)) {
|
|
2160
2463
|
return '';
|
|
2161
2464
|
}
|
|
2162
2465
|
let url;
|
|
@@ -2179,6 +2482,23 @@ const getIssuesUrl = repository => {
|
|
|
2179
2482
|
return `https://github.com/${owner}/${repositoryName}/issues`;
|
|
2180
2483
|
};
|
|
2181
2484
|
|
|
2485
|
+
const OpenCommand = {
|
|
2486
|
+
External: 1,
|
|
2487
|
+
Url: 2
|
|
2488
|
+
};
|
|
2489
|
+
const getOpenCommand = platform => {
|
|
2490
|
+
if (platform === Electron) {
|
|
2491
|
+
return OpenCommand.External;
|
|
2492
|
+
}
|
|
2493
|
+
return OpenCommand.Url;
|
|
2494
|
+
};
|
|
2495
|
+
const applyOpenCommand = async (cmd, issuesUrl) => {
|
|
2496
|
+
if (cmd === OpenCommand.External) {
|
|
2497
|
+
await openExternal(issuesUrl);
|
|
2498
|
+
} else {
|
|
2499
|
+
await openUrl(issuesUrl);
|
|
2500
|
+
}
|
|
2501
|
+
};
|
|
2182
2502
|
const reportIssue = async (state, index) => {
|
|
2183
2503
|
const {
|
|
2184
2504
|
extensions,
|
|
@@ -2189,11 +2509,8 @@ const reportIssue = async (state, index) => {
|
|
|
2189
2509
|
await confirm(reportingIssuesNotSupported());
|
|
2190
2510
|
return state;
|
|
2191
2511
|
}
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
} else {
|
|
2195
|
-
await openUrl(issuesUrl);
|
|
2196
|
-
}
|
|
2512
|
+
const cmd = getOpenCommand(platform);
|
|
2513
|
+
await applyOpenCommand(cmd, issuesUrl);
|
|
2197
2514
|
return state;
|
|
2198
2515
|
};
|
|
2199
2516
|
|
|
@@ -2216,13 +2533,16 @@ const startProfile = async state => {
|
|
|
2216
2533
|
return state;
|
|
2217
2534
|
};
|
|
2218
2535
|
|
|
2536
|
+
const canTakeHeapSnapshot = (platform, extension) => {
|
|
2537
|
+
return !(!extension || platform !== Electron || !extension.isolated);
|
|
2538
|
+
};
|
|
2219
2539
|
const takeHeapSnapshot = async (state, index) => {
|
|
2220
2540
|
const {
|
|
2221
2541
|
extensions,
|
|
2222
2542
|
platform
|
|
2223
2543
|
} = state;
|
|
2224
2544
|
const extension = extensions[index];
|
|
2225
|
-
if (!
|
|
2545
|
+
if (!canTakeHeapSnapshot(platform, extension)) {
|
|
2226
2546
|
return state;
|
|
2227
2547
|
}
|
|
2228
2548
|
const windowId = await getWindowId();
|
|
@@ -2248,6 +2568,7 @@ const commandMap = {
|
|
|
2248
2568
|
'RunningExtensions.getCommandIds': getCommandIds,
|
|
2249
2569
|
'RunningExtensions.getMenuEntries': wrapGetter(getMenuEntries),
|
|
2250
2570
|
'RunningExtensions.getMenuEntryIds': getMenuEntryIds,
|
|
2571
|
+
'RunningExtensions.handleBlur': wrapCommand(handleBlur),
|
|
2251
2572
|
'RunningExtensions.handleClickAt': wrapCommand(handleClickAt),
|
|
2252
2573
|
'RunningExtensions.handleContextMenu': wrapCommand(handleContextMenu),
|
|
2253
2574
|
'RunningExtensions.loadContent': wrapCommand(loadContent),
|
|
@@ -2293,6 +2614,13 @@ const initializeMainProcess = async () => {
|
|
|
2293
2614
|
set$3(rpc);
|
|
2294
2615
|
};
|
|
2295
2616
|
|
|
2617
|
+
const initializeRendererWorker = async () => {
|
|
2618
|
+
const rpc = await create$3({
|
|
2619
|
+
commandMap: commandMap
|
|
2620
|
+
});
|
|
2621
|
+
set$2(rpc);
|
|
2622
|
+
};
|
|
2623
|
+
|
|
2296
2624
|
const send = async port => {
|
|
2297
2625
|
await sendMessagePortToSharedProcess(port);
|
|
2298
2626
|
};
|
|
@@ -2306,11 +2634,7 @@ const initializeSharedProcess = async () => {
|
|
|
2306
2634
|
|
|
2307
2635
|
const listen = async () => {
|
|
2308
2636
|
registerCommands(commandMap);
|
|
2309
|
-
|
|
2310
|
-
commandMap: commandMap
|
|
2311
|
-
});
|
|
2312
|
-
set$2(rpc);
|
|
2313
|
-
await Promise.all([initializeClipBoardWorker(), initializeExtensionManagementWorker(), initializeMainProcess(), initializeSharedProcess()]);
|
|
2637
|
+
await Promise.all([initializeRendererWorker(), initializeClipBoardWorker(), initializeExtensionManagementWorker(), initializeMainProcess(), initializeSharedProcess()]);
|
|
2314
2638
|
};
|
|
2315
2639
|
|
|
2316
2640
|
const main = async () => {
|