@lvce-editor/renderer-process 14.0.2 → 14.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/rendererProcessMain.js +523 -504
- package/package.json +1 -1
|
@@ -230,6 +230,7 @@ const Select$1 = 'select';
|
|
|
230
230
|
const Option$1 = 'option';
|
|
231
231
|
const Code$1 = 'code';
|
|
232
232
|
const Label$1 = 'label';
|
|
233
|
+
const Dt$1 = 'dt';
|
|
233
234
|
const Audio$2 = 0;
|
|
234
235
|
const Button = 1;
|
|
235
236
|
const Col = 2;
|
|
@@ -284,6 +285,7 @@ const Select = 63;
|
|
|
284
285
|
const Option = 64;
|
|
285
286
|
const Code$2 = 65;
|
|
286
287
|
const Label = 66;
|
|
288
|
+
const Dt = 67;
|
|
287
289
|
const getElementTag = type => {
|
|
288
290
|
switch (type) {
|
|
289
291
|
case Audio$2:
|
|
@@ -392,6 +394,8 @@ const getElementTag = type => {
|
|
|
392
394
|
return Code$1;
|
|
393
395
|
case Label:
|
|
394
396
|
return Label$1;
|
|
397
|
+
case Dt:
|
|
398
|
+
return Dt$1;
|
|
395
399
|
default:
|
|
396
400
|
throw new Error(`element tag not found ${type}`);
|
|
397
401
|
}
|
|
@@ -1087,35 +1091,262 @@ const ReferencePort = 3;
|
|
|
1087
1091
|
const ModuleWorkerWithMessagePort = 4;
|
|
1088
1092
|
const Electron$1 = 5;
|
|
1089
1093
|
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1094
|
+
const Message$2 = 'message';
|
|
1095
|
+
const Error$3 = 'error';
|
|
1096
|
+
|
|
1097
|
+
const withResolvers = () => {
|
|
1098
|
+
/**
|
|
1099
|
+
* @type {any}
|
|
1100
|
+
*/
|
|
1101
|
+
let _resolve;
|
|
1102
|
+
/**
|
|
1103
|
+
* @type {any}
|
|
1104
|
+
*/
|
|
1105
|
+
let _reject;
|
|
1106
|
+
const promise = new Promise((resolve, reject) => {
|
|
1107
|
+
_resolve = resolve;
|
|
1108
|
+
_reject = reject;
|
|
1109
|
+
});
|
|
1110
|
+
return {
|
|
1111
|
+
resolve: _resolve,
|
|
1112
|
+
reject: _reject,
|
|
1113
|
+
promise
|
|
1114
|
+
};
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
const getFirstEvent$1 = (eventTarget, eventMap) => {
|
|
1118
|
+
const {
|
|
1119
|
+
resolve,
|
|
1120
|
+
promise
|
|
1121
|
+
} = withResolvers();
|
|
1122
|
+
const listenerMap = Object.create(null);
|
|
1123
|
+
const cleanup = value => {
|
|
1124
|
+
for (const event of Object.keys(eventMap)) {
|
|
1125
|
+
eventTarget.removeEventListener(event, listenerMap[event]);
|
|
1126
|
+
}
|
|
1127
|
+
resolve(value);
|
|
1128
|
+
};
|
|
1129
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
1130
|
+
const listener = event => {
|
|
1131
|
+
cleanup({
|
|
1132
|
+
type,
|
|
1133
|
+
event
|
|
1134
|
+
});
|
|
1135
|
+
};
|
|
1136
|
+
eventTarget.addEventListener(event, listener);
|
|
1137
|
+
listenerMap[event] = listener;
|
|
1104
1138
|
}
|
|
1139
|
+
return promise;
|
|
1105
1140
|
};
|
|
1106
1141
|
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1142
|
+
/**
|
|
1143
|
+
*
|
|
1144
|
+
* @param {Worker} worker
|
|
1145
|
+
* @returns
|
|
1146
|
+
*/
|
|
1147
|
+
const getFirstWorkerEvent$1 = worker => {
|
|
1148
|
+
return getFirstEvent$1(worker, {
|
|
1149
|
+
message: Message$2,
|
|
1150
|
+
error: Error$3
|
|
1151
|
+
});
|
|
1110
1152
|
};
|
|
1111
|
-
|
|
1112
|
-
|
|
1153
|
+
|
|
1154
|
+
const transferrables$1 = [];
|
|
1155
|
+
if (typeof MessagePort !== 'undefined') {
|
|
1156
|
+
transferrables$1.push(MessagePort);
|
|
1157
|
+
}
|
|
1158
|
+
if (typeof OffscreenCanvas !== 'undefined') {
|
|
1159
|
+
transferrables$1.push(OffscreenCanvas);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
const isTransferrable$1 = value => {
|
|
1163
|
+
for (const fn of transferrables$1) {
|
|
1164
|
+
if (value instanceof fn) {
|
|
1165
|
+
return true;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
return false;
|
|
1113
1169
|
};
|
|
1114
|
-
|
|
1115
|
-
|
|
1170
|
+
|
|
1171
|
+
const walkValue$1 = (value, transferrables) => {
|
|
1172
|
+
if (!value) {
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
if (isTransferrable$1(value)) {
|
|
1176
|
+
transferrables.push(value);
|
|
1177
|
+
}
|
|
1178
|
+
if (Array.isArray(value)) {
|
|
1179
|
+
for (const item of value) {
|
|
1180
|
+
walkValue$1(item, transferrables);
|
|
1181
|
+
}
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
if (typeof value === 'object') {
|
|
1185
|
+
for (const property of Object.values(value)) {
|
|
1186
|
+
walkValue$1(property, transferrables);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1116
1189
|
};
|
|
1117
|
-
|
|
1118
|
-
|
|
1190
|
+
|
|
1191
|
+
const getTransfer = value => {
|
|
1192
|
+
const transferrables = [];
|
|
1193
|
+
walkValue$1(value, transferrables);
|
|
1194
|
+
return transferrables;
|
|
1195
|
+
};
|
|
1196
|
+
|
|
1197
|
+
let IpcError$1 = class IpcError extends Error {
|
|
1198
|
+
constructor(message) {
|
|
1199
|
+
super(message);
|
|
1200
|
+
this.name = 'IpcError';
|
|
1201
|
+
}
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
const isErrorEvent$1 = event => {
|
|
1205
|
+
return event instanceof ErrorEvent;
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
const NewLine$3 = '\n';
|
|
1209
|
+
|
|
1210
|
+
const joinLines$2 = lines => {
|
|
1211
|
+
return lines.join(NewLine$3);
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
const splitLines$2 = lines => {
|
|
1215
|
+
string(lines);
|
|
1216
|
+
return lines.split(NewLine$3);
|
|
1217
|
+
};
|
|
1218
|
+
|
|
1219
|
+
let WorkerError$1 = class WorkerError extends Error {
|
|
1220
|
+
constructor(event) {
|
|
1221
|
+
super(event.message);
|
|
1222
|
+
const stackLines = splitLines$2(this.stack);
|
|
1223
|
+
const relevantLines = stackLines.slice(1);
|
|
1224
|
+
const relevant = joinLines$2(relevantLines);
|
|
1225
|
+
this.stack = `${event.message}
|
|
1226
|
+
at Module (${event.filename}:${event.lineno}:${event.colno})
|
|
1227
|
+
${relevant}`;
|
|
1228
|
+
}
|
|
1229
|
+
};
|
|
1230
|
+
|
|
1231
|
+
const Module$1 = 'module';
|
|
1232
|
+
|
|
1233
|
+
const getWorkerDisplayName$1 = name => {
|
|
1234
|
+
if (name && name.endsWith('Worker')) {
|
|
1235
|
+
return name;
|
|
1236
|
+
}
|
|
1237
|
+
return `${name} worker`;
|
|
1238
|
+
};
|
|
1239
|
+
const create$H = async ({
|
|
1240
|
+
url,
|
|
1241
|
+
name
|
|
1242
|
+
}) => {
|
|
1243
|
+
const worker = new Worker(url, {
|
|
1244
|
+
type: Module$1,
|
|
1245
|
+
name
|
|
1246
|
+
});
|
|
1247
|
+
// @ts-expect-error
|
|
1248
|
+
const {
|
|
1249
|
+
type,
|
|
1250
|
+
event
|
|
1251
|
+
} = await getFirstWorkerEvent$1(worker);
|
|
1252
|
+
switch (type) {
|
|
1253
|
+
case Message$2:
|
|
1254
|
+
if (event.data !== 'ready') {
|
|
1255
|
+
throw new IpcError$1('unexpected first message from worker');
|
|
1256
|
+
}
|
|
1257
|
+
break;
|
|
1258
|
+
case Error$3:
|
|
1259
|
+
if (isErrorEvent$1(event)) {
|
|
1260
|
+
throw new WorkerError$1(event);
|
|
1261
|
+
}
|
|
1262
|
+
const displayName = getWorkerDisplayName$1(name);
|
|
1263
|
+
throw new IpcError$1(`Failed to start ${displayName}`);
|
|
1264
|
+
}
|
|
1265
|
+
return worker;
|
|
1266
|
+
};
|
|
1267
|
+
const getData$1 = event => {
|
|
1268
|
+
// TODO why are some events not instance of message event?
|
|
1269
|
+
if (event instanceof MessageEvent) {
|
|
1270
|
+
return event.data;
|
|
1271
|
+
}
|
|
1272
|
+
return event;
|
|
1273
|
+
};
|
|
1274
|
+
const wrap = worker => {
|
|
1275
|
+
let handleMessage;
|
|
1276
|
+
return {
|
|
1277
|
+
get onmessage() {
|
|
1278
|
+
return handleMessage;
|
|
1279
|
+
},
|
|
1280
|
+
set onmessage(listener) {
|
|
1281
|
+
if (listener) {
|
|
1282
|
+
handleMessage = event => {
|
|
1283
|
+
const data = getData$1(event);
|
|
1284
|
+
listener({
|
|
1285
|
+
data,
|
|
1286
|
+
target: this
|
|
1287
|
+
});
|
|
1288
|
+
};
|
|
1289
|
+
} else {
|
|
1290
|
+
handleMessage = null;
|
|
1291
|
+
}
|
|
1292
|
+
worker.onmessage = handleMessage;
|
|
1293
|
+
},
|
|
1294
|
+
send(message) {
|
|
1295
|
+
worker.postMessage(message);
|
|
1296
|
+
},
|
|
1297
|
+
sendAndTransfer(message) {
|
|
1298
|
+
const transfer = getTransfer(message);
|
|
1299
|
+
worker.postMessage(message, transfer);
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
};
|
|
1303
|
+
|
|
1304
|
+
const IpcParentWithModuleWorker$2 = {
|
|
1305
|
+
__proto__: null,
|
|
1306
|
+
create: create$H,
|
|
1307
|
+
wrap
|
|
1308
|
+
};
|
|
1309
|
+
|
|
1310
|
+
const isMessagePort$1 = value => {
|
|
1311
|
+
return value instanceof MessagePort;
|
|
1312
|
+
};
|
|
1313
|
+
|
|
1314
|
+
const create$G = async ({
|
|
1315
|
+
url
|
|
1316
|
+
}) => {
|
|
1317
|
+
string(url);
|
|
1318
|
+
const portPromise = await new Promise(resolve => {
|
|
1319
|
+
globalThis.acceptPort = resolve;
|
|
1320
|
+
});
|
|
1321
|
+
await import(url);
|
|
1322
|
+
const port = await portPromise;
|
|
1323
|
+
delete globalThis.acceptPort;
|
|
1324
|
+
if (!port) {
|
|
1325
|
+
throw new IpcError$1('port must be defined');
|
|
1326
|
+
}
|
|
1327
|
+
if (!isMessagePort$1(port)) {
|
|
1328
|
+
throw new IpcError$1('port must be of type MessagePort');
|
|
1329
|
+
}
|
|
1330
|
+
return port;
|
|
1331
|
+
};
|
|
1332
|
+
|
|
1333
|
+
const IpcParentWithMessagePort$2 = {
|
|
1334
|
+
__proto__: null,
|
|
1335
|
+
create: create$G
|
|
1336
|
+
};
|
|
1337
|
+
|
|
1338
|
+
const create$F = async url => {
|
|
1339
|
+
const referencePort = await new Promise(resolve => {
|
|
1340
|
+
globalThis.acceptReferencePort = resolve;
|
|
1341
|
+
import(url);
|
|
1342
|
+
});
|
|
1343
|
+
delete globalThis.acceptReferencePort;
|
|
1344
|
+
return referencePort;
|
|
1345
|
+
};
|
|
1346
|
+
|
|
1347
|
+
const IpcParentWithReferencePort = {
|
|
1348
|
+
__proto__: null,
|
|
1349
|
+
create: create$F
|
|
1119
1350
|
};
|
|
1120
1351
|
|
|
1121
1352
|
const normalizeLine = line => {
|
|
@@ -1134,9 +1365,9 @@ const getCombinedMessage = (error, message) => {
|
|
|
1134
1365
|
}
|
|
1135
1366
|
return stringifiedError;
|
|
1136
1367
|
};
|
|
1137
|
-
const NewLine$
|
|
1368
|
+
const NewLine$2 = '\n';
|
|
1138
1369
|
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
1139
|
-
return string.indexOf(NewLine$
|
|
1370
|
+
return string.indexOf(NewLine$2, startIndex);
|
|
1140
1371
|
};
|
|
1141
1372
|
const mergeStacks$1 = (parent, child) => {
|
|
1142
1373
|
if (!child) {
|
|
@@ -1174,7 +1405,7 @@ let VError$1 = class VError extends Error {
|
|
|
1174
1405
|
}
|
|
1175
1406
|
};
|
|
1176
1407
|
|
|
1177
|
-
const isMessagePort
|
|
1408
|
+
const isMessagePort = value => {
|
|
1178
1409
|
return value && value instanceof MessagePort;
|
|
1179
1410
|
};
|
|
1180
1411
|
const isMessagePortMain = value => {
|
|
@@ -1189,16 +1420,16 @@ const isInstanceOf = (value, constructorName) => {
|
|
|
1189
1420
|
const isSocket = value => {
|
|
1190
1421
|
return isInstanceOf(value, 'Socket');
|
|
1191
1422
|
};
|
|
1192
|
-
const transferrables
|
|
1193
|
-
const isTransferrable
|
|
1194
|
-
for (const fn of transferrables
|
|
1423
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
1424
|
+
const isTransferrable = value => {
|
|
1425
|
+
for (const fn of transferrables) {
|
|
1195
1426
|
if (fn(value)) {
|
|
1196
1427
|
return true;
|
|
1197
1428
|
}
|
|
1198
1429
|
}
|
|
1199
1430
|
return false;
|
|
1200
1431
|
};
|
|
1201
|
-
const walkValue
|
|
1432
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
1202
1433
|
if (!value) {
|
|
1203
1434
|
return;
|
|
1204
1435
|
}
|
|
@@ -1208,20 +1439,20 @@ const walkValue$1 = (value, transferrables, isTransferrable) => {
|
|
|
1208
1439
|
}
|
|
1209
1440
|
if (Array.isArray(value)) {
|
|
1210
1441
|
for (const item of value) {
|
|
1211
|
-
walkValue
|
|
1442
|
+
walkValue(item, transferrables, isTransferrable);
|
|
1212
1443
|
}
|
|
1213
1444
|
return;
|
|
1214
1445
|
}
|
|
1215
1446
|
if (typeof value === 'object') {
|
|
1216
1447
|
for (const property of Object.values(value)) {
|
|
1217
|
-
walkValue
|
|
1448
|
+
walkValue(property, transferrables, isTransferrable);
|
|
1218
1449
|
}
|
|
1219
1450
|
return;
|
|
1220
1451
|
}
|
|
1221
1452
|
};
|
|
1222
1453
|
const getTransferrables = value => {
|
|
1223
1454
|
const transferrables = [];
|
|
1224
|
-
walkValue
|
|
1455
|
+
walkValue(value, transferrables, isTransferrable);
|
|
1225
1456
|
return transferrables;
|
|
1226
1457
|
};
|
|
1227
1458
|
const removeValues = (value, toRemove) => {
|
|
@@ -1283,9 +1514,9 @@ class Ipc extends EventTarget {
|
|
|
1283
1514
|
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
1284
1515
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
1285
1516
|
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
1286
|
-
const NewLine$
|
|
1287
|
-
const joinLines$
|
|
1288
|
-
return lines.join(NewLine$
|
|
1517
|
+
const NewLine$1 = '\n';
|
|
1518
|
+
const joinLines$1 = lines => {
|
|
1519
|
+
return lines.join(NewLine$1);
|
|
1289
1520
|
};
|
|
1290
1521
|
const RE_AT$1 = /^\s+at/;
|
|
1291
1522
|
const RE_AT_PROMISE_INDEX$1 = /^\s*at async Promise.all \(index \d+\)$/;
|
|
@@ -1296,7 +1527,7 @@ const getDetails$1 = lines => {
|
|
|
1296
1527
|
const index = lines.findIndex(isNormalStackLine$1);
|
|
1297
1528
|
if (index === -1) {
|
|
1298
1529
|
return {
|
|
1299
|
-
actualMessage: joinLines$
|
|
1530
|
+
actualMessage: joinLines$1(lines),
|
|
1300
1531
|
rest: []
|
|
1301
1532
|
};
|
|
1302
1533
|
}
|
|
@@ -1311,8 +1542,8 @@ const getDetails$1 = lines => {
|
|
|
1311
1542
|
rest: lines.slice(index, lastIndex)
|
|
1312
1543
|
};
|
|
1313
1544
|
};
|
|
1314
|
-
const splitLines$
|
|
1315
|
-
return lines.split(NewLine$
|
|
1545
|
+
const splitLines$1 = lines => {
|
|
1546
|
+
return lines.split(NewLine$1);
|
|
1316
1547
|
};
|
|
1317
1548
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
1318
1549
|
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
@@ -1323,7 +1554,7 @@ const isMessageCodeBlockEndIndex = line => {
|
|
|
1323
1554
|
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
1324
1555
|
};
|
|
1325
1556
|
const getMessageCodeBlock = stderr => {
|
|
1326
|
-
const lines = splitLines$
|
|
1557
|
+
const lines = splitLines$1(stderr);
|
|
1327
1558
|
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
1328
1559
|
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
1329
1560
|
const relevantLines = lines.slice(startIndex, endIndex);
|
|
@@ -1334,7 +1565,7 @@ const isModuleNotFoundMessage = line => {
|
|
|
1334
1565
|
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
1335
1566
|
};
|
|
1336
1567
|
const getModuleNotFoundError = stderr => {
|
|
1337
|
-
const lines = splitLines$
|
|
1568
|
+
const lines = splitLines$1(stderr);
|
|
1338
1569
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
1339
1570
|
const message = lines[messageIndex];
|
|
1340
1571
|
return {
|
|
@@ -1382,7 +1613,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
1382
1613
|
if (isModuleNotFoundError(stderr)) {
|
|
1383
1614
|
return getModuleNotFoundError(stderr);
|
|
1384
1615
|
}
|
|
1385
|
-
const lines = splitLines$
|
|
1616
|
+
const lines = splitLines$1(stderr);
|
|
1386
1617
|
const {
|
|
1387
1618
|
actualMessage,
|
|
1388
1619
|
rest
|
|
@@ -1393,7 +1624,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
1393
1624
|
stack: rest
|
|
1394
1625
|
};
|
|
1395
1626
|
};
|
|
1396
|
-
|
|
1627
|
+
class IpcError extends VError$1 {
|
|
1397
1628
|
// @ts-ignore
|
|
1398
1629
|
constructor(betterMessage, stdout = '', stderr = '') {
|
|
1399
1630
|
if (stdout || stderr) {
|
|
@@ -1418,7 +1649,7 @@ let IpcError$1 = class IpcError extends VError$1 {
|
|
|
1418
1649
|
// @ts-ignore
|
|
1419
1650
|
this.stderr = stderr;
|
|
1420
1651
|
}
|
|
1421
|
-
}
|
|
1652
|
+
}
|
|
1422
1653
|
const readyMessage = 'ready';
|
|
1423
1654
|
const getData$2 = event => {
|
|
1424
1655
|
return event.data;
|
|
@@ -1486,7 +1717,7 @@ const removeListener = (emitter, type, callback) => {
|
|
|
1486
1717
|
emitter.off(type, callback);
|
|
1487
1718
|
}
|
|
1488
1719
|
};
|
|
1489
|
-
const getFirstEvent
|
|
1720
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
1490
1721
|
const {
|
|
1491
1722
|
resolve,
|
|
1492
1723
|
promise
|
|
@@ -1515,13 +1746,13 @@ const create$5$2 = async ({
|
|
|
1515
1746
|
messagePort,
|
|
1516
1747
|
isMessagePortOpen
|
|
1517
1748
|
}) => {
|
|
1518
|
-
if (!isMessagePort
|
|
1519
|
-
throw new IpcError
|
|
1749
|
+
if (!isMessagePort(messagePort)) {
|
|
1750
|
+
throw new IpcError('port must be of type MessagePort');
|
|
1520
1751
|
}
|
|
1521
1752
|
if (isMessagePortOpen) {
|
|
1522
1753
|
return messagePort;
|
|
1523
1754
|
}
|
|
1524
|
-
const eventPromise = getFirstEvent
|
|
1755
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
1525
1756
|
message: Message$1
|
|
1526
1757
|
});
|
|
1527
1758
|
messagePort.start();
|
|
@@ -1530,17 +1761,17 @@ const create$5$2 = async ({
|
|
|
1530
1761
|
event
|
|
1531
1762
|
} = await eventPromise;
|
|
1532
1763
|
if (type !== Message$1) {
|
|
1533
|
-
throw new IpcError
|
|
1764
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
1534
1765
|
}
|
|
1535
1766
|
if (event.data !== readyMessage) {
|
|
1536
|
-
throw new IpcError
|
|
1767
|
+
throw new IpcError('unexpected first message');
|
|
1537
1768
|
}
|
|
1538
1769
|
return messagePort;
|
|
1539
1770
|
};
|
|
1540
1771
|
const signal$1 = messagePort => {
|
|
1541
1772
|
messagePort.start();
|
|
1542
1773
|
};
|
|
1543
|
-
|
|
1774
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
1544
1775
|
getData = getData$2;
|
|
1545
1776
|
send(message) {
|
|
1546
1777
|
this._rawIpc.postMessage(message);
|
|
@@ -1556,28 +1787,28 @@ let IpcParentWithMessagePort$1 = class IpcParentWithMessagePort extends Ipc {
|
|
|
1556
1787
|
this._rawIpc.addEventListener('message', callback);
|
|
1557
1788
|
}
|
|
1558
1789
|
onClose(callback) {}
|
|
1559
|
-
}
|
|
1790
|
+
}
|
|
1560
1791
|
const wrap$5 = messagePort => {
|
|
1561
|
-
return new IpcParentWithMessagePort
|
|
1792
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
1562
1793
|
};
|
|
1563
|
-
const IpcParentWithMessagePort$1
|
|
1794
|
+
const IpcParentWithMessagePort$1 = {
|
|
1564
1795
|
__proto__: null,
|
|
1565
1796
|
create: create$5$2,
|
|
1566
1797
|
signal: signal$1,
|
|
1567
1798
|
wrap: wrap$5
|
|
1568
1799
|
};
|
|
1569
|
-
const Message
|
|
1800
|
+
const Message = 'message';
|
|
1570
1801
|
const Error$1$1 = 'error';
|
|
1571
|
-
const getFirstWorkerEvent
|
|
1572
|
-
return getFirstEvent
|
|
1573
|
-
message: Message
|
|
1802
|
+
const getFirstWorkerEvent = worker => {
|
|
1803
|
+
return getFirstEvent(worker, {
|
|
1804
|
+
message: Message,
|
|
1574
1805
|
error: Error$1$1
|
|
1575
1806
|
});
|
|
1576
1807
|
};
|
|
1577
|
-
const isErrorEvent
|
|
1808
|
+
const isErrorEvent = event => {
|
|
1578
1809
|
return event instanceof ErrorEvent;
|
|
1579
1810
|
};
|
|
1580
|
-
const getWorkerDisplayName
|
|
1811
|
+
const getWorkerDisplayName = name => {
|
|
1581
1812
|
if (!name) {
|
|
1582
1813
|
return '<unknown> worker';
|
|
1583
1814
|
}
|
|
@@ -1589,42 +1820,42 @@ const getWorkerDisplayName$1 = name => {
|
|
|
1589
1820
|
const tryToGetActualErrorMessage = async ({
|
|
1590
1821
|
name
|
|
1591
1822
|
}) => {
|
|
1592
|
-
const displayName = getWorkerDisplayName
|
|
1823
|
+
const displayName = getWorkerDisplayName(name);
|
|
1593
1824
|
return `Failed to start ${displayName}: Worker Launch Error`;
|
|
1594
1825
|
};
|
|
1595
|
-
|
|
1826
|
+
class WorkerError extends Error {
|
|
1596
1827
|
constructor(event) {
|
|
1597
1828
|
super(event.message);
|
|
1598
|
-
const stackLines = splitLines$
|
|
1829
|
+
const stackLines = splitLines$1(this.stack || '');
|
|
1599
1830
|
const relevantLines = stackLines.slice(1);
|
|
1600
|
-
const relevant = joinLines$
|
|
1831
|
+
const relevant = joinLines$1(relevantLines);
|
|
1601
1832
|
this.stack = `${event.message}
|
|
1602
1833
|
at Module (${event.filename}:${event.lineno}:${event.colno})
|
|
1603
1834
|
${relevant}`;
|
|
1604
1835
|
}
|
|
1605
|
-
}
|
|
1606
|
-
const Module
|
|
1836
|
+
}
|
|
1837
|
+
const Module = 'module';
|
|
1607
1838
|
const create$4$3 = async ({
|
|
1608
1839
|
url,
|
|
1609
1840
|
name
|
|
1610
1841
|
}) => {
|
|
1611
1842
|
const worker = new Worker(url, {
|
|
1612
|
-
type: Module
|
|
1843
|
+
type: Module,
|
|
1613
1844
|
name
|
|
1614
1845
|
});
|
|
1615
1846
|
const {
|
|
1616
1847
|
type,
|
|
1617
1848
|
event
|
|
1618
|
-
} = await getFirstWorkerEvent
|
|
1849
|
+
} = await getFirstWorkerEvent(worker);
|
|
1619
1850
|
switch (type) {
|
|
1620
|
-
case Message
|
|
1851
|
+
case Message:
|
|
1621
1852
|
if (event.data !== readyMessage) {
|
|
1622
|
-
throw new IpcError
|
|
1853
|
+
throw new IpcError('unexpected first message from worker');
|
|
1623
1854
|
}
|
|
1624
1855
|
break;
|
|
1625
1856
|
case Error$1$1:
|
|
1626
|
-
if (isErrorEvent
|
|
1627
|
-
throw new WorkerError
|
|
1857
|
+
if (isErrorEvent(event)) {
|
|
1858
|
+
throw new WorkerError(event);
|
|
1628
1859
|
}
|
|
1629
1860
|
const actualErrorMessage = await tryToGetActualErrorMessage({
|
|
1630
1861
|
name
|
|
@@ -1633,16 +1864,16 @@ const create$4$3 = async ({
|
|
|
1633
1864
|
}
|
|
1634
1865
|
return worker;
|
|
1635
1866
|
};
|
|
1636
|
-
const getData
|
|
1867
|
+
const getData = event => {
|
|
1637
1868
|
// TODO why are some events not instance of message event?
|
|
1638
1869
|
if (event instanceof MessageEvent) {
|
|
1639
1870
|
return event.data;
|
|
1640
1871
|
}
|
|
1641
1872
|
return event;
|
|
1642
1873
|
};
|
|
1643
|
-
|
|
1874
|
+
class IpcParentWithModuleWorker extends Ipc {
|
|
1644
1875
|
getData(event) {
|
|
1645
|
-
return getData
|
|
1876
|
+
return getData(event);
|
|
1646
1877
|
}
|
|
1647
1878
|
send(message) {
|
|
1648
1879
|
this._rawIpc.postMessage(message);
|
|
@@ -1660,11 +1891,11 @@ let IpcParentWithModuleWorker$1 = class IpcParentWithModuleWorker extends Ipc {
|
|
|
1660
1891
|
onMessage(callback) {
|
|
1661
1892
|
this._rawIpc.addEventListener('message', callback);
|
|
1662
1893
|
}
|
|
1663
|
-
}
|
|
1894
|
+
}
|
|
1664
1895
|
const wrap$4 = worker => {
|
|
1665
|
-
return new IpcParentWithModuleWorker
|
|
1896
|
+
return new IpcParentWithModuleWorker(worker);
|
|
1666
1897
|
};
|
|
1667
|
-
const IpcParentWithModuleWorker$1
|
|
1898
|
+
const IpcParentWithModuleWorker$1 = {
|
|
1668
1899
|
__proto__: null,
|
|
1669
1900
|
create: create$4$3,
|
|
1670
1901
|
wrap: wrap$4
|
|
@@ -1679,13 +1910,13 @@ const create$4$2 = (method, params) => {
|
|
|
1679
1910
|
};
|
|
1680
1911
|
};
|
|
1681
1912
|
const callbacks = Object.create(null);
|
|
1682
|
-
const set$
|
|
1913
|
+
const set$8 = (id, fn) => {
|
|
1683
1914
|
callbacks[id] = fn;
|
|
1684
1915
|
};
|
|
1685
|
-
const get$
|
|
1916
|
+
const get$7 = id => {
|
|
1686
1917
|
return callbacks[id];
|
|
1687
1918
|
};
|
|
1688
|
-
const remove$
|
|
1919
|
+
const remove$3 = id => {
|
|
1689
1920
|
delete callbacks[id];
|
|
1690
1921
|
};
|
|
1691
1922
|
let id = 0;
|
|
@@ -1698,7 +1929,7 @@ const registerPromise = () => {
|
|
|
1698
1929
|
resolve,
|
|
1699
1930
|
promise
|
|
1700
1931
|
} = Promise.withResolvers();
|
|
1701
|
-
set$
|
|
1932
|
+
set$8(id, resolve);
|
|
1702
1933
|
return {
|
|
1703
1934
|
id,
|
|
1704
1935
|
promise
|
|
@@ -1726,7 +1957,7 @@ class JsonRpcError extends Error {
|
|
|
1726
1957
|
this.name = 'JsonRpcError';
|
|
1727
1958
|
}
|
|
1728
1959
|
}
|
|
1729
|
-
const NewLine
|
|
1960
|
+
const NewLine = '\n';
|
|
1730
1961
|
const DomException = 'DOMException';
|
|
1731
1962
|
const ReferenceError$1 = 'ReferenceError';
|
|
1732
1963
|
const SyntaxError$1 = 'SyntaxError';
|
|
@@ -1771,23 +2002,23 @@ const constructError = (message, type, name) => {
|
|
|
1771
2002
|
}
|
|
1772
2003
|
return new ErrorConstructor(message);
|
|
1773
2004
|
};
|
|
1774
|
-
const joinLines
|
|
1775
|
-
return lines.join(NewLine
|
|
2005
|
+
const joinLines = lines => {
|
|
2006
|
+
return lines.join(NewLine);
|
|
1776
2007
|
};
|
|
1777
|
-
const splitLines
|
|
1778
|
-
return lines.split(NewLine
|
|
2008
|
+
const splitLines = lines => {
|
|
2009
|
+
return lines.split(NewLine);
|
|
1779
2010
|
};
|
|
1780
2011
|
const getCurrentStack = () => {
|
|
1781
|
-
const currentStack = joinLines
|
|
2012
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
|
|
1782
2013
|
return currentStack;
|
|
1783
2014
|
};
|
|
1784
2015
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
1785
|
-
return string.indexOf(NewLine
|
|
2016
|
+
return string.indexOf(NewLine, startIndex);
|
|
1786
2017
|
};
|
|
1787
2018
|
const getParentStack = error => {
|
|
1788
2019
|
let parentStack = error.stack || error.data || error.message || '';
|
|
1789
2020
|
if (parentStack.startsWith(' at')) {
|
|
1790
|
-
parentStack = error.message + NewLine
|
|
2021
|
+
parentStack = error.message + NewLine + parentStack;
|
|
1791
2022
|
}
|
|
1792
2023
|
return parentStack;
|
|
1793
2024
|
};
|
|
@@ -1797,21 +2028,21 @@ const restoreJsonRpcError = error => {
|
|
|
1797
2028
|
const currentStack = getCurrentStack();
|
|
1798
2029
|
if (error && error instanceof Error) {
|
|
1799
2030
|
if (typeof error.stack === 'string') {
|
|
1800
|
-
error.stack = error.stack + NewLine
|
|
2031
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
1801
2032
|
}
|
|
1802
2033
|
return error;
|
|
1803
2034
|
}
|
|
1804
2035
|
if (error && error.code && error.code === MethodNotFound) {
|
|
1805
2036
|
const restoredError = new JsonRpcError(error.message);
|
|
1806
2037
|
const parentStack = getParentStack(error);
|
|
1807
|
-
restoredError.stack = parentStack + NewLine
|
|
2038
|
+
restoredError.stack = parentStack + NewLine + currentStack;
|
|
1808
2039
|
return restoredError;
|
|
1809
2040
|
}
|
|
1810
2041
|
if (error && error.message) {
|
|
1811
2042
|
const restoredError = constructError(error.message, error.type, error.name);
|
|
1812
2043
|
if (error.data) {
|
|
1813
2044
|
if (error.data.stack && error.data.type && error.message) {
|
|
1814
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine
|
|
2045
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
1815
2046
|
} else if (error.data.stack) {
|
|
1816
2047
|
restoredError.stack = error.data.stack;
|
|
1817
2048
|
}
|
|
@@ -1862,14 +2093,14 @@ const warn = (...args) => {
|
|
|
1862
2093
|
console.warn(...args);
|
|
1863
2094
|
};
|
|
1864
2095
|
const resolve = (id, response) => {
|
|
1865
|
-
const fn = get$
|
|
2096
|
+
const fn = get$7(id);
|
|
1866
2097
|
if (!fn) {
|
|
1867
2098
|
console.log(response);
|
|
1868
2099
|
warn(`callback ${id} may already be disposed`);
|
|
1869
2100
|
return;
|
|
1870
2101
|
}
|
|
1871
2102
|
fn(response);
|
|
1872
|
-
remove$
|
|
2103
|
+
remove$3(id);
|
|
1873
2104
|
};
|
|
1874
2105
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1875
2106
|
const getErrorType = prettyError => {
|
|
@@ -1925,7 +2156,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
1925
2156
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
1926
2157
|
return create$1$1(id, errorProperty);
|
|
1927
2158
|
};
|
|
1928
|
-
const create$
|
|
2159
|
+
const create$E = (message, result) => {
|
|
1929
2160
|
return {
|
|
1930
2161
|
jsonrpc: Two,
|
|
1931
2162
|
id: message.id,
|
|
@@ -1934,7 +2165,7 @@ const create$H = (message, result) => {
|
|
|
1934
2165
|
};
|
|
1935
2166
|
const getSuccessResponse = (message, result) => {
|
|
1936
2167
|
const resultProperty = result ?? null;
|
|
1937
|
-
return create$
|
|
2168
|
+
return create$E(message, resultProperty);
|
|
1938
2169
|
};
|
|
1939
2170
|
const getErrorResponseSimple = (id, error) => {
|
|
1940
2171
|
return {
|
|
@@ -2141,14 +2372,14 @@ const create$b$1 = async ({
|
|
|
2141
2372
|
}) => {
|
|
2142
2373
|
// TODO create a commandMap per rpc instance
|
|
2143
2374
|
register(commandMap);
|
|
2144
|
-
const worker = await IpcParentWithModuleWorker$1
|
|
2375
|
+
const worker = await IpcParentWithModuleWorker$1.create({
|
|
2145
2376
|
url,
|
|
2146
2377
|
name
|
|
2147
2378
|
});
|
|
2148
2379
|
if (!isWorker(worker)) {
|
|
2149
2380
|
throw new Error(`worker must be of type Worker`);
|
|
2150
2381
|
}
|
|
2151
|
-
const ipc = IpcParentWithModuleWorker$1
|
|
2382
|
+
const ipc = IpcParentWithModuleWorker$1.wrap(worker);
|
|
2152
2383
|
handleIpc(ipc);
|
|
2153
2384
|
const workerRpc = createRpc(ipc);
|
|
2154
2385
|
return workerRpc;
|
|
@@ -2165,14 +2396,14 @@ const create$a$1 = async ({
|
|
|
2165
2396
|
}) => {
|
|
2166
2397
|
// TODO create a commandMap per rpc instance
|
|
2167
2398
|
register(commandMap);
|
|
2168
|
-
const worker = await IpcParentWithModuleWorker$1
|
|
2399
|
+
const worker = await IpcParentWithModuleWorker$1.create({
|
|
2169
2400
|
url,
|
|
2170
2401
|
name
|
|
2171
2402
|
});
|
|
2172
2403
|
if (!isWorker(worker)) {
|
|
2173
2404
|
throw new Error(`worker must be of type Worker`);
|
|
2174
2405
|
}
|
|
2175
|
-
const ipc = IpcParentWithModuleWorker$1
|
|
2406
|
+
const ipc = IpcParentWithModuleWorker$1.wrap(worker);
|
|
2176
2407
|
handleIpc(ipc);
|
|
2177
2408
|
const workerRpc = createRpc(ipc);
|
|
2178
2409
|
await workerRpc.invokeAndTransfer('initialize', 'message-port', port);
|
|
@@ -2189,11 +2420,11 @@ const create$5$1 = async ({
|
|
|
2189
2420
|
}) => {
|
|
2190
2421
|
// TODO create a commandMap per rpc instance
|
|
2191
2422
|
register(commandMap);
|
|
2192
|
-
const rawIpc = await IpcParentWithMessagePort$1
|
|
2423
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
2193
2424
|
messagePort,
|
|
2194
2425
|
isMessagePortOpen: true
|
|
2195
2426
|
});
|
|
2196
|
-
const ipc = IpcParentWithMessagePort$1
|
|
2427
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
2197
2428
|
handleIpc(ipc);
|
|
2198
2429
|
const rpc = createRpc(ipc);
|
|
2199
2430
|
messagePort.start();
|
|
@@ -2213,18 +2444,24 @@ const PlainMessagePortRpcParent = {
|
|
|
2213
2444
|
create: create$4$1
|
|
2214
2445
|
};
|
|
2215
2446
|
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2447
|
+
// TODO add test
|
|
2448
|
+
const create$D = async ({
|
|
2449
|
+
url,
|
|
2219
2450
|
name,
|
|
2220
|
-
|
|
2451
|
+
port
|
|
2221
2452
|
}) => {
|
|
2222
|
-
|
|
2453
|
+
await ModuleWorkerWithMessagePortRpcParent.create({
|
|
2223
2454
|
url,
|
|
2224
2455
|
name,
|
|
2225
|
-
commandMap:
|
|
2456
|
+
commandMap: {},
|
|
2457
|
+
port
|
|
2226
2458
|
});
|
|
2227
|
-
return
|
|
2459
|
+
return undefined;
|
|
2460
|
+
};
|
|
2461
|
+
|
|
2462
|
+
const IpcParentWithModuleWorkerWithMessagePort = {
|
|
2463
|
+
__proto__: null,
|
|
2464
|
+
create: create$D
|
|
2228
2465
|
};
|
|
2229
2466
|
|
|
2230
2467
|
const Web = 1;
|
|
@@ -2254,6 +2491,75 @@ const getPlatform = () => {
|
|
|
2254
2491
|
};
|
|
2255
2492
|
const platform = getPlatform();
|
|
2256
2493
|
|
|
2494
|
+
const isElectron = platform === Electron;
|
|
2495
|
+
|
|
2496
|
+
// TODO use handleIncomingIpc function
|
|
2497
|
+
const create$C = async ({
|
|
2498
|
+
port,
|
|
2499
|
+
ipcId
|
|
2500
|
+
}) => {
|
|
2501
|
+
number(ipcId);
|
|
2502
|
+
if (!isElectron) {
|
|
2503
|
+
throw new Error('Electron api was requested but is not available');
|
|
2504
|
+
}
|
|
2505
|
+
const rpc = await ElectronWindowRpcClient.create({
|
|
2506
|
+
commandMap: {},
|
|
2507
|
+
window
|
|
2508
|
+
});
|
|
2509
|
+
const webContentsIds = await rpc.invokeAndTransfer('CreateMessagePort.createMessagePort', ipcId, port);
|
|
2510
|
+
return webContentsIds;
|
|
2511
|
+
};
|
|
2512
|
+
|
|
2513
|
+
const IpcParentWithElectron = {
|
|
2514
|
+
__proto__: null,
|
|
2515
|
+
create: create$C
|
|
2516
|
+
};
|
|
2517
|
+
|
|
2518
|
+
const getModule = method => {
|
|
2519
|
+
switch (method) {
|
|
2520
|
+
case ModuleWorker:
|
|
2521
|
+
return IpcParentWithModuleWorker$2;
|
|
2522
|
+
case MessagePort$1:
|
|
2523
|
+
return IpcParentWithMessagePort$2;
|
|
2524
|
+
case ReferencePort:
|
|
2525
|
+
return IpcParentWithReferencePort;
|
|
2526
|
+
case ModuleWorkerWithMessagePort:
|
|
2527
|
+
return IpcParentWithModuleWorkerWithMessagePort;
|
|
2528
|
+
case Electron$1:
|
|
2529
|
+
return IpcParentWithElectron;
|
|
2530
|
+
default:
|
|
2531
|
+
throw new Error('unexpected ipc type');
|
|
2532
|
+
}
|
|
2533
|
+
};
|
|
2534
|
+
|
|
2535
|
+
const ipcs = Object.create(null);
|
|
2536
|
+
const set$7 = (name, ipc) => {
|
|
2537
|
+
ipcs[name] = ipc;
|
|
2538
|
+
};
|
|
2539
|
+
const get$6 = name => {
|
|
2540
|
+
return ipcs[name];
|
|
2541
|
+
};
|
|
2542
|
+
const remove$2 = name => {
|
|
2543
|
+
delete ipcs[name];
|
|
2544
|
+
};
|
|
2545
|
+
const has = name => {
|
|
2546
|
+
return ipcs[name];
|
|
2547
|
+
};
|
|
2548
|
+
|
|
2549
|
+
const commandMapRef = {};
|
|
2550
|
+
|
|
2551
|
+
const launchWorker = async ({
|
|
2552
|
+
name,
|
|
2553
|
+
url
|
|
2554
|
+
}) => {
|
|
2555
|
+
const rpc = await ModuleWorkerRpcParent.create({
|
|
2556
|
+
url,
|
|
2557
|
+
name,
|
|
2558
|
+
commandMap: commandMapRef
|
|
2559
|
+
});
|
|
2560
|
+
return rpc;
|
|
2561
|
+
};
|
|
2562
|
+
|
|
2257
2563
|
const getAssetDir = () => {
|
|
2258
2564
|
// @ts-expect-error
|
|
2259
2565
|
if (typeof ASSET_DIR !== 'undefined') {
|
|
@@ -2331,7 +2637,7 @@ const RendererWorker = {
|
|
|
2331
2637
|
state: state$7
|
|
2332
2638
|
};
|
|
2333
2639
|
|
|
2334
|
-
const create$
|
|
2640
|
+
const create$B = async ({
|
|
2335
2641
|
method,
|
|
2336
2642
|
...options
|
|
2337
2643
|
}) => {
|
|
@@ -2341,8 +2647,8 @@ const create$G = async ({
|
|
|
2341
2647
|
}
|
|
2342
2648
|
// TODO rename method
|
|
2343
2649
|
// TODO avoid cyclic dependency
|
|
2344
|
-
const port = get$
|
|
2345
|
-
remove$
|
|
2650
|
+
const port = get$6(options.name);
|
|
2651
|
+
remove$2(options.name);
|
|
2346
2652
|
await invokeAndTransfer('Transferrable.transfer', options.id, port);
|
|
2347
2653
|
return;
|
|
2348
2654
|
}
|
|
@@ -2448,7 +2754,7 @@ const create$Notification = message => {
|
|
|
2448
2754
|
$Notification.textContent = message;
|
|
2449
2755
|
return $Notification;
|
|
2450
2756
|
};
|
|
2451
|
-
const create$
|
|
2757
|
+
const create$A = (type, message) => {
|
|
2452
2758
|
// TODO this pattern might be also useful for activitybar, sidebar etc., creating elements as late as possible, only when actually needed
|
|
2453
2759
|
const $Notification = create$Notification(message);
|
|
2454
2760
|
append$1($Notification);
|
|
@@ -2510,7 +2816,7 @@ const set$6 = (canvasId, canvas) => {
|
|
|
2510
2816
|
const get$4 = id => {
|
|
2511
2817
|
return get$5(id);
|
|
2512
2818
|
};
|
|
2513
|
-
const create$
|
|
2819
|
+
const create$z = async (canvasId, objectId) => {
|
|
2514
2820
|
const canvas = document.createElement('canvas');
|
|
2515
2821
|
const offscreenCanvas = canvas.transferControlToOffscreen();
|
|
2516
2822
|
set$6(canvasId, canvas);
|
|
@@ -2564,7 +2870,7 @@ const DragLeave = 'dragleave';
|
|
|
2564
2870
|
const DragOver = 'dragover';
|
|
2565
2871
|
const DragStart = 'dragstart';
|
|
2566
2872
|
const Drop = 'drop';
|
|
2567
|
-
const Error$
|
|
2873
|
+
const Error$2 = 'error';
|
|
2568
2874
|
const Focus = 'focus';
|
|
2569
2875
|
const FocusIn = 'focusin';
|
|
2570
2876
|
const FocusOut = 'focusout';
|
|
@@ -3714,7 +4020,7 @@ const showError = (message, y, x) => {
|
|
|
3714
4020
|
$ImagePreviewImage
|
|
3715
4021
|
};
|
|
3716
4022
|
};
|
|
3717
|
-
const create$
|
|
4023
|
+
const create$y = (uri, top, left) => {
|
|
3718
4024
|
const $ImagePreviewImage = document.createElement('img');
|
|
3719
4025
|
$ImagePreviewImage.className = 'ImagePreviewImage';
|
|
3720
4026
|
$ImagePreviewImage.src = uri;
|
|
@@ -3745,7 +4051,7 @@ const dispose$i = state => {
|
|
|
3745
4051
|
|
|
3746
4052
|
const ImagePreview$1 = {
|
|
3747
4053
|
__proto__: null,
|
|
3748
|
-
create: create$
|
|
4054
|
+
create: create$y,
|
|
3749
4055
|
dispose: dispose$i,
|
|
3750
4056
|
showError,
|
|
3751
4057
|
update
|
|
@@ -3970,7 +4276,7 @@ const ViewletAudio = {
|
|
|
3970
4276
|
Events: Events$4
|
|
3971
4277
|
};
|
|
3972
4278
|
|
|
3973
|
-
const create$
|
|
4279
|
+
const create$x = () => {
|
|
3974
4280
|
const $Viewlet = document.createElement('div');
|
|
3975
4281
|
$Viewlet.className = 'Viewlet Clock';
|
|
3976
4282
|
return {
|
|
@@ -3987,7 +4293,7 @@ const setTime = (state, time) => {
|
|
|
3987
4293
|
|
|
3988
4294
|
const ViewletClock = {
|
|
3989
4295
|
__proto__: null,
|
|
3990
|
-
create: create$
|
|
4296
|
+
create: create$x,
|
|
3991
4297
|
dispose: dispose$h,
|
|
3992
4298
|
refresh: refresh$4,
|
|
3993
4299
|
setTime
|
|
@@ -4016,7 +4322,7 @@ const stopTracking$1 = ($Target, pointerId, handlePointerMove, handlePointerUp)
|
|
|
4016
4322
|
// TODO use pointerlost event instead
|
|
4017
4323
|
$Target.removeEventListener(PointerUp, handlePointerUp);
|
|
4018
4324
|
};
|
|
4019
|
-
const create$
|
|
4325
|
+
const create$w = (pointerDown, pointerMove, pointerUp) => {
|
|
4020
4326
|
const shared = (fn, event) => {
|
|
4021
4327
|
const message = fn(event);
|
|
4022
4328
|
if (!message || message.length === 0) {
|
|
@@ -4049,7 +4355,7 @@ const create$B = (pointerDown, pointerMove, pointerUp) => {
|
|
|
4049
4355
|
};
|
|
4050
4356
|
|
|
4051
4357
|
const handleOffset = 20;
|
|
4052
|
-
const handleSliderPointerDown = create$
|
|
4358
|
+
const handleSliderPointerDown = create$w(event => {
|
|
4053
4359
|
const {
|
|
4054
4360
|
clientX,
|
|
4055
4361
|
clientY
|
|
@@ -4131,7 +4437,7 @@ const ViewletDebugConsoleEvents = {
|
|
|
4131
4437
|
handleInput: handleInput$6
|
|
4132
4438
|
};
|
|
4133
4439
|
|
|
4134
|
-
const create$
|
|
4440
|
+
const create$v = () => {
|
|
4135
4441
|
const $Viewlet = document.createElement('div');
|
|
4136
4442
|
$Viewlet.className = 'Viewlet DebugConsole';
|
|
4137
4443
|
return {
|
|
@@ -4147,7 +4453,7 @@ const setDom$9 = (state, dom) => {
|
|
|
4147
4453
|
|
|
4148
4454
|
const ViewletDebugConsole = {
|
|
4149
4455
|
__proto__: null,
|
|
4150
|
-
create: create$
|
|
4456
|
+
create: create$v,
|
|
4151
4457
|
setDom: setDom$9
|
|
4152
4458
|
};
|
|
4153
4459
|
|
|
@@ -4208,7 +4514,7 @@ const setMaskImage = ($Element, icon) => {
|
|
|
4208
4514
|
}
|
|
4209
4515
|
};
|
|
4210
4516
|
|
|
4211
|
-
const create$
|
|
4517
|
+
const create$u = icon => {
|
|
4212
4518
|
const $Icon = document.createElement('div');
|
|
4213
4519
|
$Icon.className = 'MaskIcon';
|
|
4214
4520
|
setMaskImage($Icon, icon);
|
|
@@ -4218,7 +4524,7 @@ const create$z = icon => {
|
|
|
4218
4524
|
|
|
4219
4525
|
const create$Button = (label, icon) => {
|
|
4220
4526
|
// TODO icon div might not be needed (unnecessary html element)
|
|
4221
|
-
const $Icon = create$
|
|
4527
|
+
const $Icon = create$u(icon);
|
|
4222
4528
|
const $Button = document.createElement('button');
|
|
4223
4529
|
$Button.className = 'IconButton';
|
|
4224
4530
|
$Button.title = label;
|
|
@@ -4239,7 +4545,7 @@ const handleClick$4 = event => {
|
|
|
4239
4545
|
handleClick$5(index);
|
|
4240
4546
|
};
|
|
4241
4547
|
|
|
4242
|
-
const create$
|
|
4548
|
+
const create$t = () => {
|
|
4243
4549
|
const $DialogTitle = document.createElement('h2');
|
|
4244
4550
|
$DialogTitle.id = 'DialogTitle';
|
|
4245
4551
|
const $DialogCloseButton = create$Button('Close', 'Close');
|
|
@@ -4320,7 +4626,7 @@ const setErrorStack = (state, errorStack) => {
|
|
|
4320
4626
|
|
|
4321
4627
|
const ViewletDialog = {
|
|
4322
4628
|
__proto__: null,
|
|
4323
|
-
create: create$
|
|
4629
|
+
create: create$t,
|
|
4324
4630
|
postAppend,
|
|
4325
4631
|
setButtons,
|
|
4326
4632
|
setCodeFrame,
|
|
@@ -4383,7 +4689,7 @@ const handleContextMenu$8 = event => {
|
|
|
4383
4689
|
} = event;
|
|
4384
4690
|
return ['handleContextMenu', button, clientX, clientY];
|
|
4385
4691
|
};
|
|
4386
|
-
const handleSashCornerPointerDown = create$
|
|
4692
|
+
const handleSashCornerPointerDown = create$w(event => {
|
|
4387
4693
|
const {
|
|
4388
4694
|
clientX,
|
|
4389
4695
|
clientY
|
|
@@ -4732,7 +5038,7 @@ const setNegativeMargin = (state, negativeMargin) => {
|
|
|
4732
5038
|
setTop($ListItems, negativeMargin);
|
|
4733
5039
|
};
|
|
4734
5040
|
|
|
4735
|
-
const create$
|
|
5041
|
+
const create$s = () => {
|
|
4736
5042
|
const $ListItems = document.createElement('div');
|
|
4737
5043
|
$ListItems.className = 'ListItems';
|
|
4738
5044
|
$ListItems.role = ListBox;
|
|
@@ -4816,7 +5122,7 @@ const setBounds$8 = (state, x, y, width, height) => {
|
|
|
4816
5122
|
const ViewletEditorCompletion = {
|
|
4817
5123
|
__proto__: null,
|
|
4818
5124
|
attachEvents: attachEvents$9,
|
|
4819
|
-
create: create$
|
|
5125
|
+
create: create$s,
|
|
4820
5126
|
dispose: dispose$f,
|
|
4821
5127
|
handleError: handleError$7,
|
|
4822
5128
|
setBounds: setBounds$8,
|
|
@@ -4839,7 +5145,7 @@ const ViewletEditorCompletionDetailsEvents = {
|
|
|
4839
5145
|
returnValue: returnValue$5
|
|
4840
5146
|
};
|
|
4841
5147
|
|
|
4842
|
-
const create$
|
|
5148
|
+
const create$r = () => {
|
|
4843
5149
|
const $Viewlet = document.createElement('div');
|
|
4844
5150
|
$Viewlet.className = 'Viewlet EditorCompletionDetails';
|
|
4845
5151
|
$Viewlet.id = 'CompletionsDetails';
|
|
@@ -4880,7 +5186,7 @@ const ViewletEditorCompletionDetails = {
|
|
|
4880
5186
|
Events: ViewletEditorCompletionDetailsEvents,
|
|
4881
5187
|
appendWidget: appendWidget$4,
|
|
4882
5188
|
attachEvents: attachEvents$8,
|
|
4883
|
-
create: create$
|
|
5189
|
+
create: create$r,
|
|
4884
5190
|
dispose: dispose$e,
|
|
4885
5191
|
setBounds: setBounds$7,
|
|
4886
5192
|
setDom: setDom$7
|
|
@@ -4899,7 +5205,7 @@ const ViewletEditorCompletionDetails = {
|
|
|
4899
5205
|
|
|
4900
5206
|
// TODO aria alert
|
|
4901
5207
|
|
|
4902
|
-
const create$
|
|
5208
|
+
const create$q = () => {
|
|
4903
5209
|
const $Viewlet = document.createElement('div');
|
|
4904
5210
|
$Viewlet.className = 'Viewlet EditorError';
|
|
4905
5211
|
return {
|
|
@@ -4921,13 +5227,13 @@ const setBounds$6 = (state, x, y, width, height) => {
|
|
|
4921
5227
|
|
|
4922
5228
|
const ViewletEditorError = {
|
|
4923
5229
|
__proto__: null,
|
|
4924
|
-
create: create$
|
|
5230
|
+
create: create$q,
|
|
4925
5231
|
setBounds: setBounds$6,
|
|
4926
5232
|
setDom: setDom$6
|
|
4927
5233
|
};
|
|
4928
5234
|
|
|
4929
5235
|
const returnValue$4 = true;
|
|
4930
|
-
const handleSashPointerDown$2 = create$
|
|
5236
|
+
const handleSashPointerDown$2 = create$w(event => {
|
|
4931
5237
|
const {
|
|
4932
5238
|
clientX,
|
|
4933
5239
|
clientY
|
|
@@ -5080,7 +5386,7 @@ const handleFocus$7 = event => {
|
|
|
5080
5386
|
handleFocus$9(uid);
|
|
5081
5387
|
};
|
|
5082
5388
|
|
|
5083
|
-
const create$
|
|
5389
|
+
const create$p = () => {
|
|
5084
5390
|
const $Viewlet = document.createElement('div');
|
|
5085
5391
|
$Viewlet.className = 'Viewlet EditorImage';
|
|
5086
5392
|
return {
|
|
@@ -5097,7 +5403,7 @@ const attachEvents$7 = state => {
|
|
|
5097
5403
|
[ContextMenu]: handleContextMenu$6,
|
|
5098
5404
|
[FocusIn]: handleFocus$7
|
|
5099
5405
|
});
|
|
5100
|
-
$Viewlet.addEventListener(Error$
|
|
5406
|
+
$Viewlet.addEventListener(Error$2, handleError$6, Capture);
|
|
5101
5407
|
$Viewlet.addEventListener(Wheel, handleWheel$1, Passive);
|
|
5102
5408
|
};
|
|
5103
5409
|
const setTransform = (state, transform) => {
|
|
@@ -5123,13 +5429,13 @@ const setDom$4 = (state, dom) => {
|
|
|
5123
5429
|
const ViewletEditorImage = {
|
|
5124
5430
|
__proto__: null,
|
|
5125
5431
|
attachEvents: attachEvents$7,
|
|
5126
|
-
create: create$
|
|
5432
|
+
create: create$p,
|
|
5127
5433
|
setDom: setDom$4,
|
|
5128
5434
|
setDragging,
|
|
5129
5435
|
setTransform
|
|
5130
5436
|
};
|
|
5131
5437
|
|
|
5132
|
-
const create$
|
|
5438
|
+
const create$o = () => {
|
|
5133
5439
|
const $Viewlet = document.createElement('div');
|
|
5134
5440
|
$Viewlet.className = 'Viewlet EditorText';
|
|
5135
5441
|
$Viewlet.textContent = 'loading...';
|
|
@@ -5146,7 +5452,7 @@ const refresh$3 = (state, context) => {
|
|
|
5146
5452
|
|
|
5147
5453
|
const ViewletEditorPlainText = {
|
|
5148
5454
|
__proto__: null,
|
|
5149
|
-
create: create$
|
|
5455
|
+
create: create$o,
|
|
5150
5456
|
dispose: dispose$d,
|
|
5151
5457
|
refresh: refresh$3
|
|
5152
5458
|
};
|
|
@@ -5440,7 +5746,7 @@ const handlePaste = event => {
|
|
|
5440
5746
|
const text = getText(clipboardData);
|
|
5441
5747
|
return ['paste', text];
|
|
5442
5748
|
};
|
|
5443
|
-
const handleScrollBarVerticalPointerDown = create$
|
|
5749
|
+
const handleScrollBarVerticalPointerDown = create$w(event => {
|
|
5444
5750
|
const {
|
|
5445
5751
|
clientY
|
|
5446
5752
|
} = event;
|
|
@@ -5563,7 +5869,7 @@ const setLineInfos = (state, dom) => {
|
|
|
5563
5869
|
// 1. create -> only create dom elements
|
|
5564
5870
|
// 2. render -> fill elements with attributes and data
|
|
5565
5871
|
// that way all dom nodes can be recycled
|
|
5566
|
-
const create$
|
|
5872
|
+
const create$n = () => {
|
|
5567
5873
|
const $EditorInput = document.createElement('textarea');
|
|
5568
5874
|
$EditorInput.className = 'EditorInput';
|
|
5569
5875
|
$EditorInput.ariaAutoComplete = List;
|
|
@@ -5730,7 +6036,7 @@ const setDecorationsDom$1 = (state, decorations) => {
|
|
|
5730
6036
|
setDecorationsDom$2(state, decorations);
|
|
5731
6037
|
};
|
|
5732
6038
|
|
|
5733
|
-
const create$
|
|
6039
|
+
const create$m = create$n;
|
|
5734
6040
|
const setText$1 = setText$2;
|
|
5735
6041
|
const setSelections = setSelections$1;
|
|
5736
6042
|
const setIncrementalEdits = setIncrementalEdits$1;
|
|
@@ -5772,7 +6078,7 @@ const setDecorationsDom = setDecorationsDom$1;
|
|
|
5772
6078
|
|
|
5773
6079
|
const ViewletEditorText = {
|
|
5774
6080
|
__proto__: null,
|
|
5775
|
-
create: create$
|
|
6081
|
+
create: create$m,
|
|
5776
6082
|
focus: focus$e,
|
|
5777
6083
|
handleError: handleError$5,
|
|
5778
6084
|
hideOverlayMessage,
|
|
@@ -5788,7 +6094,7 @@ const ViewletEditorText = {
|
|
|
5788
6094
|
showOverlayMessage
|
|
5789
6095
|
};
|
|
5790
6096
|
|
|
5791
|
-
const create$
|
|
6097
|
+
const create$l = () => {
|
|
5792
6098
|
const $Viewlet = document.createElement('div');
|
|
5793
6099
|
$Viewlet.className = 'Viewlet EditorTextError';
|
|
5794
6100
|
return {
|
|
@@ -5804,11 +6110,11 @@ const setMessage$4 = (state, message) => {
|
|
|
5804
6110
|
|
|
5805
6111
|
const ViewletEditorTextError = {
|
|
5806
6112
|
__proto__: null,
|
|
5807
|
-
create: create$
|
|
6113
|
+
create: create$l,
|
|
5808
6114
|
setMessage: setMessage$4
|
|
5809
6115
|
};
|
|
5810
6116
|
|
|
5811
|
-
const create$
|
|
6117
|
+
const create$k = () => {
|
|
5812
6118
|
const $Viewlet = document.createElement('div');
|
|
5813
6119
|
$Viewlet.className = 'Viewlet EditorWidgetError EditorOverlayMessage';
|
|
5814
6120
|
return {
|
|
@@ -5831,12 +6137,12 @@ const setBounds$3 = (state, x, y, width, height) => {
|
|
|
5831
6137
|
|
|
5832
6138
|
const ViewletEditorWidgetError = {
|
|
5833
6139
|
__proto__: null,
|
|
5834
|
-
create: create$
|
|
6140
|
+
create: create$k,
|
|
5835
6141
|
setBounds: setBounds$3,
|
|
5836
6142
|
setMessage: setMessage$3
|
|
5837
6143
|
};
|
|
5838
6144
|
|
|
5839
|
-
const create$
|
|
6145
|
+
const create$j = () => {
|
|
5840
6146
|
const $Viewlet = document.createElement('div');
|
|
5841
6147
|
$Viewlet.dataset.viewlet = 'Empty';
|
|
5842
6148
|
$Viewlet.className = 'Viewlet';
|
|
@@ -5850,13 +6156,13 @@ const dispose$b = state => {};
|
|
|
5850
6156
|
|
|
5851
6157
|
const ViewletEmpty = {
|
|
5852
6158
|
__proto__: null,
|
|
5853
|
-
create: create$
|
|
6159
|
+
create: create$j,
|
|
5854
6160
|
dispose: dispose$b,
|
|
5855
6161
|
focus: focus$d,
|
|
5856
6162
|
refresh: refresh$2
|
|
5857
6163
|
};
|
|
5858
6164
|
|
|
5859
|
-
const create$
|
|
6165
|
+
const create$i = () => {
|
|
5860
6166
|
const $Viewlet = document.createElement('div');
|
|
5861
6167
|
$Viewlet.className = 'Viewlet EmptyEditor';
|
|
5862
6168
|
return {
|
|
@@ -5866,10 +6172,10 @@ const create$n = () => {
|
|
|
5866
6172
|
|
|
5867
6173
|
const ViewletEmptyEditor = {
|
|
5868
6174
|
__proto__: null,
|
|
5869
|
-
create: create$
|
|
6175
|
+
create: create$i
|
|
5870
6176
|
};
|
|
5871
6177
|
|
|
5872
|
-
const create$
|
|
6178
|
+
const create$h = () => {
|
|
5873
6179
|
const $Viewlet = document.createElement('div');
|
|
5874
6180
|
$Viewlet.className = 'Viewlet Error';
|
|
5875
6181
|
return {
|
|
@@ -5885,7 +6191,7 @@ const setMessage$2 = (state, message) => {
|
|
|
5885
6191
|
|
|
5886
6192
|
const ViewletError = {
|
|
5887
6193
|
__proto__: null,
|
|
5888
|
-
create: create$
|
|
6194
|
+
create: create$h,
|
|
5889
6195
|
setMessage: setMessage$2
|
|
5890
6196
|
};
|
|
5891
6197
|
|
|
@@ -5997,7 +6303,7 @@ const handleTouchEnd = event => {
|
|
|
5997
6303
|
|
|
5998
6304
|
// based on https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/extensions/browser/extensionsList.ts (License MIT)
|
|
5999
6305
|
|
|
6000
|
-
const create$
|
|
6306
|
+
const create$g = () => {
|
|
6001
6307
|
const $ExtensionHeader = document.createElement('div');
|
|
6002
6308
|
$ExtensionHeader.className = 'ExtensionHeader';
|
|
6003
6309
|
|
|
@@ -6142,7 +6448,7 @@ const ViewletExtensions = {
|
|
|
6142
6448
|
__proto__: null,
|
|
6143
6449
|
attachEvents: attachEvents$6,
|
|
6144
6450
|
closeSuggest,
|
|
6145
|
-
create: create$
|
|
6451
|
+
create: create$g,
|
|
6146
6452
|
dispose: dispose$a,
|
|
6147
6453
|
focus: focus$c,
|
|
6148
6454
|
handleError: handleError$4,
|
|
@@ -6247,7 +6553,7 @@ const ViewletFindWidgetEvents = {
|
|
|
6247
6553
|
returnValue: returnValue$3
|
|
6248
6554
|
};
|
|
6249
6555
|
|
|
6250
|
-
const create$
|
|
6556
|
+
const create$f = () => {
|
|
6251
6557
|
const $Viewlet = document.createElement('div');
|
|
6252
6558
|
$Viewlet.className = 'Viewlet FindWidget';
|
|
6253
6559
|
$Viewlet.role = Group;
|
|
@@ -6310,7 +6616,7 @@ const ViewletFindWidget = {
|
|
|
6310
6616
|
__proto__: null,
|
|
6311
6617
|
Events: Events$3,
|
|
6312
6618
|
appendWidget: appendWidget$1,
|
|
6313
|
-
create: create$
|
|
6619
|
+
create: create$f,
|
|
6314
6620
|
dispose: dispose$9,
|
|
6315
6621
|
focus: focus$b,
|
|
6316
6622
|
setBounds: setBounds$2,
|
|
@@ -6965,7 +7271,7 @@ const handleBlur$3 = () => {
|
|
|
6965
7271
|
const handleKeyDown$1 = handleKeyDown$2;
|
|
6966
7272
|
const handleKeyUp = handleKeyUp$1;
|
|
6967
7273
|
|
|
6968
|
-
const create$
|
|
7274
|
+
const create$e = () => {
|
|
6969
7275
|
// TODO use aria role splitter once supported https://github.com/w3c/aria/issues/1348
|
|
6970
7276
|
const $SashSideBar = document.createElement('div');
|
|
6971
7277
|
$SashSideBar.className = 'Viewlet Sash SashVertical';
|
|
@@ -7021,7 +7327,7 @@ const setSashes = (state, sashSideBar, sashPanel) => {
|
|
|
7021
7327
|
const ViewletLayout = {
|
|
7022
7328
|
__proto__: null,
|
|
7023
7329
|
attachEvents: attachEvents$5,
|
|
7024
|
-
create: create$
|
|
7330
|
+
create: create$e,
|
|
7025
7331
|
setSashes
|
|
7026
7332
|
};
|
|
7027
7333
|
|
|
@@ -7116,7 +7422,7 @@ const handleContextMenu$3 = event => {
|
|
|
7116
7422
|
};
|
|
7117
7423
|
|
|
7118
7424
|
// TODO Main should not be bound to Editor -> Lazy load Editor
|
|
7119
|
-
const create$
|
|
7425
|
+
const create$d = () => {
|
|
7120
7426
|
const $Viewlet = document.createElement('div');
|
|
7121
7427
|
$Viewlet.id = 'Main';
|
|
7122
7428
|
$Viewlet.className = 'Viewlet Main';
|
|
@@ -7216,7 +7522,7 @@ const ViewletMain = {
|
|
|
7216
7522
|
attachEvents: attachEvents$4,
|
|
7217
7523
|
closeAllViewlets,
|
|
7218
7524
|
closeViewletAndTab,
|
|
7219
|
-
create: create$
|
|
7525
|
+
create: create$d,
|
|
7220
7526
|
dispose: dispose$8,
|
|
7221
7527
|
focus: focus$9,
|
|
7222
7528
|
highlightDragOver,
|
|
@@ -7293,7 +7599,7 @@ const handleTabsContextMenu = event => {
|
|
|
7293
7599
|
handleTabContextMenu(uid, clientX, clientY);
|
|
7294
7600
|
};
|
|
7295
7601
|
|
|
7296
|
-
const create$
|
|
7602
|
+
const create$c = () => {
|
|
7297
7603
|
const $MainTabs = document.createElement('div');
|
|
7298
7604
|
$MainTabs.className = 'Viewlet MainTabs';
|
|
7299
7605
|
$MainTabs.role = TabList;
|
|
@@ -7342,7 +7648,7 @@ const setHighlight = (state, highlightLeft) => {
|
|
|
7342
7648
|
const ViewletMainTabs = {
|
|
7343
7649
|
__proto__: null,
|
|
7344
7650
|
attachEvents: attachEvents$3,
|
|
7345
|
-
create: create$
|
|
7651
|
+
create: create$c,
|
|
7346
7652
|
setHighlight,
|
|
7347
7653
|
setScrollLeft,
|
|
7348
7654
|
setTabsDom: setTabsDom$2
|
|
@@ -7365,7 +7671,7 @@ const EditorPlainText = 'EditorPlainText';
|
|
|
7365
7671
|
const EditorText = 'Editor';
|
|
7366
7672
|
const EditorWidgetError = 'EditorWidgetError';
|
|
7367
7673
|
const Empty = 'Empty';
|
|
7368
|
-
const Error$
|
|
7674
|
+
const Error$1 = 'Error';
|
|
7369
7675
|
const Extensions = 'Extensions';
|
|
7370
7676
|
const FindWidget = 'FindWidget';
|
|
7371
7677
|
const ImagePreview = 'ImagePreview';
|
|
@@ -7403,7 +7709,7 @@ const EditorTextError = 'EditorTextError';
|
|
|
7403
7709
|
const EditorRename = 'EditorRename';
|
|
7404
7710
|
const EditorCodeGenerator = 'EditorCodeGenerator';
|
|
7405
7711
|
|
|
7406
|
-
const create$
|
|
7712
|
+
const create$b = () => {
|
|
7407
7713
|
const $ViewletOutputContent = document.createElement('div');
|
|
7408
7714
|
$ViewletOutputContent.className = 'OutputContent';
|
|
7409
7715
|
$ViewletOutputContent.role = Log;
|
|
@@ -7455,7 +7761,7 @@ const dispose$7 = state => {};
|
|
|
7455
7761
|
const ViewletOutput = {
|
|
7456
7762
|
__proto__: null,
|
|
7457
7763
|
clear: clear$1,
|
|
7458
|
-
create: create$
|
|
7764
|
+
create: create$b,
|
|
7459
7765
|
dispose: dispose$7,
|
|
7460
7766
|
disposeFindWidget,
|
|
7461
7767
|
focus: focus$8,
|
|
@@ -7516,7 +7822,7 @@ const UiStrings = {
|
|
|
7516
7822
|
Close: 'Close',
|
|
7517
7823
|
Maximize: 'Maximize'
|
|
7518
7824
|
};
|
|
7519
|
-
const create$
|
|
7825
|
+
const create$a = () => {
|
|
7520
7826
|
const $PanelTabs = document.createElement('div');
|
|
7521
7827
|
$PanelTabs.className = 'PanelTabs';
|
|
7522
7828
|
$PanelTabs.role = TabList;
|
|
@@ -7629,7 +7935,7 @@ const setActionsDom$1 = (state, actions, childUid) => {
|
|
|
7629
7935
|
const ViewletPanel = {
|
|
7630
7936
|
__proto__: null,
|
|
7631
7937
|
attachEvents: attachEvents$2,
|
|
7632
|
-
create: create$
|
|
7938
|
+
create: create$a,
|
|
7633
7939
|
dispose: dispose$6,
|
|
7634
7940
|
focus: focus$7,
|
|
7635
7941
|
setActionsDom: setActionsDom$1,
|
|
@@ -7720,7 +8026,7 @@ const handleLoadedMetaData = event => {
|
|
|
7720
8026
|
target.play();
|
|
7721
8027
|
};
|
|
7722
8028
|
|
|
7723
|
-
const create$
|
|
8029
|
+
const create$9 = () => {
|
|
7724
8030
|
const $Viewlet = document.createElement('div');
|
|
7725
8031
|
$Viewlet.className = 'Viewlet ScreenCapture';
|
|
7726
8032
|
return {
|
|
@@ -7740,7 +8046,7 @@ const setScreenCapture = (state, id) => {
|
|
|
7740
8046
|
|
|
7741
8047
|
const ViewletScreenCapture = {
|
|
7742
8048
|
__proto__: null,
|
|
7743
|
-
create: create$
|
|
8049
|
+
create: create$9,
|
|
7744
8050
|
setScreenCapture
|
|
7745
8051
|
};
|
|
7746
8052
|
|
|
@@ -7760,7 +8066,7 @@ const handleHeaderClick = event => {
|
|
|
7760
8066
|
}
|
|
7761
8067
|
};
|
|
7762
8068
|
|
|
7763
|
-
const create$
|
|
8069
|
+
const create$8 = () => {
|
|
7764
8070
|
const $SideBarTitleAreaTitle = document.createElement('h2');
|
|
7765
8071
|
$SideBarTitleAreaTitle.className = 'SideBarTitleAreaTitle';
|
|
7766
8072
|
const $SideBarTitleArea = document.createElement('div');
|
|
@@ -7824,7 +8130,7 @@ const focus$5 = async () => {
|
|
|
7824
8130
|
const ViewletSideBar = {
|
|
7825
8131
|
__proto__: null,
|
|
7826
8132
|
attachEvents: attachEvents$1,
|
|
7827
|
-
create: create$
|
|
8133
|
+
create: create$8,
|
|
7828
8134
|
dispose: dispose$5,
|
|
7829
8135
|
focus: focus$5,
|
|
7830
8136
|
setActionsDom,
|
|
@@ -8025,7 +8331,7 @@ const ViewletStatusBarEvents = {
|
|
|
8025
8331
|
handleClick: handleClick$2
|
|
8026
8332
|
};
|
|
8027
8333
|
|
|
8028
|
-
const create$
|
|
8334
|
+
const create$7 = () => {
|
|
8029
8335
|
const $Viewlet = document.createElement('div');
|
|
8030
8336
|
$Viewlet.id = 'StatusBar';
|
|
8031
8337
|
$Viewlet.className = 'Viewlet StatusBar';
|
|
@@ -8054,7 +8360,7 @@ const focus$3 = state => {
|
|
|
8054
8360
|
|
|
8055
8361
|
const ViewletStatusBar = {
|
|
8056
8362
|
__proto__: null,
|
|
8057
|
-
create: create$
|
|
8363
|
+
create: create$7,
|
|
8058
8364
|
focus: focus$3,
|
|
8059
8365
|
setDom: setDom$2
|
|
8060
8366
|
};
|
|
@@ -8085,7 +8391,7 @@ const handleClickTab = event => {
|
|
|
8085
8391
|
handleClickTab$2(uid, index);
|
|
8086
8392
|
};
|
|
8087
8393
|
|
|
8088
|
-
const create$
|
|
8394
|
+
const create$6 = () => {
|
|
8089
8395
|
const $Viewlet = document.createElement('div');
|
|
8090
8396
|
$Viewlet.className = 'Viewlet Terminals';
|
|
8091
8397
|
return {
|
|
@@ -8112,7 +8418,7 @@ const setTabsDom = (state, dom) => {
|
|
|
8112
8418
|
|
|
8113
8419
|
const ViewletTerminals = {
|
|
8114
8420
|
__proto__: null,
|
|
8115
|
-
create: create$
|
|
8421
|
+
create: create$6,
|
|
8116
8422
|
setTabsDom
|
|
8117
8423
|
};
|
|
8118
8424
|
|
|
@@ -8126,7 +8432,7 @@ const handleContextMenu$1 = event => {
|
|
|
8126
8432
|
return ['handleContextMenu', button, clientX, clientY];
|
|
8127
8433
|
};
|
|
8128
8434
|
|
|
8129
|
-
const create$
|
|
8435
|
+
const create$5 = () => {
|
|
8130
8436
|
// TODO set aria label for title bar menu
|
|
8131
8437
|
// TODO add tests for aria properties
|
|
8132
8438
|
const $Viewlet = document.createElement('div');
|
|
@@ -8162,7 +8468,7 @@ const setFocused = (state, isFocused) => {
|
|
|
8162
8468
|
const ViewletTitleBar = {
|
|
8163
8469
|
__proto__: null,
|
|
8164
8470
|
attachEvents,
|
|
8165
|
-
create: create$
|
|
8471
|
+
create: create$5,
|
|
8166
8472
|
setFocused
|
|
8167
8473
|
};
|
|
8168
8474
|
|
|
@@ -8537,7 +8843,7 @@ const ViewletTitleBarMenuBar = {
|
|
|
8537
8843
|
setMenus
|
|
8538
8844
|
};
|
|
8539
8845
|
|
|
8540
|
-
const create$
|
|
8846
|
+
const create$4 = () => {
|
|
8541
8847
|
const $Viewlet = document.createElement('div');
|
|
8542
8848
|
$Viewlet.className = 'Viewlet TitleBarTitle';
|
|
8543
8849
|
return {
|
|
@@ -8553,7 +8859,7 @@ const setDom$1 = (state, dom) => {
|
|
|
8553
8859
|
|
|
8554
8860
|
const ViewletTitleBarTitle = {
|
|
8555
8861
|
__proto__: null,
|
|
8556
|
-
create: create$
|
|
8862
|
+
create: create$4,
|
|
8557
8863
|
setDom: setDom$1
|
|
8558
8864
|
};
|
|
8559
8865
|
|
|
@@ -8739,7 +9045,7 @@ const load$1 = moduleId => {
|
|
|
8739
9045
|
return ViewletEditorWidgetError;
|
|
8740
9046
|
case Empty:
|
|
8741
9047
|
return ViewletEmpty;
|
|
8742
|
-
case Error$
|
|
9048
|
+
case Error$1:
|
|
8743
9049
|
return ViewletError;
|
|
8744
9050
|
case Extensions:
|
|
8745
9051
|
return ViewletExtensions;
|
|
@@ -8816,7 +9122,7 @@ const load$1 = moduleId => {
|
|
|
8816
9122
|
}
|
|
8817
9123
|
};
|
|
8818
9124
|
|
|
8819
|
-
const create$
|
|
9125
|
+
const create$3 = (id, uid = id) => {
|
|
8820
9126
|
const module = state$1.modules[id];
|
|
8821
9127
|
if (!module) {
|
|
8822
9128
|
throw new Error(`module not found: ${id}`);
|
|
@@ -9077,7 +9383,7 @@ const sendMultiple = commands => {
|
|
|
9077
9383
|
}
|
|
9078
9384
|
case 'Viewlet.create':
|
|
9079
9385
|
{
|
|
9080
|
-
create$
|
|
9386
|
+
create$3(viewletId, method);
|
|
9081
9387
|
break;
|
|
9082
9388
|
}
|
|
9083
9389
|
case 'Viewlet.createFunctionalRoot':
|
|
@@ -9135,6 +9441,10 @@ const sendMultiple = commands => {
|
|
|
9135
9441
|
case 'Viewlet.addKeyBindings':
|
|
9136
9442
|
addKeyBindings(viewletId, method);
|
|
9137
9443
|
break;
|
|
9444
|
+
case 'Viewlet.setProperty':
|
|
9445
|
+
// @ts-ignore
|
|
9446
|
+
setProperty(viewletId, method, ...args);
|
|
9447
|
+
break;
|
|
9138
9448
|
case 'Viewlet.removeKeyBindings':
|
|
9139
9449
|
removeKeyBindings(viewletId);
|
|
9140
9450
|
break;
|
|
@@ -9323,7 +9633,7 @@ const appendToBody = childId => {
|
|
|
9323
9633
|
const getFn = command => {
|
|
9324
9634
|
switch (command) {
|
|
9325
9635
|
case 'Viewlet.create':
|
|
9326
|
-
return create$
|
|
9636
|
+
return create$3;
|
|
9327
9637
|
case 'Viewlet.send':
|
|
9328
9638
|
return invoke;
|
|
9329
9639
|
case 'Viewlet.show':
|
|
@@ -9366,6 +9676,8 @@ const getFn = command => {
|
|
|
9366
9676
|
return setDragData;
|
|
9367
9677
|
case 'Viewlet.focusSelector':
|
|
9368
9678
|
return focusSelector;
|
|
9679
|
+
case 'Viewlet.setProperty':
|
|
9680
|
+
return setProperty;
|
|
9369
9681
|
case 'Css.addCssStyleSheet':
|
|
9370
9682
|
case 'Viewlet.addCss':
|
|
9371
9683
|
case 'Viewlet.setCss':
|
|
@@ -9399,6 +9711,15 @@ const setBounds$1 = (id, left, top, width, height) => {
|
|
|
9399
9711
|
const $Viewlet = instance.state.$Viewlet;
|
|
9400
9712
|
setBounds$a($Viewlet, left, top, width, height);
|
|
9401
9713
|
};
|
|
9714
|
+
const setProperty = (id, selector, property, value) => {
|
|
9715
|
+
const instance = state$1.instances[id];
|
|
9716
|
+
if (!instance) {
|
|
9717
|
+
return;
|
|
9718
|
+
}
|
|
9719
|
+
const $Viewlet = instance.state.$Viewlet;
|
|
9720
|
+
const $Element = $Viewlet.querySelector(selector);
|
|
9721
|
+
$Element[property] = value;
|
|
9722
|
+
};
|
|
9402
9723
|
|
|
9403
9724
|
const LocalStorage = 1;
|
|
9404
9725
|
const SessionStorage = 2;
|
|
@@ -9502,29 +9823,9 @@ const handleMessagePort = async port => {
|
|
|
9502
9823
|
|
|
9503
9824
|
const set = ($Iframe, permissionPolicy) => {
|
|
9504
9825
|
if (permissionPolicy === undefined) {
|
|
9505
|
-
return;
|
|
9506
|
-
}
|
|
9507
|
-
$Iframe.allow = permissionPolicy;
|
|
9508
|
-
};
|
|
9509
|
-
|
|
9510
|
-
const withResolvers = () => {
|
|
9511
|
-
/**
|
|
9512
|
-
* @type {any}
|
|
9513
|
-
*/
|
|
9514
|
-
let _resolve;
|
|
9515
|
-
/**
|
|
9516
|
-
* @type {any}
|
|
9517
|
-
*/
|
|
9518
|
-
let _reject;
|
|
9519
|
-
const promise = new Promise((resolve, reject) => {
|
|
9520
|
-
_resolve = resolve;
|
|
9521
|
-
_reject = reject;
|
|
9522
|
-
});
|
|
9523
|
-
return {
|
|
9524
|
-
resolve: _resolve,
|
|
9525
|
-
reject: _reject,
|
|
9526
|
-
promise
|
|
9527
|
-
};
|
|
9826
|
+
return;
|
|
9827
|
+
}
|
|
9828
|
+
$Iframe.allow = permissionPolicy;
|
|
9528
9829
|
};
|
|
9529
9830
|
|
|
9530
9831
|
const waitForFrameToLoad = $Frame => {
|
|
@@ -9539,7 +9840,7 @@ const waitForFrameToLoad = $Frame => {
|
|
|
9539
9840
|
};
|
|
9540
9841
|
|
|
9541
9842
|
// TODO could use browser view when running in electron
|
|
9542
|
-
const create$
|
|
9843
|
+
const create$2 = async (uid, src, sandbox, csp, credentialless, permissionPolicy, title) => {
|
|
9543
9844
|
const $Iframe = document.createElement('iframe');
|
|
9544
9845
|
setIframeCredentialless($Iframe, credentialless);
|
|
9545
9846
|
setIframeCsp($Iframe, csp);
|
|
@@ -9620,7 +9921,7 @@ const commandMap = {
|
|
|
9620
9921
|
'GetFilePathElectron.getFilePathElectron': getFilePathElectron,
|
|
9621
9922
|
'HandleMessagePort.handleMessagePort': handleMessagePort,
|
|
9622
9923
|
'InitData.getInitData': getInitData,
|
|
9623
|
-
'IpcParent.create': create$
|
|
9924
|
+
'IpcParent.create': create$B,
|
|
9624
9925
|
'KeyBindings.setIdentifiers': setIdentifiers,
|
|
9625
9926
|
'Layout.getBounds': getBounds,
|
|
9626
9927
|
'Location.getHref': getHref,
|
|
@@ -9635,10 +9936,10 @@ const commandMap = {
|
|
|
9635
9936
|
'Menu.showControlled': showControlled,
|
|
9636
9937
|
'Menu.showMenu': showMenu,
|
|
9637
9938
|
'Meta.setThemeColor': setThemeColor,
|
|
9638
|
-
'Notification.create': create$
|
|
9939
|
+
'Notification.create': create$A,
|
|
9639
9940
|
'Notification.createWithOptions': createWithOptions,
|
|
9640
9941
|
'Notification.dispose': dispose$j,
|
|
9641
|
-
'OffscreenCanvas.create': create$
|
|
9942
|
+
'OffscreenCanvas.create': create$z,
|
|
9642
9943
|
'Open.openUrl': openUrl,
|
|
9643
9944
|
'Performance.getMemory': getMemory,
|
|
9644
9945
|
'Performance.measureUserAgentSpecificMemory': measureUserAgentSpecificMemory,
|
|
@@ -9677,7 +9978,7 @@ const commandMap = {
|
|
|
9677
9978
|
'WebStorage.setItem': setItem,
|
|
9678
9979
|
'WebStorage.setJsonObjects': setJsonObjects,
|
|
9679
9980
|
'WebView.appendOnly': appendOnly,
|
|
9680
|
-
'WebView.create': create$
|
|
9981
|
+
'WebView.create': create$2,
|
|
9681
9982
|
'WebView.dispose': dispose$2,
|
|
9682
9983
|
'WebView.load': load,
|
|
9683
9984
|
'WebView.loadOnly': loadOnly,
|
|
@@ -9714,7 +10015,7 @@ const getConfiguredEditorWorkerUrl = () => {
|
|
|
9714
10015
|
const editorWorkerUrl = getConfiguredEditorWorkerUrl() || `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/editor-worker/dist/editorWorkerMain.js`;
|
|
9715
10016
|
|
|
9716
10017
|
const launchEditorWorker = async port => {
|
|
9717
|
-
const ipc = await create$
|
|
10018
|
+
const ipc = await create$B({
|
|
9718
10019
|
name: 'Editor Worker',
|
|
9719
10020
|
url: editorWorkerUrl,
|
|
9720
10021
|
method: ModuleWorkerWithMessagePort,
|
|
@@ -9730,12 +10031,10 @@ const hydrate$2 = async () => {
|
|
|
9730
10031
|
} = new MessageChannel();
|
|
9731
10032
|
// TODO only launch port and send to renderer worker
|
|
9732
10033
|
const promise = launchEditorWorker(port1);
|
|
9733
|
-
set$
|
|
10034
|
+
set$7('Editor Worker', port2);
|
|
9734
10035
|
await promise;
|
|
9735
10036
|
};
|
|
9736
10037
|
|
|
9737
|
-
const isElectron = platform === Electron;
|
|
9738
|
-
|
|
9739
10038
|
const getConfiguredExtensionHostWorkerUrl = () => {
|
|
9740
10039
|
return getConfiguredWorkerUrl('extensionHostWorkerUrl');
|
|
9741
10040
|
};
|
|
@@ -9744,7 +10043,7 @@ const extensionHostWorkerUrl = getConfiguredExtensionHostWorkerUrl() || `${asset
|
|
|
9744
10043
|
|
|
9745
10044
|
const launchExtensionHostWorker = async port => {
|
|
9746
10045
|
const name = isElectron ? 'Extension Host (Electron)' : 'Extension Host';
|
|
9747
|
-
const ipc = await create$
|
|
10046
|
+
const ipc = await create$B({
|
|
9748
10047
|
name,
|
|
9749
10048
|
url: extensionHostWorkerUrl,
|
|
9750
10049
|
method: ModuleWorkerWithMessagePort,
|
|
@@ -9761,14 +10060,14 @@ const hydrate$1 = async () => {
|
|
|
9761
10060
|
// TODO only launch port and send to renderer worker
|
|
9762
10061
|
const promise = launchExtensionHostWorker(port1);
|
|
9763
10062
|
const name = isElectron ? 'Extension Host (Electron)' : 'Extension Host';
|
|
9764
|
-
set$
|
|
10063
|
+
set$7(name, port2);
|
|
9765
10064
|
await promise;
|
|
9766
10065
|
};
|
|
9767
10066
|
|
|
9768
10067
|
const syntaxHighlightingWorkerUrl = `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/syntax-highlighting-worker/dist/syntaxHighlightingWorkerMain.js`;
|
|
9769
10068
|
|
|
9770
10069
|
const launchSyntaxHighlightingWorker = async port => {
|
|
9771
|
-
const ipc = await create$
|
|
10070
|
+
const ipc = await create$B({
|
|
9772
10071
|
name: 'Syntax Highlighting Worker',
|
|
9773
10072
|
url: syntaxHighlightingWorkerUrl,
|
|
9774
10073
|
method: ModuleWorkerWithMessagePort,
|
|
@@ -9784,7 +10083,7 @@ const hydrate = async () => {
|
|
|
9784
10083
|
} = new MessageChannel();
|
|
9785
10084
|
// TODO only launch port and send to renderer worker
|
|
9786
10085
|
const promise = launchSyntaxHighlightingWorker(port1);
|
|
9787
|
-
set$
|
|
10086
|
+
set$7('Syntax Highlighting Worker', port2);
|
|
9788
10087
|
await promise;
|
|
9789
10088
|
};
|
|
9790
10089
|
|
|
@@ -9853,13 +10152,6 @@ const ViewletEditorRename = {
|
|
|
9853
10152
|
const handleContentSecurityPolicyViolation = event => {
|
|
9854
10153
|
};
|
|
9855
10154
|
|
|
9856
|
-
const NewLine = '\n';
|
|
9857
|
-
|
|
9858
|
-
const splitLines = lines => {
|
|
9859
|
-
string(lines);
|
|
9860
|
-
return lines.split(NewLine);
|
|
9861
|
-
};
|
|
9862
|
-
|
|
9863
10155
|
const RE_AT = /^\s+at/;
|
|
9864
10156
|
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
9865
10157
|
const RE_OBJECT_AS = /^\s*at Object\.\w+ \[as ([\w.]+)]/;
|
|
@@ -9936,7 +10228,7 @@ const mergeCustom = (custom, relevantStack) => {
|
|
|
9936
10228
|
};
|
|
9937
10229
|
const cleanStack = stack => {
|
|
9938
10230
|
string(stack);
|
|
9939
|
-
const lines = splitLines(stack);
|
|
10231
|
+
const lines = splitLines$2(stack);
|
|
9940
10232
|
const {
|
|
9941
10233
|
custom,
|
|
9942
10234
|
actualStack
|
|
@@ -9971,10 +10263,6 @@ const getIsFirefox = () => {
|
|
|
9971
10263
|
*/
|
|
9972
10264
|
const isFirefox = getIsFirefox();
|
|
9973
10265
|
|
|
9974
|
-
const joinLines = lines => {
|
|
9975
|
-
return lines.join(NewLine);
|
|
9976
|
-
};
|
|
9977
|
-
|
|
9978
10266
|
const getErrorMessage = error => {
|
|
9979
10267
|
if (!error) {
|
|
9980
10268
|
return `Error: ${error}`;
|
|
@@ -9998,7 +10286,7 @@ const prepareErrorMessageWithCodeFrame = error => {
|
|
|
9998
10286
|
}
|
|
9999
10287
|
const message = getErrorMessage(error);
|
|
10000
10288
|
const lines = cleanStack(error.stack);
|
|
10001
|
-
const relevantStack = joinLines(lines);
|
|
10289
|
+
const relevantStack = joinLines$2(lines);
|
|
10002
10290
|
if (error.codeFrame) {
|
|
10003
10291
|
return {
|
|
10004
10292
|
message,
|
|
@@ -10182,275 +10470,6 @@ const main = async () => {
|
|
|
10182
10470
|
|
|
10183
10471
|
main();
|
|
10184
10472
|
|
|
10185
|
-
const Message = 'message';
|
|
10186
|
-
const Error$1 = 'error';
|
|
10187
|
-
|
|
10188
|
-
const getFirstEvent = (eventTarget, eventMap) => {
|
|
10189
|
-
const {
|
|
10190
|
-
resolve,
|
|
10191
|
-
promise
|
|
10192
|
-
} = withResolvers();
|
|
10193
|
-
const listenerMap = Object.create(null);
|
|
10194
|
-
const cleanup = value => {
|
|
10195
|
-
for (const event of Object.keys(eventMap)) {
|
|
10196
|
-
eventTarget.removeEventListener(event, listenerMap[event]);
|
|
10197
|
-
}
|
|
10198
|
-
resolve(value);
|
|
10199
|
-
};
|
|
10200
|
-
for (const [event, type] of Object.entries(eventMap)) {
|
|
10201
|
-
const listener = event => {
|
|
10202
|
-
cleanup({
|
|
10203
|
-
type,
|
|
10204
|
-
event
|
|
10205
|
-
});
|
|
10206
|
-
};
|
|
10207
|
-
eventTarget.addEventListener(event, listener);
|
|
10208
|
-
listenerMap[event] = listener;
|
|
10209
|
-
}
|
|
10210
|
-
return promise;
|
|
10211
|
-
};
|
|
10212
|
-
|
|
10213
|
-
/**
|
|
10214
|
-
*
|
|
10215
|
-
* @param {Worker} worker
|
|
10216
|
-
* @returns
|
|
10217
|
-
*/
|
|
10218
|
-
const getFirstWorkerEvent = worker => {
|
|
10219
|
-
return getFirstEvent(worker, {
|
|
10220
|
-
message: Message,
|
|
10221
|
-
error: Error$1
|
|
10222
|
-
});
|
|
10223
|
-
};
|
|
10224
|
-
|
|
10225
|
-
const transferrables = [];
|
|
10226
|
-
if (typeof MessagePort !== 'undefined') {
|
|
10227
|
-
transferrables.push(MessagePort);
|
|
10228
|
-
}
|
|
10229
|
-
if (typeof OffscreenCanvas !== 'undefined') {
|
|
10230
|
-
transferrables.push(OffscreenCanvas);
|
|
10231
|
-
}
|
|
10232
|
-
|
|
10233
|
-
const isTransferrable = value => {
|
|
10234
|
-
for (const fn of transferrables) {
|
|
10235
|
-
if (value instanceof fn) {
|
|
10236
|
-
return true;
|
|
10237
|
-
}
|
|
10238
|
-
}
|
|
10239
|
-
return false;
|
|
10240
|
-
};
|
|
10241
|
-
|
|
10242
|
-
const walkValue = (value, transferrables) => {
|
|
10243
|
-
if (!value) {
|
|
10244
|
-
return;
|
|
10245
|
-
}
|
|
10246
|
-
if (isTransferrable(value)) {
|
|
10247
|
-
transferrables.push(value);
|
|
10248
|
-
}
|
|
10249
|
-
if (Array.isArray(value)) {
|
|
10250
|
-
for (const item of value) {
|
|
10251
|
-
walkValue(item, transferrables);
|
|
10252
|
-
}
|
|
10253
|
-
return;
|
|
10254
|
-
}
|
|
10255
|
-
if (typeof value === 'object') {
|
|
10256
|
-
for (const property of Object.values(value)) {
|
|
10257
|
-
walkValue(property, transferrables);
|
|
10258
|
-
}
|
|
10259
|
-
}
|
|
10260
|
-
};
|
|
10261
|
-
|
|
10262
|
-
const getTransfer = value => {
|
|
10263
|
-
const transferrables = [];
|
|
10264
|
-
walkValue(value, transferrables);
|
|
10265
|
-
return transferrables;
|
|
10266
|
-
};
|
|
10267
|
-
|
|
10268
|
-
class IpcError extends Error {
|
|
10269
|
-
constructor(message) {
|
|
10270
|
-
super(message);
|
|
10271
|
-
this.name = 'IpcError';
|
|
10272
|
-
}
|
|
10273
|
-
}
|
|
10274
|
-
|
|
10275
|
-
const isErrorEvent = event => {
|
|
10276
|
-
return event instanceof ErrorEvent;
|
|
10277
|
-
};
|
|
10278
|
-
|
|
10279
|
-
class WorkerError extends Error {
|
|
10280
|
-
constructor(event) {
|
|
10281
|
-
super(event.message);
|
|
10282
|
-
const stackLines = splitLines(this.stack);
|
|
10283
|
-
const relevantLines = stackLines.slice(1);
|
|
10284
|
-
const relevant = joinLines(relevantLines);
|
|
10285
|
-
this.stack = `${event.message}
|
|
10286
|
-
at Module (${event.filename}:${event.lineno}:${event.colno})
|
|
10287
|
-
${relevant}`;
|
|
10288
|
-
}
|
|
10289
|
-
}
|
|
10290
|
-
|
|
10291
|
-
const Module = 'module';
|
|
10292
|
-
|
|
10293
|
-
const getWorkerDisplayName = name => {
|
|
10294
|
-
if (name && name.endsWith('Worker')) {
|
|
10295
|
-
return name;
|
|
10296
|
-
}
|
|
10297
|
-
return `${name} worker`;
|
|
10298
|
-
};
|
|
10299
|
-
const create$6 = async ({
|
|
10300
|
-
url,
|
|
10301
|
-
name
|
|
10302
|
-
}) => {
|
|
10303
|
-
const worker = new Worker(url, {
|
|
10304
|
-
type: Module,
|
|
10305
|
-
name
|
|
10306
|
-
});
|
|
10307
|
-
// @ts-expect-error
|
|
10308
|
-
const {
|
|
10309
|
-
type,
|
|
10310
|
-
event
|
|
10311
|
-
} = await getFirstWorkerEvent(worker);
|
|
10312
|
-
switch (type) {
|
|
10313
|
-
case Message:
|
|
10314
|
-
if (event.data !== 'ready') {
|
|
10315
|
-
throw new IpcError('unexpected first message from worker');
|
|
10316
|
-
}
|
|
10317
|
-
break;
|
|
10318
|
-
case Error$1:
|
|
10319
|
-
if (isErrorEvent(event)) {
|
|
10320
|
-
throw new WorkerError(event);
|
|
10321
|
-
}
|
|
10322
|
-
const displayName = getWorkerDisplayName(name);
|
|
10323
|
-
throw new IpcError(`Failed to start ${displayName}`);
|
|
10324
|
-
}
|
|
10325
|
-
return worker;
|
|
10326
|
-
};
|
|
10327
|
-
const getData = event => {
|
|
10328
|
-
// TODO why are some events not instance of message event?
|
|
10329
|
-
if (event instanceof MessageEvent) {
|
|
10330
|
-
return event.data;
|
|
10331
|
-
}
|
|
10332
|
-
return event;
|
|
10333
|
-
};
|
|
10334
|
-
const wrap = worker => {
|
|
10335
|
-
let handleMessage;
|
|
10336
|
-
return {
|
|
10337
|
-
get onmessage() {
|
|
10338
|
-
return handleMessage;
|
|
10339
|
-
},
|
|
10340
|
-
set onmessage(listener) {
|
|
10341
|
-
if (listener) {
|
|
10342
|
-
handleMessage = event => {
|
|
10343
|
-
const data = getData(event);
|
|
10344
|
-
listener({
|
|
10345
|
-
data,
|
|
10346
|
-
target: this
|
|
10347
|
-
});
|
|
10348
|
-
};
|
|
10349
|
-
} else {
|
|
10350
|
-
handleMessage = null;
|
|
10351
|
-
}
|
|
10352
|
-
worker.onmessage = handleMessage;
|
|
10353
|
-
},
|
|
10354
|
-
send(message) {
|
|
10355
|
-
worker.postMessage(message);
|
|
10356
|
-
},
|
|
10357
|
-
sendAndTransfer(message) {
|
|
10358
|
-
const transfer = getTransfer(message);
|
|
10359
|
-
worker.postMessage(message, transfer);
|
|
10360
|
-
}
|
|
10361
|
-
};
|
|
10362
|
-
};
|
|
10363
|
-
|
|
10364
|
-
const IpcParentWithModuleWorker = {
|
|
10365
|
-
__proto__: null,
|
|
10366
|
-
create: create$6,
|
|
10367
|
-
wrap
|
|
10368
|
-
};
|
|
10369
|
-
|
|
10370
|
-
const isMessagePort = value => {
|
|
10371
|
-
return value instanceof MessagePort;
|
|
10372
|
-
};
|
|
10373
|
-
|
|
10374
|
-
const create$5 = async ({
|
|
10375
|
-
url
|
|
10376
|
-
}) => {
|
|
10377
|
-
string(url);
|
|
10378
|
-
const portPromise = await new Promise(resolve => {
|
|
10379
|
-
globalThis.acceptPort = resolve;
|
|
10380
|
-
});
|
|
10381
|
-
await import(url);
|
|
10382
|
-
const port = await portPromise;
|
|
10383
|
-
delete globalThis.acceptPort;
|
|
10384
|
-
if (!port) {
|
|
10385
|
-
throw new IpcError('port must be defined');
|
|
10386
|
-
}
|
|
10387
|
-
if (!isMessagePort(port)) {
|
|
10388
|
-
throw new IpcError('port must be of type MessagePort');
|
|
10389
|
-
}
|
|
10390
|
-
return port;
|
|
10391
|
-
};
|
|
10392
|
-
|
|
10393
|
-
const IpcParentWithMessagePort = {
|
|
10394
|
-
__proto__: null,
|
|
10395
|
-
create: create$5
|
|
10396
|
-
};
|
|
10397
|
-
|
|
10398
|
-
const create$4 = async url => {
|
|
10399
|
-
const referencePort = await new Promise(resolve => {
|
|
10400
|
-
globalThis.acceptReferencePort = resolve;
|
|
10401
|
-
import(url);
|
|
10402
|
-
});
|
|
10403
|
-
delete globalThis.acceptReferencePort;
|
|
10404
|
-
return referencePort;
|
|
10405
|
-
};
|
|
10406
|
-
|
|
10407
|
-
const IpcParentWithReferencePort = {
|
|
10408
|
-
__proto__: null,
|
|
10409
|
-
create: create$4
|
|
10410
|
-
};
|
|
10411
|
-
|
|
10412
|
-
// TODO add test
|
|
10413
|
-
const create$3 = async ({
|
|
10414
|
-
url,
|
|
10415
|
-
name,
|
|
10416
|
-
port
|
|
10417
|
-
}) => {
|
|
10418
|
-
await ModuleWorkerWithMessagePortRpcParent.create({
|
|
10419
|
-
url,
|
|
10420
|
-
name,
|
|
10421
|
-
commandMap: {},
|
|
10422
|
-
port
|
|
10423
|
-
});
|
|
10424
|
-
return undefined;
|
|
10425
|
-
};
|
|
10426
|
-
|
|
10427
|
-
const IpcParentWithModuleWorkerWithMessagePort = {
|
|
10428
|
-
__proto__: null,
|
|
10429
|
-
create: create$3
|
|
10430
|
-
};
|
|
10431
|
-
|
|
10432
|
-
// TODO use handleIncomingIpc function
|
|
10433
|
-
const create$2 = async ({
|
|
10434
|
-
port,
|
|
10435
|
-
ipcId
|
|
10436
|
-
}) => {
|
|
10437
|
-
number(ipcId);
|
|
10438
|
-
if (!isElectron) {
|
|
10439
|
-
throw new Error('Electron api was requested but is not available');
|
|
10440
|
-
}
|
|
10441
|
-
const rpc = await ElectronWindowRpcClient.create({
|
|
10442
|
-
commandMap: {},
|
|
10443
|
-
window
|
|
10444
|
-
});
|
|
10445
|
-
const webContentsIds = await rpc.invokeAndTransfer('CreateMessagePort.createMessagePort', ipcId, port);
|
|
10446
|
-
return webContentsIds;
|
|
10447
|
-
};
|
|
10448
|
-
|
|
10449
|
-
const IpcParentWithElectron = {
|
|
10450
|
-
__proto__: null,
|
|
10451
|
-
create: create$2
|
|
10452
|
-
};
|
|
10453
|
-
|
|
10454
10473
|
const isUint8Array = value => {
|
|
10455
10474
|
return value instanceof Uint8Array;
|
|
10456
10475
|
};
|