@lvce-editor/activity-bar-worker 7.0.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 +1636 -1555
- package/package.json +1 -1
|
@@ -1,1711 +1,1768 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
if (line.startsWith('VError: ')) {
|
|
6
|
-
return line.slice('VError: '.length);
|
|
7
|
-
}
|
|
8
|
-
return line;
|
|
1
|
+
const toCommandId = key => {
|
|
2
|
+
const dotIndex = key.indexOf('.');
|
|
3
|
+
return key.slice(dotIndex + 1);
|
|
9
4
|
};
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
+
oldState,
|
|
17
|
+
scheduledState
|
|
18
|
+
} = states[uid];
|
|
19
|
+
const diffResult = [];
|
|
20
|
+
for (let i = 0; i < modules.length; i++) {
|
|
21
|
+
const fn = modules[i];
|
|
22
|
+
if (!fn(oldState, scheduledState)) {
|
|
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(Number);
|
|
41
|
+
},
|
|
42
|
+
registerCommands(commandMap) {
|
|
43
|
+
Object.assign(commandMapRef, commandMap);
|
|
44
|
+
},
|
|
45
|
+
set(uid, oldState, newState, scheduledState) {
|
|
46
|
+
states[uid] = {
|
|
47
|
+
newState,
|
|
48
|
+
oldState,
|
|
49
|
+
scheduledState: scheduledState ?? newState
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
wrapCommand(fn) {
|
|
53
|
+
const wrapped = async (uid, ...args) => {
|
|
54
|
+
const {
|
|
55
|
+
newState,
|
|
56
|
+
oldState
|
|
57
|
+
} = states[uid];
|
|
58
|
+
const newerState = await fn(newState, ...args);
|
|
59
|
+
if (oldState === newerState || newState === newerState) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const latestOld = states[uid];
|
|
63
|
+
const latestNew = {
|
|
64
|
+
...latestOld.newState,
|
|
65
|
+
...newerState
|
|
66
|
+
};
|
|
67
|
+
states[uid] = {
|
|
68
|
+
newState: latestNew,
|
|
69
|
+
oldState: latestOld.oldState,
|
|
70
|
+
scheduledState: latestNew
|
|
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
|
+
scheduledState: latestNew
|
|
109
|
+
};
|
|
110
|
+
return {
|
|
111
|
+
error
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
return wrapped;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
16
117
|
};
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
return string.indexOf(NewLine$2, startIndex);
|
|
118
|
+
const terminate = () => {
|
|
119
|
+
globalThis.close();
|
|
20
120
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
121
|
+
|
|
122
|
+
const {
|
|
123
|
+
diff,
|
|
124
|
+
get: get$2,
|
|
125
|
+
getCommandIds,
|
|
126
|
+
registerCommands,
|
|
127
|
+
set: set$4,
|
|
128
|
+
wrapCommand,
|
|
129
|
+
wrapGetter
|
|
130
|
+
} = create$a();
|
|
131
|
+
|
|
132
|
+
// TODO parentUid might ot be needed
|
|
133
|
+
const create$9 = (id, uri, x, y, width, height, args, parentUid, platform = 0) => {
|
|
134
|
+
const state = {
|
|
135
|
+
accountEnabled: true,
|
|
136
|
+
activityBarItems: [],
|
|
137
|
+
currentViewletId: '',
|
|
138
|
+
filteredItems: [],
|
|
139
|
+
focus: 0,
|
|
140
|
+
focused: false,
|
|
141
|
+
focusedIndex: -1,
|
|
142
|
+
height,
|
|
143
|
+
initial: true,
|
|
144
|
+
itemHeight: 48,
|
|
145
|
+
numberOfVisibleItems: 0,
|
|
146
|
+
platform,
|
|
147
|
+
scrollBarHeight: 0,
|
|
148
|
+
selectedIndex: -1,
|
|
149
|
+
sideBarLocation: 0,
|
|
150
|
+
sideBarVisible: false,
|
|
151
|
+
uid: id,
|
|
152
|
+
updateProgress: 0,
|
|
153
|
+
updateState: '',
|
|
154
|
+
userLoginState: 'logged out',
|
|
155
|
+
width,
|
|
156
|
+
x,
|
|
157
|
+
y
|
|
158
|
+
};
|
|
159
|
+
set$4(id, state, state);
|
|
160
|
+
return state;
|
|
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);
|
|
29
168
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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;
|
|
35
181
|
}
|
|
36
|
-
return
|
|
182
|
+
return `${builtinPrefix}${item.icon}`;
|
|
37
183
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// @ts-ignore
|
|
52
|
-
this.code = error.code;
|
|
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;
|
|
53
197
|
}
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
class AssertionError extends Error {
|
|
58
|
-
constructor(message) {
|
|
59
|
-
super(message);
|
|
60
|
-
this.name = 'AssertionError';
|
|
61
|
-
}
|
|
198
|
+
seen.add(customIconClass);
|
|
199
|
+
css += `.${customIconClass} {
|
|
200
|
+
mask-image: url("${escapeCssUrl(customIconUrl)}");
|
|
62
201
|
}
|
|
63
|
-
|
|
64
|
-
const Number$1 = 2;
|
|
65
|
-
const Array$1 = 3;
|
|
66
|
-
const String = 4;
|
|
67
|
-
const Boolean$1 = 5;
|
|
68
|
-
const Function = 6;
|
|
69
|
-
const Null = 7;
|
|
70
|
-
const Unknown = 8;
|
|
71
|
-
const getType = value => {
|
|
72
|
-
switch (typeof value) {
|
|
73
|
-
case 'number':
|
|
74
|
-
return Number$1;
|
|
75
|
-
case 'function':
|
|
76
|
-
return Function;
|
|
77
|
-
case 'string':
|
|
78
|
-
return String;
|
|
79
|
-
case 'object':
|
|
80
|
-
if (value === null) {
|
|
81
|
-
return Null;
|
|
82
|
-
}
|
|
83
|
-
if (Array.isArray(value)) {
|
|
84
|
-
return Array$1;
|
|
85
|
-
}
|
|
86
|
-
return Object$1;
|
|
87
|
-
case 'boolean':
|
|
88
|
-
return Boolean$1;
|
|
89
|
-
default:
|
|
90
|
-
return Unknown;
|
|
202
|
+
`;
|
|
91
203
|
}
|
|
204
|
+
return css;
|
|
92
205
|
};
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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');
|
|
98
213
|
};
|
|
99
214
|
|
|
100
|
-
const
|
|
101
|
-
return
|
|
102
|
-
};
|
|
103
|
-
const isMessagePortMain = value => {
|
|
104
|
-
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
105
|
-
};
|
|
106
|
-
const isOffscreenCanvas = value => {
|
|
107
|
-
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
215
|
+
const isEqual$2 = (oldState, newState) => {
|
|
216
|
+
return oldState.itemHeight === newState.itemHeight && getCustomIconSignature(oldState.filteredItems) === getCustomIconSignature(newState.filteredItems);
|
|
108
217
|
};
|
|
109
|
-
|
|
110
|
-
|
|
218
|
+
|
|
219
|
+
const isEqual$1 = (oldState, newState) => {
|
|
220
|
+
return oldState.focused === newState.focused && oldState.focus === newState.focus;
|
|
111
221
|
};
|
|
112
|
-
|
|
113
|
-
|
|
222
|
+
|
|
223
|
+
const isEqual = (oldState, newState) => {
|
|
224
|
+
return oldState.activityBarItems === newState.activityBarItems && oldState.filteredItems === newState.filteredItems && oldState.focusedIndex === newState.focusedIndex && oldState.sideBarLocation === newState.sideBarLocation && oldState.sideBarVisible === newState.sideBarVisible && oldState.updateProgress === newState.updateProgress && oldState.updateState === newState.updateState;
|
|
114
225
|
};
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
if (isTransferrable(value)) {
|
|
129
|
-
transferrables.push(value);
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
if (Array.isArray(value)) {
|
|
133
|
-
for (const item of value) {
|
|
134
|
-
walkValue(item, transferrables, isTransferrable);
|
|
135
|
-
}
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
if (typeof value === 'object') {
|
|
139
|
-
for (const property of Object.values(value)) {
|
|
140
|
-
walkValue(property, transferrables, isTransferrable);
|
|
141
|
-
}
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
const getTransferrables = value => {
|
|
146
|
-
const transferrables = [];
|
|
147
|
-
walkValue(value, transferrables, isTransferrable);
|
|
148
|
-
return transferrables;
|
|
149
|
-
};
|
|
150
|
-
const attachEvents = that => {
|
|
151
|
-
const handleMessage = (...args) => {
|
|
152
|
-
const data = that.getData(...args);
|
|
153
|
-
that.dispatchEvent(new MessageEvent('message', {
|
|
154
|
-
data
|
|
155
|
-
}));
|
|
156
|
-
};
|
|
157
|
-
that.onMessage(handleMessage);
|
|
158
|
-
const handleClose = event => {
|
|
159
|
-
that.dispatchEvent(new Event('close'));
|
|
160
|
-
};
|
|
161
|
-
that.onClose(handleClose);
|
|
162
|
-
};
|
|
163
|
-
class Ipc extends EventTarget {
|
|
164
|
-
constructor(rawIpc) {
|
|
165
|
-
super();
|
|
166
|
-
this._rawIpc = rawIpc;
|
|
167
|
-
attachEvents(this);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
171
|
-
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
172
|
-
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
173
|
-
const NewLine$1 = '\n';
|
|
174
|
-
const joinLines$1 = lines => {
|
|
175
|
-
return lines.join(NewLine$1);
|
|
176
|
-
};
|
|
177
|
-
const RE_AT = /^\s+at/;
|
|
178
|
-
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
179
|
-
const isNormalStackLine = line => {
|
|
180
|
-
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
226
|
+
|
|
227
|
+
const RenderItems = 4;
|
|
228
|
+
const RenderFocus = 6;
|
|
229
|
+
const RenderFocusContext = 7;
|
|
230
|
+
const RenderCss = 11;
|
|
231
|
+
const RenderIncremental = 12;
|
|
232
|
+
|
|
233
|
+
const modules = [isEqual, isEqual$1, isEqual$1, isEqual$2];
|
|
234
|
+
const numbers = [RenderIncremental, RenderFocus, RenderFocusContext, RenderCss];
|
|
235
|
+
|
|
236
|
+
const diff2 = uid => {
|
|
237
|
+
return diff(uid, modules, numbers);
|
|
181
238
|
};
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
while (++lastIndex < lines.length) {
|
|
192
|
-
if (!isNormalStackLine(lines[lastIndex])) {
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
239
|
+
|
|
240
|
+
const List = 1;
|
|
241
|
+
|
|
242
|
+
const focus = state => {
|
|
243
|
+
const {
|
|
244
|
+
focus
|
|
245
|
+
} = state;
|
|
246
|
+
if (focus) {
|
|
247
|
+
return state;
|
|
195
248
|
}
|
|
196
249
|
return {
|
|
197
|
-
|
|
198
|
-
|
|
250
|
+
...state,
|
|
251
|
+
focus: List
|
|
199
252
|
};
|
|
200
253
|
};
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
};
|
|
204
|
-
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
205
|
-
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
206
|
-
const isMessageCodeBlockStartIndex = line => {
|
|
207
|
-
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
208
|
-
};
|
|
209
|
-
const isMessageCodeBlockEndIndex = line => {
|
|
210
|
-
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
211
|
-
};
|
|
212
|
-
const getMessageCodeBlock = stderr => {
|
|
213
|
-
const lines = splitLines$1(stderr);
|
|
214
|
-
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
215
|
-
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
216
|
-
const relevantLines = lines.slice(startIndex, endIndex);
|
|
217
|
-
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
218
|
-
return relevantMessage;
|
|
219
|
-
};
|
|
220
|
-
const isModuleNotFoundMessage = line => {
|
|
221
|
-
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
222
|
-
};
|
|
223
|
-
const getModuleNotFoundError = stderr => {
|
|
224
|
-
const lines = splitLines$1(stderr);
|
|
225
|
-
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
226
|
-
const message = lines[messageIndex];
|
|
254
|
+
|
|
255
|
+
const focusIndex = (state, index) => {
|
|
227
256
|
return {
|
|
228
|
-
|
|
229
|
-
|
|
257
|
+
...state,
|
|
258
|
+
focused: true,
|
|
259
|
+
focusedIndex: index
|
|
230
260
|
};
|
|
231
261
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
237
|
-
};
|
|
238
|
-
const isModulesSyntaxError = stderr => {
|
|
239
|
-
if (!stderr) {
|
|
240
|
-
return false;
|
|
241
|
-
}
|
|
242
|
-
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
243
|
-
};
|
|
244
|
-
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
245
|
-
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
246
|
-
const isUnhelpfulNativeModuleError = stderr => {
|
|
247
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
262
|
+
|
|
263
|
+
const focusFirst = state => {
|
|
264
|
+
return focusIndex(state, -1);
|
|
248
265
|
};
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return
|
|
252
|
-
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
253
|
-
message: `Incompatible native node module: ${message}`
|
|
254
|
-
};
|
|
266
|
+
|
|
267
|
+
const focusLast = state => {
|
|
268
|
+
return focusIndex(state, -1);
|
|
255
269
|
};
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
message: `ES Modules are not supported in electron`
|
|
260
|
-
};
|
|
270
|
+
|
|
271
|
+
const focusNext = state => {
|
|
272
|
+
return focusIndex(state, -1);
|
|
261
273
|
};
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return getNativeModuleErrorMessage(stderr);
|
|
265
|
-
}
|
|
266
|
-
if (isModulesSyntaxError(stderr)) {
|
|
267
|
-
return getModuleSyntaxError();
|
|
268
|
-
}
|
|
269
|
-
if (isModuleNotFoundError(stderr)) {
|
|
270
|
-
return getModuleNotFoundError(stderr);
|
|
271
|
-
}
|
|
272
|
-
const lines = splitLines$1(stderr);
|
|
274
|
+
|
|
275
|
+
const focusNone = state => {
|
|
273
276
|
const {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
code: '',
|
|
279
|
-
message: actualMessage,
|
|
280
|
-
stack: rest
|
|
281
|
-
};
|
|
282
|
-
};
|
|
283
|
-
class IpcError extends VError {
|
|
284
|
-
// @ts-ignore
|
|
285
|
-
constructor(betterMessage, stdout = '', stderr = '') {
|
|
286
|
-
if (stdout || stderr) {
|
|
287
|
-
// @ts-ignore
|
|
288
|
-
const {
|
|
289
|
-
code,
|
|
290
|
-
message,
|
|
291
|
-
stack
|
|
292
|
-
} = getHelpfulChildProcessError(stdout, stderr);
|
|
293
|
-
const cause = new Error(message);
|
|
294
|
-
// @ts-ignore
|
|
295
|
-
cause.code = code;
|
|
296
|
-
cause.stack = stack;
|
|
297
|
-
super(cause, betterMessage);
|
|
298
|
-
} else {
|
|
299
|
-
super(betterMessage);
|
|
300
|
-
}
|
|
301
|
-
// @ts-ignore
|
|
302
|
-
this.name = 'IpcError';
|
|
303
|
-
// @ts-ignore
|
|
304
|
-
this.stdout = stdout;
|
|
305
|
-
// @ts-ignore
|
|
306
|
-
this.stderr = stderr;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
const readyMessage = 'ready';
|
|
310
|
-
const getData$2 = event => {
|
|
311
|
-
return event.data;
|
|
312
|
-
};
|
|
313
|
-
const listen$7 = () => {
|
|
314
|
-
// @ts-ignore
|
|
315
|
-
if (typeof WorkerGlobalScope === 'undefined') {
|
|
316
|
-
throw new TypeError('module is not in web worker scope');
|
|
277
|
+
focusedIndex
|
|
278
|
+
} = state;
|
|
279
|
+
if (focusedIndex === -1) {
|
|
280
|
+
return state;
|
|
317
281
|
}
|
|
318
|
-
return
|
|
319
|
-
};
|
|
320
|
-
const signal$8 = global => {
|
|
321
|
-
global.postMessage(readyMessage);
|
|
282
|
+
return focusIndex(state, -1);
|
|
322
283
|
};
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
const
|
|
347
|
-
|
|
284
|
+
|
|
285
|
+
const Button$2 = 'button';
|
|
286
|
+
const None$1 = 'none';
|
|
287
|
+
const Tab$1 = 'tab';
|
|
288
|
+
const ToolBar = 'toolbar';
|
|
289
|
+
|
|
290
|
+
const Div = 4;
|
|
291
|
+
const Text = 12;
|
|
292
|
+
const Reference = 100;
|
|
293
|
+
|
|
294
|
+
const Button$1 = 'event.button';
|
|
295
|
+
const ClientX = 'event.clientX';
|
|
296
|
+
const ClientY = 'event.clientY';
|
|
297
|
+
|
|
298
|
+
const Enter = 3;
|
|
299
|
+
const Space = 9;
|
|
300
|
+
const PageUp = 10;
|
|
301
|
+
const PageDown = 11;
|
|
302
|
+
const End = 255;
|
|
303
|
+
const Home = 12;
|
|
304
|
+
const UpArrow = 14;
|
|
305
|
+
const DownArrow = 16;
|
|
306
|
+
|
|
307
|
+
const ActivityBar$3 = 1;
|
|
308
|
+
const Settings$1 = 12;
|
|
309
|
+
const ActivityBarAdditionalViews = 17;
|
|
310
|
+
|
|
311
|
+
const Separator = 1;
|
|
312
|
+
const None = 0;
|
|
313
|
+
const Checked = 2;
|
|
314
|
+
const Unchecked = 3;
|
|
315
|
+
|
|
316
|
+
const LeftClick = 0;
|
|
317
|
+
|
|
318
|
+
const Web = 1;
|
|
319
|
+
|
|
320
|
+
const ExtensionManagementWorker = 9006;
|
|
321
|
+
const RendererWorker = 1;
|
|
322
|
+
|
|
323
|
+
const Left = 1;
|
|
324
|
+
const Right = 2;
|
|
325
|
+
|
|
326
|
+
const SetCss = 'Viewlet.setCss';
|
|
327
|
+
const SetDom2 = 'Viewlet.setDom2';
|
|
328
|
+
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
329
|
+
const SetPatches = 'Viewlet.setPatches';
|
|
330
|
+
|
|
331
|
+
const FocusActivityBar = 5;
|
|
332
|
+
const FocusExplorer = 13;
|
|
333
|
+
|
|
334
|
+
const getKeyBindings = () => {
|
|
335
|
+
return [{
|
|
336
|
+
command: 'ActivityBar.focusNext',
|
|
337
|
+
key: DownArrow,
|
|
338
|
+
when: FocusActivityBar
|
|
339
|
+
}, {
|
|
340
|
+
command: 'ActivityBar.focusPrevious',
|
|
341
|
+
key: UpArrow,
|
|
342
|
+
when: FocusActivityBar
|
|
343
|
+
}, {
|
|
344
|
+
command: 'ActivityBar.focusFirst',
|
|
345
|
+
key: Home,
|
|
346
|
+
when: FocusActivityBar
|
|
347
|
+
}, {
|
|
348
|
+
command: 'ActivityBar.focusFirst',
|
|
349
|
+
key: PageUp,
|
|
350
|
+
when: FocusActivityBar
|
|
351
|
+
}, {
|
|
352
|
+
command: 'ActivityBar.focusLast',
|
|
353
|
+
key: PageDown,
|
|
354
|
+
when: FocusActivityBar
|
|
355
|
+
}, {
|
|
356
|
+
command: 'ActivityBar.focusLast',
|
|
357
|
+
key: End,
|
|
358
|
+
when: FocusActivityBar
|
|
359
|
+
}, {
|
|
360
|
+
command: 'ActivityBar.selectCurrent',
|
|
361
|
+
key: Space,
|
|
362
|
+
when: FocusActivityBar
|
|
363
|
+
}, {
|
|
364
|
+
command: 'ActivityBar.selectCurrent',
|
|
365
|
+
key: Enter,
|
|
366
|
+
when: FocusActivityBar
|
|
367
|
+
}];
|
|
348
368
|
};
|
|
349
|
-
|
|
369
|
+
|
|
370
|
+
const getMenuEntriesAccountLoggedIn = state => {
|
|
350
371
|
const {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
372
|
+
userLoginState
|
|
373
|
+
} = state;
|
|
374
|
+
const signOutLabel = userLoginState === 'logging out' ? 'Signing Out...' : 'Sign Out';
|
|
375
|
+
return [{
|
|
376
|
+
command: 'ActivityBar.handleClickSignOut',
|
|
377
|
+
flags: None,
|
|
378
|
+
id: 'signOut',
|
|
379
|
+
label: signOutLabel
|
|
380
|
+
}];
|
|
360
381
|
};
|
|
361
|
-
const
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
id: firstMessage.id,
|
|
373
|
-
jsonrpc: '2.0',
|
|
374
|
-
result: null
|
|
375
|
-
});
|
|
376
|
-
parentIpc.dispose();
|
|
377
|
-
const port = firstMessage.params[1];
|
|
378
|
-
return port;
|
|
379
|
-
}
|
|
380
|
-
return globalThis;
|
|
382
|
+
const getMenuEntriesAccountLoggedOut = state => {
|
|
383
|
+
const {
|
|
384
|
+
userLoginState
|
|
385
|
+
} = state;
|
|
386
|
+
const signInLabel = userLoginState === 'logging in' ? 'Signing In...' : 'Sign In';
|
|
387
|
+
return [{
|
|
388
|
+
command: 'ActivityBar.handleClickSignIn',
|
|
389
|
+
flags: None,
|
|
390
|
+
id: 'signIn',
|
|
391
|
+
label: signInLabel
|
|
392
|
+
}];
|
|
381
393
|
};
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
sendAndTransfer(message) {
|
|
390
|
-
const transfer = getTransferrables(message);
|
|
391
|
-
this._rawIpc.postMessage(message, transfer);
|
|
392
|
-
}
|
|
393
|
-
dispose() {
|
|
394
|
-
if (this._rawIpc.close) {
|
|
395
|
-
this._rawIpc.close();
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
onClose(callback) {
|
|
399
|
-
// ignore
|
|
400
|
-
}
|
|
401
|
-
onMessage(callback) {
|
|
402
|
-
this._rawIpc.addEventListener('message', callback);
|
|
403
|
-
this._rawIpc.start();
|
|
394
|
+
const getMenuEntriesAccount = state => {
|
|
395
|
+
// TODO maybe query it now from layout?
|
|
396
|
+
const {
|
|
397
|
+
userLoginState
|
|
398
|
+
} = state;
|
|
399
|
+
if (userLoginState === 'logged in' || userLoginState === 'logging out') {
|
|
400
|
+
return getMenuEntriesAccountLoggedIn(state);
|
|
404
401
|
}
|
|
405
|
-
|
|
406
|
-
const wrap$e = port => {
|
|
407
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
408
|
-
};
|
|
409
|
-
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
410
|
-
__proto__: null,
|
|
411
|
-
listen: listen$6,
|
|
412
|
-
wrap: wrap$e
|
|
402
|
+
return getMenuEntriesAccountLoggedOut(state);
|
|
413
403
|
};
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
404
|
+
|
|
405
|
+
const Tab = 1;
|
|
406
|
+
const Button = 1 << 1;
|
|
407
|
+
const Progress = 1 << 2;
|
|
408
|
+
const Enabled = 1 << 3;
|
|
409
|
+
const Selected = 1 << 4;
|
|
410
|
+
const Focused = 1 << 5;
|
|
411
|
+
const MarginTop = 1 << 6;
|
|
412
|
+
|
|
413
|
+
const emptyObject = {};
|
|
414
|
+
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
415
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
416
|
+
if (placeholders === emptyObject) {
|
|
417
|
+
return key;
|
|
419
418
|
}
|
|
419
|
+
const replacer = (match, rest) => {
|
|
420
|
+
return placeholders[rest];
|
|
421
|
+
};
|
|
422
|
+
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
420
423
|
};
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
424
|
+
|
|
425
|
+
const Account$1 = 'Account';
|
|
426
|
+
const Explorer$1 = 'Explorer';
|
|
427
|
+
const Search$2 = 'Search';
|
|
428
|
+
const SourceControl$2 = 'Source Control';
|
|
429
|
+
const RunAndDebug$1 = 'Run and Debug';
|
|
430
|
+
const Extensions$2 = 'Extensions';
|
|
431
|
+
const Settings = 'Settings';
|
|
432
|
+
const AdditionalViews = 'Additional Views';
|
|
433
|
+
const ActivityBar$2 = 'Activity Bar';
|
|
434
|
+
const MoveSideBarLeft = 'Move Side Bar Left';
|
|
435
|
+
const MoveSideBarRight = 'Move Side Bar Right';
|
|
436
|
+
const HideActivityBar = 'Hide Activity Bar';
|
|
437
|
+
const CheckForUpdates = 'Check For Updates';
|
|
438
|
+
const ColorTheme = 'Color Theme';
|
|
439
|
+
const CommandPalette = 'Command Palette';
|
|
440
|
+
const KeyboardShortcuts = 'Keyboard Shortcuts';
|
|
441
|
+
|
|
442
|
+
const account = () => {
|
|
443
|
+
return i18nString(Account$1);
|
|
427
444
|
};
|
|
428
|
-
const
|
|
429
|
-
|
|
430
|
-
promise,
|
|
431
|
-
resolve
|
|
432
|
-
} = Promise.withResolvers();
|
|
433
|
-
const listenerMap = Object.create(null);
|
|
434
|
-
const cleanup = value => {
|
|
435
|
-
for (const event of Object.keys(eventMap)) {
|
|
436
|
-
removeListener(eventEmitter, event, listenerMap[event]);
|
|
437
|
-
}
|
|
438
|
-
resolve(value);
|
|
439
|
-
};
|
|
440
|
-
for (const [event, type] of Object.entries(eventMap)) {
|
|
441
|
-
const listener = event => {
|
|
442
|
-
cleanup({
|
|
443
|
-
event,
|
|
444
|
-
type
|
|
445
|
-
});
|
|
446
|
-
};
|
|
447
|
-
addListener(eventEmitter, event, listener);
|
|
448
|
-
listenerMap[event] = listener;
|
|
449
|
-
}
|
|
450
|
-
return promise;
|
|
445
|
+
const explorer = () => {
|
|
446
|
+
return i18nString(Explorer$1);
|
|
451
447
|
};
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
isMessagePortOpen,
|
|
455
|
-
messagePort
|
|
456
|
-
}) => {
|
|
457
|
-
if (!isMessagePort(messagePort)) {
|
|
458
|
-
throw new IpcError('port must be of type MessagePort');
|
|
459
|
-
}
|
|
460
|
-
if (isMessagePortOpen) {
|
|
461
|
-
return messagePort;
|
|
462
|
-
}
|
|
463
|
-
const eventPromise = getFirstEvent(messagePort, {
|
|
464
|
-
message: Message$1
|
|
465
|
-
});
|
|
466
|
-
messagePort.start();
|
|
467
|
-
const {
|
|
468
|
-
event,
|
|
469
|
-
type
|
|
470
|
-
} = await eventPromise;
|
|
471
|
-
if (type !== Message$1) {
|
|
472
|
-
throw new IpcError('Failed to wait for ipc message');
|
|
473
|
-
}
|
|
474
|
-
if (event.data !== readyMessage) {
|
|
475
|
-
throw new IpcError('unexpected first message');
|
|
476
|
-
}
|
|
477
|
-
return messagePort;
|
|
478
|
-
};
|
|
479
|
-
const signal$1 = messagePort => {
|
|
480
|
-
messagePort.start();
|
|
448
|
+
const search = () => {
|
|
449
|
+
return i18nString(Search$2);
|
|
481
450
|
};
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
send(message) {
|
|
485
|
-
this._rawIpc.postMessage(message);
|
|
486
|
-
}
|
|
487
|
-
sendAndTransfer(message) {
|
|
488
|
-
const transfer = getTransferrables(message);
|
|
489
|
-
this._rawIpc.postMessage(message, transfer);
|
|
490
|
-
}
|
|
491
|
-
dispose() {
|
|
492
|
-
this._rawIpc.close();
|
|
493
|
-
}
|
|
494
|
-
onMessage(callback) {
|
|
495
|
-
this._rawIpc.addEventListener('message', callback);
|
|
496
|
-
}
|
|
497
|
-
onClose(callback) {}
|
|
498
|
-
}
|
|
499
|
-
const wrap$5 = messagePort => {
|
|
500
|
-
return new IpcParentWithMessagePort(messagePort);
|
|
451
|
+
const sourceControl = () => {
|
|
452
|
+
return i18nString(SourceControl$2);
|
|
501
453
|
};
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
create: create$5$1,
|
|
505
|
-
signal: signal$1,
|
|
506
|
-
wrap: wrap$5
|
|
454
|
+
const runAndDebug = () => {
|
|
455
|
+
return i18nString(RunAndDebug$1);
|
|
507
456
|
};
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
constructor(command) {
|
|
511
|
-
super(`Command not found ${command}`);
|
|
512
|
-
this.name = 'CommandNotFoundError';
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
const commands = Object.create(null);
|
|
516
|
-
const register = commandMap => {
|
|
517
|
-
Object.assign(commands, commandMap);
|
|
457
|
+
const extensions = () => {
|
|
458
|
+
return i18nString(Extensions$2);
|
|
518
459
|
};
|
|
519
|
-
const
|
|
520
|
-
return
|
|
460
|
+
const settings = () => {
|
|
461
|
+
return i18nString(Settings);
|
|
521
462
|
};
|
|
522
|
-
const
|
|
523
|
-
|
|
524
|
-
if (!fn) {
|
|
525
|
-
throw new CommandNotFoundError(command);
|
|
526
|
-
}
|
|
527
|
-
return fn(...args);
|
|
463
|
+
const additionalViews = () => {
|
|
464
|
+
return i18nString(AdditionalViews);
|
|
528
465
|
};
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
const callbacks = Object.create(null);
|
|
532
|
-
const get$2 = id => {
|
|
533
|
-
return callbacks[id];
|
|
466
|
+
const activityBar = () => {
|
|
467
|
+
return i18nString(ActivityBar$2);
|
|
534
468
|
};
|
|
535
|
-
const
|
|
536
|
-
|
|
469
|
+
const moveSideBarRight = () => {
|
|
470
|
+
return i18nString(MoveSideBarRight);
|
|
537
471
|
};
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
super(message);
|
|
541
|
-
this.name = 'JsonRpcError';
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
const NewLine = '\n';
|
|
545
|
-
const DomException = 'DOMException';
|
|
546
|
-
const ReferenceError$1 = 'ReferenceError';
|
|
547
|
-
const SyntaxError$1 = 'SyntaxError';
|
|
548
|
-
const TypeError$1 = 'TypeError';
|
|
549
|
-
const getErrorConstructor = (message, type) => {
|
|
550
|
-
if (type) {
|
|
551
|
-
switch (type) {
|
|
552
|
-
case DomException:
|
|
553
|
-
return DOMException;
|
|
554
|
-
case ReferenceError$1:
|
|
555
|
-
return ReferenceError;
|
|
556
|
-
case SyntaxError$1:
|
|
557
|
-
return SyntaxError;
|
|
558
|
-
case TypeError$1:
|
|
559
|
-
return TypeError;
|
|
560
|
-
default:
|
|
561
|
-
return Error;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
if (message.startsWith('TypeError: ')) {
|
|
565
|
-
return TypeError;
|
|
566
|
-
}
|
|
567
|
-
if (message.startsWith('SyntaxError: ')) {
|
|
568
|
-
return SyntaxError;
|
|
569
|
-
}
|
|
570
|
-
if (message.startsWith('ReferenceError: ')) {
|
|
571
|
-
return ReferenceError;
|
|
572
|
-
}
|
|
573
|
-
return Error;
|
|
472
|
+
const moveSideBarLeft = () => {
|
|
473
|
+
return i18nString(MoveSideBarLeft);
|
|
574
474
|
};
|
|
575
|
-
const
|
|
576
|
-
|
|
577
|
-
if (ErrorConstructor === DOMException && name) {
|
|
578
|
-
return new ErrorConstructor(message, name);
|
|
579
|
-
}
|
|
580
|
-
if (ErrorConstructor === Error) {
|
|
581
|
-
const error = new Error(message);
|
|
582
|
-
if (name && name !== 'VError') {
|
|
583
|
-
error.name = name;
|
|
584
|
-
}
|
|
585
|
-
return error;
|
|
586
|
-
}
|
|
587
|
-
return new ErrorConstructor(message);
|
|
475
|
+
const hideActivityBar = () => {
|
|
476
|
+
return i18nString(HideActivityBar);
|
|
588
477
|
};
|
|
589
|
-
const
|
|
590
|
-
return
|
|
478
|
+
const checkForUpdates = () => {
|
|
479
|
+
return i18nString(CheckForUpdates);
|
|
591
480
|
};
|
|
592
|
-
const
|
|
593
|
-
return
|
|
481
|
+
const commandPalette = () => {
|
|
482
|
+
return i18nString(CommandPalette);
|
|
594
483
|
};
|
|
595
|
-
const
|
|
596
|
-
|
|
597
|
-
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
598
|
-
return currentStack;
|
|
484
|
+
const keyboardShortcuts = () => {
|
|
485
|
+
return i18nString(KeyboardShortcuts);
|
|
599
486
|
};
|
|
600
|
-
const
|
|
601
|
-
return
|
|
487
|
+
const colorTheme = () => {
|
|
488
|
+
return i18nString(ColorTheme);
|
|
602
489
|
};
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
490
|
+
|
|
491
|
+
const menuEntryMoveSideBar = sideBarLocation => {
|
|
492
|
+
switch (sideBarLocation) {
|
|
493
|
+
case Left:
|
|
494
|
+
return {
|
|
495
|
+
command: 'Layout.moveSideBarRight',
|
|
496
|
+
flags: None,
|
|
497
|
+
id: 'moveSideBarRight',
|
|
498
|
+
label: moveSideBarRight()
|
|
499
|
+
};
|
|
500
|
+
case Right:
|
|
501
|
+
return {
|
|
502
|
+
command: 'Layout.moveSideBarLeft',
|
|
503
|
+
flags: None,
|
|
504
|
+
id: 'moveSideBarLeft',
|
|
505
|
+
label: moveSideBarLeft()
|
|
506
|
+
};
|
|
507
|
+
default:
|
|
508
|
+
throw new Error('unexpected side bar location');
|
|
607
509
|
}
|
|
608
|
-
return parentStack;
|
|
609
510
|
};
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
511
|
+
|
|
512
|
+
const menuEntrySeparator = {
|
|
513
|
+
command: '',
|
|
514
|
+
flags: Separator,
|
|
515
|
+
id: 'separator',
|
|
516
|
+
label: ''
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
const toContextMenuItem$1 = activityBarItem => {
|
|
520
|
+
const isEnabled = activityBarItem.flags & Enabled;
|
|
521
|
+
return {
|
|
522
|
+
args: [activityBarItem.id],
|
|
523
|
+
command: 'ActivityBar.toggleActivityBarItem',
|
|
524
|
+
flags: isEnabled ? Checked : Unchecked,
|
|
525
|
+
id: `toggle-${activityBarItem.id}`,
|
|
526
|
+
label: activityBarItem.id
|
|
527
|
+
};
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
const getMenuEntriesActivityBar = state => {
|
|
531
|
+
const {
|
|
532
|
+
activityBarItems,
|
|
533
|
+
sideBarLocation
|
|
534
|
+
} = state;
|
|
535
|
+
const topItems = activityBarItems.filter(item => !(item.flags & Button));
|
|
536
|
+
const bottomItems = activityBarItems.filter(item => item.flags & Button);
|
|
537
|
+
const entries = topItems.map(toContextMenuItem$1);
|
|
538
|
+
if (bottomItems.length > 0) {
|
|
539
|
+
entries.push(menuEntrySeparator, ...bottomItems.map(toContextMenuItem$1));
|
|
619
540
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
541
|
+
return [...entries, menuEntrySeparator, menuEntryMoveSideBar(sideBarLocation), {
|
|
542
|
+
command: 'Layout.hideActivityBar',
|
|
543
|
+
flags: None,
|
|
544
|
+
id: 'hideActivityBar',
|
|
545
|
+
label: hideActivityBar()
|
|
546
|
+
}];
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
const getNumberOfVisibleItems = state => {
|
|
550
|
+
const {
|
|
551
|
+
height,
|
|
552
|
+
itemHeight
|
|
553
|
+
} = state;
|
|
554
|
+
const numberOfVisibleItemsTop = Math.floor(height / itemHeight);
|
|
555
|
+
return numberOfVisibleItemsTop;
|
|
556
|
+
};
|
|
557
|
+
const getHiddenItems = state => {
|
|
558
|
+
const numberOfVisibleItems = getNumberOfVisibleItems(state);
|
|
559
|
+
const items = state.activityBarItems.filter(item => item.flags & Enabled);
|
|
560
|
+
if (numberOfVisibleItems >= items.length) {
|
|
561
|
+
return [];
|
|
625
562
|
}
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
563
|
+
return items.slice(numberOfVisibleItems - 2, -1);
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
const toContextMenuItem = activityBarItem => {
|
|
567
|
+
return {
|
|
568
|
+
command: '-1',
|
|
569
|
+
// TODO
|
|
570
|
+
flags: None,
|
|
571
|
+
id: '8000',
|
|
572
|
+
// TODO
|
|
573
|
+
label: activityBarItem.id
|
|
574
|
+
};
|
|
575
|
+
};
|
|
576
|
+
const getMenuEntriesAdditionalViews = state => {
|
|
577
|
+
const hiddenActivityBarItems = getHiddenItems(state);
|
|
578
|
+
return hiddenActivityBarItems.map(toContextMenuItem);
|
|
579
|
+
};
|
|
580
|
+
|
|
581
|
+
const keyBindingsUri = 'app://keybindings';
|
|
582
|
+
const getMenuEntriesSettings = state => {
|
|
583
|
+
const {
|
|
584
|
+
platform
|
|
585
|
+
} = state;
|
|
586
|
+
const items = [{
|
|
587
|
+
command: 'QuickPick.showEverything',
|
|
588
|
+
flags: None,
|
|
589
|
+
id: 'commandPalette',
|
|
590
|
+
label: commandPalette()
|
|
591
|
+
}, menuEntrySeparator, {
|
|
592
|
+
command: 'Preferences.openSettingsJson',
|
|
593
|
+
flags: None,
|
|
594
|
+
id: 'settings',
|
|
595
|
+
label: settings()
|
|
596
|
+
}, {
|
|
597
|
+
args: [keyBindingsUri],
|
|
598
|
+
command: 'Main.openUri',
|
|
599
|
+
flags: None,
|
|
600
|
+
id: 'keyboardShortcuts',
|
|
601
|
+
label: keyboardShortcuts()
|
|
602
|
+
}, {
|
|
603
|
+
command: 'QuickPick.showColorTheme',
|
|
604
|
+
flags: None,
|
|
605
|
+
id: 'colorTheme',
|
|
606
|
+
label: colorTheme()
|
|
607
|
+
}];
|
|
608
|
+
if (platform !== Web) {
|
|
609
|
+
items.push(menuEntrySeparator, {
|
|
610
|
+
command: 'AutoUpdater.checkForUpdates',
|
|
611
|
+
flags: None,
|
|
612
|
+
id: 'checkForUpdates',
|
|
613
|
+
label: checkForUpdates()
|
|
614
|
+
});
|
|
664
615
|
}
|
|
665
|
-
return
|
|
616
|
+
return items;
|
|
666
617
|
};
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
618
|
+
|
|
619
|
+
const normalizeLine = line => {
|
|
620
|
+
if (line.startsWith('Error: ')) {
|
|
621
|
+
return line.slice('Error: '.length);
|
|
671
622
|
}
|
|
672
|
-
if ('
|
|
673
|
-
return
|
|
623
|
+
if (line.startsWith('VError: ')) {
|
|
624
|
+
return line.slice('VError: '.length);
|
|
674
625
|
}
|
|
675
|
-
|
|
676
|
-
};
|
|
677
|
-
const warn = (...args) => {
|
|
678
|
-
console.warn(...args);
|
|
626
|
+
return line;
|
|
679
627
|
};
|
|
680
|
-
const
|
|
681
|
-
const
|
|
682
|
-
if (
|
|
683
|
-
|
|
684
|
-
warn(`callback ${id} may already be disposed`);
|
|
685
|
-
return;
|
|
628
|
+
const getCombinedMessage = (error, message) => {
|
|
629
|
+
const stringifiedError = normalizeLine(`${error}`);
|
|
630
|
+
if (message) {
|
|
631
|
+
return `${message}: ${stringifiedError}`;
|
|
686
632
|
}
|
|
687
|
-
|
|
688
|
-
remove$1(id);
|
|
633
|
+
return stringifiedError;
|
|
689
634
|
};
|
|
690
|
-
const
|
|
691
|
-
const
|
|
692
|
-
|
|
693
|
-
|
|
635
|
+
const NewLine$2 = '\n';
|
|
636
|
+
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
637
|
+
return string.indexOf(NewLine$2, startIndex);
|
|
638
|
+
};
|
|
639
|
+
const mergeStacks = (parent, child) => {
|
|
640
|
+
if (!child) {
|
|
641
|
+
return parent;
|
|
694
642
|
}
|
|
695
|
-
|
|
696
|
-
|
|
643
|
+
const parentNewLineIndex = getNewLineIndex$1(parent);
|
|
644
|
+
const childNewLineIndex = getNewLineIndex$1(child);
|
|
645
|
+
if (childNewLineIndex === -1) {
|
|
646
|
+
return parent;
|
|
697
647
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
const
|
|
701
|
-
|
|
648
|
+
const parentFirstLine = parent.slice(0, parentNewLineIndex);
|
|
649
|
+
const childRest = child.slice(childNewLineIndex);
|
|
650
|
+
const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
|
|
651
|
+
if (parentFirstLine.includes(childFirstLine)) {
|
|
652
|
+
return parentFirstLine + childRest;
|
|
653
|
+
}
|
|
654
|
+
return child;
|
|
702
655
|
};
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
656
|
+
class VError extends Error {
|
|
657
|
+
constructor(error, message) {
|
|
658
|
+
const combinedMessage = getCombinedMessage(error, message);
|
|
659
|
+
super(combinedMessage);
|
|
660
|
+
this.name = 'VError';
|
|
661
|
+
if (error instanceof Error) {
|
|
662
|
+
this.stack = mergeStacks(this.stack, error.stack);
|
|
663
|
+
}
|
|
664
|
+
if (error.codeFrame) {
|
|
665
|
+
// @ts-ignore
|
|
666
|
+
this.codeFrame = error.codeFrame;
|
|
667
|
+
}
|
|
668
|
+
if (error.code) {
|
|
669
|
+
// @ts-ignore
|
|
670
|
+
this.code = error.code;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
class AssertionError extends Error {
|
|
676
|
+
constructor(message) {
|
|
677
|
+
super(message);
|
|
678
|
+
this.name = 'AssertionError';
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
const Object$1 = 1;
|
|
682
|
+
const Number$1 = 2;
|
|
683
|
+
const Array$1 = 3;
|
|
684
|
+
const String$1 = 4;
|
|
685
|
+
const Boolean$1 = 5;
|
|
686
|
+
const Function = 6;
|
|
687
|
+
const Null = 7;
|
|
688
|
+
const Unknown = 8;
|
|
689
|
+
const getType = value => {
|
|
690
|
+
switch (typeof value) {
|
|
691
|
+
case 'number':
|
|
692
|
+
return Number$1;
|
|
693
|
+
case 'function':
|
|
694
|
+
return Function;
|
|
695
|
+
case 'string':
|
|
696
|
+
return String$1;
|
|
697
|
+
case 'object':
|
|
698
|
+
if (value === null) {
|
|
699
|
+
return Null;
|
|
700
|
+
}
|
|
701
|
+
if (Array.isArray(value)) {
|
|
702
|
+
return Array$1;
|
|
703
|
+
}
|
|
704
|
+
return Object$1;
|
|
705
|
+
case 'boolean':
|
|
706
|
+
return Boolean$1;
|
|
707
|
+
default:
|
|
708
|
+
return Unknown;
|
|
708
709
|
}
|
|
709
|
-
return stackString;
|
|
710
710
|
};
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
data: error.stack,
|
|
716
|
-
message: error.message
|
|
717
|
-
};
|
|
711
|
+
const number = value => {
|
|
712
|
+
const type = getType(value);
|
|
713
|
+
if (type !== Number$1) {
|
|
714
|
+
throw new AssertionError('expected value to be of type number');
|
|
718
715
|
}
|
|
719
|
-
return {
|
|
720
|
-
code: Custom,
|
|
721
|
-
data: {
|
|
722
|
-
code: prettyError.code,
|
|
723
|
-
codeFrame: prettyError.codeFrame,
|
|
724
|
-
name: prettyError.name,
|
|
725
|
-
stack: getStack(prettyError),
|
|
726
|
-
type: getErrorType(prettyError)
|
|
727
|
-
},
|
|
728
|
-
message: prettyError.message
|
|
729
|
-
};
|
|
730
716
|
};
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
id,
|
|
735
|
-
jsonrpc: Two$1
|
|
736
|
-
};
|
|
717
|
+
|
|
718
|
+
const isMessagePort = value => {
|
|
719
|
+
return value && value instanceof MessagePort;
|
|
737
720
|
};
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
logError(error, prettyError);
|
|
741
|
-
const errorProperty = getErrorProperty(error, prettyError);
|
|
742
|
-
return create$1$1(id, errorProperty);
|
|
721
|
+
const isMessagePortMain = value => {
|
|
722
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
743
723
|
};
|
|
744
|
-
const
|
|
745
|
-
return
|
|
746
|
-
id: message.id,
|
|
747
|
-
jsonrpc: Two$1,
|
|
748
|
-
result: result ?? null
|
|
749
|
-
};
|
|
724
|
+
const isOffscreenCanvas = value => {
|
|
725
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
750
726
|
};
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
return create$a(message, resultProperty);
|
|
727
|
+
const isInstanceOf = (value, constructorName) => {
|
|
728
|
+
return value?.constructor?.name === constructorName;
|
|
754
729
|
};
|
|
755
|
-
const
|
|
756
|
-
return
|
|
757
|
-
error: {
|
|
758
|
-
code: Custom,
|
|
759
|
-
data: error,
|
|
760
|
-
// @ts-ignore
|
|
761
|
-
message: error.message
|
|
762
|
-
},
|
|
763
|
-
id,
|
|
764
|
-
jsonrpc: Two$1
|
|
765
|
-
};
|
|
730
|
+
const isSocket = value => {
|
|
731
|
+
return isInstanceOf(value, 'Socket');
|
|
766
732
|
};
|
|
767
|
-
const
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
if (ipc.canUseSimpleErrorResponse) {
|
|
773
|
-
return getErrorResponseSimple(message.id, error);
|
|
733
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
734
|
+
const isTransferrable = value => {
|
|
735
|
+
for (const fn of transferrables) {
|
|
736
|
+
if (fn(value)) {
|
|
737
|
+
return true;
|
|
774
738
|
}
|
|
775
|
-
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
776
739
|
}
|
|
777
|
-
};
|
|
778
|
-
const defaultPreparePrettyError = error => {
|
|
779
|
-
return error;
|
|
780
|
-
};
|
|
781
|
-
const defaultLogError = () => {
|
|
782
|
-
// ignore
|
|
783
|
-
};
|
|
784
|
-
const defaultRequiresSocket = () => {
|
|
785
740
|
return false;
|
|
786
741
|
};
|
|
787
|
-
const
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
const normalizeParams = args => {
|
|
791
|
-
if (args.length === 1) {
|
|
792
|
-
const options = args[0];
|
|
793
|
-
return {
|
|
794
|
-
execute: options.execute,
|
|
795
|
-
ipc: options.ipc,
|
|
796
|
-
logError: options.logError || defaultLogError,
|
|
797
|
-
message: options.message,
|
|
798
|
-
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
799
|
-
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
800
|
-
resolve: options.resolve || defaultResolve
|
|
801
|
-
};
|
|
742
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
743
|
+
if (!value) {
|
|
744
|
+
return;
|
|
802
745
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
resolve: args[3]
|
|
811
|
-
};
|
|
812
|
-
};
|
|
813
|
-
const handleJsonRpcMessage = async (...args) => {
|
|
814
|
-
const options = normalizeParams(args);
|
|
815
|
-
const {
|
|
816
|
-
execute,
|
|
817
|
-
ipc,
|
|
818
|
-
logError,
|
|
819
|
-
message,
|
|
820
|
-
preparePrettyError,
|
|
821
|
-
requiresSocket,
|
|
822
|
-
resolve
|
|
823
|
-
} = options;
|
|
824
|
-
if ('id' in message) {
|
|
825
|
-
if ('method' in message) {
|
|
826
|
-
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
827
|
-
try {
|
|
828
|
-
ipc.send(response);
|
|
829
|
-
} catch (error) {
|
|
830
|
-
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
831
|
-
ipc.send(errorResponse);
|
|
832
|
-
}
|
|
833
|
-
return;
|
|
746
|
+
if (isTransferrable(value)) {
|
|
747
|
+
transferrables.push(value);
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
if (Array.isArray(value)) {
|
|
751
|
+
for (const item of value) {
|
|
752
|
+
walkValue(item, transferrables, isTransferrable);
|
|
834
753
|
}
|
|
835
|
-
resolve(message.id, message);
|
|
836
754
|
return;
|
|
837
755
|
}
|
|
838
|
-
if ('
|
|
839
|
-
|
|
756
|
+
if (typeof value === 'object') {
|
|
757
|
+
for (const property of Object.values(value)) {
|
|
758
|
+
walkValue(property, transferrables, isTransferrable);
|
|
759
|
+
}
|
|
840
760
|
return;
|
|
841
761
|
}
|
|
842
|
-
throw new JsonRpcError('unexpected message');
|
|
843
762
|
};
|
|
844
|
-
|
|
845
|
-
const
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
return {
|
|
849
|
-
jsonrpc: Two,
|
|
850
|
-
method,
|
|
851
|
-
params
|
|
852
|
-
};
|
|
763
|
+
const getTransferrables = value => {
|
|
764
|
+
const transferrables = [];
|
|
765
|
+
walkValue(value, transferrables, isTransferrable);
|
|
766
|
+
return transferrables;
|
|
853
767
|
};
|
|
854
|
-
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
params
|
|
768
|
+
const attachEvents = that => {
|
|
769
|
+
const handleMessage = (...args) => {
|
|
770
|
+
const data = that.getData(...args);
|
|
771
|
+
that.dispatchEvent(new MessageEvent('message', {
|
|
772
|
+
data
|
|
773
|
+
}));
|
|
861
774
|
};
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
let id = 0;
|
|
866
|
-
const create$7 = () => {
|
|
867
|
-
return ++id;
|
|
868
|
-
};
|
|
869
|
-
|
|
870
|
-
const registerPromise = map => {
|
|
871
|
-
const id = create$7();
|
|
872
|
-
const {
|
|
873
|
-
promise,
|
|
874
|
-
resolve
|
|
875
|
-
} = Promise.withResolvers();
|
|
876
|
-
map[id] = resolve;
|
|
877
|
-
return {
|
|
878
|
-
id,
|
|
879
|
-
promise
|
|
775
|
+
that.onMessage(handleMessage);
|
|
776
|
+
const handleClose = event => {
|
|
777
|
+
that.dispatchEvent(new Event('close'));
|
|
880
778
|
};
|
|
779
|
+
that.onClose(handleClose);
|
|
881
780
|
};
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
} = registerPromise(callbacks);
|
|
888
|
-
const message = create$8(id, method, params);
|
|
889
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
890
|
-
ipc.sendAndTransfer(message);
|
|
891
|
-
} else {
|
|
892
|
-
ipc.send(message);
|
|
781
|
+
class Ipc extends EventTarget {
|
|
782
|
+
constructor(rawIpc) {
|
|
783
|
+
super();
|
|
784
|
+
this._rawIpc = rawIpc;
|
|
785
|
+
attachEvents(this);
|
|
893
786
|
}
|
|
894
|
-
|
|
895
|
-
|
|
787
|
+
}
|
|
788
|
+
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
789
|
+
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
790
|
+
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
791
|
+
const NewLine$1 = '\n';
|
|
792
|
+
const joinLines$1 = lines => {
|
|
793
|
+
return lines.join(NewLine$1);
|
|
896
794
|
};
|
|
897
|
-
const
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
},
|
|
915
|
-
invokeAndTransfer(method, ...params) {
|
|
916
|
-
return invokeHelper(callbacks, ipc, method, params, true);
|
|
917
|
-
},
|
|
918
|
-
// @ts-ignore
|
|
919
|
-
ipc,
|
|
920
|
-
/**
|
|
921
|
-
* @deprecated
|
|
922
|
-
*/
|
|
923
|
-
send(method, ...params) {
|
|
924
|
-
const message = create$9(method, params);
|
|
925
|
-
ipc.send(message);
|
|
795
|
+
const RE_AT = /^\s+at/;
|
|
796
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
797
|
+
const isNormalStackLine = line => {
|
|
798
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
799
|
+
};
|
|
800
|
+
const getDetails = lines => {
|
|
801
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
802
|
+
if (index === -1) {
|
|
803
|
+
return {
|
|
804
|
+
actualMessage: joinLines$1(lines),
|
|
805
|
+
rest: []
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
let lastIndex = index - 1;
|
|
809
|
+
while (++lastIndex < lines.length) {
|
|
810
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
811
|
+
break;
|
|
926
812
|
}
|
|
813
|
+
}
|
|
814
|
+
return {
|
|
815
|
+
actualMessage: lines[index - 1],
|
|
816
|
+
rest: lines.slice(index, lastIndex)
|
|
927
817
|
};
|
|
928
|
-
return rpc;
|
|
929
818
|
};
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
return false;
|
|
933
|
-
};
|
|
934
|
-
const preparePrettyError = error => {
|
|
935
|
-
return error;
|
|
819
|
+
const splitLines$1 = lines => {
|
|
820
|
+
return lines.split(NewLine$1);
|
|
936
821
|
};
|
|
937
|
-
const
|
|
938
|
-
|
|
822
|
+
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
823
|
+
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
824
|
+
const isMessageCodeBlockStartIndex = line => {
|
|
825
|
+
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
939
826
|
};
|
|
940
|
-
const
|
|
941
|
-
|
|
942
|
-
const actualExecute = event?.target?.execute || execute;
|
|
943
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
827
|
+
const isMessageCodeBlockEndIndex = line => {
|
|
828
|
+
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
944
829
|
};
|
|
945
|
-
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
}
|
|
830
|
+
const getMessageCodeBlock = stderr => {
|
|
831
|
+
const lines = splitLines$1(stderr);
|
|
832
|
+
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
833
|
+
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
834
|
+
const relevantLines = lines.slice(startIndex, endIndex);
|
|
835
|
+
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
836
|
+
return relevantMessage;
|
|
953
837
|
};
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
const rawIpc = await module.listen(options);
|
|
957
|
-
if (module.signal) {
|
|
958
|
-
module.signal(rawIpc);
|
|
959
|
-
}
|
|
960
|
-
const ipc = module.wrap(rawIpc);
|
|
961
|
-
return ipc;
|
|
838
|
+
const isModuleNotFoundMessage = line => {
|
|
839
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
962
840
|
};
|
|
963
|
-
|
|
964
|
-
const
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
messagePort
|
|
968
|
-
}) => {
|
|
969
|
-
// TODO create a commandMap per rpc instance
|
|
970
|
-
register(commandMap);
|
|
971
|
-
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
972
|
-
isMessagePortOpen,
|
|
973
|
-
messagePort
|
|
974
|
-
});
|
|
975
|
-
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
976
|
-
handleIpc(ipc);
|
|
977
|
-
const rpc = createRpc(ipc);
|
|
978
|
-
messagePort.start();
|
|
979
|
-
return rpc;
|
|
980
|
-
};
|
|
981
|
-
|
|
982
|
-
const create$5 = async ({
|
|
983
|
-
commandMap,
|
|
984
|
-
isMessagePortOpen,
|
|
985
|
-
send
|
|
986
|
-
}) => {
|
|
987
|
-
const {
|
|
988
|
-
port1,
|
|
989
|
-
port2
|
|
990
|
-
} = new MessageChannel();
|
|
991
|
-
await send(port1);
|
|
992
|
-
return create$6({
|
|
993
|
-
commandMap,
|
|
994
|
-
isMessagePortOpen,
|
|
995
|
-
messagePort: port2
|
|
996
|
-
});
|
|
997
|
-
};
|
|
998
|
-
|
|
999
|
-
const createSharedLazyRpc = factory => {
|
|
1000
|
-
let rpcPromise;
|
|
1001
|
-
const getOrCreate = () => {
|
|
1002
|
-
if (!rpcPromise) {
|
|
1003
|
-
rpcPromise = factory();
|
|
1004
|
-
}
|
|
1005
|
-
return rpcPromise;
|
|
1006
|
-
};
|
|
841
|
+
const getModuleNotFoundError = stderr => {
|
|
842
|
+
const lines = splitLines$1(stderr);
|
|
843
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
844
|
+
const message = lines[messageIndex];
|
|
1007
845
|
return {
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
await rpc.dispose();
|
|
1011
|
-
},
|
|
1012
|
-
async invoke(method, ...params) {
|
|
1013
|
-
const rpc = await getOrCreate();
|
|
1014
|
-
return rpc.invoke(method, ...params);
|
|
1015
|
-
},
|
|
1016
|
-
async invokeAndTransfer(method, ...params) {
|
|
1017
|
-
const rpc = await getOrCreate();
|
|
1018
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
1019
|
-
},
|
|
1020
|
-
async send(method, ...params) {
|
|
1021
|
-
const rpc = await getOrCreate();
|
|
1022
|
-
rpc.send(method, ...params);
|
|
1023
|
-
}
|
|
846
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
847
|
+
message
|
|
1024
848
|
};
|
|
1025
849
|
};
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
}) => {
|
|
1032
|
-
return createSharedLazyRpc(() => {
|
|
1033
|
-
return create$5({
|
|
1034
|
-
commandMap,
|
|
1035
|
-
isMessagePortOpen,
|
|
1036
|
-
send
|
|
1037
|
-
});
|
|
1038
|
-
});
|
|
850
|
+
const isModuleNotFoundError = stderr => {
|
|
851
|
+
if (!stderr) {
|
|
852
|
+
return false;
|
|
853
|
+
}
|
|
854
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
1039
855
|
};
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
register(commandMap);
|
|
1046
|
-
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1047
|
-
handleIpc(ipc);
|
|
1048
|
-
const rpc = createRpc(ipc);
|
|
1049
|
-
return rpc;
|
|
856
|
+
const isModulesSyntaxError = stderr => {
|
|
857
|
+
if (!stderr) {
|
|
858
|
+
return false;
|
|
859
|
+
}
|
|
860
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
1050
861
|
};
|
|
1051
|
-
|
|
1052
|
-
const
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
}
|
|
1062
|
-
return command(...params);
|
|
862
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
863
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
864
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
865
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
866
|
+
};
|
|
867
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
868
|
+
const message = getMessageCodeBlock(stderr);
|
|
869
|
+
return {
|
|
870
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
871
|
+
message: `Incompatible native node module: ${message}`
|
|
1063
872
|
};
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
873
|
+
};
|
|
874
|
+
const getModuleSyntaxError = () => {
|
|
875
|
+
return {
|
|
876
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
877
|
+
message: `ES Modules are not supported in electron`
|
|
1068
878
|
};
|
|
1069
|
-
return mockRpc;
|
|
1070
879
|
};
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
880
|
+
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
881
|
+
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
882
|
+
return getNativeModuleErrorMessage(stderr);
|
|
883
|
+
}
|
|
884
|
+
if (isModulesSyntaxError(stderr)) {
|
|
885
|
+
return getModuleSyntaxError();
|
|
886
|
+
}
|
|
887
|
+
if (isModuleNotFoundError(stderr)) {
|
|
888
|
+
return getModuleNotFoundError(stderr);
|
|
889
|
+
}
|
|
890
|
+
const lines = splitLines$1(stderr);
|
|
891
|
+
const {
|
|
892
|
+
actualMessage,
|
|
893
|
+
rest
|
|
894
|
+
} = getDetails(lines);
|
|
895
|
+
return {
|
|
896
|
+
code: '',
|
|
897
|
+
message: actualMessage,
|
|
898
|
+
stack: rest
|
|
899
|
+
};
|
|
1075
900
|
};
|
|
1076
|
-
|
|
1077
|
-
|
|
901
|
+
class IpcError extends VError {
|
|
902
|
+
// @ts-ignore
|
|
903
|
+
constructor(betterMessage, stdout = '', stderr = '') {
|
|
904
|
+
if (stdout || stderr) {
|
|
905
|
+
// @ts-ignore
|
|
906
|
+
const {
|
|
907
|
+
code,
|
|
908
|
+
message,
|
|
909
|
+
stack
|
|
910
|
+
} = getHelpfulChildProcessError(stdout, stderr);
|
|
911
|
+
const cause = new Error(message);
|
|
912
|
+
// @ts-ignore
|
|
913
|
+
cause.code = code;
|
|
914
|
+
cause.stack = stack;
|
|
915
|
+
super(cause, betterMessage);
|
|
916
|
+
} else {
|
|
917
|
+
super(betterMessage);
|
|
918
|
+
}
|
|
919
|
+
// @ts-ignore
|
|
920
|
+
this.name = 'IpcError';
|
|
921
|
+
// @ts-ignore
|
|
922
|
+
this.stdout = stdout;
|
|
923
|
+
// @ts-ignore
|
|
924
|
+
this.stderr = stderr;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
const readyMessage = 'ready';
|
|
928
|
+
const getData$2 = event => {
|
|
929
|
+
return event.data;
|
|
1078
930
|
};
|
|
1079
|
-
const
|
|
1080
|
-
|
|
931
|
+
const listen$7 = () => {
|
|
932
|
+
// @ts-ignore
|
|
933
|
+
if (typeof WorkerGlobalScope === 'undefined') {
|
|
934
|
+
throw new TypeError('module is not in web worker scope');
|
|
935
|
+
}
|
|
936
|
+
return globalThis;
|
|
1081
937
|
};
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
938
|
+
const signal$8 = global => {
|
|
939
|
+
global.postMessage(readyMessage);
|
|
940
|
+
};
|
|
941
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
942
|
+
getData(event) {
|
|
943
|
+
return getData$2(event);
|
|
944
|
+
}
|
|
945
|
+
send(message) {
|
|
1090
946
|
// @ts-ignore
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
},
|
|
947
|
+
this._rawIpc.postMessage(message);
|
|
948
|
+
}
|
|
949
|
+
sendAndTransfer(message) {
|
|
950
|
+
const transfer = getTransferrables(message);
|
|
1096
951
|
// @ts-ignore
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
952
|
+
this._rawIpc.postMessage(message, transfer);
|
|
953
|
+
}
|
|
954
|
+
dispose() {
|
|
955
|
+
// ignore
|
|
956
|
+
}
|
|
957
|
+
onClose(callback) {
|
|
958
|
+
// ignore
|
|
959
|
+
}
|
|
960
|
+
onMessage(callback) {
|
|
961
|
+
this._rawIpc.addEventListener('message', callback);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
const wrap$f = global => {
|
|
965
|
+
return new IpcChildWithModuleWorker(global);
|
|
966
|
+
};
|
|
967
|
+
const waitForFirstMessage = async port => {
|
|
968
|
+
const {
|
|
969
|
+
promise,
|
|
970
|
+
resolve
|
|
971
|
+
} = Promise.withResolvers();
|
|
972
|
+
port.addEventListener('message', resolve, {
|
|
973
|
+
once: true
|
|
974
|
+
});
|
|
975
|
+
const event = await promise;
|
|
976
|
+
// @ts-ignore
|
|
977
|
+
return event.data;
|
|
978
|
+
};
|
|
979
|
+
const listen$6 = async () => {
|
|
980
|
+
const parentIpcRaw = listen$7();
|
|
981
|
+
signal$8(parentIpcRaw);
|
|
982
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
|
983
|
+
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
984
|
+
if (firstMessage.method !== 'initialize') {
|
|
985
|
+
throw new IpcError('unexpected first message');
|
|
986
|
+
}
|
|
987
|
+
const type = firstMessage.params[0];
|
|
988
|
+
if (type === 'message-port') {
|
|
989
|
+
parentIpc.send({
|
|
990
|
+
id: firstMessage.id,
|
|
991
|
+
jsonrpc: '2.0',
|
|
992
|
+
result: null
|
|
993
|
+
});
|
|
994
|
+
parentIpc.dispose();
|
|
995
|
+
const port = firstMessage.params[1];
|
|
996
|
+
return port;
|
|
997
|
+
}
|
|
998
|
+
return globalThis;
|
|
999
|
+
};
|
|
1000
|
+
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
1001
|
+
getData(event) {
|
|
1002
|
+
return getData$2(event);
|
|
1003
|
+
}
|
|
1004
|
+
send(message) {
|
|
1005
|
+
this._rawIpc.postMessage(message);
|
|
1006
|
+
}
|
|
1007
|
+
sendAndTransfer(message) {
|
|
1008
|
+
const transfer = getTransferrables(message);
|
|
1009
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1010
|
+
}
|
|
1011
|
+
dispose() {
|
|
1012
|
+
if (this._rawIpc.close) {
|
|
1013
|
+
this._rawIpc.close();
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
onClose(callback) {
|
|
1017
|
+
// ignore
|
|
1018
|
+
}
|
|
1019
|
+
onMessage(callback) {
|
|
1020
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1021
|
+
this._rawIpc.start();
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
const wrap$e = port => {
|
|
1025
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
1026
|
+
};
|
|
1027
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
1028
|
+
__proto__: null,
|
|
1029
|
+
listen: listen$6,
|
|
1030
|
+
wrap: wrap$e
|
|
1031
|
+
};
|
|
1032
|
+
const addListener = (emitter, type, callback) => {
|
|
1033
|
+
if ('addEventListener' in emitter) {
|
|
1034
|
+
emitter.addEventListener(type, callback);
|
|
1035
|
+
} else {
|
|
1036
|
+
emitter.on(type, callback);
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
const removeListener = (emitter, type, callback) => {
|
|
1040
|
+
if ('removeEventListener' in emitter) {
|
|
1041
|
+
emitter.removeEventListener(type, callback);
|
|
1042
|
+
} else {
|
|
1043
|
+
emitter.off(type, callback);
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
1047
|
+
const {
|
|
1048
|
+
promise,
|
|
1049
|
+
resolve
|
|
1050
|
+
} = Promise.withResolvers();
|
|
1051
|
+
const listenerMap = Object.create(null);
|
|
1052
|
+
const cleanup = value => {
|
|
1053
|
+
for (const event of Object.keys(eventMap)) {
|
|
1054
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
1055
|
+
}
|
|
1056
|
+
resolve(value);
|
|
1057
|
+
};
|
|
1058
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
1059
|
+
const listener = event => {
|
|
1060
|
+
cleanup({
|
|
1061
|
+
event,
|
|
1062
|
+
type
|
|
1063
|
+
});
|
|
1064
|
+
};
|
|
1065
|
+
addListener(eventEmitter, event, listener);
|
|
1066
|
+
listenerMap[event] = listener;
|
|
1067
|
+
}
|
|
1068
|
+
return promise;
|
|
1069
|
+
};
|
|
1070
|
+
const Message$1 = 3;
|
|
1071
|
+
const create$5$1 = async ({
|
|
1072
|
+
isMessagePortOpen,
|
|
1073
|
+
messagePort
|
|
1074
|
+
}) => {
|
|
1075
|
+
if (!isMessagePort(messagePort)) {
|
|
1076
|
+
throw new IpcError('port must be of type MessagePort');
|
|
1077
|
+
}
|
|
1078
|
+
if (isMessagePortOpen) {
|
|
1079
|
+
return messagePort;
|
|
1080
|
+
}
|
|
1081
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
1082
|
+
message: Message$1
|
|
1083
|
+
});
|
|
1084
|
+
messagePort.start();
|
|
1085
|
+
const {
|
|
1086
|
+
event,
|
|
1087
|
+
type
|
|
1088
|
+
} = await eventPromise;
|
|
1089
|
+
if (type !== Message$1) {
|
|
1090
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
1091
|
+
}
|
|
1092
|
+
if (event.data !== readyMessage) {
|
|
1093
|
+
throw new IpcError('unexpected first message');
|
|
1094
|
+
}
|
|
1095
|
+
return messagePort;
|
|
1096
|
+
};
|
|
1097
|
+
const signal$1 = messagePort => {
|
|
1098
|
+
messagePort.start();
|
|
1099
|
+
};
|
|
1100
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
1101
|
+
getData = getData$2;
|
|
1102
|
+
send(message) {
|
|
1103
|
+
this._rawIpc.postMessage(message);
|
|
1104
|
+
}
|
|
1105
|
+
sendAndTransfer(message) {
|
|
1106
|
+
const transfer = getTransferrables(message);
|
|
1107
|
+
this._rawIpc.postMessage(message, transfer);
|
|
1108
|
+
}
|
|
1109
|
+
dispose() {
|
|
1110
|
+
this._rawIpc.close();
|
|
1111
|
+
}
|
|
1112
|
+
onMessage(callback) {
|
|
1113
|
+
this._rawIpc.addEventListener('message', callback);
|
|
1114
|
+
}
|
|
1115
|
+
onClose(callback) {}
|
|
1116
|
+
}
|
|
1117
|
+
const wrap$5 = messagePort => {
|
|
1118
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
1119
|
+
};
|
|
1120
|
+
const IpcParentWithMessagePort$1 = {
|
|
1121
|
+
__proto__: null,
|
|
1122
|
+
create: create$5$1,
|
|
1123
|
+
signal: signal$1,
|
|
1124
|
+
wrap: wrap$5
|
|
1118
1125
|
};
|
|
1119
1126
|
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
const
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1129
|
-
const Div = 4;
|
|
1130
|
-
const Text = 12;
|
|
1131
|
-
const Reference = 100;
|
|
1132
|
-
|
|
1133
|
-
const Button$1 = 'event.button';
|
|
1134
|
-
const ClientX = 'event.clientX';
|
|
1135
|
-
const ClientY = 'event.clientY';
|
|
1136
|
-
|
|
1137
|
-
const Enter = 3;
|
|
1138
|
-
const Space = 9;
|
|
1139
|
-
const PageUp = 10;
|
|
1140
|
-
const PageDown = 11;
|
|
1141
|
-
const End = 255;
|
|
1142
|
-
const Home = 12;
|
|
1143
|
-
const UpArrow = 14;
|
|
1144
|
-
const DownArrow = 16;
|
|
1145
|
-
|
|
1146
|
-
const ActivityBar$3 = 1;
|
|
1147
|
-
const Settings$1 = 12;
|
|
1148
|
-
const ActivityBarAdditionalViews = 17;
|
|
1149
|
-
|
|
1150
|
-
const Separator = 1;
|
|
1151
|
-
const None = 0;
|
|
1152
|
-
const Checked = 2;
|
|
1153
|
-
const Unchecked = 3;
|
|
1154
|
-
|
|
1155
|
-
const LeftClick = 0;
|
|
1156
|
-
|
|
1157
|
-
const Web = 1;
|
|
1158
|
-
|
|
1159
|
-
const ExtensionManagementWorker = 9006;
|
|
1160
|
-
const RendererWorker = 1;
|
|
1161
|
-
|
|
1162
|
-
const Left = 1;
|
|
1163
|
-
const Right = 2;
|
|
1164
|
-
|
|
1165
|
-
const SetCss = 'Viewlet.setCss';
|
|
1166
|
-
const SetDom2 = 'Viewlet.setDom2';
|
|
1167
|
-
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1168
|
-
const SetPatches = 'Viewlet.setPatches';
|
|
1169
|
-
|
|
1170
|
-
const FocusActivityBar = 5;
|
|
1171
|
-
const FocusExplorer = 13;
|
|
1172
|
-
|
|
1173
|
-
const {
|
|
1174
|
-
invoke: invoke$1,
|
|
1175
|
-
set: set$2
|
|
1176
|
-
} = create$2(ExtensionManagementWorker);
|
|
1177
|
-
|
|
1178
|
-
const {
|
|
1179
|
-
invoke,
|
|
1180
|
-
invokeAndTransfer,
|
|
1181
|
-
set: set$1
|
|
1182
|
-
} = create$2(RendererWorker);
|
|
1183
|
-
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1184
|
-
number(uid);
|
|
1185
|
-
number(menuId);
|
|
1186
|
-
number(x);
|
|
1187
|
-
number(y);
|
|
1188
|
-
await invoke('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1127
|
+
class CommandNotFoundError extends Error {
|
|
1128
|
+
constructor(command) {
|
|
1129
|
+
super(`Command not found ${command}`);
|
|
1130
|
+
this.name = 'CommandNotFoundError';
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
const commands = Object.create(null);
|
|
1134
|
+
const register = commandMap => {
|
|
1135
|
+
Object.assign(commands, commandMap);
|
|
1189
1136
|
};
|
|
1190
|
-
const
|
|
1191
|
-
|
|
1192
|
-
|
|
1137
|
+
const getCommand = key => {
|
|
1138
|
+
return commands[key];
|
|
1139
|
+
};
|
|
1140
|
+
const execute = (command, ...args) => {
|
|
1141
|
+
const fn = getCommand(command);
|
|
1142
|
+
if (!fn) {
|
|
1143
|
+
throw new CommandNotFoundError(command);
|
|
1144
|
+
}
|
|
1145
|
+
return fn(...args);
|
|
1193
1146
|
};
|
|
1194
1147
|
|
|
1195
|
-
const
|
|
1196
|
-
|
|
1197
|
-
|
|
1148
|
+
const Two$1 = '2.0';
|
|
1149
|
+
const callbacks = Object.create(null);
|
|
1150
|
+
const get$1 = id => {
|
|
1151
|
+
return callbacks[id];
|
|
1198
1152
|
};
|
|
1199
|
-
const
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1153
|
+
const remove$1 = id => {
|
|
1154
|
+
delete callbacks[id];
|
|
1155
|
+
};
|
|
1156
|
+
class JsonRpcError extends Error {
|
|
1157
|
+
constructor(message) {
|
|
1158
|
+
super(message);
|
|
1159
|
+
this.name = 'JsonRpcError';
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
const NewLine = '\n';
|
|
1163
|
+
const DomException = 'DOMException';
|
|
1164
|
+
const ReferenceError$1 = 'ReferenceError';
|
|
1165
|
+
const SyntaxError$1 = 'SyntaxError';
|
|
1166
|
+
const TypeError$1 = 'TypeError';
|
|
1167
|
+
const getErrorConstructor = (message, type) => {
|
|
1168
|
+
if (type) {
|
|
1169
|
+
switch (type) {
|
|
1170
|
+
case DomException:
|
|
1171
|
+
return DOMException;
|
|
1172
|
+
case ReferenceError$1:
|
|
1173
|
+
return ReferenceError;
|
|
1174
|
+
case SyntaxError$1:
|
|
1175
|
+
return SyntaxError;
|
|
1176
|
+
case TypeError$1:
|
|
1177
|
+
return TypeError;
|
|
1178
|
+
default:
|
|
1179
|
+
return Error;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
if (message.startsWith('TypeError: ')) {
|
|
1183
|
+
return TypeError;
|
|
1184
|
+
}
|
|
1185
|
+
if (message.startsWith('SyntaxError: ')) {
|
|
1186
|
+
return SyntaxError;
|
|
1187
|
+
}
|
|
1188
|
+
if (message.startsWith('ReferenceError: ')) {
|
|
1189
|
+
return ReferenceError;
|
|
1190
|
+
}
|
|
1191
|
+
return Error;
|
|
1192
|
+
};
|
|
1193
|
+
const constructError = (message, type, name) => {
|
|
1194
|
+
const ErrorConstructor = getErrorConstructor(message, type);
|
|
1195
|
+
if (ErrorConstructor === DOMException && name) {
|
|
1196
|
+
return new ErrorConstructor(message, name);
|
|
1197
|
+
}
|
|
1198
|
+
if (ErrorConstructor === Error) {
|
|
1199
|
+
const error = new Error(message);
|
|
1200
|
+
if (name && name !== 'VError') {
|
|
1201
|
+
error.name = name;
|
|
1202
|
+
}
|
|
1203
|
+
return error;
|
|
1204
|
+
}
|
|
1205
|
+
return new ErrorConstructor(message);
|
|
1206
|
+
};
|
|
1207
|
+
const joinLines = lines => {
|
|
1208
|
+
return lines.join(NewLine);
|
|
1209
|
+
};
|
|
1210
|
+
const splitLines = lines => {
|
|
1211
|
+
return lines.split(NewLine);
|
|
1212
|
+
};
|
|
1213
|
+
const getCurrentStack = () => {
|
|
1214
|
+
const stackLinesToSkip = 3;
|
|
1215
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
1216
|
+
return currentStack;
|
|
1217
|
+
};
|
|
1218
|
+
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
1219
|
+
return string.indexOf(NewLine, startIndex);
|
|
1220
|
+
};
|
|
1221
|
+
const getParentStack = error => {
|
|
1222
|
+
let parentStack = error.stack || error.data || error.message || '';
|
|
1223
|
+
if (parentStack.startsWith(' at')) {
|
|
1224
|
+
parentStack = error.message + NewLine + parentStack;
|
|
1225
|
+
}
|
|
1226
|
+
return parentStack;
|
|
1227
|
+
};
|
|
1228
|
+
const MethodNotFound = -32601;
|
|
1229
|
+
const Custom = -32001;
|
|
1230
|
+
const restoreJsonRpcError = error => {
|
|
1231
|
+
const currentStack = getCurrentStack();
|
|
1232
|
+
if (error && error instanceof Error) {
|
|
1233
|
+
if (typeof error.stack === 'string') {
|
|
1234
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
1235
|
+
}
|
|
1236
|
+
return error;
|
|
1237
|
+
}
|
|
1238
|
+
if (error && error.code && error.code === MethodNotFound) {
|
|
1239
|
+
const restoredError = new JsonRpcError(error.message);
|
|
1240
|
+
const parentStack = getParentStack(error);
|
|
1241
|
+
restoredError.stack = parentStack + NewLine + currentStack;
|
|
1242
|
+
return restoredError;
|
|
1243
|
+
}
|
|
1244
|
+
if (error && error.message) {
|
|
1245
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
1246
|
+
if (error.data) {
|
|
1247
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
1248
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
1249
|
+
} else if (error.data.stack) {
|
|
1250
|
+
restoredError.stack = error.data.stack;
|
|
1206
1251
|
}
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1252
|
+
if (error.data.codeFrame) {
|
|
1253
|
+
// @ts-ignore
|
|
1254
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
1255
|
+
}
|
|
1256
|
+
if (error.data.code) {
|
|
1257
|
+
// @ts-ignore
|
|
1258
|
+
restoredError.code = error.data.code;
|
|
1259
|
+
}
|
|
1260
|
+
if (error.data.type) {
|
|
1261
|
+
// @ts-ignore
|
|
1262
|
+
restoredError.name = error.data.type;
|
|
1263
|
+
}
|
|
1264
|
+
} else {
|
|
1265
|
+
if (error.stack) {
|
|
1266
|
+
const lowerStack = restoredError.stack || '';
|
|
1267
|
+
// @ts-ignore
|
|
1268
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
1269
|
+
const parentStack = getParentStack(error);
|
|
1270
|
+
// @ts-ignore
|
|
1271
|
+
restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
|
|
1272
|
+
}
|
|
1273
|
+
if (error.codeFrame) {
|
|
1274
|
+
// @ts-ignore
|
|
1275
|
+
restoredError.codeFrame = error.codeFrame;
|
|
1219
1276
|
}
|
|
1220
|
-
return diffResult;
|
|
1221
|
-
},
|
|
1222
|
-
dispose(uid) {
|
|
1223
|
-
delete states[uid];
|
|
1224
|
-
},
|
|
1225
|
-
get(uid) {
|
|
1226
|
-
return states[uid];
|
|
1227
|
-
},
|
|
1228
|
-
getCommandIds() {
|
|
1229
|
-
const keys = Object.keys(commandMapRef);
|
|
1230
|
-
const ids = keys.map(toCommandId);
|
|
1231
|
-
return ids;
|
|
1232
|
-
},
|
|
1233
|
-
getKeys() {
|
|
1234
|
-
return Object.keys(states).map(key => {
|
|
1235
|
-
return Number.parseFloat(key);
|
|
1236
|
-
});
|
|
1237
|
-
},
|
|
1238
|
-
registerCommands(commandMap) {
|
|
1239
|
-
Object.assign(commandMapRef, commandMap);
|
|
1240
|
-
},
|
|
1241
|
-
set(uid, oldState, newState) {
|
|
1242
|
-
states[uid] = {
|
|
1243
|
-
newState,
|
|
1244
|
-
oldState
|
|
1245
|
-
};
|
|
1246
|
-
},
|
|
1247
|
-
wrapCommand(fn) {
|
|
1248
|
-
const wrapped = async (uid, ...args) => {
|
|
1249
|
-
const {
|
|
1250
|
-
newState,
|
|
1251
|
-
oldState
|
|
1252
|
-
} = states[uid];
|
|
1253
|
-
const newerState = await fn(newState, ...args);
|
|
1254
|
-
if (oldState === newerState || newState === newerState) {
|
|
1255
|
-
return;
|
|
1256
|
-
}
|
|
1257
|
-
const latestOld = states[uid];
|
|
1258
|
-
const latestNew = {
|
|
1259
|
-
...latestOld.newState,
|
|
1260
|
-
...newerState
|
|
1261
|
-
};
|
|
1262
|
-
states[uid] = {
|
|
1263
|
-
newState: latestNew,
|
|
1264
|
-
oldState: latestOld.oldState
|
|
1265
|
-
};
|
|
1266
|
-
};
|
|
1267
|
-
return wrapped;
|
|
1268
|
-
},
|
|
1269
|
-
wrapGetter(fn) {
|
|
1270
|
-
const wrapped = (uid, ...args) => {
|
|
1271
|
-
const {
|
|
1272
|
-
newState
|
|
1273
|
-
} = states[uid];
|
|
1274
|
-
return fn(newState, ...args);
|
|
1275
|
-
};
|
|
1276
|
-
return wrapped;
|
|
1277
|
-
},
|
|
1278
|
-
wrapLoadContent(fn) {
|
|
1279
|
-
const wrapped = async (uid, ...args) => {
|
|
1280
|
-
const {
|
|
1281
|
-
newState,
|
|
1282
|
-
oldState
|
|
1283
|
-
} = states[uid];
|
|
1284
|
-
const result = await fn(newState, ...args);
|
|
1285
|
-
const {
|
|
1286
|
-
error,
|
|
1287
|
-
state
|
|
1288
|
-
} = result;
|
|
1289
|
-
if (oldState === state || newState === state) {
|
|
1290
|
-
return {
|
|
1291
|
-
error
|
|
1292
|
-
};
|
|
1293
|
-
}
|
|
1294
|
-
const latestOld = states[uid];
|
|
1295
|
-
const latestNew = {
|
|
1296
|
-
...latestOld.newState,
|
|
1297
|
-
...state
|
|
1298
|
-
};
|
|
1299
|
-
states[uid] = {
|
|
1300
|
-
newState: latestNew,
|
|
1301
|
-
oldState: latestOld.oldState
|
|
1302
|
-
};
|
|
1303
|
-
return {
|
|
1304
|
-
error
|
|
1305
|
-
};
|
|
1306
|
-
};
|
|
1307
|
-
return wrapped;
|
|
1308
1277
|
}
|
|
1309
|
-
|
|
1278
|
+
return restoredError;
|
|
1279
|
+
}
|
|
1280
|
+
if (typeof error === 'string') {
|
|
1281
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
1282
|
+
}
|
|
1283
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
1310
1284
|
};
|
|
1311
|
-
const
|
|
1312
|
-
|
|
1285
|
+
const unwrapJsonRpcResult = responseMessage => {
|
|
1286
|
+
if ('error' in responseMessage) {
|
|
1287
|
+
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
1288
|
+
throw restoredError;
|
|
1289
|
+
}
|
|
1290
|
+
if ('result' in responseMessage) {
|
|
1291
|
+
return responseMessage.result;
|
|
1292
|
+
}
|
|
1293
|
+
throw new JsonRpcError('unexpected response message');
|
|
1313
1294
|
};
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
diff,
|
|
1317
|
-
get,
|
|
1318
|
-
getCommandIds,
|
|
1319
|
-
registerCommands,
|
|
1320
|
-
set,
|
|
1321
|
-
wrapCommand,
|
|
1322
|
-
wrapGetter
|
|
1323
|
-
} = create$1();
|
|
1324
|
-
|
|
1325
|
-
// TODO parentUid might ot be needed
|
|
1326
|
-
const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) => {
|
|
1327
|
-
const state = {
|
|
1328
|
-
accountEnabled: true,
|
|
1329
|
-
activityBarItems: [],
|
|
1330
|
-
currentViewletId: '',
|
|
1331
|
-
filteredItems: [],
|
|
1332
|
-
focus: 0,
|
|
1333
|
-
focused: false,
|
|
1334
|
-
focusedIndex: -1,
|
|
1335
|
-
height,
|
|
1336
|
-
initial: true,
|
|
1337
|
-
itemHeight: 48,
|
|
1338
|
-
numberOfVisibleItems: 0,
|
|
1339
|
-
platform,
|
|
1340
|
-
scrollBarHeight: 0,
|
|
1341
|
-
selectedIndex: -1,
|
|
1342
|
-
sideBarLocation: 0,
|
|
1343
|
-
sideBarVisible: false,
|
|
1344
|
-
uid: id,
|
|
1345
|
-
updateProgress: 0,
|
|
1346
|
-
updateState: '',
|
|
1347
|
-
userLoginState: 'logged out',
|
|
1348
|
-
width,
|
|
1349
|
-
x,
|
|
1350
|
-
y
|
|
1351
|
-
};
|
|
1352
|
-
set(id, state, state);
|
|
1353
|
-
return state;
|
|
1295
|
+
const warn = (...args) => {
|
|
1296
|
+
console.warn(...args);
|
|
1354
1297
|
};
|
|
1355
|
-
|
|
1356
|
-
const
|
|
1357
|
-
|
|
1298
|
+
const resolve = (id, response) => {
|
|
1299
|
+
const fn = get$1(id);
|
|
1300
|
+
if (!fn) {
|
|
1301
|
+
console.log(response);
|
|
1302
|
+
warn(`callback ${id} may already be disposed`);
|
|
1303
|
+
return;
|
|
1304
|
+
}
|
|
1305
|
+
fn(response);
|
|
1306
|
+
remove$1(id);
|
|
1358
1307
|
};
|
|
1359
|
-
|
|
1360
|
-
const
|
|
1361
|
-
|
|
1308
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1309
|
+
const getErrorType = prettyError => {
|
|
1310
|
+
if (prettyError && prettyError.type) {
|
|
1311
|
+
return prettyError.type;
|
|
1312
|
+
}
|
|
1313
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
1314
|
+
return prettyError.constructor.name;
|
|
1315
|
+
}
|
|
1316
|
+
return undefined;
|
|
1362
1317
|
};
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
return oldState.activityBarItems === newState.activityBarItems && oldState.filteredItems === newState.filteredItems && oldState.focusedIndex === newState.focusedIndex && oldState.sideBarLocation === newState.sideBarLocation && oldState.sideBarVisible === newState.sideBarVisible && oldState.updateProgress === newState.updateProgress && oldState.updateState === newState.updateState;
|
|
1318
|
+
const isAlreadyStack = line => {
|
|
1319
|
+
return line.trim().startsWith('at ');
|
|
1366
1320
|
};
|
|
1367
|
-
|
|
1368
|
-
const
|
|
1369
|
-
const
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
const modules = [isEqual, isEqual$1, isEqual$1, isEqual$2];
|
|
1375
|
-
const numbers = [RenderIncremental, RenderFocus, RenderFocusContext, RenderCss];
|
|
1376
|
-
|
|
1377
|
-
const diff2 = uid => {
|
|
1378
|
-
return diff(uid, modules, numbers);
|
|
1321
|
+
const getStack = prettyError => {
|
|
1322
|
+
const stackString = prettyError.stack || '';
|
|
1323
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
1324
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
1325
|
+
return stackString.slice(newLineIndex + 1);
|
|
1326
|
+
}
|
|
1327
|
+
return stackString;
|
|
1379
1328
|
};
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
if (focus) {
|
|
1388
|
-
return state;
|
|
1329
|
+
const getErrorProperty = (error, prettyError) => {
|
|
1330
|
+
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
1331
|
+
return {
|
|
1332
|
+
code: MethodNotFound,
|
|
1333
|
+
data: error.stack,
|
|
1334
|
+
message: error.message
|
|
1335
|
+
};
|
|
1389
1336
|
}
|
|
1390
1337
|
return {
|
|
1391
|
-
|
|
1392
|
-
|
|
1338
|
+
code: Custom,
|
|
1339
|
+
data: {
|
|
1340
|
+
code: prettyError.code,
|
|
1341
|
+
codeFrame: prettyError.codeFrame,
|
|
1342
|
+
name: prettyError.name,
|
|
1343
|
+
stack: getStack(prettyError),
|
|
1344
|
+
type: getErrorType(prettyError)
|
|
1345
|
+
},
|
|
1346
|
+
message: prettyError.message
|
|
1393
1347
|
};
|
|
1394
1348
|
};
|
|
1395
|
-
|
|
1396
|
-
const focusIndex = (state, index) => {
|
|
1349
|
+
const create$1$1 = (id, error) => {
|
|
1397
1350
|
return {
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1351
|
+
error,
|
|
1352
|
+
id,
|
|
1353
|
+
jsonrpc: Two$1
|
|
1401
1354
|
};
|
|
1402
1355
|
};
|
|
1403
|
-
|
|
1404
|
-
const
|
|
1405
|
-
|
|
1356
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
1357
|
+
const prettyError = preparePrettyError(error);
|
|
1358
|
+
logError(error, prettyError);
|
|
1359
|
+
const errorProperty = getErrorProperty(error, prettyError);
|
|
1360
|
+
return create$1$1(id, errorProperty);
|
|
1406
1361
|
};
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1362
|
+
const create$8 = (message, result) => {
|
|
1363
|
+
return {
|
|
1364
|
+
id: message.id,
|
|
1365
|
+
jsonrpc: Two$1,
|
|
1366
|
+
result: result ?? null
|
|
1367
|
+
};
|
|
1410
1368
|
};
|
|
1411
|
-
|
|
1412
|
-
const
|
|
1413
|
-
return
|
|
1369
|
+
const getSuccessResponse = (message, result) => {
|
|
1370
|
+
const resultProperty = result ?? null;
|
|
1371
|
+
return create$8(message, resultProperty);
|
|
1414
1372
|
};
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1373
|
+
const getErrorResponseSimple = (id, error) => {
|
|
1374
|
+
return {
|
|
1375
|
+
error: {
|
|
1376
|
+
code: Custom,
|
|
1377
|
+
data: error,
|
|
1378
|
+
// @ts-ignore
|
|
1379
|
+
message: error.message
|
|
1380
|
+
},
|
|
1381
|
+
id,
|
|
1382
|
+
jsonrpc: Two$1
|
|
1383
|
+
};
|
|
1384
|
+
};
|
|
1385
|
+
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
1386
|
+
try {
|
|
1387
|
+
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
1388
|
+
return getSuccessResponse(message, result);
|
|
1389
|
+
} catch (error) {
|
|
1390
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
1391
|
+
return getErrorResponseSimple(message.id, error);
|
|
1392
|
+
}
|
|
1393
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1422
1394
|
}
|
|
1423
|
-
return focusIndex(state, -1);
|
|
1424
1395
|
};
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
return [{
|
|
1428
|
-
command: 'ActivityBar.focusNext',
|
|
1429
|
-
key: DownArrow,
|
|
1430
|
-
when: FocusActivityBar
|
|
1431
|
-
}, {
|
|
1432
|
-
command: 'ActivityBar.focusPrevious',
|
|
1433
|
-
key: UpArrow,
|
|
1434
|
-
when: FocusActivityBar
|
|
1435
|
-
}, {
|
|
1436
|
-
command: 'ActivityBar.focusFirst',
|
|
1437
|
-
key: Home,
|
|
1438
|
-
when: FocusActivityBar
|
|
1439
|
-
}, {
|
|
1440
|
-
command: 'ActivityBar.focusFirst',
|
|
1441
|
-
key: PageUp,
|
|
1442
|
-
when: FocusActivityBar
|
|
1443
|
-
}, {
|
|
1444
|
-
command: 'ActivityBar.focusLast',
|
|
1445
|
-
key: PageDown,
|
|
1446
|
-
when: FocusActivityBar
|
|
1447
|
-
}, {
|
|
1448
|
-
command: 'ActivityBar.focusLast',
|
|
1449
|
-
key: End,
|
|
1450
|
-
when: FocusActivityBar
|
|
1451
|
-
}, {
|
|
1452
|
-
command: 'ActivityBar.selectCurrent',
|
|
1453
|
-
key: Space,
|
|
1454
|
-
when: FocusActivityBar
|
|
1455
|
-
}, {
|
|
1456
|
-
command: 'ActivityBar.selectCurrent',
|
|
1457
|
-
key: Enter,
|
|
1458
|
-
when: FocusActivityBar
|
|
1459
|
-
}];
|
|
1396
|
+
const defaultPreparePrettyError = error => {
|
|
1397
|
+
return error;
|
|
1460
1398
|
};
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
const {
|
|
1464
|
-
userLoginState
|
|
1465
|
-
} = state;
|
|
1466
|
-
const signOutLabel = userLoginState === 'logging out' ? 'Signing Out...' : 'Sign Out';
|
|
1467
|
-
return [{
|
|
1468
|
-
command: 'ActivityBar.handleClickSignOut',
|
|
1469
|
-
flags: None,
|
|
1470
|
-
id: 'signOut',
|
|
1471
|
-
label: signOutLabel
|
|
1472
|
-
}];
|
|
1399
|
+
const defaultLogError = () => {
|
|
1400
|
+
// ignore
|
|
1473
1401
|
};
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1402
|
+
const defaultRequiresSocket = () => {
|
|
1403
|
+
return false;
|
|
1404
|
+
};
|
|
1405
|
+
const defaultResolve = resolve;
|
|
1406
|
+
|
|
1407
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
1408
|
+
const normalizeParams = args => {
|
|
1409
|
+
if (args.length === 1) {
|
|
1410
|
+
const options = args[0];
|
|
1411
|
+
return {
|
|
1412
|
+
execute: options.execute,
|
|
1413
|
+
ipc: options.ipc,
|
|
1414
|
+
logError: options.logError || defaultLogError,
|
|
1415
|
+
message: options.message,
|
|
1416
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
1417
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
1418
|
+
resolve: options.resolve || defaultResolve
|
|
1419
|
+
};
|
|
1420
|
+
}
|
|
1421
|
+
return {
|
|
1422
|
+
execute: args[2],
|
|
1423
|
+
ipc: args[0],
|
|
1424
|
+
logError: args[5],
|
|
1425
|
+
message: args[1],
|
|
1426
|
+
preparePrettyError: args[4],
|
|
1427
|
+
requiresSocket: args[6],
|
|
1428
|
+
resolve: args[3]
|
|
1429
|
+
};
|
|
1485
1430
|
};
|
|
1486
|
-
const
|
|
1487
|
-
|
|
1431
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
1432
|
+
const options = normalizeParams(args);
|
|
1488
1433
|
const {
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1434
|
+
execute,
|
|
1435
|
+
ipc,
|
|
1436
|
+
logError,
|
|
1437
|
+
message,
|
|
1438
|
+
preparePrettyError,
|
|
1439
|
+
requiresSocket,
|
|
1440
|
+
resolve
|
|
1441
|
+
} = options;
|
|
1442
|
+
if ('id' in message) {
|
|
1443
|
+
if ('method' in message) {
|
|
1444
|
+
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
1445
|
+
try {
|
|
1446
|
+
ipc.send(response);
|
|
1447
|
+
} catch (error) {
|
|
1448
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1449
|
+
ipc.send(errorResponse);
|
|
1450
|
+
}
|
|
1451
|
+
return;
|
|
1452
|
+
}
|
|
1453
|
+
resolve(message.id, message);
|
|
1454
|
+
return;
|
|
1493
1455
|
}
|
|
1494
|
-
|
|
1456
|
+
if ('method' in message) {
|
|
1457
|
+
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
throw new JsonRpcError('unexpected message');
|
|
1495
1461
|
};
|
|
1496
1462
|
|
|
1497
|
-
const
|
|
1498
|
-
const Button = 1 << 1;
|
|
1499
|
-
const Progress = 1 << 2;
|
|
1500
|
-
const Enabled = 1 << 3;
|
|
1501
|
-
const Selected = 1 << 4;
|
|
1502
|
-
const Focused = 1 << 5;
|
|
1503
|
-
const MarginTop = 1 << 6;
|
|
1463
|
+
const Two = '2.0';
|
|
1504
1464
|
|
|
1505
|
-
const
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
}
|
|
1511
|
-
const replacer = (match, rest) => {
|
|
1512
|
-
return placeholders[rest];
|
|
1465
|
+
const create$7 = (method, params) => {
|
|
1466
|
+
return {
|
|
1467
|
+
jsonrpc: Two,
|
|
1468
|
+
method,
|
|
1469
|
+
params
|
|
1513
1470
|
};
|
|
1514
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1515
1471
|
};
|
|
1516
1472
|
|
|
1517
|
-
const
|
|
1518
|
-
const
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
const ActivityBar$2 = 'Activity Bar';
|
|
1526
|
-
const MoveSideBarLeft = 'Move Side Bar Left';
|
|
1527
|
-
const MoveSideBarRight = 'Move Side Bar Right';
|
|
1528
|
-
const HideActivityBar = 'Hide Activity Bar';
|
|
1529
|
-
const CheckForUpdates = 'Check For Updates';
|
|
1530
|
-
const ColorTheme = 'Color Theme';
|
|
1531
|
-
const CommandPalette = 'Command Palette';
|
|
1532
|
-
const KeyboardShortcuts = 'Keyboard Shortcuts';
|
|
1533
|
-
|
|
1534
|
-
const account = () => {
|
|
1535
|
-
return i18nString(Account$1);
|
|
1536
|
-
};
|
|
1537
|
-
const explorer = () => {
|
|
1538
|
-
return i18nString(Explorer$1);
|
|
1539
|
-
};
|
|
1540
|
-
const search = () => {
|
|
1541
|
-
return i18nString(Search$2);
|
|
1542
|
-
};
|
|
1543
|
-
const sourceControl = () => {
|
|
1544
|
-
return i18nString(SourceControl$2);
|
|
1545
|
-
};
|
|
1546
|
-
const runAndDebug = () => {
|
|
1547
|
-
return i18nString(RunAndDebug$1);
|
|
1548
|
-
};
|
|
1549
|
-
const extensions = () => {
|
|
1550
|
-
return i18nString(Extensions$2);
|
|
1551
|
-
};
|
|
1552
|
-
const settings = () => {
|
|
1553
|
-
return i18nString(Settings);
|
|
1473
|
+
const create$6 = (id, method, params) => {
|
|
1474
|
+
const message = {
|
|
1475
|
+
id,
|
|
1476
|
+
jsonrpc: Two,
|
|
1477
|
+
method,
|
|
1478
|
+
params
|
|
1479
|
+
};
|
|
1480
|
+
return message;
|
|
1554
1481
|
};
|
|
1555
|
-
|
|
1556
|
-
|
|
1482
|
+
|
|
1483
|
+
let id = 0;
|
|
1484
|
+
const create$5 = () => {
|
|
1485
|
+
return ++id;
|
|
1557
1486
|
};
|
|
1558
|
-
|
|
1559
|
-
|
|
1487
|
+
|
|
1488
|
+
const registerPromise = map => {
|
|
1489
|
+
const id = create$5();
|
|
1490
|
+
const {
|
|
1491
|
+
promise,
|
|
1492
|
+
resolve
|
|
1493
|
+
} = Promise.withResolvers();
|
|
1494
|
+
map[id] = resolve;
|
|
1495
|
+
return {
|
|
1496
|
+
id,
|
|
1497
|
+
promise
|
|
1498
|
+
};
|
|
1560
1499
|
};
|
|
1561
|
-
|
|
1562
|
-
|
|
1500
|
+
|
|
1501
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
1502
|
+
const {
|
|
1503
|
+
id,
|
|
1504
|
+
promise
|
|
1505
|
+
} = registerPromise(callbacks);
|
|
1506
|
+
const message = create$6(id, method, params);
|
|
1507
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1508
|
+
ipc.sendAndTransfer(message);
|
|
1509
|
+
} else {
|
|
1510
|
+
ipc.send(message);
|
|
1511
|
+
}
|
|
1512
|
+
const responseMessage = await promise;
|
|
1513
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
1563
1514
|
};
|
|
1564
|
-
const
|
|
1565
|
-
|
|
1515
|
+
const createRpc = ipc => {
|
|
1516
|
+
const callbacks = Object.create(null);
|
|
1517
|
+
ipc._resolve = (id, response) => {
|
|
1518
|
+
const fn = callbacks[id];
|
|
1519
|
+
if (!fn) {
|
|
1520
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
fn(response);
|
|
1524
|
+
delete callbacks[id];
|
|
1525
|
+
};
|
|
1526
|
+
const rpc = {
|
|
1527
|
+
async dispose() {
|
|
1528
|
+
await ipc?.dispose();
|
|
1529
|
+
},
|
|
1530
|
+
invoke(method, ...params) {
|
|
1531
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
1532
|
+
},
|
|
1533
|
+
invokeAndTransfer(method, ...params) {
|
|
1534
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
1535
|
+
},
|
|
1536
|
+
// @ts-ignore
|
|
1537
|
+
ipc,
|
|
1538
|
+
/**
|
|
1539
|
+
* @deprecated
|
|
1540
|
+
*/
|
|
1541
|
+
send(method, ...params) {
|
|
1542
|
+
const message = create$7(method, params);
|
|
1543
|
+
ipc.send(message);
|
|
1544
|
+
}
|
|
1545
|
+
};
|
|
1546
|
+
return rpc;
|
|
1566
1547
|
};
|
|
1567
|
-
|
|
1568
|
-
|
|
1548
|
+
|
|
1549
|
+
const requiresSocket = () => {
|
|
1550
|
+
return false;
|
|
1569
1551
|
};
|
|
1570
|
-
const
|
|
1571
|
-
return
|
|
1552
|
+
const preparePrettyError = error => {
|
|
1553
|
+
return error;
|
|
1572
1554
|
};
|
|
1573
|
-
const
|
|
1574
|
-
|
|
1555
|
+
const logError = () => {
|
|
1556
|
+
// handled by renderer worker
|
|
1575
1557
|
};
|
|
1576
|
-
const
|
|
1577
|
-
|
|
1558
|
+
const handleMessage = event => {
|
|
1559
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
1560
|
+
const actualExecute = event?.target?.execute || execute;
|
|
1561
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1578
1562
|
};
|
|
1579
|
-
|
|
1580
|
-
|
|
1563
|
+
|
|
1564
|
+
const handleIpc = ipc => {
|
|
1565
|
+
if ('addEventListener' in ipc) {
|
|
1566
|
+
ipc.addEventListener('message', handleMessage);
|
|
1567
|
+
} else if ('on' in ipc) {
|
|
1568
|
+
// deprecated
|
|
1569
|
+
ipc.on('message', handleMessage);
|
|
1570
|
+
}
|
|
1581
1571
|
};
|
|
1582
1572
|
|
|
1583
|
-
const
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
command: 'Layout.moveSideBarRight',
|
|
1588
|
-
flags: None,
|
|
1589
|
-
id: 'moveSideBarRight',
|
|
1590
|
-
label: moveSideBarRight()
|
|
1591
|
-
};
|
|
1592
|
-
case Right:
|
|
1593
|
-
return {
|
|
1594
|
-
command: 'Layout.moveSideBarLeft',
|
|
1595
|
-
flags: None,
|
|
1596
|
-
id: 'moveSideBarLeft',
|
|
1597
|
-
label: moveSideBarLeft()
|
|
1598
|
-
};
|
|
1599
|
-
default:
|
|
1600
|
-
throw new Error('unexpected side bar location');
|
|
1573
|
+
const listen$1 = async (module, options) => {
|
|
1574
|
+
const rawIpc = await module.listen(options);
|
|
1575
|
+
if (module.signal) {
|
|
1576
|
+
module.signal(rawIpc);
|
|
1601
1577
|
}
|
|
1578
|
+
const ipc = module.wrap(rawIpc);
|
|
1579
|
+
return ipc;
|
|
1580
|
+
};
|
|
1581
|
+
|
|
1582
|
+
const create$4 = async ({
|
|
1583
|
+
commandMap,
|
|
1584
|
+
isMessagePortOpen = true,
|
|
1585
|
+
messagePort
|
|
1586
|
+
}) => {
|
|
1587
|
+
// TODO create a commandMap per rpc instance
|
|
1588
|
+
register(commandMap);
|
|
1589
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1590
|
+
isMessagePortOpen,
|
|
1591
|
+
messagePort
|
|
1592
|
+
});
|
|
1593
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1594
|
+
handleIpc(ipc);
|
|
1595
|
+
const rpc = createRpc(ipc);
|
|
1596
|
+
messagePort.start();
|
|
1597
|
+
return rpc;
|
|
1602
1598
|
};
|
|
1603
1599
|
|
|
1604
|
-
const
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1600
|
+
const create$3 = async ({
|
|
1601
|
+
commandMap,
|
|
1602
|
+
isMessagePortOpen,
|
|
1603
|
+
send
|
|
1604
|
+
}) => {
|
|
1605
|
+
const {
|
|
1606
|
+
port1,
|
|
1607
|
+
port2
|
|
1608
|
+
} = new MessageChannel();
|
|
1609
|
+
await send(port1);
|
|
1610
|
+
return create$4({
|
|
1611
|
+
commandMap,
|
|
1612
|
+
isMessagePortOpen,
|
|
1613
|
+
messagePort: port2
|
|
1614
|
+
});
|
|
1609
1615
|
};
|
|
1610
1616
|
|
|
1611
|
-
const
|
|
1612
|
-
|
|
1617
|
+
const createSharedLazyRpc = factory => {
|
|
1618
|
+
let rpcPromise;
|
|
1619
|
+
const getOrCreate = () => {
|
|
1620
|
+
if (!rpcPromise) {
|
|
1621
|
+
rpcPromise = factory();
|
|
1622
|
+
}
|
|
1623
|
+
return rpcPromise;
|
|
1624
|
+
};
|
|
1613
1625
|
return {
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1626
|
+
async dispose() {
|
|
1627
|
+
const rpc = await getOrCreate();
|
|
1628
|
+
await rpc.dispose();
|
|
1629
|
+
},
|
|
1630
|
+
async invoke(method, ...params) {
|
|
1631
|
+
const rpc = await getOrCreate();
|
|
1632
|
+
return rpc.invoke(method, ...params);
|
|
1633
|
+
},
|
|
1634
|
+
async invokeAndTransfer(method, ...params) {
|
|
1635
|
+
const rpc = await getOrCreate();
|
|
1636
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1637
|
+
},
|
|
1638
|
+
async send(method, ...params) {
|
|
1639
|
+
const rpc = await getOrCreate();
|
|
1640
|
+
rpc.send(method, ...params);
|
|
1641
|
+
}
|
|
1619
1642
|
};
|
|
1620
1643
|
};
|
|
1621
1644
|
|
|
1622
|
-
const
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
command: 'Layout.hideActivityBar',
|
|
1635
|
-
flags: None,
|
|
1636
|
-
id: 'hideActivityBar',
|
|
1637
|
-
label: hideActivityBar()
|
|
1638
|
-
}];
|
|
1645
|
+
const create$2 = async ({
|
|
1646
|
+
commandMap,
|
|
1647
|
+
isMessagePortOpen,
|
|
1648
|
+
send
|
|
1649
|
+
}) => {
|
|
1650
|
+
return createSharedLazyRpc(() => {
|
|
1651
|
+
return create$3({
|
|
1652
|
+
commandMap,
|
|
1653
|
+
isMessagePortOpen,
|
|
1654
|
+
send
|
|
1655
|
+
});
|
|
1656
|
+
});
|
|
1639
1657
|
};
|
|
1640
1658
|
|
|
1641
|
-
const
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
const
|
|
1647
|
-
|
|
1659
|
+
const create$1 = async ({
|
|
1660
|
+
commandMap
|
|
1661
|
+
}) => {
|
|
1662
|
+
// TODO create a commandMap per rpc instance
|
|
1663
|
+
register(commandMap);
|
|
1664
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1665
|
+
handleIpc(ipc);
|
|
1666
|
+
const rpc = createRpc(ipc);
|
|
1667
|
+
return rpc;
|
|
1648
1668
|
};
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1669
|
+
|
|
1670
|
+
const createMockRpc = ({
|
|
1671
|
+
commandMap
|
|
1672
|
+
}) => {
|
|
1673
|
+
const invocations = [];
|
|
1674
|
+
const invoke = (method, ...params) => {
|
|
1675
|
+
invocations.push([method, ...params]);
|
|
1676
|
+
const command = commandMap[method];
|
|
1677
|
+
if (!command) {
|
|
1678
|
+
throw new Error(`command ${method} not found`);
|
|
1679
|
+
}
|
|
1680
|
+
return command(...params);
|
|
1681
|
+
};
|
|
1682
|
+
const mockRpc = {
|
|
1683
|
+
invocations,
|
|
1684
|
+
invoke,
|
|
1685
|
+
invokeAndTransfer: invoke
|
|
1686
|
+
};
|
|
1687
|
+
return mockRpc;
|
|
1656
1688
|
};
|
|
1657
1689
|
|
|
1658
|
-
const
|
|
1690
|
+
const rpcs = Object.create(null);
|
|
1691
|
+
const set$3 = (id, rpc) => {
|
|
1692
|
+
rpcs[id] = rpc;
|
|
1693
|
+
};
|
|
1694
|
+
const get = id => {
|
|
1695
|
+
return rpcs[id];
|
|
1696
|
+
};
|
|
1697
|
+
const remove = id => {
|
|
1698
|
+
delete rpcs[id];
|
|
1699
|
+
};
|
|
1700
|
+
|
|
1701
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1702
|
+
const create = rpcId => {
|
|
1659
1703
|
return {
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
//
|
|
1665
|
-
|
|
1704
|
+
async dispose() {
|
|
1705
|
+
const rpc = get(rpcId);
|
|
1706
|
+
await rpc.dispose();
|
|
1707
|
+
},
|
|
1708
|
+
// @ts-ignore
|
|
1709
|
+
invoke(method, ...params) {
|
|
1710
|
+
const rpc = get(rpcId);
|
|
1711
|
+
// @ts-ignore
|
|
1712
|
+
return rpc.invoke(method, ...params);
|
|
1713
|
+
},
|
|
1714
|
+
// @ts-ignore
|
|
1715
|
+
invokeAndTransfer(method, ...params) {
|
|
1716
|
+
const rpc = get(rpcId);
|
|
1717
|
+
// @ts-ignore
|
|
1718
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1719
|
+
},
|
|
1720
|
+
registerMockRpc(commandMap) {
|
|
1721
|
+
const mockRpc = createMockRpc({
|
|
1722
|
+
commandMap
|
|
1723
|
+
});
|
|
1724
|
+
set$3(rpcId, mockRpc);
|
|
1725
|
+
// @ts-ignore
|
|
1726
|
+
mockRpc[Symbol.dispose] = () => {
|
|
1727
|
+
remove(rpcId);
|
|
1728
|
+
};
|
|
1729
|
+
// @ts-ignore
|
|
1730
|
+
return mockRpc;
|
|
1731
|
+
},
|
|
1732
|
+
set(rpc) {
|
|
1733
|
+
set$3(rpcId, rpc);
|
|
1734
|
+
}
|
|
1666
1735
|
};
|
|
1667
1736
|
};
|
|
1668
|
-
const getMenuEntriesAdditionalViews = state => {
|
|
1669
|
-
const hiddenActivityBarItems = getHiddenItems(state);
|
|
1670
|
-
return hiddenActivityBarItems.map(toContextMenuItem);
|
|
1671
|
-
};
|
|
1672
1737
|
|
|
1673
|
-
const
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
items.push(menuEntrySeparator, {
|
|
1702
|
-
command: 'AutoUpdater.checkForUpdates',
|
|
1703
|
-
flags: None,
|
|
1704
|
-
id: 'checkForUpdates',
|
|
1705
|
-
label: checkForUpdates()
|
|
1706
|
-
});
|
|
1707
|
-
}
|
|
1708
|
-
return items;
|
|
1738
|
+
const {
|
|
1739
|
+
set: set$2
|
|
1740
|
+
} = create(6010);
|
|
1741
|
+
|
|
1742
|
+
const {
|
|
1743
|
+
invoke: invoke$1,
|
|
1744
|
+
set: set$1
|
|
1745
|
+
} = create(ExtensionManagementWorker);
|
|
1746
|
+
|
|
1747
|
+
const {
|
|
1748
|
+
invoke,
|
|
1749
|
+
invokeAndTransfer,
|
|
1750
|
+
set
|
|
1751
|
+
} = create(RendererWorker);
|
|
1752
|
+
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1753
|
+
number(uid);
|
|
1754
|
+
number(menuId);
|
|
1755
|
+
number(x);
|
|
1756
|
+
number(y);
|
|
1757
|
+
await invoke('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1758
|
+
};
|
|
1759
|
+
const sendMessagePortToAuthWorker = async (port, rpcId) => {
|
|
1760
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1761
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToAuthWorker', port, command, rpcId);
|
|
1762
|
+
};
|
|
1763
|
+
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
1764
|
+
const command = 'Extensions.handleMessagePort';
|
|
1765
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1709
1766
|
};
|
|
1710
1767
|
|
|
1711
1768
|
const show2 = async (uid, menuId, x, y, args) => {
|
|
@@ -1750,7 +1807,7 @@ const updateItemsWithBadgeCount = async items => {
|
|
|
1750
1807
|
const badgeCounts = await invoke('Layout.getBadgeCounts');
|
|
1751
1808
|
const newItems = items.map(item => {
|
|
1752
1809
|
const badgeCount = badgeCounts[item.id] || 0;
|
|
1753
|
-
const badgeText = badgeCount ?
|
|
1810
|
+
const badgeText = badgeCount ? String(badgeCount) : '';
|
|
1754
1811
|
return {
|
|
1755
1812
|
...item,
|
|
1756
1813
|
badgeText
|
|
@@ -2011,11 +2068,11 @@ const handleContextMenu = async (state, button, eventX, eventY) => {
|
|
|
2011
2068
|
const commandMap$1 = {};
|
|
2012
2069
|
|
|
2013
2070
|
const handleExtensionManagementMessagePort = async port => {
|
|
2014
|
-
const rpc = await create$
|
|
2071
|
+
const rpc = await create$4({
|
|
2015
2072
|
commandMap: commandMap$1,
|
|
2016
2073
|
messagePort: port
|
|
2017
2074
|
});
|
|
2018
|
-
set$
|
|
2075
|
+
set$1(rpc);
|
|
2019
2076
|
};
|
|
2020
2077
|
|
|
2021
2078
|
const Explorer = 'Explorer';
|
|
@@ -2025,13 +2082,24 @@ const Search = 'Search';
|
|
|
2025
2082
|
const SourceControl = 'Source Control';
|
|
2026
2083
|
|
|
2027
2084
|
const toActivityBarItem = view => {
|
|
2028
|
-
|
|
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 = {
|
|
2029
2089
|
flags: Tab | Enabled,
|
|
2030
|
-
icon
|
|
2090
|
+
icon,
|
|
2031
2091
|
id: view.id,
|
|
2032
2092
|
keyShortcuts: '',
|
|
2033
2093
|
title: view.title || view.id
|
|
2034
2094
|
};
|
|
2095
|
+
if (customIconClass && customIconUrl) {
|
|
2096
|
+
return {
|
|
2097
|
+
...item,
|
|
2098
|
+
customIconClass,
|
|
2099
|
+
customIconUrl
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
return item;
|
|
2035
2103
|
};
|
|
2036
2104
|
const getActivityBarItems = (state, contributedViews = []) => {
|
|
2037
2105
|
const {
|
|
@@ -2341,19 +2409,20 @@ const loadContent = async state => {
|
|
|
2341
2409
|
};
|
|
2342
2410
|
};
|
|
2343
2411
|
|
|
2344
|
-
const getCss = itemHeight => {
|
|
2412
|
+
const getCss = (itemHeight, items = []) => {
|
|
2345
2413
|
return `:root {
|
|
2346
2414
|
--ActivityBarItemHeight: var(--${itemHeight}px);
|
|
2347
2415
|
}
|
|
2348
|
-
`;
|
|
2416
|
+
${getCustomIconCss(items)}`;
|
|
2349
2417
|
};
|
|
2350
2418
|
|
|
2351
2419
|
const renderCss = (oldState, newState) => {
|
|
2352
2420
|
const {
|
|
2421
|
+
filteredItems,
|
|
2353
2422
|
itemHeight,
|
|
2354
2423
|
uid
|
|
2355
2424
|
} = newState;
|
|
2356
|
-
const css = getCss(itemHeight);
|
|
2425
|
+
const css = getCss(itemHeight, filteredItems);
|
|
2357
2426
|
return [SetCss, uid, css];
|
|
2358
2427
|
};
|
|
2359
2428
|
|
|
@@ -2447,12 +2516,12 @@ const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
|
2447
2516
|
};
|
|
2448
2517
|
|
|
2449
2518
|
const compareNodes = (oldNode, newNode) => {
|
|
2450
|
-
const patches = [];
|
|
2451
2519
|
// Check if node type changed - return null to signal incompatible nodes
|
|
2452
2520
|
// (caller should handle this with a Replace operation)
|
|
2453
2521
|
if (oldNode.type !== newNode.type) {
|
|
2454
2522
|
return null;
|
|
2455
2523
|
}
|
|
2524
|
+
const patches = [];
|
|
2456
2525
|
// Handle reference nodes - special handling for uid changes
|
|
2457
2526
|
if (oldNode.type === Reference) {
|
|
2458
2527
|
if (oldNode.uid !== newNode.uid) {
|
|
@@ -2488,7 +2557,7 @@ const compareNodes = (oldNode, newNode) => {
|
|
|
2488
2557
|
}
|
|
2489
2558
|
// Check for removed attributes
|
|
2490
2559
|
for (const key of oldKeys) {
|
|
2491
|
-
if (!(key
|
|
2560
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
2492
2561
|
patches.push({
|
|
2493
2562
|
type: RemoveAttribute,
|
|
2494
2563
|
key
|
|
@@ -2703,7 +2772,6 @@ const getClassName = (isFocused, marginTop, isSelected) => {
|
|
|
2703
2772
|
const getActivityBarItemInProgressDom = item => {
|
|
2704
2773
|
const {
|
|
2705
2774
|
flags,
|
|
2706
|
-
icon,
|
|
2707
2775
|
title
|
|
2708
2776
|
} = item;
|
|
2709
2777
|
const isTab = flags & Tab;
|
|
@@ -2726,7 +2794,7 @@ const getActivityBarItemInProgressDom = item => {
|
|
|
2726
2794
|
type: Div
|
|
2727
2795
|
}, {
|
|
2728
2796
|
childCount: 0,
|
|
2729
|
-
className: mergeClassNames(Icon,
|
|
2797
|
+
className: mergeClassNames(Icon, getIconClass(item, 'MaskIcon')),
|
|
2730
2798
|
role: None$1,
|
|
2731
2799
|
type: Div
|
|
2732
2800
|
}, ...getBadgeVirtualDom()];
|
|
@@ -2736,7 +2804,6 @@ const getActivityBarItemWithBadgeDom = item => {
|
|
|
2736
2804
|
const {
|
|
2737
2805
|
badgeText,
|
|
2738
2806
|
flags,
|
|
2739
|
-
icon,
|
|
2740
2807
|
title
|
|
2741
2808
|
} = item;
|
|
2742
2809
|
if (!badgeText) {
|
|
@@ -2763,7 +2830,7 @@ const getActivityBarItemWithBadgeDom = item => {
|
|
|
2763
2830
|
type: Div
|
|
2764
2831
|
}, {
|
|
2765
2832
|
childCount: 0,
|
|
2766
|
-
className: mergeClassNames(Icon,
|
|
2833
|
+
className: mergeClassNames(Icon, getIconClass(item, 'MaskIcon')),
|
|
2767
2834
|
role: None$1,
|
|
2768
2835
|
type: Div
|
|
2769
2836
|
}, {
|
|
@@ -2773,10 +2840,10 @@ const getActivityBarItemWithBadgeDom = item => {
|
|
|
2773
2840
|
}, text(badgeText)];
|
|
2774
2841
|
};
|
|
2775
2842
|
|
|
2776
|
-
const getIconVirtualDom = (icon, type = Div) => {
|
|
2843
|
+
const getIconVirtualDom = (icon, type = Div, customIconClass = '') => {
|
|
2777
2844
|
return {
|
|
2778
2845
|
childCount: 0,
|
|
2779
|
-
className: `MaskIcon MaskIcon${icon}`,
|
|
2846
|
+
className: customIconClass ? `MaskIcon ${customIconClass}` : `MaskIcon MaskIcon${icon}`,
|
|
2780
2847
|
role: None$1,
|
|
2781
2848
|
type
|
|
2782
2849
|
};
|
|
@@ -2808,7 +2875,7 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
2808
2875
|
role,
|
|
2809
2876
|
title,
|
|
2810
2877
|
type: Div
|
|
2811
|
-
}, getIconVirtualDom(icon)];
|
|
2878
|
+
}, getIconVirtualDom(icon, Div, item.customIconClass)];
|
|
2812
2879
|
}
|
|
2813
2880
|
|
|
2814
2881
|
// TODO support progress on selected activity bar item
|
|
@@ -2823,7 +2890,7 @@ const getActivityBarItemVirtualDom = item => {
|
|
|
2823
2890
|
ariaLabel: '',
|
|
2824
2891
|
ariaSelected,
|
|
2825
2892
|
childCount: 0,
|
|
2826
|
-
className: mergeClassNames(className,
|
|
2893
|
+
className: mergeClassNames(className, getIconClass(item, 'Icon')),
|
|
2827
2894
|
role,
|
|
2828
2895
|
title,
|
|
2829
2896
|
type: Div
|
|
@@ -2909,8 +2976,8 @@ const render2 = (uid, diffResult) => {
|
|
|
2909
2976
|
const {
|
|
2910
2977
|
newState,
|
|
2911
2978
|
oldState
|
|
2912
|
-
} = get(uid);
|
|
2913
|
-
set(uid, newState, newState);
|
|
2979
|
+
} = get$2(uid);
|
|
2980
|
+
set$4(uid, newState, newState);
|
|
2914
2981
|
const commands = applyRender(oldState, newState, diffResult);
|
|
2915
2982
|
return commands;
|
|
2916
2983
|
};
|
|
@@ -2990,7 +3057,7 @@ const toggleActivityBarItem = async (state, itemId) => {
|
|
|
2990
3057
|
};
|
|
2991
3058
|
|
|
2992
3059
|
const commandMap = {
|
|
2993
|
-
'ActivityBar.create': create,
|
|
3060
|
+
'ActivityBar.create': create$9,
|
|
2994
3061
|
'ActivityBar.diff2': diff2,
|
|
2995
3062
|
'ActivityBar.focus': wrapCommand(focus),
|
|
2996
3063
|
'ActivityBar.focusFirst': wrapCommand(focusFirst),
|
|
@@ -3029,25 +3096,39 @@ const commandMap = {
|
|
|
3029
3096
|
'ActivityBar.toggleActivityBarItem': wrapCommand(toggleActivityBarItem)
|
|
3030
3097
|
};
|
|
3031
3098
|
|
|
3032
|
-
const send = async port => {
|
|
3099
|
+
const send$1 = async port => {
|
|
3033
3100
|
// @ts-ignore
|
|
3034
3101
|
await sendMessagePortToAuthWorker(port);
|
|
3035
3102
|
};
|
|
3036
3103
|
const initializeAuthWorker = async () => {
|
|
3037
|
-
const rpc = await create$
|
|
3104
|
+
const rpc = await create$2({
|
|
3105
|
+
commandMap: {},
|
|
3106
|
+
send: send$1
|
|
3107
|
+
});
|
|
3108
|
+
set$2(rpc);
|
|
3109
|
+
};
|
|
3110
|
+
|
|
3111
|
+
const send = async port => {
|
|
3112
|
+
await sendMessagePortToExtensionManagementWorker(port, 0);
|
|
3113
|
+
};
|
|
3114
|
+
const initializeExtensionManagementWorker = async () => {
|
|
3115
|
+
const rpc = await create$2({
|
|
3038
3116
|
commandMap: {},
|
|
3039
3117
|
send
|
|
3040
3118
|
});
|
|
3041
|
-
set$
|
|
3119
|
+
set$1(rpc);
|
|
3042
3120
|
};
|
|
3043
3121
|
|
|
3044
|
-
const
|
|
3045
|
-
|
|
3046
|
-
const rpc = await create$3({
|
|
3122
|
+
const initializeRendererWorker = async () => {
|
|
3123
|
+
const rpc = await create$1({
|
|
3047
3124
|
commandMap: commandMap
|
|
3048
3125
|
});
|
|
3049
|
-
set
|
|
3050
|
-
|
|
3126
|
+
set(rpc);
|
|
3127
|
+
};
|
|
3128
|
+
|
|
3129
|
+
const listen = async () => {
|
|
3130
|
+
registerCommands(commandMap);
|
|
3131
|
+
await Promise.all([initializeRendererWorker(), initializeAuthWorker(), initializeExtensionManagementWorker()]);
|
|
3051
3132
|
};
|
|
3052
3133
|
|
|
3053
3134
|
const main = async () => {
|