@lvce-editor/status-bar-worker 2.4.0 → 2.5.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 +279 -234
- 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?
|
|
@@ -1530,21 +1572,16 @@ const sendMessagePortToExtensionHostWorker = async port => {
|
|
|
1530
1572
|
await sendMessagePortToExtensionHostWorker$1(port, id);
|
|
1531
1573
|
};
|
|
1532
1574
|
|
|
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
|
-
}
|
|
1575
|
+
const initializeExtensionHostWorker = async () => {
|
|
1576
|
+
const rpc = await create$2({
|
|
1577
|
+
commandMap: {},
|
|
1578
|
+
send: sendMessagePortToExtensionHostWorker
|
|
1579
|
+
});
|
|
1580
|
+
set$1(rpc);
|
|
1543
1581
|
};
|
|
1544
1582
|
|
|
1545
1583
|
const initialize = async () => {
|
|
1546
|
-
|
|
1547
|
-
set$2(rpc);
|
|
1584
|
+
await initializeExtensionHostWorker();
|
|
1548
1585
|
};
|
|
1549
1586
|
|
|
1550
1587
|
const getIndex = (items, item) => {
|
|
@@ -1616,14 +1653,18 @@ const loadContent = async state => {
|
|
|
1616
1653
|
platform,
|
|
1617
1654
|
warningCount
|
|
1618
1655
|
} = state;
|
|
1619
|
-
const
|
|
1656
|
+
const {
|
|
1657
|
+
builtinNotificationsEnabled,
|
|
1658
|
+
builtinProblemsEnabled,
|
|
1659
|
+
itemsVisible
|
|
1660
|
+
} = await loadStatusBarPreferences();
|
|
1620
1661
|
const statusBarItems = await getStatusBarItems({
|
|
1621
1662
|
assetDir,
|
|
1622
|
-
builtinNotificationsEnabled:
|
|
1623
|
-
builtinProblemsEnabled:
|
|
1663
|
+
builtinNotificationsEnabled: builtinNotificationsEnabled,
|
|
1664
|
+
builtinProblemsEnabled: builtinProblemsEnabled,
|
|
1624
1665
|
errorCount,
|
|
1625
1666
|
platform,
|
|
1626
|
-
showItems:
|
|
1667
|
+
showItems: itemsVisible,
|
|
1627
1668
|
warningCount
|
|
1628
1669
|
});
|
|
1629
1670
|
return {
|
|
@@ -2072,8 +2113,8 @@ const render2 = (uid, diffResult) => {
|
|
|
2072
2113
|
const {
|
|
2073
2114
|
newState,
|
|
2074
2115
|
oldState
|
|
2075
|
-
} = get$
|
|
2076
|
-
set(uid, newState, newState);
|
|
2116
|
+
} = get$3(uid);
|
|
2117
|
+
set$3(uid, newState, newState);
|
|
2077
2118
|
const commands = applyRender(oldState, newState, diffResult);
|
|
2078
2119
|
return commands;
|
|
2079
2120
|
};
|
|
@@ -2108,7 +2149,7 @@ const saveState = state => {
|
|
|
2108
2149
|
};
|
|
2109
2150
|
|
|
2110
2151
|
const commandMap = {
|
|
2111
|
-
'StatusBar.create': create,
|
|
2152
|
+
'StatusBar.create': create$9,
|
|
2112
2153
|
'StatusBar.diff2': diff2,
|
|
2113
2154
|
'StatusBar.getCommandIds': getCommandIds,
|
|
2114
2155
|
'StatusBar.handleChange': wrapCommand(handleItemsChanged),
|
|
@@ -2128,12 +2169,16 @@ const commandMap = {
|
|
|
2128
2169
|
'StatusBar.terminate': terminate
|
|
2129
2170
|
};
|
|
2130
2171
|
|
|
2131
|
-
const
|
|
2132
|
-
|
|
2133
|
-
const rpc = await create$3({
|
|
2172
|
+
const initializeRenderWorker = async () => {
|
|
2173
|
+
const rpc = await create$1({
|
|
2134
2174
|
commandMap: commandMap
|
|
2135
2175
|
});
|
|
2136
|
-
set
|
|
2176
|
+
set(rpc);
|
|
2177
|
+
};
|
|
2178
|
+
|
|
2179
|
+
const listen = async () => {
|
|
2180
|
+
registerCommands(commandMap);
|
|
2181
|
+
await initializeRenderWorker();
|
|
2137
2182
|
};
|
|
2138
2183
|
|
|
2139
2184
|
const main = async () => {
|