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