@lvce-editor/status-bar-worker 3.34.0 → 3.35.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/statusBarWorkerMain.js +1949 -1972
- package/package.json +1 -1
|
@@ -1,2185 +1,2102 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
const normalizeLine = line => {
|
|
2
|
+
if (line.startsWith('Error: ')) {
|
|
3
|
+
return line.slice('Error: '.length);
|
|
4
|
+
}
|
|
5
|
+
if (line.startsWith('VError: ')) {
|
|
6
|
+
return line.slice('VError: '.length);
|
|
7
|
+
}
|
|
8
|
+
return line;
|
|
4
9
|
};
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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;
|
|
37
|
+
};
|
|
38
|
+
class VError extends Error {
|
|
39
|
+
constructor(error, message) {
|
|
40
|
+
const combinedMessage = getCombinedMessage(error, message);
|
|
41
|
+
super(combinedMessage);
|
|
42
|
+
this.name = 'VError';
|
|
43
|
+
if (error instanceof Error) {
|
|
44
|
+
this.stack = mergeStacks(this.stack, error.stack);
|
|
18
45
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
states[uid] = {
|
|
23
|
-
newState: updatedState,
|
|
24
|
-
oldState: current.oldState,
|
|
25
|
-
scheduledState: updatedState
|
|
26
|
-
};
|
|
46
|
+
if (error.codeFrame) {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
this.codeFrame = error.codeFrame;
|
|
27
49
|
}
|
|
28
|
-
|
|
50
|
+
if (error.code) {
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
this.code = error.code;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const isMessagePort = value => {
|
|
58
|
+
return value && value instanceof MessagePort;
|
|
59
|
+
};
|
|
60
|
+
const isMessagePortMain = value => {
|
|
61
|
+
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
62
|
+
};
|
|
63
|
+
const isOffscreenCanvas = value => {
|
|
64
|
+
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
65
|
+
};
|
|
66
|
+
const isInstanceOf = (value, constructorName) => {
|
|
67
|
+
return value?.constructor?.name === constructorName;
|
|
68
|
+
};
|
|
69
|
+
const isSocket = value => {
|
|
70
|
+
return isInstanceOf(value, 'Socket');
|
|
71
|
+
};
|
|
72
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
73
|
+
const isTransferrable = value => {
|
|
74
|
+
for (const fn of transferrables) {
|
|
75
|
+
if (fn(value)) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
};
|
|
81
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
82
|
+
if (!value) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (isTransferrable(value)) {
|
|
86
|
+
transferrables.push(value);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (Array.isArray(value)) {
|
|
90
|
+
for (const item of value) {
|
|
91
|
+
walkValue(item, transferrables, isTransferrable);
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (typeof value === 'object') {
|
|
96
|
+
for (const property of Object.values(value)) {
|
|
97
|
+
walkValue(property, transferrables, isTransferrable);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const getTransferrables = value => {
|
|
102
|
+
const transferrables = [];
|
|
103
|
+
walkValue(value, transferrables, isTransferrable);
|
|
104
|
+
return transferrables;
|
|
105
|
+
};
|
|
106
|
+
const attachEvents = that => {
|
|
107
|
+
const handleMessage = (...args) => {
|
|
108
|
+
const data = that.getData(...args);
|
|
109
|
+
that.dispatchEvent(new MessageEvent('message', {
|
|
110
|
+
data
|
|
111
|
+
}));
|
|
29
112
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
getState: () => {
|
|
34
|
-
if (isCurrentGeneration(uid, generation)) {
|
|
35
|
-
latestState = states[uid].newState;
|
|
36
|
-
}
|
|
37
|
-
return latestState;
|
|
38
|
-
},
|
|
39
|
-
updateState: async updater => {
|
|
40
|
-
latestState = await updateState(uid, generation, latestState, updater);
|
|
41
|
-
return latestState;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
113
|
+
that.onMessage(handleMessage);
|
|
114
|
+
const handleClose = event => {
|
|
115
|
+
that.dispatchEvent(new Event('close'));
|
|
44
116
|
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
117
|
+
that.onClose(handleClose);
|
|
118
|
+
};
|
|
119
|
+
class Ipc extends EventTarget {
|
|
120
|
+
constructor(rawIpc) {
|
|
121
|
+
super();
|
|
122
|
+
this._rawIpc = rawIpc;
|
|
123
|
+
attachEvents(this);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
127
|
+
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
128
|
+
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
129
|
+
const NewLine$1 = '\n';
|
|
130
|
+
const joinLines$1 = lines => {
|
|
131
|
+
return lines.join(NewLine$1);
|
|
132
|
+
};
|
|
133
|
+
const RE_AT = /^\s+at/;
|
|
134
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
135
|
+
const isNormalStackLine = line => {
|
|
136
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
137
|
+
};
|
|
138
|
+
const getDetails = lines => {
|
|
139
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
140
|
+
if (index === -1) {
|
|
141
|
+
return {
|
|
142
|
+
actualMessage: joinLines$1(lines),
|
|
143
|
+
rest: []
|
|
54
144
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (commandQueues.get(uid) === current) {
|
|
61
|
-
commandQueues.delete(uid);
|
|
62
|
-
}
|
|
145
|
+
}
|
|
146
|
+
let lastIndex = index - 1;
|
|
147
|
+
while (++lastIndex < lines.length) {
|
|
148
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
149
|
+
break;
|
|
63
150
|
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
actualMessage: lines[index - 1],
|
|
154
|
+
rest: lines.slice(index, lastIndex)
|
|
64
155
|
};
|
|
156
|
+
};
|
|
157
|
+
const splitLines$1 = lines => {
|
|
158
|
+
return lines.split(NewLine$1);
|
|
159
|
+
};
|
|
160
|
+
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
161
|
+
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
162
|
+
const isMessageCodeBlockStartIndex = line => {
|
|
163
|
+
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
164
|
+
};
|
|
165
|
+
const isMessageCodeBlockEndIndex = line => {
|
|
166
|
+
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
167
|
+
};
|
|
168
|
+
const getMessageCodeBlock = stderr => {
|
|
169
|
+
const lines = splitLines$1(stderr);
|
|
170
|
+
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
171
|
+
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
172
|
+
const relevantLines = lines.slice(startIndex, endIndex);
|
|
173
|
+
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
174
|
+
return relevantMessage;
|
|
175
|
+
};
|
|
176
|
+
const isModuleNotFoundMessage = line => {
|
|
177
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
178
|
+
};
|
|
179
|
+
const getModuleNotFoundError = stderr => {
|
|
180
|
+
const lines = splitLines$1(stderr);
|
|
181
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
182
|
+
const message = lines[messageIndex];
|
|
65
183
|
return {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
for (const key of Object.keys(states)) {
|
|
69
|
-
delete states[key];
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
createDirectEventCommandMap(requestRender) {
|
|
73
|
-
return {
|
|
74
|
-
async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
|
|
75
|
-
const fn = commandsById[command];
|
|
76
|
-
if (!fn) {
|
|
77
|
-
throw new Error(`Viewlet command not found: ${command}`);
|
|
78
|
-
}
|
|
79
|
-
await fn(uid, ...args);
|
|
80
|
-
await requestRender(uid);
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
},
|
|
84
|
-
diff(uid, modules, numbers) {
|
|
85
|
-
const {
|
|
86
|
-
oldState,
|
|
87
|
-
scheduledState
|
|
88
|
-
} = states[uid];
|
|
89
|
-
const diffResult = [];
|
|
90
|
-
for (let i = 0; i < modules.length; i++) {
|
|
91
|
-
const fn = modules[i];
|
|
92
|
-
if (!fn(oldState, scheduledState)) {
|
|
93
|
-
diffResult.push(numbers[i]);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return diffResult;
|
|
97
|
-
},
|
|
98
|
-
dispose(uid) {
|
|
99
|
-
commandQueues.delete(uid);
|
|
100
|
-
delete states[uid];
|
|
101
|
-
},
|
|
102
|
-
get(uid) {
|
|
103
|
-
return states[uid];
|
|
104
|
-
},
|
|
105
|
-
getCommandIds() {
|
|
106
|
-
const keys = Object.keys(commandMapRef);
|
|
107
|
-
const ids = keys.map(toCommandId);
|
|
108
|
-
return ids;
|
|
109
|
-
},
|
|
110
|
-
getKeys() {
|
|
111
|
-
return Object.keys(states).map(Number);
|
|
112
|
-
},
|
|
113
|
-
registerCommands(commandMap) {
|
|
114
|
-
Object.assign(commandMapRef, commandMap);
|
|
115
|
-
for (const [key, fn] of Object.entries(commandMap)) {
|
|
116
|
-
commandsById[toCommandId(key)] = fn;
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
set(uid, oldState, newState, scheduledState) {
|
|
120
|
-
const current = states[uid];
|
|
121
|
-
if (!current || oldState === newState && newState !== current.newState) {
|
|
122
|
-
generations[uid] = getGeneration(uid) + 1;
|
|
123
|
-
}
|
|
124
|
-
states[uid] = {
|
|
125
|
-
newState,
|
|
126
|
-
oldState,
|
|
127
|
-
scheduledState: scheduledState ?? newState
|
|
128
|
-
};
|
|
129
|
-
},
|
|
130
|
-
wrapAsyncCommand(fn) {
|
|
131
|
-
const wrapped = async (uid, ...args) => {
|
|
132
|
-
const generation = getGeneration(uid);
|
|
133
|
-
const context = createAsyncCommandContext(uid, generation);
|
|
134
|
-
await fn(context, ...args);
|
|
135
|
-
};
|
|
136
|
-
return wrapped;
|
|
137
|
-
},
|
|
138
|
-
wrapCommand(fn) {
|
|
139
|
-
const wrapped = async (uid, ...args) => {
|
|
140
|
-
const generation = getGeneration(uid);
|
|
141
|
-
const {
|
|
142
|
-
newState,
|
|
143
|
-
oldState
|
|
144
|
-
} = states[uid];
|
|
145
|
-
const newerState = await fn(newState, ...args);
|
|
146
|
-
if (oldState === newerState || newState === newerState) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
if (!isCurrentGeneration(uid, generation)) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
const latestOld = states[uid];
|
|
153
|
-
const latestNew = {
|
|
154
|
-
...latestOld.newState,
|
|
155
|
-
...newerState
|
|
156
|
-
};
|
|
157
|
-
states[uid] = {
|
|
158
|
-
newState: latestNew,
|
|
159
|
-
oldState: latestOld.oldState,
|
|
160
|
-
scheduledState: latestNew
|
|
161
|
-
};
|
|
162
|
-
};
|
|
163
|
-
return wrapped;
|
|
164
|
-
},
|
|
165
|
-
wrapGetter(fn) {
|
|
166
|
-
const wrapped = (uid, ...args) => {
|
|
167
|
-
const {
|
|
168
|
-
newState
|
|
169
|
-
} = states[uid];
|
|
170
|
-
return fn(newState, ...args);
|
|
171
|
-
};
|
|
172
|
-
return wrapped;
|
|
173
|
-
},
|
|
174
|
-
wrapLoadContent(fn) {
|
|
175
|
-
const wrapped = async (uid, ...args) => {
|
|
176
|
-
const generation = getGeneration(uid);
|
|
177
|
-
const {
|
|
178
|
-
newState,
|
|
179
|
-
oldState
|
|
180
|
-
} = states[uid];
|
|
181
|
-
const result = await fn(newState, ...args);
|
|
182
|
-
const {
|
|
183
|
-
error,
|
|
184
|
-
state
|
|
185
|
-
} = result;
|
|
186
|
-
if (oldState === state || newState === state) {
|
|
187
|
-
return {
|
|
188
|
-
error
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
if (!isCurrentGeneration(uid, generation)) {
|
|
192
|
-
return {
|
|
193
|
-
error
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
const latestOld = states[uid];
|
|
197
|
-
const latestNew = {
|
|
198
|
-
...latestOld.newState,
|
|
199
|
-
...state
|
|
200
|
-
};
|
|
201
|
-
states[uid] = {
|
|
202
|
-
newState: latestNew,
|
|
203
|
-
oldState: latestOld.oldState,
|
|
204
|
-
scheduledState: latestNew
|
|
205
|
-
};
|
|
206
|
-
return {
|
|
207
|
-
error
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
return wrapped;
|
|
211
|
-
},
|
|
212
|
-
wrapSerialAsyncCommand(fn) {
|
|
213
|
-
const wrapped = async (uid, ...args) => {
|
|
214
|
-
await enqueueCommand(uid, async () => {
|
|
215
|
-
if (!states[uid]) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
const generation = getGeneration(uid);
|
|
219
|
-
const context = createAsyncCommandContext(uid, generation);
|
|
220
|
-
await fn(context, ...args);
|
|
221
|
-
});
|
|
222
|
-
};
|
|
223
|
-
return wrapped;
|
|
224
|
-
},
|
|
225
|
-
wrapSerialCommand(fn) {
|
|
226
|
-
const wrapped = async (uid, ...args) => {
|
|
227
|
-
await enqueueCommand(uid, async () => {
|
|
228
|
-
if (!states[uid]) {
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
const generation = getGeneration(uid);
|
|
232
|
-
const {
|
|
233
|
-
newState,
|
|
234
|
-
oldState
|
|
235
|
-
} = states[uid];
|
|
236
|
-
const newerState = await fn(newState, ...args);
|
|
237
|
-
if (oldState === newerState || newState === newerState) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
if (!isCurrentGeneration(uid, generation)) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
const latestOld = states[uid];
|
|
244
|
-
const latestNew = {
|
|
245
|
-
...latestOld.newState,
|
|
246
|
-
...newerState
|
|
247
|
-
};
|
|
248
|
-
states[uid] = {
|
|
249
|
-
newState: latestNew,
|
|
250
|
-
oldState: latestOld.oldState,
|
|
251
|
-
scheduledState: latestNew
|
|
252
|
-
};
|
|
253
|
-
});
|
|
254
|
-
};
|
|
255
|
-
return wrapped;
|
|
256
|
-
}
|
|
184
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
185
|
+
message
|
|
257
186
|
};
|
|
258
187
|
};
|
|
259
|
-
const
|
|
260
|
-
|
|
188
|
+
const isModuleNotFoundError = stderr => {
|
|
189
|
+
if (!stderr) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
261
193
|
};
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
registerCommands,
|
|
268
|
-
set: set$9,
|
|
269
|
-
wrapCommand,
|
|
270
|
-
wrapGetter,
|
|
271
|
-
wrapSerialAsyncCommand} = create$a();
|
|
272
|
-
|
|
273
|
-
const create$9 = (uid, uri, x, y, width, height, platform, assetDir, applicationId) => {
|
|
274
|
-
const state = {
|
|
275
|
-
...(applicationId !== undefined && {
|
|
276
|
-
applicationId
|
|
277
|
-
}),
|
|
278
|
-
assetDir,
|
|
279
|
-
errorCount: 0,
|
|
280
|
-
initial: true,
|
|
281
|
-
platform,
|
|
282
|
-
statusBarItemsLeft: [],
|
|
283
|
-
statusBarItemsRight: [],
|
|
284
|
-
uid,
|
|
285
|
-
visibleStatusBarItemsLeft: [],
|
|
286
|
-
visibleStatusBarItemsRight: [],
|
|
287
|
-
warningCount: 0,
|
|
288
|
-
width
|
|
289
|
-
};
|
|
290
|
-
set$9(uid, state, state);
|
|
194
|
+
const isModulesSyntaxError = stderr => {
|
|
195
|
+
if (!stderr) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
291
199
|
};
|
|
292
|
-
|
|
293
|
-
const
|
|
294
|
-
|
|
200
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
201
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
202
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
203
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
295
204
|
};
|
|
296
|
-
const
|
|
297
|
-
|
|
205
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
206
|
+
const message = getMessageCodeBlock(stderr);
|
|
207
|
+
return {
|
|
208
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
209
|
+
message: `Incompatible native node module: ${message}`
|
|
210
|
+
};
|
|
298
211
|
};
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
const numbers = [RenderIncremental];
|
|
305
|
-
|
|
306
|
-
const diff = (oldState, newState) => {
|
|
307
|
-
const diffResult = [];
|
|
308
|
-
for (let i = 0; i < modules.length; i++) {
|
|
309
|
-
const fn = modules[i];
|
|
310
|
-
if (!fn(oldState, newState)) {
|
|
311
|
-
diffResult.push(numbers[i]);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
return diffResult;
|
|
212
|
+
const getModuleSyntaxError = () => {
|
|
213
|
+
return {
|
|
214
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
215
|
+
message: `ES Modules are not supported in electron`
|
|
216
|
+
};
|
|
315
217
|
};
|
|
316
|
-
|
|
317
|
-
|
|
218
|
+
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
219
|
+
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
220
|
+
return getNativeModuleErrorMessage(stderr);
|
|
221
|
+
}
|
|
222
|
+
if (isModulesSyntaxError(stderr)) {
|
|
223
|
+
return getModuleSyntaxError();
|
|
224
|
+
}
|
|
225
|
+
if (isModuleNotFoundError(stderr)) {
|
|
226
|
+
return getModuleNotFoundError(stderr);
|
|
227
|
+
}
|
|
228
|
+
const lines = splitLines$1(stderr);
|
|
318
229
|
const {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
} =
|
|
322
|
-
const result = diff(oldState, newState);
|
|
323
|
-
return result;
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
const getComponentState = uid => {
|
|
327
|
-
return get$5(uid).newState;
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
const Status = 'status';
|
|
331
|
-
|
|
332
|
-
const MaskIcon = 'MaskIcon';
|
|
333
|
-
|
|
334
|
-
const Audio = 0;
|
|
335
|
-
const Button$1 = 1;
|
|
336
|
-
const Col = 2;
|
|
337
|
-
const ColGroup = 3;
|
|
338
|
-
const Div = 4;
|
|
339
|
-
const H1 = 5;
|
|
340
|
-
const Input = 6;
|
|
341
|
-
const Kbd = 7;
|
|
342
|
-
const Span = 8;
|
|
343
|
-
const Table = 9;
|
|
344
|
-
const TBody = 10;
|
|
345
|
-
const Td = 11;
|
|
346
|
-
const Text = 12;
|
|
347
|
-
const Th = 13;
|
|
348
|
-
const THead = 14;
|
|
349
|
-
const Tr = 15;
|
|
350
|
-
const I = 16;
|
|
351
|
-
const Img = 17;
|
|
352
|
-
const Root = 0;
|
|
353
|
-
const Ins = 20;
|
|
354
|
-
const Del = 21;
|
|
355
|
-
const H2 = 22;
|
|
356
|
-
const H3 = 23;
|
|
357
|
-
const H4 = 24;
|
|
358
|
-
const H5 = 25;
|
|
359
|
-
const H6 = 26;
|
|
360
|
-
const Article = 27;
|
|
361
|
-
const Aside = 28;
|
|
362
|
-
const Footer = 29;
|
|
363
|
-
const Header = 30;
|
|
364
|
-
const Nav = 40;
|
|
365
|
-
const Section = 41;
|
|
366
|
-
const Search = 42;
|
|
367
|
-
const Dd = 43;
|
|
368
|
-
const Dl = 44;
|
|
369
|
-
const Figcaption = 45;
|
|
370
|
-
const Figure = 46;
|
|
371
|
-
const Hr = 47;
|
|
372
|
-
const Li = 48;
|
|
373
|
-
const Ol = 49;
|
|
374
|
-
const P = 50;
|
|
375
|
-
const Pre = 51;
|
|
376
|
-
const A = 53;
|
|
377
|
-
const Abbr = 54;
|
|
378
|
-
const Br = 55;
|
|
379
|
-
const Cite = 56;
|
|
380
|
-
const Data = 57;
|
|
381
|
-
const Time = 58;
|
|
382
|
-
const Tfoot = 59;
|
|
383
|
-
const Ul = 60;
|
|
384
|
-
const Video = 61;
|
|
385
|
-
const TextArea = 62;
|
|
386
|
-
const Select = 63;
|
|
387
|
-
const Option = 64;
|
|
388
|
-
const Code = 65;
|
|
389
|
-
const Label = 66;
|
|
390
|
-
const Dt = 67;
|
|
391
|
-
const Iframe = 68;
|
|
392
|
-
const Main = 69;
|
|
393
|
-
const Strong = 70;
|
|
394
|
-
const Em = 71;
|
|
395
|
-
const Style = 72;
|
|
396
|
-
const Html = 73;
|
|
397
|
-
const Head = 74;
|
|
398
|
-
const Title = 75;
|
|
399
|
-
const Meta = 76;
|
|
400
|
-
const Canvas = 77;
|
|
401
|
-
const Form = 78;
|
|
402
|
-
const BlockQuote = 79;
|
|
403
|
-
const Quote = 80;
|
|
404
|
-
const Circle = 81;
|
|
405
|
-
const Defs = 82;
|
|
406
|
-
const Ellipse = 83;
|
|
407
|
-
const G = 84;
|
|
408
|
-
const Line = 85;
|
|
409
|
-
const Path = 86;
|
|
410
|
-
const Polygon = 87;
|
|
411
|
-
const Polyline = 88;
|
|
412
|
-
const Rect = 89;
|
|
413
|
-
const Svg = 90;
|
|
414
|
-
const Use = 91;
|
|
415
|
-
const Progress = 92;
|
|
416
|
-
const Reference = 100;
|
|
417
|
-
|
|
418
|
-
const VirtualDomElements = {
|
|
419
|
-
__proto__: null,
|
|
420
|
-
A,
|
|
421
|
-
Abbr,
|
|
422
|
-
Article,
|
|
423
|
-
Aside,
|
|
424
|
-
Audio,
|
|
425
|
-
BlockQuote,
|
|
426
|
-
Br,
|
|
427
|
-
Button: Button$1,
|
|
428
|
-
Canvas,
|
|
429
|
-
Circle,
|
|
430
|
-
Cite,
|
|
431
|
-
Code,
|
|
432
|
-
Col,
|
|
433
|
-
ColGroup,
|
|
434
|
-
Data,
|
|
435
|
-
Dd,
|
|
436
|
-
Defs,
|
|
437
|
-
Del,
|
|
438
|
-
Div,
|
|
439
|
-
Dl,
|
|
440
|
-
Dt,
|
|
441
|
-
Ellipse,
|
|
442
|
-
Em,
|
|
443
|
-
Figcaption,
|
|
444
|
-
Figure,
|
|
445
|
-
Footer,
|
|
446
|
-
Form,
|
|
447
|
-
G,
|
|
448
|
-
H1,
|
|
449
|
-
H2,
|
|
450
|
-
H3,
|
|
451
|
-
H4,
|
|
452
|
-
H5,
|
|
453
|
-
H6,
|
|
454
|
-
Head,
|
|
455
|
-
Header,
|
|
456
|
-
Hr,
|
|
457
|
-
Html,
|
|
458
|
-
I,
|
|
459
|
-
Iframe,
|
|
460
|
-
Img,
|
|
461
|
-
Input,
|
|
462
|
-
Ins,
|
|
463
|
-
Kbd,
|
|
464
|
-
Label,
|
|
465
|
-
Li,
|
|
466
|
-
Line,
|
|
467
|
-
Main,
|
|
468
|
-
Meta,
|
|
469
|
-
Nav,
|
|
470
|
-
Ol,
|
|
471
|
-
Option,
|
|
472
|
-
P,
|
|
473
|
-
Path,
|
|
474
|
-
Polygon,
|
|
475
|
-
Polyline,
|
|
476
|
-
Pre,
|
|
477
|
-
Progress,
|
|
478
|
-
Quote,
|
|
479
|
-
Rect,
|
|
480
|
-
Reference,
|
|
481
|
-
Root,
|
|
482
|
-
Search,
|
|
483
|
-
Section,
|
|
484
|
-
Select,
|
|
485
|
-
Span,
|
|
486
|
-
Strong,
|
|
487
|
-
Style,
|
|
488
|
-
Svg,
|
|
489
|
-
TBody,
|
|
490
|
-
THead,
|
|
491
|
-
Table,
|
|
492
|
-
Td,
|
|
493
|
-
Text,
|
|
494
|
-
TextArea,
|
|
495
|
-
Tfoot,
|
|
496
|
-
Th,
|
|
497
|
-
Time,
|
|
498
|
-
Title,
|
|
499
|
-
Tr,
|
|
500
|
-
Ul,
|
|
501
|
-
Use,
|
|
502
|
-
Video
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
const Button = 'event.button';
|
|
506
|
-
const ClientX = 'event.clientX';
|
|
507
|
-
const ClientY = 'event.clientY';
|
|
508
|
-
const TargetName = 'event.target.name';
|
|
509
|
-
|
|
510
|
-
const ExtensionManagementWorker = 9006;
|
|
511
|
-
const RendererProcess = 1670;
|
|
512
|
-
const RendererWorker = 1;
|
|
513
|
-
const TextMeasurementWorker = 7011;
|
|
514
|
-
|
|
515
|
-
const SetDom2 = 'Viewlet.setDom2';
|
|
516
|
-
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
517
|
-
const SetPatches = 'Viewlet.setPatches';
|
|
518
|
-
|
|
519
|
-
const mergeClassNames = (...classNames) => {
|
|
520
|
-
return classNames.filter(Boolean).join(' ');
|
|
521
|
-
};
|
|
522
|
-
|
|
523
|
-
const text = data => {
|
|
230
|
+
actualMessage,
|
|
231
|
+
rest
|
|
232
|
+
} = getDetails(lines);
|
|
524
233
|
return {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
234
|
+
code: '',
|
|
235
|
+
message: actualMessage,
|
|
236
|
+
stack: rest
|
|
528
237
|
};
|
|
529
238
|
};
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
const
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
const
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
239
|
+
class IpcError extends VError {
|
|
240
|
+
// @ts-ignore
|
|
241
|
+
constructor(betterMessage, stdout = '', stderr = '') {
|
|
242
|
+
if (stdout || stderr) {
|
|
243
|
+
// @ts-ignore
|
|
244
|
+
const {
|
|
245
|
+
code,
|
|
246
|
+
message,
|
|
247
|
+
stack
|
|
248
|
+
} = getHelpfulChildProcessError(stdout, stderr);
|
|
249
|
+
const cause = new Error(message);
|
|
250
|
+
// @ts-ignore
|
|
251
|
+
cause.code = code;
|
|
252
|
+
if (stack) {
|
|
253
|
+
Object.defineProperty(cause, 'stack', {
|
|
254
|
+
configurable: true,
|
|
255
|
+
enumerable: false,
|
|
256
|
+
value: stack,
|
|
257
|
+
writable: true
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
super(cause, betterMessage);
|
|
261
|
+
} else {
|
|
262
|
+
super(betterMessage);
|
|
263
|
+
}
|
|
264
|
+
// @ts-ignore
|
|
265
|
+
this.name = 'IpcError';
|
|
266
|
+
// @ts-ignore
|
|
267
|
+
this.stdout = stdout;
|
|
268
|
+
// @ts-ignore
|
|
269
|
+
this.stderr = stderr;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
const readyMessage = 'ready';
|
|
273
|
+
const getData$2 = event => {
|
|
274
|
+
return event.data;
|
|
546
275
|
};
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
276
|
+
const listen$7 = () => {
|
|
277
|
+
// @ts-ignore
|
|
278
|
+
if (typeof WorkerGlobalScope === 'undefined') {
|
|
279
|
+
throw new TypeError('module is not in web worker scope');
|
|
280
|
+
}
|
|
281
|
+
return globalThis;
|
|
551
282
|
};
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
const {
|
|
559
|
-
children,
|
|
560
|
-
nodesConsumed
|
|
561
|
-
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
562
|
-
result.push({
|
|
563
|
-
node,
|
|
564
|
-
children
|
|
565
|
-
});
|
|
566
|
-
i += 1 + nodesConsumed;
|
|
283
|
+
const signal$8 = global => {
|
|
284
|
+
global.postMessage(readyMessage);
|
|
285
|
+
};
|
|
286
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
287
|
+
getData(event) {
|
|
288
|
+
return getData$2(event);
|
|
567
289
|
}
|
|
568
|
-
|
|
290
|
+
send(message) {
|
|
291
|
+
// @ts-ignore
|
|
292
|
+
this._rawIpc.postMessage(message);
|
|
293
|
+
}
|
|
294
|
+
sendAndTransfer(message) {
|
|
295
|
+
const transfer = getTransferrables(message);
|
|
296
|
+
// @ts-ignore
|
|
297
|
+
this._rawIpc.postMessage(message, transfer);
|
|
298
|
+
}
|
|
299
|
+
dispose() {
|
|
300
|
+
// ignore
|
|
301
|
+
}
|
|
302
|
+
onClose(callback) {
|
|
303
|
+
// ignore
|
|
304
|
+
}
|
|
305
|
+
onMessage(callback) {
|
|
306
|
+
this._rawIpc.addEventListener('message', callback);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const wrap$f = global => {
|
|
310
|
+
return new IpcChildWithModuleWorker(global);
|
|
569
311
|
};
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
312
|
+
const waitForFirstMessage = async port => {
|
|
313
|
+
const {
|
|
314
|
+
promise,
|
|
315
|
+
resolve
|
|
316
|
+
} = Promise.withResolvers();
|
|
317
|
+
port.addEventListener('message', resolve, {
|
|
318
|
+
once: true
|
|
319
|
+
});
|
|
320
|
+
const event = await promise;
|
|
321
|
+
// @ts-ignore
|
|
322
|
+
return event.data;
|
|
323
|
+
};
|
|
324
|
+
const listen$6 = async () => {
|
|
325
|
+
const parentIpcRaw = listen$7();
|
|
326
|
+
signal$8(parentIpcRaw);
|
|
327
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
|
328
|
+
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
329
|
+
if (firstMessage.method !== 'initialize') {
|
|
330
|
+
throw new IpcError('unexpected first message');
|
|
576
331
|
}
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
const nodeChildCount = node.childCount || 0;
|
|
584
|
-
const {
|
|
585
|
-
children: nodeChildren,
|
|
586
|
-
nodesConsumed
|
|
587
|
-
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
588
|
-
children.push({
|
|
589
|
-
node,
|
|
590
|
-
children: nodeChildren
|
|
332
|
+
const type = firstMessage.params[0];
|
|
333
|
+
if (type === 'message-port') {
|
|
334
|
+
parentIpc.send({
|
|
335
|
+
id: firstMessage.id,
|
|
336
|
+
jsonrpc: '2.0',
|
|
337
|
+
result: null
|
|
591
338
|
});
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
remaining--;
|
|
339
|
+
parentIpc.dispose();
|
|
340
|
+
const port = firstMessage.params[1];
|
|
341
|
+
return port;
|
|
596
342
|
}
|
|
597
|
-
return
|
|
598
|
-
children,
|
|
599
|
-
nodesConsumed: totalConsumed
|
|
600
|
-
};
|
|
343
|
+
return globalThis;
|
|
601
344
|
};
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
// (caller should handle this with a Replace operation)
|
|
606
|
-
if (oldNode.type !== newNode.type) {
|
|
607
|
-
return null;
|
|
345
|
+
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
346
|
+
getData(event) {
|
|
347
|
+
return getData$2(event);
|
|
608
348
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
|
|
612
|
-
patches.push({
|
|
613
|
-
type: SetReferenceNodeUid,
|
|
614
|
-
uid: newNode.uid
|
|
615
|
-
});
|
|
349
|
+
send(message) {
|
|
350
|
+
this._rawIpc.postMessage(message);
|
|
616
351
|
}
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
patches.push({
|
|
621
|
-
type: SetText,
|
|
622
|
-
value: newNode.text
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
return patches;
|
|
352
|
+
sendAndTransfer(message) {
|
|
353
|
+
const transfer = getTransferrables(message);
|
|
354
|
+
this._rawIpc.postMessage(message, transfer);
|
|
626
355
|
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
// Check for attribute changes
|
|
631
|
-
for (const key of newKeys) {
|
|
632
|
-
if (oldNode[key] !== newNode[key]) {
|
|
633
|
-
patches.push({
|
|
634
|
-
type: SetAttribute,
|
|
635
|
-
key,
|
|
636
|
-
value: newNode[key]
|
|
637
|
-
});
|
|
356
|
+
dispose() {
|
|
357
|
+
if (this._rawIpc.close) {
|
|
358
|
+
this._rawIpc.close();
|
|
638
359
|
}
|
|
639
360
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
if (!Object.hasOwn(newNode, key)) {
|
|
643
|
-
patches.push({
|
|
644
|
-
type: RemoveAttribute,
|
|
645
|
-
key
|
|
646
|
-
});
|
|
647
|
-
}
|
|
361
|
+
onClose(callback) {
|
|
362
|
+
// ignore
|
|
648
363
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
const treeToArray = node => {
|
|
653
|
-
const result = [];
|
|
654
|
-
const stack = [node];
|
|
655
|
-
while (stack.length > 0) {
|
|
656
|
-
const current = stack.pop();
|
|
657
|
-
result.push(current.node);
|
|
658
|
-
for (let i = current.children.length - 1; i >= 0; i--) {
|
|
659
|
-
stack.push(current.children[i]);
|
|
660
|
-
}
|
|
364
|
+
onMessage(callback) {
|
|
365
|
+
this._rawIpc.addEventListener('message', callback);
|
|
366
|
+
this._rawIpc.start();
|
|
661
367
|
}
|
|
662
|
-
|
|
368
|
+
}
|
|
369
|
+
const wrap$e = port => {
|
|
370
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
663
371
|
};
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
type: NavigateChild,
|
|
669
|
-
index
|
|
670
|
-
});
|
|
671
|
-
return index;
|
|
672
|
-
}
|
|
673
|
-
if (currentChildIndex !== index) {
|
|
674
|
-
patches.push({
|
|
675
|
-
type: NavigateSibling,
|
|
676
|
-
index
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
return index;
|
|
372
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
373
|
+
__proto__: null,
|
|
374
|
+
listen: listen$6,
|
|
375
|
+
wrap: wrap$e
|
|
680
376
|
};
|
|
681
|
-
const
|
|
682
|
-
if (
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
377
|
+
const addListener = (emitter, type, callback) => {
|
|
378
|
+
if ('addEventListener' in emitter) {
|
|
379
|
+
emitter.addEventListener(type, callback);
|
|
380
|
+
} else {
|
|
381
|
+
emitter.on(type, callback);
|
|
686
382
|
}
|
|
687
|
-
return -1;
|
|
688
383
|
};
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
type
|
|
692
|
-
|
|
693
|
-
|
|
384
|
+
const removeListener = (emitter, type, callback) => {
|
|
385
|
+
if ('removeEventListener' in emitter) {
|
|
386
|
+
emitter.removeEventListener(type, callback);
|
|
387
|
+
} else {
|
|
388
|
+
emitter.off(type, callback);
|
|
389
|
+
}
|
|
694
390
|
};
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
});
|
|
391
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
392
|
+
const {
|
|
393
|
+
promise,
|
|
394
|
+
resolve
|
|
395
|
+
} = Promise.withResolvers();
|
|
396
|
+
const listenerMap = Object.create(null);
|
|
397
|
+
const cleanup = value => {
|
|
398
|
+
for (const event of Object.keys(eventMap)) {
|
|
399
|
+
removeListener(eventEmitter, event, listenerMap[event]);
|
|
400
|
+
}
|
|
401
|
+
resolve(value);
|
|
402
|
+
};
|
|
403
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
404
|
+
const listener = event => {
|
|
405
|
+
cleanup({
|
|
406
|
+
event,
|
|
407
|
+
type
|
|
408
|
+
});
|
|
409
|
+
};
|
|
410
|
+
addListener(eventEmitter, event, listener);
|
|
411
|
+
listenerMap[event] = listener;
|
|
412
|
+
}
|
|
413
|
+
return promise;
|
|
700
414
|
};
|
|
701
|
-
const
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
415
|
+
const Message$1 = 3;
|
|
416
|
+
const create$5$1 = async ({
|
|
417
|
+
isMessagePortOpen,
|
|
418
|
+
messagePort
|
|
419
|
+
}) => {
|
|
420
|
+
if (!isMessagePort(messagePort)) {
|
|
421
|
+
throw new IpcError('port must be of type MessagePort');
|
|
707
422
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
return currentChildIndex;
|
|
423
|
+
if (isMessagePortOpen) {
|
|
424
|
+
return messagePort;
|
|
711
425
|
}
|
|
712
|
-
const
|
|
713
|
-
|
|
714
|
-
|
|
426
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
427
|
+
message: Message$1
|
|
428
|
+
});
|
|
429
|
+
messagePort.start();
|
|
430
|
+
const {
|
|
431
|
+
event,
|
|
432
|
+
type
|
|
433
|
+
} = await eventPromise;
|
|
434
|
+
if (type !== Message$1) {
|
|
435
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
715
436
|
}
|
|
716
|
-
if (
|
|
717
|
-
|
|
437
|
+
if (event.data !== readyMessage) {
|
|
438
|
+
throw new IpcError('unexpected first message');
|
|
718
439
|
}
|
|
719
|
-
return
|
|
440
|
+
return messagePort;
|
|
720
441
|
};
|
|
721
|
-
const
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
patches.push(...nodePatches);
|
|
442
|
+
const signal$1 = messagePort => {
|
|
443
|
+
messagePort.start();
|
|
444
|
+
};
|
|
445
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
446
|
+
getData = getData$2;
|
|
447
|
+
send(message) {
|
|
448
|
+
this._rawIpc.postMessage(message);
|
|
729
449
|
}
|
|
730
|
-
|
|
731
|
-
|
|
450
|
+
sendAndTransfer(message) {
|
|
451
|
+
const transfer = getTransferrables(message);
|
|
452
|
+
this._rawIpc.postMessage(message, transfer);
|
|
732
453
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
736
|
-
let currentChildIndex = -1;
|
|
737
|
-
const indicesToRemove = [];
|
|
738
|
-
for (let i = 0; i < maxLength; i++) {
|
|
739
|
-
const oldNode = oldChildren[i];
|
|
740
|
-
const newNode = newChildren[i];
|
|
741
|
-
if (!oldNode && !newNode) {
|
|
742
|
-
continue;
|
|
743
|
-
}
|
|
744
|
-
if (!oldNode) {
|
|
745
|
-
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
746
|
-
addTree(newNode, patches);
|
|
747
|
-
continue;
|
|
748
|
-
}
|
|
749
|
-
if (!newNode) {
|
|
750
|
-
indicesToRemove.push(i);
|
|
751
|
-
continue;
|
|
752
|
-
}
|
|
753
|
-
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
454
|
+
dispose() {
|
|
455
|
+
this._rawIpc.close();
|
|
754
456
|
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
patches.push({
|
|
758
|
-
type: RemoveChild,
|
|
759
|
-
index: indicesToRemove[j]
|
|
760
|
-
});
|
|
457
|
+
onMessage(callback) {
|
|
458
|
+
this._rawIpc.addEventListener('message', callback);
|
|
761
459
|
}
|
|
460
|
+
onClose(callback) {}
|
|
461
|
+
}
|
|
462
|
+
const wrap$5 = messagePort => {
|
|
463
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
762
464
|
};
|
|
763
|
-
const
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
diffChildren(oldTree, newTree, patches);
|
|
465
|
+
const IpcParentWithMessagePort$1 = {
|
|
466
|
+
__proto__: null,
|
|
467
|
+
create: create$5$1,
|
|
468
|
+
signal: signal$1,
|
|
469
|
+
wrap: wrap$5
|
|
769
470
|
};
|
|
770
471
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
break;
|
|
776
|
-
}
|
|
777
|
-
patches.pop();
|
|
472
|
+
class CommandNotFoundError extends Error {
|
|
473
|
+
constructor(command) {
|
|
474
|
+
super(`Command not found ${command}`);
|
|
475
|
+
this.name = 'CommandNotFoundError';
|
|
778
476
|
}
|
|
779
|
-
|
|
477
|
+
}
|
|
478
|
+
const commands = Object.create(null);
|
|
479
|
+
const register = commandMap => {
|
|
480
|
+
Object.assign(commands, commandMap);
|
|
780
481
|
};
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
return removeTrailingNavigationPatches(patches);
|
|
482
|
+
const getCommand = key => {
|
|
483
|
+
return commands[key];
|
|
484
|
+
};
|
|
485
|
+
const execute = (command, ...args) => {
|
|
486
|
+
const fn = getCommand(command);
|
|
487
|
+
if (!fn) {
|
|
488
|
+
throw new CommandNotFoundError(command);
|
|
489
|
+
}
|
|
490
|
+
return fn(...args);
|
|
791
491
|
};
|
|
792
492
|
|
|
793
|
-
const
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
const ProblemsWarningIcon = 'ProblemsWarningIcon';
|
|
798
|
-
const StatusBarItem = 'StatusBarItem';
|
|
799
|
-
const StatusBarItemsLeft = 'StatusBarItemsLeft';
|
|
800
|
-
const StatusBarItemsRight = 'StatusBarItemsRight';
|
|
801
|
-
|
|
802
|
-
const getTextVirtualDom = (element, name) => {
|
|
803
|
-
return [{
|
|
804
|
-
childCount: 1,
|
|
805
|
-
className: 'StatusBarItemLabel',
|
|
806
|
-
name,
|
|
807
|
-
type: Span
|
|
808
|
-
}, text(element.value)];
|
|
493
|
+
const Two$1 = '2.0';
|
|
494
|
+
const callbacks = Object.create(null);
|
|
495
|
+
const get$5 = id => {
|
|
496
|
+
return callbacks[id];
|
|
809
497
|
};
|
|
810
|
-
const
|
|
811
|
-
|
|
812
|
-
childCount: 0,
|
|
813
|
-
className: mergeClassNames(MaskIcon, 'StatusBarIcon', element.value, element.spinning ? 'Spinning' : ''),
|
|
814
|
-
name,
|
|
815
|
-
type: Div
|
|
816
|
-
}];
|
|
498
|
+
const remove$1 = id => {
|
|
499
|
+
delete callbacks[id];
|
|
817
500
|
};
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
max: element.max,
|
|
823
|
-
name,
|
|
824
|
-
type: Progress
|
|
825
|
-
};
|
|
826
|
-
if (element.value !== undefined) {
|
|
827
|
-
return [{
|
|
828
|
-
...node,
|
|
829
|
-
value: element.value
|
|
830
|
-
}];
|
|
501
|
+
class JsonRpcError extends Error {
|
|
502
|
+
constructor(message) {
|
|
503
|
+
super(message);
|
|
504
|
+
this.name = 'JsonRpcError';
|
|
831
505
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
|
|
506
|
+
}
|
|
507
|
+
const NewLine = '\n';
|
|
508
|
+
const DomException = 'DOMException';
|
|
509
|
+
const ReferenceError$1 = 'ReferenceError';
|
|
510
|
+
const SyntaxError$1 = 'SyntaxError';
|
|
511
|
+
const TypeError$1 = 'TypeError';
|
|
512
|
+
const getErrorConstructor = (message, type) => {
|
|
513
|
+
if (type) {
|
|
514
|
+
switch (type) {
|
|
515
|
+
case DomException:
|
|
516
|
+
return DOMException;
|
|
517
|
+
case ReferenceError$1:
|
|
518
|
+
return ReferenceError;
|
|
519
|
+
case SyntaxError$1:
|
|
520
|
+
return SyntaxError;
|
|
521
|
+
case TypeError$1:
|
|
522
|
+
return TypeError;
|
|
523
|
+
default:
|
|
524
|
+
return Error;
|
|
525
|
+
}
|
|
837
526
|
}
|
|
838
|
-
if (
|
|
839
|
-
return
|
|
527
|
+
if (message.startsWith('TypeError: ')) {
|
|
528
|
+
return TypeError;
|
|
840
529
|
}
|
|
841
|
-
if (
|
|
842
|
-
return
|
|
530
|
+
if (message.startsWith('SyntaxError: ')) {
|
|
531
|
+
return SyntaxError;
|
|
843
532
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
const getStatusBarItemVirtualDom = statusBarItem => {
|
|
848
|
-
const {
|
|
849
|
-
ariaLabel,
|
|
850
|
-
elements,
|
|
851
|
-
name,
|
|
852
|
-
tooltip
|
|
853
|
-
} = statusBarItem;
|
|
854
|
-
const elementNodes = elements.flatMap(element => getStatusBarItemElementVirtualDom(element, name));
|
|
855
|
-
const buttonNode = {
|
|
856
|
-
ariaLabel,
|
|
857
|
-
childCount: elements.length,
|
|
858
|
-
className: StatusBarItem,
|
|
859
|
-
name,
|
|
860
|
-
tabIndex: -1,
|
|
861
|
-
title: tooltip,
|
|
862
|
-
type: Button$1
|
|
863
|
-
};
|
|
864
|
-
return [buttonNode, ...elementNodes];
|
|
865
|
-
};
|
|
866
|
-
|
|
867
|
-
const getStatusBarItemsVirtualDom = (items, className) => {
|
|
868
|
-
if (items.length === 0) {
|
|
869
|
-
return [];
|
|
533
|
+
if (message.startsWith('ReferenceError: ')) {
|
|
534
|
+
return ReferenceError;
|
|
870
535
|
}
|
|
871
|
-
return
|
|
872
|
-
childCount: items.length,
|
|
873
|
-
className,
|
|
874
|
-
type: Div
|
|
875
|
-
}, ...items.flatMap(getStatusBarItemVirtualDom)];
|
|
536
|
+
return Error;
|
|
876
537
|
};
|
|
877
|
-
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
type: Div
|
|
882
|
-
}];
|
|
883
|
-
const getStatusBarItemsLeftDom = statusBarItemsLeft => {
|
|
884
|
-
if (statusBarItemsLeft.length === 0) {
|
|
885
|
-
return emptyStatusBarItemsLeftDom;
|
|
538
|
+
const constructError = (message, type, name) => {
|
|
539
|
+
const ErrorConstructor = getErrorConstructor(message, type);
|
|
540
|
+
if (ErrorConstructor === DOMException && name) {
|
|
541
|
+
return new ErrorConstructor(message, name);
|
|
886
542
|
}
|
|
887
|
-
|
|
543
|
+
if (ErrorConstructor === Error) {
|
|
544
|
+
const error = new Error(message);
|
|
545
|
+
if (name && name !== 'VError') {
|
|
546
|
+
Object.defineProperty(error, 'name', {
|
|
547
|
+
configurable: true,
|
|
548
|
+
value: name
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
return error;
|
|
552
|
+
}
|
|
553
|
+
return new ErrorConstructor(message);
|
|
888
554
|
};
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
return getStatusBarItemsVirtualDom(statusBarItemsRight, StatusBarItemsRight);
|
|
555
|
+
const joinLines = lines => {
|
|
556
|
+
return lines.join(NewLine);
|
|
892
557
|
};
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
const getChildCount = rightCount => {
|
|
897
|
-
return rightCount > 0 ? 2 : 1;
|
|
558
|
+
const splitLines = lines => {
|
|
559
|
+
return lines.split(NewLine);
|
|
898
560
|
};
|
|
899
|
-
const
|
|
900
|
-
const
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
childCount: getChildCount(statusBarItemsRight.length),
|
|
904
|
-
className: 'StatusBar',
|
|
905
|
-
onClick: HandleClick,
|
|
906
|
-
onContextMenu: HandleContextMenu,
|
|
907
|
-
role: Status,
|
|
908
|
-
tabIndex: Focusable,
|
|
909
|
-
type: Div
|
|
910
|
-
}, ...getStatusBarItemsLeftDom(statusBarItemsLeft), ...getStatusBarItemsRightDom(statusBarItemsRight)];
|
|
911
|
-
return dom;
|
|
561
|
+
const getCurrentStack = () => {
|
|
562
|
+
const stackLinesToSkip = 3;
|
|
563
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
564
|
+
return currentStack;
|
|
912
565
|
};
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
visibleStatusBarItemsLeft,
|
|
918
|
-
visibleStatusBarItemsRight
|
|
919
|
-
} = newState;
|
|
920
|
-
const dom = getStatusBarVirtualDom(visibleStatusBarItemsLeft, visibleStatusBarItemsRight);
|
|
921
|
-
return [SetDom2, uid, dom];
|
|
566
|
+
const getNewLineIndex = (string, startIndex) => {
|
|
567
|
+
{
|
|
568
|
+
return string.indexOf(NewLine);
|
|
569
|
+
}
|
|
922
570
|
};
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
571
|
+
const getParentStack = error => {
|
|
572
|
+
let parentStack = error.stack || error.data || error.message || '';
|
|
573
|
+
if (parentStack.startsWith(' at')) {
|
|
574
|
+
parentStack = error.message + NewLine + parentStack;
|
|
575
|
+
}
|
|
576
|
+
return parentStack;
|
|
927
577
|
};
|
|
928
|
-
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
578
|
+
const MethodNotFound = -32601;
|
|
579
|
+
const Custom = -32001;
|
|
580
|
+
const setStack = (error, stack) => {
|
|
581
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
582
|
+
if (descriptor) {
|
|
583
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
587
|
+
error.stack = stack;
|
|
588
|
+
return;
|
|
933
589
|
}
|
|
934
590
|
}
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
};
|
|
940
|
-
|
|
941
|
-
const EditorEncoding$1 = 'EditorEncoding';
|
|
942
|
-
const EditorEndOfLine$1 = 'EditorEndOfLine';
|
|
943
|
-
const EditorIndentation = 'EditorIndentation';
|
|
944
|
-
const EditorLanguage$1 = 'EditorLanguage';
|
|
945
|
-
const EditorPosition$1 = 'EditorPosition';
|
|
946
|
-
const Notifications$1 = 'Notifications';
|
|
947
|
-
const Problems$1 = 'Problems';
|
|
948
|
-
const isEditorStatus = name => {
|
|
949
|
-
return [EditorEncoding$1, EditorEndOfLine$1, EditorIndentation, EditorLanguage$1, EditorPosition$1].includes(name);
|
|
950
|
-
};
|
|
951
|
-
const isRight = name => {
|
|
952
|
-
return name === Notifications$1 || isEditorStatus(name);
|
|
953
|
-
};
|
|
954
|
-
|
|
955
|
-
const state$2 = {
|
|
956
|
-
rpc: undefined
|
|
591
|
+
Object.defineProperty(error, 'stack', {
|
|
592
|
+
configurable: true,
|
|
593
|
+
value: stack,
|
|
594
|
+
writable: true
|
|
595
|
+
});
|
|
957
596
|
};
|
|
958
|
-
const
|
|
959
|
-
|
|
597
|
+
const restoreExistingError = (error, currentStack) => {
|
|
598
|
+
if (typeof error.stack === 'string') {
|
|
599
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
600
|
+
}
|
|
601
|
+
return error;
|
|
960
602
|
};
|
|
961
|
-
const
|
|
962
|
-
const
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
603
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
604
|
+
const restoredError = new JsonRpcError(error.message);
|
|
605
|
+
Object.assign(restoredError, {
|
|
606
|
+
code: error.code
|
|
607
|
+
});
|
|
608
|
+
const parentStack = getParentStack(error);
|
|
609
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
610
|
+
return restoredError;
|
|
966
611
|
};
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
612
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
613
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
614
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
970
615
|
return;
|
|
971
616
|
}
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
await invoke$6('QuickPick.openStatusBarPicker', 'end-of-line');
|
|
975
|
-
return;
|
|
976
|
-
case EditorIndentation:
|
|
977
|
-
await invoke$6('QuickPick.openStatusBarPicker', 'indentation');
|
|
978
|
-
return;
|
|
979
|
-
case EditorLanguage$1:
|
|
980
|
-
await invoke$6('QuickPick.openStatusBarPicker', 'language-mode');
|
|
981
|
-
return;
|
|
982
|
-
case EditorPosition$1:
|
|
983
|
-
await invoke$6('QuickPick.openStatusBarPicker', 'go-to-line', status.line, status.column);
|
|
984
|
-
return;
|
|
617
|
+
if (error.data.stack) {
|
|
618
|
+
setStack(restoredError, error.data.stack);
|
|
985
619
|
}
|
|
986
620
|
};
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
if (
|
|
990
|
-
|
|
621
|
+
const applyDataProperties = (restoredError, error) => {
|
|
622
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
623
|
+
if (error.data.codeFrame) {
|
|
624
|
+
// @ts-ignore
|
|
625
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
991
626
|
}
|
|
992
|
-
if (
|
|
993
|
-
|
|
627
|
+
if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
|
|
628
|
+
// @ts-ignore
|
|
629
|
+
Object.defineProperty(restoredError, 'code', {
|
|
630
|
+
configurable: true,
|
|
631
|
+
value: error.data.code,
|
|
632
|
+
writable: true
|
|
633
|
+
});
|
|
994
634
|
}
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
const stringifiedError = normalizeLine(`${error}`);
|
|
999
|
-
if (message) {
|
|
1000
|
-
return `${message}: ${stringifiedError}`;
|
|
635
|
+
if (error.data.type) {
|
|
636
|
+
// @ts-ignore
|
|
637
|
+
restoredError.name = error.data.type;
|
|
1001
638
|
}
|
|
1002
|
-
return stringifiedError;
|
|
1003
639
|
};
|
|
1004
|
-
const
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
}
|
|
1012
|
-
const parentNewLineIndex = getNewLineIndex$1(parent);
|
|
1013
|
-
const childNewLineIndex = getNewLineIndex$1(child);
|
|
1014
|
-
if (childNewLineIndex === -1) {
|
|
1015
|
-
return parent;
|
|
640
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
641
|
+
if (error.stack) {
|
|
642
|
+
const lowerStack = restoredError.stack || '';
|
|
643
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
644
|
+
const parentStack = getParentStack(error);
|
|
645
|
+
// @ts-ignore
|
|
646
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
1016
647
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
if (parentFirstLine.includes(childFirstLine)) {
|
|
1021
|
-
return parentFirstLine + childRest;
|
|
648
|
+
if (error.codeFrame) {
|
|
649
|
+
// @ts-ignore
|
|
650
|
+
restoredError.codeFrame = error.codeFrame;
|
|
1022
651
|
}
|
|
1023
|
-
return child;
|
|
1024
652
|
};
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
}
|
|
1033
|
-
if (error.codeFrame) {
|
|
1034
|
-
// @ts-ignore
|
|
1035
|
-
this.codeFrame = error.codeFrame;
|
|
1036
|
-
}
|
|
1037
|
-
if (error.code) {
|
|
1038
|
-
// @ts-ignore
|
|
1039
|
-
this.code = error.code;
|
|
1040
|
-
}
|
|
653
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
654
|
+
const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
|
|
655
|
+
if (typeof error.code === 'string' || typeof error.code === 'number') {
|
|
656
|
+
Object.defineProperty(restoredError, 'code', {
|
|
657
|
+
configurable: true,
|
|
658
|
+
value: error.code,
|
|
659
|
+
writable: true
|
|
660
|
+
});
|
|
1041
661
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
1049
|
-
};
|
|
1050
|
-
const isOffscreenCanvas = value => {
|
|
1051
|
-
return typeof OffscreenCanvas !== 'undefined' && value instanceof OffscreenCanvas;
|
|
1052
|
-
};
|
|
1053
|
-
const isInstanceOf = (value, constructorName) => {
|
|
1054
|
-
return value?.constructor?.name === constructorName;
|
|
1055
|
-
};
|
|
1056
|
-
const isSocket = value => {
|
|
1057
|
-
return isInstanceOf(value, 'Socket');
|
|
662
|
+
if (error.data) {
|
|
663
|
+
applyDataProperties(restoredError, error);
|
|
664
|
+
} else {
|
|
665
|
+
applyDirectProperties(restoredError, error);
|
|
666
|
+
}
|
|
667
|
+
return restoredError;
|
|
1058
668
|
};
|
|
1059
|
-
const
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
669
|
+
const getFallbackMessage = error => {
|
|
670
|
+
if (error && typeof error.message === 'string' && error.message) {
|
|
671
|
+
return error.message;
|
|
672
|
+
}
|
|
673
|
+
if (error && error.data) {
|
|
674
|
+
return getFallbackMessage(error.data);
|
|
675
|
+
}
|
|
676
|
+
const stringified = String(error);
|
|
677
|
+
if (stringified !== '[object Object]') {
|
|
678
|
+
return stringified;
|
|
679
|
+
}
|
|
680
|
+
try {
|
|
681
|
+
return JSON.stringify(error);
|
|
682
|
+
} catch {
|
|
683
|
+
return stringified;
|
|
1065
684
|
}
|
|
1066
|
-
return false;
|
|
1067
685
|
};
|
|
1068
|
-
const
|
|
1069
|
-
|
|
1070
|
-
|
|
686
|
+
const restoreJsonRpcError = error => {
|
|
687
|
+
const currentStack = getCurrentStack();
|
|
688
|
+
if (error && error instanceof Error) {
|
|
689
|
+
return restoreExistingError(error, currentStack);
|
|
1071
690
|
}
|
|
1072
|
-
if (
|
|
1073
|
-
|
|
1074
|
-
return;
|
|
691
|
+
if (error && error.code && error.code === MethodNotFound) {
|
|
692
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
1075
693
|
}
|
|
1076
|
-
if (
|
|
1077
|
-
|
|
1078
|
-
walkValue(item, transferrables, isTransferrable);
|
|
1079
|
-
}
|
|
1080
|
-
return;
|
|
694
|
+
if (error && error.error) {
|
|
695
|
+
return restoreJsonRpcError(error.error);
|
|
1081
696
|
}
|
|
1082
|
-
if (
|
|
1083
|
-
|
|
1084
|
-
walkValue(property, transferrables, isTransferrable);
|
|
1085
|
-
}
|
|
697
|
+
if (error && error.message) {
|
|
698
|
+
return restoreMessageError(error);
|
|
1086
699
|
}
|
|
700
|
+
return new Error(`JsonRpc Error: ${getFallbackMessage(error)}`);
|
|
1087
701
|
};
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
702
|
+
const unwrapJsonRpcResult = responseMessage => {
|
|
703
|
+
if ('error' in responseMessage) {
|
|
704
|
+
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
705
|
+
throw restoredError;
|
|
706
|
+
}
|
|
707
|
+
if ('result' in responseMessage) {
|
|
708
|
+
return responseMessage.result;
|
|
709
|
+
}
|
|
710
|
+
throw new JsonRpcError('unexpected response message');
|
|
1092
711
|
};
|
|
1093
|
-
const
|
|
1094
|
-
|
|
1095
|
-
const data = that.getData(...args);
|
|
1096
|
-
that.dispatchEvent(new MessageEvent('message', {
|
|
1097
|
-
data
|
|
1098
|
-
}));
|
|
1099
|
-
};
|
|
1100
|
-
that.onMessage(handleMessage);
|
|
1101
|
-
const handleClose = event => {
|
|
1102
|
-
that.dispatchEvent(new Event('close'));
|
|
1103
|
-
};
|
|
1104
|
-
that.onClose(handleClose);
|
|
712
|
+
const warn = (...args) => {
|
|
713
|
+
console.warn(...args);
|
|
1105
714
|
};
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
715
|
+
const resolve = (id, response) => {
|
|
716
|
+
const fn = get$5(id);
|
|
717
|
+
if (!fn) {
|
|
718
|
+
console.log(response);
|
|
719
|
+
warn(`callback ${id} may already be disposed`);
|
|
720
|
+
return;
|
|
1111
721
|
}
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
1115
|
-
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
1116
|
-
const NewLine$1 = '\n';
|
|
1117
|
-
const joinLines$1 = lines => {
|
|
1118
|
-
return lines.join(NewLine$1);
|
|
722
|
+
fn(response);
|
|
723
|
+
remove$1(id);
|
|
1119
724
|
};
|
|
1120
|
-
const
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1123
|
-
|
|
725
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
726
|
+
const getErrorType = prettyError => {
|
|
727
|
+
if (prettyError && prettyError.type) {
|
|
728
|
+
return prettyError.type;
|
|
729
|
+
}
|
|
730
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
731
|
+
return prettyError.constructor.name;
|
|
732
|
+
}
|
|
733
|
+
return undefined;
|
|
1124
734
|
};
|
|
1125
|
-
const
|
|
1126
|
-
|
|
1127
|
-
|
|
735
|
+
const isAlreadyStack = line => {
|
|
736
|
+
return line.trim().startsWith('at ');
|
|
737
|
+
};
|
|
738
|
+
const getStack = prettyError => {
|
|
739
|
+
const stackString = prettyError.stack || '';
|
|
740
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
741
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
742
|
+
return stackString.slice(newLineIndex + 1);
|
|
743
|
+
}
|
|
744
|
+
return stackString;
|
|
745
|
+
};
|
|
746
|
+
const getErrorProperty = (error, prettyError) => {
|
|
747
|
+
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
1128
748
|
return {
|
|
1129
|
-
|
|
1130
|
-
|
|
749
|
+
code: MethodNotFound,
|
|
750
|
+
data: error.stack,
|
|
751
|
+
message: error.message
|
|
1131
752
|
};
|
|
1132
753
|
}
|
|
1133
|
-
let lastIndex = index - 1;
|
|
1134
|
-
while (++lastIndex < lines.length) {
|
|
1135
|
-
if (!isNormalStackLine(lines[lastIndex])) {
|
|
1136
|
-
break;
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
754
|
return {
|
|
1140
|
-
|
|
1141
|
-
|
|
755
|
+
code: Custom,
|
|
756
|
+
data: {
|
|
757
|
+
code: prettyError.code ?? error?.code,
|
|
758
|
+
codeFrame: prettyError.codeFrame,
|
|
759
|
+
name: prettyError.name ?? error?.name,
|
|
760
|
+
stack: getStack(prettyError),
|
|
761
|
+
type: getErrorType(prettyError)
|
|
762
|
+
},
|
|
763
|
+
message: prettyError.message
|
|
1142
764
|
};
|
|
1143
765
|
};
|
|
1144
|
-
const
|
|
1145
|
-
return
|
|
766
|
+
const create$1$1 = (id, error) => {
|
|
767
|
+
return {
|
|
768
|
+
error,
|
|
769
|
+
id,
|
|
770
|
+
jsonrpc: Two$1
|
|
771
|
+
};
|
|
1146
772
|
};
|
|
1147
|
-
const
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1150
|
-
|
|
773
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
774
|
+
const prettyError = preparePrettyError(error);
|
|
775
|
+
logError(error, prettyError);
|
|
776
|
+
const errorProperty = getErrorProperty(error, prettyError);
|
|
777
|
+
return create$1$1(id, errorProperty);
|
|
1151
778
|
};
|
|
1152
|
-
const
|
|
1153
|
-
return
|
|
779
|
+
const create$a = (message, result) => {
|
|
780
|
+
return {
|
|
781
|
+
id: message.id,
|
|
782
|
+
jsonrpc: Two$1,
|
|
783
|
+
result: result ?? null
|
|
784
|
+
};
|
|
1154
785
|
};
|
|
1155
|
-
const
|
|
1156
|
-
const
|
|
1157
|
-
|
|
1158
|
-
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
1159
|
-
const relevantLines = lines.slice(startIndex, endIndex);
|
|
1160
|
-
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
1161
|
-
return relevantMessage;
|
|
1162
|
-
};
|
|
1163
|
-
const isModuleNotFoundMessage = line => {
|
|
1164
|
-
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
786
|
+
const getSuccessResponse = (message, result) => {
|
|
787
|
+
const resultProperty = result ?? null;
|
|
788
|
+
return create$a(message, resultProperty);
|
|
1165
789
|
};
|
|
1166
|
-
const
|
|
1167
|
-
const lines = splitLines$1(stderr);
|
|
1168
|
-
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
1169
|
-
const message = lines[messageIndex];
|
|
790
|
+
const getErrorResponseSimple = (id, error) => {
|
|
1170
791
|
return {
|
|
1171
|
-
|
|
1172
|
-
|
|
792
|
+
error: {
|
|
793
|
+
code: Custom,
|
|
794
|
+
data: error instanceof Error ? {
|
|
795
|
+
...error,
|
|
796
|
+
code: 'code' in error ? error.code : undefined,
|
|
797
|
+
stack: error.stack,
|
|
798
|
+
type: error.name
|
|
799
|
+
} : error,
|
|
800
|
+
// @ts-ignore
|
|
801
|
+
message: error.message
|
|
802
|
+
},
|
|
803
|
+
id,
|
|
804
|
+
jsonrpc: Two$1
|
|
1173
805
|
};
|
|
1174
806
|
};
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
return
|
|
807
|
+
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
808
|
+
try {
|
|
809
|
+
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
810
|
+
return getSuccessResponse(message, result);
|
|
811
|
+
} catch (error) {
|
|
812
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
813
|
+
return getErrorResponseSimple(message.id, error);
|
|
814
|
+
}
|
|
815
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1184
816
|
}
|
|
1185
|
-
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
1186
817
|
};
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1189
|
-
const isUnhelpfulNativeModuleError = stderr => {
|
|
1190
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
818
|
+
const defaultPreparePrettyError = error => {
|
|
819
|
+
return error;
|
|
1191
820
|
};
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
return {
|
|
1195
|
-
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
1196
|
-
message: `Incompatible native node module: ${message}`
|
|
1197
|
-
};
|
|
821
|
+
const defaultLogError = () => {
|
|
822
|
+
// ignore
|
|
1198
823
|
};
|
|
1199
|
-
const
|
|
1200
|
-
return
|
|
1201
|
-
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
1202
|
-
message: `ES Modules are not supported in electron`
|
|
1203
|
-
};
|
|
824
|
+
const defaultRequiresSocket = () => {
|
|
825
|
+
return false;
|
|
1204
826
|
};
|
|
1205
|
-
const
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
if (
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
827
|
+
const defaultResolve = resolve;
|
|
828
|
+
|
|
829
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
830
|
+
const normalizeParams = args => {
|
|
831
|
+
if (args.length === 1) {
|
|
832
|
+
const options = args[0];
|
|
833
|
+
return {
|
|
834
|
+
execute: options.execute,
|
|
835
|
+
ipc: options.ipc,
|
|
836
|
+
logError: options.logError || defaultLogError,
|
|
837
|
+
message: options.message,
|
|
838
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
839
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
840
|
+
resolve: options.resolve || defaultResolve
|
|
841
|
+
};
|
|
1214
842
|
}
|
|
1215
|
-
const lines = splitLines$1(stderr);
|
|
1216
|
-
const {
|
|
1217
|
-
actualMessage,
|
|
1218
|
-
rest
|
|
1219
|
-
} = getDetails(lines);
|
|
1220
843
|
return {
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
844
|
+
execute: args[2],
|
|
845
|
+
ipc: args[0],
|
|
846
|
+
logError: args[5],
|
|
847
|
+
message: args[1],
|
|
848
|
+
preparePrettyError: args[4],
|
|
849
|
+
requiresSocket: args[6],
|
|
850
|
+
resolve: args[3]
|
|
1224
851
|
};
|
|
1225
852
|
};
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
});
|
|
853
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
854
|
+
const options = normalizeParams(args);
|
|
855
|
+
const {
|
|
856
|
+
execute,
|
|
857
|
+
ipc,
|
|
858
|
+
logError,
|
|
859
|
+
message,
|
|
860
|
+
preparePrettyError,
|
|
861
|
+
requiresSocket,
|
|
862
|
+
resolve
|
|
863
|
+
} = options;
|
|
864
|
+
if ('id' in message) {
|
|
865
|
+
if ('method' in message) {
|
|
866
|
+
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
867
|
+
try {
|
|
868
|
+
ipc.send(response);
|
|
869
|
+
} catch (error) {
|
|
870
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
871
|
+
ipc.send(errorResponse);
|
|
1246
872
|
}
|
|
1247
|
-
|
|
1248
|
-
} else {
|
|
1249
|
-
super(betterMessage);
|
|
873
|
+
return;
|
|
1250
874
|
}
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
// @ts-ignore
|
|
1254
|
-
this.stdout = stdout;
|
|
1255
|
-
// @ts-ignore
|
|
1256
|
-
this.stderr = stderr;
|
|
875
|
+
resolve(message.id, message);
|
|
876
|
+
return;
|
|
1257
877
|
}
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
return event.data;
|
|
1262
|
-
};
|
|
1263
|
-
const listen$7 = () => {
|
|
1264
|
-
// @ts-ignore
|
|
1265
|
-
if (typeof WorkerGlobalScope === 'undefined') {
|
|
1266
|
-
throw new TypeError('module is not in web worker scope');
|
|
878
|
+
if ('method' in message) {
|
|
879
|
+
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
880
|
+
return;
|
|
1267
881
|
}
|
|
1268
|
-
|
|
882
|
+
throw new JsonRpcError('unexpected message');
|
|
1269
883
|
};
|
|
1270
|
-
|
|
1271
|
-
|
|
884
|
+
|
|
885
|
+
const Two = '2.0';
|
|
886
|
+
|
|
887
|
+
const create$9 = (method, params) => {
|
|
888
|
+
return {
|
|
889
|
+
jsonrpc: Two,
|
|
890
|
+
method,
|
|
891
|
+
params
|
|
892
|
+
};
|
|
1272
893
|
};
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
const transfer = getTransferrables(message);
|
|
1283
|
-
// @ts-ignore
|
|
1284
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1285
|
-
}
|
|
1286
|
-
dispose() {
|
|
1287
|
-
// ignore
|
|
1288
|
-
}
|
|
1289
|
-
onClose(callback) {
|
|
1290
|
-
// ignore
|
|
1291
|
-
}
|
|
1292
|
-
onMessage(callback) {
|
|
1293
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1294
|
-
}
|
|
1295
|
-
}
|
|
1296
|
-
const wrap$f = global => {
|
|
1297
|
-
return new IpcChildWithModuleWorker(global);
|
|
894
|
+
|
|
895
|
+
const create$8 = (id, method, params) => {
|
|
896
|
+
const message = {
|
|
897
|
+
id,
|
|
898
|
+
jsonrpc: Two,
|
|
899
|
+
method,
|
|
900
|
+
params
|
|
901
|
+
};
|
|
902
|
+
return message;
|
|
1298
903
|
};
|
|
1299
|
-
|
|
904
|
+
|
|
905
|
+
let id = 0;
|
|
906
|
+
const create$7 = () => {
|
|
907
|
+
return ++id;
|
|
908
|
+
};
|
|
909
|
+
|
|
910
|
+
const registerPromise = map => {
|
|
911
|
+
const id = create$7();
|
|
1300
912
|
const {
|
|
1301
913
|
promise,
|
|
1302
914
|
resolve
|
|
1303
915
|
} = Promise.withResolvers();
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
return event.data;
|
|
916
|
+
map[id] = resolve;
|
|
917
|
+
return {
|
|
918
|
+
id,
|
|
919
|
+
promise
|
|
920
|
+
};
|
|
1310
921
|
};
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
922
|
+
|
|
923
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
924
|
+
const {
|
|
925
|
+
id,
|
|
926
|
+
promise
|
|
927
|
+
} = registerPromise(callbacks);
|
|
928
|
+
const message = create$8(id, method, params);
|
|
929
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
930
|
+
ipc.sendAndTransfer(message);
|
|
931
|
+
} else {
|
|
932
|
+
ipc.send(message);
|
|
1318
933
|
}
|
|
1319
|
-
const
|
|
1320
|
-
|
|
1321
|
-
parentIpc.send({
|
|
1322
|
-
id: firstMessage.id,
|
|
1323
|
-
jsonrpc: '2.0',
|
|
1324
|
-
result: null
|
|
1325
|
-
});
|
|
1326
|
-
parentIpc.dispose();
|
|
1327
|
-
const port = firstMessage.params[1];
|
|
1328
|
-
return port;
|
|
1329
|
-
}
|
|
1330
|
-
return globalThis;
|
|
934
|
+
const responseMessage = await promise;
|
|
935
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
1331
936
|
};
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
sendAndTransfer(message) {
|
|
1340
|
-
const transfer = getTransferrables(message);
|
|
1341
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1342
|
-
}
|
|
1343
|
-
dispose() {
|
|
1344
|
-
if (this._rawIpc.close) {
|
|
1345
|
-
this._rawIpc.close();
|
|
937
|
+
const createRpc = ipc => {
|
|
938
|
+
const callbacks = Object.create(null);
|
|
939
|
+
ipc._resolve = (id, response) => {
|
|
940
|
+
const fn = callbacks[id];
|
|
941
|
+
if (!fn) {
|
|
942
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
943
|
+
return;
|
|
1346
944
|
}
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
945
|
+
fn(response);
|
|
946
|
+
delete callbacks[id];
|
|
947
|
+
};
|
|
948
|
+
const rpc = {
|
|
949
|
+
async dispose() {
|
|
950
|
+
await ipc?.dispose();
|
|
951
|
+
},
|
|
952
|
+
invoke(method, ...params) {
|
|
953
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
954
|
+
},
|
|
955
|
+
invokeAndTransfer(method, ...params) {
|
|
956
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
957
|
+
},
|
|
958
|
+
// @ts-ignore
|
|
959
|
+
ipc,
|
|
960
|
+
/**
|
|
961
|
+
* @deprecated
|
|
962
|
+
*/
|
|
963
|
+
send(method, ...params) {
|
|
964
|
+
const message = create$9(method, params);
|
|
965
|
+
ipc.send(message);
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
return rpc;
|
|
1358
969
|
};
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
wrap: wrap$e
|
|
970
|
+
|
|
971
|
+
const requiresSocket = () => {
|
|
972
|
+
return false;
|
|
1363
973
|
};
|
|
1364
|
-
const
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
974
|
+
const preparePrettyError = error => {
|
|
975
|
+
return error;
|
|
976
|
+
};
|
|
977
|
+
const logError = () => {
|
|
978
|
+
// handled by renderer worker
|
|
979
|
+
};
|
|
980
|
+
const handleMessage = event => {
|
|
981
|
+
if (event.data === 'ready') {
|
|
982
|
+
return Promise.resolve();
|
|
1369
983
|
}
|
|
984
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
985
|
+
const actualExecute = event?.target?.execute || execute;
|
|
986
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1370
987
|
};
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
988
|
+
|
|
989
|
+
const handleIpc = ipc => {
|
|
990
|
+
if ('addEventListener' in ipc) {
|
|
991
|
+
ipc.addEventListener('message', handleMessage);
|
|
992
|
+
} else if ('on' in ipc) {
|
|
993
|
+
// deprecated
|
|
994
|
+
ipc.on('message', handleMessage);
|
|
1376
995
|
}
|
|
1377
996
|
};
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
const
|
|
1385
|
-
|
|
1386
|
-
|
|
997
|
+
|
|
998
|
+
const listen$1 = async (module, options) => {
|
|
999
|
+
const rawIpc = await module.listen(options);
|
|
1000
|
+
if (module.signal) {
|
|
1001
|
+
module.signal(rawIpc);
|
|
1002
|
+
}
|
|
1003
|
+
const ipc = module.wrap(rawIpc);
|
|
1004
|
+
return ipc;
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
const createSharedLazyRpc = factory => {
|
|
1008
|
+
let rpcPromise;
|
|
1009
|
+
const getOrCreate = () => {
|
|
1010
|
+
if (!rpcPromise) {
|
|
1011
|
+
rpcPromise = factory();
|
|
1012
|
+
}
|
|
1013
|
+
return rpcPromise;
|
|
1014
|
+
};
|
|
1015
|
+
return {
|
|
1016
|
+
async dispose() {
|
|
1017
|
+
const rpc = await getOrCreate();
|
|
1018
|
+
await rpc.dispose();
|
|
1019
|
+
},
|
|
1020
|
+
async invoke(method, ...params) {
|
|
1021
|
+
const rpc = await getOrCreate();
|
|
1022
|
+
return rpc.invoke(method, ...params);
|
|
1023
|
+
},
|
|
1024
|
+
async invokeAndTransfer(method, ...params) {
|
|
1025
|
+
const rpc = await getOrCreate();
|
|
1026
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1027
|
+
},
|
|
1028
|
+
async send(method, ...params) {
|
|
1029
|
+
const rpc = await getOrCreate();
|
|
1030
|
+
rpc.send(method, ...params);
|
|
1387
1031
|
}
|
|
1388
|
-
resolve(value);
|
|
1389
1032
|
};
|
|
1390
|
-
for (const [event, type] of Object.entries(eventMap)) {
|
|
1391
|
-
const listener = event => {
|
|
1392
|
-
cleanup({
|
|
1393
|
-
event,
|
|
1394
|
-
type
|
|
1395
|
-
});
|
|
1396
|
-
};
|
|
1397
|
-
addListener(eventEmitter, event, listener);
|
|
1398
|
-
listenerMap[event] = listener;
|
|
1399
|
-
}
|
|
1400
|
-
return promise;
|
|
1401
1033
|
};
|
|
1402
|
-
|
|
1403
|
-
const create$
|
|
1404
|
-
|
|
1034
|
+
|
|
1035
|
+
const create$6 = async ({
|
|
1036
|
+
commandMap,
|
|
1037
|
+
isMessagePortOpen = true,
|
|
1405
1038
|
messagePort
|
|
1406
1039
|
}) => {
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
}
|
|
1413
|
-
const eventPromise = getFirstEvent(messagePort, {
|
|
1414
|
-
message: Message$1
|
|
1040
|
+
// TODO create a commandMap per rpc instance
|
|
1041
|
+
register(commandMap);
|
|
1042
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
1043
|
+
isMessagePortOpen,
|
|
1044
|
+
messagePort
|
|
1415
1045
|
});
|
|
1046
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
1047
|
+
handleIpc(ipc);
|
|
1048
|
+
const rpc = createRpc(ipc);
|
|
1416
1049
|
messagePort.start();
|
|
1417
|
-
|
|
1418
|
-
event,
|
|
1419
|
-
type
|
|
1420
|
-
} = await eventPromise;
|
|
1421
|
-
if (type !== Message$1) {
|
|
1422
|
-
throw new IpcError('Failed to wait for ipc message');
|
|
1423
|
-
}
|
|
1424
|
-
if (event.data !== readyMessage) {
|
|
1425
|
-
throw new IpcError('unexpected first message');
|
|
1426
|
-
}
|
|
1427
|
-
return messagePort;
|
|
1428
|
-
};
|
|
1429
|
-
const signal$1 = messagePort => {
|
|
1430
|
-
messagePort.start();
|
|
1050
|
+
return rpc;
|
|
1431
1051
|
};
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
}
|
|
1449
|
-
const wrap$5 = messagePort => {
|
|
1450
|
-
return new IpcParentWithMessagePort(messagePort);
|
|
1052
|
+
|
|
1053
|
+
const create$5 = async ({
|
|
1054
|
+
commandMap,
|
|
1055
|
+
isMessagePortOpen,
|
|
1056
|
+
send
|
|
1057
|
+
}) => {
|
|
1058
|
+
const {
|
|
1059
|
+
port1,
|
|
1060
|
+
port2
|
|
1061
|
+
} = new MessageChannel();
|
|
1062
|
+
await send(port1);
|
|
1063
|
+
return create$6({
|
|
1064
|
+
commandMap,
|
|
1065
|
+
isMessagePortOpen,
|
|
1066
|
+
messagePort: port2
|
|
1067
|
+
});
|
|
1451
1068
|
};
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1069
|
+
|
|
1070
|
+
const create$4 = async ({
|
|
1071
|
+
commandMap,
|
|
1072
|
+
isMessagePortOpen,
|
|
1073
|
+
send
|
|
1074
|
+
}) => {
|
|
1075
|
+
return createSharedLazyRpc(() => {
|
|
1076
|
+
return create$5({
|
|
1077
|
+
commandMap,
|
|
1078
|
+
isMessagePortOpen,
|
|
1079
|
+
send
|
|
1080
|
+
});
|
|
1081
|
+
});
|
|
1457
1082
|
};
|
|
1458
1083
|
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
const
|
|
1467
|
-
|
|
1084
|
+
const create$3 = async ({
|
|
1085
|
+
commandMap
|
|
1086
|
+
}) => {
|
|
1087
|
+
// TODO create a commandMap per rpc instance
|
|
1088
|
+
register(commandMap);
|
|
1089
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1090
|
+
handleIpc(ipc);
|
|
1091
|
+
const rpc = createRpc(ipc);
|
|
1092
|
+
return rpc;
|
|
1468
1093
|
};
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1094
|
+
|
|
1095
|
+
const createMockRpc = ({
|
|
1096
|
+
commandMap
|
|
1097
|
+
}) => {
|
|
1098
|
+
const invocations = [];
|
|
1099
|
+
const invoke = (method, ...params) => {
|
|
1100
|
+
invocations.push([method, ...params]);
|
|
1101
|
+
const command = commandMap[method];
|
|
1102
|
+
if (!command) {
|
|
1103
|
+
throw new Error(`command ${method} not found`);
|
|
1104
|
+
}
|
|
1105
|
+
return command(...params);
|
|
1106
|
+
};
|
|
1107
|
+
const mockRpc = {
|
|
1108
|
+
invocations,
|
|
1109
|
+
invoke,
|
|
1110
|
+
invokeAndTransfer: invoke
|
|
1111
|
+
};
|
|
1112
|
+
return mockRpc;
|
|
1478
1113
|
};
|
|
1479
1114
|
|
|
1480
|
-
const
|
|
1481
|
-
const
|
|
1482
|
-
|
|
1483
|
-
return callbacks[id];
|
|
1115
|
+
const rpcs = Object.create(null);
|
|
1116
|
+
const set$a = (id, rpc) => {
|
|
1117
|
+
rpcs[id] = rpc;
|
|
1484
1118
|
};
|
|
1485
|
-
const
|
|
1486
|
-
|
|
1119
|
+
const get$4 = id => {
|
|
1120
|
+
return rpcs[id];
|
|
1487
1121
|
};
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
super(message);
|
|
1491
|
-
this.name = 'JsonRpcError';
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
const NewLine = '\n';
|
|
1495
|
-
const DomException = 'DOMException';
|
|
1496
|
-
const ReferenceError$1 = 'ReferenceError';
|
|
1497
|
-
const SyntaxError$1 = 'SyntaxError';
|
|
1498
|
-
const TypeError$1 = 'TypeError';
|
|
1499
|
-
const getErrorConstructor = (message, type) => {
|
|
1500
|
-
if (type) {
|
|
1501
|
-
switch (type) {
|
|
1502
|
-
case DomException:
|
|
1503
|
-
return DOMException;
|
|
1504
|
-
case ReferenceError$1:
|
|
1505
|
-
return ReferenceError;
|
|
1506
|
-
case SyntaxError$1:
|
|
1507
|
-
return SyntaxError;
|
|
1508
|
-
case TypeError$1:
|
|
1509
|
-
return TypeError;
|
|
1510
|
-
default:
|
|
1511
|
-
return Error;
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
if (message.startsWith('TypeError: ')) {
|
|
1515
|
-
return TypeError;
|
|
1516
|
-
}
|
|
1517
|
-
if (message.startsWith('SyntaxError: ')) {
|
|
1518
|
-
return SyntaxError;
|
|
1519
|
-
}
|
|
1520
|
-
if (message.startsWith('ReferenceError: ')) {
|
|
1521
|
-
return ReferenceError;
|
|
1522
|
-
}
|
|
1523
|
-
return Error;
|
|
1122
|
+
const remove = id => {
|
|
1123
|
+
delete rpcs[id];
|
|
1524
1124
|
};
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1125
|
+
|
|
1126
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1127
|
+
const create$2 = rpcId => {
|
|
1128
|
+
return {
|
|
1129
|
+
async dispose() {
|
|
1130
|
+
const rpc = get$4(rpcId);
|
|
1131
|
+
await rpc.dispose();
|
|
1132
|
+
},
|
|
1133
|
+
// @ts-ignore
|
|
1134
|
+
invoke(method, ...params) {
|
|
1135
|
+
const rpc = get$4(rpcId);
|
|
1136
|
+
// @ts-ignore
|
|
1137
|
+
return rpc.invoke(method, ...params);
|
|
1138
|
+
},
|
|
1139
|
+
// @ts-ignore
|
|
1140
|
+
invokeAndTransfer(method, ...params) {
|
|
1141
|
+
const rpc = get$4(rpcId);
|
|
1142
|
+
// @ts-ignore
|
|
1143
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1144
|
+
},
|
|
1145
|
+
registerMockRpc(commandMap) {
|
|
1146
|
+
const mockRpc = createMockRpc({
|
|
1147
|
+
commandMap
|
|
1536
1148
|
});
|
|
1149
|
+
set$a(rpcId, mockRpc);
|
|
1150
|
+
// @ts-ignore
|
|
1151
|
+
mockRpc[Symbol.dispose] = () => {
|
|
1152
|
+
remove(rpcId);
|
|
1153
|
+
};
|
|
1154
|
+
// @ts-ignore
|
|
1155
|
+
return mockRpc;
|
|
1156
|
+
},
|
|
1157
|
+
set(rpc) {
|
|
1158
|
+
set$a(rpcId, rpc);
|
|
1537
1159
|
}
|
|
1538
|
-
|
|
1539
|
-
}
|
|
1540
|
-
return new ErrorConstructor(message);
|
|
1160
|
+
};
|
|
1541
1161
|
};
|
|
1542
|
-
|
|
1543
|
-
|
|
1162
|
+
|
|
1163
|
+
const {
|
|
1164
|
+
invoke: invoke$7,
|
|
1165
|
+
set: set$9
|
|
1166
|
+
} = create$2(19_001);
|
|
1167
|
+
const getCacheStorageJsonItem = async (request, cacheName, bucketName, bucketOptions) => {
|
|
1168
|
+
return invoke$7('Cache.getCacheStorageJsonItem', request, cacheName, bucketName, bucketOptions);
|
|
1544
1169
|
};
|
|
1545
|
-
const
|
|
1546
|
-
return
|
|
1170
|
+
const setCacheStorageJsonItem = async (request, value, cacheName, bucketName, bucketOptions) => {
|
|
1171
|
+
return invoke$7('Cache.setCacheStorageJsonItem', request, value, cacheName, bucketName, bucketOptions);
|
|
1547
1172
|
};
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1173
|
+
|
|
1174
|
+
const Status = 'status';
|
|
1175
|
+
|
|
1176
|
+
const MaskIcon = 'MaskIcon';
|
|
1177
|
+
|
|
1178
|
+
const Button$1 = 1;
|
|
1179
|
+
const Div = 4;
|
|
1180
|
+
const Span = 8;
|
|
1181
|
+
const Text = 12;
|
|
1182
|
+
const Progress = 92;
|
|
1183
|
+
const Reference = 100;
|
|
1184
|
+
|
|
1185
|
+
const Button = 'event.button';
|
|
1186
|
+
const ClientX = 'event.clientX';
|
|
1187
|
+
const ClientY = 'event.clientY';
|
|
1188
|
+
const TargetName = 'event.target.name';
|
|
1189
|
+
|
|
1190
|
+
const ExtensionManagementWorker = 9006;
|
|
1191
|
+
const RendererProcess = 1670;
|
|
1192
|
+
const RendererWorker = 1;
|
|
1193
|
+
const TextMeasurementWorker = 7011;
|
|
1194
|
+
|
|
1195
|
+
const SetDom2 = 'Viewlet.setDom2';
|
|
1196
|
+
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1197
|
+
const SetPatches = 'Viewlet.setPatches';
|
|
1198
|
+
|
|
1199
|
+
const {
|
|
1200
|
+
invoke: invoke$6,
|
|
1201
|
+
set: set$8
|
|
1202
|
+
} = create$2(ExtensionManagementWorker);
|
|
1203
|
+
|
|
1204
|
+
const {
|
|
1205
|
+
invoke: invoke$5,
|
|
1206
|
+
set: set$7
|
|
1207
|
+
} = create$2(RendererProcess);
|
|
1208
|
+
|
|
1209
|
+
const {
|
|
1210
|
+
invoke: invoke$4,
|
|
1211
|
+
set: set$6
|
|
1212
|
+
} = create$2(TextMeasurementWorker);
|
|
1213
|
+
const measureTextWidths$1 = async (texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth) => {
|
|
1214
|
+
return invoke$4('TextMeasurement.measureTextWidths', texts, fontWeight, fontSize, fontFamily, letterSpacing, isMonoSpaceFont, charWidth);
|
|
1552
1215
|
};
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1216
|
+
|
|
1217
|
+
const {
|
|
1218
|
+
invoke: invoke$3,
|
|
1219
|
+
invokeAndTransfer,
|
|
1220
|
+
set: set$5
|
|
1221
|
+
} = create$2(RendererWorker);
|
|
1222
|
+
const sendMessagePortToTextMeasurementWorker = async port => {
|
|
1223
|
+
const command = 'TextMeasurement.handleMessagePort';
|
|
1224
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
1557
1225
|
};
|
|
1558
|
-
const
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
parentStack = error.message + NewLine + parentStack;
|
|
1562
|
-
}
|
|
1563
|
-
return parentStack;
|
|
1226
|
+
const sendMessagePortToCacheWorker = async port => {
|
|
1227
|
+
const command = 'CacheWorker.handleMessagePort';
|
|
1228
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToCacheWorker', port, command, 0);
|
|
1564
1229
|
};
|
|
1565
|
-
const
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1230
|
+
const getPreference = async key => {
|
|
1231
|
+
return await invoke$3('Preferences.get', key);
|
|
1232
|
+
};
|
|
1233
|
+
|
|
1234
|
+
const toCommandId = key => {
|
|
1235
|
+
const dotIndex = key.indexOf('.');
|
|
1236
|
+
return key.slice(dotIndex + 1);
|
|
1237
|
+
};
|
|
1238
|
+
const create$1 = () => {
|
|
1239
|
+
const commandQueues = new Map();
|
|
1240
|
+
const generations = Object.create(null);
|
|
1241
|
+
const states = Object.create(null);
|
|
1242
|
+
const commandMapRef = Object.create(null);
|
|
1243
|
+
const commandsById = Object.create(null);
|
|
1244
|
+
const getGeneration = uid => generations[uid] || 0;
|
|
1245
|
+
const isCurrentGeneration = (uid, generation) => {
|
|
1246
|
+
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
1247
|
+
};
|
|
1248
|
+
const updateState = (uid, generation, fallbackState, updater) => {
|
|
1249
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1250
|
+
return Promise.resolve(fallbackState);
|
|
1572
1251
|
}
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1252
|
+
const current = states[uid];
|
|
1253
|
+
const updatedState = updater(current.newState);
|
|
1254
|
+
if (updatedState !== current.newState) {
|
|
1255
|
+
states[uid] = {
|
|
1256
|
+
newState: updatedState,
|
|
1257
|
+
oldState: current.oldState,
|
|
1258
|
+
scheduledState: updatedState
|
|
1259
|
+
};
|
|
1260
|
+
}
|
|
1261
|
+
return Promise.resolve(updatedState);
|
|
1262
|
+
};
|
|
1263
|
+
const createAsyncCommandContext = (uid, generation) => {
|
|
1264
|
+
let latestState = states[uid].newState;
|
|
1265
|
+
return {
|
|
1266
|
+
getState: () => {
|
|
1267
|
+
if (isCurrentGeneration(uid, generation)) {
|
|
1268
|
+
latestState = states[uid].newState;
|
|
1269
|
+
}
|
|
1270
|
+
return latestState;
|
|
1271
|
+
},
|
|
1272
|
+
updateState: async updater => {
|
|
1273
|
+
latestState = await updateState(uid, generation, latestState, updater);
|
|
1274
|
+
return latestState;
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
};
|
|
1278
|
+
const enqueueCommand = async (uid, command) => {
|
|
1279
|
+
const previous = commandQueues.get(uid) || Promise.resolve();
|
|
1280
|
+
const run = async () => {
|
|
1281
|
+
try {
|
|
1282
|
+
await previous;
|
|
1283
|
+
} catch {
|
|
1284
|
+
// The previous caller receives its error; later commands must still run.
|
|
1285
|
+
}
|
|
1286
|
+
await command();
|
|
1287
|
+
};
|
|
1288
|
+
const current = run();
|
|
1289
|
+
commandQueues.set(uid, current);
|
|
1290
|
+
try {
|
|
1291
|
+
await current;
|
|
1292
|
+
} finally {
|
|
1293
|
+
if (commandQueues.get(uid) === current) {
|
|
1294
|
+
commandQueues.delete(uid);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
};
|
|
1298
|
+
return {
|
|
1299
|
+
clear() {
|
|
1300
|
+
commandQueues.clear();
|
|
1301
|
+
for (const key of Object.keys(states)) {
|
|
1302
|
+
delete states[key];
|
|
1303
|
+
}
|
|
1304
|
+
},
|
|
1305
|
+
createDirectEventCommandMap(requestRender) {
|
|
1306
|
+
return {
|
|
1307
|
+
async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
|
|
1308
|
+
const fn = commandsById[command];
|
|
1309
|
+
if (!fn) {
|
|
1310
|
+
throw new Error(`Viewlet command not found: ${command}`);
|
|
1311
|
+
}
|
|
1312
|
+
await fn(uid, ...args);
|
|
1313
|
+
await requestRender(uid);
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
},
|
|
1317
|
+
diff(uid, modules, numbers) {
|
|
1318
|
+
const {
|
|
1319
|
+
oldState,
|
|
1320
|
+
scheduledState
|
|
1321
|
+
} = states[uid];
|
|
1322
|
+
const diffResult = [];
|
|
1323
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1324
|
+
const fn = modules[i];
|
|
1325
|
+
if (!fn(oldState, scheduledState)) {
|
|
1326
|
+
diffResult.push(numbers[i]);
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
return diffResult;
|
|
1330
|
+
},
|
|
1331
|
+
dispose(uid) {
|
|
1332
|
+
commandQueues.delete(uid);
|
|
1333
|
+
delete states[uid];
|
|
1334
|
+
},
|
|
1335
|
+
get(uid) {
|
|
1336
|
+
return states[uid];
|
|
1337
|
+
},
|
|
1338
|
+
getCommandIds() {
|
|
1339
|
+
const keys = Object.keys(commandMapRef);
|
|
1340
|
+
const ids = keys.map(toCommandId);
|
|
1341
|
+
return ids;
|
|
1342
|
+
},
|
|
1343
|
+
getKeys() {
|
|
1344
|
+
return Object.keys(states).map(Number);
|
|
1345
|
+
},
|
|
1346
|
+
registerCommands(commandMap) {
|
|
1347
|
+
Object.assign(commandMapRef, commandMap);
|
|
1348
|
+
for (const [key, fn] of Object.entries(commandMap)) {
|
|
1349
|
+
commandsById[toCommandId(key)] = fn;
|
|
1350
|
+
}
|
|
1351
|
+
},
|
|
1352
|
+
set(uid, oldState, newState, scheduledState) {
|
|
1353
|
+
const current = states[uid];
|
|
1354
|
+
if (!current || oldState === newState && newState !== current.newState) {
|
|
1355
|
+
generations[uid] = getGeneration(uid) + 1;
|
|
1356
|
+
}
|
|
1357
|
+
states[uid] = {
|
|
1358
|
+
newState,
|
|
1359
|
+
oldState,
|
|
1360
|
+
scheduledState: scheduledState ?? newState
|
|
1361
|
+
};
|
|
1362
|
+
},
|
|
1363
|
+
wrapAsyncCommand(fn) {
|
|
1364
|
+
const wrapped = async (uid, ...args) => {
|
|
1365
|
+
const generation = getGeneration(uid);
|
|
1366
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1367
|
+
await fn(context, ...args);
|
|
1368
|
+
};
|
|
1369
|
+
return wrapped;
|
|
1370
|
+
},
|
|
1371
|
+
wrapCommand(fn) {
|
|
1372
|
+
const wrapped = async (uid, ...args) => {
|
|
1373
|
+
const generation = getGeneration(uid);
|
|
1374
|
+
const {
|
|
1375
|
+
newState,
|
|
1376
|
+
oldState
|
|
1377
|
+
} = states[uid];
|
|
1378
|
+
const newerState = await fn(newState, ...args);
|
|
1379
|
+
if (oldState === newerState || newState === newerState) {
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
const latestOld = states[uid];
|
|
1386
|
+
const latestNew = {
|
|
1387
|
+
...latestOld.newState,
|
|
1388
|
+
...newerState
|
|
1389
|
+
};
|
|
1390
|
+
states[uid] = {
|
|
1391
|
+
newState: latestNew,
|
|
1392
|
+
oldState: latestOld.oldState,
|
|
1393
|
+
scheduledState: latestNew
|
|
1394
|
+
};
|
|
1395
|
+
};
|
|
1396
|
+
return wrapped;
|
|
1397
|
+
},
|
|
1398
|
+
wrapGetter(fn) {
|
|
1399
|
+
const wrapped = (uid, ...args) => {
|
|
1400
|
+
const {
|
|
1401
|
+
newState
|
|
1402
|
+
} = states[uid];
|
|
1403
|
+
return fn(newState, ...args);
|
|
1404
|
+
};
|
|
1405
|
+
return wrapped;
|
|
1406
|
+
},
|
|
1407
|
+
wrapLoadContent(fn) {
|
|
1408
|
+
const wrapped = async (uid, ...args) => {
|
|
1409
|
+
const generation = getGeneration(uid);
|
|
1410
|
+
const {
|
|
1411
|
+
newState,
|
|
1412
|
+
oldState
|
|
1413
|
+
} = states[uid];
|
|
1414
|
+
const result = await fn(newState, ...args);
|
|
1415
|
+
const {
|
|
1416
|
+
error,
|
|
1417
|
+
state
|
|
1418
|
+
} = result;
|
|
1419
|
+
if (oldState === state || newState === state) {
|
|
1420
|
+
return {
|
|
1421
|
+
error
|
|
1422
|
+
};
|
|
1423
|
+
}
|
|
1424
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1425
|
+
return {
|
|
1426
|
+
error
|
|
1427
|
+
};
|
|
1428
|
+
}
|
|
1429
|
+
const latestOld = states[uid];
|
|
1430
|
+
const latestNew = {
|
|
1431
|
+
...latestOld.newState,
|
|
1432
|
+
...state
|
|
1433
|
+
};
|
|
1434
|
+
states[uid] = {
|
|
1435
|
+
newState: latestNew,
|
|
1436
|
+
oldState: latestOld.oldState,
|
|
1437
|
+
scheduledState: latestNew
|
|
1438
|
+
};
|
|
1439
|
+
return {
|
|
1440
|
+
error
|
|
1441
|
+
};
|
|
1442
|
+
};
|
|
1443
|
+
return wrapped;
|
|
1444
|
+
},
|
|
1445
|
+
wrapSerialAsyncCommand(fn) {
|
|
1446
|
+
const wrapped = async (uid, ...args) => {
|
|
1447
|
+
await enqueueCommand(uid, async () => {
|
|
1448
|
+
if (!states[uid]) {
|
|
1449
|
+
return;
|
|
1450
|
+
}
|
|
1451
|
+
const generation = getGeneration(uid);
|
|
1452
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1453
|
+
await fn(context, ...args);
|
|
1454
|
+
});
|
|
1455
|
+
};
|
|
1456
|
+
return wrapped;
|
|
1457
|
+
},
|
|
1458
|
+
wrapSerialCommand(fn) {
|
|
1459
|
+
const wrapped = async (uid, ...args) => {
|
|
1460
|
+
await enqueueCommand(uid, async () => {
|
|
1461
|
+
if (!states[uid]) {
|
|
1462
|
+
return;
|
|
1463
|
+
}
|
|
1464
|
+
const generation = getGeneration(uid);
|
|
1465
|
+
const {
|
|
1466
|
+
newState,
|
|
1467
|
+
oldState
|
|
1468
|
+
} = states[uid];
|
|
1469
|
+
const newerState = await fn(newState, ...args);
|
|
1470
|
+
if (oldState === newerState || newState === newerState) {
|
|
1471
|
+
return;
|
|
1472
|
+
}
|
|
1473
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1474
|
+
return;
|
|
1475
|
+
}
|
|
1476
|
+
const latestOld = states[uid];
|
|
1477
|
+
const latestNew = {
|
|
1478
|
+
...latestOld.newState,
|
|
1479
|
+
...newerState
|
|
1480
|
+
};
|
|
1481
|
+
states[uid] = {
|
|
1482
|
+
newState: latestNew,
|
|
1483
|
+
oldState: latestOld.oldState,
|
|
1484
|
+
scheduledState: latestNew
|
|
1485
|
+
};
|
|
1486
|
+
});
|
|
1487
|
+
};
|
|
1488
|
+
return wrapped;
|
|
1576
1489
|
}
|
|
1577
|
-
}
|
|
1578
|
-
Object.defineProperty(error, 'stack', {
|
|
1579
|
-
configurable: true,
|
|
1580
|
-
value: stack,
|
|
1581
|
-
writable: true
|
|
1582
|
-
});
|
|
1583
|
-
};
|
|
1584
|
-
const restoreExistingError = (error, currentStack) => {
|
|
1585
|
-
if (typeof error.stack === 'string') {
|
|
1586
|
-
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
1587
|
-
}
|
|
1588
|
-
return error;
|
|
1589
|
-
};
|
|
1590
|
-
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
1591
|
-
const restoredError = new JsonRpcError(error.message);
|
|
1592
|
-
Object.assign(restoredError, {
|
|
1593
|
-
code: error.code
|
|
1594
|
-
});
|
|
1595
|
-
const parentStack = getParentStack(error);
|
|
1596
|
-
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
1597
|
-
return restoredError;
|
|
1598
|
-
};
|
|
1599
|
-
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
1600
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
1601
|
-
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
1602
|
-
return;
|
|
1603
|
-
}
|
|
1604
|
-
if (error.data.stack) {
|
|
1605
|
-
setStack(restoredError, error.data.stack);
|
|
1606
|
-
}
|
|
1607
|
-
};
|
|
1608
|
-
const applyDataProperties = (restoredError, error) => {
|
|
1609
|
-
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
1610
|
-
if (error.data.codeFrame) {
|
|
1611
|
-
// @ts-ignore
|
|
1612
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
1613
|
-
}
|
|
1614
|
-
if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
|
|
1615
|
-
// @ts-ignore
|
|
1616
|
-
Object.defineProperty(restoredError, 'code', {
|
|
1617
|
-
configurable: true,
|
|
1618
|
-
value: error.data.code,
|
|
1619
|
-
writable: true
|
|
1620
|
-
});
|
|
1621
|
-
}
|
|
1622
|
-
if (error.data.type) {
|
|
1623
|
-
// @ts-ignore
|
|
1624
|
-
restoredError.name = error.data.type;
|
|
1625
|
-
}
|
|
1626
|
-
};
|
|
1627
|
-
const applyDirectProperties = (restoredError, error) => {
|
|
1628
|
-
if (error.stack) {
|
|
1629
|
-
const lowerStack = restoredError.stack || '';
|
|
1630
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
1631
|
-
const parentStack = getParentStack(error);
|
|
1632
|
-
// @ts-ignore
|
|
1633
|
-
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
1634
|
-
}
|
|
1635
|
-
if (error.codeFrame) {
|
|
1636
|
-
// @ts-ignore
|
|
1637
|
-
restoredError.codeFrame = error.codeFrame;
|
|
1638
|
-
}
|
|
1639
|
-
};
|
|
1640
|
-
const restoreMessageError = (error, _currentStack) => {
|
|
1641
|
-
const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
|
|
1642
|
-
if (typeof error.code === 'string' || typeof error.code === 'number') {
|
|
1643
|
-
Object.defineProperty(restoredError, 'code', {
|
|
1644
|
-
configurable: true,
|
|
1645
|
-
value: error.code,
|
|
1646
|
-
writable: true
|
|
1647
|
-
});
|
|
1648
|
-
}
|
|
1649
|
-
if (error.data) {
|
|
1650
|
-
applyDataProperties(restoredError, error);
|
|
1651
|
-
} else {
|
|
1652
|
-
applyDirectProperties(restoredError, error);
|
|
1653
|
-
}
|
|
1654
|
-
return restoredError;
|
|
1655
|
-
};
|
|
1656
|
-
const getFallbackMessage = error => {
|
|
1657
|
-
if (error && typeof error.message === 'string' && error.message) {
|
|
1658
|
-
return error.message;
|
|
1659
|
-
}
|
|
1660
|
-
if (error && error.data) {
|
|
1661
|
-
return getFallbackMessage(error.data);
|
|
1662
|
-
}
|
|
1663
|
-
const stringified = String(error);
|
|
1664
|
-
if (stringified !== '[object Object]') {
|
|
1665
|
-
return stringified;
|
|
1666
|
-
}
|
|
1667
|
-
try {
|
|
1668
|
-
return JSON.stringify(error);
|
|
1669
|
-
} catch {
|
|
1670
|
-
return stringified;
|
|
1671
|
-
}
|
|
1672
|
-
};
|
|
1673
|
-
const restoreJsonRpcError = error => {
|
|
1674
|
-
const currentStack = getCurrentStack();
|
|
1675
|
-
if (error && error instanceof Error) {
|
|
1676
|
-
return restoreExistingError(error, currentStack);
|
|
1677
|
-
}
|
|
1678
|
-
if (error && error.code && error.code === MethodNotFound) {
|
|
1679
|
-
return restoreMethodNotFoundError(error, currentStack);
|
|
1680
|
-
}
|
|
1681
|
-
if (error && error.error) {
|
|
1682
|
-
return restoreJsonRpcError(error.error);
|
|
1683
|
-
}
|
|
1684
|
-
if (error && error.message) {
|
|
1685
|
-
return restoreMessageError(error);
|
|
1686
|
-
}
|
|
1687
|
-
return new Error(`JsonRpc Error: ${getFallbackMessage(error)}`);
|
|
1688
|
-
};
|
|
1689
|
-
const unwrapJsonRpcResult = responseMessage => {
|
|
1690
|
-
if ('error' in responseMessage) {
|
|
1691
|
-
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
1692
|
-
throw restoredError;
|
|
1693
|
-
}
|
|
1694
|
-
if ('result' in responseMessage) {
|
|
1695
|
-
return responseMessage.result;
|
|
1696
|
-
}
|
|
1697
|
-
throw new JsonRpcError('unexpected response message');
|
|
1698
|
-
};
|
|
1699
|
-
const warn = (...args) => {
|
|
1700
|
-
console.warn(...args);
|
|
1490
|
+
};
|
|
1701
1491
|
};
|
|
1702
|
-
const
|
|
1703
|
-
|
|
1704
|
-
if (!fn) {
|
|
1705
|
-
console.log(response);
|
|
1706
|
-
warn(`callback ${id} may already be disposed`);
|
|
1707
|
-
return;
|
|
1708
|
-
}
|
|
1709
|
-
fn(response);
|
|
1710
|
-
remove$1(id);
|
|
1492
|
+
const terminate = () => {
|
|
1493
|
+
globalThis.close();
|
|
1711
1494
|
};
|
|
1712
|
-
|
|
1713
|
-
const
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1495
|
+
|
|
1496
|
+
const {
|
|
1497
|
+
get: get$3,
|
|
1498
|
+
getCommandIds,
|
|
1499
|
+
getKeys: getKeys$1,
|
|
1500
|
+
registerCommands,
|
|
1501
|
+
set: set$4,
|
|
1502
|
+
wrapCommand,
|
|
1503
|
+
wrapGetter,
|
|
1504
|
+
wrapSerialAsyncCommand} = create$1();
|
|
1505
|
+
|
|
1506
|
+
const create = (uid, uri, x, y, width, height, platform, assetDir, applicationId) => {
|
|
1507
|
+
const state = {
|
|
1508
|
+
...(applicationId !== undefined && {
|
|
1509
|
+
applicationId
|
|
1510
|
+
}),
|
|
1511
|
+
assetDir,
|
|
1512
|
+
errorCount: 0,
|
|
1513
|
+
initial: true,
|
|
1514
|
+
platform,
|
|
1515
|
+
statusBarItemsLeft: [],
|
|
1516
|
+
statusBarItemsRight: [],
|
|
1517
|
+
uid,
|
|
1518
|
+
visibleStatusBarItemsLeft: [],
|
|
1519
|
+
visibleStatusBarItemsRight: [],
|
|
1520
|
+
warningCount: 0,
|
|
1521
|
+
width
|
|
1522
|
+
};
|
|
1523
|
+
set$4(uid, state, state);
|
|
1721
1524
|
};
|
|
1722
|
-
|
|
1723
|
-
|
|
1525
|
+
|
|
1526
|
+
const areItemsEqual = (left, right) => {
|
|
1527
|
+
return left.length === right.length && left.every((item, index) => item === right[index]);
|
|
1724
1528
|
};
|
|
1725
|
-
const
|
|
1726
|
-
|
|
1727
|
-
const newLineIndex = stackString.indexOf('\n');
|
|
1728
|
-
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
1729
|
-
return stackString.slice(newLineIndex + 1);
|
|
1730
|
-
}
|
|
1731
|
-
return stackString;
|
|
1529
|
+
const isEqual = (oldState, newState) => {
|
|
1530
|
+
return oldState.statusBarItemsLeft === newState.statusBarItemsLeft && oldState.statusBarItemsRight === newState.statusBarItemsRight && oldState.width === newState.width && areItemsEqual(oldState.visibleStatusBarItemsLeft, newState.visibleStatusBarItemsLeft) && areItemsEqual(oldState.visibleStatusBarItemsRight, newState.visibleStatusBarItemsRight);
|
|
1732
1531
|
};
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1532
|
+
|
|
1533
|
+
const RenderItems = 4;
|
|
1534
|
+
const RenderIncremental = 11;
|
|
1535
|
+
|
|
1536
|
+
const modules = [isEqual];
|
|
1537
|
+
const numbers = [RenderIncremental];
|
|
1538
|
+
|
|
1539
|
+
const diff = (oldState, newState) => {
|
|
1540
|
+
const diffResult = [];
|
|
1541
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1542
|
+
const fn = modules[i];
|
|
1543
|
+
if (!fn(oldState, newState)) {
|
|
1544
|
+
diffResult.push(numbers[i]);
|
|
1545
|
+
}
|
|
1740
1546
|
}
|
|
1741
|
-
return
|
|
1742
|
-
code: Custom,
|
|
1743
|
-
data: {
|
|
1744
|
-
code: prettyError.code ?? error?.code,
|
|
1745
|
-
codeFrame: prettyError.codeFrame,
|
|
1746
|
-
name: prettyError.name ?? error?.name,
|
|
1747
|
-
stack: getStack(prettyError),
|
|
1748
|
-
type: getErrorType(prettyError)
|
|
1749
|
-
},
|
|
1750
|
-
message: prettyError.message
|
|
1751
|
-
};
|
|
1752
|
-
};
|
|
1753
|
-
const create$1$1 = (id, error) => {
|
|
1754
|
-
return {
|
|
1755
|
-
error,
|
|
1756
|
-
id,
|
|
1757
|
-
jsonrpc: Two$1
|
|
1758
|
-
};
|
|
1759
|
-
};
|
|
1760
|
-
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
1761
|
-
const prettyError = preparePrettyError(error);
|
|
1762
|
-
logError(error, prettyError);
|
|
1763
|
-
const errorProperty = getErrorProperty(error, prettyError);
|
|
1764
|
-
return create$1$1(id, errorProperty);
|
|
1547
|
+
return diffResult;
|
|
1765
1548
|
};
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
};
|
|
1549
|
+
|
|
1550
|
+
const diff2 = uid => {
|
|
1551
|
+
const {
|
|
1552
|
+
newState,
|
|
1553
|
+
oldState
|
|
1554
|
+
} = get$3(uid);
|
|
1555
|
+
const result = diff(oldState, newState);
|
|
1556
|
+
return result;
|
|
1772
1557
|
};
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
return
|
|
1558
|
+
|
|
1559
|
+
const getComponentState = uid => {
|
|
1560
|
+
return get$3(uid).newState;
|
|
1776
1561
|
};
|
|
1777
|
-
|
|
1562
|
+
|
|
1563
|
+
const mergeClassNames = (...classNames) => {
|
|
1564
|
+
return classNames.filter(Boolean).join(' ');
|
|
1565
|
+
};
|
|
1566
|
+
|
|
1567
|
+
const text = data => {
|
|
1778
1568
|
return {
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
...error,
|
|
1783
|
-
code: 'code' in error ? error.code : undefined,
|
|
1784
|
-
stack: error.stack,
|
|
1785
|
-
type: error.name
|
|
1786
|
-
} : error,
|
|
1787
|
-
// @ts-ignore
|
|
1788
|
-
message: error.message
|
|
1789
|
-
},
|
|
1790
|
-
id,
|
|
1791
|
-
jsonrpc: Two$1
|
|
1569
|
+
childCount: 0,
|
|
1570
|
+
text: data,
|
|
1571
|
+
type: Text
|
|
1792
1572
|
};
|
|
1793
1573
|
};
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
const
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
// ignore
|
|
1574
|
+
|
|
1575
|
+
const SetText = 1;
|
|
1576
|
+
const Replace = 2;
|
|
1577
|
+
const SetAttribute = 3;
|
|
1578
|
+
const RemoveAttribute = 4;
|
|
1579
|
+
const Add = 6;
|
|
1580
|
+
const NavigateChild = 7;
|
|
1581
|
+
const NavigateParent = 8;
|
|
1582
|
+
const RemoveChild = 9;
|
|
1583
|
+
const NavigateSibling = 10;
|
|
1584
|
+
const SetReferenceNodeUid = 11;
|
|
1585
|
+
const MultiNavigation = 18;
|
|
1586
|
+
|
|
1587
|
+
const isKey = key => {
|
|
1588
|
+
return key !== 'type' && key !== 'childCount';
|
|
1810
1589
|
};
|
|
1811
|
-
|
|
1812
|
-
|
|
1590
|
+
|
|
1591
|
+
const getKeys = node => {
|
|
1592
|
+
const keys = Object.keys(node).filter(isKey);
|
|
1593
|
+
return keys;
|
|
1813
1594
|
};
|
|
1814
|
-
const defaultResolve = resolve;
|
|
1815
1595
|
|
|
1816
|
-
|
|
1817
|
-
const
|
|
1818
|
-
|
|
1819
|
-
|
|
1596
|
+
const arrayToTree = nodes => {
|
|
1597
|
+
const result = [];
|
|
1598
|
+
let i = 0;
|
|
1599
|
+
while (i < nodes.length) {
|
|
1600
|
+
const node = nodes[i];
|
|
1601
|
+
const {
|
|
1602
|
+
children,
|
|
1603
|
+
nodesConsumed
|
|
1604
|
+
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
1605
|
+
result.push({
|
|
1606
|
+
node,
|
|
1607
|
+
children
|
|
1608
|
+
});
|
|
1609
|
+
i += 1 + nodesConsumed;
|
|
1610
|
+
}
|
|
1611
|
+
return result;
|
|
1612
|
+
};
|
|
1613
|
+
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
1614
|
+
if (childCount === 0) {
|
|
1820
1615
|
return {
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
logError: options.logError || defaultLogError,
|
|
1824
|
-
message: options.message,
|
|
1825
|
-
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
1826
|
-
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
1827
|
-
resolve: options.resolve || defaultResolve
|
|
1616
|
+
children: [],
|
|
1617
|
+
nodesConsumed: 0
|
|
1828
1618
|
};
|
|
1829
1619
|
}
|
|
1620
|
+
const children = [];
|
|
1621
|
+
let i = startIndex;
|
|
1622
|
+
let remaining = childCount;
|
|
1623
|
+
let totalConsumed = 0;
|
|
1624
|
+
while (remaining > 0 && i < nodes.length) {
|
|
1625
|
+
const node = nodes[i];
|
|
1626
|
+
const nodeChildCount = node.childCount || 0;
|
|
1627
|
+
const {
|
|
1628
|
+
children: nodeChildren,
|
|
1629
|
+
nodesConsumed
|
|
1630
|
+
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
1631
|
+
children.push({
|
|
1632
|
+
node,
|
|
1633
|
+
children: nodeChildren
|
|
1634
|
+
});
|
|
1635
|
+
const nodeSize = 1 + nodesConsumed;
|
|
1636
|
+
i += nodeSize;
|
|
1637
|
+
totalConsumed += nodeSize;
|
|
1638
|
+
remaining--;
|
|
1639
|
+
}
|
|
1830
1640
|
return {
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
logError: args[5],
|
|
1834
|
-
message: args[1],
|
|
1835
|
-
preparePrettyError: args[4],
|
|
1836
|
-
requiresSocket: args[6],
|
|
1837
|
-
resolve: args[3]
|
|
1641
|
+
children,
|
|
1642
|
+
nodesConsumed: totalConsumed
|
|
1838
1643
|
};
|
|
1839
1644
|
};
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1645
|
+
|
|
1646
|
+
const isNavigationPatch = patch => {
|
|
1647
|
+
switch (patch.type) {
|
|
1648
|
+
case NavigateChild:
|
|
1649
|
+
case NavigateParent:
|
|
1650
|
+
case NavigateSibling:
|
|
1651
|
+
return true;
|
|
1652
|
+
default:
|
|
1653
|
+
return false;
|
|
1654
|
+
}
|
|
1655
|
+
};
|
|
1656
|
+
const getNavigationIndex = patch => {
|
|
1657
|
+
switch (patch.type) {
|
|
1658
|
+
case NavigateChild:
|
|
1659
|
+
case NavigateSibling:
|
|
1660
|
+
return patch.index;
|
|
1661
|
+
default:
|
|
1662
|
+
return 0;
|
|
1663
|
+
}
|
|
1664
|
+
};
|
|
1665
|
+
const appendNavigationPatch = (patches, type, index) => {
|
|
1666
|
+
const previousPatch = patches.at(-1);
|
|
1667
|
+
if (!previousPatch) {
|
|
1668
|
+
patches.push(type === NavigateParent ? {
|
|
1669
|
+
type
|
|
1670
|
+
} : {
|
|
1671
|
+
index,
|
|
1672
|
+
type
|
|
1673
|
+
});
|
|
1863
1674
|
return;
|
|
1864
1675
|
}
|
|
1865
|
-
if (
|
|
1866
|
-
|
|
1676
|
+
if (previousPatch.type === MultiNavigation) {
|
|
1677
|
+
previousPatch.navigations.push(type, index);
|
|
1867
1678
|
return;
|
|
1868
1679
|
}
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
const create$6 = (id, method, params) => {
|
|
1883
|
-
const message = {
|
|
1884
|
-
id,
|
|
1885
|
-
jsonrpc: Two,
|
|
1886
|
-
method,
|
|
1887
|
-
params
|
|
1888
|
-
};
|
|
1889
|
-
return message;
|
|
1680
|
+
if (isNavigationPatch(previousPatch)) {
|
|
1681
|
+
patches[patches.length - 1] = {
|
|
1682
|
+
navigations: [previousPatch.type, getNavigationIndex(previousPatch), type, index],
|
|
1683
|
+
type: MultiNavigation
|
|
1684
|
+
};
|
|
1685
|
+
return;
|
|
1686
|
+
}
|
|
1687
|
+
patches.push(type === NavigateParent ? {
|
|
1688
|
+
type
|
|
1689
|
+
} : {
|
|
1690
|
+
index,
|
|
1691
|
+
type
|
|
1692
|
+
});
|
|
1890
1693
|
};
|
|
1891
1694
|
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1695
|
+
const compareNodes = (oldNode, newNode) => {
|
|
1696
|
+
// Check if node type changed - return null to signal incompatible nodes
|
|
1697
|
+
// (caller should handle this with a Replace operation)
|
|
1698
|
+
if (oldNode.type !== newNode.type) {
|
|
1699
|
+
return null;
|
|
1700
|
+
}
|
|
1701
|
+
const patches = [];
|
|
1702
|
+
// Handle reference nodes - special handling for uid changes
|
|
1703
|
+
if (oldNode.type === Reference && oldNode.uid !== newNode.uid) {
|
|
1704
|
+
patches.push({
|
|
1705
|
+
type: SetReferenceNodeUid,
|
|
1706
|
+
uid: newNode.uid
|
|
1707
|
+
});
|
|
1708
|
+
}
|
|
1709
|
+
// Handle text nodes
|
|
1710
|
+
if (oldNode.type === Text && newNode.type === Text) {
|
|
1711
|
+
if (oldNode.text !== newNode.text) {
|
|
1712
|
+
patches.push({
|
|
1713
|
+
type: SetText,
|
|
1714
|
+
value: newNode.text
|
|
1715
|
+
});
|
|
1716
|
+
}
|
|
1717
|
+
return patches;
|
|
1718
|
+
}
|
|
1719
|
+
// Compare attributes
|
|
1720
|
+
const oldKeys = getKeys(oldNode).filter(key => oldNode.type !== Reference || key !== 'uid');
|
|
1721
|
+
const newKeys = getKeys(newNode).filter(key => newNode.type !== Reference || key !== 'uid');
|
|
1722
|
+
// Check for attribute changes
|
|
1723
|
+
for (const key of newKeys) {
|
|
1724
|
+
if (oldNode[key] !== newNode[key]) {
|
|
1725
|
+
patches.push({
|
|
1726
|
+
type: SetAttribute,
|
|
1727
|
+
key,
|
|
1728
|
+
value: newNode[key]
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
// Check for removed attributes
|
|
1733
|
+
for (const key of oldKeys) {
|
|
1734
|
+
if (!Object.hasOwn(newNode, key)) {
|
|
1735
|
+
patches.push({
|
|
1736
|
+
type: RemoveAttribute,
|
|
1737
|
+
key
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
return patches;
|
|
1895
1742
|
};
|
|
1896
1743
|
|
|
1897
|
-
const
|
|
1898
|
-
const
|
|
1899
|
-
const
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1744
|
+
const treeToArray = node => {
|
|
1745
|
+
const result = [];
|
|
1746
|
+
const stack = [node];
|
|
1747
|
+
while (stack.length > 0) {
|
|
1748
|
+
const current = stack.pop();
|
|
1749
|
+
result.push(current.node);
|
|
1750
|
+
for (let i = current.children.length - 1; i >= 0; i--) {
|
|
1751
|
+
stack.push(current.children[i]);
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
return result;
|
|
1908
1755
|
};
|
|
1909
1756
|
|
|
1910
|
-
const
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
} = registerPromise(callbacks);
|
|
1915
|
-
const message = create$6(id, method, params);
|
|
1916
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1917
|
-
ipc.sendAndTransfer(message);
|
|
1918
|
-
} else {
|
|
1919
|
-
ipc.send(message);
|
|
1757
|
+
const navigateToChild = (patches, currentChildIndex, index) => {
|
|
1758
|
+
if (currentChildIndex === -1) {
|
|
1759
|
+
appendNavigationPatch(patches, NavigateChild, index);
|
|
1760
|
+
return index;
|
|
1920
1761
|
}
|
|
1921
|
-
|
|
1922
|
-
|
|
1762
|
+
if (currentChildIndex !== index) {
|
|
1763
|
+
appendNavigationPatch(patches, NavigateSibling, index);
|
|
1764
|
+
}
|
|
1765
|
+
return index;
|
|
1923
1766
|
};
|
|
1924
|
-
const
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1767
|
+
const navigateToParent = (patches, currentChildIndex) => {
|
|
1768
|
+
if (currentChildIndex >= 0) {
|
|
1769
|
+
appendNavigationPatch(patches, NavigateParent, 0);
|
|
1770
|
+
}
|
|
1771
|
+
return -1;
|
|
1772
|
+
};
|
|
1773
|
+
const addTree = (newNode, patches) => {
|
|
1774
|
+
patches.push({
|
|
1775
|
+
type: Add,
|
|
1776
|
+
nodes: treeToArray(newNode)
|
|
1777
|
+
});
|
|
1778
|
+
};
|
|
1779
|
+
const replaceTree = (newNode, patches) => {
|
|
1780
|
+
patches.push({
|
|
1781
|
+
type: Replace,
|
|
1782
|
+
nodes: treeToArray(newNode)
|
|
1783
|
+
});
|
|
1784
|
+
};
|
|
1785
|
+
const appendPatch = (patches, patch) => {
|
|
1786
|
+
switch (patch.type) {
|
|
1787
|
+
case MultiNavigation:
|
|
1788
|
+
for (let i = 0; i < patch.navigations.length; i += 2) {
|
|
1789
|
+
appendNavigationPatch(patches, patch.navigations[i], patch.navigations[i + 1]);
|
|
1790
|
+
}
|
|
1930
1791
|
return;
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
},
|
|
1942
|
-
invokeAndTransfer(method, ...params) {
|
|
1943
|
-
return invokeHelper(callbacks, ipc, method, params, true);
|
|
1944
|
-
},
|
|
1945
|
-
// @ts-ignore
|
|
1946
|
-
ipc,
|
|
1947
|
-
/**
|
|
1948
|
-
* @deprecated
|
|
1949
|
-
*/
|
|
1950
|
-
send(method, ...params) {
|
|
1951
|
-
const message = create$7(method, params);
|
|
1952
|
-
ipc.send(message);
|
|
1953
|
-
}
|
|
1954
|
-
};
|
|
1955
|
-
return rpc;
|
|
1792
|
+
case NavigateChild:
|
|
1793
|
+
case NavigateSibling:
|
|
1794
|
+
appendNavigationPatch(patches, patch.type, patch.index);
|
|
1795
|
+
return;
|
|
1796
|
+
case NavigateParent:
|
|
1797
|
+
appendNavigationPatch(patches, patch.type, 0);
|
|
1798
|
+
return;
|
|
1799
|
+
default:
|
|
1800
|
+
patches.push(patch);
|
|
1801
|
+
}
|
|
1956
1802
|
};
|
|
1957
|
-
|
|
1958
|
-
const
|
|
1959
|
-
|
|
1803
|
+
const appendPatches = (patches, newPatches) => {
|
|
1804
|
+
for (const patch of newPatches) {
|
|
1805
|
+
appendPatch(patches, patch);
|
|
1806
|
+
}
|
|
1960
1807
|
};
|
|
1961
|
-
const
|
|
1962
|
-
|
|
1808
|
+
const diffExistingChild = (oldNode, newNode, patches, currentChildIndex, index) => {
|
|
1809
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1810
|
+
if (nodePatches === null) {
|
|
1811
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
1812
|
+
replaceTree(newNode, patches);
|
|
1813
|
+
return nextChildIndex;
|
|
1814
|
+
}
|
|
1815
|
+
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
1816
|
+
const childPatches = [];
|
|
1817
|
+
if (hasChildrenToCompare) {
|
|
1818
|
+
diffChildren(oldNode.children, newNode.children, childPatches);
|
|
1819
|
+
}
|
|
1820
|
+
if (nodePatches.length === 0 && childPatches.length === 0) {
|
|
1821
|
+
return currentChildIndex;
|
|
1822
|
+
}
|
|
1823
|
+
const nextChildIndex = navigateToChild(patches, currentChildIndex, index);
|
|
1824
|
+
patches.push(...nodePatches);
|
|
1825
|
+
appendPatches(patches, childPatches);
|
|
1826
|
+
return nextChildIndex;
|
|
1963
1827
|
};
|
|
1964
|
-
const
|
|
1965
|
-
|
|
1828
|
+
const diffRootNode = (oldNode, newNode, patches) => {
|
|
1829
|
+
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
1830
|
+
if (nodePatches === null) {
|
|
1831
|
+
replaceTree(newNode, patches);
|
|
1832
|
+
return;
|
|
1833
|
+
}
|
|
1834
|
+
if (nodePatches.length > 0) {
|
|
1835
|
+
patches.push(...nodePatches);
|
|
1836
|
+
}
|
|
1837
|
+
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
1838
|
+
diffChildren(oldNode.children, newNode.children, patches);
|
|
1839
|
+
}
|
|
1966
1840
|
};
|
|
1967
|
-
const
|
|
1968
|
-
const
|
|
1969
|
-
|
|
1970
|
-
|
|
1841
|
+
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
1842
|
+
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
1843
|
+
let currentChildIndex = -1;
|
|
1844
|
+
const indicesToRemove = [];
|
|
1845
|
+
for (let i = 0; i < maxLength; i++) {
|
|
1846
|
+
const oldNode = oldChildren[i];
|
|
1847
|
+
const newNode = newChildren[i];
|
|
1848
|
+
if (!oldNode && !newNode) {
|
|
1849
|
+
continue;
|
|
1850
|
+
}
|
|
1851
|
+
if (!oldNode) {
|
|
1852
|
+
currentChildIndex = navigateToParent(patches, currentChildIndex);
|
|
1853
|
+
addTree(newNode, patches);
|
|
1854
|
+
continue;
|
|
1855
|
+
}
|
|
1856
|
+
if (!newNode) {
|
|
1857
|
+
indicesToRemove.push(i);
|
|
1858
|
+
continue;
|
|
1859
|
+
}
|
|
1860
|
+
currentChildIndex = diffExistingChild(oldNode, newNode, patches, currentChildIndex, i);
|
|
1861
|
+
}
|
|
1862
|
+
navigateToParent(patches, currentChildIndex);
|
|
1863
|
+
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
1864
|
+
patches.push({
|
|
1865
|
+
type: RemoveChild,
|
|
1866
|
+
index: indicesToRemove[j]
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1971
1869
|
};
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
} else if ('on' in ipc) {
|
|
1977
|
-
// deprecated
|
|
1978
|
-
ipc.on('message', handleMessage);
|
|
1870
|
+
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
1871
|
+
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
1872
|
+
diffRootNode(oldTree[0], newTree[0], patches);
|
|
1873
|
+
return;
|
|
1979
1874
|
}
|
|
1875
|
+
diffChildren(oldTree, newTree, patches);
|
|
1980
1876
|
};
|
|
1981
1877
|
|
|
1982
|
-
const
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1878
|
+
const removeTrailingNavigationPatches = patches => {
|
|
1879
|
+
while (patches.length > 0) {
|
|
1880
|
+
const patch = patches.at(-1);
|
|
1881
|
+
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling && patch.type !== MultiNavigation) {
|
|
1882
|
+
break;
|
|
1883
|
+
}
|
|
1884
|
+
patches.pop();
|
|
1986
1885
|
}
|
|
1987
|
-
|
|
1988
|
-
return ipc;
|
|
1886
|
+
return patches;
|
|
1989
1887
|
};
|
|
1990
1888
|
|
|
1991
|
-
const
|
|
1992
|
-
|
|
1993
|
-
const
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
return
|
|
2000
|
-
async dispose() {
|
|
2001
|
-
const rpc = await getOrCreate();
|
|
2002
|
-
await rpc.dispose();
|
|
2003
|
-
},
|
|
2004
|
-
async invoke(method, ...params) {
|
|
2005
|
-
const rpc = await getOrCreate();
|
|
2006
|
-
return rpc.invoke(method, ...params);
|
|
2007
|
-
},
|
|
2008
|
-
async invokeAndTransfer(method, ...params) {
|
|
2009
|
-
const rpc = await getOrCreate();
|
|
2010
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
2011
|
-
},
|
|
2012
|
-
async send(method, ...params) {
|
|
2013
|
-
const rpc = await getOrCreate();
|
|
2014
|
-
rpc.send(method, ...params);
|
|
2015
|
-
}
|
|
2016
|
-
};
|
|
1889
|
+
const diffTree = (oldNodes, newNodes) => {
|
|
1890
|
+
// Step 1: Convert flat arrays to tree structures
|
|
1891
|
+
const oldTree = arrayToTree(oldNodes);
|
|
1892
|
+
const newTree = arrayToTree(newNodes);
|
|
1893
|
+
// Step 3: Compare the trees
|
|
1894
|
+
const patches = [];
|
|
1895
|
+
diffTrees(oldTree, newTree, patches, []);
|
|
1896
|
+
// Remove trailing navigation patches since they serve no purpose
|
|
1897
|
+
return removeTrailingNavigationPatches(patches);
|
|
2017
1898
|
};
|
|
2018
1899
|
|
|
2019
|
-
const
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
1900
|
+
const HandleContextMenu = 2;
|
|
1901
|
+
const HandleClick = 11;
|
|
1902
|
+
|
|
1903
|
+
const ProblemsErrorIcon = 'ProblemsErrorIcon';
|
|
1904
|
+
const ProblemsWarningIcon = 'ProblemsWarningIcon';
|
|
1905
|
+
const StatusBarItem = 'StatusBarItem';
|
|
1906
|
+
const StatusBarItemsLeft = 'StatusBarItemsLeft';
|
|
1907
|
+
const StatusBarItemsRight = 'StatusBarItemsRight';
|
|
1908
|
+
|
|
1909
|
+
const getTextVirtualDom = (element, name) => {
|
|
1910
|
+
return [{
|
|
1911
|
+
childCount: 1,
|
|
1912
|
+
className: 'StatusBarItemLabel',
|
|
1913
|
+
name,
|
|
1914
|
+
type: Span
|
|
1915
|
+
}, text(element.value)];
|
|
1916
|
+
};
|
|
1917
|
+
const getIconVirtualDom = (element, name) => {
|
|
1918
|
+
return [{
|
|
1919
|
+
childCount: 0,
|
|
1920
|
+
className: mergeClassNames(MaskIcon, 'StatusBarIcon', element.value, element.spinning ? 'Spinning' : ''),
|
|
1921
|
+
name,
|
|
1922
|
+
type: Div
|
|
1923
|
+
}];
|
|
1924
|
+
};
|
|
1925
|
+
const getProgressVirtualDom = (element, name) => {
|
|
1926
|
+
const node = {
|
|
1927
|
+
ariaLabel: element.ariaLabel,
|
|
1928
|
+
className: 'StatusBarItemProgress',
|
|
1929
|
+
max: element.max,
|
|
1930
|
+
name,
|
|
1931
|
+
type: Progress
|
|
1932
|
+
};
|
|
1933
|
+
if (element.value !== undefined) {
|
|
1934
|
+
return [{
|
|
1935
|
+
...node,
|
|
1936
|
+
value: element.value
|
|
1937
|
+
}];
|
|
1938
|
+
}
|
|
1939
|
+
return [node];
|
|
1940
|
+
};
|
|
1941
|
+
const getStatusBarItemElementVirtualDom = (element, name) => {
|
|
1942
|
+
if (element.type === 'text') {
|
|
1943
|
+
return getTextVirtualDom(element, name);
|
|
1944
|
+
}
|
|
1945
|
+
if (element.type === 'icon') {
|
|
1946
|
+
return getIconVirtualDom(element, name);
|
|
1947
|
+
}
|
|
1948
|
+
if (element.type === 'progress') {
|
|
1949
|
+
return getProgressVirtualDom(element, name);
|
|
1950
|
+
}
|
|
1951
|
+
return [];
|
|
2035
1952
|
};
|
|
2036
1953
|
|
|
2037
|
-
const
|
|
2038
|
-
commandMap,
|
|
2039
|
-
isMessagePortOpen,
|
|
2040
|
-
send
|
|
2041
|
-
}) => {
|
|
1954
|
+
const getStatusBarItemVirtualDom = statusBarItem => {
|
|
2042
1955
|
const {
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
1956
|
+
ariaLabel,
|
|
1957
|
+
elements,
|
|
1958
|
+
name,
|
|
1959
|
+
tooltip
|
|
1960
|
+
} = statusBarItem;
|
|
1961
|
+
const elementNodes = elements.flatMap(element => getStatusBarItemElementVirtualDom(element, name));
|
|
1962
|
+
const buttonNode = {
|
|
1963
|
+
ariaLabel,
|
|
1964
|
+
childCount: elements.length,
|
|
1965
|
+
className: StatusBarItem,
|
|
1966
|
+
name,
|
|
1967
|
+
tabIndex: -1,
|
|
1968
|
+
title: tooltip,
|
|
1969
|
+
type: Button$1
|
|
1970
|
+
};
|
|
1971
|
+
return [buttonNode, ...elementNodes];
|
|
2052
1972
|
};
|
|
2053
1973
|
|
|
2054
|
-
const
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
send
|
|
2064
|
-
});
|
|
2065
|
-
});
|
|
1974
|
+
const getStatusBarItemsVirtualDom = (items, className) => {
|
|
1975
|
+
if (items.length === 0) {
|
|
1976
|
+
return [];
|
|
1977
|
+
}
|
|
1978
|
+
return [{
|
|
1979
|
+
childCount: items.length,
|
|
1980
|
+
className,
|
|
1981
|
+
type: Div
|
|
1982
|
+
}, ...items.flatMap(getStatusBarItemVirtualDom)];
|
|
2066
1983
|
};
|
|
2067
1984
|
|
|
2068
|
-
const
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
1985
|
+
const emptyStatusBarItemsLeftDom = [{
|
|
1986
|
+
childCount: 0,
|
|
1987
|
+
className: StatusBarItemsLeft,
|
|
1988
|
+
type: Div
|
|
1989
|
+
}];
|
|
1990
|
+
const getStatusBarItemsLeftDom = statusBarItemsLeft => {
|
|
1991
|
+
if (statusBarItemsLeft.length === 0) {
|
|
1992
|
+
return emptyStatusBarItemsLeftDom;
|
|
1993
|
+
}
|
|
1994
|
+
return getStatusBarItemsVirtualDom(statusBarItemsLeft, StatusBarItemsLeft);
|
|
2077
1995
|
};
|
|
2078
1996
|
|
|
2079
|
-
const
|
|
2080
|
-
|
|
2081
|
-
}) => {
|
|
2082
|
-
const invocations = [];
|
|
2083
|
-
const invoke = (method, ...params) => {
|
|
2084
|
-
invocations.push([method, ...params]);
|
|
2085
|
-
const command = commandMap[method];
|
|
2086
|
-
if (!command) {
|
|
2087
|
-
throw new Error(`command ${method} not found`);
|
|
2088
|
-
}
|
|
2089
|
-
return command(...params);
|
|
2090
|
-
};
|
|
2091
|
-
const mockRpc = {
|
|
2092
|
-
invocations,
|
|
2093
|
-
invoke,
|
|
2094
|
-
invokeAndTransfer: invoke
|
|
2095
|
-
};
|
|
2096
|
-
return mockRpc;
|
|
1997
|
+
const getStatusBarItemsRightDom = statusBarItemsRight => {
|
|
1998
|
+
return getStatusBarItemsVirtualDom(statusBarItemsRight, StatusBarItemsRight);
|
|
2097
1999
|
};
|
|
2098
2000
|
|
|
2099
|
-
const
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
const get$3 = id => {
|
|
2104
|
-
return rpcs[id];
|
|
2001
|
+
const Focusable = 0;
|
|
2002
|
+
|
|
2003
|
+
const getChildCount = rightCount => {
|
|
2004
|
+
return rightCount > 0 ? 2 : 1;
|
|
2105
2005
|
};
|
|
2106
|
-
const
|
|
2107
|
-
|
|
2006
|
+
const getStatusBarVirtualDom = (statusBarItemsLeft, statusBarItemsRight) => {
|
|
2007
|
+
const dom = [{
|
|
2008
|
+
ariaLive: 'off',
|
|
2009
|
+
ariaRoleDescription: 'Status Bar',
|
|
2010
|
+
childCount: getChildCount(statusBarItemsRight.length),
|
|
2011
|
+
className: 'StatusBar',
|
|
2012
|
+
onClick: HandleClick,
|
|
2013
|
+
onContextMenu: HandleContextMenu,
|
|
2014
|
+
role: Status,
|
|
2015
|
+
tabIndex: Focusable,
|
|
2016
|
+
type: Div
|
|
2017
|
+
}, ...getStatusBarItemsLeftDom(statusBarItemsLeft), ...getStatusBarItemsRightDom(statusBarItemsRight)];
|
|
2018
|
+
return dom;
|
|
2108
2019
|
};
|
|
2109
2020
|
|
|
2110
|
-
|
|
2111
|
-
const
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
invoke(method, ...params) {
|
|
2119
|
-
const rpc = get$3(rpcId);
|
|
2120
|
-
// @ts-ignore
|
|
2121
|
-
return rpc.invoke(method, ...params);
|
|
2122
|
-
},
|
|
2123
|
-
// @ts-ignore
|
|
2124
|
-
invokeAndTransfer(method, ...params) {
|
|
2125
|
-
const rpc = get$3(rpcId);
|
|
2126
|
-
// @ts-ignore
|
|
2127
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
2128
|
-
},
|
|
2129
|
-
registerMockRpc(commandMap) {
|
|
2130
|
-
const mockRpc = createMockRpc({
|
|
2131
|
-
commandMap
|
|
2132
|
-
});
|
|
2133
|
-
set$7(rpcId, mockRpc);
|
|
2134
|
-
// @ts-ignore
|
|
2135
|
-
mockRpc[Symbol.dispose] = () => {
|
|
2136
|
-
remove(rpcId);
|
|
2137
|
-
};
|
|
2138
|
-
// @ts-ignore
|
|
2139
|
-
return mockRpc;
|
|
2140
|
-
},
|
|
2141
|
-
set(rpc) {
|
|
2142
|
-
set$7(rpcId, rpc);
|
|
2143
|
-
}
|
|
2144
|
-
};
|
|
2021
|
+
const renderItems = (oldState, newState) => {
|
|
2022
|
+
const {
|
|
2023
|
+
uid,
|
|
2024
|
+
visibleStatusBarItemsLeft,
|
|
2025
|
+
visibleStatusBarItemsRight
|
|
2026
|
+
} = newState;
|
|
2027
|
+
const dom = getStatusBarVirtualDom(visibleStatusBarItemsLeft, visibleStatusBarItemsRight);
|
|
2028
|
+
return [SetDom2, uid, dom];
|
|
2145
2029
|
};
|
|
2146
2030
|
|
|
2147
|
-
const {
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
}
|
|
2031
|
+
const getComponentDom = uid => {
|
|
2032
|
+
const state = getComponentState(uid);
|
|
2033
|
+
return renderItems(state, state)[2];
|
|
2034
|
+
};
|
|
2151
2035
|
|
|
2152
|
-
const {
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2036
|
+
const getMatchingItemInternal = (items, name) => {
|
|
2037
|
+
for (const item of items) {
|
|
2038
|
+
if (item.name === name) {
|
|
2039
|
+
return item;
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
return undefined;
|
|
2043
|
+
};
|
|
2044
|
+
const getMatchingItem = (itemsLeft, itemsRight, name) => {
|
|
2045
|
+
return getMatchingItemInternal(itemsLeft, name) ?? getMatchingItemInternal(itemsRight, name);
|
|
2046
|
+
};
|
|
2156
2047
|
|
|
2157
|
-
const
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
const
|
|
2162
|
-
|
|
2048
|
+
const EditorEncoding$1 = 'EditorEncoding';
|
|
2049
|
+
const EditorEndOfLine$1 = 'EditorEndOfLine';
|
|
2050
|
+
const EditorIndentation = 'EditorIndentation';
|
|
2051
|
+
const EditorLanguage$1 = 'EditorLanguage';
|
|
2052
|
+
const EditorPosition$1 = 'EditorPosition';
|
|
2053
|
+
const Notifications$1 = 'Notifications';
|
|
2054
|
+
const Problems$1 = 'Problems';
|
|
2055
|
+
const isEditorStatus = name => {
|
|
2056
|
+
return [EditorEncoding$1, EditorEndOfLine$1, EditorIndentation, EditorLanguage$1, EditorPosition$1].includes(name);
|
|
2057
|
+
};
|
|
2058
|
+
const isRight = name => {
|
|
2059
|
+
return name === Notifications$1 || isEditorStatus(name);
|
|
2163
2060
|
};
|
|
2164
2061
|
|
|
2165
|
-
const {
|
|
2166
|
-
|
|
2167
|
-
invokeAndTransfer,
|
|
2168
|
-
set: set$3
|
|
2169
|
-
} = create(RendererWorker);
|
|
2170
|
-
const sendMessagePortToTextMeasurementWorker = async port => {
|
|
2171
|
-
const command = 'TextMeasurement.handleMessagePort';
|
|
2172
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
2062
|
+
const state$2 = {
|
|
2063
|
+
rpc: undefined
|
|
2173
2064
|
};
|
|
2174
|
-
const
|
|
2175
|
-
|
|
2065
|
+
const set$3 = rpc => {
|
|
2066
|
+
state$2.rpc = rpc;
|
|
2067
|
+
};
|
|
2068
|
+
const invoke$2 = (method, ...args) => {
|
|
2069
|
+
const {
|
|
2070
|
+
rpc
|
|
2071
|
+
} = state$2;
|
|
2072
|
+
return rpc.invoke(method, ...args);
|
|
2073
|
+
};
|
|
2074
|
+
|
|
2075
|
+
const handleClickEditorStatus = async (name, status) => {
|
|
2076
|
+
if (!status) {
|
|
2077
|
+
return;
|
|
2078
|
+
}
|
|
2079
|
+
switch (name) {
|
|
2080
|
+
case EditorEndOfLine$1:
|
|
2081
|
+
await invoke$2('QuickPick.openStatusBarPicker', 'end-of-line');
|
|
2082
|
+
return;
|
|
2083
|
+
case EditorIndentation:
|
|
2084
|
+
await invoke$2('QuickPick.openStatusBarPicker', 'indentation');
|
|
2085
|
+
return;
|
|
2086
|
+
case EditorLanguage$1:
|
|
2087
|
+
await invoke$2('QuickPick.openStatusBarPicker', 'language-mode');
|
|
2088
|
+
return;
|
|
2089
|
+
case EditorPosition$1:
|
|
2090
|
+
await invoke$2('QuickPick.openStatusBarPicker', 'go-to-line', status.line, status.column);
|
|
2091
|
+
return;
|
|
2092
|
+
}
|
|
2176
2093
|
};
|
|
2177
2094
|
|
|
2178
2095
|
const invokeExtensionCommand = (applicationId, command, ...args) => {
|
|
2179
2096
|
if (applicationId !== undefined) {
|
|
2180
|
-
return invoke$
|
|
2097
|
+
return invoke$6('Extensions.invokeForApplication', applicationId, command, ...args);
|
|
2181
2098
|
}
|
|
2182
|
-
return invoke$
|
|
2099
|
+
return invoke$6(command, ...args);
|
|
2183
2100
|
};
|
|
2184
2101
|
|
|
2185
2102
|
const handleClickExtensionStatusBarItem = async (name, applicationId) => {
|
|
@@ -2191,12 +2108,12 @@ const handleClickExtensionStatusBarItem = async (name, applicationId) => {
|
|
|
2191
2108
|
};
|
|
2192
2109
|
|
|
2193
2110
|
const handleClickNotification = async () => {
|
|
2194
|
-
await invoke$
|
|
2111
|
+
await invoke$3('Viewlet.openWidget', 'NotificationCenter');
|
|
2195
2112
|
};
|
|
2196
2113
|
|
|
2197
2114
|
const handleClickProblems = async () => {
|
|
2198
2115
|
// @ts-ignore
|
|
2199
|
-
await invoke$
|
|
2116
|
+
await invoke$3('Layout.showPanel', 'Problems');
|
|
2200
2117
|
};
|
|
2201
2118
|
|
|
2202
2119
|
const handleClick = async (state, name) => {
|
|
@@ -2532,6 +2449,32 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
2532
2449
|
return commands;
|
|
2533
2450
|
};
|
|
2534
2451
|
|
|
2452
|
+
const cacheName = 'lvce-status-bar-measurements-v1';
|
|
2453
|
+
const fontSize$1 = 12;
|
|
2454
|
+
const fontFamily$1 = 'system-ui, Ubuntu, Droid Sans, sans-serif';
|
|
2455
|
+
const getCacheKey = text => {
|
|
2456
|
+
const parameters = [text, 400, fontSize$1, fontFamily$1, 0, false, 0];
|
|
2457
|
+
return `/status-bar-measurements/v1/${encodeURIComponent(JSON.stringify(parameters))}`;
|
|
2458
|
+
};
|
|
2459
|
+
const isValidWidth = value => {
|
|
2460
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
2461
|
+
};
|
|
2462
|
+
const getWidth = async text => {
|
|
2463
|
+
try {
|
|
2464
|
+
const item = await getCacheStorageJsonItem(getCacheKey(text), cacheName);
|
|
2465
|
+
return item && isValidWidth(item.value) ? item.value : undefined;
|
|
2466
|
+
} catch {
|
|
2467
|
+
return undefined;
|
|
2468
|
+
}
|
|
2469
|
+
};
|
|
2470
|
+
const setWidth = async (text, width) => {
|
|
2471
|
+
try {
|
|
2472
|
+
await setCacheStorageJsonItem(getCacheKey(text), width, cacheName);
|
|
2473
|
+
} catch {
|
|
2474
|
+
// Cache writes are best-effort; measurements remain usable without persistence.
|
|
2475
|
+
}
|
|
2476
|
+
};
|
|
2477
|
+
|
|
2535
2478
|
const fontSize = 12;
|
|
2536
2479
|
const fontFamily = 'system-ui, Ubuntu, Droid Sans, sans-serif';
|
|
2537
2480
|
const itemPaddingAndMargin = 16;
|
|
@@ -2544,11 +2487,31 @@ const measureTextWidths = async values => {
|
|
|
2544
2487
|
if (values.length === 0) {
|
|
2545
2488
|
return [];
|
|
2546
2489
|
}
|
|
2490
|
+
const cachedWidths = await Promise.all(values.map(value => getWidth(value)));
|
|
2491
|
+
const missingValues = values.filter((_, index) => cachedWidths[index] === undefined);
|
|
2492
|
+
if (missingValues.length === 0) {
|
|
2493
|
+
return cachedWidths;
|
|
2494
|
+
}
|
|
2495
|
+
let measuredWidths;
|
|
2496
|
+
let measurementSucceeded = true;
|
|
2547
2497
|
try {
|
|
2548
|
-
|
|
2498
|
+
measuredWidths = await measureTextWidths$1(missingValues, 400, fontSize, fontFamily, 0, false, 0);
|
|
2549
2499
|
} catch {
|
|
2550
|
-
|
|
2500
|
+
measurementSucceeded = false;
|
|
2501
|
+
measuredWidths = missingValues.map(() => fallbackTextWidth);
|
|
2551
2502
|
}
|
|
2503
|
+
let measuredIndex = 0;
|
|
2504
|
+
const widths = cachedWidths.map(width => {
|
|
2505
|
+
if (width !== undefined) {
|
|
2506
|
+
return width;
|
|
2507
|
+
}
|
|
2508
|
+
const measuredWidth = measuredWidths[measuredIndex++];
|
|
2509
|
+
if (measurementSucceeded) {
|
|
2510
|
+
void setWidth(missingValues[measuredIndex - 1], measuredWidth);
|
|
2511
|
+
}
|
|
2512
|
+
return measuredWidth;
|
|
2513
|
+
});
|
|
2514
|
+
return widths;
|
|
2552
2515
|
};
|
|
2553
2516
|
const getElementWidth = (element, textWidths, textIndex) => {
|
|
2554
2517
|
switch (element.type) {
|
|
@@ -2626,10 +2589,10 @@ const isConnected = () => {
|
|
|
2626
2589
|
return connected;
|
|
2627
2590
|
};
|
|
2628
2591
|
const invoke = (method, ...params) => {
|
|
2629
|
-
return invoke$
|
|
2592
|
+
return invoke$5(method, ...params);
|
|
2630
2593
|
};
|
|
2631
2594
|
const set$1 = rpc => {
|
|
2632
|
-
set$
|
|
2595
|
+
set$7(rpc);
|
|
2633
2596
|
state.connected = true;
|
|
2634
2597
|
};
|
|
2635
2598
|
|
|
@@ -2640,20 +2603,20 @@ const renderDirect = async (uid, commands) => {
|
|
|
2640
2603
|
return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
|
|
2641
2604
|
};
|
|
2642
2605
|
const render2 = async (uid, _diffResult) => {
|
|
2643
|
-
let current = get$
|
|
2606
|
+
let current = get$3(uid);
|
|
2644
2607
|
let {
|
|
2645
2608
|
newState
|
|
2646
2609
|
} = current;
|
|
2647
2610
|
while (true) {
|
|
2648
2611
|
const measuredState = await getVisibleStatusBarItems(newState);
|
|
2649
|
-
const latest = get$
|
|
2612
|
+
const latest = get$3(uid);
|
|
2650
2613
|
const {
|
|
2651
2614
|
newState: latestState
|
|
2652
2615
|
} = latest;
|
|
2653
2616
|
if (latestState === newState) {
|
|
2654
2617
|
current = latest;
|
|
2655
2618
|
newState = measuredState;
|
|
2656
|
-
set$
|
|
2619
|
+
set$4(uid, current.oldState, newState);
|
|
2657
2620
|
break;
|
|
2658
2621
|
}
|
|
2659
2622
|
newState = latestState;
|
|
@@ -2668,7 +2631,7 @@ const render2 = async (uid, _diffResult) => {
|
|
|
2668
2631
|
const commands = applyRender(oldState, newState, diffResult);
|
|
2669
2632
|
// Advance synchronously: subsequent out-of-band updates must diff against
|
|
2670
2633
|
// the DOM commands just generated, including updates that revert a value.
|
|
2671
|
-
set$
|
|
2634
|
+
set$4(uid, newState, newState);
|
|
2672
2635
|
if (!isConnected()) {
|
|
2673
2636
|
return commands;
|
|
2674
2637
|
}
|
|
@@ -2681,7 +2644,7 @@ const renderOutOfBand = async uid => {
|
|
|
2681
2644
|
}
|
|
2682
2645
|
const {
|
|
2683
2646
|
newState
|
|
2684
|
-
} = get$
|
|
2647
|
+
} = get$3(uid);
|
|
2685
2648
|
if (newState.initial) {
|
|
2686
2649
|
return;
|
|
2687
2650
|
}
|
|
@@ -2706,7 +2669,7 @@ const handleEditorStatusChangedAll = async update => {
|
|
|
2706
2669
|
const {
|
|
2707
2670
|
newState,
|
|
2708
2671
|
oldState
|
|
2709
|
-
} = get$
|
|
2672
|
+
} = get$3(uid);
|
|
2710
2673
|
const newerState = isVisible() ? handleEditorStatusChanged(newState, editorStatus, previous) : {
|
|
2711
2674
|
...newState,
|
|
2712
2675
|
editorStatus
|
|
@@ -2714,7 +2677,7 @@ const handleEditorStatusChangedAll = async update => {
|
|
|
2714
2677
|
if (newState === newerState || oldState === newerState) {
|
|
2715
2678
|
continue;
|
|
2716
2679
|
}
|
|
2717
|
-
set$
|
|
2680
|
+
set$4(uid, oldState, newerState);
|
|
2718
2681
|
changedUids.push(uid);
|
|
2719
2682
|
}
|
|
2720
2683
|
await Promise.all(changedUids.map(renderOutOfBand));
|
|
@@ -2750,12 +2713,12 @@ const handleEditorStatusVisibilityChangedAll = async visible => {
|
|
|
2750
2713
|
const {
|
|
2751
2714
|
newState,
|
|
2752
2715
|
oldState
|
|
2753
|
-
} = get$
|
|
2716
|
+
} = get$3(uid);
|
|
2754
2717
|
const newerState = handleEditorStatusVisibilityChanged(newState, visible);
|
|
2755
2718
|
if (newState === newerState || oldState === newerState) {
|
|
2756
2719
|
continue;
|
|
2757
2720
|
}
|
|
2758
|
-
set$
|
|
2721
|
+
set$4(uid, oldState, newerState);
|
|
2759
2722
|
changedUids.push(uid);
|
|
2760
2723
|
}
|
|
2761
2724
|
await Promise.all(changedUids.map(renderOutOfBand));
|
|
@@ -2921,7 +2884,7 @@ const toUiStatusBarItems = statusBarItems => {
|
|
|
2921
2884
|
|
|
2922
2885
|
const getNotificationCount = async () => {
|
|
2923
2886
|
try {
|
|
2924
|
-
return await invoke$
|
|
2887
|
+
return await invoke$6('Extensions.getNotificationCount');
|
|
2925
2888
|
} catch {
|
|
2926
2889
|
return 0;
|
|
2927
2890
|
}
|
|
@@ -2995,15 +2958,15 @@ const handleExtensionManagementChange = async () => {
|
|
|
2995
2958
|
const {
|
|
2996
2959
|
newState,
|
|
2997
2960
|
oldState
|
|
2998
|
-
} = get$
|
|
2961
|
+
} = get$3(uid);
|
|
2999
2962
|
const newerState = await handleItemsChanged(newState);
|
|
3000
2963
|
if (newState === newerState || oldState === newerState) {
|
|
3001
2964
|
continue;
|
|
3002
2965
|
}
|
|
3003
2966
|
// Loading and other updates can finish while the provider query is pending.
|
|
3004
2967
|
// Only replace the extension items; retain the current lifecycle and render baseline.
|
|
3005
|
-
const current = get$
|
|
3006
|
-
set$
|
|
2968
|
+
const current = get$3(uid);
|
|
2969
|
+
set$4(uid, current.oldState, {
|
|
3007
2970
|
...current.newState,
|
|
3008
2971
|
statusBarItemsLeft: newerState.statusBarItemsLeft
|
|
3009
2972
|
});
|
|
@@ -3043,12 +3006,12 @@ const handleNotificationCountChangedAll = async count => {
|
|
|
3043
3006
|
const {
|
|
3044
3007
|
newState,
|
|
3045
3008
|
oldState
|
|
3046
|
-
} = get$
|
|
3009
|
+
} = get$3(uid);
|
|
3047
3010
|
const newerState = handleNotificationCountChanged(newState, count);
|
|
3048
3011
|
if (newState === newerState || oldState === newerState) {
|
|
3049
3012
|
continue;
|
|
3050
3013
|
}
|
|
3051
|
-
set$
|
|
3014
|
+
set$4(uid, oldState, newerState);
|
|
3052
3015
|
await renderOutOfBand(uid);
|
|
3053
3016
|
}
|
|
3054
3017
|
};
|
|
@@ -3059,11 +3022,11 @@ const commandMap$1 = {
|
|
|
3059
3022
|
};
|
|
3060
3023
|
|
|
3061
3024
|
const handleExtensionManagementMessagePort = async port => {
|
|
3062
|
-
const rpc = await create$
|
|
3025
|
+
const rpc = await create$6({
|
|
3063
3026
|
commandMap: commandMap$1,
|
|
3064
3027
|
messagePort: port
|
|
3065
3028
|
});
|
|
3066
|
-
set$
|
|
3029
|
+
set$8(rpc);
|
|
3067
3030
|
};
|
|
3068
3031
|
|
|
3069
3032
|
const supportsEditorStatusDeltas = () => true;
|
|
@@ -3075,9 +3038,9 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess =
|
|
|
3075
3038
|
throw new TypeError(`Viewlet command not found: ${command}`);
|
|
3076
3039
|
}
|
|
3077
3040
|
await fn(uid, ...args);
|
|
3078
|
-
await invoke$
|
|
3041
|
+
await invoke$3('Viewlet.requestRender', uid);
|
|
3079
3042
|
};
|
|
3080
|
-
const rpc = await create$
|
|
3043
|
+
const rpc = await create$6({
|
|
3081
3044
|
commandMap: {
|
|
3082
3045
|
'StatusBar.handleEditorStatusChanged': handleEditorStatusChangedAll,
|
|
3083
3046
|
'StatusBar.handleEditorStatusVisibilityChanged': handleEditorStatusVisibilityChangedAll,
|
|
@@ -3161,7 +3124,7 @@ const handleWorkspaceChange = async state => {
|
|
|
3161
3124
|
assetDir,
|
|
3162
3125
|
platform
|
|
3163
3126
|
} = state;
|
|
3164
|
-
await invoke$
|
|
3127
|
+
await invoke$6('Extensions.activateByEvent', 'onStatusBarItem', assetDir, platform);
|
|
3165
3128
|
return state;
|
|
3166
3129
|
};
|
|
3167
3130
|
|
|
@@ -3353,7 +3316,7 @@ const handleWorkspaceChangeAndRefresh = async (uid, workspacePath) => {
|
|
|
3353
3316
|
await refreshExtensionItems(uid);
|
|
3354
3317
|
};
|
|
3355
3318
|
const commandMap = {
|
|
3356
|
-
'StatusBar.create': create
|
|
3319
|
+
'StatusBar.create': create,
|
|
3357
3320
|
'StatusBar.diff2': diff2,
|
|
3358
3321
|
'StatusBar.getCommandIds': getCommandIds,
|
|
3359
3322
|
'StatusBar.getComponentDom': getComponentDom,
|
|
@@ -3386,7 +3349,7 @@ const commandMap = {
|
|
|
3386
3349
|
};
|
|
3387
3350
|
|
|
3388
3351
|
const initializeMenuWorker = async () => {
|
|
3389
|
-
const rpc = await create$
|
|
3352
|
+
const rpc = await create$4({
|
|
3390
3353
|
commandMap: {},
|
|
3391
3354
|
async send(port) {
|
|
3392
3355
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToMenuWorker', port);
|
|
@@ -3396,20 +3359,20 @@ const initializeMenuWorker = async () => {
|
|
|
3396
3359
|
};
|
|
3397
3360
|
|
|
3398
3361
|
const initializeQuickPickWorker = async () => {
|
|
3399
|
-
const rpc = await create$
|
|
3362
|
+
const rpc = await create$4({
|
|
3400
3363
|
commandMap: {},
|
|
3401
3364
|
async send(port) {
|
|
3402
3365
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToQuickPickWorker', port, 'QuickPick.handleStatusBarMessagePort', 0);
|
|
3403
3366
|
}
|
|
3404
3367
|
});
|
|
3405
|
-
set$
|
|
3368
|
+
set$3(rpc);
|
|
3406
3369
|
};
|
|
3407
3370
|
|
|
3408
3371
|
const initializeRenderWorker = async () => {
|
|
3409
|
-
const rpc = await create$
|
|
3372
|
+
const rpc = await create$3({
|
|
3410
3373
|
commandMap: commandMap
|
|
3411
3374
|
});
|
|
3412
|
-
set$
|
|
3375
|
+
set$5(rpc);
|
|
3413
3376
|
};
|
|
3414
3377
|
|
|
3415
3378
|
const send = port => {
|
|
@@ -3417,16 +3380,30 @@ const send = port => {
|
|
|
3417
3380
|
return sendMessagePortToTextMeasurementWorker(port);
|
|
3418
3381
|
};
|
|
3419
3382
|
const initializeTextMeasurementWorkerRpc = async () => {
|
|
3420
|
-
const rpc = await create$
|
|
3383
|
+
const rpc = await create$4({
|
|
3421
3384
|
commandMap: {},
|
|
3422
3385
|
send
|
|
3423
3386
|
});
|
|
3424
|
-
set$
|
|
3387
|
+
set$6(rpc);
|
|
3425
3388
|
};
|
|
3426
3389
|
|
|
3390
|
+
const registerCacheWorker = async () => {
|
|
3391
|
+
const lazyRpc = await create$4({
|
|
3392
|
+
commandMap: {},
|
|
3393
|
+
async send(port) {
|
|
3394
|
+
try {
|
|
3395
|
+
await sendMessagePortToCacheWorker(port);
|
|
3396
|
+
} catch (error) {
|
|
3397
|
+
await registerCacheWorker();
|
|
3398
|
+
throw error;
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
});
|
|
3402
|
+
set$9(lazyRpc);
|
|
3403
|
+
};
|
|
3427
3404
|
const listen = async () => {
|
|
3428
3405
|
registerCommands(commandMap);
|
|
3429
|
-
await Promise.all([initializeRenderWorker(), initializeQuickPickWorker(), initializeMenuWorker(), initializeTextMeasurementWorkerRpc()]);
|
|
3406
|
+
await Promise.all([initializeRenderWorker(), initializeQuickPickWorker(), initializeMenuWorker(), initializeTextMeasurementWorkerRpc(), registerCacheWorker()]);
|
|
3430
3407
|
};
|
|
3431
3408
|
|
|
3432
3409
|
const main = async () => {
|