@lvce-editor/status-bar-worker 2.4.0 → 2.6.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/statusBarWorkerMain.js +366 -341
- package/package.json +1 -1
|
@@ -1,3 +1,188 @@
|
|
|
1
|
+
const toCommandId = key => {
|
|
2
|
+
const dotIndex = key.indexOf('.');
|
|
3
|
+
return key.slice(dotIndex + 1);
|
|
4
|
+
};
|
|
5
|
+
const create$a = () => {
|
|
6
|
+
const states = Object.create(null);
|
|
7
|
+
const commandMapRef = {};
|
|
8
|
+
return {
|
|
9
|
+
clear() {
|
|
10
|
+
for (const key of Object.keys(states)) {
|
|
11
|
+
delete states[key];
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
diff(uid, modules, numbers) {
|
|
15
|
+
const {
|
|
16
|
+
newState,
|
|
17
|
+
oldState
|
|
18
|
+
} = states[uid];
|
|
19
|
+
const diffResult = [];
|
|
20
|
+
for (let i = 0; i < modules.length; i++) {
|
|
21
|
+
const fn = modules[i];
|
|
22
|
+
if (!fn(oldState, newState)) {
|
|
23
|
+
diffResult.push(numbers[i]);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return diffResult;
|
|
27
|
+
},
|
|
28
|
+
dispose(uid) {
|
|
29
|
+
delete states[uid];
|
|
30
|
+
},
|
|
31
|
+
get(uid) {
|
|
32
|
+
return states[uid];
|
|
33
|
+
},
|
|
34
|
+
getCommandIds() {
|
|
35
|
+
const keys = Object.keys(commandMapRef);
|
|
36
|
+
const ids = keys.map(toCommandId);
|
|
37
|
+
return ids;
|
|
38
|
+
},
|
|
39
|
+
getKeys() {
|
|
40
|
+
return Object.keys(states).map(key => {
|
|
41
|
+
return Number.parseFloat(key);
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
registerCommands(commandMap) {
|
|
45
|
+
Object.assign(commandMapRef, commandMap);
|
|
46
|
+
},
|
|
47
|
+
set(uid, oldState, newState) {
|
|
48
|
+
states[uid] = {
|
|
49
|
+
newState,
|
|
50
|
+
oldState
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
wrapCommand(fn) {
|
|
54
|
+
const wrapped = async (uid, ...args) => {
|
|
55
|
+
const {
|
|
56
|
+
newState,
|
|
57
|
+
oldState
|
|
58
|
+
} = states[uid];
|
|
59
|
+
const newerState = await fn(newState, ...args);
|
|
60
|
+
if (oldState === newerState || newState === newerState) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const latestOld = states[uid];
|
|
64
|
+
const latestNew = {
|
|
65
|
+
...latestOld.newState,
|
|
66
|
+
...newerState
|
|
67
|
+
};
|
|
68
|
+
states[uid] = {
|
|
69
|
+
newState: latestNew,
|
|
70
|
+
oldState: latestOld.oldState
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
return wrapped;
|
|
74
|
+
},
|
|
75
|
+
wrapGetter(fn) {
|
|
76
|
+
const wrapped = (uid, ...args) => {
|
|
77
|
+
const {
|
|
78
|
+
newState
|
|
79
|
+
} = states[uid];
|
|
80
|
+
return fn(newState, ...args);
|
|
81
|
+
};
|
|
82
|
+
return wrapped;
|
|
83
|
+
},
|
|
84
|
+
wrapLoadContent(fn) {
|
|
85
|
+
const wrapped = async (uid, ...args) => {
|
|
86
|
+
const {
|
|
87
|
+
newState,
|
|
88
|
+
oldState
|
|
89
|
+
} = states[uid];
|
|
90
|
+
const result = await fn(newState, ...args);
|
|
91
|
+
const {
|
|
92
|
+
error,
|
|
93
|
+
state
|
|
94
|
+
} = result;
|
|
95
|
+
if (oldState === state || newState === state) {
|
|
96
|
+
return {
|
|
97
|
+
error
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const latestOld = states[uid];
|
|
101
|
+
const latestNew = {
|
|
102
|
+
...latestOld.newState,
|
|
103
|
+
...state
|
|
104
|
+
};
|
|
105
|
+
states[uid] = {
|
|
106
|
+
newState: latestNew,
|
|
107
|
+
oldState: latestOld.oldState
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
error
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
return wrapped;
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
const terminate = () => {
|
|
118
|
+
globalThis.close();
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const {
|
|
122
|
+
get: get$3,
|
|
123
|
+
getCommandIds,
|
|
124
|
+
registerCommands,
|
|
125
|
+
set: set$3,
|
|
126
|
+
wrapCommand,
|
|
127
|
+
wrapGetter
|
|
128
|
+
} = create$a();
|
|
129
|
+
|
|
130
|
+
const create$9 = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
131
|
+
const state = {
|
|
132
|
+
assetDir,
|
|
133
|
+
errorCount: 0,
|
|
134
|
+
initial: true,
|
|
135
|
+
platform,
|
|
136
|
+
statusBarItemsLeft: [],
|
|
137
|
+
statusBarItemsRight: [],
|
|
138
|
+
uid,
|
|
139
|
+
warningCount: 0
|
|
140
|
+
};
|
|
141
|
+
set$3(uid, state, state);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const isEqual = (oldState, newState) => {
|
|
145
|
+
return oldState.statusBarItemsLeft === newState.statusBarItemsLeft && oldState.statusBarItemsRight === newState.statusBarItemsRight;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const RenderItems = 4;
|
|
149
|
+
const RenderIncremental = 11;
|
|
150
|
+
|
|
151
|
+
const modules = [isEqual];
|
|
152
|
+
const numbers = [RenderIncremental];
|
|
153
|
+
|
|
154
|
+
const diff = (oldState, newState) => {
|
|
155
|
+
const diffResult = [];
|
|
156
|
+
for (let i = 0; i < modules.length; i++) {
|
|
157
|
+
const fn = modules[i];
|
|
158
|
+
if (!fn(oldState, newState)) {
|
|
159
|
+
diffResult.push(numbers[i]);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return diffResult;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const diff2 = uid => {
|
|
166
|
+
const {
|
|
167
|
+
newState,
|
|
168
|
+
oldState
|
|
169
|
+
} = get$3(uid);
|
|
170
|
+
const result = diff(oldState, newState);
|
|
171
|
+
return result;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const getMatchingItemInternal = (items, name) => {
|
|
175
|
+
for (const item of items) {
|
|
176
|
+
if (item.name === name) {
|
|
177
|
+
return item;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return undefined;
|
|
181
|
+
};
|
|
182
|
+
const getMatchingItem = (itemsLeft, itemsRight, name) => {
|
|
183
|
+
return getMatchingItemInternal(itemsLeft, name) ?? getMatchingItemInternal(itemsRight, name);
|
|
184
|
+
};
|
|
185
|
+
|
|
1
186
|
const normalizeLine = line => {
|
|
2
187
|
if (line.startsWith('Error: ')) {
|
|
3
188
|
return line.slice('Error: '.length);
|
|
@@ -486,7 +671,7 @@ const execute = (command, ...args) => {
|
|
|
486
671
|
|
|
487
672
|
const Two$1 = '2.0';
|
|
488
673
|
const callbacks = Object.create(null);
|
|
489
|
-
const get$
|
|
674
|
+
const get$2 = id => {
|
|
490
675
|
return callbacks[id];
|
|
491
676
|
};
|
|
492
677
|
const remove$1 = id => {
|
|
@@ -635,7 +820,7 @@ const warn = (...args) => {
|
|
|
635
820
|
console.warn(...args);
|
|
636
821
|
};
|
|
637
822
|
const resolve = (id, response) => {
|
|
638
|
-
const fn = get$
|
|
823
|
+
const fn = get$2(id);
|
|
639
824
|
if (!fn) {
|
|
640
825
|
console.log(response);
|
|
641
826
|
warn(`callback ${id} may already be disposed`);
|
|
@@ -698,7 +883,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
698
883
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
699
884
|
return create$1$1(id, errorProperty);
|
|
700
885
|
};
|
|
701
|
-
const create$
|
|
886
|
+
const create$8 = (message, result) => {
|
|
702
887
|
return {
|
|
703
888
|
id: message.id,
|
|
704
889
|
jsonrpc: Two$1,
|
|
@@ -707,7 +892,7 @@ const create$9 = (message, result) => {
|
|
|
707
892
|
};
|
|
708
893
|
const getSuccessResponse = (message, result) => {
|
|
709
894
|
const resultProperty = result ?? null;
|
|
710
|
-
return create$
|
|
895
|
+
return create$8(message, resultProperty);
|
|
711
896
|
};
|
|
712
897
|
const getErrorResponseSimple = (id, error) => {
|
|
713
898
|
return {
|
|
@@ -801,7 +986,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
801
986
|
|
|
802
987
|
const Two = '2.0';
|
|
803
988
|
|
|
804
|
-
const create$
|
|
989
|
+
const create$7 = (method, params) => {
|
|
805
990
|
return {
|
|
806
991
|
jsonrpc: Two,
|
|
807
992
|
method,
|
|
@@ -809,7 +994,7 @@ const create$8 = (method, params) => {
|
|
|
809
994
|
};
|
|
810
995
|
};
|
|
811
996
|
|
|
812
|
-
const create$
|
|
997
|
+
const create$6 = (id, method, params) => {
|
|
813
998
|
const message = {
|
|
814
999
|
id,
|
|
815
1000
|
jsonrpc: Two,
|
|
@@ -820,12 +1005,12 @@ const create$7 = (id, method, params) => {
|
|
|
820
1005
|
};
|
|
821
1006
|
|
|
822
1007
|
let id$1 = 0;
|
|
823
|
-
const create$
|
|
1008
|
+
const create$5 = () => {
|
|
824
1009
|
return ++id$1;
|
|
825
1010
|
};
|
|
826
1011
|
|
|
827
1012
|
const registerPromise = map => {
|
|
828
|
-
const id = create$
|
|
1013
|
+
const id = create$5();
|
|
829
1014
|
const {
|
|
830
1015
|
promise,
|
|
831
1016
|
resolve
|
|
@@ -842,7 +1027,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
842
1027
|
id,
|
|
843
1028
|
promise
|
|
844
1029
|
} = registerPromise(callbacks);
|
|
845
|
-
const message = create$
|
|
1030
|
+
const message = create$6(id, method, params);
|
|
846
1031
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
847
1032
|
ipc.sendAndTransfer(message);
|
|
848
1033
|
} else {
|
|
@@ -878,7 +1063,7 @@ const createRpc = ipc => {
|
|
|
878
1063
|
* @deprecated
|
|
879
1064
|
*/
|
|
880
1065
|
send(method, ...params) {
|
|
881
|
-
const message = create$
|
|
1066
|
+
const message = create$7(method, params);
|
|
882
1067
|
ipc.send(message);
|
|
883
1068
|
}
|
|
884
1069
|
};
|
|
@@ -918,7 +1103,7 @@ const listen$1 = async (module, options) => {
|
|
|
918
1103
|
return ipc;
|
|
919
1104
|
};
|
|
920
1105
|
|
|
921
|
-
const create$
|
|
1106
|
+
const create$4 = async ({
|
|
922
1107
|
commandMap,
|
|
923
1108
|
isMessagePortOpen = true,
|
|
924
1109
|
messagePort
|
|
@@ -936,7 +1121,7 @@ const create$5 = async ({
|
|
|
936
1121
|
return rpc;
|
|
937
1122
|
};
|
|
938
1123
|
|
|
939
|
-
const create$
|
|
1124
|
+
const create$3 = async ({
|
|
940
1125
|
commandMap,
|
|
941
1126
|
isMessagePortOpen,
|
|
942
1127
|
send
|
|
@@ -946,14 +1131,56 @@ const create$4 = async ({
|
|
|
946
1131
|
port2
|
|
947
1132
|
} = new MessageChannel();
|
|
948
1133
|
await send(port1);
|
|
949
|
-
return create$
|
|
1134
|
+
return create$4({
|
|
950
1135
|
commandMap,
|
|
951
1136
|
isMessagePortOpen,
|
|
952
1137
|
messagePort: port2
|
|
953
1138
|
});
|
|
954
1139
|
};
|
|
955
1140
|
|
|
956
|
-
const
|
|
1141
|
+
const createSharedLazyRpc = factory => {
|
|
1142
|
+
let rpcPromise;
|
|
1143
|
+
const getOrCreate = () => {
|
|
1144
|
+
if (!rpcPromise) {
|
|
1145
|
+
rpcPromise = factory();
|
|
1146
|
+
}
|
|
1147
|
+
return rpcPromise;
|
|
1148
|
+
};
|
|
1149
|
+
return {
|
|
1150
|
+
async dispose() {
|
|
1151
|
+
const rpc = await getOrCreate();
|
|
1152
|
+
await rpc.dispose();
|
|
1153
|
+
},
|
|
1154
|
+
async invoke(method, ...params) {
|
|
1155
|
+
const rpc = await getOrCreate();
|
|
1156
|
+
return rpc.invoke(method, ...params);
|
|
1157
|
+
},
|
|
1158
|
+
async invokeAndTransfer(method, ...params) {
|
|
1159
|
+
const rpc = await getOrCreate();
|
|
1160
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1161
|
+
},
|
|
1162
|
+
async send(method, ...params) {
|
|
1163
|
+
const rpc = await getOrCreate();
|
|
1164
|
+
rpc.send(method, ...params);
|
|
1165
|
+
}
|
|
1166
|
+
};
|
|
1167
|
+
};
|
|
1168
|
+
|
|
1169
|
+
const create$2 = async ({
|
|
1170
|
+
commandMap,
|
|
1171
|
+
isMessagePortOpen,
|
|
1172
|
+
send
|
|
1173
|
+
}) => {
|
|
1174
|
+
return createSharedLazyRpc(() => {
|
|
1175
|
+
return create$3({
|
|
1176
|
+
commandMap,
|
|
1177
|
+
isMessagePortOpen,
|
|
1178
|
+
send
|
|
1179
|
+
});
|
|
1180
|
+
});
|
|
1181
|
+
};
|
|
1182
|
+
|
|
1183
|
+
const create$1 = async ({
|
|
957
1184
|
commandMap
|
|
958
1185
|
}) => {
|
|
959
1186
|
// TODO create a commandMap per rpc instance
|
|
@@ -985,10 +1212,10 @@ const createMockRpc = ({
|
|
|
985
1212
|
};
|
|
986
1213
|
|
|
987
1214
|
const rpcs = Object.create(null);
|
|
988
|
-
const set$
|
|
1215
|
+
const set$2 = (id, rpc) => {
|
|
989
1216
|
rpcs[id] = rpc;
|
|
990
1217
|
};
|
|
991
|
-
const get$
|
|
1218
|
+
const get$1 = id => {
|
|
992
1219
|
return rpcs[id];
|
|
993
1220
|
};
|
|
994
1221
|
const remove = id => {
|
|
@@ -996,21 +1223,21 @@ const remove = id => {
|
|
|
996
1223
|
};
|
|
997
1224
|
|
|
998
1225
|
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
999
|
-
const create
|
|
1226
|
+
const create = rpcId => {
|
|
1000
1227
|
return {
|
|
1001
1228
|
async dispose() {
|
|
1002
|
-
const rpc = get$
|
|
1229
|
+
const rpc = get$1(rpcId);
|
|
1003
1230
|
await rpc.dispose();
|
|
1004
1231
|
},
|
|
1005
1232
|
// @ts-ignore
|
|
1006
1233
|
invoke(method, ...params) {
|
|
1007
|
-
const rpc = get$
|
|
1234
|
+
const rpc = get$1(rpcId);
|
|
1008
1235
|
// @ts-ignore
|
|
1009
1236
|
return rpc.invoke(method, ...params);
|
|
1010
1237
|
},
|
|
1011
1238
|
// @ts-ignore
|
|
1012
1239
|
invokeAndTransfer(method, ...params) {
|
|
1013
|
-
const rpc = get$
|
|
1240
|
+
const rpc = get$1(rpcId);
|
|
1014
1241
|
// @ts-ignore
|
|
1015
1242
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1016
1243
|
},
|
|
@@ -1018,7 +1245,7 @@ const create$2 = rpcId => {
|
|
|
1018
1245
|
const mockRpc = createMockRpc({
|
|
1019
1246
|
commandMap
|
|
1020
1247
|
});
|
|
1021
|
-
set$
|
|
1248
|
+
set$2(rpcId, mockRpc);
|
|
1022
1249
|
// @ts-ignore
|
|
1023
1250
|
mockRpc[Symbol.dispose] = () => {
|
|
1024
1251
|
remove(rpcId);
|
|
@@ -1027,7 +1254,7 @@ const create$2 = rpcId => {
|
|
|
1027
1254
|
return mockRpc;
|
|
1028
1255
|
},
|
|
1029
1256
|
set(rpc) {
|
|
1030
|
-
set$
|
|
1257
|
+
set$2(rpcId, rpc);
|
|
1031
1258
|
}
|
|
1032
1259
|
};
|
|
1033
1260
|
};
|
|
@@ -1053,14 +1280,14 @@ const SetPatches = 'Viewlet.setPatches';
|
|
|
1053
1280
|
|
|
1054
1281
|
const {
|
|
1055
1282
|
invoke: invoke$1,
|
|
1056
|
-
set: set$
|
|
1057
|
-
} = create
|
|
1283
|
+
set: set$1
|
|
1284
|
+
} = create(ExtensionHostWorker);
|
|
1058
1285
|
|
|
1059
1286
|
const {
|
|
1060
1287
|
invoke,
|
|
1061
1288
|
invokeAndTransfer,
|
|
1062
|
-
set
|
|
1063
|
-
} = create
|
|
1289
|
+
set
|
|
1290
|
+
} = create(RendererWorker);
|
|
1064
1291
|
const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
|
|
1065
1292
|
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1066
1293
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
@@ -1072,191 +1299,6 @@ const getPreference = async key => {
|
|
|
1072
1299
|
return await invoke('Preferences.get', key);
|
|
1073
1300
|
};
|
|
1074
1301
|
|
|
1075
|
-
const toCommandId = key => {
|
|
1076
|
-
const dotIndex = key.indexOf('.');
|
|
1077
|
-
return key.slice(dotIndex + 1);
|
|
1078
|
-
};
|
|
1079
|
-
const create$1 = () => {
|
|
1080
|
-
const states = Object.create(null);
|
|
1081
|
-
const commandMapRef = {};
|
|
1082
|
-
return {
|
|
1083
|
-
clear() {
|
|
1084
|
-
for (const key of Object.keys(states)) {
|
|
1085
|
-
delete states[key];
|
|
1086
|
-
}
|
|
1087
|
-
},
|
|
1088
|
-
diff(uid, modules, numbers) {
|
|
1089
|
-
const {
|
|
1090
|
-
newState,
|
|
1091
|
-
oldState
|
|
1092
|
-
} = states[uid];
|
|
1093
|
-
const diffResult = [];
|
|
1094
|
-
for (let i = 0; i < modules.length; i++) {
|
|
1095
|
-
const fn = modules[i];
|
|
1096
|
-
if (!fn(oldState, newState)) {
|
|
1097
|
-
diffResult.push(numbers[i]);
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
return diffResult;
|
|
1101
|
-
},
|
|
1102
|
-
dispose(uid) {
|
|
1103
|
-
delete states[uid];
|
|
1104
|
-
},
|
|
1105
|
-
get(uid) {
|
|
1106
|
-
return states[uid];
|
|
1107
|
-
},
|
|
1108
|
-
getCommandIds() {
|
|
1109
|
-
const keys = Object.keys(commandMapRef);
|
|
1110
|
-
const ids = keys.map(toCommandId);
|
|
1111
|
-
return ids;
|
|
1112
|
-
},
|
|
1113
|
-
getKeys() {
|
|
1114
|
-
return Object.keys(states).map(key => {
|
|
1115
|
-
return Number.parseFloat(key);
|
|
1116
|
-
});
|
|
1117
|
-
},
|
|
1118
|
-
registerCommands(commandMap) {
|
|
1119
|
-
Object.assign(commandMapRef, commandMap);
|
|
1120
|
-
},
|
|
1121
|
-
set(uid, oldState, newState) {
|
|
1122
|
-
states[uid] = {
|
|
1123
|
-
newState,
|
|
1124
|
-
oldState
|
|
1125
|
-
};
|
|
1126
|
-
},
|
|
1127
|
-
wrapCommand(fn) {
|
|
1128
|
-
const wrapped = async (uid, ...args) => {
|
|
1129
|
-
const {
|
|
1130
|
-
newState,
|
|
1131
|
-
oldState
|
|
1132
|
-
} = states[uid];
|
|
1133
|
-
const newerState = await fn(newState, ...args);
|
|
1134
|
-
if (oldState === newerState || newState === newerState) {
|
|
1135
|
-
return;
|
|
1136
|
-
}
|
|
1137
|
-
const latestOld = states[uid];
|
|
1138
|
-
const latestNew = {
|
|
1139
|
-
...latestOld.newState,
|
|
1140
|
-
...newerState
|
|
1141
|
-
};
|
|
1142
|
-
states[uid] = {
|
|
1143
|
-
newState: latestNew,
|
|
1144
|
-
oldState: latestOld.oldState
|
|
1145
|
-
};
|
|
1146
|
-
};
|
|
1147
|
-
return wrapped;
|
|
1148
|
-
},
|
|
1149
|
-
wrapGetter(fn) {
|
|
1150
|
-
const wrapped = (uid, ...args) => {
|
|
1151
|
-
const {
|
|
1152
|
-
newState
|
|
1153
|
-
} = states[uid];
|
|
1154
|
-
return fn(newState, ...args);
|
|
1155
|
-
};
|
|
1156
|
-
return wrapped;
|
|
1157
|
-
},
|
|
1158
|
-
wrapLoadContent(fn) {
|
|
1159
|
-
const wrapped = async (uid, ...args) => {
|
|
1160
|
-
const {
|
|
1161
|
-
newState,
|
|
1162
|
-
oldState
|
|
1163
|
-
} = states[uid];
|
|
1164
|
-
const result = await fn(newState, ...args);
|
|
1165
|
-
const {
|
|
1166
|
-
error,
|
|
1167
|
-
state
|
|
1168
|
-
} = result;
|
|
1169
|
-
if (oldState === state || newState === state) {
|
|
1170
|
-
return {
|
|
1171
|
-
error
|
|
1172
|
-
};
|
|
1173
|
-
}
|
|
1174
|
-
const latestOld = states[uid];
|
|
1175
|
-
const latestNew = {
|
|
1176
|
-
...latestOld.newState,
|
|
1177
|
-
...state
|
|
1178
|
-
};
|
|
1179
|
-
states[uid] = {
|
|
1180
|
-
newState: latestNew,
|
|
1181
|
-
oldState: latestOld.oldState
|
|
1182
|
-
};
|
|
1183
|
-
return {
|
|
1184
|
-
error
|
|
1185
|
-
};
|
|
1186
|
-
};
|
|
1187
|
-
return wrapped;
|
|
1188
|
-
}
|
|
1189
|
-
};
|
|
1190
|
-
};
|
|
1191
|
-
const terminate = () => {
|
|
1192
|
-
globalThis.close();
|
|
1193
|
-
};
|
|
1194
|
-
|
|
1195
|
-
const {
|
|
1196
|
-
get: get$1,
|
|
1197
|
-
getCommandIds,
|
|
1198
|
-
registerCommands,
|
|
1199
|
-
set,
|
|
1200
|
-
wrapCommand,
|
|
1201
|
-
wrapGetter
|
|
1202
|
-
} = create$1();
|
|
1203
|
-
|
|
1204
|
-
const create = (uid, uri, x, y, width, height, platform, assetDir) => {
|
|
1205
|
-
const state = {
|
|
1206
|
-
assetDir,
|
|
1207
|
-
errorCount: 0,
|
|
1208
|
-
initial: true,
|
|
1209
|
-
platform,
|
|
1210
|
-
statusBarItemsLeft: [],
|
|
1211
|
-
statusBarItemsRight: [],
|
|
1212
|
-
uid,
|
|
1213
|
-
warningCount: 0
|
|
1214
|
-
};
|
|
1215
|
-
set(uid, state, state);
|
|
1216
|
-
};
|
|
1217
|
-
|
|
1218
|
-
const isEqual = (oldState, newState) => {
|
|
1219
|
-
return oldState.statusBarItemsLeft === newState.statusBarItemsLeft && oldState.statusBarItemsRight === newState.statusBarItemsRight;
|
|
1220
|
-
};
|
|
1221
|
-
|
|
1222
|
-
const RenderItems = 4;
|
|
1223
|
-
const RenderIncremental = 11;
|
|
1224
|
-
|
|
1225
|
-
const modules = [isEqual];
|
|
1226
|
-
const numbers = [RenderIncremental];
|
|
1227
|
-
|
|
1228
|
-
const diff = (oldState, newState) => {
|
|
1229
|
-
const diffResult = [];
|
|
1230
|
-
for (let i = 0; i < modules.length; i++) {
|
|
1231
|
-
const fn = modules[i];
|
|
1232
|
-
if (!fn(oldState, newState)) {
|
|
1233
|
-
diffResult.push(numbers[i]);
|
|
1234
|
-
}
|
|
1235
|
-
}
|
|
1236
|
-
return diffResult;
|
|
1237
|
-
};
|
|
1238
|
-
|
|
1239
|
-
const diff2 = uid => {
|
|
1240
|
-
const {
|
|
1241
|
-
newState,
|
|
1242
|
-
oldState
|
|
1243
|
-
} = get$1(uid);
|
|
1244
|
-
const result = diff(oldState, newState);
|
|
1245
|
-
return result;
|
|
1246
|
-
};
|
|
1247
|
-
|
|
1248
|
-
const getMatchingItemInternal = (items, name) => {
|
|
1249
|
-
for (const item of items) {
|
|
1250
|
-
if (item.name === name) {
|
|
1251
|
-
return item;
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
return undefined;
|
|
1255
|
-
};
|
|
1256
|
-
const getMatchingItem = (itemsLeft, itemsRight, name) => {
|
|
1257
|
-
return getMatchingItemInternal(itemsLeft, name) ?? getMatchingItemInternal(itemsRight, name);
|
|
1258
|
-
};
|
|
1259
|
-
|
|
1260
1302
|
const handleClickExtensionStatusBarItem = async name => {
|
|
1261
1303
|
// TODO maybe relay this to extension management worker,
|
|
1262
1304
|
// and it forwards it to the right extension host?
|
|
@@ -1319,6 +1361,10 @@ const activateByEvent = (event, assetDir, platform) => {
|
|
|
1319
1361
|
// @ts-ignore
|
|
1320
1362
|
return activateByEvent$1(event, assetDir, platform);
|
|
1321
1363
|
};
|
|
1364
|
+
const getStatusBarItems$2 = () => {
|
|
1365
|
+
// @ts-ignore
|
|
1366
|
+
return invoke('ExtensionHostManagement.getStatusBarItems');
|
|
1367
|
+
};
|
|
1322
1368
|
|
|
1323
1369
|
const executeProviders = async ({
|
|
1324
1370
|
assetDir,
|
|
@@ -1340,7 +1386,7 @@ const combineResults = results => {
|
|
|
1340
1386
|
return results.flat();
|
|
1341
1387
|
};
|
|
1342
1388
|
const getStatusBarItems$1 = (assetDir, platform) => {
|
|
1343
|
-
|
|
1389
|
+
const legacyItems = executeProviders({
|
|
1344
1390
|
assetDir,
|
|
1345
1391
|
combineResults,
|
|
1346
1392
|
event: OnStatusBarItem,
|
|
@@ -1350,6 +1396,8 @@ const getStatusBarItems$1 = (assetDir, platform) => {
|
|
|
1350
1396
|
params: [],
|
|
1351
1397
|
platform
|
|
1352
1398
|
});
|
|
1399
|
+
const isolatedItems = getStatusBarItems$2();
|
|
1400
|
+
return Promise.all([legacyItems, isolatedItems]).then(combineResults);
|
|
1353
1401
|
};
|
|
1354
1402
|
|
|
1355
1403
|
const getNotificationsStatusBarItem = enabled => {
|
|
@@ -1530,21 +1578,16 @@ const sendMessagePortToExtensionHostWorker = async port => {
|
|
|
1530
1578
|
await sendMessagePortToExtensionHostWorker$1(port, id);
|
|
1531
1579
|
};
|
|
1532
1580
|
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
return rpc;
|
|
1540
|
-
} catch (error) {
|
|
1541
|
-
throw new VError(error, `Failed to create extension host rpc`);
|
|
1542
|
-
}
|
|
1581
|
+
const initializeExtensionHostWorker = async () => {
|
|
1582
|
+
const rpc = await create$2({
|
|
1583
|
+
commandMap: {},
|
|
1584
|
+
send: sendMessagePortToExtensionHostWorker
|
|
1585
|
+
});
|
|
1586
|
+
set$1(rpc);
|
|
1543
1587
|
};
|
|
1544
1588
|
|
|
1545
1589
|
const initialize = async () => {
|
|
1546
|
-
|
|
1547
|
-
set$2(rpc);
|
|
1590
|
+
await initializeExtensionHostWorker();
|
|
1548
1591
|
};
|
|
1549
1592
|
|
|
1550
1593
|
const getIndex = (items, item) => {
|
|
@@ -1616,14 +1659,18 @@ const loadContent = async state => {
|
|
|
1616
1659
|
platform,
|
|
1617
1660
|
warningCount
|
|
1618
1661
|
} = state;
|
|
1619
|
-
const
|
|
1662
|
+
const {
|
|
1663
|
+
builtinNotificationsEnabled,
|
|
1664
|
+
builtinProblemsEnabled,
|
|
1665
|
+
itemsVisible
|
|
1666
|
+
} = await loadStatusBarPreferences();
|
|
1620
1667
|
const statusBarItems = await getStatusBarItems({
|
|
1621
1668
|
assetDir,
|
|
1622
|
-
builtinNotificationsEnabled:
|
|
1623
|
-
builtinProblemsEnabled:
|
|
1669
|
+
builtinNotificationsEnabled: builtinNotificationsEnabled,
|
|
1670
|
+
builtinProblemsEnabled: builtinProblemsEnabled,
|
|
1624
1671
|
errorCount,
|
|
1625
1672
|
platform,
|
|
1626
|
-
showItems:
|
|
1673
|
+
showItems: itemsVisible,
|
|
1627
1674
|
warningCount
|
|
1628
1675
|
});
|
|
1629
1676
|
return {
|
|
@@ -1778,11 +1825,78 @@ const treeToArray = node => {
|
|
|
1778
1825
|
return result;
|
|
1779
1826
|
};
|
|
1780
1827
|
|
|
1828
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
1829
|
+
if (currentChildIndex === -1) {
|
|
1830
|
+
patches.push({
|
|
1831
|
+
type: NavigateChild,
|
|
1832
|
+
index
|
|
1833
|
+
});
|
|
1834
|
+
return index;
|
|
1835
|
+
}
|
|
1836
|
+
if (currentChildIndex !== index) {
|
|
1837
|
+
patches.push({
|
|
1838
|
+
type: NavigateSibling,
|
|
1839
|
+
index
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
return index;
|
|
1843
|
+
};
|
|
1844
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
1845
|
+
if (currentChildIndex >= 0) {
|
|
1846
|
+
patches.push({
|
|
1847
|
+
type: NavigateParent
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
return -1;
|
|
1851
|
+
};
|
|
1852
|
+
const addTree = (newNode, patches) => {
|
|
1853
|
+
patches.push({
|
|
1854
|
+
type: Add,
|
|
1855
|
+
nodes: treeToArray(newNode)
|
|
1856
|
+
});
|
|
1857
|
+
};
|
|
1858
|
+
const replaceTree = (newNode, patches) => {
|
|
1859
|
+
patches.push({
|
|
1860
|
+
type: Replace,
|
|
1861
|
+
nodes: treeToArray(newNode)
|
|
1862
|
+
});
|
|
1863
|
+
};
|
|
1864
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
1865
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1866
|
+
if (nodePatches === null) {
|
|
1867
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
1868
|
+
replaceTree(newNode, patches);
|
|
1869
|
+
return nextChildIndex;
|
|
1870
|
+
}
|
|
1871
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
1872
|
+
if (nodePatches.length === 0 && !hasChildrenToCompare) {
|
|
1873
|
+
return currentChildIndex;
|
|
1874
|
+
}
|
|
1875
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
1876
|
+
if (nodePatches.length > 0) {
|
|
1877
|
+
patches.push(...nodePatches);
|
|
1878
|
+
}
|
|
1879
|
+
if (hasChildrenToCompare) {
|
|
1880
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
1881
|
+
}
|
|
1882
|
+
return nextChildIndex;
|
|
1883
|
+
};
|
|
1884
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
1885
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1886
|
+
if (nodePatches === null) {
|
|
1887
|
+
replaceTree(newNode, patches);
|
|
1888
|
+
return;
|
|
1889
|
+
}
|
|
1890
|
+
if (nodePatches.length > 0) {
|
|
1891
|
+
patches.push(...nodePatches);
|
|
1892
|
+
}
|
|
1893
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
1894
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
1895
|
+
}
|
|
1896
|
+
};
|
|
1781
1897
|
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
1782
1898
|
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
1783
|
-
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
1784
1899
|
let currentChildIndex = -1;
|
|
1785
|
-
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
1786
1900
|
const indicesToRemove = [];
|
|
1787
1901
|
for (let i = 0; i < maxLength; i++) {
|
|
1788
1902
|
const oldNode = oldChildren[i];
|
|
@@ -1791,88 +1905,17 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
1791
1905
|
continue;
|
|
1792
1906
|
}
|
|
1793
1907
|
if (!oldNode) {
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
});
|
|
1800
|
-
currentChildIndex = -1;
|
|
1801
|
-
}
|
|
1802
|
-
// Flatten the entire subtree so renderInternal can handle it
|
|
1803
|
-
const flatNodes = treeToArray(newNode);
|
|
1804
|
-
patches.push({
|
|
1805
|
-
type: Add,
|
|
1806
|
-
nodes: flatNodes
|
|
1807
|
-
});
|
|
1808
|
-
} else if (newNode) {
|
|
1809
|
-
// Compare nodes to see if we need any patches
|
|
1810
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1811
|
-
// If nodePatches is null, the node types are incompatible - need to replace
|
|
1812
|
-
if (nodePatches === null) {
|
|
1813
|
-
// Navigate to this child
|
|
1814
|
-
if (currentChildIndex === -1) {
|
|
1815
|
-
patches.push({
|
|
1816
|
-
type: NavigateChild,
|
|
1817
|
-
index: i
|
|
1818
|
-
});
|
|
1819
|
-
currentChildIndex = i;
|
|
1820
|
-
} else if (currentChildIndex !== i) {
|
|
1821
|
-
patches.push({
|
|
1822
|
-
type: NavigateSibling,
|
|
1823
|
-
index: i
|
|
1824
|
-
});
|
|
1825
|
-
currentChildIndex = i;
|
|
1826
|
-
}
|
|
1827
|
-
// Replace the entire subtree
|
|
1828
|
-
const flatNodes = treeToArray(newNode);
|
|
1829
|
-
patches.push({
|
|
1830
|
-
type: Replace,
|
|
1831
|
-
nodes: flatNodes
|
|
1832
|
-
});
|
|
1833
|
-
// After replace, we're at the new element (same position)
|
|
1834
|
-
continue;
|
|
1835
|
-
}
|
|
1836
|
-
// Check if we need to recurse into children
|
|
1837
|
-
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
1838
|
-
// Only navigate to this element if we need to do something
|
|
1839
|
-
if (nodePatches.length > 0 || hasChildrenToCompare) {
|
|
1840
|
-
// Navigate to this child if not already there
|
|
1841
|
-
if (currentChildIndex === -1) {
|
|
1842
|
-
patches.push({
|
|
1843
|
-
type: NavigateChild,
|
|
1844
|
-
index: i
|
|
1845
|
-
});
|
|
1846
|
-
currentChildIndex = i;
|
|
1847
|
-
} else if (currentChildIndex !== i) {
|
|
1848
|
-
patches.push({
|
|
1849
|
-
type: NavigateSibling,
|
|
1850
|
-
index: i
|
|
1851
|
-
});
|
|
1852
|
-
currentChildIndex = i;
|
|
1853
|
-
}
|
|
1854
|
-
// Apply node patches (these apply to the current element, not children)
|
|
1855
|
-
if (nodePatches.length > 0) {
|
|
1856
|
-
patches.push(...nodePatches);
|
|
1857
|
-
}
|
|
1858
|
-
// Compare children recursively
|
|
1859
|
-
if (hasChildrenToCompare) {
|
|
1860
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
1861
|
-
}
|
|
1862
|
-
}
|
|
1863
|
-
} else {
|
|
1864
|
-
// Remove old node - collect the index for later removal
|
|
1908
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
1909
|
+
addTree(newNode, patches);
|
|
1910
|
+
continue;
|
|
1911
|
+
}
|
|
1912
|
+
if (!newNode) {
|
|
1865
1913
|
indicesToRemove.push(i);
|
|
1914
|
+
continue;
|
|
1866
1915
|
}
|
|
1916
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
1867
1917
|
}
|
|
1868
|
-
|
|
1869
|
-
if (currentChildIndex >= 0) {
|
|
1870
|
-
patches.push({
|
|
1871
|
-
type: NavigateParent
|
|
1872
|
-
});
|
|
1873
|
-
}
|
|
1874
|
-
// Add remove patches in reverse order (highest index first)
|
|
1875
|
-
// This ensures indices remain valid as we remove
|
|
1918
|
+
navigateToParent(patches, currentChildIndex);
|
|
1876
1919
|
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
1877
1920
|
patches.push({
|
|
1878
1921
|
type: RemoveChild,
|
|
@@ -1881,33 +1924,11 @@ const diffChildren = (oldChildren, newChildren, patches) => {
|
|
|
1881
1924
|
}
|
|
1882
1925
|
};
|
|
1883
1926
|
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
1884
|
-
// At the root level (path.length === 0), we're already AT the element
|
|
1885
|
-
// So we compare the root node directly, then compare its children
|
|
1886
1927
|
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
// Compare root nodes
|
|
1890
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1891
|
-
// If nodePatches is null, the root node types are incompatible - need to replace
|
|
1892
|
-
if (nodePatches === null) {
|
|
1893
|
-
const flatNodes = treeToArray(newNode);
|
|
1894
|
-
patches.push({
|
|
1895
|
-
type: Replace,
|
|
1896
|
-
nodes: flatNodes
|
|
1897
|
-
});
|
|
1898
|
-
return;
|
|
1899
|
-
}
|
|
1900
|
-
if (nodePatches.length > 0) {
|
|
1901
|
-
patches.push(...nodePatches);
|
|
1902
|
-
}
|
|
1903
|
-
// Compare children
|
|
1904
|
-
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
1905
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
1906
|
-
}
|
|
1907
|
-
} else {
|
|
1908
|
-
// Non-root level or multiple root elements - use the regular comparison
|
|
1909
|
-
diffChildren(oldTree, newTree, patches);
|
|
1928
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
1929
|
+
return;
|
|
1910
1930
|
}
|
|
1931
|
+
diffChildren(oldTree, newTree, patches);
|
|
1911
1932
|
};
|
|
1912
1933
|
|
|
1913
1934
|
const removeTrailingNavigationPatches = patches => {
|
|
@@ -2072,8 +2093,8 @@ const render2 = (uid, diffResult) => {
|
|
|
2072
2093
|
const {
|
|
2073
2094
|
newState,
|
|
2074
2095
|
oldState
|
|
2075
|
-
} = get$
|
|
2076
|
-
set(uid, newState, newState);
|
|
2096
|
+
} = get$3(uid);
|
|
2097
|
+
set$3(uid, newState, newState);
|
|
2077
2098
|
const commands = applyRender(oldState, newState, diffResult);
|
|
2078
2099
|
return commands;
|
|
2079
2100
|
};
|
|
@@ -2108,7 +2129,7 @@ const saveState = state => {
|
|
|
2108
2129
|
};
|
|
2109
2130
|
|
|
2110
2131
|
const commandMap = {
|
|
2111
|
-
'StatusBar.create': create,
|
|
2132
|
+
'StatusBar.create': create$9,
|
|
2112
2133
|
'StatusBar.diff2': diff2,
|
|
2113
2134
|
'StatusBar.getCommandIds': getCommandIds,
|
|
2114
2135
|
'StatusBar.handleChange': wrapCommand(handleItemsChanged),
|
|
@@ -2128,12 +2149,16 @@ const commandMap = {
|
|
|
2128
2149
|
'StatusBar.terminate': terminate
|
|
2129
2150
|
};
|
|
2130
2151
|
|
|
2131
|
-
const
|
|
2132
|
-
|
|
2133
|
-
const rpc = await create$3({
|
|
2152
|
+
const initializeRenderWorker = async () => {
|
|
2153
|
+
const rpc = await create$1({
|
|
2134
2154
|
commandMap: commandMap
|
|
2135
2155
|
});
|
|
2136
|
-
set
|
|
2156
|
+
set(rpc);
|
|
2157
|
+
};
|
|
2158
|
+
|
|
2159
|
+
const listen = async () => {
|
|
2160
|
+
registerCommands(commandMap);
|
|
2161
|
+
await initializeRenderWorker();
|
|
2137
2162
|
};
|
|
2138
2163
|
|
|
2139
2164
|
const main = async () => {
|