@lvce-editor/renderer-process 14.1.0 → 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 +519 -504
- package/package.json +1 -1
|
@@ -1091,35 +1091,262 @@ const ReferencePort = 3;
|
|
|
1091
1091
|
const ModuleWorkerWithMessagePort = 4;
|
|
1092
1092
|
const Electron$1 = 5;
|
|
1093
1093
|
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
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;
|
|
1108
1138
|
}
|
|
1139
|
+
return promise;
|
|
1109
1140
|
};
|
|
1110
1141
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
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
|
+
});
|
|
1114
1152
|
};
|
|
1115
|
-
|
|
1116
|
-
|
|
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;
|
|
1117
1169
|
};
|
|
1118
|
-
|
|
1119
|
-
|
|
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
|
+
}
|
|
1120
1189
|
};
|
|
1121
|
-
|
|
1122
|
-
|
|
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
|
|
1123
1350
|
};
|
|
1124
1351
|
|
|
1125
1352
|
const normalizeLine = line => {
|
|
@@ -1138,9 +1365,9 @@ const getCombinedMessage = (error, message) => {
|
|
|
1138
1365
|
}
|
|
1139
1366
|
return stringifiedError;
|
|
1140
1367
|
};
|
|
1141
|
-
const NewLine$
|
|
1368
|
+
const NewLine$2 = '\n';
|
|
1142
1369
|
const getNewLineIndex$1 = (string, startIndex = undefined) => {
|
|
1143
|
-
return string.indexOf(NewLine$
|
|
1370
|
+
return string.indexOf(NewLine$2, startIndex);
|
|
1144
1371
|
};
|
|
1145
1372
|
const mergeStacks$1 = (parent, child) => {
|
|
1146
1373
|
if (!child) {
|
|
@@ -1178,7 +1405,7 @@ let VError$1 = class VError extends Error {
|
|
|
1178
1405
|
}
|
|
1179
1406
|
};
|
|
1180
1407
|
|
|
1181
|
-
const isMessagePort
|
|
1408
|
+
const isMessagePort = value => {
|
|
1182
1409
|
return value && value instanceof MessagePort;
|
|
1183
1410
|
};
|
|
1184
1411
|
const isMessagePortMain = value => {
|
|
@@ -1193,16 +1420,16 @@ const isInstanceOf = (value, constructorName) => {
|
|
|
1193
1420
|
const isSocket = value => {
|
|
1194
1421
|
return isInstanceOf(value, 'Socket');
|
|
1195
1422
|
};
|
|
1196
|
-
const transferrables
|
|
1197
|
-
const isTransferrable
|
|
1198
|
-
for (const fn of transferrables
|
|
1423
|
+
const transferrables = [isMessagePort, isMessagePortMain, isOffscreenCanvas, isSocket];
|
|
1424
|
+
const isTransferrable = value => {
|
|
1425
|
+
for (const fn of transferrables) {
|
|
1199
1426
|
if (fn(value)) {
|
|
1200
1427
|
return true;
|
|
1201
1428
|
}
|
|
1202
1429
|
}
|
|
1203
1430
|
return false;
|
|
1204
1431
|
};
|
|
1205
|
-
const walkValue
|
|
1432
|
+
const walkValue = (value, transferrables, isTransferrable) => {
|
|
1206
1433
|
if (!value) {
|
|
1207
1434
|
return;
|
|
1208
1435
|
}
|
|
@@ -1212,20 +1439,20 @@ const walkValue$1 = (value, transferrables, isTransferrable) => {
|
|
|
1212
1439
|
}
|
|
1213
1440
|
if (Array.isArray(value)) {
|
|
1214
1441
|
for (const item of value) {
|
|
1215
|
-
walkValue
|
|
1442
|
+
walkValue(item, transferrables, isTransferrable);
|
|
1216
1443
|
}
|
|
1217
1444
|
return;
|
|
1218
1445
|
}
|
|
1219
1446
|
if (typeof value === 'object') {
|
|
1220
1447
|
for (const property of Object.values(value)) {
|
|
1221
|
-
walkValue
|
|
1448
|
+
walkValue(property, transferrables, isTransferrable);
|
|
1222
1449
|
}
|
|
1223
1450
|
return;
|
|
1224
1451
|
}
|
|
1225
1452
|
};
|
|
1226
1453
|
const getTransferrables = value => {
|
|
1227
1454
|
const transferrables = [];
|
|
1228
|
-
walkValue
|
|
1455
|
+
walkValue(value, transferrables, isTransferrable);
|
|
1229
1456
|
return transferrables;
|
|
1230
1457
|
};
|
|
1231
1458
|
const removeValues = (value, toRemove) => {
|
|
@@ -1287,9 +1514,9 @@ class Ipc extends EventTarget {
|
|
|
1287
1514
|
const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
1288
1515
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
1289
1516
|
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
1290
|
-
const NewLine$
|
|
1291
|
-
const joinLines$
|
|
1292
|
-
return lines.join(NewLine$
|
|
1517
|
+
const NewLine$1 = '\n';
|
|
1518
|
+
const joinLines$1 = lines => {
|
|
1519
|
+
return lines.join(NewLine$1);
|
|
1293
1520
|
};
|
|
1294
1521
|
const RE_AT$1 = /^\s+at/;
|
|
1295
1522
|
const RE_AT_PROMISE_INDEX$1 = /^\s*at async Promise.all \(index \d+\)$/;
|
|
@@ -1300,7 +1527,7 @@ const getDetails$1 = lines => {
|
|
|
1300
1527
|
const index = lines.findIndex(isNormalStackLine$1);
|
|
1301
1528
|
if (index === -1) {
|
|
1302
1529
|
return {
|
|
1303
|
-
actualMessage: joinLines$
|
|
1530
|
+
actualMessage: joinLines$1(lines),
|
|
1304
1531
|
rest: []
|
|
1305
1532
|
};
|
|
1306
1533
|
}
|
|
@@ -1315,8 +1542,8 @@ const getDetails$1 = lines => {
|
|
|
1315
1542
|
rest: lines.slice(index, lastIndex)
|
|
1316
1543
|
};
|
|
1317
1544
|
};
|
|
1318
|
-
const splitLines$
|
|
1319
|
-
return lines.split(NewLine$
|
|
1545
|
+
const splitLines$1 = lines => {
|
|
1546
|
+
return lines.split(NewLine$1);
|
|
1320
1547
|
};
|
|
1321
1548
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
1322
1549
|
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
@@ -1327,7 +1554,7 @@ const isMessageCodeBlockEndIndex = line => {
|
|
|
1327
1554
|
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
1328
1555
|
};
|
|
1329
1556
|
const getMessageCodeBlock = stderr => {
|
|
1330
|
-
const lines = splitLines$
|
|
1557
|
+
const lines = splitLines$1(stderr);
|
|
1331
1558
|
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
1332
1559
|
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
1333
1560
|
const relevantLines = lines.slice(startIndex, endIndex);
|
|
@@ -1338,7 +1565,7 @@ const isModuleNotFoundMessage = line => {
|
|
|
1338
1565
|
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
1339
1566
|
};
|
|
1340
1567
|
const getModuleNotFoundError = stderr => {
|
|
1341
|
-
const lines = splitLines$
|
|
1568
|
+
const lines = splitLines$1(stderr);
|
|
1342
1569
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
1343
1570
|
const message = lines[messageIndex];
|
|
1344
1571
|
return {
|
|
@@ -1386,7 +1613,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
1386
1613
|
if (isModuleNotFoundError(stderr)) {
|
|
1387
1614
|
return getModuleNotFoundError(stderr);
|
|
1388
1615
|
}
|
|
1389
|
-
const lines = splitLines$
|
|
1616
|
+
const lines = splitLines$1(stderr);
|
|
1390
1617
|
const {
|
|
1391
1618
|
actualMessage,
|
|
1392
1619
|
rest
|
|
@@ -1397,7 +1624,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
1397
1624
|
stack: rest
|
|
1398
1625
|
};
|
|
1399
1626
|
};
|
|
1400
|
-
|
|
1627
|
+
class IpcError extends VError$1 {
|
|
1401
1628
|
// @ts-ignore
|
|
1402
1629
|
constructor(betterMessage, stdout = '', stderr = '') {
|
|
1403
1630
|
if (stdout || stderr) {
|
|
@@ -1422,7 +1649,7 @@ let IpcError$1 = class IpcError extends VError$1 {
|
|
|
1422
1649
|
// @ts-ignore
|
|
1423
1650
|
this.stderr = stderr;
|
|
1424
1651
|
}
|
|
1425
|
-
}
|
|
1652
|
+
}
|
|
1426
1653
|
const readyMessage = 'ready';
|
|
1427
1654
|
const getData$2 = event => {
|
|
1428
1655
|
return event.data;
|
|
@@ -1490,7 +1717,7 @@ const removeListener = (emitter, type, callback) => {
|
|
|
1490
1717
|
emitter.off(type, callback);
|
|
1491
1718
|
}
|
|
1492
1719
|
};
|
|
1493
|
-
const getFirstEvent
|
|
1720
|
+
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
1494
1721
|
const {
|
|
1495
1722
|
resolve,
|
|
1496
1723
|
promise
|
|
@@ -1519,13 +1746,13 @@ const create$5$2 = async ({
|
|
|
1519
1746
|
messagePort,
|
|
1520
1747
|
isMessagePortOpen
|
|
1521
1748
|
}) => {
|
|
1522
|
-
if (!isMessagePort
|
|
1523
|
-
throw new IpcError
|
|
1749
|
+
if (!isMessagePort(messagePort)) {
|
|
1750
|
+
throw new IpcError('port must be of type MessagePort');
|
|
1524
1751
|
}
|
|
1525
1752
|
if (isMessagePortOpen) {
|
|
1526
1753
|
return messagePort;
|
|
1527
1754
|
}
|
|
1528
|
-
const eventPromise = getFirstEvent
|
|
1755
|
+
const eventPromise = getFirstEvent(messagePort, {
|
|
1529
1756
|
message: Message$1
|
|
1530
1757
|
});
|
|
1531
1758
|
messagePort.start();
|
|
@@ -1534,17 +1761,17 @@ const create$5$2 = async ({
|
|
|
1534
1761
|
event
|
|
1535
1762
|
} = await eventPromise;
|
|
1536
1763
|
if (type !== Message$1) {
|
|
1537
|
-
throw new IpcError
|
|
1764
|
+
throw new IpcError('Failed to wait for ipc message');
|
|
1538
1765
|
}
|
|
1539
1766
|
if (event.data !== readyMessage) {
|
|
1540
|
-
throw new IpcError
|
|
1767
|
+
throw new IpcError('unexpected first message');
|
|
1541
1768
|
}
|
|
1542
1769
|
return messagePort;
|
|
1543
1770
|
};
|
|
1544
1771
|
const signal$1 = messagePort => {
|
|
1545
1772
|
messagePort.start();
|
|
1546
1773
|
};
|
|
1547
|
-
|
|
1774
|
+
class IpcParentWithMessagePort extends Ipc {
|
|
1548
1775
|
getData = getData$2;
|
|
1549
1776
|
send(message) {
|
|
1550
1777
|
this._rawIpc.postMessage(message);
|
|
@@ -1560,28 +1787,28 @@ let IpcParentWithMessagePort$1 = class IpcParentWithMessagePort extends Ipc {
|
|
|
1560
1787
|
this._rawIpc.addEventListener('message', callback);
|
|
1561
1788
|
}
|
|
1562
1789
|
onClose(callback) {}
|
|
1563
|
-
}
|
|
1790
|
+
}
|
|
1564
1791
|
const wrap$5 = messagePort => {
|
|
1565
|
-
return new IpcParentWithMessagePort
|
|
1792
|
+
return new IpcParentWithMessagePort(messagePort);
|
|
1566
1793
|
};
|
|
1567
|
-
const IpcParentWithMessagePort$1
|
|
1794
|
+
const IpcParentWithMessagePort$1 = {
|
|
1568
1795
|
__proto__: null,
|
|
1569
1796
|
create: create$5$2,
|
|
1570
1797
|
signal: signal$1,
|
|
1571
1798
|
wrap: wrap$5
|
|
1572
1799
|
};
|
|
1573
|
-
const Message
|
|
1800
|
+
const Message = 'message';
|
|
1574
1801
|
const Error$1$1 = 'error';
|
|
1575
|
-
const getFirstWorkerEvent
|
|
1576
|
-
return getFirstEvent
|
|
1577
|
-
message: Message
|
|
1802
|
+
const getFirstWorkerEvent = worker => {
|
|
1803
|
+
return getFirstEvent(worker, {
|
|
1804
|
+
message: Message,
|
|
1578
1805
|
error: Error$1$1
|
|
1579
1806
|
});
|
|
1580
1807
|
};
|
|
1581
|
-
const isErrorEvent
|
|
1808
|
+
const isErrorEvent = event => {
|
|
1582
1809
|
return event instanceof ErrorEvent;
|
|
1583
1810
|
};
|
|
1584
|
-
const getWorkerDisplayName
|
|
1811
|
+
const getWorkerDisplayName = name => {
|
|
1585
1812
|
if (!name) {
|
|
1586
1813
|
return '<unknown> worker';
|
|
1587
1814
|
}
|
|
@@ -1593,42 +1820,42 @@ const getWorkerDisplayName$1 = name => {
|
|
|
1593
1820
|
const tryToGetActualErrorMessage = async ({
|
|
1594
1821
|
name
|
|
1595
1822
|
}) => {
|
|
1596
|
-
const displayName = getWorkerDisplayName
|
|
1823
|
+
const displayName = getWorkerDisplayName(name);
|
|
1597
1824
|
return `Failed to start ${displayName}: Worker Launch Error`;
|
|
1598
1825
|
};
|
|
1599
|
-
|
|
1826
|
+
class WorkerError extends Error {
|
|
1600
1827
|
constructor(event) {
|
|
1601
1828
|
super(event.message);
|
|
1602
|
-
const stackLines = splitLines$
|
|
1829
|
+
const stackLines = splitLines$1(this.stack || '');
|
|
1603
1830
|
const relevantLines = stackLines.slice(1);
|
|
1604
|
-
const relevant = joinLines$
|
|
1831
|
+
const relevant = joinLines$1(relevantLines);
|
|
1605
1832
|
this.stack = `${event.message}
|
|
1606
1833
|
at Module (${event.filename}:${event.lineno}:${event.colno})
|
|
1607
1834
|
${relevant}`;
|
|
1608
1835
|
}
|
|
1609
|
-
}
|
|
1610
|
-
const Module
|
|
1836
|
+
}
|
|
1837
|
+
const Module = 'module';
|
|
1611
1838
|
const create$4$3 = async ({
|
|
1612
1839
|
url,
|
|
1613
1840
|
name
|
|
1614
1841
|
}) => {
|
|
1615
1842
|
const worker = new Worker(url, {
|
|
1616
|
-
type: Module
|
|
1843
|
+
type: Module,
|
|
1617
1844
|
name
|
|
1618
1845
|
});
|
|
1619
1846
|
const {
|
|
1620
1847
|
type,
|
|
1621
1848
|
event
|
|
1622
|
-
} = await getFirstWorkerEvent
|
|
1849
|
+
} = await getFirstWorkerEvent(worker);
|
|
1623
1850
|
switch (type) {
|
|
1624
|
-
case Message
|
|
1851
|
+
case Message:
|
|
1625
1852
|
if (event.data !== readyMessage) {
|
|
1626
|
-
throw new IpcError
|
|
1853
|
+
throw new IpcError('unexpected first message from worker');
|
|
1627
1854
|
}
|
|
1628
1855
|
break;
|
|
1629
1856
|
case Error$1$1:
|
|
1630
|
-
if (isErrorEvent
|
|
1631
|
-
throw new WorkerError
|
|
1857
|
+
if (isErrorEvent(event)) {
|
|
1858
|
+
throw new WorkerError(event);
|
|
1632
1859
|
}
|
|
1633
1860
|
const actualErrorMessage = await tryToGetActualErrorMessage({
|
|
1634
1861
|
name
|
|
@@ -1637,16 +1864,16 @@ const create$4$3 = async ({
|
|
|
1637
1864
|
}
|
|
1638
1865
|
return worker;
|
|
1639
1866
|
};
|
|
1640
|
-
const getData
|
|
1867
|
+
const getData = event => {
|
|
1641
1868
|
// TODO why are some events not instance of message event?
|
|
1642
1869
|
if (event instanceof MessageEvent) {
|
|
1643
1870
|
return event.data;
|
|
1644
1871
|
}
|
|
1645
1872
|
return event;
|
|
1646
1873
|
};
|
|
1647
|
-
|
|
1874
|
+
class IpcParentWithModuleWorker extends Ipc {
|
|
1648
1875
|
getData(event) {
|
|
1649
|
-
return getData
|
|
1876
|
+
return getData(event);
|
|
1650
1877
|
}
|
|
1651
1878
|
send(message) {
|
|
1652
1879
|
this._rawIpc.postMessage(message);
|
|
@@ -1664,11 +1891,11 @@ let IpcParentWithModuleWorker$1 = class IpcParentWithModuleWorker extends Ipc {
|
|
|
1664
1891
|
onMessage(callback) {
|
|
1665
1892
|
this._rawIpc.addEventListener('message', callback);
|
|
1666
1893
|
}
|
|
1667
|
-
}
|
|
1894
|
+
}
|
|
1668
1895
|
const wrap$4 = worker => {
|
|
1669
|
-
return new IpcParentWithModuleWorker
|
|
1896
|
+
return new IpcParentWithModuleWorker(worker);
|
|
1670
1897
|
};
|
|
1671
|
-
const IpcParentWithModuleWorker$1
|
|
1898
|
+
const IpcParentWithModuleWorker$1 = {
|
|
1672
1899
|
__proto__: null,
|
|
1673
1900
|
create: create$4$3,
|
|
1674
1901
|
wrap: wrap$4
|
|
@@ -1683,13 +1910,13 @@ const create$4$2 = (method, params) => {
|
|
|
1683
1910
|
};
|
|
1684
1911
|
};
|
|
1685
1912
|
const callbacks = Object.create(null);
|
|
1686
|
-
const set$
|
|
1913
|
+
const set$8 = (id, fn) => {
|
|
1687
1914
|
callbacks[id] = fn;
|
|
1688
1915
|
};
|
|
1689
|
-
const get$
|
|
1916
|
+
const get$7 = id => {
|
|
1690
1917
|
return callbacks[id];
|
|
1691
1918
|
};
|
|
1692
|
-
const remove$
|
|
1919
|
+
const remove$3 = id => {
|
|
1693
1920
|
delete callbacks[id];
|
|
1694
1921
|
};
|
|
1695
1922
|
let id = 0;
|
|
@@ -1702,7 +1929,7 @@ const registerPromise = () => {
|
|
|
1702
1929
|
resolve,
|
|
1703
1930
|
promise
|
|
1704
1931
|
} = Promise.withResolvers();
|
|
1705
|
-
set$
|
|
1932
|
+
set$8(id, resolve);
|
|
1706
1933
|
return {
|
|
1707
1934
|
id,
|
|
1708
1935
|
promise
|
|
@@ -1730,7 +1957,7 @@ class JsonRpcError extends Error {
|
|
|
1730
1957
|
this.name = 'JsonRpcError';
|
|
1731
1958
|
}
|
|
1732
1959
|
}
|
|
1733
|
-
const NewLine
|
|
1960
|
+
const NewLine = '\n';
|
|
1734
1961
|
const DomException = 'DOMException';
|
|
1735
1962
|
const ReferenceError$1 = 'ReferenceError';
|
|
1736
1963
|
const SyntaxError$1 = 'SyntaxError';
|
|
@@ -1775,23 +2002,23 @@ const constructError = (message, type, name) => {
|
|
|
1775
2002
|
}
|
|
1776
2003
|
return new ErrorConstructor(message);
|
|
1777
2004
|
};
|
|
1778
|
-
const joinLines
|
|
1779
|
-
return lines.join(NewLine
|
|
2005
|
+
const joinLines = lines => {
|
|
2006
|
+
return lines.join(NewLine);
|
|
1780
2007
|
};
|
|
1781
|
-
const splitLines
|
|
1782
|
-
return lines.split(NewLine
|
|
2008
|
+
const splitLines = lines => {
|
|
2009
|
+
return lines.split(NewLine);
|
|
1783
2010
|
};
|
|
1784
2011
|
const getCurrentStack = () => {
|
|
1785
|
-
const currentStack = joinLines
|
|
2012
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(2));
|
|
1786
2013
|
return currentStack;
|
|
1787
2014
|
};
|
|
1788
2015
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
1789
|
-
return string.indexOf(NewLine
|
|
2016
|
+
return string.indexOf(NewLine, startIndex);
|
|
1790
2017
|
};
|
|
1791
2018
|
const getParentStack = error => {
|
|
1792
2019
|
let parentStack = error.stack || error.data || error.message || '';
|
|
1793
2020
|
if (parentStack.startsWith(' at')) {
|
|
1794
|
-
parentStack = error.message + NewLine
|
|
2021
|
+
parentStack = error.message + NewLine + parentStack;
|
|
1795
2022
|
}
|
|
1796
2023
|
return parentStack;
|
|
1797
2024
|
};
|
|
@@ -1801,21 +2028,21 @@ const restoreJsonRpcError = error => {
|
|
|
1801
2028
|
const currentStack = getCurrentStack();
|
|
1802
2029
|
if (error && error instanceof Error) {
|
|
1803
2030
|
if (typeof error.stack === 'string') {
|
|
1804
|
-
error.stack = error.stack + NewLine
|
|
2031
|
+
error.stack = error.stack + NewLine + currentStack;
|
|
1805
2032
|
}
|
|
1806
2033
|
return error;
|
|
1807
2034
|
}
|
|
1808
2035
|
if (error && error.code && error.code === MethodNotFound) {
|
|
1809
2036
|
const restoredError = new JsonRpcError(error.message);
|
|
1810
2037
|
const parentStack = getParentStack(error);
|
|
1811
|
-
restoredError.stack = parentStack + NewLine
|
|
2038
|
+
restoredError.stack = parentStack + NewLine + currentStack;
|
|
1812
2039
|
return restoredError;
|
|
1813
2040
|
}
|
|
1814
2041
|
if (error && error.message) {
|
|
1815
2042
|
const restoredError = constructError(error.message, error.type, error.name);
|
|
1816
2043
|
if (error.data) {
|
|
1817
2044
|
if (error.data.stack && error.data.type && error.message) {
|
|
1818
|
-
restoredError.stack = error.data.type + ': ' + error.message + NewLine
|
|
2045
|
+
restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
|
|
1819
2046
|
} else if (error.data.stack) {
|
|
1820
2047
|
restoredError.stack = error.data.stack;
|
|
1821
2048
|
}
|
|
@@ -1866,14 +2093,14 @@ const warn = (...args) => {
|
|
|
1866
2093
|
console.warn(...args);
|
|
1867
2094
|
};
|
|
1868
2095
|
const resolve = (id, response) => {
|
|
1869
|
-
const fn = get$
|
|
2096
|
+
const fn = get$7(id);
|
|
1870
2097
|
if (!fn) {
|
|
1871
2098
|
console.log(response);
|
|
1872
2099
|
warn(`callback ${id} may already be disposed`);
|
|
1873
2100
|
return;
|
|
1874
2101
|
}
|
|
1875
2102
|
fn(response);
|
|
1876
|
-
remove$
|
|
2103
|
+
remove$3(id);
|
|
1877
2104
|
};
|
|
1878
2105
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
1879
2106
|
const getErrorType = prettyError => {
|
|
@@ -1929,7 +2156,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
1929
2156
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
1930
2157
|
return create$1$1(id, errorProperty);
|
|
1931
2158
|
};
|
|
1932
|
-
const create$
|
|
2159
|
+
const create$E = (message, result) => {
|
|
1933
2160
|
return {
|
|
1934
2161
|
jsonrpc: Two,
|
|
1935
2162
|
id: message.id,
|
|
@@ -1938,7 +2165,7 @@ const create$H = (message, result) => {
|
|
|
1938
2165
|
};
|
|
1939
2166
|
const getSuccessResponse = (message, result) => {
|
|
1940
2167
|
const resultProperty = result ?? null;
|
|
1941
|
-
return create$
|
|
2168
|
+
return create$E(message, resultProperty);
|
|
1942
2169
|
};
|
|
1943
2170
|
const getErrorResponseSimple = (id, error) => {
|
|
1944
2171
|
return {
|
|
@@ -2145,14 +2372,14 @@ const create$b$1 = async ({
|
|
|
2145
2372
|
}) => {
|
|
2146
2373
|
// TODO create a commandMap per rpc instance
|
|
2147
2374
|
register(commandMap);
|
|
2148
|
-
const worker = await IpcParentWithModuleWorker$1
|
|
2375
|
+
const worker = await IpcParentWithModuleWorker$1.create({
|
|
2149
2376
|
url,
|
|
2150
2377
|
name
|
|
2151
2378
|
});
|
|
2152
2379
|
if (!isWorker(worker)) {
|
|
2153
2380
|
throw new Error(`worker must be of type Worker`);
|
|
2154
2381
|
}
|
|
2155
|
-
const ipc = IpcParentWithModuleWorker$1
|
|
2382
|
+
const ipc = IpcParentWithModuleWorker$1.wrap(worker);
|
|
2156
2383
|
handleIpc(ipc);
|
|
2157
2384
|
const workerRpc = createRpc(ipc);
|
|
2158
2385
|
return workerRpc;
|
|
@@ -2169,14 +2396,14 @@ const create$a$1 = async ({
|
|
|
2169
2396
|
}) => {
|
|
2170
2397
|
// TODO create a commandMap per rpc instance
|
|
2171
2398
|
register(commandMap);
|
|
2172
|
-
const worker = await IpcParentWithModuleWorker$1
|
|
2399
|
+
const worker = await IpcParentWithModuleWorker$1.create({
|
|
2173
2400
|
url,
|
|
2174
2401
|
name
|
|
2175
2402
|
});
|
|
2176
2403
|
if (!isWorker(worker)) {
|
|
2177
2404
|
throw new Error(`worker must be of type Worker`);
|
|
2178
2405
|
}
|
|
2179
|
-
const ipc = IpcParentWithModuleWorker$1
|
|
2406
|
+
const ipc = IpcParentWithModuleWorker$1.wrap(worker);
|
|
2180
2407
|
handleIpc(ipc);
|
|
2181
2408
|
const workerRpc = createRpc(ipc);
|
|
2182
2409
|
await workerRpc.invokeAndTransfer('initialize', 'message-port', port);
|
|
@@ -2193,11 +2420,11 @@ const create$5$1 = async ({
|
|
|
2193
2420
|
}) => {
|
|
2194
2421
|
// TODO create a commandMap per rpc instance
|
|
2195
2422
|
register(commandMap);
|
|
2196
|
-
const rawIpc = await IpcParentWithMessagePort$1
|
|
2423
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
2197
2424
|
messagePort,
|
|
2198
2425
|
isMessagePortOpen: true
|
|
2199
2426
|
});
|
|
2200
|
-
const ipc = IpcParentWithMessagePort$1
|
|
2427
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
2201
2428
|
handleIpc(ipc);
|
|
2202
2429
|
const rpc = createRpc(ipc);
|
|
2203
2430
|
messagePort.start();
|
|
@@ -2217,18 +2444,24 @@ const PlainMessagePortRpcParent = {
|
|
|
2217
2444
|
create: create$4$1
|
|
2218
2445
|
};
|
|
2219
2446
|
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2447
|
+
// TODO add test
|
|
2448
|
+
const create$D = async ({
|
|
2449
|
+
url,
|
|
2223
2450
|
name,
|
|
2224
|
-
|
|
2451
|
+
port
|
|
2225
2452
|
}) => {
|
|
2226
|
-
|
|
2453
|
+
await ModuleWorkerWithMessagePortRpcParent.create({
|
|
2227
2454
|
url,
|
|
2228
2455
|
name,
|
|
2229
|
-
commandMap:
|
|
2456
|
+
commandMap: {},
|
|
2457
|
+
port
|
|
2230
2458
|
});
|
|
2231
|
-
return
|
|
2459
|
+
return undefined;
|
|
2460
|
+
};
|
|
2461
|
+
|
|
2462
|
+
const IpcParentWithModuleWorkerWithMessagePort = {
|
|
2463
|
+
__proto__: null,
|
|
2464
|
+
create: create$D
|
|
2232
2465
|
};
|
|
2233
2466
|
|
|
2234
2467
|
const Web = 1;
|
|
@@ -2258,6 +2491,75 @@ const getPlatform = () => {
|
|
|
2258
2491
|
};
|
|
2259
2492
|
const platform = getPlatform();
|
|
2260
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
|
+
|
|
2261
2563
|
const getAssetDir = () => {
|
|
2262
2564
|
// @ts-expect-error
|
|
2263
2565
|
if (typeof ASSET_DIR !== 'undefined') {
|
|
@@ -2335,7 +2637,7 @@ const RendererWorker = {
|
|
|
2335
2637
|
state: state$7
|
|
2336
2638
|
};
|
|
2337
2639
|
|
|
2338
|
-
const create$
|
|
2640
|
+
const create$B = async ({
|
|
2339
2641
|
method,
|
|
2340
2642
|
...options
|
|
2341
2643
|
}) => {
|
|
@@ -2345,8 +2647,8 @@ const create$G = async ({
|
|
|
2345
2647
|
}
|
|
2346
2648
|
// TODO rename method
|
|
2347
2649
|
// TODO avoid cyclic dependency
|
|
2348
|
-
const port = get$
|
|
2349
|
-
remove$
|
|
2650
|
+
const port = get$6(options.name);
|
|
2651
|
+
remove$2(options.name);
|
|
2350
2652
|
await invokeAndTransfer('Transferrable.transfer', options.id, port);
|
|
2351
2653
|
return;
|
|
2352
2654
|
}
|
|
@@ -2452,7 +2754,7 @@ const create$Notification = message => {
|
|
|
2452
2754
|
$Notification.textContent = message;
|
|
2453
2755
|
return $Notification;
|
|
2454
2756
|
};
|
|
2455
|
-
const create$
|
|
2757
|
+
const create$A = (type, message) => {
|
|
2456
2758
|
// TODO this pattern might be also useful for activitybar, sidebar etc., creating elements as late as possible, only when actually needed
|
|
2457
2759
|
const $Notification = create$Notification(message);
|
|
2458
2760
|
append$1($Notification);
|
|
@@ -2514,7 +2816,7 @@ const set$6 = (canvasId, canvas) => {
|
|
|
2514
2816
|
const get$4 = id => {
|
|
2515
2817
|
return get$5(id);
|
|
2516
2818
|
};
|
|
2517
|
-
const create$
|
|
2819
|
+
const create$z = async (canvasId, objectId) => {
|
|
2518
2820
|
const canvas = document.createElement('canvas');
|
|
2519
2821
|
const offscreenCanvas = canvas.transferControlToOffscreen();
|
|
2520
2822
|
set$6(canvasId, canvas);
|
|
@@ -2568,7 +2870,7 @@ const DragLeave = 'dragleave';
|
|
|
2568
2870
|
const DragOver = 'dragover';
|
|
2569
2871
|
const DragStart = 'dragstart';
|
|
2570
2872
|
const Drop = 'drop';
|
|
2571
|
-
const Error$
|
|
2873
|
+
const Error$2 = 'error';
|
|
2572
2874
|
const Focus = 'focus';
|
|
2573
2875
|
const FocusIn = 'focusin';
|
|
2574
2876
|
const FocusOut = 'focusout';
|
|
@@ -3718,7 +4020,7 @@ const showError = (message, y, x) => {
|
|
|
3718
4020
|
$ImagePreviewImage
|
|
3719
4021
|
};
|
|
3720
4022
|
};
|
|
3721
|
-
const create$
|
|
4023
|
+
const create$y = (uri, top, left) => {
|
|
3722
4024
|
const $ImagePreviewImage = document.createElement('img');
|
|
3723
4025
|
$ImagePreviewImage.className = 'ImagePreviewImage';
|
|
3724
4026
|
$ImagePreviewImage.src = uri;
|
|
@@ -3749,7 +4051,7 @@ const dispose$i = state => {
|
|
|
3749
4051
|
|
|
3750
4052
|
const ImagePreview$1 = {
|
|
3751
4053
|
__proto__: null,
|
|
3752
|
-
create: create$
|
|
4054
|
+
create: create$y,
|
|
3753
4055
|
dispose: dispose$i,
|
|
3754
4056
|
showError,
|
|
3755
4057
|
update
|
|
@@ -3974,7 +4276,7 @@ const ViewletAudio = {
|
|
|
3974
4276
|
Events: Events$4
|
|
3975
4277
|
};
|
|
3976
4278
|
|
|
3977
|
-
const create$
|
|
4279
|
+
const create$x = () => {
|
|
3978
4280
|
const $Viewlet = document.createElement('div');
|
|
3979
4281
|
$Viewlet.className = 'Viewlet Clock';
|
|
3980
4282
|
return {
|
|
@@ -3991,7 +4293,7 @@ const setTime = (state, time) => {
|
|
|
3991
4293
|
|
|
3992
4294
|
const ViewletClock = {
|
|
3993
4295
|
__proto__: null,
|
|
3994
|
-
create: create$
|
|
4296
|
+
create: create$x,
|
|
3995
4297
|
dispose: dispose$h,
|
|
3996
4298
|
refresh: refresh$4,
|
|
3997
4299
|
setTime
|
|
@@ -4020,7 +4322,7 @@ const stopTracking$1 = ($Target, pointerId, handlePointerMove, handlePointerUp)
|
|
|
4020
4322
|
// TODO use pointerlost event instead
|
|
4021
4323
|
$Target.removeEventListener(PointerUp, handlePointerUp);
|
|
4022
4324
|
};
|
|
4023
|
-
const create$
|
|
4325
|
+
const create$w = (pointerDown, pointerMove, pointerUp) => {
|
|
4024
4326
|
const shared = (fn, event) => {
|
|
4025
4327
|
const message = fn(event);
|
|
4026
4328
|
if (!message || message.length === 0) {
|
|
@@ -4053,7 +4355,7 @@ const create$B = (pointerDown, pointerMove, pointerUp) => {
|
|
|
4053
4355
|
};
|
|
4054
4356
|
|
|
4055
4357
|
const handleOffset = 20;
|
|
4056
|
-
const handleSliderPointerDown = create$
|
|
4358
|
+
const handleSliderPointerDown = create$w(event => {
|
|
4057
4359
|
const {
|
|
4058
4360
|
clientX,
|
|
4059
4361
|
clientY
|
|
@@ -4135,7 +4437,7 @@ const ViewletDebugConsoleEvents = {
|
|
|
4135
4437
|
handleInput: handleInput$6
|
|
4136
4438
|
};
|
|
4137
4439
|
|
|
4138
|
-
const create$
|
|
4440
|
+
const create$v = () => {
|
|
4139
4441
|
const $Viewlet = document.createElement('div');
|
|
4140
4442
|
$Viewlet.className = 'Viewlet DebugConsole';
|
|
4141
4443
|
return {
|
|
@@ -4151,7 +4453,7 @@ const setDom$9 = (state, dom) => {
|
|
|
4151
4453
|
|
|
4152
4454
|
const ViewletDebugConsole = {
|
|
4153
4455
|
__proto__: null,
|
|
4154
|
-
create: create$
|
|
4456
|
+
create: create$v,
|
|
4155
4457
|
setDom: setDom$9
|
|
4156
4458
|
};
|
|
4157
4459
|
|
|
@@ -4212,7 +4514,7 @@ const setMaskImage = ($Element, icon) => {
|
|
|
4212
4514
|
}
|
|
4213
4515
|
};
|
|
4214
4516
|
|
|
4215
|
-
const create$
|
|
4517
|
+
const create$u = icon => {
|
|
4216
4518
|
const $Icon = document.createElement('div');
|
|
4217
4519
|
$Icon.className = 'MaskIcon';
|
|
4218
4520
|
setMaskImage($Icon, icon);
|
|
@@ -4222,7 +4524,7 @@ const create$z = icon => {
|
|
|
4222
4524
|
|
|
4223
4525
|
const create$Button = (label, icon) => {
|
|
4224
4526
|
// TODO icon div might not be needed (unnecessary html element)
|
|
4225
|
-
const $Icon = create$
|
|
4527
|
+
const $Icon = create$u(icon);
|
|
4226
4528
|
const $Button = document.createElement('button');
|
|
4227
4529
|
$Button.className = 'IconButton';
|
|
4228
4530
|
$Button.title = label;
|
|
@@ -4243,7 +4545,7 @@ const handleClick$4 = event => {
|
|
|
4243
4545
|
handleClick$5(index);
|
|
4244
4546
|
};
|
|
4245
4547
|
|
|
4246
|
-
const create$
|
|
4548
|
+
const create$t = () => {
|
|
4247
4549
|
const $DialogTitle = document.createElement('h2');
|
|
4248
4550
|
$DialogTitle.id = 'DialogTitle';
|
|
4249
4551
|
const $DialogCloseButton = create$Button('Close', 'Close');
|
|
@@ -4324,7 +4626,7 @@ const setErrorStack = (state, errorStack) => {
|
|
|
4324
4626
|
|
|
4325
4627
|
const ViewletDialog = {
|
|
4326
4628
|
__proto__: null,
|
|
4327
|
-
create: create$
|
|
4629
|
+
create: create$t,
|
|
4328
4630
|
postAppend,
|
|
4329
4631
|
setButtons,
|
|
4330
4632
|
setCodeFrame,
|
|
@@ -4387,7 +4689,7 @@ const handleContextMenu$8 = event => {
|
|
|
4387
4689
|
} = event;
|
|
4388
4690
|
return ['handleContextMenu', button, clientX, clientY];
|
|
4389
4691
|
};
|
|
4390
|
-
const handleSashCornerPointerDown = create$
|
|
4692
|
+
const handleSashCornerPointerDown = create$w(event => {
|
|
4391
4693
|
const {
|
|
4392
4694
|
clientX,
|
|
4393
4695
|
clientY
|
|
@@ -4736,7 +5038,7 @@ const setNegativeMargin = (state, negativeMargin) => {
|
|
|
4736
5038
|
setTop($ListItems, negativeMargin);
|
|
4737
5039
|
};
|
|
4738
5040
|
|
|
4739
|
-
const create$
|
|
5041
|
+
const create$s = () => {
|
|
4740
5042
|
const $ListItems = document.createElement('div');
|
|
4741
5043
|
$ListItems.className = 'ListItems';
|
|
4742
5044
|
$ListItems.role = ListBox;
|
|
@@ -4820,7 +5122,7 @@ const setBounds$8 = (state, x, y, width, height) => {
|
|
|
4820
5122
|
const ViewletEditorCompletion = {
|
|
4821
5123
|
__proto__: null,
|
|
4822
5124
|
attachEvents: attachEvents$9,
|
|
4823
|
-
create: create$
|
|
5125
|
+
create: create$s,
|
|
4824
5126
|
dispose: dispose$f,
|
|
4825
5127
|
handleError: handleError$7,
|
|
4826
5128
|
setBounds: setBounds$8,
|
|
@@ -4843,7 +5145,7 @@ const ViewletEditorCompletionDetailsEvents = {
|
|
|
4843
5145
|
returnValue: returnValue$5
|
|
4844
5146
|
};
|
|
4845
5147
|
|
|
4846
|
-
const create$
|
|
5148
|
+
const create$r = () => {
|
|
4847
5149
|
const $Viewlet = document.createElement('div');
|
|
4848
5150
|
$Viewlet.className = 'Viewlet EditorCompletionDetails';
|
|
4849
5151
|
$Viewlet.id = 'CompletionsDetails';
|
|
@@ -4884,7 +5186,7 @@ const ViewletEditorCompletionDetails = {
|
|
|
4884
5186
|
Events: ViewletEditorCompletionDetailsEvents,
|
|
4885
5187
|
appendWidget: appendWidget$4,
|
|
4886
5188
|
attachEvents: attachEvents$8,
|
|
4887
|
-
create: create$
|
|
5189
|
+
create: create$r,
|
|
4888
5190
|
dispose: dispose$e,
|
|
4889
5191
|
setBounds: setBounds$7,
|
|
4890
5192
|
setDom: setDom$7
|
|
@@ -4903,7 +5205,7 @@ const ViewletEditorCompletionDetails = {
|
|
|
4903
5205
|
|
|
4904
5206
|
// TODO aria alert
|
|
4905
5207
|
|
|
4906
|
-
const create$
|
|
5208
|
+
const create$q = () => {
|
|
4907
5209
|
const $Viewlet = document.createElement('div');
|
|
4908
5210
|
$Viewlet.className = 'Viewlet EditorError';
|
|
4909
5211
|
return {
|
|
@@ -4925,13 +5227,13 @@ const setBounds$6 = (state, x, y, width, height) => {
|
|
|
4925
5227
|
|
|
4926
5228
|
const ViewletEditorError = {
|
|
4927
5229
|
__proto__: null,
|
|
4928
|
-
create: create$
|
|
5230
|
+
create: create$q,
|
|
4929
5231
|
setBounds: setBounds$6,
|
|
4930
5232
|
setDom: setDom$6
|
|
4931
5233
|
};
|
|
4932
5234
|
|
|
4933
5235
|
const returnValue$4 = true;
|
|
4934
|
-
const handleSashPointerDown$2 = create$
|
|
5236
|
+
const handleSashPointerDown$2 = create$w(event => {
|
|
4935
5237
|
const {
|
|
4936
5238
|
clientX,
|
|
4937
5239
|
clientY
|
|
@@ -5084,7 +5386,7 @@ const handleFocus$7 = event => {
|
|
|
5084
5386
|
handleFocus$9(uid);
|
|
5085
5387
|
};
|
|
5086
5388
|
|
|
5087
|
-
const create$
|
|
5389
|
+
const create$p = () => {
|
|
5088
5390
|
const $Viewlet = document.createElement('div');
|
|
5089
5391
|
$Viewlet.className = 'Viewlet EditorImage';
|
|
5090
5392
|
return {
|
|
@@ -5101,7 +5403,7 @@ const attachEvents$7 = state => {
|
|
|
5101
5403
|
[ContextMenu]: handleContextMenu$6,
|
|
5102
5404
|
[FocusIn]: handleFocus$7
|
|
5103
5405
|
});
|
|
5104
|
-
$Viewlet.addEventListener(Error$
|
|
5406
|
+
$Viewlet.addEventListener(Error$2, handleError$6, Capture);
|
|
5105
5407
|
$Viewlet.addEventListener(Wheel, handleWheel$1, Passive);
|
|
5106
5408
|
};
|
|
5107
5409
|
const setTransform = (state, transform) => {
|
|
@@ -5127,13 +5429,13 @@ const setDom$4 = (state, dom) => {
|
|
|
5127
5429
|
const ViewletEditorImage = {
|
|
5128
5430
|
__proto__: null,
|
|
5129
5431
|
attachEvents: attachEvents$7,
|
|
5130
|
-
create: create$
|
|
5432
|
+
create: create$p,
|
|
5131
5433
|
setDom: setDom$4,
|
|
5132
5434
|
setDragging,
|
|
5133
5435
|
setTransform
|
|
5134
5436
|
};
|
|
5135
5437
|
|
|
5136
|
-
const create$
|
|
5438
|
+
const create$o = () => {
|
|
5137
5439
|
const $Viewlet = document.createElement('div');
|
|
5138
5440
|
$Viewlet.className = 'Viewlet EditorText';
|
|
5139
5441
|
$Viewlet.textContent = 'loading...';
|
|
@@ -5150,7 +5452,7 @@ const refresh$3 = (state, context) => {
|
|
|
5150
5452
|
|
|
5151
5453
|
const ViewletEditorPlainText = {
|
|
5152
5454
|
__proto__: null,
|
|
5153
|
-
create: create$
|
|
5455
|
+
create: create$o,
|
|
5154
5456
|
dispose: dispose$d,
|
|
5155
5457
|
refresh: refresh$3
|
|
5156
5458
|
};
|
|
@@ -5444,7 +5746,7 @@ const handlePaste = event => {
|
|
|
5444
5746
|
const text = getText(clipboardData);
|
|
5445
5747
|
return ['paste', text];
|
|
5446
5748
|
};
|
|
5447
|
-
const handleScrollBarVerticalPointerDown = create$
|
|
5749
|
+
const handleScrollBarVerticalPointerDown = create$w(event => {
|
|
5448
5750
|
const {
|
|
5449
5751
|
clientY
|
|
5450
5752
|
} = event;
|
|
@@ -5567,7 +5869,7 @@ const setLineInfos = (state, dom) => {
|
|
|
5567
5869
|
// 1. create -> only create dom elements
|
|
5568
5870
|
// 2. render -> fill elements with attributes and data
|
|
5569
5871
|
// that way all dom nodes can be recycled
|
|
5570
|
-
const create$
|
|
5872
|
+
const create$n = () => {
|
|
5571
5873
|
const $EditorInput = document.createElement('textarea');
|
|
5572
5874
|
$EditorInput.className = 'EditorInput';
|
|
5573
5875
|
$EditorInput.ariaAutoComplete = List;
|
|
@@ -5734,7 +6036,7 @@ const setDecorationsDom$1 = (state, decorations) => {
|
|
|
5734
6036
|
setDecorationsDom$2(state, decorations);
|
|
5735
6037
|
};
|
|
5736
6038
|
|
|
5737
|
-
const create$
|
|
6039
|
+
const create$m = create$n;
|
|
5738
6040
|
const setText$1 = setText$2;
|
|
5739
6041
|
const setSelections = setSelections$1;
|
|
5740
6042
|
const setIncrementalEdits = setIncrementalEdits$1;
|
|
@@ -5776,7 +6078,7 @@ const setDecorationsDom = setDecorationsDom$1;
|
|
|
5776
6078
|
|
|
5777
6079
|
const ViewletEditorText = {
|
|
5778
6080
|
__proto__: null,
|
|
5779
|
-
create: create$
|
|
6081
|
+
create: create$m,
|
|
5780
6082
|
focus: focus$e,
|
|
5781
6083
|
handleError: handleError$5,
|
|
5782
6084
|
hideOverlayMessage,
|
|
@@ -5792,7 +6094,7 @@ const ViewletEditorText = {
|
|
|
5792
6094
|
showOverlayMessage
|
|
5793
6095
|
};
|
|
5794
6096
|
|
|
5795
|
-
const create$
|
|
6097
|
+
const create$l = () => {
|
|
5796
6098
|
const $Viewlet = document.createElement('div');
|
|
5797
6099
|
$Viewlet.className = 'Viewlet EditorTextError';
|
|
5798
6100
|
return {
|
|
@@ -5808,11 +6110,11 @@ const setMessage$4 = (state, message) => {
|
|
|
5808
6110
|
|
|
5809
6111
|
const ViewletEditorTextError = {
|
|
5810
6112
|
__proto__: null,
|
|
5811
|
-
create: create$
|
|
6113
|
+
create: create$l,
|
|
5812
6114
|
setMessage: setMessage$4
|
|
5813
6115
|
};
|
|
5814
6116
|
|
|
5815
|
-
const create$
|
|
6117
|
+
const create$k = () => {
|
|
5816
6118
|
const $Viewlet = document.createElement('div');
|
|
5817
6119
|
$Viewlet.className = 'Viewlet EditorWidgetError EditorOverlayMessage';
|
|
5818
6120
|
return {
|
|
@@ -5835,12 +6137,12 @@ const setBounds$3 = (state, x, y, width, height) => {
|
|
|
5835
6137
|
|
|
5836
6138
|
const ViewletEditorWidgetError = {
|
|
5837
6139
|
__proto__: null,
|
|
5838
|
-
create: create$
|
|
6140
|
+
create: create$k,
|
|
5839
6141
|
setBounds: setBounds$3,
|
|
5840
6142
|
setMessage: setMessage$3
|
|
5841
6143
|
};
|
|
5842
6144
|
|
|
5843
|
-
const create$
|
|
6145
|
+
const create$j = () => {
|
|
5844
6146
|
const $Viewlet = document.createElement('div');
|
|
5845
6147
|
$Viewlet.dataset.viewlet = 'Empty';
|
|
5846
6148
|
$Viewlet.className = 'Viewlet';
|
|
@@ -5854,13 +6156,13 @@ const dispose$b = state => {};
|
|
|
5854
6156
|
|
|
5855
6157
|
const ViewletEmpty = {
|
|
5856
6158
|
__proto__: null,
|
|
5857
|
-
create: create$
|
|
6159
|
+
create: create$j,
|
|
5858
6160
|
dispose: dispose$b,
|
|
5859
6161
|
focus: focus$d,
|
|
5860
6162
|
refresh: refresh$2
|
|
5861
6163
|
};
|
|
5862
6164
|
|
|
5863
|
-
const create$
|
|
6165
|
+
const create$i = () => {
|
|
5864
6166
|
const $Viewlet = document.createElement('div');
|
|
5865
6167
|
$Viewlet.className = 'Viewlet EmptyEditor';
|
|
5866
6168
|
return {
|
|
@@ -5870,10 +6172,10 @@ const create$n = () => {
|
|
|
5870
6172
|
|
|
5871
6173
|
const ViewletEmptyEditor = {
|
|
5872
6174
|
__proto__: null,
|
|
5873
|
-
create: create$
|
|
6175
|
+
create: create$i
|
|
5874
6176
|
};
|
|
5875
6177
|
|
|
5876
|
-
const create$
|
|
6178
|
+
const create$h = () => {
|
|
5877
6179
|
const $Viewlet = document.createElement('div');
|
|
5878
6180
|
$Viewlet.className = 'Viewlet Error';
|
|
5879
6181
|
return {
|
|
@@ -5889,7 +6191,7 @@ const setMessage$2 = (state, message) => {
|
|
|
5889
6191
|
|
|
5890
6192
|
const ViewletError = {
|
|
5891
6193
|
__proto__: null,
|
|
5892
|
-
create: create$
|
|
6194
|
+
create: create$h,
|
|
5893
6195
|
setMessage: setMessage$2
|
|
5894
6196
|
};
|
|
5895
6197
|
|
|
@@ -6001,7 +6303,7 @@ const handleTouchEnd = event => {
|
|
|
6001
6303
|
|
|
6002
6304
|
// based on https://github.com/microsoft/vscode/blob/main/src/vs/workbench/contrib/extensions/browser/extensionsList.ts (License MIT)
|
|
6003
6305
|
|
|
6004
|
-
const create$
|
|
6306
|
+
const create$g = () => {
|
|
6005
6307
|
const $ExtensionHeader = document.createElement('div');
|
|
6006
6308
|
$ExtensionHeader.className = 'ExtensionHeader';
|
|
6007
6309
|
|
|
@@ -6146,7 +6448,7 @@ const ViewletExtensions = {
|
|
|
6146
6448
|
__proto__: null,
|
|
6147
6449
|
attachEvents: attachEvents$6,
|
|
6148
6450
|
closeSuggest,
|
|
6149
|
-
create: create$
|
|
6451
|
+
create: create$g,
|
|
6150
6452
|
dispose: dispose$a,
|
|
6151
6453
|
focus: focus$c,
|
|
6152
6454
|
handleError: handleError$4,
|
|
@@ -6251,7 +6553,7 @@ const ViewletFindWidgetEvents = {
|
|
|
6251
6553
|
returnValue: returnValue$3
|
|
6252
6554
|
};
|
|
6253
6555
|
|
|
6254
|
-
const create$
|
|
6556
|
+
const create$f = () => {
|
|
6255
6557
|
const $Viewlet = document.createElement('div');
|
|
6256
6558
|
$Viewlet.className = 'Viewlet FindWidget';
|
|
6257
6559
|
$Viewlet.role = Group;
|
|
@@ -6314,7 +6616,7 @@ const ViewletFindWidget = {
|
|
|
6314
6616
|
__proto__: null,
|
|
6315
6617
|
Events: Events$3,
|
|
6316
6618
|
appendWidget: appendWidget$1,
|
|
6317
|
-
create: create$
|
|
6619
|
+
create: create$f,
|
|
6318
6620
|
dispose: dispose$9,
|
|
6319
6621
|
focus: focus$b,
|
|
6320
6622
|
setBounds: setBounds$2,
|
|
@@ -6969,7 +7271,7 @@ const handleBlur$3 = () => {
|
|
|
6969
7271
|
const handleKeyDown$1 = handleKeyDown$2;
|
|
6970
7272
|
const handleKeyUp = handleKeyUp$1;
|
|
6971
7273
|
|
|
6972
|
-
const create$
|
|
7274
|
+
const create$e = () => {
|
|
6973
7275
|
// TODO use aria role splitter once supported https://github.com/w3c/aria/issues/1348
|
|
6974
7276
|
const $SashSideBar = document.createElement('div');
|
|
6975
7277
|
$SashSideBar.className = 'Viewlet Sash SashVertical';
|
|
@@ -7025,7 +7327,7 @@ const setSashes = (state, sashSideBar, sashPanel) => {
|
|
|
7025
7327
|
const ViewletLayout = {
|
|
7026
7328
|
__proto__: null,
|
|
7027
7329
|
attachEvents: attachEvents$5,
|
|
7028
|
-
create: create$
|
|
7330
|
+
create: create$e,
|
|
7029
7331
|
setSashes
|
|
7030
7332
|
};
|
|
7031
7333
|
|
|
@@ -7120,7 +7422,7 @@ const handleContextMenu$3 = event => {
|
|
|
7120
7422
|
};
|
|
7121
7423
|
|
|
7122
7424
|
// TODO Main should not be bound to Editor -> Lazy load Editor
|
|
7123
|
-
const create$
|
|
7425
|
+
const create$d = () => {
|
|
7124
7426
|
const $Viewlet = document.createElement('div');
|
|
7125
7427
|
$Viewlet.id = 'Main';
|
|
7126
7428
|
$Viewlet.className = 'Viewlet Main';
|
|
@@ -7220,7 +7522,7 @@ const ViewletMain = {
|
|
|
7220
7522
|
attachEvents: attachEvents$4,
|
|
7221
7523
|
closeAllViewlets,
|
|
7222
7524
|
closeViewletAndTab,
|
|
7223
|
-
create: create$
|
|
7525
|
+
create: create$d,
|
|
7224
7526
|
dispose: dispose$8,
|
|
7225
7527
|
focus: focus$9,
|
|
7226
7528
|
highlightDragOver,
|
|
@@ -7297,7 +7599,7 @@ const handleTabsContextMenu = event => {
|
|
|
7297
7599
|
handleTabContextMenu(uid, clientX, clientY);
|
|
7298
7600
|
};
|
|
7299
7601
|
|
|
7300
|
-
const create$
|
|
7602
|
+
const create$c = () => {
|
|
7301
7603
|
const $MainTabs = document.createElement('div');
|
|
7302
7604
|
$MainTabs.className = 'Viewlet MainTabs';
|
|
7303
7605
|
$MainTabs.role = TabList;
|
|
@@ -7346,7 +7648,7 @@ const setHighlight = (state, highlightLeft) => {
|
|
|
7346
7648
|
const ViewletMainTabs = {
|
|
7347
7649
|
__proto__: null,
|
|
7348
7650
|
attachEvents: attachEvents$3,
|
|
7349
|
-
create: create$
|
|
7651
|
+
create: create$c,
|
|
7350
7652
|
setHighlight,
|
|
7351
7653
|
setScrollLeft,
|
|
7352
7654
|
setTabsDom: setTabsDom$2
|
|
@@ -7369,7 +7671,7 @@ const EditorPlainText = 'EditorPlainText';
|
|
|
7369
7671
|
const EditorText = 'Editor';
|
|
7370
7672
|
const EditorWidgetError = 'EditorWidgetError';
|
|
7371
7673
|
const Empty = 'Empty';
|
|
7372
|
-
const Error$
|
|
7674
|
+
const Error$1 = 'Error';
|
|
7373
7675
|
const Extensions = 'Extensions';
|
|
7374
7676
|
const FindWidget = 'FindWidget';
|
|
7375
7677
|
const ImagePreview = 'ImagePreview';
|
|
@@ -7407,7 +7709,7 @@ const EditorTextError = 'EditorTextError';
|
|
|
7407
7709
|
const EditorRename = 'EditorRename';
|
|
7408
7710
|
const EditorCodeGenerator = 'EditorCodeGenerator';
|
|
7409
7711
|
|
|
7410
|
-
const create$
|
|
7712
|
+
const create$b = () => {
|
|
7411
7713
|
const $ViewletOutputContent = document.createElement('div');
|
|
7412
7714
|
$ViewletOutputContent.className = 'OutputContent';
|
|
7413
7715
|
$ViewletOutputContent.role = Log;
|
|
@@ -7459,7 +7761,7 @@ const dispose$7 = state => {};
|
|
|
7459
7761
|
const ViewletOutput = {
|
|
7460
7762
|
__proto__: null,
|
|
7461
7763
|
clear: clear$1,
|
|
7462
|
-
create: create$
|
|
7764
|
+
create: create$b,
|
|
7463
7765
|
dispose: dispose$7,
|
|
7464
7766
|
disposeFindWidget,
|
|
7465
7767
|
focus: focus$8,
|
|
@@ -7520,7 +7822,7 @@ const UiStrings = {
|
|
|
7520
7822
|
Close: 'Close',
|
|
7521
7823
|
Maximize: 'Maximize'
|
|
7522
7824
|
};
|
|
7523
|
-
const create$
|
|
7825
|
+
const create$a = () => {
|
|
7524
7826
|
const $PanelTabs = document.createElement('div');
|
|
7525
7827
|
$PanelTabs.className = 'PanelTabs';
|
|
7526
7828
|
$PanelTabs.role = TabList;
|
|
@@ -7633,7 +7935,7 @@ const setActionsDom$1 = (state, actions, childUid) => {
|
|
|
7633
7935
|
const ViewletPanel = {
|
|
7634
7936
|
__proto__: null,
|
|
7635
7937
|
attachEvents: attachEvents$2,
|
|
7636
|
-
create: create$
|
|
7938
|
+
create: create$a,
|
|
7637
7939
|
dispose: dispose$6,
|
|
7638
7940
|
focus: focus$7,
|
|
7639
7941
|
setActionsDom: setActionsDom$1,
|
|
@@ -7724,7 +8026,7 @@ const handleLoadedMetaData = event => {
|
|
|
7724
8026
|
target.play();
|
|
7725
8027
|
};
|
|
7726
8028
|
|
|
7727
|
-
const create$
|
|
8029
|
+
const create$9 = () => {
|
|
7728
8030
|
const $Viewlet = document.createElement('div');
|
|
7729
8031
|
$Viewlet.className = 'Viewlet ScreenCapture';
|
|
7730
8032
|
return {
|
|
@@ -7744,7 +8046,7 @@ const setScreenCapture = (state, id) => {
|
|
|
7744
8046
|
|
|
7745
8047
|
const ViewletScreenCapture = {
|
|
7746
8048
|
__proto__: null,
|
|
7747
|
-
create: create$
|
|
8049
|
+
create: create$9,
|
|
7748
8050
|
setScreenCapture
|
|
7749
8051
|
};
|
|
7750
8052
|
|
|
@@ -7764,7 +8066,7 @@ const handleHeaderClick = event => {
|
|
|
7764
8066
|
}
|
|
7765
8067
|
};
|
|
7766
8068
|
|
|
7767
|
-
const create$
|
|
8069
|
+
const create$8 = () => {
|
|
7768
8070
|
const $SideBarTitleAreaTitle = document.createElement('h2');
|
|
7769
8071
|
$SideBarTitleAreaTitle.className = 'SideBarTitleAreaTitle';
|
|
7770
8072
|
const $SideBarTitleArea = document.createElement('div');
|
|
@@ -7828,7 +8130,7 @@ const focus$5 = async () => {
|
|
|
7828
8130
|
const ViewletSideBar = {
|
|
7829
8131
|
__proto__: null,
|
|
7830
8132
|
attachEvents: attachEvents$1,
|
|
7831
|
-
create: create$
|
|
8133
|
+
create: create$8,
|
|
7832
8134
|
dispose: dispose$5,
|
|
7833
8135
|
focus: focus$5,
|
|
7834
8136
|
setActionsDom,
|
|
@@ -8029,7 +8331,7 @@ const ViewletStatusBarEvents = {
|
|
|
8029
8331
|
handleClick: handleClick$2
|
|
8030
8332
|
};
|
|
8031
8333
|
|
|
8032
|
-
const create$
|
|
8334
|
+
const create$7 = () => {
|
|
8033
8335
|
const $Viewlet = document.createElement('div');
|
|
8034
8336
|
$Viewlet.id = 'StatusBar';
|
|
8035
8337
|
$Viewlet.className = 'Viewlet StatusBar';
|
|
@@ -8058,7 +8360,7 @@ const focus$3 = state => {
|
|
|
8058
8360
|
|
|
8059
8361
|
const ViewletStatusBar = {
|
|
8060
8362
|
__proto__: null,
|
|
8061
|
-
create: create$
|
|
8363
|
+
create: create$7,
|
|
8062
8364
|
focus: focus$3,
|
|
8063
8365
|
setDom: setDom$2
|
|
8064
8366
|
};
|
|
@@ -8089,7 +8391,7 @@ const handleClickTab = event => {
|
|
|
8089
8391
|
handleClickTab$2(uid, index);
|
|
8090
8392
|
};
|
|
8091
8393
|
|
|
8092
|
-
const create$
|
|
8394
|
+
const create$6 = () => {
|
|
8093
8395
|
const $Viewlet = document.createElement('div');
|
|
8094
8396
|
$Viewlet.className = 'Viewlet Terminals';
|
|
8095
8397
|
return {
|
|
@@ -8116,7 +8418,7 @@ const setTabsDom = (state, dom) => {
|
|
|
8116
8418
|
|
|
8117
8419
|
const ViewletTerminals = {
|
|
8118
8420
|
__proto__: null,
|
|
8119
|
-
create: create$
|
|
8421
|
+
create: create$6,
|
|
8120
8422
|
setTabsDom
|
|
8121
8423
|
};
|
|
8122
8424
|
|
|
@@ -8130,7 +8432,7 @@ const handleContextMenu$1 = event => {
|
|
|
8130
8432
|
return ['handleContextMenu', button, clientX, clientY];
|
|
8131
8433
|
};
|
|
8132
8434
|
|
|
8133
|
-
const create$
|
|
8435
|
+
const create$5 = () => {
|
|
8134
8436
|
// TODO set aria label for title bar menu
|
|
8135
8437
|
// TODO add tests for aria properties
|
|
8136
8438
|
const $Viewlet = document.createElement('div');
|
|
@@ -8166,7 +8468,7 @@ const setFocused = (state, isFocused) => {
|
|
|
8166
8468
|
const ViewletTitleBar = {
|
|
8167
8469
|
__proto__: null,
|
|
8168
8470
|
attachEvents,
|
|
8169
|
-
create: create$
|
|
8471
|
+
create: create$5,
|
|
8170
8472
|
setFocused
|
|
8171
8473
|
};
|
|
8172
8474
|
|
|
@@ -8541,7 +8843,7 @@ const ViewletTitleBarMenuBar = {
|
|
|
8541
8843
|
setMenus
|
|
8542
8844
|
};
|
|
8543
8845
|
|
|
8544
|
-
const create$
|
|
8846
|
+
const create$4 = () => {
|
|
8545
8847
|
const $Viewlet = document.createElement('div');
|
|
8546
8848
|
$Viewlet.className = 'Viewlet TitleBarTitle';
|
|
8547
8849
|
return {
|
|
@@ -8557,7 +8859,7 @@ const setDom$1 = (state, dom) => {
|
|
|
8557
8859
|
|
|
8558
8860
|
const ViewletTitleBarTitle = {
|
|
8559
8861
|
__proto__: null,
|
|
8560
|
-
create: create$
|
|
8862
|
+
create: create$4,
|
|
8561
8863
|
setDom: setDom$1
|
|
8562
8864
|
};
|
|
8563
8865
|
|
|
@@ -8743,7 +9045,7 @@ const load$1 = moduleId => {
|
|
|
8743
9045
|
return ViewletEditorWidgetError;
|
|
8744
9046
|
case Empty:
|
|
8745
9047
|
return ViewletEmpty;
|
|
8746
|
-
case Error$
|
|
9048
|
+
case Error$1:
|
|
8747
9049
|
return ViewletError;
|
|
8748
9050
|
case Extensions:
|
|
8749
9051
|
return ViewletExtensions;
|
|
@@ -8820,7 +9122,7 @@ const load$1 = moduleId => {
|
|
|
8820
9122
|
}
|
|
8821
9123
|
};
|
|
8822
9124
|
|
|
8823
|
-
const create$
|
|
9125
|
+
const create$3 = (id, uid = id) => {
|
|
8824
9126
|
const module = state$1.modules[id];
|
|
8825
9127
|
if (!module) {
|
|
8826
9128
|
throw new Error(`module not found: ${id}`);
|
|
@@ -9081,7 +9383,7 @@ const sendMultiple = commands => {
|
|
|
9081
9383
|
}
|
|
9082
9384
|
case 'Viewlet.create':
|
|
9083
9385
|
{
|
|
9084
|
-
create$
|
|
9386
|
+
create$3(viewletId, method);
|
|
9085
9387
|
break;
|
|
9086
9388
|
}
|
|
9087
9389
|
case 'Viewlet.createFunctionalRoot':
|
|
@@ -9139,6 +9441,10 @@ const sendMultiple = commands => {
|
|
|
9139
9441
|
case 'Viewlet.addKeyBindings':
|
|
9140
9442
|
addKeyBindings(viewletId, method);
|
|
9141
9443
|
break;
|
|
9444
|
+
case 'Viewlet.setProperty':
|
|
9445
|
+
// @ts-ignore
|
|
9446
|
+
setProperty(viewletId, method, ...args);
|
|
9447
|
+
break;
|
|
9142
9448
|
case 'Viewlet.removeKeyBindings':
|
|
9143
9449
|
removeKeyBindings(viewletId);
|
|
9144
9450
|
break;
|
|
@@ -9327,7 +9633,7 @@ const appendToBody = childId => {
|
|
|
9327
9633
|
const getFn = command => {
|
|
9328
9634
|
switch (command) {
|
|
9329
9635
|
case 'Viewlet.create':
|
|
9330
|
-
return create$
|
|
9636
|
+
return create$3;
|
|
9331
9637
|
case 'Viewlet.send':
|
|
9332
9638
|
return invoke;
|
|
9333
9639
|
case 'Viewlet.show':
|
|
@@ -9370,6 +9676,8 @@ const getFn = command => {
|
|
|
9370
9676
|
return setDragData;
|
|
9371
9677
|
case 'Viewlet.focusSelector':
|
|
9372
9678
|
return focusSelector;
|
|
9679
|
+
case 'Viewlet.setProperty':
|
|
9680
|
+
return setProperty;
|
|
9373
9681
|
case 'Css.addCssStyleSheet':
|
|
9374
9682
|
case 'Viewlet.addCss':
|
|
9375
9683
|
case 'Viewlet.setCss':
|
|
@@ -9403,6 +9711,15 @@ const setBounds$1 = (id, left, top, width, height) => {
|
|
|
9403
9711
|
const $Viewlet = instance.state.$Viewlet;
|
|
9404
9712
|
setBounds$a($Viewlet, left, top, width, height);
|
|
9405
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
|
+
};
|
|
9406
9723
|
|
|
9407
9724
|
const LocalStorage = 1;
|
|
9408
9725
|
const SessionStorage = 2;
|
|
@@ -9506,29 +9823,9 @@ const handleMessagePort = async port => {
|
|
|
9506
9823
|
|
|
9507
9824
|
const set = ($Iframe, permissionPolicy) => {
|
|
9508
9825
|
if (permissionPolicy === undefined) {
|
|
9509
|
-
return;
|
|
9510
|
-
}
|
|
9511
|
-
$Iframe.allow = permissionPolicy;
|
|
9512
|
-
};
|
|
9513
|
-
|
|
9514
|
-
const withResolvers = () => {
|
|
9515
|
-
/**
|
|
9516
|
-
* @type {any}
|
|
9517
|
-
*/
|
|
9518
|
-
let _resolve;
|
|
9519
|
-
/**
|
|
9520
|
-
* @type {any}
|
|
9521
|
-
*/
|
|
9522
|
-
let _reject;
|
|
9523
|
-
const promise = new Promise((resolve, reject) => {
|
|
9524
|
-
_resolve = resolve;
|
|
9525
|
-
_reject = reject;
|
|
9526
|
-
});
|
|
9527
|
-
return {
|
|
9528
|
-
resolve: _resolve,
|
|
9529
|
-
reject: _reject,
|
|
9530
|
-
promise
|
|
9531
|
-
};
|
|
9826
|
+
return;
|
|
9827
|
+
}
|
|
9828
|
+
$Iframe.allow = permissionPolicy;
|
|
9532
9829
|
};
|
|
9533
9830
|
|
|
9534
9831
|
const waitForFrameToLoad = $Frame => {
|
|
@@ -9543,7 +9840,7 @@ const waitForFrameToLoad = $Frame => {
|
|
|
9543
9840
|
};
|
|
9544
9841
|
|
|
9545
9842
|
// TODO could use browser view when running in electron
|
|
9546
|
-
const create$
|
|
9843
|
+
const create$2 = async (uid, src, sandbox, csp, credentialless, permissionPolicy, title) => {
|
|
9547
9844
|
const $Iframe = document.createElement('iframe');
|
|
9548
9845
|
setIframeCredentialless($Iframe, credentialless);
|
|
9549
9846
|
setIframeCsp($Iframe, csp);
|
|
@@ -9624,7 +9921,7 @@ const commandMap = {
|
|
|
9624
9921
|
'GetFilePathElectron.getFilePathElectron': getFilePathElectron,
|
|
9625
9922
|
'HandleMessagePort.handleMessagePort': handleMessagePort,
|
|
9626
9923
|
'InitData.getInitData': getInitData,
|
|
9627
|
-
'IpcParent.create': create$
|
|
9924
|
+
'IpcParent.create': create$B,
|
|
9628
9925
|
'KeyBindings.setIdentifiers': setIdentifiers,
|
|
9629
9926
|
'Layout.getBounds': getBounds,
|
|
9630
9927
|
'Location.getHref': getHref,
|
|
@@ -9639,10 +9936,10 @@ const commandMap = {
|
|
|
9639
9936
|
'Menu.showControlled': showControlled,
|
|
9640
9937
|
'Menu.showMenu': showMenu,
|
|
9641
9938
|
'Meta.setThemeColor': setThemeColor,
|
|
9642
|
-
'Notification.create': create$
|
|
9939
|
+
'Notification.create': create$A,
|
|
9643
9940
|
'Notification.createWithOptions': createWithOptions,
|
|
9644
9941
|
'Notification.dispose': dispose$j,
|
|
9645
|
-
'OffscreenCanvas.create': create$
|
|
9942
|
+
'OffscreenCanvas.create': create$z,
|
|
9646
9943
|
'Open.openUrl': openUrl,
|
|
9647
9944
|
'Performance.getMemory': getMemory,
|
|
9648
9945
|
'Performance.measureUserAgentSpecificMemory': measureUserAgentSpecificMemory,
|
|
@@ -9681,7 +9978,7 @@ const commandMap = {
|
|
|
9681
9978
|
'WebStorage.setItem': setItem,
|
|
9682
9979
|
'WebStorage.setJsonObjects': setJsonObjects,
|
|
9683
9980
|
'WebView.appendOnly': appendOnly,
|
|
9684
|
-
'WebView.create': create$
|
|
9981
|
+
'WebView.create': create$2,
|
|
9685
9982
|
'WebView.dispose': dispose$2,
|
|
9686
9983
|
'WebView.load': load,
|
|
9687
9984
|
'WebView.loadOnly': loadOnly,
|
|
@@ -9718,7 +10015,7 @@ const getConfiguredEditorWorkerUrl = () => {
|
|
|
9718
10015
|
const editorWorkerUrl = getConfiguredEditorWorkerUrl() || `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/editor-worker/dist/editorWorkerMain.js`;
|
|
9719
10016
|
|
|
9720
10017
|
const launchEditorWorker = async port => {
|
|
9721
|
-
const ipc = await create$
|
|
10018
|
+
const ipc = await create$B({
|
|
9722
10019
|
name: 'Editor Worker',
|
|
9723
10020
|
url: editorWorkerUrl,
|
|
9724
10021
|
method: ModuleWorkerWithMessagePort,
|
|
@@ -9734,12 +10031,10 @@ const hydrate$2 = async () => {
|
|
|
9734
10031
|
} = new MessageChannel();
|
|
9735
10032
|
// TODO only launch port and send to renderer worker
|
|
9736
10033
|
const promise = launchEditorWorker(port1);
|
|
9737
|
-
set$
|
|
10034
|
+
set$7('Editor Worker', port2);
|
|
9738
10035
|
await promise;
|
|
9739
10036
|
};
|
|
9740
10037
|
|
|
9741
|
-
const isElectron = platform === Electron;
|
|
9742
|
-
|
|
9743
10038
|
const getConfiguredExtensionHostWorkerUrl = () => {
|
|
9744
10039
|
return getConfiguredWorkerUrl('extensionHostWorkerUrl');
|
|
9745
10040
|
};
|
|
@@ -9748,7 +10043,7 @@ const extensionHostWorkerUrl = getConfiguredExtensionHostWorkerUrl() || `${asset
|
|
|
9748
10043
|
|
|
9749
10044
|
const launchExtensionHostWorker = async port => {
|
|
9750
10045
|
const name = isElectron ? 'Extension Host (Electron)' : 'Extension Host';
|
|
9751
|
-
const ipc = await create$
|
|
10046
|
+
const ipc = await create$B({
|
|
9752
10047
|
name,
|
|
9753
10048
|
url: extensionHostWorkerUrl,
|
|
9754
10049
|
method: ModuleWorkerWithMessagePort,
|
|
@@ -9765,14 +10060,14 @@ const hydrate$1 = async () => {
|
|
|
9765
10060
|
// TODO only launch port and send to renderer worker
|
|
9766
10061
|
const promise = launchExtensionHostWorker(port1);
|
|
9767
10062
|
const name = isElectron ? 'Extension Host (Electron)' : 'Extension Host';
|
|
9768
|
-
set$
|
|
10063
|
+
set$7(name, port2);
|
|
9769
10064
|
await promise;
|
|
9770
10065
|
};
|
|
9771
10066
|
|
|
9772
10067
|
const syntaxHighlightingWorkerUrl = `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/syntax-highlighting-worker/dist/syntaxHighlightingWorkerMain.js`;
|
|
9773
10068
|
|
|
9774
10069
|
const launchSyntaxHighlightingWorker = async port => {
|
|
9775
|
-
const ipc = await create$
|
|
10070
|
+
const ipc = await create$B({
|
|
9776
10071
|
name: 'Syntax Highlighting Worker',
|
|
9777
10072
|
url: syntaxHighlightingWorkerUrl,
|
|
9778
10073
|
method: ModuleWorkerWithMessagePort,
|
|
@@ -9788,7 +10083,7 @@ const hydrate = async () => {
|
|
|
9788
10083
|
} = new MessageChannel();
|
|
9789
10084
|
// TODO only launch port and send to renderer worker
|
|
9790
10085
|
const promise = launchSyntaxHighlightingWorker(port1);
|
|
9791
|
-
set$
|
|
10086
|
+
set$7('Syntax Highlighting Worker', port2);
|
|
9792
10087
|
await promise;
|
|
9793
10088
|
};
|
|
9794
10089
|
|
|
@@ -9857,13 +10152,6 @@ const ViewletEditorRename = {
|
|
|
9857
10152
|
const handleContentSecurityPolicyViolation = event => {
|
|
9858
10153
|
};
|
|
9859
10154
|
|
|
9860
|
-
const NewLine = '\n';
|
|
9861
|
-
|
|
9862
|
-
const splitLines = lines => {
|
|
9863
|
-
string(lines);
|
|
9864
|
-
return lines.split(NewLine);
|
|
9865
|
-
};
|
|
9866
|
-
|
|
9867
10155
|
const RE_AT = /^\s+at/;
|
|
9868
10156
|
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
9869
10157
|
const RE_OBJECT_AS = /^\s*at Object\.\w+ \[as ([\w.]+)]/;
|
|
@@ -9940,7 +10228,7 @@ const mergeCustom = (custom, relevantStack) => {
|
|
|
9940
10228
|
};
|
|
9941
10229
|
const cleanStack = stack => {
|
|
9942
10230
|
string(stack);
|
|
9943
|
-
const lines = splitLines(stack);
|
|
10231
|
+
const lines = splitLines$2(stack);
|
|
9944
10232
|
const {
|
|
9945
10233
|
custom,
|
|
9946
10234
|
actualStack
|
|
@@ -9975,10 +10263,6 @@ const getIsFirefox = () => {
|
|
|
9975
10263
|
*/
|
|
9976
10264
|
const isFirefox = getIsFirefox();
|
|
9977
10265
|
|
|
9978
|
-
const joinLines = lines => {
|
|
9979
|
-
return lines.join(NewLine);
|
|
9980
|
-
};
|
|
9981
|
-
|
|
9982
10266
|
const getErrorMessage = error => {
|
|
9983
10267
|
if (!error) {
|
|
9984
10268
|
return `Error: ${error}`;
|
|
@@ -10002,7 +10286,7 @@ const prepareErrorMessageWithCodeFrame = error => {
|
|
|
10002
10286
|
}
|
|
10003
10287
|
const message = getErrorMessage(error);
|
|
10004
10288
|
const lines = cleanStack(error.stack);
|
|
10005
|
-
const relevantStack = joinLines(lines);
|
|
10289
|
+
const relevantStack = joinLines$2(lines);
|
|
10006
10290
|
if (error.codeFrame) {
|
|
10007
10291
|
return {
|
|
10008
10292
|
message,
|
|
@@ -10186,275 +10470,6 @@ const main = async () => {
|
|
|
10186
10470
|
|
|
10187
10471
|
main();
|
|
10188
10472
|
|
|
10189
|
-
const Message = 'message';
|
|
10190
|
-
const Error$1 = 'error';
|
|
10191
|
-
|
|
10192
|
-
const getFirstEvent = (eventTarget, eventMap) => {
|
|
10193
|
-
const {
|
|
10194
|
-
resolve,
|
|
10195
|
-
promise
|
|
10196
|
-
} = withResolvers();
|
|
10197
|
-
const listenerMap = Object.create(null);
|
|
10198
|
-
const cleanup = value => {
|
|
10199
|
-
for (const event of Object.keys(eventMap)) {
|
|
10200
|
-
eventTarget.removeEventListener(event, listenerMap[event]);
|
|
10201
|
-
}
|
|
10202
|
-
resolve(value);
|
|
10203
|
-
};
|
|
10204
|
-
for (const [event, type] of Object.entries(eventMap)) {
|
|
10205
|
-
const listener = event => {
|
|
10206
|
-
cleanup({
|
|
10207
|
-
type,
|
|
10208
|
-
event
|
|
10209
|
-
});
|
|
10210
|
-
};
|
|
10211
|
-
eventTarget.addEventListener(event, listener);
|
|
10212
|
-
listenerMap[event] = listener;
|
|
10213
|
-
}
|
|
10214
|
-
return promise;
|
|
10215
|
-
};
|
|
10216
|
-
|
|
10217
|
-
/**
|
|
10218
|
-
*
|
|
10219
|
-
* @param {Worker} worker
|
|
10220
|
-
* @returns
|
|
10221
|
-
*/
|
|
10222
|
-
const getFirstWorkerEvent = worker => {
|
|
10223
|
-
return getFirstEvent(worker, {
|
|
10224
|
-
message: Message,
|
|
10225
|
-
error: Error$1
|
|
10226
|
-
});
|
|
10227
|
-
};
|
|
10228
|
-
|
|
10229
|
-
const transferrables = [];
|
|
10230
|
-
if (typeof MessagePort !== 'undefined') {
|
|
10231
|
-
transferrables.push(MessagePort);
|
|
10232
|
-
}
|
|
10233
|
-
if (typeof OffscreenCanvas !== 'undefined') {
|
|
10234
|
-
transferrables.push(OffscreenCanvas);
|
|
10235
|
-
}
|
|
10236
|
-
|
|
10237
|
-
const isTransferrable = value => {
|
|
10238
|
-
for (const fn of transferrables) {
|
|
10239
|
-
if (value instanceof fn) {
|
|
10240
|
-
return true;
|
|
10241
|
-
}
|
|
10242
|
-
}
|
|
10243
|
-
return false;
|
|
10244
|
-
};
|
|
10245
|
-
|
|
10246
|
-
const walkValue = (value, transferrables) => {
|
|
10247
|
-
if (!value) {
|
|
10248
|
-
return;
|
|
10249
|
-
}
|
|
10250
|
-
if (isTransferrable(value)) {
|
|
10251
|
-
transferrables.push(value);
|
|
10252
|
-
}
|
|
10253
|
-
if (Array.isArray(value)) {
|
|
10254
|
-
for (const item of value) {
|
|
10255
|
-
walkValue(item, transferrables);
|
|
10256
|
-
}
|
|
10257
|
-
return;
|
|
10258
|
-
}
|
|
10259
|
-
if (typeof value === 'object') {
|
|
10260
|
-
for (const property of Object.values(value)) {
|
|
10261
|
-
walkValue(property, transferrables);
|
|
10262
|
-
}
|
|
10263
|
-
}
|
|
10264
|
-
};
|
|
10265
|
-
|
|
10266
|
-
const getTransfer = value => {
|
|
10267
|
-
const transferrables = [];
|
|
10268
|
-
walkValue(value, transferrables);
|
|
10269
|
-
return transferrables;
|
|
10270
|
-
};
|
|
10271
|
-
|
|
10272
|
-
class IpcError extends Error {
|
|
10273
|
-
constructor(message) {
|
|
10274
|
-
super(message);
|
|
10275
|
-
this.name = 'IpcError';
|
|
10276
|
-
}
|
|
10277
|
-
}
|
|
10278
|
-
|
|
10279
|
-
const isErrorEvent = event => {
|
|
10280
|
-
return event instanceof ErrorEvent;
|
|
10281
|
-
};
|
|
10282
|
-
|
|
10283
|
-
class WorkerError extends Error {
|
|
10284
|
-
constructor(event) {
|
|
10285
|
-
super(event.message);
|
|
10286
|
-
const stackLines = splitLines(this.stack);
|
|
10287
|
-
const relevantLines = stackLines.slice(1);
|
|
10288
|
-
const relevant = joinLines(relevantLines);
|
|
10289
|
-
this.stack = `${event.message}
|
|
10290
|
-
at Module (${event.filename}:${event.lineno}:${event.colno})
|
|
10291
|
-
${relevant}`;
|
|
10292
|
-
}
|
|
10293
|
-
}
|
|
10294
|
-
|
|
10295
|
-
const Module = 'module';
|
|
10296
|
-
|
|
10297
|
-
const getWorkerDisplayName = name => {
|
|
10298
|
-
if (name && name.endsWith('Worker')) {
|
|
10299
|
-
return name;
|
|
10300
|
-
}
|
|
10301
|
-
return `${name} worker`;
|
|
10302
|
-
};
|
|
10303
|
-
const create$6 = async ({
|
|
10304
|
-
url,
|
|
10305
|
-
name
|
|
10306
|
-
}) => {
|
|
10307
|
-
const worker = new Worker(url, {
|
|
10308
|
-
type: Module,
|
|
10309
|
-
name
|
|
10310
|
-
});
|
|
10311
|
-
// @ts-expect-error
|
|
10312
|
-
const {
|
|
10313
|
-
type,
|
|
10314
|
-
event
|
|
10315
|
-
} = await getFirstWorkerEvent(worker);
|
|
10316
|
-
switch (type) {
|
|
10317
|
-
case Message:
|
|
10318
|
-
if (event.data !== 'ready') {
|
|
10319
|
-
throw new IpcError('unexpected first message from worker');
|
|
10320
|
-
}
|
|
10321
|
-
break;
|
|
10322
|
-
case Error$1:
|
|
10323
|
-
if (isErrorEvent(event)) {
|
|
10324
|
-
throw new WorkerError(event);
|
|
10325
|
-
}
|
|
10326
|
-
const displayName = getWorkerDisplayName(name);
|
|
10327
|
-
throw new IpcError(`Failed to start ${displayName}`);
|
|
10328
|
-
}
|
|
10329
|
-
return worker;
|
|
10330
|
-
};
|
|
10331
|
-
const getData = event => {
|
|
10332
|
-
// TODO why are some events not instance of message event?
|
|
10333
|
-
if (event instanceof MessageEvent) {
|
|
10334
|
-
return event.data;
|
|
10335
|
-
}
|
|
10336
|
-
return event;
|
|
10337
|
-
};
|
|
10338
|
-
const wrap = worker => {
|
|
10339
|
-
let handleMessage;
|
|
10340
|
-
return {
|
|
10341
|
-
get onmessage() {
|
|
10342
|
-
return handleMessage;
|
|
10343
|
-
},
|
|
10344
|
-
set onmessage(listener) {
|
|
10345
|
-
if (listener) {
|
|
10346
|
-
handleMessage = event => {
|
|
10347
|
-
const data = getData(event);
|
|
10348
|
-
listener({
|
|
10349
|
-
data,
|
|
10350
|
-
target: this
|
|
10351
|
-
});
|
|
10352
|
-
};
|
|
10353
|
-
} else {
|
|
10354
|
-
handleMessage = null;
|
|
10355
|
-
}
|
|
10356
|
-
worker.onmessage = handleMessage;
|
|
10357
|
-
},
|
|
10358
|
-
send(message) {
|
|
10359
|
-
worker.postMessage(message);
|
|
10360
|
-
},
|
|
10361
|
-
sendAndTransfer(message) {
|
|
10362
|
-
const transfer = getTransfer(message);
|
|
10363
|
-
worker.postMessage(message, transfer);
|
|
10364
|
-
}
|
|
10365
|
-
};
|
|
10366
|
-
};
|
|
10367
|
-
|
|
10368
|
-
const IpcParentWithModuleWorker = {
|
|
10369
|
-
__proto__: null,
|
|
10370
|
-
create: create$6,
|
|
10371
|
-
wrap
|
|
10372
|
-
};
|
|
10373
|
-
|
|
10374
|
-
const isMessagePort = value => {
|
|
10375
|
-
return value instanceof MessagePort;
|
|
10376
|
-
};
|
|
10377
|
-
|
|
10378
|
-
const create$5 = async ({
|
|
10379
|
-
url
|
|
10380
|
-
}) => {
|
|
10381
|
-
string(url);
|
|
10382
|
-
const portPromise = await new Promise(resolve => {
|
|
10383
|
-
globalThis.acceptPort = resolve;
|
|
10384
|
-
});
|
|
10385
|
-
await import(url);
|
|
10386
|
-
const port = await portPromise;
|
|
10387
|
-
delete globalThis.acceptPort;
|
|
10388
|
-
if (!port) {
|
|
10389
|
-
throw new IpcError('port must be defined');
|
|
10390
|
-
}
|
|
10391
|
-
if (!isMessagePort(port)) {
|
|
10392
|
-
throw new IpcError('port must be of type MessagePort');
|
|
10393
|
-
}
|
|
10394
|
-
return port;
|
|
10395
|
-
};
|
|
10396
|
-
|
|
10397
|
-
const IpcParentWithMessagePort = {
|
|
10398
|
-
__proto__: null,
|
|
10399
|
-
create: create$5
|
|
10400
|
-
};
|
|
10401
|
-
|
|
10402
|
-
const create$4 = async url => {
|
|
10403
|
-
const referencePort = await new Promise(resolve => {
|
|
10404
|
-
globalThis.acceptReferencePort = resolve;
|
|
10405
|
-
import(url);
|
|
10406
|
-
});
|
|
10407
|
-
delete globalThis.acceptReferencePort;
|
|
10408
|
-
return referencePort;
|
|
10409
|
-
};
|
|
10410
|
-
|
|
10411
|
-
const IpcParentWithReferencePort = {
|
|
10412
|
-
__proto__: null,
|
|
10413
|
-
create: create$4
|
|
10414
|
-
};
|
|
10415
|
-
|
|
10416
|
-
// TODO add test
|
|
10417
|
-
const create$3 = async ({
|
|
10418
|
-
url,
|
|
10419
|
-
name,
|
|
10420
|
-
port
|
|
10421
|
-
}) => {
|
|
10422
|
-
await ModuleWorkerWithMessagePortRpcParent.create({
|
|
10423
|
-
url,
|
|
10424
|
-
name,
|
|
10425
|
-
commandMap: {},
|
|
10426
|
-
port
|
|
10427
|
-
});
|
|
10428
|
-
return undefined;
|
|
10429
|
-
};
|
|
10430
|
-
|
|
10431
|
-
const IpcParentWithModuleWorkerWithMessagePort = {
|
|
10432
|
-
__proto__: null,
|
|
10433
|
-
create: create$3
|
|
10434
|
-
};
|
|
10435
|
-
|
|
10436
|
-
// TODO use handleIncomingIpc function
|
|
10437
|
-
const create$2 = async ({
|
|
10438
|
-
port,
|
|
10439
|
-
ipcId
|
|
10440
|
-
}) => {
|
|
10441
|
-
number(ipcId);
|
|
10442
|
-
if (!isElectron) {
|
|
10443
|
-
throw new Error('Electron api was requested but is not available');
|
|
10444
|
-
}
|
|
10445
|
-
const rpc = await ElectronWindowRpcClient.create({
|
|
10446
|
-
commandMap: {},
|
|
10447
|
-
window
|
|
10448
|
-
});
|
|
10449
|
-
const webContentsIds = await rpc.invokeAndTransfer('CreateMessagePort.createMessagePort', ipcId, port);
|
|
10450
|
-
return webContentsIds;
|
|
10451
|
-
};
|
|
10452
|
-
|
|
10453
|
-
const IpcParentWithElectron = {
|
|
10454
|
-
__proto__: null,
|
|
10455
|
-
create: create$2
|
|
10456
|
-
};
|
|
10457
|
-
|
|
10458
10473
|
const isUint8Array = value => {
|
|
10459
10474
|
return value instanceof Uint8Array;
|
|
10460
10475
|
};
|