@lvce-editor/about-view 7.11.0 → 7.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aboutWorkerMain.js +1583 -1571
- package/package.json +1 -1
package/dist/aboutWorkerMain.js
CHANGED
|
@@ -1,1756 +1,1763 @@
|
|
|
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
|
-
|
|
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$3 = '\n';
|
|
18
|
+
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
19
|
+
return string.indexOf(NewLine$3, 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);
|
|
17
45
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
states[uid] = {
|
|
22
|
-
newState: updatedState,
|
|
23
|
-
oldState: current.oldState,
|
|
24
|
-
scheduledState: updatedState
|
|
25
|
-
};
|
|
46
|
+
if (error.codeFrame) {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
this.codeFrame = error.codeFrame;
|
|
26
49
|
}
|
|
27
|
-
|
|
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
|
+
}));
|
|
28
112
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
getState: () => {
|
|
33
|
-
if (isCurrentGeneration(uid, generation)) {
|
|
34
|
-
latestState = states[uid].newState;
|
|
35
|
-
}
|
|
36
|
-
return latestState;
|
|
37
|
-
},
|
|
38
|
-
updateState: async updater => {
|
|
39
|
-
latestState = await updateState(uid, generation, latestState, updater);
|
|
40
|
-
return latestState;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
113
|
+
that.onMessage(handleMessage);
|
|
114
|
+
const handleClose = event => {
|
|
115
|
+
that.dispatchEvent(new Event('close'));
|
|
43
116
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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$2 = '\n';
|
|
130
|
+
const joinLines$2 = lines => {
|
|
131
|
+
return lines.join(NewLine$2);
|
|
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$2(lines),
|
|
143
|
+
rest: []
|
|
53
144
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (commandQueues.get(uid) === current) {
|
|
60
|
-
commandQueues.delete(uid);
|
|
61
|
-
}
|
|
145
|
+
}
|
|
146
|
+
let lastIndex = index - 1;
|
|
147
|
+
while (++lastIndex < lines.length) {
|
|
148
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
149
|
+
break;
|
|
62
150
|
}
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
actualMessage: lines[index - 1],
|
|
154
|
+
rest: lines.slice(index, lastIndex)
|
|
63
155
|
};
|
|
156
|
+
};
|
|
157
|
+
const splitLines$1 = lines => {
|
|
158
|
+
return lines.split(NewLine$2);
|
|
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];
|
|
64
183
|
return {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
for (const key of Object.keys(states)) {
|
|
68
|
-
delete states[key];
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
diff(uid, modules, numbers) {
|
|
72
|
-
const {
|
|
73
|
-
oldState,
|
|
74
|
-
scheduledState
|
|
75
|
-
} = states[uid];
|
|
76
|
-
const diffResult = [];
|
|
77
|
-
for (let i = 0; i < modules.length; i++) {
|
|
78
|
-
const fn = modules[i];
|
|
79
|
-
if (!fn(oldState, scheduledState)) {
|
|
80
|
-
diffResult.push(numbers[i]);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return diffResult;
|
|
84
|
-
},
|
|
85
|
-
dispose(uid) {
|
|
86
|
-
commandQueues.delete(uid);
|
|
87
|
-
delete states[uid];
|
|
88
|
-
},
|
|
89
|
-
get(uid) {
|
|
90
|
-
return states[uid];
|
|
91
|
-
},
|
|
92
|
-
getCommandIds() {
|
|
93
|
-
const keys = Object.keys(commandMapRef);
|
|
94
|
-
const ids = keys.map(toCommandId);
|
|
95
|
-
return ids;
|
|
96
|
-
},
|
|
97
|
-
getKeys() {
|
|
98
|
-
return Object.keys(states).map(Number);
|
|
99
|
-
},
|
|
100
|
-
registerCommands(commandMap) {
|
|
101
|
-
Object.assign(commandMapRef, commandMap);
|
|
102
|
-
},
|
|
103
|
-
set(uid, oldState, newState, scheduledState) {
|
|
104
|
-
const current = states[uid];
|
|
105
|
-
if (!current || oldState === newState && newState !== current.newState) {
|
|
106
|
-
generations[uid] = getGeneration(uid) + 1;
|
|
107
|
-
}
|
|
108
|
-
states[uid] = {
|
|
109
|
-
newState,
|
|
110
|
-
oldState,
|
|
111
|
-
scheduledState: scheduledState ?? newState
|
|
112
|
-
};
|
|
113
|
-
},
|
|
114
|
-
wrapAsyncCommand(fn) {
|
|
115
|
-
const wrapped = async (uid, ...args) => {
|
|
116
|
-
const generation = getGeneration(uid);
|
|
117
|
-
const context = createAsyncCommandContext(uid, generation);
|
|
118
|
-
await fn(context, ...args);
|
|
119
|
-
};
|
|
120
|
-
return wrapped;
|
|
121
|
-
},
|
|
122
|
-
wrapCommand(fn) {
|
|
123
|
-
const wrapped = async (uid, ...args) => {
|
|
124
|
-
const generation = getGeneration(uid);
|
|
125
|
-
const {
|
|
126
|
-
newState,
|
|
127
|
-
oldState
|
|
128
|
-
} = states[uid];
|
|
129
|
-
const newerState = await fn(newState, ...args);
|
|
130
|
-
if (oldState === newerState || newState === newerState) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
if (!isCurrentGeneration(uid, generation)) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
const latestOld = states[uid];
|
|
137
|
-
const latestNew = {
|
|
138
|
-
...latestOld.newState,
|
|
139
|
-
...newerState
|
|
140
|
-
};
|
|
141
|
-
states[uid] = {
|
|
142
|
-
newState: latestNew,
|
|
143
|
-
oldState: latestOld.oldState,
|
|
144
|
-
scheduledState: latestNew
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
return wrapped;
|
|
148
|
-
},
|
|
149
|
-
wrapGetter(fn) {
|
|
150
|
-
const wrapped = (uid, ...args) => {
|
|
151
|
-
const {
|
|
152
|
-
newState
|
|
153
|
-
} = states[uid];
|
|
154
|
-
return fn(newState, ...args);
|
|
155
|
-
};
|
|
156
|
-
return wrapped;
|
|
157
|
-
},
|
|
158
|
-
wrapLoadContent(fn) {
|
|
159
|
-
const wrapped = async (uid, ...args) => {
|
|
160
|
-
const generation = getGeneration(uid);
|
|
161
|
-
const {
|
|
162
|
-
newState,
|
|
163
|
-
oldState
|
|
164
|
-
} = states[uid];
|
|
165
|
-
const result = await fn(newState, ...args);
|
|
166
|
-
const {
|
|
167
|
-
error,
|
|
168
|
-
state
|
|
169
|
-
} = result;
|
|
170
|
-
if (oldState === state || newState === state) {
|
|
171
|
-
return {
|
|
172
|
-
error
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
if (!isCurrentGeneration(uid, generation)) {
|
|
176
|
-
return {
|
|
177
|
-
error
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
const latestOld = states[uid];
|
|
181
|
-
const latestNew = {
|
|
182
|
-
...latestOld.newState,
|
|
183
|
-
...state
|
|
184
|
-
};
|
|
185
|
-
states[uid] = {
|
|
186
|
-
newState: latestNew,
|
|
187
|
-
oldState: latestOld.oldState,
|
|
188
|
-
scheduledState: latestNew
|
|
189
|
-
};
|
|
190
|
-
return {
|
|
191
|
-
error
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
return wrapped;
|
|
195
|
-
},
|
|
196
|
-
wrapSerialAsyncCommand(fn) {
|
|
197
|
-
const wrapped = async (uid, ...args) => {
|
|
198
|
-
await enqueueCommand(uid, async () => {
|
|
199
|
-
if (!states[uid]) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
const generation = getGeneration(uid);
|
|
203
|
-
const context = createAsyncCommandContext(uid, generation);
|
|
204
|
-
await fn(context, ...args);
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
return wrapped;
|
|
208
|
-
},
|
|
209
|
-
wrapSerialCommand(fn) {
|
|
210
|
-
const wrapped = async (uid, ...args) => {
|
|
211
|
-
await enqueueCommand(uid, async () => {
|
|
212
|
-
if (!states[uid]) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
const generation = getGeneration(uid);
|
|
216
|
-
const {
|
|
217
|
-
newState,
|
|
218
|
-
oldState
|
|
219
|
-
} = states[uid];
|
|
220
|
-
const newerState = await fn(newState, ...args);
|
|
221
|
-
if (oldState === newerState || newState === newerState) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
if (!isCurrentGeneration(uid, generation)) {
|
|
225
|
-
return;
|
|
226
|
-
}
|
|
227
|
-
const latestOld = states[uid];
|
|
228
|
-
const latestNew = {
|
|
229
|
-
...latestOld.newState,
|
|
230
|
-
...newerState
|
|
231
|
-
};
|
|
232
|
-
states[uid] = {
|
|
233
|
-
newState: latestNew,
|
|
234
|
-
oldState: latestOld.oldState,
|
|
235
|
-
scheduledState: latestNew
|
|
236
|
-
};
|
|
237
|
-
});
|
|
238
|
-
};
|
|
239
|
-
return wrapped;
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
const {
|
|
245
|
-
dispose: dispose$1,
|
|
246
|
-
get: get$2,
|
|
247
|
-
getCommandIds,
|
|
248
|
-
registerCommands,
|
|
249
|
-
set: set$3,
|
|
250
|
-
wrapAsyncCommand,
|
|
251
|
-
wrapCommand
|
|
252
|
-
} = create$a();
|
|
253
|
-
|
|
254
|
-
const create$9 = uid => {
|
|
255
|
-
const state = {
|
|
256
|
-
focusId: 0,
|
|
257
|
-
lines: [],
|
|
258
|
-
productName: '',
|
|
259
|
-
uid
|
|
184
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
185
|
+
message
|
|
260
186
|
};
|
|
261
|
-
set$3(uid, state, state);
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
const RenderFocus = 2;
|
|
265
|
-
const RenderFocusContext = 4;
|
|
266
|
-
const RenderAbout = 3;
|
|
267
|
-
|
|
268
|
-
const diffType$2 = RenderAbout;
|
|
269
|
-
const isEqual$2 = (oldState, newState) => {
|
|
270
|
-
return oldState.productName === newState.productName && JSON.stringify(oldState.lines) === JSON.stringify(newState.lines);
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
const diffType$1 = RenderFocus;
|
|
274
|
-
const isEqual$1 = (oldState, newState) => {
|
|
275
|
-
return oldState.focusId === newState.focusId;
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
const diffType = RenderFocusContext;
|
|
279
|
-
const isEqual = (oldState, newState) => {
|
|
280
|
-
return oldState.focusId === newState.focusId;
|
|
281
187
|
};
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const diff = (oldState, newState) => {
|
|
287
|
-
const diffResult = [];
|
|
288
|
-
for (let i = 0; i < modules.length; i++) {
|
|
289
|
-
const fn = modules[i];
|
|
290
|
-
if (!fn(oldState, newState)) {
|
|
291
|
-
diffResult.push(numbers[i]);
|
|
292
|
-
}
|
|
188
|
+
const isModuleNotFoundError = stderr => {
|
|
189
|
+
if (!stderr) {
|
|
190
|
+
return false;
|
|
293
191
|
}
|
|
294
|
-
return
|
|
192
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
295
193
|
};
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
} = get$2(uid);
|
|
302
|
-
const diffResult = diff(oldState, scheduledState);
|
|
303
|
-
return diffResult;
|
|
194
|
+
const isModulesSyntaxError = stderr => {
|
|
195
|
+
if (!stderr) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
304
199
|
};
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
|
|
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);
|
|
308
204
|
};
|
|
309
|
-
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
switch (focusId) {
|
|
316
|
-
case Copy$2:
|
|
317
|
-
return Ok$2;
|
|
318
|
-
case Ok$2:
|
|
319
|
-
return Copy$2;
|
|
320
|
-
default:
|
|
321
|
-
return None;
|
|
322
|
-
}
|
|
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
|
+
};
|
|
323
211
|
};
|
|
324
|
-
|
|
325
|
-
const focusNext = state => {
|
|
326
|
-
const {
|
|
327
|
-
focusId
|
|
328
|
-
} = state;
|
|
212
|
+
const getModuleSyntaxError = () => {
|
|
329
213
|
return {
|
|
330
|
-
|
|
331
|
-
|
|
214
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
215
|
+
message: `ES Modules are not supported in electron`
|
|
332
216
|
};
|
|
333
217
|
};
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
case Copy$2:
|
|
338
|
-
return Ok$2;
|
|
339
|
-
case Ok$2:
|
|
340
|
-
return Copy$2;
|
|
341
|
-
default:
|
|
342
|
-
return None;
|
|
218
|
+
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
219
|
+
if (isUnhelpfulNativeModuleError(stderr)) {
|
|
220
|
+
return getNativeModuleErrorMessage(stderr);
|
|
343
221
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
222
|
+
if (isModulesSyntaxError(stderr)) {
|
|
223
|
+
return getModuleSyntaxError();
|
|
224
|
+
}
|
|
225
|
+
if (isModuleNotFoundError(stderr)) {
|
|
226
|
+
return getModuleNotFoundError(stderr);
|
|
227
|
+
}
|
|
228
|
+
const lines = splitLines$1(stderr);
|
|
347
229
|
const {
|
|
348
|
-
|
|
349
|
-
|
|
230
|
+
actualMessage,
|
|
231
|
+
rest
|
|
232
|
+
} = getDetails(lines);
|
|
350
233
|
return {
|
|
351
|
-
|
|
352
|
-
|
|
234
|
+
code: '',
|
|
235
|
+
message: actualMessage,
|
|
236
|
+
stack: rest
|
|
353
237
|
};
|
|
354
238
|
};
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
const
|
|
389
|
-
const
|
|
390
|
-
|
|
391
|
-
const Figcaption = 45;
|
|
392
|
-
const Figure = 46;
|
|
393
|
-
const Hr = 47;
|
|
394
|
-
const Li = 48;
|
|
395
|
-
const Ol = 49;
|
|
396
|
-
const P = 50;
|
|
397
|
-
const Pre = 51;
|
|
398
|
-
const A = 53;
|
|
399
|
-
const Abbr = 54;
|
|
400
|
-
const Br = 55;
|
|
401
|
-
const Cite = 56;
|
|
402
|
-
const Data = 57;
|
|
403
|
-
const Time = 58;
|
|
404
|
-
const Tfoot = 59;
|
|
405
|
-
const Ul = 60;
|
|
406
|
-
const Video = 61;
|
|
407
|
-
const TextArea = 62;
|
|
408
|
-
const Select = 63;
|
|
409
|
-
const Option = 64;
|
|
410
|
-
const Code = 65;
|
|
411
|
-
const Label = 66;
|
|
412
|
-
const Dt = 67;
|
|
413
|
-
const Iframe = 68;
|
|
414
|
-
const Main = 69;
|
|
415
|
-
const Strong = 70;
|
|
416
|
-
const Em = 71;
|
|
417
|
-
const Style = 72;
|
|
418
|
-
const Html = 73;
|
|
419
|
-
const Head = 74;
|
|
420
|
-
const Title = 75;
|
|
421
|
-
const Meta = 76;
|
|
422
|
-
const Canvas = 77;
|
|
423
|
-
const Form = 78;
|
|
424
|
-
const BlockQuote = 79;
|
|
425
|
-
const Quote = 80;
|
|
426
|
-
const Circle = 81;
|
|
427
|
-
const Defs = 82;
|
|
428
|
-
const Ellipse = 83;
|
|
429
|
-
const G = 84;
|
|
430
|
-
const Line = 85;
|
|
431
|
-
const Path = 86;
|
|
432
|
-
const Polygon = 87;
|
|
433
|
-
const Polyline = 88;
|
|
434
|
-
const Rect = 89;
|
|
435
|
-
const Svg = 90;
|
|
436
|
-
const Use = 91;
|
|
437
|
-
const Reference = 100;
|
|
438
|
-
|
|
439
|
-
const VirtualDomElements = {
|
|
440
|
-
__proto__: null,
|
|
441
|
-
A,
|
|
442
|
-
Abbr,
|
|
443
|
-
Article,
|
|
444
|
-
Aside,
|
|
445
|
-
Audio,
|
|
446
|
-
BlockQuote,
|
|
447
|
-
Br,
|
|
448
|
-
Button: Button$1,
|
|
449
|
-
Canvas,
|
|
450
|
-
Circle,
|
|
451
|
-
Cite,
|
|
452
|
-
Code,
|
|
453
|
-
Col,
|
|
454
|
-
ColGroup,
|
|
455
|
-
Data,
|
|
456
|
-
Dd,
|
|
457
|
-
Defs,
|
|
458
|
-
Del,
|
|
459
|
-
Div,
|
|
460
|
-
Dl,
|
|
461
|
-
Dt,
|
|
462
|
-
Ellipse,
|
|
463
|
-
Em,
|
|
464
|
-
Figcaption,
|
|
465
|
-
Figure,
|
|
466
|
-
Footer,
|
|
467
|
-
Form,
|
|
468
|
-
G,
|
|
469
|
-
H1,
|
|
470
|
-
H2,
|
|
471
|
-
H3,
|
|
472
|
-
H4,
|
|
473
|
-
H5,
|
|
474
|
-
H6,
|
|
475
|
-
Head,
|
|
476
|
-
Header,
|
|
477
|
-
Hr,
|
|
478
|
-
Html,
|
|
479
|
-
I,
|
|
480
|
-
Iframe,
|
|
481
|
-
Img,
|
|
482
|
-
Input,
|
|
483
|
-
Ins,
|
|
484
|
-
Kbd,
|
|
485
|
-
Label,
|
|
486
|
-
Li,
|
|
487
|
-
Line,
|
|
488
|
-
Main,
|
|
489
|
-
Meta,
|
|
490
|
-
Nav,
|
|
491
|
-
Ol,
|
|
492
|
-
Option,
|
|
493
|
-
P,
|
|
494
|
-
Path,
|
|
495
|
-
Polygon,
|
|
496
|
-
Polyline,
|
|
497
|
-
Pre,
|
|
498
|
-
Quote,
|
|
499
|
-
Rect,
|
|
500
|
-
Reference,
|
|
501
|
-
Root,
|
|
502
|
-
Search,
|
|
503
|
-
Section,
|
|
504
|
-
Select,
|
|
505
|
-
Span,
|
|
506
|
-
Strong,
|
|
507
|
-
Style,
|
|
508
|
-
Svg,
|
|
509
|
-
TBody,
|
|
510
|
-
THead,
|
|
511
|
-
Table,
|
|
512
|
-
Td,
|
|
513
|
-
Text,
|
|
514
|
-
TextArea,
|
|
515
|
-
Tfoot,
|
|
516
|
-
Th,
|
|
517
|
-
Time,
|
|
518
|
-
Title,
|
|
519
|
-
Tr,
|
|
520
|
-
Ul,
|
|
521
|
-
Use,
|
|
522
|
-
Video
|
|
523
|
-
};
|
|
524
|
-
|
|
525
|
-
const TargetName = 'event.target.name';
|
|
526
|
-
|
|
527
|
-
const Tab = 2;
|
|
528
|
-
const Escape = 8;
|
|
529
|
-
|
|
530
|
-
const Shift = 1 << 10 >>> 0;
|
|
531
|
-
|
|
532
|
-
const FileSystemWorker = 209;
|
|
533
|
-
const RendererWorker$1 = 1;
|
|
534
|
-
|
|
535
|
-
const mergeClassNames = (...classNames) => {
|
|
536
|
-
return classNames.filter(Boolean).join(' ');
|
|
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;
|
|
537
275
|
};
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
};
|
|
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;
|
|
545
282
|
};
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
const FocusAbout = 4;
|
|
550
|
-
|
|
551
|
-
const getKeyBindings = () => {
|
|
552
|
-
return [{
|
|
553
|
-
command: 'About.handleClickClose',
|
|
554
|
-
key: Escape,
|
|
555
|
-
when: FocusAbout
|
|
556
|
-
}, {
|
|
557
|
-
command: 'About.focusNext',
|
|
558
|
-
key: Tab,
|
|
559
|
-
when: FocusAbout
|
|
560
|
-
}, {
|
|
561
|
-
command: 'About.focusPrevious',
|
|
562
|
-
key: Tab | Shift,
|
|
563
|
-
when: FocusAbout
|
|
564
|
-
}];
|
|
283
|
+
const signal$8 = global => {
|
|
284
|
+
global.postMessage(readyMessage);
|
|
565
285
|
};
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
return line.slice('Error: '.length);
|
|
286
|
+
class IpcChildWithModuleWorker extends Ipc {
|
|
287
|
+
getData(event) {
|
|
288
|
+
return getData$2(event);
|
|
570
289
|
}
|
|
571
|
-
|
|
572
|
-
|
|
290
|
+
send(message) {
|
|
291
|
+
// @ts-ignore
|
|
292
|
+
this._rawIpc.postMessage(message);
|
|
573
293
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
if (message) {
|
|
579
|
-
return `${message}: ${stringifiedError}`;
|
|
294
|
+
sendAndTransfer(message) {
|
|
295
|
+
const transfer = getTransferrables(message);
|
|
296
|
+
// @ts-ignore
|
|
297
|
+
this._rawIpc.postMessage(message, transfer);
|
|
580
298
|
}
|
|
581
|
-
|
|
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);
|
|
582
311
|
};
|
|
583
|
-
const
|
|
584
|
-
const
|
|
585
|
-
|
|
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;
|
|
586
323
|
};
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
return parent;
|
|
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');
|
|
595
331
|
}
|
|
596
|
-
const
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
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
|
|
338
|
+
});
|
|
339
|
+
parentIpc.dispose();
|
|
340
|
+
const port = firstMessage.params[1];
|
|
341
|
+
return port;
|
|
601
342
|
}
|
|
602
|
-
return
|
|
343
|
+
return globalThis;
|
|
603
344
|
};
|
|
604
|
-
class
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
if (
|
|
617
|
-
|
|
618
|
-
this.code = error.code;
|
|
345
|
+
class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
346
|
+
getData(event) {
|
|
347
|
+
return getData$2(event);
|
|
348
|
+
}
|
|
349
|
+
send(message) {
|
|
350
|
+
this._rawIpc.postMessage(message);
|
|
351
|
+
}
|
|
352
|
+
sendAndTransfer(message) {
|
|
353
|
+
const transfer = getTransferrables(message);
|
|
354
|
+
this._rawIpc.postMessage(message, transfer);
|
|
355
|
+
}
|
|
356
|
+
dispose() {
|
|
357
|
+
if (this._rawIpc.close) {
|
|
358
|
+
this._rawIpc.close();
|
|
619
359
|
}
|
|
620
360
|
}
|
|
361
|
+
onClose(callback) {
|
|
362
|
+
// ignore
|
|
363
|
+
}
|
|
364
|
+
onMessage(callback) {
|
|
365
|
+
this._rawIpc.addEventListener('message', callback);
|
|
366
|
+
this._rawIpc.start();
|
|
367
|
+
}
|
|
621
368
|
}
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
return value && value instanceof MessagePort;
|
|
625
|
-
};
|
|
626
|
-
const isMessagePortMain = value => {
|
|
627
|
-
return value && value.constructor && value.constructor.name === 'MessagePortMain';
|
|
369
|
+
const wrap$e = port => {
|
|
370
|
+
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
628
371
|
};
|
|
629
|
-
const
|
|
630
|
-
|
|
372
|
+
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
373
|
+
__proto__: null,
|
|
374
|
+
listen: listen$6,
|
|
375
|
+
wrap: wrap$e
|
|
631
376
|
};
|
|
632
|
-
const
|
|
633
|
-
|
|
377
|
+
const addListener = (emitter, type, callback) => {
|
|
378
|
+
if ('addEventListener' in emitter) {
|
|
379
|
+
emitter.addEventListener(type, callback);
|
|
380
|
+
} else {
|
|
381
|
+
emitter.on(type, callback);
|
|
382
|
+
}
|
|
634
383
|
};
|
|
635
|
-
const
|
|
636
|
-
|
|
384
|
+
const removeListener = (emitter, type, callback) => {
|
|
385
|
+
if ('removeEventListener' in emitter) {
|
|
386
|
+
emitter.removeEventListener(type, callback);
|
|
387
|
+
} else {
|
|
388
|
+
emitter.off(type, callback);
|
|
389
|
+
}
|
|
637
390
|
};
|
|
638
|
-
const
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
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]);
|
|
643
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;
|
|
644
412
|
}
|
|
645
|
-
return
|
|
413
|
+
return promise;
|
|
646
414
|
};
|
|
647
|
-
const
|
|
648
|
-
|
|
649
|
-
|
|
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');
|
|
650
422
|
}
|
|
651
|
-
if (
|
|
652
|
-
|
|
653
|
-
return;
|
|
423
|
+
if (isMessagePortOpen) {
|
|
424
|
+
return messagePort;
|
|
654
425
|
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
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');
|
|
660
436
|
}
|
|
661
|
-
if (
|
|
662
|
-
|
|
663
|
-
walkValue(property, transferrables, isTransferrable);
|
|
664
|
-
}
|
|
437
|
+
if (event.data !== readyMessage) {
|
|
438
|
+
throw new IpcError('unexpected first message');
|
|
665
439
|
}
|
|
440
|
+
return messagePort;
|
|
666
441
|
};
|
|
667
|
-
const
|
|
668
|
-
|
|
669
|
-
walkValue(value, transferrables, isTransferrable);
|
|
670
|
-
return transferrables;
|
|
671
|
-
};
|
|
672
|
-
const attachEvents = that => {
|
|
673
|
-
const handleMessage = (...args) => {
|
|
674
|
-
const data = that.getData(...args);
|
|
675
|
-
that.dispatchEvent(new MessageEvent('message', {
|
|
676
|
-
data
|
|
677
|
-
}));
|
|
678
|
-
};
|
|
679
|
-
that.onMessage(handleMessage);
|
|
680
|
-
const handleClose = event => {
|
|
681
|
-
that.dispatchEvent(new Event('close'));
|
|
682
|
-
};
|
|
683
|
-
that.onClose(handleClose);
|
|
442
|
+
const signal$1 = messagePort => {
|
|
443
|
+
messagePort.start();
|
|
684
444
|
};
|
|
685
|
-
class
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
this._rawIpc
|
|
689
|
-
|
|
445
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
446
|
+
getData = getData$2;
|
|
447
|
+
send(message) {
|
|
448
|
+
this._rawIpc.postMessage(message);
|
|
449
|
+
}
|
|
450
|
+
sendAndTransfer(message) {
|
|
451
|
+
const transfer = getTransferrables(message);
|
|
452
|
+
this._rawIpc.postMessage(message, transfer);
|
|
690
453
|
}
|
|
454
|
+
dispose() {
|
|
455
|
+
this._rawIpc.close();
|
|
456
|
+
}
|
|
457
|
+
onMessage(callback) {
|
|
458
|
+
this._rawIpc.addEventListener('message', callback);
|
|
459
|
+
}
|
|
460
|
+
onClose(callback) {}
|
|
691
461
|
}
|
|
692
|
-
const
|
|
693
|
-
|
|
694
|
-
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
695
|
-
const NewLine$2 = '\n';
|
|
696
|
-
const joinLines$2 = lines => {
|
|
697
|
-
return lines.join(NewLine$2);
|
|
462
|
+
const wrap$5 = messagePort => {
|
|
463
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
698
464
|
};
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
465
|
+
const IpcParentWithMessagePort$1 = {
|
|
466
|
+
__proto__: null,
|
|
467
|
+
create: create$5$1,
|
|
468
|
+
signal: signal$1,
|
|
469
|
+
wrap: wrap$5
|
|
703
470
|
};
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
rest: []
|
|
710
|
-
};
|
|
471
|
+
|
|
472
|
+
class CommandNotFoundError extends Error {
|
|
473
|
+
constructor(command) {
|
|
474
|
+
super(`Command not found ${command}`);
|
|
475
|
+
this.name = 'CommandNotFoundError';
|
|
711
476
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
477
|
+
}
|
|
478
|
+
const commands = Object.create(null);
|
|
479
|
+
const register = commandMap => {
|
|
480
|
+
Object.assign(commands, commandMap);
|
|
481
|
+
};
|
|
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);
|
|
717
489
|
}
|
|
718
|
-
return
|
|
719
|
-
actualMessage: lines[index - 1],
|
|
720
|
-
rest: lines.slice(index, lastIndex)
|
|
721
|
-
};
|
|
490
|
+
return fn(...args);
|
|
722
491
|
};
|
|
723
|
-
|
|
724
|
-
|
|
492
|
+
|
|
493
|
+
const Two$1 = '2.0';
|
|
494
|
+
const callbacks = Object.create(null);
|
|
495
|
+
const get$2 = id => {
|
|
496
|
+
return callbacks[id];
|
|
725
497
|
};
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
const isMessageCodeBlockStartIndex = line => {
|
|
729
|
-
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
498
|
+
const remove$1 = id => {
|
|
499
|
+
delete callbacks[id];
|
|
730
500
|
};
|
|
731
|
-
|
|
732
|
-
|
|
501
|
+
class JsonRpcError extends Error {
|
|
502
|
+
constructor(message) {
|
|
503
|
+
super(message);
|
|
504
|
+
this.name = 'JsonRpcError';
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
const NewLine$1 = '\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
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (message.startsWith('TypeError: ')) {
|
|
528
|
+
return TypeError;
|
|
529
|
+
}
|
|
530
|
+
if (message.startsWith('SyntaxError: ')) {
|
|
531
|
+
return SyntaxError;
|
|
532
|
+
}
|
|
533
|
+
if (message.startsWith('ReferenceError: ')) {
|
|
534
|
+
return ReferenceError;
|
|
535
|
+
}
|
|
536
|
+
return Error;
|
|
733
537
|
};
|
|
734
|
-
const
|
|
735
|
-
const
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
538
|
+
const constructError = (message, type, name) => {
|
|
539
|
+
const ErrorConstructor = getErrorConstructor(message, type);
|
|
540
|
+
if (ErrorConstructor === DOMException && name) {
|
|
541
|
+
return new ErrorConstructor(message, name);
|
|
542
|
+
}
|
|
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);
|
|
741
554
|
};
|
|
742
|
-
const
|
|
743
|
-
return
|
|
555
|
+
const joinLines$1 = lines => {
|
|
556
|
+
return lines.join(NewLine$1);
|
|
744
557
|
};
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
748
|
-
const message = lines[messageIndex];
|
|
749
|
-
return {
|
|
750
|
-
code: ERR_MODULE_NOT_FOUND,
|
|
751
|
-
message
|
|
752
|
-
};
|
|
558
|
+
const splitLines = lines => {
|
|
559
|
+
return lines.split(NewLine$1);
|
|
753
560
|
};
|
|
754
|
-
const
|
|
755
|
-
|
|
756
|
-
|
|
561
|
+
const getCurrentStack = () => {
|
|
562
|
+
const stackLinesToSkip = 3;
|
|
563
|
+
const currentStack = joinLines$1(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
564
|
+
return currentStack;
|
|
565
|
+
};
|
|
566
|
+
const getNewLineIndex = (string, startIndex) => {
|
|
567
|
+
{
|
|
568
|
+
return string.indexOf(NewLine$1);
|
|
757
569
|
}
|
|
758
|
-
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
759
570
|
};
|
|
760
|
-
const
|
|
761
|
-
|
|
762
|
-
|
|
571
|
+
const getParentStack = error => {
|
|
572
|
+
let parentStack = error.stack || error.data || error.message || '';
|
|
573
|
+
if (parentStack.startsWith(' at')) {
|
|
574
|
+
parentStack = error.message + NewLine$1 + parentStack;
|
|
763
575
|
}
|
|
764
|
-
return
|
|
576
|
+
return parentStack;
|
|
765
577
|
};
|
|
766
|
-
const
|
|
767
|
-
const
|
|
768
|
-
const
|
|
769
|
-
|
|
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;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
Object.defineProperty(error, 'stack', {
|
|
592
|
+
configurable: true,
|
|
593
|
+
value: stack,
|
|
594
|
+
writable: true
|
|
595
|
+
});
|
|
770
596
|
};
|
|
771
|
-
const
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
};
|
|
597
|
+
const restoreExistingError = (error, currentStack) => {
|
|
598
|
+
if (typeof error.stack === 'string') {
|
|
599
|
+
setStack(error, `${error.stack}${NewLine$1}${currentStack}`);
|
|
600
|
+
}
|
|
601
|
+
return error;
|
|
777
602
|
};
|
|
778
|
-
const
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
603
|
+
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
604
|
+
const restoredError = new JsonRpcError(error.message);
|
|
605
|
+
const parentStack = getParentStack(error);
|
|
606
|
+
setStack(restoredError, `${parentStack}${NewLine$1}${currentStack}`);
|
|
607
|
+
return restoredError;
|
|
783
608
|
};
|
|
784
|
-
const
|
|
785
|
-
if (
|
|
786
|
-
|
|
609
|
+
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
610
|
+
if (error.data.stack && error.data.type && error.message) {
|
|
611
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine$1}${error.data.stack}${NewLine$1}${currentStack}`);
|
|
612
|
+
return;
|
|
787
613
|
}
|
|
788
|
-
if (
|
|
789
|
-
|
|
614
|
+
if (error.data.stack) {
|
|
615
|
+
setStack(restoredError, error.data.stack);
|
|
790
616
|
}
|
|
791
|
-
|
|
792
|
-
|
|
617
|
+
};
|
|
618
|
+
const applyDataProperties = (restoredError, error) => {
|
|
619
|
+
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
620
|
+
if (error.data.codeFrame) {
|
|
621
|
+
// @ts-ignore
|
|
622
|
+
restoredError.codeFrame = error.data.codeFrame;
|
|
623
|
+
}
|
|
624
|
+
if (error.data.code) {
|
|
625
|
+
// @ts-ignore
|
|
626
|
+
restoredError.code = error.data.code;
|
|
627
|
+
}
|
|
628
|
+
if (error.data.type) {
|
|
629
|
+
// @ts-ignore
|
|
630
|
+
restoredError.name = error.data.type;
|
|
793
631
|
}
|
|
794
|
-
const lines = splitLines$1(stderr);
|
|
795
|
-
const {
|
|
796
|
-
actualMessage,
|
|
797
|
-
rest
|
|
798
|
-
} = getDetails(lines);
|
|
799
|
-
return {
|
|
800
|
-
code: '',
|
|
801
|
-
message: actualMessage,
|
|
802
|
-
stack: rest
|
|
803
|
-
};
|
|
804
632
|
};
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
const {
|
|
811
|
-
code,
|
|
812
|
-
message,
|
|
813
|
-
stack
|
|
814
|
-
} = getHelpfulChildProcessError(stdout, stderr);
|
|
815
|
-
const cause = new Error(message);
|
|
816
|
-
// @ts-ignore
|
|
817
|
-
cause.code = code;
|
|
818
|
-
if (stack) {
|
|
819
|
-
Object.defineProperty(cause, 'stack', {
|
|
820
|
-
configurable: true,
|
|
821
|
-
enumerable: false,
|
|
822
|
-
value: stack,
|
|
823
|
-
writable: true
|
|
824
|
-
});
|
|
825
|
-
}
|
|
826
|
-
super(cause, betterMessage);
|
|
827
|
-
} else {
|
|
828
|
-
super(betterMessage);
|
|
829
|
-
}
|
|
830
|
-
// @ts-ignore
|
|
831
|
-
this.name = 'IpcError';
|
|
633
|
+
const applyDirectProperties = (restoredError, error) => {
|
|
634
|
+
if (error.stack) {
|
|
635
|
+
const lowerStack = restoredError.stack || '';
|
|
636
|
+
const indexNewLine = getNewLineIndex(lowerStack);
|
|
637
|
+
const parentStack = getParentStack(error);
|
|
832
638
|
// @ts-ignore
|
|
833
|
-
|
|
639
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
640
|
+
}
|
|
641
|
+
if (error.codeFrame) {
|
|
834
642
|
// @ts-ignore
|
|
835
|
-
|
|
643
|
+
restoredError.codeFrame = error.codeFrame;
|
|
836
644
|
}
|
|
837
|
-
}
|
|
838
|
-
const readyMessage = 'ready';
|
|
839
|
-
const getData$2 = event => {
|
|
840
|
-
return event.data;
|
|
841
645
|
};
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
if (
|
|
845
|
-
|
|
646
|
+
const restoreMessageError = (error, _currentStack) => {
|
|
647
|
+
const restoredError = constructError(error.message, error.type, error.name);
|
|
648
|
+
if (error.data) {
|
|
649
|
+
applyDataProperties(restoredError, error);
|
|
650
|
+
} else {
|
|
651
|
+
applyDirectProperties(restoredError, error);
|
|
846
652
|
}
|
|
847
|
-
return
|
|
848
|
-
};
|
|
849
|
-
const signal$8 = global => {
|
|
850
|
-
global.postMessage(readyMessage);
|
|
653
|
+
return restoredError;
|
|
851
654
|
};
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
655
|
+
const restoreJsonRpcError = error => {
|
|
656
|
+
const currentStack = getCurrentStack();
|
|
657
|
+
if (error && error instanceof Error) {
|
|
658
|
+
return restoreExistingError(error, currentStack);
|
|
855
659
|
}
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
this._rawIpc.postMessage(message);
|
|
660
|
+
if (error && error.code && error.code === MethodNotFound) {
|
|
661
|
+
return restoreMethodNotFoundError(error, currentStack);
|
|
859
662
|
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
// @ts-ignore
|
|
863
|
-
this._rawIpc.postMessage(message, transfer);
|
|
663
|
+
if (error && error.message) {
|
|
664
|
+
return restoreMessageError(error);
|
|
864
665
|
}
|
|
865
|
-
|
|
866
|
-
|
|
666
|
+
if (typeof error === 'string') {
|
|
667
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
867
668
|
}
|
|
868
|
-
|
|
869
|
-
|
|
669
|
+
return new Error(`JsonRpc Error: ${error}`);
|
|
670
|
+
};
|
|
671
|
+
const unwrapJsonRpcResult = responseMessage => {
|
|
672
|
+
if ('error' in responseMessage) {
|
|
673
|
+
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
674
|
+
throw restoredError;
|
|
870
675
|
}
|
|
871
|
-
|
|
872
|
-
|
|
676
|
+
if ('result' in responseMessage) {
|
|
677
|
+
return responseMessage.result;
|
|
873
678
|
}
|
|
874
|
-
|
|
875
|
-
const wrap$f = global => {
|
|
876
|
-
return new IpcChildWithModuleWorker(global);
|
|
679
|
+
throw new JsonRpcError('unexpected response message');
|
|
877
680
|
};
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
promise,
|
|
881
|
-
resolve
|
|
882
|
-
} = Promise.withResolvers();
|
|
883
|
-
port.addEventListener('message', resolve, {
|
|
884
|
-
once: true
|
|
885
|
-
});
|
|
886
|
-
const event = await promise;
|
|
887
|
-
// @ts-ignore
|
|
888
|
-
return event.data;
|
|
681
|
+
const warn = (...args) => {
|
|
682
|
+
console.warn(...args);
|
|
889
683
|
};
|
|
890
|
-
const
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
throw new IpcError('unexpected first message');
|
|
897
|
-
}
|
|
898
|
-
const type = firstMessage.params[0];
|
|
899
|
-
if (type === 'message-port') {
|
|
900
|
-
parentIpc.send({
|
|
901
|
-
id: firstMessage.id,
|
|
902
|
-
jsonrpc: '2.0',
|
|
903
|
-
result: null
|
|
904
|
-
});
|
|
905
|
-
parentIpc.dispose();
|
|
906
|
-
const port = firstMessage.params[1];
|
|
907
|
-
return port;
|
|
684
|
+
const resolve = (id, response) => {
|
|
685
|
+
const fn = get$2(id);
|
|
686
|
+
if (!fn) {
|
|
687
|
+
console.log(response);
|
|
688
|
+
warn(`callback ${id} may already be disposed`);
|
|
689
|
+
return;
|
|
908
690
|
}
|
|
909
|
-
|
|
691
|
+
fn(response);
|
|
692
|
+
remove$1(id);
|
|
910
693
|
};
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
send(message) {
|
|
916
|
-
this._rawIpc.postMessage(message);
|
|
917
|
-
}
|
|
918
|
-
sendAndTransfer(message) {
|
|
919
|
-
const transfer = getTransferrables(message);
|
|
920
|
-
this._rawIpc.postMessage(message, transfer);
|
|
921
|
-
}
|
|
922
|
-
dispose() {
|
|
923
|
-
if (this._rawIpc.close) {
|
|
924
|
-
this._rawIpc.close();
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
onClose(callback) {
|
|
928
|
-
// ignore
|
|
694
|
+
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
695
|
+
const getErrorType = prettyError => {
|
|
696
|
+
if (prettyError && prettyError.type) {
|
|
697
|
+
return prettyError.type;
|
|
929
698
|
}
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
this._rawIpc.start();
|
|
699
|
+
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
700
|
+
return prettyError.constructor.name;
|
|
933
701
|
}
|
|
934
|
-
|
|
935
|
-
const wrap$e = port => {
|
|
936
|
-
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
702
|
+
return undefined;
|
|
937
703
|
};
|
|
938
|
-
const
|
|
939
|
-
|
|
940
|
-
listen: listen$6,
|
|
941
|
-
wrap: wrap$e
|
|
704
|
+
const isAlreadyStack = line => {
|
|
705
|
+
return line.trim().startsWith('at ');
|
|
942
706
|
};
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
707
|
+
const getStack = prettyError => {
|
|
708
|
+
const stackString = prettyError.stack || '';
|
|
709
|
+
const newLineIndex = stackString.indexOf('\n');
|
|
710
|
+
if (newLineIndex !== -1 && !isAlreadyStack(stackString.slice(0, newLineIndex))) {
|
|
711
|
+
return stackString.slice(newLineIndex + 1);
|
|
948
712
|
}
|
|
713
|
+
return stackString;
|
|
949
714
|
};
|
|
950
|
-
const
|
|
951
|
-
if (
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
715
|
+
const getErrorProperty = (error, prettyError) => {
|
|
716
|
+
if (error && error.code === E_COMMAND_NOT_FOUND) {
|
|
717
|
+
return {
|
|
718
|
+
code: MethodNotFound,
|
|
719
|
+
data: error.stack,
|
|
720
|
+
message: error.message
|
|
721
|
+
};
|
|
955
722
|
}
|
|
723
|
+
return {
|
|
724
|
+
code: Custom,
|
|
725
|
+
data: {
|
|
726
|
+
code: prettyError.code,
|
|
727
|
+
codeFrame: prettyError.codeFrame,
|
|
728
|
+
name: prettyError.name,
|
|
729
|
+
stack: getStack(prettyError),
|
|
730
|
+
type: getErrorType(prettyError)
|
|
731
|
+
},
|
|
732
|
+
message: prettyError.message
|
|
733
|
+
};
|
|
956
734
|
};
|
|
957
|
-
const
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
const listenerMap = Object.create(null);
|
|
963
|
-
const cleanup = value => {
|
|
964
|
-
for (const event of Object.keys(eventMap)) {
|
|
965
|
-
removeListener(eventEmitter, event, listenerMap[event]);
|
|
966
|
-
}
|
|
967
|
-
resolve(value);
|
|
735
|
+
const create$1$1 = (id, error) => {
|
|
736
|
+
return {
|
|
737
|
+
error,
|
|
738
|
+
id,
|
|
739
|
+
jsonrpc: Two$1
|
|
968
740
|
};
|
|
969
|
-
for (const [event, type] of Object.entries(eventMap)) {
|
|
970
|
-
const listener = event => {
|
|
971
|
-
cleanup({
|
|
972
|
-
event,
|
|
973
|
-
type
|
|
974
|
-
});
|
|
975
|
-
};
|
|
976
|
-
addListener(eventEmitter, event, listener);
|
|
977
|
-
listenerMap[event] = listener;
|
|
978
|
-
}
|
|
979
|
-
return promise;
|
|
980
741
|
};
|
|
981
|
-
const
|
|
982
|
-
const
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
if (!isMessagePort(messagePort)) {
|
|
987
|
-
throw new IpcError('port must be of type MessagePort');
|
|
988
|
-
}
|
|
989
|
-
if (isMessagePortOpen) {
|
|
990
|
-
return messagePort;
|
|
991
|
-
}
|
|
992
|
-
const eventPromise = getFirstEvent(messagePort, {
|
|
993
|
-
message: Message$1
|
|
994
|
-
});
|
|
995
|
-
messagePort.start();
|
|
996
|
-
const {
|
|
997
|
-
event,
|
|
998
|
-
type
|
|
999
|
-
} = await eventPromise;
|
|
1000
|
-
if (type !== Message$1) {
|
|
1001
|
-
throw new IpcError('Failed to wait for ipc message');
|
|
1002
|
-
}
|
|
1003
|
-
if (event.data !== readyMessage) {
|
|
1004
|
-
throw new IpcError('unexpected first message');
|
|
1005
|
-
}
|
|
1006
|
-
return messagePort;
|
|
742
|
+
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
743
|
+
const prettyError = preparePrettyError(error);
|
|
744
|
+
logError(error, prettyError);
|
|
745
|
+
const errorProperty = getErrorProperty(error, prettyError);
|
|
746
|
+
return create$1$1(id, errorProperty);
|
|
1007
747
|
};
|
|
1008
|
-
const
|
|
1009
|
-
|
|
748
|
+
const create$a = (message, result) => {
|
|
749
|
+
return {
|
|
750
|
+
id: message.id,
|
|
751
|
+
jsonrpc: Two$1,
|
|
752
|
+
result: result ?? null
|
|
753
|
+
};
|
|
1010
754
|
};
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
this._rawIpc.postMessage(message);
|
|
1015
|
-
}
|
|
1016
|
-
sendAndTransfer(message) {
|
|
1017
|
-
const transfer = getTransferrables(message);
|
|
1018
|
-
this._rawIpc.postMessage(message, transfer);
|
|
1019
|
-
}
|
|
1020
|
-
dispose() {
|
|
1021
|
-
this._rawIpc.close();
|
|
1022
|
-
}
|
|
1023
|
-
onMessage(callback) {
|
|
1024
|
-
this._rawIpc.addEventListener('message', callback);
|
|
1025
|
-
}
|
|
1026
|
-
onClose(callback) {}
|
|
1027
|
-
}
|
|
1028
|
-
const wrap$5 = messagePort => {
|
|
1029
|
-
return new IpcParentWithMessagePort(messagePort);
|
|
755
|
+
const getSuccessResponse = (message, result) => {
|
|
756
|
+
const resultProperty = result ?? null;
|
|
757
|
+
return create$a(message, resultProperty);
|
|
1030
758
|
};
|
|
1031
|
-
const
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
759
|
+
const getErrorResponseSimple = (id, error) => {
|
|
760
|
+
return {
|
|
761
|
+
error: {
|
|
762
|
+
code: Custom,
|
|
763
|
+
data: error,
|
|
764
|
+
// @ts-ignore
|
|
765
|
+
message: error.message
|
|
766
|
+
},
|
|
767
|
+
id,
|
|
768
|
+
jsonrpc: Two$1
|
|
769
|
+
};
|
|
1036
770
|
};
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
771
|
+
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
772
|
+
try {
|
|
773
|
+
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
774
|
+
return getSuccessResponse(message, result);
|
|
775
|
+
} catch (error) {
|
|
776
|
+
if (ipc.canUseSimpleErrorResponse) {
|
|
777
|
+
return getErrorResponseSimple(message.id, error);
|
|
778
|
+
}
|
|
779
|
+
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1042
780
|
}
|
|
1043
|
-
}
|
|
1044
|
-
const commands = Object.create(null);
|
|
1045
|
-
const register = commandMap => {
|
|
1046
|
-
Object.assign(commands, commandMap);
|
|
1047
|
-
};
|
|
1048
|
-
const getCommand = key => {
|
|
1049
|
-
return commands[key];
|
|
1050
781
|
};
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1053
|
-
if (!fn) {
|
|
1054
|
-
throw new CommandNotFoundError(command);
|
|
1055
|
-
}
|
|
1056
|
-
return fn(...args);
|
|
782
|
+
const defaultPreparePrettyError = error => {
|
|
783
|
+
return error;
|
|
1057
784
|
};
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
const callbacks = Object.create(null);
|
|
1061
|
-
const get$1 = id => {
|
|
1062
|
-
return callbacks[id];
|
|
785
|
+
const defaultLogError = () => {
|
|
786
|
+
// ignore
|
|
1063
787
|
};
|
|
1064
|
-
const
|
|
1065
|
-
|
|
788
|
+
const defaultRequiresSocket = () => {
|
|
789
|
+
return false;
|
|
1066
790
|
};
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
return DOMException;
|
|
1083
|
-
case ReferenceError$1:
|
|
1084
|
-
return ReferenceError;
|
|
1085
|
-
case SyntaxError$1:
|
|
1086
|
-
return SyntaxError;
|
|
1087
|
-
case TypeError$1:
|
|
1088
|
-
return TypeError;
|
|
1089
|
-
default:
|
|
1090
|
-
return Error;
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
if (message.startsWith('TypeError: ')) {
|
|
1094
|
-
return TypeError;
|
|
1095
|
-
}
|
|
1096
|
-
if (message.startsWith('SyntaxError: ')) {
|
|
1097
|
-
return SyntaxError;
|
|
1098
|
-
}
|
|
1099
|
-
if (message.startsWith('ReferenceError: ')) {
|
|
1100
|
-
return ReferenceError;
|
|
791
|
+
const defaultResolve = resolve;
|
|
792
|
+
|
|
793
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
794
|
+
const normalizeParams = args => {
|
|
795
|
+
if (args.length === 1) {
|
|
796
|
+
const options = args[0];
|
|
797
|
+
return {
|
|
798
|
+
execute: options.execute,
|
|
799
|
+
ipc: options.ipc,
|
|
800
|
+
logError: options.logError || defaultLogError,
|
|
801
|
+
message: options.message,
|
|
802
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
803
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
804
|
+
resolve: options.resolve || defaultResolve
|
|
805
|
+
};
|
|
1101
806
|
}
|
|
1102
|
-
return
|
|
807
|
+
return {
|
|
808
|
+
execute: args[2],
|
|
809
|
+
ipc: args[0],
|
|
810
|
+
logError: args[5],
|
|
811
|
+
message: args[1],
|
|
812
|
+
preparePrettyError: args[4],
|
|
813
|
+
requiresSocket: args[6],
|
|
814
|
+
resolve: args[3]
|
|
815
|
+
};
|
|
1103
816
|
};
|
|
1104
|
-
const
|
|
1105
|
-
const
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
817
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
818
|
+
const options = normalizeParams(args);
|
|
819
|
+
const {
|
|
820
|
+
execute,
|
|
821
|
+
ipc,
|
|
822
|
+
logError,
|
|
823
|
+
message,
|
|
824
|
+
preparePrettyError,
|
|
825
|
+
requiresSocket,
|
|
826
|
+
resolve
|
|
827
|
+
} = options;
|
|
828
|
+
if ('id' in message) {
|
|
829
|
+
if ('method' in message) {
|
|
830
|
+
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
831
|
+
try {
|
|
832
|
+
ipc.send(response);
|
|
833
|
+
} catch (error) {
|
|
834
|
+
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
835
|
+
ipc.send(errorResponse);
|
|
836
|
+
}
|
|
837
|
+
return;
|
|
1116
838
|
}
|
|
1117
|
-
|
|
839
|
+
resolve(message.id, message);
|
|
840
|
+
return;
|
|
1118
841
|
}
|
|
1119
|
-
|
|
842
|
+
if ('method' in message) {
|
|
843
|
+
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
throw new JsonRpcError('unexpected message');
|
|
1120
847
|
};
|
|
1121
|
-
|
|
1122
|
-
|
|
848
|
+
|
|
849
|
+
const Two = '2.0';
|
|
850
|
+
|
|
851
|
+
const create$9 = (method, params) => {
|
|
852
|
+
return {
|
|
853
|
+
jsonrpc: Two,
|
|
854
|
+
method,
|
|
855
|
+
params
|
|
856
|
+
};
|
|
1123
857
|
};
|
|
1124
|
-
|
|
1125
|
-
|
|
858
|
+
|
|
859
|
+
const create$8 = (id, method, params) => {
|
|
860
|
+
const message = {
|
|
861
|
+
id,
|
|
862
|
+
jsonrpc: Two,
|
|
863
|
+
method,
|
|
864
|
+
params
|
|
865
|
+
};
|
|
866
|
+
return message;
|
|
1126
867
|
};
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
return
|
|
868
|
+
|
|
869
|
+
let id = 0;
|
|
870
|
+
const create$7 = () => {
|
|
871
|
+
return ++id;
|
|
1131
872
|
};
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
873
|
+
|
|
874
|
+
const registerPromise = map => {
|
|
875
|
+
const id = create$7();
|
|
876
|
+
const {
|
|
877
|
+
promise,
|
|
878
|
+
resolve
|
|
879
|
+
} = Promise.withResolvers();
|
|
880
|
+
map[id] = resolve;
|
|
881
|
+
return {
|
|
882
|
+
id,
|
|
883
|
+
promise
|
|
884
|
+
};
|
|
1136
885
|
};
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
886
|
+
|
|
887
|
+
const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
|
|
888
|
+
const {
|
|
889
|
+
id,
|
|
890
|
+
promise
|
|
891
|
+
} = registerPromise(callbacks);
|
|
892
|
+
const message = create$8(id, method, params);
|
|
893
|
+
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
894
|
+
ipc.sendAndTransfer(message);
|
|
895
|
+
} else {
|
|
896
|
+
ipc.send(message);
|
|
1141
897
|
}
|
|
1142
|
-
|
|
898
|
+
const responseMessage = await promise;
|
|
899
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
1143
900
|
};
|
|
1144
|
-
const
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
return;
|
|
1151
|
-
}
|
|
1152
|
-
if (!descriptor.configurable && descriptor.writable) {
|
|
1153
|
-
error.stack = stack;
|
|
901
|
+
const createRpc = ipc => {
|
|
902
|
+
const callbacks = Object.create(null);
|
|
903
|
+
ipc._resolve = (id, response) => {
|
|
904
|
+
const fn = callbacks[id];
|
|
905
|
+
if (!fn) {
|
|
906
|
+
console.warn(`callback ${id} may already be disposed`);
|
|
1154
907
|
return;
|
|
1155
908
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
}
|
|
1169
|
-
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
1170
|
-
const restoredError = new JsonRpcError(error.message);
|
|
1171
|
-
const parentStack = getParentStack(error);
|
|
1172
|
-
setStack(restoredError, `${parentStack}${NewLine$1}${currentStack}`);
|
|
1173
|
-
return restoredError;
|
|
1174
|
-
};
|
|
1175
|
-
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
1176
|
-
if (error.data.stack && error.data.type && error.message) {
|
|
1177
|
-
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine$1}${error.data.stack}${NewLine$1}${currentStack}`);
|
|
1178
|
-
return;
|
|
1179
|
-
}
|
|
1180
|
-
if (error.data.stack) {
|
|
1181
|
-
setStack(restoredError, error.data.stack);
|
|
1182
|
-
}
|
|
1183
|
-
};
|
|
1184
|
-
const applyDataProperties = (restoredError, error) => {
|
|
1185
|
-
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
1186
|
-
if (error.data.codeFrame) {
|
|
1187
|
-
// @ts-ignore
|
|
1188
|
-
restoredError.codeFrame = error.data.codeFrame;
|
|
1189
|
-
}
|
|
1190
|
-
if (error.data.code) {
|
|
1191
|
-
// @ts-ignore
|
|
1192
|
-
restoredError.code = error.data.code;
|
|
1193
|
-
}
|
|
1194
|
-
if (error.data.type) {
|
|
1195
|
-
// @ts-ignore
|
|
1196
|
-
restoredError.name = error.data.type;
|
|
1197
|
-
}
|
|
1198
|
-
};
|
|
1199
|
-
const applyDirectProperties = (restoredError, error) => {
|
|
1200
|
-
if (error.stack) {
|
|
1201
|
-
const lowerStack = restoredError.stack || '';
|
|
1202
|
-
const indexNewLine = getNewLineIndex(lowerStack);
|
|
1203
|
-
const parentStack = getParentStack(error);
|
|
1204
|
-
// @ts-ignore
|
|
1205
|
-
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
1206
|
-
}
|
|
1207
|
-
if (error.codeFrame) {
|
|
909
|
+
fn(response);
|
|
910
|
+
delete callbacks[id];
|
|
911
|
+
};
|
|
912
|
+
const rpc = {
|
|
913
|
+
async dispose() {
|
|
914
|
+
await ipc?.dispose();
|
|
915
|
+
},
|
|
916
|
+
invoke(method, ...params) {
|
|
917
|
+
return invokeHelper(callbacks, ipc, method, params, false);
|
|
918
|
+
},
|
|
919
|
+
invokeAndTransfer(method, ...params) {
|
|
920
|
+
return invokeHelper(callbacks, ipc, method, params, true);
|
|
921
|
+
},
|
|
1208
922
|
// @ts-ignore
|
|
1209
|
-
|
|
1210
|
-
|
|
923
|
+
ipc,
|
|
924
|
+
/**
|
|
925
|
+
* @deprecated
|
|
926
|
+
*/
|
|
927
|
+
send(method, ...params) {
|
|
928
|
+
const message = create$9(method, params);
|
|
929
|
+
ipc.send(message);
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
return rpc;
|
|
1211
933
|
};
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
applyDataProperties(restoredError, error);
|
|
1216
|
-
} else {
|
|
1217
|
-
applyDirectProperties(restoredError, error);
|
|
1218
|
-
}
|
|
1219
|
-
return restoredError;
|
|
934
|
+
|
|
935
|
+
const requiresSocket = () => {
|
|
936
|
+
return false;
|
|
1220
937
|
};
|
|
1221
|
-
const
|
|
1222
|
-
|
|
1223
|
-
if (error && error instanceof Error) {
|
|
1224
|
-
return restoreExistingError(error, currentStack);
|
|
1225
|
-
}
|
|
1226
|
-
if (error && error.code && error.code === MethodNotFound) {
|
|
1227
|
-
return restoreMethodNotFoundError(error, currentStack);
|
|
1228
|
-
}
|
|
1229
|
-
if (error && error.message) {
|
|
1230
|
-
return restoreMessageError(error);
|
|
1231
|
-
}
|
|
1232
|
-
if (typeof error === 'string') {
|
|
1233
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
1234
|
-
}
|
|
1235
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
938
|
+
const preparePrettyError = error => {
|
|
939
|
+
return error;
|
|
1236
940
|
};
|
|
1237
|
-
const
|
|
1238
|
-
|
|
1239
|
-
const restoredError = restoreJsonRpcError(responseMessage.error);
|
|
1240
|
-
throw restoredError;
|
|
1241
|
-
}
|
|
1242
|
-
if ('result' in responseMessage) {
|
|
1243
|
-
return responseMessage.result;
|
|
1244
|
-
}
|
|
1245
|
-
throw new JsonRpcError('unexpected response message');
|
|
941
|
+
const logError = () => {
|
|
942
|
+
// handled by renderer worker
|
|
1246
943
|
};
|
|
1247
|
-
const
|
|
1248
|
-
|
|
944
|
+
const handleMessage = event => {
|
|
945
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
946
|
+
const actualExecute = event?.target?.execute || execute;
|
|
947
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1249
948
|
};
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
if (
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
949
|
+
|
|
950
|
+
const handleIpc = ipc => {
|
|
951
|
+
if ('addEventListener' in ipc) {
|
|
952
|
+
ipc.addEventListener('message', handleMessage);
|
|
953
|
+
} else if ('on' in ipc) {
|
|
954
|
+
// deprecated
|
|
955
|
+
ipc.on('message', handleMessage);
|
|
1256
956
|
}
|
|
1257
|
-
fn(response);
|
|
1258
|
-
remove$1(id);
|
|
1259
957
|
};
|
|
1260
|
-
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
if (prettyError && prettyError.constructor && prettyError.constructor.name) {
|
|
1266
|
-
return prettyError.constructor.name;
|
|
958
|
+
|
|
959
|
+
const listen$1 = async (module, options) => {
|
|
960
|
+
const rawIpc = await module.listen(options);
|
|
961
|
+
if (module.signal) {
|
|
962
|
+
module.signal(rawIpc);
|
|
1267
963
|
}
|
|
1268
|
-
|
|
964
|
+
const ipc = module.wrap(rawIpc);
|
|
965
|
+
return ipc;
|
|
1269
966
|
};
|
|
1270
|
-
|
|
1271
|
-
|
|
967
|
+
|
|
968
|
+
const create$6 = async ({
|
|
969
|
+
commandMap,
|
|
970
|
+
isMessagePortOpen = true,
|
|
971
|
+
messagePort
|
|
972
|
+
}) => {
|
|
973
|
+
// TODO create a commandMap per rpc instance
|
|
974
|
+
register(commandMap);
|
|
975
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
976
|
+
isMessagePortOpen,
|
|
977
|
+
messagePort
|
|
978
|
+
});
|
|
979
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
980
|
+
handleIpc(ipc);
|
|
981
|
+
const rpc = createRpc(ipc);
|
|
982
|
+
messagePort.start();
|
|
983
|
+
return rpc;
|
|
1272
984
|
};
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
985
|
+
|
|
986
|
+
const create$5 = async ({
|
|
987
|
+
commandMap,
|
|
988
|
+
isMessagePortOpen,
|
|
989
|
+
send
|
|
990
|
+
}) => {
|
|
991
|
+
const {
|
|
992
|
+
port1,
|
|
993
|
+
port2
|
|
994
|
+
} = new MessageChannel();
|
|
995
|
+
await send(port1);
|
|
996
|
+
return create$6({
|
|
997
|
+
commandMap,
|
|
998
|
+
isMessagePortOpen,
|
|
999
|
+
messagePort: port2
|
|
1000
|
+
});
|
|
1280
1001
|
};
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
}
|
|
1288
|
-
|
|
1002
|
+
|
|
1003
|
+
const createSharedLazyRpc = factory => {
|
|
1004
|
+
let rpcPromise;
|
|
1005
|
+
const getOrCreate = () => {
|
|
1006
|
+
if (!rpcPromise) {
|
|
1007
|
+
rpcPromise = factory();
|
|
1008
|
+
}
|
|
1009
|
+
return rpcPromise;
|
|
1010
|
+
};
|
|
1289
1011
|
return {
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
codeFrame: prettyError.codeFrame,
|
|
1294
|
-
name: prettyError.name,
|
|
1295
|
-
stack: getStack(prettyError),
|
|
1296
|
-
type: getErrorType(prettyError)
|
|
1012
|
+
async dispose() {
|
|
1013
|
+
const rpc = await getOrCreate();
|
|
1014
|
+
await rpc.dispose();
|
|
1297
1015
|
},
|
|
1298
|
-
|
|
1016
|
+
async invoke(method, ...params) {
|
|
1017
|
+
const rpc = await getOrCreate();
|
|
1018
|
+
return rpc.invoke(method, ...params);
|
|
1019
|
+
},
|
|
1020
|
+
async invokeAndTransfer(method, ...params) {
|
|
1021
|
+
const rpc = await getOrCreate();
|
|
1022
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1023
|
+
},
|
|
1024
|
+
async send(method, ...params) {
|
|
1025
|
+
const rpc = await getOrCreate();
|
|
1026
|
+
rpc.send(method, ...params);
|
|
1027
|
+
}
|
|
1299
1028
|
};
|
|
1300
1029
|
};
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1030
|
+
|
|
1031
|
+
const create$4 = async ({
|
|
1032
|
+
commandMap,
|
|
1033
|
+
isMessagePortOpen,
|
|
1034
|
+
send
|
|
1035
|
+
}) => {
|
|
1036
|
+
return createSharedLazyRpc(() => {
|
|
1037
|
+
return create$5({
|
|
1038
|
+
commandMap,
|
|
1039
|
+
isMessagePortOpen,
|
|
1040
|
+
send
|
|
1041
|
+
});
|
|
1042
|
+
});
|
|
1307
1043
|
};
|
|
1308
|
-
const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
1309
|
-
const prettyError = preparePrettyError(error);
|
|
1310
|
-
logError(error, prettyError);
|
|
1311
|
-
const errorProperty = getErrorProperty(error, prettyError);
|
|
1312
|
-
return create$1$1(id, errorProperty);
|
|
1313
|
-
};
|
|
1314
|
-
const create$8 = (message, result) => {
|
|
1315
|
-
return {
|
|
1316
|
-
id: message.id,
|
|
1317
|
-
jsonrpc: Two$1,
|
|
1318
|
-
result: result ?? null
|
|
1319
|
-
};
|
|
1320
|
-
};
|
|
1321
|
-
const getSuccessResponse = (message, result) => {
|
|
1322
|
-
const resultProperty = result ?? null;
|
|
1323
|
-
return create$8(message, resultProperty);
|
|
1324
|
-
};
|
|
1325
|
-
const getErrorResponseSimple = (id, error) => {
|
|
1326
|
-
return {
|
|
1327
|
-
error: {
|
|
1328
|
-
code: Custom,
|
|
1329
|
-
data: error,
|
|
1330
|
-
// @ts-ignore
|
|
1331
|
-
message: error.message
|
|
1332
|
-
},
|
|
1333
|
-
id,
|
|
1334
|
-
jsonrpc: Two$1
|
|
1335
|
-
};
|
|
1336
|
-
};
|
|
1337
|
-
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
1338
|
-
try {
|
|
1339
|
-
const result = requiresSocket(message.method) ? await execute(message.method, ipc, ...message.params) : await execute(message.method, ...message.params);
|
|
1340
|
-
return getSuccessResponse(message, result);
|
|
1341
|
-
} catch (error) {
|
|
1342
|
-
if (ipc.canUseSimpleErrorResponse) {
|
|
1343
|
-
return getErrorResponseSimple(message.id, error);
|
|
1344
|
-
}
|
|
1345
|
-
return getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1346
|
-
}
|
|
1347
|
-
};
|
|
1348
|
-
const defaultPreparePrettyError = error => {
|
|
1349
|
-
return error;
|
|
1350
|
-
};
|
|
1351
|
-
const defaultLogError = () => {
|
|
1352
|
-
// ignore
|
|
1353
|
-
};
|
|
1354
|
-
const defaultRequiresSocket = () => {
|
|
1355
|
-
return false;
|
|
1356
|
-
};
|
|
1357
|
-
const defaultResolve = resolve;
|
|
1358
1044
|
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
1369
|
-
requiresSocket: options.requiresSocket || defaultRequiresSocket,
|
|
1370
|
-
resolve: options.resolve || defaultResolve
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
return {
|
|
1374
|
-
execute: args[2],
|
|
1375
|
-
ipc: args[0],
|
|
1376
|
-
logError: args[5],
|
|
1377
|
-
message: args[1],
|
|
1378
|
-
preparePrettyError: args[4],
|
|
1379
|
-
requiresSocket: args[6],
|
|
1380
|
-
resolve: args[3]
|
|
1381
|
-
};
|
|
1382
|
-
};
|
|
1383
|
-
const handleJsonRpcMessage = async (...args) => {
|
|
1384
|
-
const options = normalizeParams(args);
|
|
1385
|
-
const {
|
|
1386
|
-
execute,
|
|
1387
|
-
ipc,
|
|
1388
|
-
logError,
|
|
1389
|
-
message,
|
|
1390
|
-
preparePrettyError,
|
|
1391
|
-
requiresSocket,
|
|
1392
|
-
resolve
|
|
1393
|
-
} = options;
|
|
1394
|
-
if ('id' in message) {
|
|
1395
|
-
if ('method' in message) {
|
|
1396
|
-
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
1397
|
-
try {
|
|
1398
|
-
ipc.send(response);
|
|
1399
|
-
} catch (error) {
|
|
1400
|
-
const errorResponse = getErrorResponse(message.id, error, preparePrettyError, logError);
|
|
1401
|
-
ipc.send(errorResponse);
|
|
1402
|
-
}
|
|
1403
|
-
return;
|
|
1404
|
-
}
|
|
1405
|
-
resolve(message.id, message);
|
|
1406
|
-
return;
|
|
1407
|
-
}
|
|
1408
|
-
if ('method' in message) {
|
|
1409
|
-
await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
1410
|
-
return;
|
|
1411
|
-
}
|
|
1412
|
-
throw new JsonRpcError('unexpected message');
|
|
1045
|
+
const create$3 = async ({
|
|
1046
|
+
commandMap
|
|
1047
|
+
}) => {
|
|
1048
|
+
// TODO create a commandMap per rpc instance
|
|
1049
|
+
register(commandMap);
|
|
1050
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1051
|
+
handleIpc(ipc);
|
|
1052
|
+
const rpc = createRpc(ipc);
|
|
1053
|
+
return rpc;
|
|
1413
1054
|
};
|
|
1414
1055
|
|
|
1415
|
-
const
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
method,
|
|
1421
|
-
|
|
1056
|
+
const createMockRpc = ({
|
|
1057
|
+
commandMap
|
|
1058
|
+
}) => {
|
|
1059
|
+
const invocations = [];
|
|
1060
|
+
const invoke = (method, ...params) => {
|
|
1061
|
+
invocations.push([method, ...params]);
|
|
1062
|
+
const command = commandMap[method];
|
|
1063
|
+
if (!command) {
|
|
1064
|
+
throw new Error(`command ${method} not found`);
|
|
1065
|
+
}
|
|
1066
|
+
return command(...params);
|
|
1422
1067
|
};
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
id,
|
|
1428
|
-
jsonrpc: Two,
|
|
1429
|
-
method,
|
|
1430
|
-
params
|
|
1068
|
+
const mockRpc = {
|
|
1069
|
+
invocations,
|
|
1070
|
+
invoke,
|
|
1071
|
+
invokeAndTransfer: invoke
|
|
1431
1072
|
};
|
|
1432
|
-
return
|
|
1073
|
+
return mockRpc;
|
|
1433
1074
|
};
|
|
1434
1075
|
|
|
1435
|
-
|
|
1436
|
-
const
|
|
1437
|
-
|
|
1076
|
+
const rpcs = Object.create(null);
|
|
1077
|
+
const set$4 = (id, rpc) => {
|
|
1078
|
+
rpcs[id] = rpc;
|
|
1438
1079
|
};
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
const id = create$5();
|
|
1442
|
-
const {
|
|
1443
|
-
promise,
|
|
1444
|
-
resolve
|
|
1445
|
-
} = Promise.withResolvers();
|
|
1446
|
-
map[id] = resolve;
|
|
1447
|
-
return {
|
|
1448
|
-
id,
|
|
1449
|
-
promise
|
|
1450
|
-
};
|
|
1080
|
+
const get$1 = id => {
|
|
1081
|
+
return rpcs[id];
|
|
1451
1082
|
};
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
const {
|
|
1455
|
-
id,
|
|
1456
|
-
promise
|
|
1457
|
-
} = registerPromise(callbacks);
|
|
1458
|
-
const message = create$6(id, method, params);
|
|
1459
|
-
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1460
|
-
ipc.sendAndTransfer(message);
|
|
1461
|
-
} else {
|
|
1462
|
-
ipc.send(message);
|
|
1463
|
-
}
|
|
1464
|
-
const responseMessage = await promise;
|
|
1465
|
-
return unwrapJsonRpcResult(responseMessage);
|
|
1083
|
+
const remove = id => {
|
|
1084
|
+
delete rpcs[id];
|
|
1466
1085
|
};
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
if (!fn) {
|
|
1472
|
-
console.warn(`callback ${id} may already be disposed`);
|
|
1473
|
-
return;
|
|
1474
|
-
}
|
|
1475
|
-
fn(response);
|
|
1476
|
-
delete callbacks[id];
|
|
1477
|
-
};
|
|
1478
|
-
const rpc = {
|
|
1086
|
+
|
|
1087
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1088
|
+
const create$2 = rpcId => {
|
|
1089
|
+
return {
|
|
1479
1090
|
async dispose() {
|
|
1480
|
-
|
|
1091
|
+
const rpc = get$1(rpcId);
|
|
1092
|
+
await rpc.dispose();
|
|
1481
1093
|
},
|
|
1094
|
+
// @ts-ignore
|
|
1482
1095
|
invoke(method, ...params) {
|
|
1483
|
-
|
|
1096
|
+
const rpc = get$1(rpcId);
|
|
1097
|
+
// @ts-ignore
|
|
1098
|
+
return rpc.invoke(method, ...params);
|
|
1484
1099
|
},
|
|
1100
|
+
// @ts-ignore
|
|
1485
1101
|
invokeAndTransfer(method, ...params) {
|
|
1486
|
-
|
|
1102
|
+
const rpc = get$1(rpcId);
|
|
1103
|
+
// @ts-ignore
|
|
1104
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1487
1105
|
},
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1106
|
+
registerMockRpc(commandMap) {
|
|
1107
|
+
const mockRpc = createMockRpc({
|
|
1108
|
+
commandMap
|
|
1109
|
+
});
|
|
1110
|
+
set$4(rpcId, mockRpc);
|
|
1111
|
+
// @ts-ignore
|
|
1112
|
+
mockRpc[Symbol.dispose] = () => {
|
|
1113
|
+
remove(rpcId);
|
|
1114
|
+
};
|
|
1115
|
+
// @ts-ignore
|
|
1116
|
+
return mockRpc;
|
|
1117
|
+
},
|
|
1118
|
+
set(rpc) {
|
|
1119
|
+
set$4(rpcId, rpc);
|
|
1496
1120
|
}
|
|
1497
1121
|
};
|
|
1498
|
-
return rpc;
|
|
1499
|
-
};
|
|
1500
|
-
|
|
1501
|
-
const requiresSocket = () => {
|
|
1502
|
-
return false;
|
|
1503
|
-
};
|
|
1504
|
-
const preparePrettyError = error => {
|
|
1505
|
-
return error;
|
|
1506
|
-
};
|
|
1507
|
-
const logError = () => {
|
|
1508
|
-
// handled by renderer worker
|
|
1509
|
-
};
|
|
1510
|
-
const handleMessage = event => {
|
|
1511
|
-
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
1512
|
-
const actualExecute = event?.target?.execute || execute;
|
|
1513
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1514
|
-
};
|
|
1515
|
-
|
|
1516
|
-
const handleIpc = ipc => {
|
|
1517
|
-
if ('addEventListener' in ipc) {
|
|
1518
|
-
ipc.addEventListener('message', handleMessage);
|
|
1519
|
-
} else if ('on' in ipc) {
|
|
1520
|
-
// deprecated
|
|
1521
|
-
ipc.on('message', handleMessage);
|
|
1522
|
-
}
|
|
1523
|
-
};
|
|
1524
|
-
|
|
1525
|
-
const listen$1 = async (module, options) => {
|
|
1526
|
-
const rawIpc = await module.listen(options);
|
|
1527
|
-
if (module.signal) {
|
|
1528
|
-
module.signal(rawIpc);
|
|
1529
|
-
}
|
|
1530
|
-
const ipc = module.wrap(rawIpc);
|
|
1531
|
-
return ipc;
|
|
1532
1122
|
};
|
|
1533
1123
|
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1124
|
+
const Audio = 0;
|
|
1125
|
+
const Button$1 = 1;
|
|
1126
|
+
const Col = 2;
|
|
1127
|
+
const ColGroup = 3;
|
|
1128
|
+
const Div = 4;
|
|
1129
|
+
const H1 = 5;
|
|
1130
|
+
const Input = 6;
|
|
1131
|
+
const Kbd = 7;
|
|
1132
|
+
const Span = 8;
|
|
1133
|
+
const Table = 9;
|
|
1134
|
+
const TBody = 10;
|
|
1135
|
+
const Td = 11;
|
|
1136
|
+
const Text = 12;
|
|
1137
|
+
const Th = 13;
|
|
1138
|
+
const THead = 14;
|
|
1139
|
+
const Tr = 15;
|
|
1140
|
+
const I = 16;
|
|
1141
|
+
const Img = 17;
|
|
1142
|
+
const Root = 0;
|
|
1143
|
+
const Ins = 20;
|
|
1144
|
+
const Del = 21;
|
|
1145
|
+
const H2 = 22;
|
|
1146
|
+
const H3 = 23;
|
|
1147
|
+
const H4 = 24;
|
|
1148
|
+
const H5 = 25;
|
|
1149
|
+
const H6 = 26;
|
|
1150
|
+
const Article = 27;
|
|
1151
|
+
const Aside = 28;
|
|
1152
|
+
const Footer = 29;
|
|
1153
|
+
const Header = 30;
|
|
1154
|
+
const Nav = 40;
|
|
1155
|
+
const Section = 41;
|
|
1156
|
+
const Search = 42;
|
|
1157
|
+
const Dd = 43;
|
|
1158
|
+
const Dl = 44;
|
|
1159
|
+
const Figcaption = 45;
|
|
1160
|
+
const Figure = 46;
|
|
1161
|
+
const Hr = 47;
|
|
1162
|
+
const Li = 48;
|
|
1163
|
+
const Ol = 49;
|
|
1164
|
+
const P = 50;
|
|
1165
|
+
const Pre = 51;
|
|
1166
|
+
const A = 53;
|
|
1167
|
+
const Abbr = 54;
|
|
1168
|
+
const Br = 55;
|
|
1169
|
+
const Cite = 56;
|
|
1170
|
+
const Data = 57;
|
|
1171
|
+
const Time = 58;
|
|
1172
|
+
const Tfoot = 59;
|
|
1173
|
+
const Ul = 60;
|
|
1174
|
+
const Video = 61;
|
|
1175
|
+
const TextArea = 62;
|
|
1176
|
+
const Select = 63;
|
|
1177
|
+
const Option = 64;
|
|
1178
|
+
const Code = 65;
|
|
1179
|
+
const Label = 66;
|
|
1180
|
+
const Dt = 67;
|
|
1181
|
+
const Iframe = 68;
|
|
1182
|
+
const Main = 69;
|
|
1183
|
+
const Strong = 70;
|
|
1184
|
+
const Em = 71;
|
|
1185
|
+
const Style = 72;
|
|
1186
|
+
const Html = 73;
|
|
1187
|
+
const Head = 74;
|
|
1188
|
+
const Title = 75;
|
|
1189
|
+
const Meta = 76;
|
|
1190
|
+
const Canvas = 77;
|
|
1191
|
+
const Form = 78;
|
|
1192
|
+
const BlockQuote = 79;
|
|
1193
|
+
const Quote = 80;
|
|
1194
|
+
const Circle = 81;
|
|
1195
|
+
const Defs = 82;
|
|
1196
|
+
const Ellipse = 83;
|
|
1197
|
+
const G = 84;
|
|
1198
|
+
const Line = 85;
|
|
1199
|
+
const Path = 86;
|
|
1200
|
+
const Polygon = 87;
|
|
1201
|
+
const Polyline = 88;
|
|
1202
|
+
const Rect = 89;
|
|
1203
|
+
const Svg = 90;
|
|
1204
|
+
const Use = 91;
|
|
1205
|
+
const Reference = 100;
|
|
1206
|
+
|
|
1207
|
+
const VirtualDomElements = {
|
|
1208
|
+
__proto__: null,
|
|
1209
|
+
A,
|
|
1210
|
+
Abbr,
|
|
1211
|
+
Article,
|
|
1212
|
+
Aside,
|
|
1213
|
+
Audio,
|
|
1214
|
+
BlockQuote,
|
|
1215
|
+
Br,
|
|
1216
|
+
Button: Button$1,
|
|
1217
|
+
Canvas,
|
|
1218
|
+
Circle,
|
|
1219
|
+
Cite,
|
|
1220
|
+
Code,
|
|
1221
|
+
Col,
|
|
1222
|
+
ColGroup,
|
|
1223
|
+
Data,
|
|
1224
|
+
Dd,
|
|
1225
|
+
Defs,
|
|
1226
|
+
Del,
|
|
1227
|
+
Div,
|
|
1228
|
+
Dl,
|
|
1229
|
+
Dt,
|
|
1230
|
+
Ellipse,
|
|
1231
|
+
Em,
|
|
1232
|
+
Figcaption,
|
|
1233
|
+
Figure,
|
|
1234
|
+
Footer,
|
|
1235
|
+
Form,
|
|
1236
|
+
G,
|
|
1237
|
+
H1,
|
|
1238
|
+
H2,
|
|
1239
|
+
H3,
|
|
1240
|
+
H4,
|
|
1241
|
+
H5,
|
|
1242
|
+
H6,
|
|
1243
|
+
Head,
|
|
1244
|
+
Header,
|
|
1245
|
+
Hr,
|
|
1246
|
+
Html,
|
|
1247
|
+
I,
|
|
1248
|
+
Iframe,
|
|
1249
|
+
Img,
|
|
1250
|
+
Input,
|
|
1251
|
+
Ins,
|
|
1252
|
+
Kbd,
|
|
1253
|
+
Label,
|
|
1254
|
+
Li,
|
|
1255
|
+
Line,
|
|
1256
|
+
Main,
|
|
1257
|
+
Meta,
|
|
1258
|
+
Nav,
|
|
1259
|
+
Ol,
|
|
1260
|
+
Option,
|
|
1261
|
+
P,
|
|
1262
|
+
Path,
|
|
1263
|
+
Polygon,
|
|
1264
|
+
Polyline,
|
|
1265
|
+
Pre,
|
|
1266
|
+
Quote,
|
|
1267
|
+
Rect,
|
|
1268
|
+
Reference,
|
|
1269
|
+
Root,
|
|
1270
|
+
Search,
|
|
1271
|
+
Section,
|
|
1272
|
+
Select,
|
|
1273
|
+
Span,
|
|
1274
|
+
Strong,
|
|
1275
|
+
Style,
|
|
1276
|
+
Svg,
|
|
1277
|
+
TBody,
|
|
1278
|
+
THead,
|
|
1279
|
+
Table,
|
|
1280
|
+
Td,
|
|
1281
|
+
Text,
|
|
1282
|
+
TextArea,
|
|
1283
|
+
Tfoot,
|
|
1284
|
+
Th,
|
|
1285
|
+
Time,
|
|
1286
|
+
Title,
|
|
1287
|
+
Tr,
|
|
1288
|
+
Ul,
|
|
1289
|
+
Use,
|
|
1290
|
+
Video
|
|
1550
1291
|
};
|
|
1551
1292
|
|
|
1552
|
-
const
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1293
|
+
const TargetName = 'event.target.name';
|
|
1294
|
+
|
|
1295
|
+
const Tab = 2;
|
|
1296
|
+
const Escape = 8;
|
|
1297
|
+
|
|
1298
|
+
const Shift = 1 << 10 >>> 0;
|
|
1299
|
+
|
|
1300
|
+
const DialogWorker = 7014;
|
|
1301
|
+
const FileSystemWorker = 209;
|
|
1302
|
+
const RendererWorker$1 = 1;
|
|
1303
|
+
|
|
1304
|
+
const {
|
|
1305
|
+
invoke: invoke$2,
|
|
1306
|
+
set: set$3
|
|
1307
|
+
} = create$2(DialogWorker);
|
|
1308
|
+
|
|
1309
|
+
const {
|
|
1310
|
+
invoke: invoke$1,
|
|
1311
|
+
set: set$2
|
|
1312
|
+
} = create$2(FileSystemWorker);
|
|
1313
|
+
const readFile = async uri => {
|
|
1314
|
+
return invoke$1('FileSystem.readFile', uri);
|
|
1567
1315
|
};
|
|
1568
1316
|
|
|
1569
|
-
const
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1317
|
+
const {
|
|
1318
|
+
invoke,
|
|
1319
|
+
invokeAndTransfer,
|
|
1320
|
+
set: set$1
|
|
1321
|
+
} = create$2(RendererWorker$1);
|
|
1322
|
+
const getElectronVersion$1 = async () => {
|
|
1323
|
+
return invoke('Process.getElectronVersion');
|
|
1324
|
+
};
|
|
1325
|
+
const getNodeVersion$1 = async () => {
|
|
1326
|
+
return invoke('Process.getNodeVersion');
|
|
1327
|
+
};
|
|
1328
|
+
const getChromeVersion$1 = async () => {
|
|
1329
|
+
return invoke('Process.getChromeVersion');
|
|
1330
|
+
};
|
|
1331
|
+
const getV8Version$1 = async () => {
|
|
1332
|
+
return invoke('Process.getV8Version');
|
|
1333
|
+
};
|
|
1334
|
+
const sendMessagePortToDialogWorker = async port => {
|
|
1335
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1336
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
|
|
1337
|
+
};
|
|
1338
|
+
const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
|
|
1339
|
+
const command = 'FileSystem.handleMessagePort';
|
|
1340
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1341
|
+
};
|
|
1342
|
+
const setFocus = key => {
|
|
1343
|
+
return invoke('Focus.setFocus', key);
|
|
1344
|
+
};
|
|
1345
|
+
const closeWidget$1 = async widgetId => {
|
|
1346
|
+
return invoke('Viewlet.closeWidget', widgetId);
|
|
1347
|
+
};
|
|
1348
|
+
const writeClipBoardText = async text => {
|
|
1349
|
+
await invoke('ClipBoard.writeText', /* text */text);
|
|
1350
|
+
};
|
|
1351
|
+
const openWidget = async name => {
|
|
1352
|
+
await invoke('Viewlet.openWidget', name);
|
|
1353
|
+
};
|
|
1354
|
+
const getWindowId$1 = async () => {
|
|
1355
|
+
return invoke('GetWindowId.getWindowId');
|
|
1356
|
+
};
|
|
1357
|
+
|
|
1358
|
+
const RendererWorker = {
|
|
1359
|
+
__proto__: null,
|
|
1360
|
+
closeWidget: closeWidget$1,
|
|
1361
|
+
getChromeVersion: getChromeVersion$1,
|
|
1362
|
+
getElectronVersion: getElectronVersion$1,
|
|
1363
|
+
getNodeVersion: getNodeVersion$1,
|
|
1364
|
+
getV8Version: getV8Version$1,
|
|
1365
|
+
getWindowId: getWindowId$1,
|
|
1366
|
+
invoke,
|
|
1367
|
+
invokeAndTransfer,
|
|
1368
|
+
openWidget,
|
|
1369
|
+
sendMessagePortToDialogWorker,
|
|
1370
|
+
sendMessagePortToFileSystemWorker,
|
|
1371
|
+
set: set$1,
|
|
1372
|
+
setFocus,
|
|
1373
|
+
writeClipBoardText
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1376
|
+
const toCommandId = key => {
|
|
1377
|
+
const dotIndex = key.indexOf('.');
|
|
1378
|
+
return key.slice(dotIndex + 1);
|
|
1379
|
+
};
|
|
1380
|
+
const create$1 = () => {
|
|
1381
|
+
const commandQueues = new Map();
|
|
1382
|
+
const generations = Object.create(null);
|
|
1383
|
+
const states = Object.create(null);
|
|
1384
|
+
const commandMapRef = {};
|
|
1385
|
+
const getGeneration = uid => generations[uid] || 0;
|
|
1386
|
+
const isCurrentGeneration = (uid, generation) => {
|
|
1387
|
+
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
1388
|
+
};
|
|
1389
|
+
const updateState = (uid, generation, fallbackState, updater) => {
|
|
1390
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1391
|
+
return Promise.resolve(fallbackState);
|
|
1392
|
+
}
|
|
1393
|
+
const current = states[uid];
|
|
1394
|
+
const updatedState = updater(current.newState);
|
|
1395
|
+
if (updatedState !== current.newState) {
|
|
1396
|
+
states[uid] = {
|
|
1397
|
+
newState: updatedState,
|
|
1398
|
+
oldState: current.oldState,
|
|
1399
|
+
scheduledState: updatedState
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
return Promise.resolve(updatedState);
|
|
1403
|
+
};
|
|
1404
|
+
const createAsyncCommandContext = (uid, generation) => {
|
|
1405
|
+
let latestState = states[uid].newState;
|
|
1406
|
+
return {
|
|
1407
|
+
getState: () => {
|
|
1408
|
+
if (isCurrentGeneration(uid, generation)) {
|
|
1409
|
+
latestState = states[uid].newState;
|
|
1410
|
+
}
|
|
1411
|
+
return latestState;
|
|
1412
|
+
},
|
|
1413
|
+
updateState: async updater => {
|
|
1414
|
+
latestState = await updateState(uid, generation, latestState, updater);
|
|
1415
|
+
return latestState;
|
|
1416
|
+
}
|
|
1417
|
+
};
|
|
1418
|
+
};
|
|
1419
|
+
const enqueueCommand = async (uid, command) => {
|
|
1420
|
+
const previous = commandQueues.get(uid) || Promise.resolve();
|
|
1421
|
+
const run = async () => {
|
|
1422
|
+
try {
|
|
1423
|
+
await previous;
|
|
1424
|
+
} catch {
|
|
1425
|
+
// The previous caller receives its error; later commands must still run.
|
|
1426
|
+
}
|
|
1427
|
+
await command();
|
|
1428
|
+
};
|
|
1429
|
+
const current = run();
|
|
1430
|
+
commandQueues.set(uid, current);
|
|
1431
|
+
try {
|
|
1432
|
+
await current;
|
|
1433
|
+
} finally {
|
|
1434
|
+
if (commandQueues.get(uid) === current) {
|
|
1435
|
+
commandQueues.delete(uid);
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
return {
|
|
1440
|
+
clear() {
|
|
1441
|
+
commandQueues.clear();
|
|
1442
|
+
for (const key of Object.keys(states)) {
|
|
1443
|
+
delete states[key];
|
|
1444
|
+
}
|
|
1445
|
+
},
|
|
1446
|
+
diff(uid, modules, numbers) {
|
|
1447
|
+
const {
|
|
1448
|
+
oldState,
|
|
1449
|
+
scheduledState
|
|
1450
|
+
} = states[uid];
|
|
1451
|
+
const diffResult = [];
|
|
1452
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1453
|
+
const fn = modules[i];
|
|
1454
|
+
if (!fn(oldState, scheduledState)) {
|
|
1455
|
+
diffResult.push(numbers[i]);
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
return diffResult;
|
|
1459
|
+
},
|
|
1460
|
+
dispose(uid) {
|
|
1461
|
+
commandQueues.delete(uid);
|
|
1462
|
+
delete states[uid];
|
|
1463
|
+
},
|
|
1464
|
+
get(uid) {
|
|
1465
|
+
return states[uid];
|
|
1466
|
+
},
|
|
1467
|
+
getCommandIds() {
|
|
1468
|
+
const keys = Object.keys(commandMapRef);
|
|
1469
|
+
const ids = keys.map(toCommandId);
|
|
1470
|
+
return ids;
|
|
1471
|
+
},
|
|
1472
|
+
getKeys() {
|
|
1473
|
+
return Object.keys(states).map(Number);
|
|
1474
|
+
},
|
|
1475
|
+
registerCommands(commandMap) {
|
|
1476
|
+
Object.assign(commandMapRef, commandMap);
|
|
1477
|
+
},
|
|
1478
|
+
set(uid, oldState, newState, scheduledState) {
|
|
1479
|
+
const current = states[uid];
|
|
1480
|
+
if (!current || oldState === newState && newState !== current.newState) {
|
|
1481
|
+
generations[uid] = getGeneration(uid) + 1;
|
|
1482
|
+
}
|
|
1483
|
+
states[uid] = {
|
|
1484
|
+
newState,
|
|
1485
|
+
oldState,
|
|
1486
|
+
scheduledState: scheduledState ?? newState
|
|
1487
|
+
};
|
|
1488
|
+
},
|
|
1489
|
+
wrapAsyncCommand(fn) {
|
|
1490
|
+
const wrapped = async (uid, ...args) => {
|
|
1491
|
+
const generation = getGeneration(uid);
|
|
1492
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1493
|
+
await fn(context, ...args);
|
|
1494
|
+
};
|
|
1495
|
+
return wrapped;
|
|
1496
|
+
},
|
|
1497
|
+
wrapCommand(fn) {
|
|
1498
|
+
const wrapped = async (uid, ...args) => {
|
|
1499
|
+
const generation = getGeneration(uid);
|
|
1500
|
+
const {
|
|
1501
|
+
newState,
|
|
1502
|
+
oldState
|
|
1503
|
+
} = states[uid];
|
|
1504
|
+
const newerState = await fn(newState, ...args);
|
|
1505
|
+
if (oldState === newerState || newState === newerState) {
|
|
1506
|
+
return;
|
|
1507
|
+
}
|
|
1508
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1509
|
+
return;
|
|
1510
|
+
}
|
|
1511
|
+
const latestOld = states[uid];
|
|
1512
|
+
const latestNew = {
|
|
1513
|
+
...latestOld.newState,
|
|
1514
|
+
...newerState
|
|
1515
|
+
};
|
|
1516
|
+
states[uid] = {
|
|
1517
|
+
newState: latestNew,
|
|
1518
|
+
oldState: latestOld.oldState,
|
|
1519
|
+
scheduledState: latestNew
|
|
1520
|
+
};
|
|
1521
|
+
};
|
|
1522
|
+
return wrapped;
|
|
1523
|
+
},
|
|
1524
|
+
wrapGetter(fn) {
|
|
1525
|
+
const wrapped = (uid, ...args) => {
|
|
1526
|
+
const {
|
|
1527
|
+
newState
|
|
1528
|
+
} = states[uid];
|
|
1529
|
+
return fn(newState, ...args);
|
|
1530
|
+
};
|
|
1531
|
+
return wrapped;
|
|
1532
|
+
},
|
|
1533
|
+
wrapLoadContent(fn) {
|
|
1534
|
+
const wrapped = async (uid, ...args) => {
|
|
1535
|
+
const generation = getGeneration(uid);
|
|
1536
|
+
const {
|
|
1537
|
+
newState,
|
|
1538
|
+
oldState
|
|
1539
|
+
} = states[uid];
|
|
1540
|
+
const result = await fn(newState, ...args);
|
|
1541
|
+
const {
|
|
1542
|
+
error,
|
|
1543
|
+
state
|
|
1544
|
+
} = result;
|
|
1545
|
+
if (oldState === state || newState === state) {
|
|
1546
|
+
return {
|
|
1547
|
+
error
|
|
1548
|
+
};
|
|
1549
|
+
}
|
|
1550
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1551
|
+
return {
|
|
1552
|
+
error
|
|
1553
|
+
};
|
|
1554
|
+
}
|
|
1555
|
+
const latestOld = states[uid];
|
|
1556
|
+
const latestNew = {
|
|
1557
|
+
...latestOld.newState,
|
|
1558
|
+
...state
|
|
1559
|
+
};
|
|
1560
|
+
states[uid] = {
|
|
1561
|
+
newState: latestNew,
|
|
1562
|
+
oldState: latestOld.oldState,
|
|
1563
|
+
scheduledState: latestNew
|
|
1564
|
+
};
|
|
1565
|
+
return {
|
|
1566
|
+
error
|
|
1567
|
+
};
|
|
1568
|
+
};
|
|
1569
|
+
return wrapped;
|
|
1570
|
+
},
|
|
1571
|
+
wrapSerialAsyncCommand(fn) {
|
|
1572
|
+
const wrapped = async (uid, ...args) => {
|
|
1573
|
+
await enqueueCommand(uid, async () => {
|
|
1574
|
+
if (!states[uid]) {
|
|
1575
|
+
return;
|
|
1576
|
+
}
|
|
1577
|
+
const generation = getGeneration(uid);
|
|
1578
|
+
const context = createAsyncCommandContext(uid, generation);
|
|
1579
|
+
await fn(context, ...args);
|
|
1580
|
+
});
|
|
1581
|
+
};
|
|
1582
|
+
return wrapped;
|
|
1583
|
+
},
|
|
1584
|
+
wrapSerialCommand(fn) {
|
|
1585
|
+
const wrapped = async (uid, ...args) => {
|
|
1586
|
+
await enqueueCommand(uid, async () => {
|
|
1587
|
+
if (!states[uid]) {
|
|
1588
|
+
return;
|
|
1589
|
+
}
|
|
1590
|
+
const generation = getGeneration(uid);
|
|
1591
|
+
const {
|
|
1592
|
+
newState,
|
|
1593
|
+
oldState
|
|
1594
|
+
} = states[uid];
|
|
1595
|
+
const newerState = await fn(newState, ...args);
|
|
1596
|
+
if (oldState === newerState || newState === newerState) {
|
|
1597
|
+
return;
|
|
1598
|
+
}
|
|
1599
|
+
if (!isCurrentGeneration(uid, generation)) {
|
|
1600
|
+
return;
|
|
1601
|
+
}
|
|
1602
|
+
const latestOld = states[uid];
|
|
1603
|
+
const latestNew = {
|
|
1604
|
+
...latestOld.newState,
|
|
1605
|
+
...newerState
|
|
1606
|
+
};
|
|
1607
|
+
states[uid] = {
|
|
1608
|
+
newState: latestNew,
|
|
1609
|
+
oldState: latestOld.oldState,
|
|
1610
|
+
scheduledState: latestNew
|
|
1611
|
+
};
|
|
1612
|
+
});
|
|
1613
|
+
};
|
|
1614
|
+
return wrapped;
|
|
1574
1615
|
}
|
|
1575
|
-
return rpcPromise;
|
|
1576
1616
|
};
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1617
|
+
};
|
|
1618
|
+
|
|
1619
|
+
const {
|
|
1620
|
+
dispose: dispose$1,
|
|
1621
|
+
get,
|
|
1622
|
+
getCommandIds,
|
|
1623
|
+
registerCommands,
|
|
1624
|
+
set,
|
|
1625
|
+
wrapAsyncCommand,
|
|
1626
|
+
wrapCommand
|
|
1627
|
+
} = create$1();
|
|
1628
|
+
|
|
1629
|
+
const create = uid => {
|
|
1630
|
+
const state = {
|
|
1631
|
+
focusId: 0,
|
|
1632
|
+
lines: [],
|
|
1633
|
+
productName: '',
|
|
1634
|
+
uid
|
|
1594
1635
|
};
|
|
1636
|
+
set(uid, state, state);
|
|
1595
1637
|
};
|
|
1596
1638
|
|
|
1597
|
-
const
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
commandMap,
|
|
1605
|
-
isMessagePortOpen,
|
|
1606
|
-
send
|
|
1607
|
-
});
|
|
1608
|
-
});
|
|
1639
|
+
const RenderFocus = 2;
|
|
1640
|
+
const RenderFocusContext = 4;
|
|
1641
|
+
const RenderAbout = 3;
|
|
1642
|
+
|
|
1643
|
+
const diffType$2 = RenderAbout;
|
|
1644
|
+
const isEqual$2 = (oldState, newState) => {
|
|
1645
|
+
return oldState.productName === newState.productName && JSON.stringify(oldState.lines) === JSON.stringify(newState.lines);
|
|
1609
1646
|
};
|
|
1610
1647
|
|
|
1611
|
-
const
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
// TODO create a commandMap per rpc instance
|
|
1615
|
-
register(commandMap);
|
|
1616
|
-
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1617
|
-
handleIpc(ipc);
|
|
1618
|
-
const rpc = createRpc(ipc);
|
|
1619
|
-
return rpc;
|
|
1648
|
+
const diffType$1 = RenderFocus;
|
|
1649
|
+
const isEqual$1 = (oldState, newState) => {
|
|
1650
|
+
return oldState.focusId === newState.focusId;
|
|
1620
1651
|
};
|
|
1621
1652
|
|
|
1622
|
-
const
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1653
|
+
const diffType = RenderFocusContext;
|
|
1654
|
+
const isEqual = (oldState, newState) => {
|
|
1655
|
+
return oldState.focusId === newState.focusId;
|
|
1656
|
+
};
|
|
1657
|
+
|
|
1658
|
+
const modules = [isEqual$2, isEqual$1, isEqual];
|
|
1659
|
+
const numbers = [diffType$2, diffType$1, diffType];
|
|
1660
|
+
|
|
1661
|
+
const diff = (oldState, newState) => {
|
|
1662
|
+
const diffResult = [];
|
|
1663
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1664
|
+
const fn = modules[i];
|
|
1665
|
+
if (!fn(oldState, newState)) {
|
|
1666
|
+
diffResult.push(numbers[i]);
|
|
1631
1667
|
}
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
const mockRpc = {
|
|
1635
|
-
invocations,
|
|
1636
|
-
invoke,
|
|
1637
|
-
invokeAndTransfer: invoke
|
|
1638
|
-
};
|
|
1639
|
-
return mockRpc;
|
|
1668
|
+
}
|
|
1669
|
+
return diffResult;
|
|
1640
1670
|
};
|
|
1641
1671
|
|
|
1642
|
-
const
|
|
1643
|
-
const
|
|
1644
|
-
|
|
1672
|
+
const diff2 = uid => {
|
|
1673
|
+
const {
|
|
1674
|
+
oldState,
|
|
1675
|
+
scheduledState
|
|
1676
|
+
} = get(uid);
|
|
1677
|
+
const diffResult = diff(oldState, scheduledState);
|
|
1678
|
+
return diffResult;
|
|
1645
1679
|
};
|
|
1646
|
-
|
|
1647
|
-
|
|
1680
|
+
|
|
1681
|
+
const dispose = uid => {
|
|
1682
|
+
dispose$1(uid);
|
|
1648
1683
|
};
|
|
1649
|
-
|
|
1650
|
-
|
|
1684
|
+
|
|
1685
|
+
const None = 0;
|
|
1686
|
+
const Ok$2 = 1;
|
|
1687
|
+
const Copy$2 = 2;
|
|
1688
|
+
|
|
1689
|
+
const getNextFocus = focusId => {
|
|
1690
|
+
switch (focusId) {
|
|
1691
|
+
case Copy$2:
|
|
1692
|
+
return Ok$2;
|
|
1693
|
+
case Ok$2:
|
|
1694
|
+
return Copy$2;
|
|
1695
|
+
default:
|
|
1696
|
+
return None;
|
|
1697
|
+
}
|
|
1651
1698
|
};
|
|
1652
1699
|
|
|
1653
|
-
|
|
1654
|
-
const
|
|
1700
|
+
const focusNext = state => {
|
|
1701
|
+
const {
|
|
1702
|
+
focusId
|
|
1703
|
+
} = state;
|
|
1655
1704
|
return {
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
await rpc.dispose();
|
|
1659
|
-
},
|
|
1660
|
-
// @ts-ignore
|
|
1661
|
-
invoke(method, ...params) {
|
|
1662
|
-
const rpc = get(rpcId);
|
|
1663
|
-
// @ts-ignore
|
|
1664
|
-
return rpc.invoke(method, ...params);
|
|
1665
|
-
},
|
|
1666
|
-
// @ts-ignore
|
|
1667
|
-
invokeAndTransfer(method, ...params) {
|
|
1668
|
-
const rpc = get(rpcId);
|
|
1669
|
-
// @ts-ignore
|
|
1670
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
1671
|
-
},
|
|
1672
|
-
registerMockRpc(commandMap) {
|
|
1673
|
-
const mockRpc = createMockRpc({
|
|
1674
|
-
commandMap
|
|
1675
|
-
});
|
|
1676
|
-
set$2(rpcId, mockRpc);
|
|
1677
|
-
// @ts-ignore
|
|
1678
|
-
mockRpc[Symbol.dispose] = () => {
|
|
1679
|
-
remove(rpcId);
|
|
1680
|
-
};
|
|
1681
|
-
// @ts-ignore
|
|
1682
|
-
return mockRpc;
|
|
1683
|
-
},
|
|
1684
|
-
set(rpc) {
|
|
1685
|
-
set$2(rpcId, rpc);
|
|
1686
|
-
}
|
|
1705
|
+
...state,
|
|
1706
|
+
focusId: getNextFocus(focusId)
|
|
1687
1707
|
};
|
|
1688
1708
|
};
|
|
1689
1709
|
|
|
1690
|
-
const {
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1710
|
+
const getPreviousFocus = focusId => {
|
|
1711
|
+
switch (focusId) {
|
|
1712
|
+
case Copy$2:
|
|
1713
|
+
return Ok$2;
|
|
1714
|
+
case Ok$2:
|
|
1715
|
+
return Copy$2;
|
|
1716
|
+
default:
|
|
1717
|
+
return None;
|
|
1718
|
+
}
|
|
1696
1719
|
};
|
|
1697
1720
|
|
|
1698
|
-
const {
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
};
|
|
1706
|
-
const getNodeVersion$1 = async () => {
|
|
1707
|
-
return invoke('Process.getNodeVersion');
|
|
1708
|
-
};
|
|
1709
|
-
const getChromeVersion$1 = async () => {
|
|
1710
|
-
return invoke('Process.getChromeVersion');
|
|
1711
|
-
};
|
|
1712
|
-
const getV8Version$1 = async () => {
|
|
1713
|
-
return invoke('Process.getV8Version');
|
|
1714
|
-
};
|
|
1715
|
-
const sendMessagePortToFileSystemWorker = async (port, rpcId) => {
|
|
1716
|
-
const command = 'FileSystem.handleMessagePort';
|
|
1717
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, command, rpcId);
|
|
1718
|
-
};
|
|
1719
|
-
const setFocus = key => {
|
|
1720
|
-
return invoke('Focus.setFocus', key);
|
|
1721
|
-
};
|
|
1722
|
-
const closeWidget$1 = async widgetId => {
|
|
1723
|
-
return invoke('Viewlet.closeWidget', widgetId);
|
|
1724
|
-
};
|
|
1725
|
-
const writeClipBoardText = async text => {
|
|
1726
|
-
await invoke('ClipBoard.writeText', /* text */text);
|
|
1727
|
-
};
|
|
1728
|
-
const showMessageBox$1 = async options => {
|
|
1729
|
-
return invoke('ElectronDialog.showMessageBox', options);
|
|
1721
|
+
const focusPrevious = state => {
|
|
1722
|
+
const {
|
|
1723
|
+
focusId
|
|
1724
|
+
} = state;
|
|
1725
|
+
return {
|
|
1726
|
+
...state,
|
|
1727
|
+
focusId: getPreviousFocus(focusId)
|
|
1728
|
+
};
|
|
1730
1729
|
};
|
|
1731
|
-
|
|
1732
|
-
|
|
1730
|
+
|
|
1731
|
+
const mergeClassNames = (...classNames) => {
|
|
1732
|
+
return classNames.filter(Boolean).join(' ');
|
|
1733
1733
|
};
|
|
1734
|
-
|
|
1735
|
-
|
|
1734
|
+
|
|
1735
|
+
const text = data => {
|
|
1736
|
+
return {
|
|
1737
|
+
childCount: 0,
|
|
1738
|
+
text: data,
|
|
1739
|
+
type: Text
|
|
1740
|
+
};
|
|
1736
1741
|
};
|
|
1737
1742
|
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1743
|
+
new Set(Object.values(VirtualDomElements));
|
|
1744
|
+
|
|
1745
|
+
const FocusAbout = 4;
|
|
1746
|
+
|
|
1747
|
+
const getKeyBindings = () => {
|
|
1748
|
+
return [{
|
|
1749
|
+
command: 'About.handleClickClose',
|
|
1750
|
+
key: Escape,
|
|
1751
|
+
when: FocusAbout
|
|
1752
|
+
}, {
|
|
1753
|
+
command: 'About.focusNext',
|
|
1754
|
+
key: Tab,
|
|
1755
|
+
when: FocusAbout
|
|
1756
|
+
}, {
|
|
1757
|
+
command: 'About.focusPrevious',
|
|
1758
|
+
key: Tab | Shift,
|
|
1759
|
+
when: FocusAbout
|
|
1760
|
+
}];
|
|
1754
1761
|
};
|
|
1755
1762
|
|
|
1756
1763
|
const {
|
|
@@ -2399,8 +2406,8 @@ const doRender = (uid, diffResult) => {
|
|
|
2399
2406
|
const {
|
|
2400
2407
|
oldState,
|
|
2401
2408
|
scheduledState
|
|
2402
|
-
} = get
|
|
2403
|
-
set
|
|
2409
|
+
} = get(uid);
|
|
2410
|
+
set(uid, scheduledState, scheduledState);
|
|
2404
2411
|
const commands = applyRender(oldState, scheduledState, diffResult);
|
|
2405
2412
|
return commands;
|
|
2406
2413
|
};
|
|
@@ -2438,7 +2445,7 @@ const showMessageBox = async options => {
|
|
|
2438
2445
|
...options,
|
|
2439
2446
|
windowId
|
|
2440
2447
|
};
|
|
2441
|
-
return
|
|
2448
|
+
return invoke$2('ElectronDialog.showMessageBox', finalOptions);
|
|
2442
2449
|
};
|
|
2443
2450
|
|
|
2444
2451
|
const Info = 'info';
|
|
@@ -2501,7 +2508,7 @@ const showAbout = async platform => {
|
|
|
2501
2508
|
};
|
|
2502
2509
|
|
|
2503
2510
|
const commandMap = {
|
|
2504
|
-
'About.create': create
|
|
2511
|
+
'About.create': create,
|
|
2505
2512
|
'About.diff2': diff2,
|
|
2506
2513
|
'About.dispose': dispose,
|
|
2507
2514
|
'About.focusNext': wrapCommand(focusNext),
|
|
@@ -2524,24 +2531,29 @@ const send = async port => {
|
|
|
2524
2531
|
await sendMessagePortToFileSystemWorker(port, 0);
|
|
2525
2532
|
};
|
|
2526
2533
|
const initializeFileSystemWorker = async () => {
|
|
2527
|
-
const rpc = await create$
|
|
2534
|
+
const rpc = await create$4({
|
|
2528
2535
|
commandMap: {},
|
|
2529
2536
|
send
|
|
2530
2537
|
});
|
|
2531
|
-
set$
|
|
2538
|
+
set$2(rpc);
|
|
2532
2539
|
};
|
|
2533
2540
|
|
|
2534
2541
|
const initializeRendererWorker = async () => {
|
|
2535
|
-
const rpc = await create$
|
|
2542
|
+
const rpc = await create$3({
|
|
2536
2543
|
commandMap: commandMap
|
|
2537
2544
|
});
|
|
2538
|
-
set(rpc);
|
|
2545
|
+
set$1(rpc);
|
|
2539
2546
|
};
|
|
2540
2547
|
|
|
2541
2548
|
const listen = async () => {
|
|
2542
2549
|
registerCommands(commandMap);
|
|
2543
2550
|
await initializeRendererWorker();
|
|
2544
2551
|
await initializeFileSystemWorker();
|
|
2552
|
+
const dialogRpc = await create$4({
|
|
2553
|
+
commandMap: {},
|
|
2554
|
+
send: sendMessagePortToDialogWorker
|
|
2555
|
+
});
|
|
2556
|
+
set$3(dialogRpc);
|
|
2545
2557
|
};
|
|
2546
2558
|
|
|
2547
2559
|
const main = async () => {
|